Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonah Graham2018-11-20 16:20:42 +0000
committerJonah Graham2018-11-22 21:47:02 +0000
commit170e654b4796bad1453ae85a427b97317d67a69a (patch)
tree6ca9b8a8fedd5fd25f97eb79c408312e256ff981 /core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields
parent35996a5c5ca5c254959ba48241eaada6dbf8628d (diff)
downloadorg.eclipse.cdt-170e654b4796bad1453ae85a427b97317d67a69a.tar.gz
org.eclipse.cdt-170e654b4796bad1453ae85a427b97317d67a69a.tar.xz
org.eclipse.cdt-170e654b4796bad1453ae85a427b97317d67a69a.zip
Bug 540373: Cleanup: Format & Remove trailing whitespace
This was done by selecting all projects in Eclipse then Source -> Clean Up... -> choosing: - Format source code - Remove trailing white spaces on all lines and completing the wizard Change-Id: I63685372c6bcc67719bcf145123bcb72e5b00394
Diffstat (limited to 'core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields')
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/CheckedListDialogField.java82
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/ComboDialogField.java128
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/DialogField.java119
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/IDialogFieldListener.java2
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/IListAdapter.java10
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/IStringButtonAdapter.java2
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/ITreeListAdapter.java6
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/LayoutUtil.java88
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/LinkToFileGroup.java147
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/ListDialogField.java517
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/SelectionButtonDialogField.java96
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/SelectionButtonDialogFieldGroup.java170
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/Separator.java49
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/StringButtonDialogField.java77
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/StringDialogField.java90
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/TreeListDialogField.java18
16 files changed, 791 insertions, 810 deletions
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/CheckedListDialogField.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/CheckedListDialogField.java
index 80fc3dee1ba..cacac52cb17 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/CheckedListDialogField.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/CheckedListDialogField.java
@@ -37,41 +37,41 @@ import org.eclipse.swt.widgets.Table;
public class CheckedListDialogField<T> extends ListDialogField<T> {
private int fCheckAllButtonIndex;
private int fUncheckAllButtonIndex;
-
+
private List<T> fCheckElements;
public CheckedListDialogField(IListAdapter<T> adapter, String[] customButtonLabels, IBaseLabelProvider lprovider) {
super(adapter, customButtonLabels, lprovider);
- fCheckElements= new ArrayList<T>();
-
- fCheckAllButtonIndex= -1;
- fUncheckAllButtonIndex= -1;
+ fCheckElements = new ArrayList<T>();
+
+ 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)
- */
+ */
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)
- */
+ */
public void setUncheckAllButtonIndex(int uncheckButtonIndex) {
Assert.isTrue(uncheckButtonIndex < fButtonLabels.length);
- fUncheckAllButtonIndex= uncheckButtonIndex;
+ fUncheckAllButtonIndex = uncheckButtonIndex;
}
@Override
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() {
@Override
public void checkStateChanged(CheckStateChangedEvent e) {
@@ -79,35 +79,35 @@ public class CheckedListDialogField<T> extends ListDialogField<T> {
}
});
return tableViewer;
- }
+ }
@Override
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.
*/
@Override
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
super.dialogFieldChanged();
- }
+ }
/**
* Gets the checked elements.
@@ -115,43 +115,43 @@ public class CheckedListDialogField<T> extends ListDialogField<T> {
public List<T> getCheckedElements() {
return new ArrayList<T>(fCheckElements);
}
-
+
/**
* Returns the number of checked elements.
*/
public int getCheckedSize() {
return fCheckElements.size();
}
-
+
/**
* Returns true if the element is checked.
*/
public boolean isChecked(Object obj) {
return fCheckElements.contains(obj);
- }
-
+ }
+
/**
* Sets the checked elements.
- */
+ */
public void setCheckedElements(Collection<T> list) {
- fCheckElements= new ArrayList<T>(list);
+ fCheckElements = new ArrayList<T>(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(T object, boolean state) {
setCheckedWithoutUpdate(object, state);
checkStateChanged();
}
-
+
/**
* Sets the checked state of an element. No dialog changed listener is informed.
- */
+ */
public void setCheckedWithoutUpdate(T object, boolean state) {
if (state) {
if (!fCheckElements.contains(object)) {
@@ -167,10 +167,10 @@ public class CheckedListDialogField<T> extends ListDialogField<T> {
/**
* Sets the check state of all elements
- */
+ */
public void checkAll(boolean state) {
if (state) {
- fCheckElements= getElements();
+ fCheckElements = getElements();
} else {
fCheckElements.clear();
}
@@ -179,27 +179,27 @@ public class CheckedListDialogField<T> extends ListDialogField<T> {
}
checkStateChanged();
}
-
+
void doCheckStateChanged(CheckStateChangedEvent e) {
if (e.getChecked()) {
@SuppressWarnings("unchecked")
- T elem= (T) e.getElement();
+ T elem = (T) e.getElement();
fCheckElements.add(elem);
} else {
fCheckElements.remove(e.getElement());
- }
+ }
checkStateChanged();
}
-
+
@Override
public void replaceElement(T oldElement, T newElement) throws IllegalArgumentException {
- boolean wasChecked= isChecked(oldElement);
+ boolean wasChecked = isChecked(oldElement);
super.replaceElement(oldElement, newElement);
setChecked(newElement, wasChecked);
}
-
+
// ------ enable / disable management
-
+
/*
* @see ListDialogField#getManagedButtonState
*/
@@ -211,11 +211,11 @@ public class CheckedListDialogField<T> extends ListDialogField<T> {
return !fElements.isEmpty();
}
return super.getManagedButtonState(sel, index);
- }
+ }
/*
* @see ListDialogField#extraButtonPressed
- */
+ */
@Override
protected boolean managedButtonPressed(int index) {
if (index == fCheckAllButtonIndex) {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/ComboDialogField.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/ComboDialogField.java
index 3ba8783d190..36008944e1a 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/ComboDialogField.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/ComboDialogField.java
@@ -27,57 +27,57 @@ import org.eclipse.swt.widgets.Label;
* Dialog field containing a label and a combo control.
*/
public class ComboDialogField extends DialogField {
-
+
private String fText;
private int fSelectionIndex;
private String[] fItems;
private Combo fComboControl;
private ModifyListener fModifyListener;
private int fFlags;
-
+
public ComboDialogField(int flags) {
super();
- fText= ""; //$NON-NLS-1$
- fItems= new String[0];
- fFlags= flags;
- fSelectionIndex= -1;
+ fText = ""; //$NON-NLS-1$
+ fItems = new String[0];
+ fFlags = flags;
+ fSelectionIndex = -1;
}
-
+
// ------- layout helpers
-
+
/*
* @see DialogField#doFillIntoGrid
*/
@Override
public Control[] doFillIntoGrid(Composite parent, int nColumns) {
assertEnoughColumns(nColumns);
-
- Label label= getLabelControl(parent);
+
+ Label label = getLabelControl(parent);
label.setLayoutData(gridDataForLabel(1));
- Combo combo= getComboControl(parent);
+ Combo combo = getComboControl(parent);
combo.setLayoutData(gridDataForCombo(nColumns - 1));
-
+
return new Control[] { label, combo };
- }
+ }
/*
* @see DialogField#getNumberOfControls
*/
@Override
public int getNumberOfControls() {
- return 2;
+ return 2;
}
-
+
protected static GridData gridDataForCombo(int span) {
- GridData gd= new GridData();
- gd.horizontalAlignment= GridData.FILL;
- gd.grabExcessHorizontalSpace= false;
- gd.horizontalSpan= span;
+ GridData gd = new GridData();
+ gd.horizontalAlignment = GridData.FILL;
+ gd.grabExcessHorizontalSpace = false;
+ gd.horizontalSpan = span;
return gd;
- }
-
+ }
+
// ------- focus methods
-
+
/*
* @see DialogField#setFocus
*/
@@ -88,34 +88,35 @@ public class ComboDialogField extends DialogField {
}
return true;
}
-
- // ------- ui creation
+
+ // ------- ui creation
/**
* Creates or returns the created combo control.
* @param parent The parent composite or <code>null</code> when the widget has
* already been created.
- */
+ */
public Combo getComboControl(Composite parent) {
if (fComboControl == null) {
assertCompositeNotNull(parent);
- fModifyListener= new ModifyListener() {
+ fModifyListener = new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
doModifyText(e);
}
};
- SelectionListener selectionListener= new SelectionListener() {
+ SelectionListener selectionListener = new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
doSelectionChanged(e);
}
-
+
@Override
- public void widgetDefaultSelected(SelectionEvent e) { }
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
};
-
- fComboControl= new Combo(parent, fFlags);
+
+ fComboControl = new Combo(parent, fFlags);
// moved up due to 1GEUNW2
fComboControl.setItems(fItems);
if (fSelectionIndex != -1) {
@@ -129,107 +130,106 @@ public class ComboDialogField extends DialogField {
fComboControl.setEnabled(isEnabled());
}
return fComboControl;
- }
-
+ }
+
protected void doModifyText(ModifyEvent e) {
if (isOkToUse(fComboControl)) {
- fText= fComboControl.getText();
- fSelectionIndex= fComboControl.getSelectionIndex();
+ fText = fComboControl.getText();
+ fSelectionIndex = fComboControl.getSelectionIndex();
}
dialogFieldChanged();
}
-
+
protected void doSelectionChanged(SelectionEvent e) {
if (isOkToUse(fComboControl)) {
- fItems= fComboControl.getItems();
- fText= fComboControl.getText();
- fSelectionIndex= fComboControl.getSelectionIndex();
+ fItems = fComboControl.getItems();
+ fText = fComboControl.getText();
+ fSelectionIndex = fComboControl.getSelectionIndex();
}
- dialogFieldChanged();
+ dialogFieldChanged();
}
-
+
// ------ enable / disable management
-
+
/*
* @see DialogField#updateEnableState
- */
+ */
@Override
protected void updateEnableState() {
- super.updateEnableState();
+ super.updateEnableState();
if (isOkToUse(fComboControl)) {
fComboControl.setEnabled(isEnabled());
- }
- }
-
- // ------ text access
-
+ }
+ }
+
+ // ------ text access
+
/**
* Gets the combo items.
- */
+ */
public String[] getItems() {
return fItems;
}
-
+
/**
* Sets the combo items. Triggers a dialog-changed event.
*/
public void setItems(String[] items) {
- fItems= items;
+ fItems = items;
if (isOkToUse(fComboControl)) {
fComboControl.setItems(items);
}
dialogFieldChanged();
}
-
+
/**
* Gets the text.
- */
+ */
public String getText() {
return fText;
}
-
+
/**
* Sets the text. Triggers a dialog-changed event.
*/
public void setText(String text) {
- fText= text;
+ fText = text;
if (isOkToUse(fComboControl)) {
fComboControl.setText(text);
} else {
dialogFieldChanged();
- }
+ }
}
/**
* Selects an item.
- */
+ */
public void selectItem(int index) {
if (isOkToUse(fComboControl)) {
fComboControl.select(index);
} else {
if (index >= 0 && index < fItems.length) {
- fText= fItems[index];
- fSelectionIndex= index;
+ fText = fItems[index];
+ fSelectionIndex = index;
}
}
dialogFieldChanged();
}
-
+
public int getSelectionIndex() {
return fSelectionIndex;
}
-
/**
* Sets the text without triggering a dialog-changed event.
*/
public void setTextWithoutUpdate(String text) {
- fText= text;
+ fText = text;
if (isOkToUse(fComboControl)) {
fComboControl.removeModifyListener(fModifyListener);
fComboControl.setText(text);
fComboControl.addModifyListener(fModifyListener);
}
}
-
+
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/DialogField.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/DialogField.java
index 7fbe5aeff41..5f06bfa9bc9 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/DialogField.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/DialogField.java
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
@@ -26,44 +26,44 @@ public class DialogField {
private Label fLabel;
protected String fLabelText;
-
+
private IDialogFieldListener fDialogFieldListener;
-
+
private boolean fEnabled;
public DialogField() {
- fEnabled= true;
- fLabel= null;
- fLabelText= ""; //$NON-NLS-1$
+ fEnabled = true;
+ fLabel = null;
+ fLabelText = ""; //$NON-NLS-1$
}
-
+
/**
* Sets the label of the dialog field.
*/
public void setLabelText(String labeltext) {
- fLabelText= labeltext;
+ fLabelText = labeltext;
}
-
+
// ------ change listener
-
+
/**
* Defines the listener for this dialog field.
- */
+ */
public final void setDialogFieldListener(IDialogFieldListener listener) {
- fDialogFieldListener= listener;
+ fDialogFieldListener = listener;
}
/**
* Programmatical invocation of a dialog field change.
- */
+ */
public void dialogFieldChanged() {
if (fDialogFieldListener != null) {
fDialogFieldListener.dialogFieldChanged(this);
}
- }
-
+ }
+
// ------- focus management
-
+
/**
* Tries to set the focus to the dialog field.
* Returns <code>true</code> if the dialog field can take focus.
@@ -75,22 +75,20 @@ public class DialogField {
/**
* Posts <code>setFocus</code> to the display event queue.
- */
+ */
public void postSetFocusOnDialogField(Display display) {
if (display != null) {
- display.asyncExec(
- new Runnable() {
- @Override
- public void run() {
- setFocus();
- }
+ display.asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ setFocus();
}
- );
+ });
}
- }
-
+ }
+
// ------- layout helpers
-
+
/**
* Creates all controls of the dialog field and fills it to a composite.
* The composite is assumed to have <code>MGridLayout</code> as
@@ -100,48 +98,48 @@ public class DialogField {
*/
public Control[] doFillIntoGrid(Composite parent, int nColumns) {
assertEnoughColumns(nColumns);
-
- Label label= getLabelControl(parent);
+
+ Label label = getLabelControl(parent);
label.setLayoutData(gridDataForLabel(nColumns));
-
+
return new Control[] { label };
}
-
+
/**
* Returns the number of columns of the dialog field.
* To be reimplemented by dialog field implementors.
*/
public int getNumberOfControls() {
- return 1;
- }
-
+ return 1;
+ }
+
protected static GridData gridDataForLabel(int span) {
- GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- gd.horizontalSpan= span;
+ GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ gd.horizontalSpan = span;
return gd;
}
-
+
// ------- ui creation
/**
* Creates or returns the created label widget.
* @param parent The parent composite or <code>null</code> if the widget has
* already been created.
- */
+ */
public Label getLabelControl(Composite parent) {
if (fLabel == null) {
assertCompositeNotNull(parent);
-
- fLabel= new Label(parent, SWT.LEFT);
+
+ fLabel = new Label(parent, SWT.LEFT);
fLabel.setFont(parent.getFont());
- fLabel.setEnabled(fEnabled);
+ fLabel.setEnabled(fEnabled);
if (fLabelText != null && !fLabelText.isEmpty()) {
fLabel.setText(fLabelText);
} else {
// XXX: to avoid a 16 pixel wide empty label - revisit
fLabel.setText("."); //$NON-NLS-1$
fLabel.setVisible(false);
- }
+ }
}
return fLabel;
}
@@ -150,7 +148,7 @@ public class DialogField {
* Creates a spacer control.
*
* @param parent The parent composite
- */
+ */
public static Control createEmptySpace(Composite parent) {
return createEmptySpace(parent, 1);
}
@@ -160,39 +158,39 @@ public class DialogField {
* The composite is assumed to have {@link GridLayout} as layout.
*
* @param parent The parent composite
- */
+ */
public static Control createEmptySpace(Composite parent, int span) {
- Label label= new Label(parent, SWT.LEFT);
- GridData gd= new GridData();
- gd.horizontalAlignment= GridData.BEGINNING;
- gd.grabExcessHorizontalSpace= false;
- gd.horizontalSpan= span;
- gd.horizontalIndent= 0;
- gd.widthHint= 0;
- gd.heightHint= 0;
+ Label label = new Label(parent, SWT.LEFT);
+ GridData gd = new GridData();
+ gd.horizontalAlignment = GridData.BEGINNING;
+ gd.grabExcessHorizontalSpace = false;
+ gd.horizontalSpan = span;
+ gd.horizontalIndent = 0;
+ gd.widthHint = 0;
+ gd.heightHint = 0;
label.setLayoutData(gd);
return label;
}
-
+
/**
* Tests is the control is not <code>null</code> and not disposed.
*/
protected final boolean isOkToUse(Control control) {
return (control != null) && !(control.isDisposed());
}
-
+
// --------- enable / disable management
-
+
/**
* Sets the enable state of the dialog field.
*/
public final void setEnabled(boolean enabled) {
if (enabled != fEnabled) {
- fEnabled= enabled;
+ fEnabled = enabled;
updateEnableState();
}
}
-
+
/**
* Called when the enable state changed.
* To be extended by dialog field implementors.
@@ -205,7 +203,7 @@ public class DialogField {
/**
* Gets the enable state of the dialog field.
- */
+ */
public final boolean isEnabled() {
return fEnabled;
}
@@ -213,12 +211,9 @@ public class DialogField {
protected final void assertCompositeNotNull(Composite comp) {
Assert.isNotNull(comp, "uncreated control requested with composite null"); //$NON-NLS-1$
}
-
+
protected final void assertEnoughColumns(int nColumns) {
Assert.isTrue(nColumns >= getNumberOfControls(), "given number of columns is too small"); //$NON-NLS-1$
}
-
-
-
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/IDialogFieldListener.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/IDialogFieldListener.java
index bdf3f7a988a..28145614849 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/IDialogFieldListener.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/IDialogFieldListener.java
@@ -14,6 +14,6 @@
package org.eclipse.cdt.internal.ui.wizards.dialogfields;
public interface IDialogFieldListener {
-
+
void dialogFieldChanged(DialogField field);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/IListAdapter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/IListAdapter.java
index dc079ca1267..f4f8ead0b91 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/IListAdapter.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/IListAdapter.java
@@ -17,20 +17,20 @@ package org.eclipse.cdt.internal.ui.wizards.dialogfields;
* Change listener used by <code>ListDialogField</code> and <code>CheckedListDialogField</code>
*/
public interface IListAdapter<T> {
-
+
/**
* A button from the button bar has been pressed.
*/
void customButtonPressed(ListDialogField<T> field, int index);
-
+
/**
* The selection of the list has changed.
- */
+ */
void selectionChanged(ListDialogField<T> field);
-
+
/**
* En entry in the list has been double clicked
*/
- void doubleClicked(ListDialogField<T> field);
+ void doubleClicked(ListDialogField<T> field);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/IStringButtonAdapter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/IStringButtonAdapter.java
index 35c4c235bb6..53ba6774c99 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/IStringButtonAdapter.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/IStringButtonAdapter.java
@@ -14,6 +14,6 @@
package org.eclipse.cdt.internal.ui.wizards.dialogfields;
public interface IStringButtonAdapter {
-
+
void changeControlPressed(DialogField field);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/ITreeListAdapter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/ITreeListAdapter.java
index cea235b352c..1d47c091c6a 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/ITreeListAdapter.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/ITreeListAdapter.java
@@ -19,15 +19,15 @@ import org.eclipse.swt.events.KeyEvent;
* Change listener used by <code>TreeListDialogField</code>
*/
public interface ITreeListAdapter<T> {
-
+
/**
* A button from the button bar has been pressed.
*/
void customButtonPressed(TreeListDialogField<T> field, int index);
-
+
/**
* The selection of the list has changed.
- */
+ */
void selectionChanged(TreeListDialogField<T> field);
/**
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/LayoutUtil.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/LayoutUtil.java
index b5047867845..7e2cddf2d89 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/LayoutUtil.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/LayoutUtil.java
@@ -27,9 +27,9 @@ public class LayoutUtil {
* Calculates the number of columns needed by field editors
*/
public static int getNumberOfColumns(DialogField[] editors) {
- int nColumns= 0;
- for (int i= 0; i < editors.length; i++) {
- nColumns= Math.max(editors[i].getNumberOfControls(), nColumns);
+ int nColumns = 0;
+ for (int i = 0; i < editors.length; i++) {
+ nColumns = Math.max(editors[i].getNumberOfControls(), nColumns);
}
return nColumns;
}
@@ -42,11 +42,11 @@ public class LayoutUtil {
Layout layout = composite.getLayout();
return layout instanceof GridLayout ? ((GridLayout) layout).numColumns : 1;
}
-
+
/**
* Creates a composite and fills in the given editors.
* @param labelOnTop Defines if the label of all fields should be on top of the fields
- */
+ */
public static void doDefaultLayout(Composite parent, DialogField[] editors, boolean labelOnTop) {
doDefaultLayout(parent, editors, labelOnTop, 0, 0, 0, 0);
}
@@ -55,10 +55,10 @@ public class LayoutUtil {
* Creates a composite and fills in the given editors.
* @param labelOnTop Defines if the label of all fields should be on top of the fields
* @param minWidth The minimal width of the composite
- * @param minHeight The minimal height of the composite
+ * @param minHeight The minimal height of the composite
*/
- public static void doDefaultLayout(Composite parent, DialogField[] editors, boolean labelOnTop,
- int minWidth, int minHeight) {
+ public static void doDefaultLayout(Composite parent, DialogField[] editors, boolean labelOnTop, int minWidth,
+ int minHeight) {
doDefaultLayout(parent, editors, labelOnTop, minWidth, minHeight, 0, 0);
}
@@ -69,88 +69,88 @@ public class LayoutUtil {
* @param minHeight The minimal height of the composite
* @param marginWidth The margin width to be used by the composite
* @param marginHeight The margin height to be used by the composite
- */
- private static void doDefaultLayout(Composite parent, DialogField[] editors, boolean labelOnTop,
- int minWidth, int minHeight, int marginWidth, int marginHeight) {
- int nCulumns= getNumberOfColumns(editors);
- Control[][] controls= new Control[editors.length][];
- for (int i= 0; i < editors.length; i++) {
- controls[i]= editors[i].doFillIntoGrid(parent, nCulumns);
+ */
+ private static void doDefaultLayout(Composite parent, DialogField[] editors, boolean labelOnTop, int minWidth,
+ int minHeight, int marginWidth, int marginHeight) {
+ int nCulumns = getNumberOfColumns(editors);
+ Control[][] controls = new Control[editors.length][];
+ for (int i = 0; i < editors.length; i++) {
+ controls[i] = editors[i].doFillIntoGrid(parent, nCulumns);
}
if (labelOnTop) {
nCulumns--;
modifyLabelSpans(controls, nCulumns);
}
- GridLayout layout= new GridLayout();
+ GridLayout layout = new GridLayout();
if (marginWidth != SWT.DEFAULT) {
- layout.marginWidth= marginWidth;
+ layout.marginWidth = marginWidth;
}
if (marginHeight != SWT.DEFAULT) {
- layout.marginHeight= marginHeight;
+ layout.marginHeight = marginHeight;
}
- layout.numColumns= nCulumns;
+ layout.numColumns = nCulumns;
parent.setLayout(layout);
}
-
+
private static void modifyLabelSpans(Control[][] controls, int nCulumns) {
- for (int i= 0; i < controls.length; i++) {
+ for (int i = 0; i < controls.length; i++) {
setHorizontalSpan(controls[i][0], nCulumns);
}
}
-
+
/**
* Sets the span of a control. Assumes that GridData is used.
*/
public static void setHorizontalSpan(Control control, int span) {
- Object ld= control.getLayoutData();
+ Object ld = control.getLayoutData();
if (ld instanceof GridData) {
- ((GridData) ld).horizontalSpan= span;
+ ((GridData) ld).horizontalSpan = span;
} else if (span != 1) {
- GridData gd= new GridData();
- gd.horizontalSpan= span;
+ GridData gd = new GridData();
+ gd.horizontalSpan = span;
control.setLayoutData(gd);
}
- }
+ }
/**
* Sets the width hint of a control. Assumes that GridData is used.
*/
public static void setWidthHint(Control control, int widthHint) {
- Object ld= control.getLayoutData();
+ Object ld = control.getLayoutData();
if (ld instanceof GridData) {
- ((GridData) ld).widthHint= widthHint;
+ ((GridData) ld).widthHint = widthHint;
}
}
-
+
/**
* Sets the heigthHint hint of a control. Assumes that GridData is used.
*/
public static void setHeightHint(Control control, int heigthHint) {
- Object ld= control.getLayoutData();
+ Object ld = control.getLayoutData();
if (ld instanceof GridData) {
- ((GridData) ld).heightHint= heigthHint;
+ ((GridData) ld).heightHint = heigthHint;
}
- }
-
+ }
+
/**
* Sets the horizontal indent of a control. Assumes that GridData is used.
*/
public static void setHorizontalIndent(Control control, int horizontalIndent) {
- Object ld= control.getLayoutData();
+ Object ld = control.getLayoutData();
if (ld instanceof GridData) {
- ((GridData) ld).horizontalIndent= horizontalIndent;
+ ((GridData) ld).horizontalIndent = horizontalIndent;
}
}
-
+
/**
* Sets the horizontal alignment of a control. Assumes that GridData is used.
*/
public static void setHorizontalAlignment(Control control, int horizontalAlignment) {
- Object ld= control.getLayoutData();
+ Object ld = control.getLayoutData();
if (ld instanceof GridData) {
- ((GridData) ld).horizontalAlignment= horizontalAlignment;
+ ((GridData) ld).horizontalAlignment = horizontalAlignment;
}
- }
+ }
/**
* Makes a control grab all available horizontal space. Assumes that GridData is used.
@@ -164,9 +164,9 @@ public class LayoutUtil {
* @param value <code>true</code> to grab, <code>false</code> not to grab
*/
public static void setHorizontalGrabbing(Control control, boolean value) {
- Object ld= control.getLayoutData();
+ Object ld = control.getLayoutData();
if (ld instanceof GridData) {
- ((GridData) ld).grabExcessHorizontalSpace= value;
+ ((GridData) ld).grabExcessHorizontalSpace = value;
}
}
@@ -175,9 +175,9 @@ public class LayoutUtil {
* @param value <code>true</code> to grab, <code>false</code> not to grab
*/
public static void setVerticalGrabbing(Control control, boolean value) {
- Object ld= control.getLayoutData();
+ Object ld = control.getLayoutData();
if (ld instanceof GridData) {
- ((GridData) ld).grabExcessVerticalSpace= value;
+ ((GridData) ld).grabExcessVerticalSpace = value;
}
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/LinkToFileGroup.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/LinkToFileGroup.java
index 0d832164618..9763ea8c313 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/LinkToFileGroup.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/LinkToFileGroup.java
@@ -45,7 +45,7 @@ import org.eclipse.swt.widgets.Text;
/**
* This class is part of the NewClassWizard.
- * It handles the Link to file part.
+ * It handles the Link to file part.
*/
public class LinkToFileGroup extends StringButtonDialogField {
protected Listener listener;
@@ -64,56 +64,56 @@ public class LinkToFileGroup extends StringButtonDialogField {
private Label resolvedPathLabelText;
private Label resolvedPathLabelData;
boolean preventDialogFieldChanged = false;
-
+
public LinkToFileGroup(IStringButtonAdapter adapter, Listener listener) {
super(adapter);
this.listener = listener;
this.type = IResource.FILE;
}
-
+
@Override
public Control[] doFillIntoGrid(Composite parent, int nColumns) {
assertEnoughColumns(nColumns);
//initializeDialogUnits(parent);
-
- Label label= getLabelControl(parent);
+
+ Label label = getLabelControl(parent);
label.setLayoutData(gridDataForLabel(1));
-
- getLinkCheckButtonControl(parent);
- Text text= getTextControl(parent);
+ getLinkCheckButtonControl(parent);
+
+ Text text = getTextControl(parent);
text.setLayoutData(gridDataForText(2));
- Button browseButton = getBrowseButtonControl(parent);
+ Button browseButton = getBrowseButtonControl(parent);
browseButton.setLayoutData(gridDataForButton(browseButton, 1));
-
+
DialogField.createEmptySpace(parent);
resolvedPathLabelText = new Label(parent, SWT.SINGLE);
- resolvedPathLabelText.setText(NewWizardMessages.CreateLinkedResourceGroup_resolvedPathLabel);
- resolvedPathLabelText.setVisible(true);
-
+ resolvedPathLabelText.setText(NewWizardMessages.CreateLinkedResourceGroup_resolvedPathLabel);
+ resolvedPathLabelText.setVisible(true);
+
resolvedPathLabelData = new Label(parent, SWT.SINGLE);
GridData data = new GridData(GridData.FILL_HORIZONTAL);
data.horizontalSpan = 3;
resolvedPathLabelData.setLayoutData(data);
resolvedPathLabelData.setVisible(true);
-
+
return null;
}
-
+
/*
* @see DialogField#getNumberOfControls
- */
+ */
@Override
public int getNumberOfControls() {
- return 4;
+ return 4;
}
-
- public Button getLinkCheckButtonControl(Composite parent){
- if (linkButton == null){
+
+ public Button getLinkCheckButtonControl(Composite parent) {
+ if (linkButton == null) {
linkButton = new Button(parent, SWT.CHECK);
- linkButton.setText(NewWizardMessages.NewClassWizardPage_files_linkFileButton);
+ linkButton.setText(NewWizardMessages.NewClassWizardPage_files_linkFileButton);
linkButton.setSelection(createLink);
linkButton.setFont(parent.getFont());
SelectionListener selectionListener = new SelectionAdapter() {
@@ -133,12 +133,12 @@ public class LinkToFileGroup extends StringButtonDialogField {
}
return linkButton;
}
-
+
@Override
public String getText() {
return linkTargetField.getText();
}
-
+
@Override
public void setText(String text) {
if (isOkToUse(linkTargetField)) {
@@ -146,12 +146,12 @@ public class LinkToFileGroup extends StringButtonDialogField {
linkTargetField.setText(text);
preventDialogFieldChanged = false;
}
-// dialogFieldChanged();
+ // dialogFieldChanged();
}
-
+
@Override
- public Text getTextControl(Composite parent){
- if (linkTargetField == null){
+ public Text getTextControl(Composite parent) {
+ if (linkTargetField == null) {
assertCompositeNotNull(parent);
linkTargetField = new Text(parent, SWT.BORDER);
linkTargetField.setFont(parent.getFont());
@@ -169,26 +169,26 @@ public class LinkToFileGroup extends StringButtonDialogField {
if (initialLinkTarget != null)
linkTargetField.setText(initialLinkTarget);
}
- return linkTargetField;
+ return linkTargetField;
}
-
- public static GridData gridDataForText(int span){
+
+ public static GridData gridDataForText(int span) {
GridData data = new GridData();
data.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH;
- data.horizontalAlignment= GridData.FILL;
- data.grabExcessHorizontalSpace= false;
- data.horizontalSpan= span;
+ data.horizontalAlignment = GridData.FILL;
+ data.grabExcessHorizontalSpace = false;
+ data.horizontalSpan = span;
return data;
}
-
- public Button getBrowseButtonControl(Composite parent){
+
+ public Button getBrowseButtonControl(Composite parent) {
// browse button
- if (browseButton == null){
+ if (browseButton == null) {
assertCompositeNotNull(parent);
browseButton = new Button(parent, SWT.PUSH);
//setButtonLayoutData(browseButton);
browseButton.setFont(parent.getFont());
- browseButton.setText(NewWizardMessages.CreateLinkedResourceGroup_browseButton);
+ browseButton.setText(NewWizardMessages.CreateLinkedResourceGroup_browseButton);
browseButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
@@ -202,19 +202,15 @@ public class LinkToFileGroup extends StringButtonDialogField {
/**
* Returns a new status object with the given severity and message.
- *
+ *
* @return a new status object with the given severity and message.
*/
private IStatus createStatus(int severity, String message) {
- return new Status(
- severity,
- CUIPlugin.getPluginId(),
- severity,
- message,
- null);
- }
+ return new Status(severity, CUIPlugin.getPluginId(), severity, message, null);
+ }
+
/**
- * Returns the link target location entered by the user.
+ * Returns the link target location entered by the user.
*
* @return the link target location entered by the user. null if the user
* chose not to create a link.
@@ -240,43 +236,43 @@ public class LinkToFileGroup extends StringButtonDialogField {
String linkTargetName = linkTargetField.getText();
File file = null;
String selection = null;
-
- if ("".equals(linkTargetName) == false) { //$NON-NLS-1$
+
+ if ("".equals(linkTargetName) == false) { //$NON-NLS-1$
file = new File(linkTargetName);
if (file.exists() == false)
file = null;
}
if (type == IResource.FILE) {
FileDialog dialog = new FileDialog(linkTargetField.getShell());
- dialog.setText(NewWizardMessages.CreateLinkedResourceGroup_open);
+ dialog.setText(NewWizardMessages.CreateLinkedResourceGroup_open);
if (file != null) {
if (file.isFile())
dialog.setFileName(linkTargetName);
else
dialog.setFilterPath(linkTargetName);
}
- selection = dialog.open();
- }
- else {
+ selection = dialog.open();
+ } else {
DirectoryDialog dialog = new DirectoryDialog(linkTargetField.getShell());
- dialog.setText(NewWizardMessages.CreateLinkedResourceGroup_open);
+ dialog.setText(NewWizardMessages.CreateLinkedResourceGroup_open);
if (file != null) {
if (file.isFile())
linkTargetName = file.getParent();
if (linkTargetName != null)
dialog.setFilterPath(linkTargetName);
}
- dialog.setMessage(NewWizardMessages.CreateLinkedResourceGroup_targetSelectionLabel);
+ dialog.setMessage(NewWizardMessages.CreateLinkedResourceGroup_targetSelectionLabel);
selection = dialog.open();
- }
+ }
if (selection != null) {
linkTargetField.setText(selection);
if (!preventDialogFieldChanged)
dialogFieldChanged();
}
}
+
/**
- * Tries to resolve the value entered in the link target field as
+ * Tries to resolve the value entered in the link target field as
* a variable, if the value is a relative path.
* Displays the resolved value if the entered value is a variable.
*/
@@ -285,16 +281,17 @@ public class LinkToFileGroup extends StringButtonDialogField {
resolvedPathLabelData.setText(""); //$NON-NLS-1$
return;
}
-
+
IPathVariableManager pathVariableManager = ResourcesPlugin.getWorkspace().getPathVariableManager();
IPath path = new Path(linkTargetField.getText());
IPath resolvedPath = pathVariableManager.resolvePath(path);
-
+
resolvedPathLabelData.setText(resolvedPath.toOSString());
}
+
/**
* Sets the value of the link target field
- *
+ *
* @param target the value of the link target field
*/
public void setLinkTarget(String target) {
@@ -305,44 +302,42 @@ public class LinkToFileGroup extends StringButtonDialogField {
dialogFieldChanged();
}
}
+
/**
* Validates the type of the given file against the link type specified
* in the constructor.
- *
+ *
* @param linkTargetFile file to validate
- * @return IStatus indicating the validation result. IStatus.OK if the
+ * @return IStatus indicating the validation result. IStatus.OK if the
* given file is valid.
*/
private IStatus validateFileType(File linkTargetFile) {
if (type == IResource.FILE && linkTargetFile.isFile() == false) {
- return createStatus(
- IStatus.ERROR,
- NewWizardMessages.CreateLinkedResourceGroup_linkTargetNotFile);
+ return createStatus(IStatus.ERROR, NewWizardMessages.CreateLinkedResourceGroup_linkTargetNotFile);
} else if (type == IResource.FOLDER && linkTargetFile.isDirectory() == false) {
- return createStatus(
- IStatus.ERROR,
- NewWizardMessages.CreateLinkedResourceGroup_linkTargetNotFolder);
+ return createStatus(IStatus.ERROR, NewWizardMessages.CreateLinkedResourceGroup_linkTargetNotFolder);
}
return createStatus(IStatus.OK, ""); //$NON-NLS-1$
}
+
/**
* Validates this page's controls.
*
- * @return IStatus indicating the validation result. IStatus.OK if the
+ * @return IStatus indicating the validation result. IStatus.OK if the
* specified link target is valid given the linkHandle.
*/
public IStatus validateLinkLocation(IResource linkHandle) {
if (linkTargetField == null || linkTargetField.isDisposed())
- return createStatus(IStatus.OK, ""); //$NON-NLS-1$
-
+ return createStatus(IStatus.OK, ""); //$NON-NLS-1$
+
IWorkspace workspace = ResourcesPlugin.getWorkspace();
String linkTargetName = linkTargetField.getText();
IPath path = new Path(linkTargetName);
-
+
if (createLink == false)
return createStatus(IStatus.OK, ""); //$NON-NLS-1$
- IStatus locationStatus = workspace.validateLinkLocation(linkHandle, path);
+ IStatus locationStatus = workspace.validateLinkLocation(linkHandle, path);
if (locationStatus.getSeverity() == IStatus.ERROR)
return locationStatus;
@@ -356,14 +351,12 @@ public class LinkToFileGroup extends StringButtonDialogField {
return fileTypeStatus;
} else if (locationStatus.getSeverity() == IStatus.OK) {
// locationStatus takes precedence over missing location warning.
- return createStatus(
- IStatus.WARNING,
- NewWizardMessages.CreateLinkedResourceGroup_linkTargetNonExistent);
+ return createStatus(IStatus.WARNING, NewWizardMessages.CreateLinkedResourceGroup_linkTargetNonExistent);
}
return locationStatus;
}
-
- public boolean linkCreated (){
+
+ public boolean linkCreated() {
return createLink;
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/ListDialogField.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/ListDialogField.java
index 1f2d6d240ba..ad8b69e2f3c 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/ListDialogField.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/ListDialogField.java
@@ -59,35 +59,35 @@ import org.eclipse.cdt.internal.ui.util.TableLayoutComposite;
* DialogFields controls are: Label, List and Composite containing buttons.
*/
public class ListDialogField<T> extends DialogField {
-
+
public static class ColumnsDescription {
protected ColumnLayoutData[] columns;
protected String[] headers;
protected boolean drawLines;
-
+
public ColumnsDescription(ColumnLayoutData[] columns, String[] headers, boolean drawLines) {
- this.columns= columns;
- this.headers= headers;
- this.drawLines= drawLines;
+ this.columns = columns;
+ this.headers = headers;
+ this.drawLines = drawLines;
}
-
+
public ColumnsDescription(String[] headers, boolean drawLines) {
this(createColumnWeightData(headers.length), headers, drawLines);
}
-
+
public ColumnsDescription(int nColumns, boolean drawLines) {
this(createColumnWeightData(nColumns), null, drawLines);
}
-
+
private static ColumnLayoutData[] createColumnWeightData(int nColumns) {
- ColumnLayoutData[] data= new ColumnLayoutData[nColumns];
- for (int i= 0; i < nColumns; i++) {
- data[i]= new ColumnWeightData(1);
- }
+ ColumnLayoutData[] data = new ColumnLayoutData[nColumns];
+ for (int i = 0; i < nColumns; i++) {
+ data[i] = new ColumnWeightData(1);
+ }
return data;
}
}
-
+
protected TableViewer fTable;
protected IBaseLabelProvider fLabelProvider;
protected ListViewerAdapter fListViewerAdapter;
@@ -96,25 +96,24 @@ public class ListDialogField<T> extends DialogField {
protected String[] fButtonLabels;
private Button[] fButtonControls;
-
+
private boolean[] fButtonsEnabled;
-
+
private int fRemoveButtonIndex;
private int fUpButtonIndex;
private int fDownButtonIndex;
-
+
private Label fLastSeparator;
-
+
protected Control fTableControl;
private Composite fButtonsControl;
private ISelection fSelectionWhenEnabled;
-
+
private IListAdapter<T> fListAdapter;
-
+
private Object fParentElement;
-
+
protected ColumnsDescription fTableColumns;
-
/**
* Creates the <code>ListDialogField</code>.
@@ -123,87 +122,86 @@ public class ListDialogField<T> extends DialogField {
* @param buttonLabels The labels of all buttons: <code>null</code> is a valid array entry and
* marks a separator.
* @param lprovider The label provider to render the table entries
- */
+ */
public ListDialogField(IListAdapter<T> adapter, String[] buttonLabels, IBaseLabelProvider lprovider) {
super();
- fListAdapter= adapter;
+ fListAdapter = adapter;
+
+ fLabelProvider = lprovider;
+ fListViewerAdapter = new ListViewerAdapter();
+ fParentElement = this;
- fLabelProvider= lprovider;
- fListViewerAdapter= new ListViewerAdapter();
- fParentElement= this;
+ fElements = new ArrayList<T>(10);
- fElements= new ArrayList<T>(10);
-
- fButtonLabels= buttonLabels;
+ fButtonLabels = buttonLabels;
if (fButtonLabels != null) {
- int nButtons= fButtonLabels.length;
- fButtonsEnabled= new boolean[nButtons];
- for (int i= 0; i < nButtons; i++) {
- fButtonsEnabled[i]= true;
+ int nButtons = fButtonLabels.length;
+ fButtonsEnabled = new boolean[nButtons];
+ for (int i = 0; i < nButtons; i++) {
+ fButtonsEnabled[i] = true;
}
- }
-
- fTable= null;
- fTableControl= null;
- fButtonsControl= null;
- fTableColumns= null;
-
- fRemoveButtonIndex= -1;
- fUpButtonIndex= -1;
- fDownButtonIndex= -1;
- }
-
+ }
+
+ fTable = null;
+ fTableControl = null;
+ fButtonsControl = null;
+ fTableColumns = null;
+
+ fRemoveButtonIndex = -1;
+ fUpButtonIndex = -1;
+ fDownButtonIndex = -1;
+ }
+
/**
* Sets the index of the 'remove' button in the button label array passed in the constructor.
* The behaviour of the button marked as the 'remove' button will then be handled internally.
* (enable state, button invocation behaviour)
- */
+ */
public void setRemoveButtonIndex(int removeButtonIndex) {
Assert.isTrue(removeButtonIndex < fButtonLabels.length);
- fRemoveButtonIndex= removeButtonIndex;
+ fRemoveButtonIndex = removeButtonIndex;
}
/**
* Sets the index of the 'up' button in the button label array passed in the constructor.
* The behaviour of the button marked as the 'up' button will then be handled internally.
* (enable state, button invocation behaviour)
- */
+ */
public void setUpButtonIndex(int upButtonIndex) {
Assert.isTrue(upButtonIndex < fButtonLabels.length);
- fUpButtonIndex= upButtonIndex;
+ fUpButtonIndex = upButtonIndex;
}
/**
* Sets the index of the 'down' button in the button label array passed in the constructor.
* The behaviour of the button marked as the 'down' button will then be handled internally.
* (enable state, button invocation behaviour)
- */
+ */
public void setDownButtonIndex(int downButtonIndex) {
Assert.isTrue(downButtonIndex < fButtonLabels.length);
- fDownButtonIndex= downButtonIndex;
+ fDownButtonIndex = downButtonIndex;
}
-
+
/**
* Sets the viewerComparator.
* @param viewerComparator The viewerComparator to set
*/
public void setViewerComparator(ViewerComparator viewerComparator) {
- fViewerComparator= viewerComparator;
+ fViewerComparator = viewerComparator;
}
-
+
public void setTableColumns(ColumnsDescription column) {
- fTableColumns= column;
+ fTableColumns = column;
}
-
-
+
// ------ adapter communication
-
+
private void buttonPressed(int index) {
if (!managedButtonPressed(index) && fListAdapter != null) {
fListAdapter.customButtonPressed(this, index);
}
}
-
+
/**
* Checks if the button pressed is handled internally
* @return Returns true if button has been handled.
@@ -220,68 +218,66 @@ public class ListDialogField<T> extends DialogField {
}
return true;
}
-
// ------ layout helpers
-
+
/*
* @see DialogField#doFillIntoGrid
*/
@Override
public Control[] doFillIntoGrid(Composite parent, int nColumns) {
- PixelConverter converter= new PixelConverter(parent);
-
+ PixelConverter converter = new PixelConverter(parent);
+
assertEnoughColumns(nColumns);
-
- Label label= getLabelControl(parent);
- GridData gd= gridDataForLabel(1);
- gd.verticalAlignment= GridData.BEGINNING;
+
+ Label label = getLabelControl(parent);
+ GridData gd = gridDataForLabel(1);
+ gd.verticalAlignment = GridData.BEGINNING;
label.setLayoutData(gd);
-
- Control list= getListControl(parent);
- gd= new GridData();
- gd.horizontalAlignment= GridData.FILL;
- gd.grabExcessHorizontalSpace= true;
- gd.verticalAlignment= GridData.FILL;
- gd.grabExcessVerticalSpace= true;
- gd.horizontalSpan= nColumns - 2;
- gd.widthHint= converter.convertWidthInCharsToPixels(50);
- gd.heightHint= converter.convertHeightInCharsToPixels(6);
+
+ Control list = getListControl(parent);
+ gd = new GridData();
+ gd.horizontalAlignment = GridData.FILL;
+ gd.grabExcessHorizontalSpace = true;
+ gd.verticalAlignment = GridData.FILL;
+ gd.grabExcessVerticalSpace = true;
+ gd.horizontalSpan = nColumns - 2;
+ gd.widthHint = converter.convertWidthInCharsToPixels(50);
+ gd.heightHint = converter.convertHeightInCharsToPixels(6);
list.setLayoutData(gd);
-
- Composite buttons= getButtonBox(parent);
- gd= new GridData();
- gd.horizontalAlignment= GridData.FILL;
- gd.grabExcessHorizontalSpace= false;
- gd.verticalAlignment= GridData.FILL;
- gd.grabExcessVerticalSpace= true;
- gd.horizontalSpan= 1;
+
+ Composite buttons = getButtonBox(parent);
+ gd = new GridData();
+ gd.horizontalAlignment = GridData.FILL;
+ gd.grabExcessHorizontalSpace = false;
+ gd.verticalAlignment = GridData.FILL;
+ gd.grabExcessVerticalSpace = true;
+ gd.horizontalSpan = 1;
buttons.setLayoutData(gd);
-
+
return new Control[] { label, list, buttons };
}
/*
* @see DialogField#getNumberOfControls
- */
+ */
@Override
public int getNumberOfControls() {
- return 3;
+ return 3;
}
/**
* Sets the minimal width of the buttons. Must be called after widget creation.
- */
+ */
public void setButtonsMinWidth(int minWidth) {
if (fLastSeparator != null) {
- ((GridData)fLastSeparator.getLayoutData()).widthHint= minWidth;
+ ((GridData) fLastSeparator.getLayoutData()).widthHint = minWidth;
}
}
-
-
+
// ------ ui creation
-
+
/**
* Returns the list control. When called the first time, the control will be created.
* @param parent the parent composite when called the first time, or <code>null</code>
@@ -290,26 +286,26 @@ public class ListDialogField<T> extends DialogField {
public Control getListControl(Composite parent) {
if (fTableControl == null) {
assertCompositeNotNull(parent);
-
+
if (fTableColumns == null) {
- fTable= createTableViewer(parent);
- Table tableControl= fTable.getTable();
-
- fTableControl= tableControl;
+ fTable = createTableViewer(parent);
+ Table tableControl = fTable.getTable();
+
+ fTableControl = tableControl;
tableControl.setLayout(new TableLayout());
} else {
- TableLayoutComposite composite= new TableLayoutComposite(parent, SWT.NONE);
- fTableControl= composite;
-
- fTable= createTableViewer(composite);
- Table tableControl= fTable.getTable();
-
+ TableLayoutComposite composite = new TableLayoutComposite(parent, SWT.NONE);
+ fTableControl = composite;
+
+ fTable = createTableViewer(composite);
+ Table tableControl = fTable.getTable();
+
tableControl.setHeaderVisible(fTableColumns.headers != null);
tableControl.setLinesVisible(fTableColumns.drawLines);
- ColumnLayoutData[] columns= fTableColumns.columns;
- for (int i= 0; i < columns.length; i++) {
+ ColumnLayoutData[] columns = fTableColumns.columns;
+ for (int i = 0; i < columns.length; i++) {
composite.addColumnData(columns[i]);
- TableColumn column= new TableColumn(tableControl, SWT.NONE);
+ TableColumn column = new TableColumn(tableControl, SWT.NONE);
//tableLayout.addColumnData(columns[i]);
if (fTableColumns.headers != null) {
column.setText(fTableColumns.headers[i]);
@@ -323,20 +319,20 @@ public class ListDialogField<T> extends DialogField {
handleKeyPressed(e);
}
});
-
- //fTableControl.setLayout(tableLayout);
-
+
+ //fTableControl.setLayout(tableLayout);
+
fTable.setContentProvider(fListViewerAdapter);
fTable.setLabelProvider(fLabelProvider);
fTable.addSelectionChangedListener(fListViewerAdapter);
fTable.addDoubleClickListener(fListViewerAdapter);
-
+
fTable.setInput(fParentElement);
-
+
if (fViewerComparator != null) {
fTable.setComparator(fViewerComparator);
}
-
+
fTableControl.setEnabled(isEnabled());
if (fSelectionWhenEnabled != null) {
postSetSelection(fSelectionWhenEnabled);
@@ -347,105 +343,106 @@ public class ListDialogField<T> extends DialogField {
/**
* Returns the internally used table viewer.
- */
+ */
public TableViewer getTableViewer() {
return fTable;
}
-
- /*
+
+ /*
* Subclasses may override to specify a different style.
*/
- protected int getListStyle(){
- int style= SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL ;
+ protected int getListStyle() {
+ int style = SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL;
if (fTableColumns != null) {
style |= SWT.FULL_SELECTION;
}
- return style;
+ return style;
}
-
+
protected TableViewer createTableViewer(Composite parent) {
- Table table= new Table(parent, getListStyle());
+ Table table = new Table(parent, getListStyle());
return new TableViewer(table);
- }
-
+ }
+
protected Button createButton(Composite parent, String label, SelectionListener listener) {
- Button button= new Button(parent, SWT.PUSH);
+ Button button = new Button(parent, SWT.PUSH);
button.setText(label);
button.addSelectionListener(listener);
- GridData gd= new GridData();
- gd.horizontalAlignment= GridData.FILL;
- gd.grabExcessHorizontalSpace= true;
- gd.verticalAlignment= GridData.BEGINNING;
+ GridData gd = new GridData();
+ gd.horizontalAlignment = GridData.FILL;
+ gd.grabExcessHorizontalSpace = true;
+ gd.verticalAlignment = GridData.BEGINNING;
gd.widthHint = SWTUtil.getButtonWidthHint(button);
-
+
button.setLayoutData(gd);
return button;
}
-
+
private Label createSeparator(Composite parent) {
- Label separator= new Label(parent, SWT.NONE);
+ Label separator = new Label(parent, SWT.NONE);
separator.setVisible(false);
- GridData gd= new GridData();
- gd.horizontalAlignment= GridData.FILL;
- gd.verticalAlignment= GridData.BEGINNING;
- gd.heightHint= 4;
+ GridData gd = new GridData();
+ gd.horizontalAlignment = GridData.FILL;
+ gd.verticalAlignment = GridData.BEGINNING;
+ gd.heightHint = 4;
separator.setLayoutData(gd);
return separator;
- }
+ }
/**
* Returns the composite containing the buttons. When called the first time, the control
* will be created.
* @param parent the parent composite when called the first time, or <code>null</code>
* after.
- */
+ */
public Composite getButtonBox(Composite parent) {
if (fButtonsControl == null) {
assertCompositeNotNull(parent);
-
- SelectionListener listener= new SelectionListener() {
+
+ SelectionListener listener = new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
doButtonSelected(e);
}
+
@Override
public void widgetSelected(SelectionEvent e) {
doButtonSelected(e);
}
};
-
- Composite contents= new Composite(parent, SWT.NULL);
- GridLayout layout= new GridLayout();
- layout.marginWidth= 0;
- layout.marginHeight= 0;
+
+ Composite contents = new Composite(parent, SWT.NULL);
+ GridLayout layout = new GridLayout();
+ layout.marginWidth = 0;
+ layout.marginHeight = 0;
contents.setLayout(layout);
-
+
if (fButtonLabels != null) {
- fButtonControls= new Button[fButtonLabels.length];
- for (int i= 0; i < fButtonLabels.length; i++) {
- String currLabel= fButtonLabels[i];
+ fButtonControls = new Button[fButtonLabels.length];
+ for (int i = 0; i < fButtonLabels.length; i++) {
+ String currLabel = fButtonLabels[i];
if (currLabel != null) {
- fButtonControls[i]= createButton(contents, currLabel, listener);
+ fButtonControls[i] = createButton(contents, currLabel, listener);
fButtonControls[i].setEnabled(isEnabled() && fButtonsEnabled[i]);
} else {
- fButtonControls[i]= null;
+ fButtonControls[i] = null;
createSeparator(contents);
}
}
}
-
- fLastSeparator= createSeparator(contents);
-
+
+ fLastSeparator = createSeparator(contents);
+
updateButtonState();
- fButtonsControl= contents;
+ fButtonsControl = contents;
}
-
+
return fButtonsControl;
}
-
+
protected void doButtonSelected(SelectionEvent e) {
if (fButtonControls != null) {
- for (int i= 0; i < fButtonControls.length; i++) {
+ for (int i = 0; i < fButtonControls.length; i++) {
if (e.widget == fButtonControls[i]) {
buttonPressed(i);
return;
@@ -453,7 +450,7 @@ public class ListDialogField<T> extends DialogField {
}
}
}
-
+
/**
* Handles key events in the table viewer. Specifically
* when the delete key is pressed.
@@ -463,35 +460,35 @@ public class ListDialogField<T> extends DialogField {
if (fRemoveButtonIndex != -1 && isButtonEnabled(fTable.getSelection(), fRemoveButtonIndex)) {
managedButtonPressed(fRemoveButtonIndex);
}
- }
- }
-
+ }
+ }
+
// ------ enable / disable management
/*
* @see DialogField#dialogFieldChanged
- */
+ */
@Override
public void dialogFieldChanged() {
super.dialogFieldChanged();
updateButtonState();
}
-
+
/*
* Updates the enable state of the all buttons
- */
+ */
protected void updateButtonState() {
if (fButtonControls != null) {
- ISelection sel= fTable.getSelection();
- for (int i= 0; i < fButtonControls.length; i++) {
- Button button= fButtonControls[i];
+ ISelection sel = fTable.getSelection();
+ for (int i = 0; i < fButtonControls.length; i++) {
+ Button button = fButtonControls[i];
if (isOkToUse(button)) {
button.setEnabled(isButtonEnabled(sel, i));
- }
+ }
}
}
}
-
+
protected boolean getManagedButtonState(ISelection sel, int index) {
if (index == fRemoveButtonIndex) {
return !sel.isEmpty();
@@ -501,23 +498,23 @@ public class ListDialogField<T> extends DialogField {
return !sel.isEmpty() && canMoveDown();
}
return true;
- }
+ }
/*
* @see DialogField#updateEnableState
- */
+ */
@Override
protected void updateEnableState() {
super.updateEnableState();
-
- boolean enabled= isEnabled();
+
+ boolean enabled = isEnabled();
if (isOkToUse(fTableControl)) {
if (!enabled) {
- fSelectionWhenEnabled= fTable.getSelection();
+ fSelectionWhenEnabled = fTable.getSelection();
selectElements(null);
} else {
selectElements(fSelectionWhenEnabled);
- fSelectionWhenEnabled= null;
+ fSelectionWhenEnabled = null;
}
fTableControl.setEnabled(enabled);
}
@@ -526,27 +523,26 @@ public class ListDialogField<T> extends DialogField {
/**
* Sets a button enabled or disabled.
- */
+ */
public void enableButton(int index, boolean enable) {
if (fButtonsEnabled != null && index < fButtonsEnabled.length) {
- fButtonsEnabled[index]= enable;
+ fButtonsEnabled[index] = enable;
updateButtonState();
}
}
-
+
private boolean isButtonEnabled(ISelection sel, int index) {
- boolean extraState= getManagedButtonState(sel, index);
+ boolean extraState = getManagedButtonState(sel, index);
return isEnabled() && extraState && fButtonsEnabled[index];
- }
-
+ }
// ------ model access
-
+
/**
* Sets the elements shown in the list.
*/
public void setElements(List<? extends T> elements) {
- fElements= new ArrayList<T>(elements);
+ fElements = new ArrayList<T>(elements);
if (fTable != null) {
fTable.refresh();
}
@@ -556,34 +552,34 @@ public class ListDialogField<T> extends DialogField {
/**
* Gets the elements shown in the list.
* The list returned is a copy, so it can be modified by the user.
- */
+ */
public List<T> getElements() {
return new ArrayList<T>(fElements);
}
/**
* Gets the elements shown at the given index.
- */
+ */
public T getElement(int index) {
return fElements.get(index);
}
-
+
/**
* Gets the index of an element in the list or -1 if element is not in list.
*/
public int getIndexOfElement(Object elem) {
return fElements.indexOf(elem);
- }
+ }
/**
* Replace an element.
- */
- public void replaceElement(T oldElement, T newElement) throws IllegalArgumentException {
- int idx= fElements.indexOf(oldElement);
+ */
+ public void replaceElement(T oldElement, T newElement) throws IllegalArgumentException {
+ int idx = fElements.indexOf(oldElement);
if (idx != -1) {
fElements.set(idx, newElement);
if (fTable != null) {
- List<T> selected= getSelectedElements();
+ List<T> selected = getSelectedElements();
if (selected.remove(oldElement)) {
selected.add(newElement);
}
@@ -594,12 +590,12 @@ public class ListDialogField<T> extends DialogField {
} else {
throw new IllegalArgumentException();
}
- }
+ }
/**
* Adds an element at the end of the list.
- */
- public void addElement(T element) {
+ */
+ public void addElement(T element) {
if (fElements.contains(element)) {
return;
}
@@ -612,19 +608,19 @@ public class ListDialogField<T> extends DialogField {
/**
* Adds elements at the end of the list.
- */
+ */
public void addElements(List<? extends T> elements) {
- int nElements= elements.size();
-
+ int nElements = elements.size();
+
if (nElements > 0) {
// filter duplicated
- ArrayList<T> elementsToAdd= new ArrayList<T>(nElements);
-
- for (int i= 0; i < nElements; i++) {
- T elem= elements.get(i);
+ ArrayList<T> elementsToAdd = new ArrayList<T>(nElements);
+
+ for (int i = 0; i < nElements; i++) {
+ T elem = elements.get(i);
if (!fElements.contains(elem)) {
elementsToAdd.add(elem);
- }
+ }
}
fElements.addAll(elementsToAdd);
if (fTable != null) {
@@ -632,11 +628,11 @@ public class ListDialogField<T> extends DialogField {
}
dialogFieldChanged();
}
- }
+ }
/**
* Adds an element at a position.
- */
+ */
public void insertElementAt(T element, int index) {
if (fElements.contains(element)) {
return;
@@ -645,13 +641,13 @@ public class ListDialogField<T> extends DialogField {
if (fTable != null) {
fTable.add(element);
}
-
+
dialogFieldChanged();
- }
+ }
/**
* Adds an element at a position.
- */
+ */
public void removeAllElements() {
if (fElements.size() > 0) {
fElements.clear();
@@ -661,10 +657,10 @@ public class ListDialogField<T> extends DialogField {
dialogFieldChanged();
}
}
-
+
/**
* Removes an element from the list.
- */
+ */
public void removeElement(Object element) throws IllegalArgumentException {
if (fElements.remove(element)) {
if (fTable != null) {
@@ -678,7 +674,7 @@ public class ListDialogField<T> extends DialogField {
/**
* Removes elements from the list.
- */
+ */
public void removeElements(List<?> elements) {
if (elements.size() > 0) {
fElements.removeAll(elements);
@@ -691,39 +687,39 @@ public class ListDialogField<T> extends DialogField {
/**
* Gets the number of elements
- */
+ */
public int getSize() {
return fElements.size();
}
public void selectElements(ISelection selection) {
- fSelectionWhenEnabled= selection;
+ fSelectionWhenEnabled = selection;
if (fTable != null) {
fTable.setSelection(selection, true);
}
}
-
+
public void selectFirstElement() {
- Object element= null;
+ Object element = null;
if (fViewerComparator != null) {
- Object[] arr= fElements.toArray();
+ Object[] arr = fElements.toArray();
fViewerComparator.sort(fTable, arr);
if (arr.length > 0) {
- element= arr[0];
+ element = arr[0];
}
} else {
if (fElements.size() > 0) {
- element= fElements.get(0);
+ element = fElements.get(0);
}
}
if (element != null) {
selectElements(new StructuredSelection(element));
}
}
-
+
public void postSetSelection(final ISelection selection) {
if (isOkToUse(fTableControl)) {
- Display d= fTableControl.getDisplay();
+ Display d = fTableControl.getDisplay();
d.asyncExec(new Runnable() {
@Override
public void run() {
@@ -734,7 +730,7 @@ public class ListDialogField<T> extends DialogField {
});
}
}
-
+
/**
* Refreshes the table.
*/
@@ -743,68 +739,68 @@ public class ListDialogField<T> extends DialogField {
fTable.refresh();
}
}
-
+
// ------- list maintenance
-
+
private List<T> moveUp(List<? extends T> elements, List<? extends T> move) {
- int nElements= elements.size();
- List<T> res= new ArrayList<T>(nElements);
- T floating= null;
- for (int i= 0; i < nElements; i++) {
- T curr= elements.get(i);
+ int nElements = elements.size();
+ List<T> res = new ArrayList<T>(nElements);
+ T floating = null;
+ for (int i = 0; i < nElements; i++) {
+ T curr = elements.get(i);
if (move.contains(curr)) {
res.add(curr);
} else {
if (floating != null) {
res.add(floating);
}
- floating= curr;
+ floating = curr;
}
}
if (floating != null) {
res.add(floating);
}
return res;
- }
-
+ }
+
private void moveUp(List<? extends T> toMoveUp) {
if (toMoveUp.size() > 0) {
setElements(moveUp(fElements, toMoveUp));
fTable.reveal(toMoveUp.get(0));
}
}
-
+
private void moveDown(List<? extends T> toMoveDown) {
if (toMoveDown.size() > 0) {
setElements(reverse(moveUp(reverse(fElements), toMoveDown)));
fTable.reveal(toMoveDown.get(toMoveDown.size() - 1));
}
}
-
+
private List<T> reverse(List<? extends T> p) {
- List<T> reverse= new ArrayList<T>(p.size());
- for (int i= p.size()-1; i >= 0; i--) {
+ List<T> reverse = new ArrayList<T>(p.size());
+ for (int i = p.size() - 1; i >= 0; i--) {
reverse.add(p.get(i));
}
return reverse;
}
-
+
protected void remove() {
removeElements(getSelectedElements());
}
-
+
protected void up() {
moveUp(getSelectedElements());
}
-
+
protected void down() {
moveDown(getSelectedElements());
}
-
+
protected boolean canMoveUp() {
if (isOkToUse(fTableControl)) {
- int[] indc= fTable.getTable().getSelectionIndices();
- for (int i= 0; i < indc.length; i++) {
+ int[] indc = fTable.getTable().getSelectionIndices();
+ for (int i = 0; i < indc.length; i++) {
if (indc[i] != i) {
return true;
}
@@ -812,30 +808,30 @@ public class ListDialogField<T> extends DialogField {
}
return false;
}
-
+
protected boolean canMoveDown() {
if (isOkToUse(fTableControl)) {
- int[] indc= fTable.getTable().getSelectionIndices();
- int k= fElements.size() - 1;
- for (int i= indc.length - 1; i >= 0 ; i--, k--) {
+ int[] indc = fTable.getTable().getSelectionIndices();
+ int k = fElements.size() - 1;
+ for (int i = indc.length - 1; i >= 0; i--, k--) {
if (indc[i] != k) {
return true;
}
}
}
return false;
- }
+ }
/**
* Returns the selected elements.
*/
public List<T> getSelectedElements() {
- List<T> result= new ArrayList<T>();
+ List<T> result = new ArrayList<T>();
if (fTable != null) {
- ISelection selection= fTable.getSelection();
+ ISelection selection = fTable.getSelection();
if (selection instanceof IStructuredSelection) {
@SuppressWarnings("unchecked")
- Iterator<T> iter= ((IStructuredSelection)selection).iterator();
+ Iterator<T> iter = ((IStructuredSelection) selection).iterator();
while (iter.hasNext()) {
result.add(iter.next());
}
@@ -843,34 +839,35 @@ public class ListDialogField<T> extends DialogField {
}
return result;
}
-
+
// ------- ListViewerAdapter
-
- private class ListViewerAdapter implements IStructuredContentProvider, ISelectionChangedListener, IDoubleClickListener {
+
+ private class ListViewerAdapter
+ implements IStructuredContentProvider, ISelectionChangedListener, IDoubleClickListener {
// ------- ITableContentProvider Interface ------------
-
+
@Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
// will never happen
}
-
+
@Override
public void dispose() {
}
-
+
@Override
public Object[] getElements(Object obj) {
return fElements.toArray();
}
-
+
// ------- ISelectionChangedListener Interface ------------
-
+
@Override
public void selectionChanged(SelectionChangedEvent event) {
doListSelected(event);
}
-
+
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.IDoubleClickListener#doubleClick(org.eclipse.jface.viewers.DoubleClickEvent)
*/
@@ -879,17 +876,17 @@ public class ListDialogField<T> extends DialogField {
doDoubleClick(event);
}
}
-
+
protected void doListSelected(SelectionChangedEvent event) {
updateButtonState();
if (fListAdapter != null) {
fListAdapter.selectionChanged(this);
}
}
-
+
protected void doDoubleClick(DoubleClickEvent event) {
if (fListAdapter != null) {
fListAdapter.doubleClicked(this);
}
- }
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/SelectionButtonDialogField.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/SelectionButtonDialogField.java
index b486e228e20..4bf31d3c2a6 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/SelectionButtonDialogField.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/SelectionButtonDialogField.java
@@ -27,7 +27,7 @@ import org.eclipse.cdt.internal.ui.util.SWTUtil;
* Dialog Field containing a single button such as a radio or checkbox button.
*/
public class SelectionButtonDialogField extends DialogField {
-
+
private Button fButton;
private boolean fIsSelected;
private DialogField[] fAttachedDialogFields;
@@ -39,11 +39,11 @@ public class SelectionButtonDialogField extends DialogField {
*/
public SelectionButtonDialogField(int buttonStyle) {
super();
- fIsSelected= false;
- fAttachedDialogFields= null;
- fButtonStyle= buttonStyle;
+ fIsSelected = false;
+ fAttachedDialogFields = null;
+ fButtonStyle = buttonStyle;
}
-
+
/**
* Attaches a field to the selection state of the selection button.
* The attached field will be disabled if the selection button is not selected.
@@ -55,20 +55,20 @@ public class SelectionButtonDialogField extends DialogField {
/**
* Attaches fields to the selection state of the selection button.
* The attached fields will be disabled if the selection button is not selected.
- */
+ */
public void attachDialogFields(DialogField[] dialogFields) {
- fAttachedDialogFields= dialogFields;
- for (int i= 0; i < dialogFields.length; i++) {
+ fAttachedDialogFields = dialogFields;
+ for (int i = 0; i < dialogFields.length; i++) {
dialogFields[i].setEnabled(fIsSelected);
}
- }
-
+ }
+
/**
* Returns <code>true</code> is teh gived field is attached to the selection button.
*/
public boolean isAttached(DialogField editor) {
if (fAttachedDialogFields != null) {
- for (int i=0; i < fAttachedDialogFields.length; i++) {
+ for (int i = 0; i < fAttachedDialogFields.length; i++) {
if (fAttachedDialogFields[i] == editor) {
return true;
}
@@ -76,50 +76,50 @@ public class SelectionButtonDialogField extends DialogField {
}
return false;
}
-
+
// ------- layout helpers
-
+
/*
* @see DialogField#doFillIntoGrid
*/
@Override
public Control[] doFillIntoGrid(Composite parent, int nColumns) {
assertEnoughColumns(nColumns);
-
- Button button= getSelectionButton(parent);
- GridData gd= new GridData();
- gd.horizontalSpan= nColumns;
- gd.horizontalAlignment= GridData.FILL;
+
+ Button button = getSelectionButton(parent);
+ GridData gd = new GridData();
+ gd.horizontalSpan = nColumns;
+ gd.horizontalAlignment = GridData.FILL;
if (fButtonStyle == SWT.PUSH) {
gd.widthHint = SWTUtil.getButtonWidthHint(button);
- }
-
+ }
+
button.setLayoutData(gd);
-
+
return new Control[] { button };
- }
+ }
/*
* @see DialogField#getNumberOfControls
- */
+ */
@Override
public int getNumberOfControls() {
- return 1;
- }
-
- // ------- ui creation
+ return 1;
+ }
+
+ // ------- ui creation
/**
* Returns the selection button widget. When called the first time, the widget will be created.
* @param group the parent composite when called the first time, or <code>null</code>
* after.
- */
+ */
public Button getSelectionButton(Composite group) {
if (fButton == null) {
assertCompositeNotNull(group);
-
- fButton= new Button(group, fButtonStyle);
- fButton.setFont(group.getFont());
+
+ fButton = new Button(group, fButtonStyle);
+ fButton.setFont(group.getFont());
fButton.setText(fLabelText);
fButton.setEnabled(isEnabled());
fButton.setSelection(fIsSelected);
@@ -128,30 +128,31 @@ public class SelectionButtonDialogField extends DialogField {
public void widgetDefaultSelected(SelectionEvent e) {
doWidgetSelected(e);
}
+
@Override
public void widgetSelected(SelectionEvent e) {
doWidgetSelected(e);
}
- });
+ });
}
return fButton;
}
-
+
protected void doWidgetSelected(SelectionEvent e) {
if (isOkToUse(fButton)) {
changeValue(fButton.getSelection());
}
- }
-
+ }
+
private void changeValue(boolean newState) {
if (fIsSelected != newState) {
- fIsSelected= newState;
+ fIsSelected = newState;
if (fAttachedDialogFields != null) {
- boolean focusSet= false;
- for (int i= 0; i < fAttachedDialogFields.length; i++) {
+ boolean focusSet = false;
+ for (int i = 0; i < fAttachedDialogFields.length; i++) {
fAttachedDialogFields[i].setEnabled(fIsSelected);
if (fIsSelected && !focusSet) {
- focusSet= fAttachedDialogFields[i].setFocus();
+ focusSet = fAttachedDialogFields[i].setFocus();
}
}
}
@@ -159,10 +160,10 @@ public class SelectionButtonDialogField extends DialogField {
} else if (fButtonStyle == SWT.PUSH) {
dialogFieldChanged();
}
- }
+ }
+
+ // ------ model access
- // ------ model access
-
/**
* Returns the selection state of the button.
*/
@@ -172,7 +173,7 @@ public class SelectionButtonDialogField extends DialogField {
/**
* Sets the selection state of the button.
- */
+ */
public void setSelection(boolean selected) {
changeValue(selected);
if (isOkToUse(fButton)) {
@@ -184,16 +185,13 @@ public class SelectionButtonDialogField extends DialogField {
/*
* @see DialogField#updateEnableState
- */
+ */
@Override
protected void updateEnableState() {
super.updateEnableState();
if (isOkToUse(fButton)) {
fButton.setEnabled(isEnabled());
- }
+ }
}
-
-
-
-
+
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/SelectionButtonDialogFieldGroup.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/SelectionButtonDialogFieldGroup.java
index ee331faa876..44f567d397f 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/SelectionButtonDialogFieldGroup.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/SelectionButtonDialogFieldGroup.java
@@ -30,96 +30,95 @@ import org.eclipse.core.runtime.Assert;
* Dialog field describing a group with buttons (Checkboxes, radio buttons..)
*/
public class SelectionButtonDialogFieldGroup extends DialogField {
-
+
private Composite fButtonComposite;
-
+
private Button[] fButtons;
private String[] fButtonNames;
private boolean[] fButtonsSelected;
private boolean[] fButtonsEnabled;
-
+
private int fGroupBorderStyle;
private int fGroupNumberOfColumns;
- private int fButtonsStyle;
-
+ private int fButtonsStyle;
+
/**
* Creates a group without border.
*/
public SelectionButtonDialogFieldGroup(int buttonsStyle, String[] buttonNames, int nColumns) {
- this(buttonsStyle, buttonNames, nColumns, SWT.NONE);
- }
-
-
+ this(buttonsStyle, buttonNames, nColumns, SWT.NONE);
+ }
+
/**
* Creates a group with border (label in border).
* Accepted button styles are: SWT.RADIO, SWT.CHECK, SWT.TOGGLE
* For border styles see <code>Group</code>
- */
+ */
public SelectionButtonDialogFieldGroup(int buttonsStyle, String[] buttonNames, int nColumns, int borderStyle) {
super();
-
+
Assert.isTrue(buttonsStyle == SWT.RADIO || buttonsStyle == SWT.CHECK || buttonsStyle == SWT.TOGGLE);
- fButtonNames= buttonNames;
-
- int nButtons= buttonNames.length;
- fButtonsSelected= new boolean[nButtons];
- fButtonsEnabled= new boolean[nButtons];
- for (int i= 0; i < nButtons; i++) {
- fButtonsSelected[i]= false;
- fButtonsEnabled[i]= true;
+ fButtonNames = buttonNames;
+
+ int nButtons = buttonNames.length;
+ fButtonsSelected = new boolean[nButtons];
+ fButtonsEnabled = new boolean[nButtons];
+ for (int i = 0; i < nButtons; i++) {
+ fButtonsSelected[i] = false;
+ fButtonsEnabled[i] = true;
}
if (fButtonsStyle == SWT.RADIO) {
- fButtonsSelected[0]= true;
+ fButtonsSelected[0] = true;
}
-
- fGroupBorderStyle= borderStyle;
- fGroupNumberOfColumns= (nColumns <= 0) ? nButtons : nColumns;
-
- fButtonsStyle= buttonsStyle;
-
+
+ fGroupBorderStyle = borderStyle;
+ fGroupNumberOfColumns = (nColumns <= 0) ? nButtons : nColumns;
+
+ fButtonsStyle = buttonsStyle;
+
}
-
+
// ------- layout helpers
-
+
/*
* @see DialogField#doFillIntoGrid
*/
@Override
public Control[] doFillIntoGrid(Composite parent, int nColumns) {
assertEnoughColumns(nColumns);
-
+
if (fGroupBorderStyle == SWT.NONE) {
- Label label= getLabelControl(parent);
+ Label label = getLabelControl(parent);
label.setLayoutData(gridDataForLabel(1));
-
- Composite buttonsgroup= getSelectionButtonsGroup(parent);
- GridData gd= new GridData();
- gd.horizontalSpan= nColumns - 1;
+
+ Composite buttonsgroup = getSelectionButtonsGroup(parent);
+ GridData gd = new GridData();
+ gd.horizontalSpan = nColumns - 1;
buttonsgroup.setLayoutData(gd);
-
+
return new Control[] { label, buttonsgroup };
}
- Composite buttonsgroup= getSelectionButtonsGroup(parent);
- GridData gd= new GridData();
- gd.horizontalSpan= nColumns;
+ Composite buttonsgroup = getSelectionButtonsGroup(parent);
+ GridData gd = new GridData();
+ gd.horizontalSpan = nColumns;
buttonsgroup.setLayoutData(gd);
-
+
return new Control[] { buttonsgroup };
- }
+ }
/*
* @see DialogField#doFillIntoGrid
- */
+ */
@Override
public int getNumberOfControls() {
return (fGroupBorderStyle == SWT.NONE) ? 2 : 1;
}
-
+
// ------- ui creation
-
+
private Button createSelectionButton(int index, Composite group, SelectionListener listener) {
- Button button= new Button(group, fButtonsStyle | SWT.LEFT);
- button.setFont(group.getFont());
+ Button button = new Button(group, fButtonsStyle | SWT.LEFT);
+ button.setFont(group.getFont());
button.setText(fButtonNames[index]);
button.setEnabled(isEnabled() && fButtonsEnabled[index]);
button.setSelection(fButtonsSelected[index]);
@@ -136,43 +135,44 @@ public class SelectionButtonDialogFieldGroup extends DialogField {
public Composite getSelectionButtonsGroup(Composite parent) {
if (fButtonComposite == null) {
assertCompositeNotNull(parent);
-
- GridLayout layout= new GridLayout();
- layout.makeColumnsEqualWidth= true;
- layout.numColumns= fGroupNumberOfColumns;
-
+
+ GridLayout layout = new GridLayout();
+ layout.makeColumnsEqualWidth = true;
+ layout.numColumns = fGroupNumberOfColumns;
+
if (fGroupBorderStyle != SWT.NONE) {
- Group group= new Group(parent, fGroupBorderStyle);
+ Group group = new Group(parent, fGroupBorderStyle);
if (fLabelText != null && fLabelText.length() > 0) {
group.setText(fLabelText);
}
- fButtonComposite= group;
+ fButtonComposite = group;
} else {
- fButtonComposite= new Composite(parent, SWT.NULL);
- layout.marginHeight= 0;
- layout.marginWidth= 0;
+ fButtonComposite = new Composite(parent, SWT.NULL);
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
}
fButtonComposite.setLayout(layout);
-
- SelectionListener listener= new SelectionListener() {
+
+ SelectionListener listener = new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
doWidgetSelected(e);
}
+
@Override
public void widgetSelected(SelectionEvent e) {
doWidgetSelected(e);
}
- };
- int nButtons= fButtonNames.length;
- fButtons= new Button[nButtons];
- for (int i= 0; i < nButtons; i++) {
- fButtons[i]= createSelectionButton(i, fButtonComposite, listener);
+ };
+ int nButtons = fButtonNames.length;
+ fButtons = new Button[nButtons];
+ for (int i = 0; i < nButtons; i++) {
+ fButtons[i] = createSelectionButton(i, fButtonComposite, listener);
}
- int nRows= nButtons / fGroupNumberOfColumns;
- int nFillElements= nRows * fGroupNumberOfColumns - nButtons;
- for (int i= 0; i < nFillElements; i++) {
+ int nRows = nButtons / fGroupNumberOfColumns;
+ int nFillElements = nRows * fGroupNumberOfColumns - nButtons;
+ for (int i = 0; i < nFillElements; i++) {
createEmptySpace(fButtonComposite);
}
}
@@ -181,26 +181,26 @@ public class SelectionButtonDialogFieldGroup extends DialogField {
/**
* Returns a button from the group or <code>null</code> if not yet created.
- */
+ */
public Button getSelectionButton(int index) {
if (index >= 0 && index < fButtons.length) {
return fButtons[index];
}
return null;
}
-
+
protected void doWidgetSelected(SelectionEvent e) {
- Button button= (Button)e.widget;
- for (int i= 0; i < fButtons.length; i++) {
+ Button button = (Button) e.widget;
+ for (int i = 0; i < fButtons.length; i++) {
if (fButtons[i] == button) {
- fButtonsSelected[i]= button.getSelection();
+ fButtonsSelected[i] = button.getSelection();
dialogFieldChanged();
return;
}
}
- }
-
- // ------ model access
+ }
+
+ // ------ model access
/**
* Returns the selection state of a button contained in the group.
@@ -212,16 +212,16 @@ public class SelectionButtonDialogFieldGroup extends DialogField {
}
return false;
}
-
+
/**
* Sets the selection state of a button contained in the group.
*/
public void setSelection(int index, boolean selected) {
if (index >= 0 && index < fButtonsSelected.length) {
if (fButtonsSelected[index] != selected) {
- fButtonsSelected[index]= selected;
+ fButtonsSelected[index] = selected;
if (fButtons != null) {
- Button button= fButtons[index];
+ Button button = fButtons[index];
if (isOkToUse(button)) {
button.setSelection(selected);
}
@@ -231,33 +231,33 @@ public class SelectionButtonDialogFieldGroup extends DialogField {
}
// ------ enable / disable management
-
+
@Override
protected void updateEnableState() {
super.updateEnableState();
if (fButtons != null) {
- boolean enabled= isEnabled();
- for (int i= 0; i < fButtons.length; i++) {
- Button button= fButtons[i];
+ boolean enabled = isEnabled();
+ for (int i = 0; i < fButtons.length; i++) {
+ Button button = fButtons[i];
if (isOkToUse(button)) {
button.setEnabled(enabled && fButtonsEnabled[i]);
}
}
}
}
-
+
/**
* Sets the enable state of a button contained in the group.
- */
+ */
public void enableSelectionButton(int index, boolean enable) {
if (index >= 0 && index < fButtonsEnabled.length) {
- fButtonsEnabled[index]= enable;
+ fButtonsEnabled[index] = enable;
if (fButtons != null) {
- Button button= fButtons[index];
+ Button button = fButtons[index];
if (isOkToUse(button)) {
button.setEnabled(isEnabled() && enable);
}
}
}
- }
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/Separator.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/Separator.java
index eaa74dda1e9..b5094c11d29 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/Separator.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/Separator.java
@@ -13,7 +13,6 @@
*******************************************************************************/
package org.eclipse.cdt.internal.ui.wizards.dialogfields;
-
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
@@ -25,41 +24,41 @@ import org.eclipse.swt.layout.GridData;
* Dialog field describing a separator.
*/
public class Separator extends DialogField {
-
+
private Label fSeparator;
private int fStyle;
-
+
public Separator() {
this(SWT.NONE);
- }
-
+ }
+
/**
* @param style of the separator. See <code>Label</code> for possible
* styles.
*/
public Separator(int style) {
super();
- fStyle= style;
+ fStyle = style;
}
-
+
// ------- layout helpers
/**
* Creates the separator and fills it in a MGridLayout.
* @param height The heigth of the separator
- */
+ */
public Control[] doFillIntoGrid(Composite parent, int nColumns, int height) {
assertEnoughColumns(nColumns);
-
- Control separator= getSeparator(parent);
+
+ Control separator = getSeparator(parent);
separator.setLayoutData(gridDataForSeperator(nColumns, height));
-
+
return new Control[] { separator };
}
/*
* @see DialogField#doFillIntoGrid
- */
+ */
@Override
public Control[] doFillIntoGrid(Composite parent, int nColumns) {
return doFillIntoGrid(parent, nColumns, 4);
@@ -67,33 +66,33 @@ public class Separator extends DialogField {
/*
* @see DialogField#getNumberOfControls
- */
+ */
@Override
public int getNumberOfControls() {
- return 1;
+ return 1;
}
-
+
protected static GridData gridDataForSeperator(int span, int height) {
- GridData gd= new GridData();
- gd.horizontalAlignment= GridData.FILL;
- gd.verticalAlignment= GridData.BEGINNING;
- gd.heightHint= height;
- gd.horizontalSpan= span;
+ GridData gd = new GridData();
+ gd.horizontalAlignment = GridData.FILL;
+ gd.verticalAlignment = GridData.BEGINNING;
+ gd.heightHint = height;
+ gd.horizontalSpan = span;
return gd;
}
-
- // ------- ui creation
+
+ // ------- ui creation
/**
* Creates or returns the created separator.
* @param parent The parent composite or <code>null</code> if the widget has
* already been created.
- */
+ */
public Control getSeparator(Composite parent) {
if (fSeparator == null) {
assertCompositeNotNull(parent);
- fSeparator= new Label(parent, fStyle);
- }
+ fSeparator = new Label(parent, fStyle);
+ }
return fSeparator;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/StringButtonDialogField.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/StringButtonDialogField.java
index 798d3259a72..7f96fb38ffb 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/StringButtonDialogField.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/StringButtonDialogField.java
@@ -29,84 +29,84 @@ import org.eclipse.cdt.internal.ui.util.SWTUtil;
* Dialog field containing a label, text control and a button control.
*/
public class StringButtonDialogField extends StringDialogField {
-
+
private Button fBrowseButton;
private String fBrowseButtonLabel;
private IStringButtonAdapter fStringButtonAdapter;
-
+
private boolean fButtonEnabled;
-
+
public StringButtonDialogField(IStringButtonAdapter adapter) {
super();
- fStringButtonAdapter= adapter;
- fBrowseButtonLabel= "!Browse...!"; //$NON-NLS-1$
- fButtonEnabled= true;
+ fStringButtonAdapter = adapter;
+ fBrowseButtonLabel = "!Browse...!"; //$NON-NLS-1$
+ fButtonEnabled = true;
}
/**
* Sets the label of the button.
*/
public void setButtonLabel(String label) {
- fBrowseButtonLabel= label;
+ fBrowseButtonLabel = label;
}
-
+
// ------ adapter communication
/**
* Programmatical pressing of the button
- */
+ */
public void changeControlPressed() {
fStringButtonAdapter.changeControlPressed(this);
}
-
+
// ------- layout helpers
/*
* @see DialogField#doFillIntoGrid
- */
+ */
@Override
public Control[] doFillIntoGrid(Composite parent, int nColumns) {
assertEnoughColumns(nColumns);
-
- Label label= getLabelControl(parent);
+
+ Label label = getLabelControl(parent);
label.setLayoutData(gridDataForLabel(1));
- Text text= getTextControl(parent);
+ Text text = getTextControl(parent);
text.setLayoutData(gridDataForText(nColumns - 2));
- Button button= getChangeControl(parent);
+ Button button = getChangeControl(parent);
button.setLayoutData(gridDataForButton(button, 1));
-
+
return new Control[] { label, text, button };
- }
+ }
/*
* @see DialogField#getNumberOfControls
- */
+ */
@Override
public int getNumberOfControls() {
- return 3;
+ return 3;
}
-
+
protected static GridData gridDataForButton(Button button, int span) {
- GridData gd= new GridData();
- gd.horizontalAlignment= GridData.FILL;
- gd.grabExcessHorizontalSpace= false;
- gd.horizontalSpan= span;
- gd.widthHint = SWTUtil.getButtonWidthHint(button);
+ GridData gd = new GridData();
+ gd.horizontalAlignment = GridData.FILL;
+ gd.grabExcessHorizontalSpace = false;
+ gd.horizontalSpan = span;
+ gd.widthHint = SWTUtil.getButtonWidthHint(button);
return gd;
- }
-
- // ------- ui creation
+ }
+
+ // ------- ui creation
/**
* Creates or returns the created buttom widget.
* @param parent The parent composite or <code>null</code> if the widget has
* already been created.
- */
+ */
public Button getChangeControl(Composite parent) {
if (fBrowseButton == null) {
assertCompositeNotNull(parent);
-
- fBrowseButton= new Button(parent, SWT.PUSH);
+
+ fBrowseButton = new Button(parent, SWT.PUSH);
fBrowseButton.setText(fBrowseButtonLabel);
fBrowseButton.setEnabled(isEnabled() && fButtonEnabled);
fBrowseButton.addSelectionListener(new SelectionListener() {
@@ -114,18 +114,19 @@ public class StringButtonDialogField extends StringDialogField {
public void widgetDefaultSelected(SelectionEvent e) {
changeControlPressed();
}
+
@Override
public void widgetSelected(SelectionEvent e) {
changeControlPressed();
}
- });
-
+ });
+
}
return fBrowseButton;
}
-
+
// ------ enable / disable management
-
+
/**
* Sets the enable state of the button.
*/
@@ -133,17 +134,17 @@ public class StringButtonDialogField extends StringDialogField {
if (isOkToUse(fBrowseButton)) {
fBrowseButton.setEnabled(isEnabled() && enable);
}
- fButtonEnabled= enable;
+ fButtonEnabled = enable;
}
/*
* @see DialogField#updateEnableState
- */
+ */
@Override
protected void updateEnableState() {
super.updateEnableState();
if (isOkToUse(fBrowseButton)) {
fBrowseButton.setEnabled(isEnabled() && fButtonEnabled);
}
- }
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/StringDialogField.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/StringDialogField.java
index 0720c8daae2..4df4938746d 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/StringDialogField.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/StringDialogField.java
@@ -17,7 +17,6 @@ package org.eclipse.cdt.internal.ui.wizards.dialogfields;
* (c) Copyright IBM Corp. 2000, 2001.
* All Rights Reserved.
*/
-
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
@@ -28,53 +27,52 @@ import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
-
public class StringDialogField extends DialogField {
-
+
private String fText;
private Text fTextControl;
private ModifyListener fModifyListener;
-
+
public StringDialogField() {
super();
- fText= ""; //$NON-NLS-1$
+ fText = ""; //$NON-NLS-1$
}
-
+
// ------- layout helpers
-
+
/*
* @see DialogField#doFillIntoGrid
*/
@Override
public Control[] doFillIntoGrid(Composite parent, int nColumns) {
assertEnoughColumns(nColumns);
-
- Label label= getLabelControl(parent);
+
+ Label label = getLabelControl(parent);
label.setLayoutData(gridDataForLabel(1));
- Text text= getTextControl(parent);
+ Text text = getTextControl(parent);
text.setLayoutData(gridDataForText(nColumns - 1));
-
+
return new Control[] { label, text };
- }
+ }
/*
* @see DialogField#getNumberOfControls
*/
@Override
public int getNumberOfControls() {
- return 2;
+ return 2;
}
-
+
protected static GridData gridDataForText(int span) {
- GridData gd= new GridData();
- gd.horizontalAlignment= GridData.FILL;
- gd.grabExcessHorizontalSpace= true;
- gd.horizontalSpan= span;
+ GridData gd = new GridData();
+ gd.horizontalAlignment = GridData.FILL;
+ gd.grabExcessHorizontalSpace = true;
+ gd.horizontalSpan = span;
return gd;
- }
-
+ }
+
// ------- focus methods
-
+
/*
* @see DialogField#setFocus
*/
@@ -86,86 +84,86 @@ public class StringDialogField extends DialogField {
}
return true;
}
-
- // ------- ui creation
+
+ // ------- ui creation
/**
* Creates or returns the created text control.
* @param parent The parent composite or <code>null</code> when the widget has
* already been created.
- */
+ */
public Text getTextControl(Composite parent) {
if (fTextControl == null) {
assertCompositeNotNull(parent);
- fModifyListener= new ModifyListener() {
+ fModifyListener = new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
doModifyText(e);
}
};
-
- fTextControl= new Text(parent, SWT.SINGLE | SWT.BORDER);
+
+ fTextControl = new Text(parent, SWT.SINGLE | SWT.BORDER);
// moved up due to 1GEUNW2
fTextControl.setText(fText);
fTextControl.setFont(parent.getFont());
fTextControl.addModifyListener(fModifyListener);
-
+
fTextControl.setEnabled(isEnabled());
}
return fTextControl;
}
-
+
protected void doModifyText(ModifyEvent e) {
if (isOkToUse(fTextControl)) {
- fText= fTextControl.getText();
+ fText = fTextControl.getText();
}
dialogFieldChanged();
- }
-
+ }
+
// ------ enable / disable management
-
+
/*
* @see DialogField#updateEnableState
- */
+ */
@Override
protected void updateEnableState() {
- super.updateEnableState();
+ super.updateEnableState();
if (isOkToUse(fTextControl)) {
fTextControl.setEnabled(isEnabled());
- }
- }
-
- // ------ text access
-
+ }
+ }
+
+ // ------ text access
+
/**
* Gets the text. Can not be <code>null</code>
- */
+ */
public String getText() {
return fText;
}
-
+
/**
* Sets the text. Triggers a dialog-changed event.
*/
public void setText(String text) {
- fText= text;
+ fText = text;
if (isOkToUse(fTextControl)) {
fTextControl.setText(text);
} else {
dialogFieldChanged();
- }
+ }
}
/**
* Sets the text without triggering a dialog-changed event.
*/
public void setTextWithoutUpdate(String text) {
- fText= text;
+ fText = text;
if (isOkToUse(fTextControl)) {
fTextControl.removeModifyListener(fModifyListener);
fTextControl.setText(text);
fTextControl.addModifyListener(fModifyListener);
}
}
-
+
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/TreeListDialogField.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/TreeListDialogField.java
index c31a0357c99..bb6ce3747d0 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/TreeListDialogField.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/TreeListDialogField.java
@@ -148,10 +148,10 @@ public class TreeListDialogField<T> extends DialogField {
/**
* Sets the viewerSorter.
- *
+ *
* @param viewerSorter
* The viewerSorter to set
- *
+ *
* @deprecated Use {@link #setViewerComparator(ViewerComparator)} instead.
*/
@Deprecated
@@ -161,7 +161,7 @@ public class TreeListDialogField<T> extends DialogField {
/**
* Sets the viewerComparator.
- *
+ *
* @param viewerComparator
* The viewerComparator to set
*/
@@ -186,7 +186,7 @@ public class TreeListDialogField<T> extends DialogField {
/**
* Checks if the button pressed is handled internally
- *
+ *
* @return Returns true if button has been handled.
*/
protected boolean managedButtonPressed(int index) {
@@ -239,7 +239,7 @@ public class TreeListDialogField<T> extends DialogField {
gd.horizontalSpan = 1;
buttons.setLayoutData(gd);
- return new Control[] { label, list, buttons};
+ return new Control[] { label, list, buttons };
}
/*
@@ -265,8 +265,8 @@ public class TreeListDialogField<T> extends DialogField {
/**
* Returns the tree control. When called the first time, the control will be
* created.
- *
- * @param parent
+ *
+ * @param parent
* parent composite when called the first time, or <code>null</code>
* after.
*/
@@ -352,7 +352,7 @@ public class TreeListDialogField<T> extends DialogField {
/**
* Returns the composite containing the buttons. When called the first time,
* the control will be created.
- *
+ *
* @param parent
* parent composite when called the first time, or <code>null</code>
* after.
@@ -898,7 +898,7 @@ public class TreeListDialogField<T> extends DialogField {
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.jface.viewers.IDoubleClickListener#doubleClick(org.eclipse.jface.viewers.DoubleClickEvent)
*/
@Override

Back to the top