FileDocCategorySizeDatePackage
GenericBooleanParameter.javaAPI DocAzureus 3.0.3.45066Tue Jul 10 00:10:06 BST 2007org.gudy.azureus2.ui.swt.config.generic

GenericBooleanParameter

public class GenericBooleanParameter extends Object
author
Olivier

Fields Summary
protected static final boolean
DEBUG
GenericParameterAdapter
adapter
String
name
org.eclipse.swt.widgets.Button
checkBox
boolean
defaultValue
List
performers
Constructors Summary
public GenericBooleanParameter(GenericParameterAdapter adapter, org.eclipse.swt.widgets.Composite composite, String name)


	  
			     
		this(adapter, composite, name, adapter.getBooleanValue(name), null, null);
	
public GenericBooleanParameter(GenericParameterAdapter adapter, org.eclipse.swt.widgets.Composite composite, String name, String textKey)

		this(adapter, composite, name, adapter.getBooleanValue(name), textKey, null);
	
public GenericBooleanParameter(GenericParameterAdapter adapter, org.eclipse.swt.widgets.Composite composite, String name, boolean defaultValue, String textKey)

		this(adapter, composite, name, defaultValue, textKey, null);
	
public GenericBooleanParameter(GenericParameterAdapter adapter, org.eclipse.swt.widgets.Composite composite, String name, boolean defaultValue)

		this(adapter, composite, name, defaultValue, null, null);
	
public GenericBooleanParameter(GenericParameterAdapter _adapter, org.eclipse.swt.widgets.Composite composite, String _name, boolean _defaultValue, String textKey, org.gudy.azureus2.ui.swt.config.IAdditionalActionPerformer actionPerformer)

		adapter = _adapter;
		name = _name;
		defaultValue = _defaultValue;
		if (actionPerformer != null) {
			performers.add(actionPerformer);
		}
		boolean value = adapter.getBooleanValue(name, defaultValue);
		checkBox = new Button(composite, SWT.CHECK);
		if (textKey != null)
			Messages.setLanguageText(checkBox, textKey);
		checkBox.setSelection(value);

		checkBox.addListener(SWT.Selection, new Listener() {
			public void handleEvent(Event event) {
				setSelected(checkBox.getSelection(), true);
			}
		});
	
Methods Summary
private voiddebug(java.lang.String string)

		System.out.println("[GenericBooleanParameter:" + name + "] " + string);
	
public org.eclipse.swt.widgets.ControlgetControl()

		return checkBox;
	
public java.lang.StringgetName()

		return name;
	
public booleanisSelected()

		return adapter.getBooleanValue(name);
	
public voidsetAdditionalActionPerformer(org.gudy.azureus2.ui.swt.config.IAdditionalActionPerformer actionPerformer)

		performers.add(actionPerformer);
		actionPerformer.setSelected(isSelected());
		actionPerformer.performAction();
	
public voidsetLayoutData(java.lang.Object layoutData)

		checkBox.setLayoutData(layoutData);
	
public voidsetName(java.lang.String newName)

		name = newName;
	
public voidsetSelected(boolean selected)

		Utils.execSWTThread(new AERunnable() {
			public void runSupport() {
				if (!checkBox.isDisposed()) {
					if (checkBox.getSelection() != selected) {
						if (DEBUG) {
							debug("bool.setSelection(" + selected + ")");
						}
						checkBox.setSelection(selected);
					}
					if (DEBUG) {
						debug("setBooleanValue to " + checkBox.getSelection()
								+ " via setValue(int)");
					}
					adapter.setBooleanValue(name, checkBox.getSelection());
				} else {
					adapter.setBooleanValue(name, selected);
				}

				if (performers.size() > 0) {

					for (int i = 0; i < performers.size(); i++) {

						IAdditionalActionPerformer performer = (IAdditionalActionPerformer) performers.get(i);

						performer.setSelected(selected);

						performer.performAction();
					}
				}

				adapter.informChanged(false);
			}
		});
	
protected voidsetSelected(boolean selected, boolean force)

		if (force) {
			setSelected(selected);
		} else {
			Utils.execSWTThread(new AERunnable() {
				public void runSupport() {
					if (checkBox.getSelection() != selected) {
						checkBox.setSelection(selected);
					}
				}
			});
		}