X-Git-Url: http://git.phpeclipse.com diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/wizards/dialogfields/CheckedListDialogField.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/wizards/dialogfields/CheckedListDialogField.java index 755815f..fe748f9 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/wizards/dialogfields/CheckedListDialogField.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/wizards/dialogfields/CheckedListDialogField.java @@ -26,89 +26,92 @@ import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Table; /** - * A list with checkboxes and a button bar. Typical buttons are 'Check All' and 'Uncheck All'. - * List model is independend of widget creation. - * DialogFields controls are: Label, List and Composite containing buttons. + * A list with checkboxes and a button bar. Typical buttons are 'Check All' and + * 'Uncheck All'. List model is independend of widget creation. DialogFields + * controls are: Label, List and Composite containing buttons. */ public class CheckedListDialogField extends ListDialogField { - + private int fCheckAllButtonIndex; + private int fUncheckAllButtonIndex; - + private List fCheckElements; - public CheckedListDialogField(IListAdapter adapter, String[] customButtonLabels, ILabelProvider lprovider) { + public CheckedListDialogField(IListAdapter adapter, + String[] customButtonLabels, ILabelProvider lprovider) { super(adapter, customButtonLabels, lprovider); - fCheckElements= new ArrayList(); - - fCheckAllButtonIndex= -1; - fUncheckAllButtonIndex= -1; + fCheckElements = new ArrayList(); + + fCheckAllButtonIndex = -1; + fUncheckAllButtonIndex = -1; } /** - * Sets the index of the 'check' button in the button label array passed in the constructor. - * The behaviour of the button marked as the check button will then be handled internally. - * (enable state, button invocation behaviour) - */ + * Sets the index of the 'check' button in the button label array passed in + * the constructor. The behaviour of the button marked as the check button + * will then be handled internally. (enable state, button invocation + * behaviour) + */ public void setCheckAllButtonIndex(int checkButtonIndex) { Assert.isTrue(checkButtonIndex < fButtonLabels.length); - fCheckAllButtonIndex= checkButtonIndex; + fCheckAllButtonIndex = checkButtonIndex; } /** - * Sets the index of the 'uncheck' button in the button label array passed in the constructor. - * The behaviour of the button marked as the uncheck button will then be handled internally. - * (enable state, button invocation behaviour) - */ + * Sets the index of the 'uncheck' button in the button label array passed + * in the constructor. The behaviour of the button marked as the uncheck + * button will then be handled internally. (enable state, button invocation + * behaviour) + */ public void setUncheckAllButtonIndex(int uncheckButtonIndex) { Assert.isTrue(uncheckButtonIndex < fButtonLabels.length); - fUncheckAllButtonIndex= uncheckButtonIndex; + fUncheckAllButtonIndex = uncheckButtonIndex; } - /* * @see ListDialogField#createTableViewer */ protected TableViewer createTableViewer(Composite parent) { - Table table= new Table(parent, SWT.CHECK + getListStyle()); - CheckboxTableViewer tableViewer= new CheckboxTableViewer(table); + Table table = new Table(parent, SWT.CHECK + getListStyle()); + CheckboxTableViewer tableViewer = new CheckboxTableViewer(table); tableViewer.addCheckStateListener(new ICheckStateListener() { public void checkStateChanged(CheckStateChangedEvent e) { doCheckStateChanged(e); } }); return tableViewer; - } - - + } + /* * @see ListDialogField#getListControl */ public Control getListControl(Composite parent) { - Control control= super.getListControl(parent); + Control control = super.getListControl(parent); if (parent != null) { - ((CheckboxTableViewer)fTable).setCheckedElements(fCheckElements.toArray()); + ((CheckboxTableViewer) fTable).setCheckedElements(fCheckElements + .toArray()); } return control; - } - + } + /* - * @see DialogField#dialogFieldChanged - * Hooks in to get element changes to update check model. + * @see DialogField#dialogFieldChanged Hooks in to get element changes to + * update check model. */ public void dialogFieldChanged() { - for (int i= fCheckElements.size() -1; i >= 0; i--) { + for (int i = fCheckElements.size() - 1; i >= 0; i--) { if (!fElements.contains(fCheckElements.get(i))) { fCheckElements.remove(i); } } super.dialogFieldChanged(); - } - + } + private void checkStateChanged() { - //call super and do not update check model + // call super and do not update check model super.dialogFieldChanged(); - } + } /** * Gets the checked elements. @@ -116,72 +119,72 @@ public class CheckedListDialogField extends ListDialogField { public List getCheckedElements() { return new ArrayList(fCheckElements); } - + /** * Returns true if the element is checked. */ public boolean isChecked(Object obj) { return fCheckElements.contains(obj); - } - + } + /** * Sets the checked elements. - */ + */ public void setCheckedElements(List list) { - fCheckElements= new ArrayList(list); + fCheckElements = new ArrayList(list); if (fTable != null) { - ((CheckboxTableViewer)fTable).setCheckedElements(list.toArray()); + ((CheckboxTableViewer) fTable).setCheckedElements(list.toArray()); } checkStateChanged(); } /** * Sets the checked state of an element. - */ + */ public void setChecked(Object object, boolean state) { setCheckedWithoutUpdate(object, state); checkStateChanged(); } - + /** - * Sets the checked state of an element. No dialog changed listener is informed. - */ + * Sets the checked state of an element. No dialog changed listener is + * informed. + */ public void setCheckedWithoutUpdate(Object object, boolean state) { if (!fCheckElements.contains(object)) { fCheckElements.add(object); } if (fTable != null) { - ((CheckboxTableViewer)fTable).setChecked(object, state); + ((CheckboxTableViewer) fTable).setChecked(object, state); } } /** * Sets the check state of all elements - */ + */ public void checkAll(boolean state) { if (state) { - fCheckElements= getElements(); + fCheckElements = getElements(); } else { fCheckElements.clear(); } if (fTable != null) { - ((CheckboxTableViewer)fTable).setAllChecked(state); + ((CheckboxTableViewer) fTable).setAllChecked(state); } checkStateChanged(); } - - + private void doCheckStateChanged(CheckStateChangedEvent e) { if (e.getChecked()) { fCheckElements.add(e.getElement()); } else { fCheckElements.remove(e.getElement()); - } + } checkStateChanged(); } - + // ------ enable / disable management - + /* * @see ListDialogField#getManagedButtonState */ @@ -192,11 +195,11 @@ public class CheckedListDialogField extends ListDialogField { return !fElements.isEmpty(); } return super.getManagedButtonState(sel, index); - } + } /* * @see ListDialogField#extraButtonPressed - */ + */ protected boolean managedButtonPressed(int index) { if (index == fCheckAllButtonIndex) { checkAll(true); @@ -207,9 +210,5 @@ public class CheckedListDialogField extends ListDialogField { } return true; } - - - - }