mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-21 23:33:57 +02:00
Cosmetics.
This commit is contained in:
parent
d79a9c2863
commit
54300eafa3
1 changed files with 136 additions and 136 deletions
|
@ -62,20 +62,20 @@ import org.eclipse.cdt.internal.ui.dialogs.IStatusChangeListener;
|
||||||
* an options configuration page.
|
* an options configuration page.
|
||||||
*/
|
*/
|
||||||
public abstract class OptionsConfigurationBlock {
|
public abstract class OptionsConfigurationBlock {
|
||||||
|
|
||||||
public static final class Key {
|
public static final class Key {
|
||||||
private String fQualifier;
|
private String fQualifier;
|
||||||
private String fKey;
|
private String fKey;
|
||||||
|
|
||||||
public Key(String qualifier, String key) {
|
public Key(String qualifier, String key) {
|
||||||
fQualifier= qualifier;
|
fQualifier= qualifier;
|
||||||
fKey= key;
|
fKey= key;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return fKey;
|
return fKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
private IEclipsePreferences getNode(IScopeContext context, IWorkingCopyManager manager) {
|
private IEclipsePreferences getNode(IScopeContext context, IWorkingCopyManager manager) {
|
||||||
IEclipsePreferences node= context.getNode(fQualifier);
|
IEclipsePreferences node= context.getNode(fQualifier);
|
||||||
if (manager != null) {
|
if (manager != null) {
|
||||||
|
@ -83,11 +83,11 @@ public abstract class OptionsConfigurationBlock {
|
||||||
}
|
}
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getStoredValue(IScopeContext context, IWorkingCopyManager manager) {
|
public String getStoredValue(IScopeContext context, IWorkingCopyManager manager) {
|
||||||
return getNode(context, manager).get(fKey, null);
|
return getNode(context, manager).get(fKey, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getStoredValue(IScopeContext[] lookupOrder, boolean ignoreTopScope, IWorkingCopyManager manager) {
|
public String getStoredValue(IScopeContext[] lookupOrder, boolean ignoreTopScope, IWorkingCopyManager manager) {
|
||||||
for (int i= ignoreTopScope ? 1 : 0; i < lookupOrder.length; i++) {
|
for (int i= ignoreTopScope ? 1 : 0; i < lookupOrder.length; i++) {
|
||||||
String value= getStoredValue(lookupOrder[i], manager);
|
String value= getStoredValue(lookupOrder[i], manager);
|
||||||
|
@ -97,7 +97,7 @@ public abstract class OptionsConfigurationBlock {
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setStoredValue(IScopeContext context, String value, IWorkingCopyManager manager) {
|
public void setStoredValue(IScopeContext context, String value, IWorkingCopyManager manager) {
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
getNode(context, manager).put(fKey, value);
|
getNode(context, manager).put(fKey, value);
|
||||||
|
@ -105,7 +105,7 @@ public abstract class OptionsConfigurationBlock {
|
||||||
getNode(context, manager).remove(fKey);
|
getNode(context, manager).remove(fKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see java.lang.Object#toString()
|
* @see java.lang.Object#toString()
|
||||||
*/
|
*/
|
||||||
|
@ -122,25 +122,25 @@ public abstract class OptionsConfigurationBlock {
|
||||||
protected static class ControlData {
|
protected static class ControlData {
|
||||||
private Key fKey;
|
private Key fKey;
|
||||||
private String[] fValues;
|
private String[] fValues;
|
||||||
|
|
||||||
public ControlData(Key key, String[] values) {
|
public ControlData(Key key, String[] values) {
|
||||||
fKey= key;
|
fKey= key;
|
||||||
fValues= values;
|
fValues= values;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Key getKey() {
|
public Key getKey() {
|
||||||
return fKey;
|
return fKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getValue(boolean selection) {
|
public String getValue(boolean selection) {
|
||||||
int index= selection ? 0 : 1;
|
int index= selection ? 0 : 1;
|
||||||
return fValues[index];
|
return fValues[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getValue(int index) {
|
public String getValue(int index) {
|
||||||
return fValues[index];
|
return fValues[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getSelection(String value) {
|
public int getSelection(String value) {
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
for (int i= 0; i < fValues.length; i++) {
|
for (int i= 0; i < fValues.length; i++) {
|
||||||
|
@ -152,9 +152,9 @@ public abstract class OptionsConfigurationBlock {
|
||||||
return fValues.length -1; // assume the last option is the least severe
|
return fValues.length -1; // assume the last option is the least severe
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final String REBUILD_COUNT_KEY= "preferences_build_requested"; //$NON-NLS-1$
|
private static final String REBUILD_COUNT_KEY= "preferences_build_requested"; //$NON-NLS-1$
|
||||||
|
|
||||||
private static final String SETTINGS_EXPANDED= "expanded"; //$NON-NLS-1$
|
private static final String SETTINGS_EXPANDED= "expanded"; //$NON-NLS-1$
|
||||||
|
|
||||||
protected final ArrayList<Button> fCheckBoxes;
|
protected final ArrayList<Button> fCheckBoxes;
|
||||||
|
@ -162,25 +162,25 @@ public abstract class OptionsConfigurationBlock {
|
||||||
protected final ArrayList<Text> fTextBoxes;
|
protected final ArrayList<Text> fTextBoxes;
|
||||||
protected final HashMap<Control, Label> fLabels;
|
protected final HashMap<Control, Label> fLabels;
|
||||||
protected final ArrayList<ExpandableComposite> fExpandedComposites;
|
protected final ArrayList<ExpandableComposite> fExpandedComposites;
|
||||||
|
|
||||||
private SelectionListener fSelectionListener;
|
private SelectionListener fSelectionListener;
|
||||||
private ModifyListener fTextModifyListener;
|
private ModifyListener fTextModifyListener;
|
||||||
|
|
||||||
protected IStatusChangeListener fContext;
|
protected IStatusChangeListener fContext;
|
||||||
protected final IProject fProject; // project or null
|
protected final IProject fProject; // project or null
|
||||||
protected final Key[] fAllKeys;
|
protected final Key[] fAllKeys;
|
||||||
|
|
||||||
private IScopeContext[] fLookupOrder;
|
private IScopeContext[] fLookupOrder;
|
||||||
|
|
||||||
private Shell fShell;
|
private Shell fShell;
|
||||||
|
|
||||||
private final IWorkingCopyManager fManager;
|
private final IWorkingCopyManager fManager;
|
||||||
private IWorkbenchPreferenceContainer fContainer;
|
private IWorkbenchPreferenceContainer fContainer;
|
||||||
|
|
||||||
private Map<Key, String> fDisabledProjectSettings; // null when project specific settings are turned off
|
private Map<Key, String> fDisabledProjectSettings; // null when project specific settings are turned off
|
||||||
|
|
||||||
private int fRebuildCount; // used to prevent multiple dialogs that ask for a rebuild
|
private int fRebuildCount; // used to prevent multiple dialogs that ask for a rebuild
|
||||||
|
|
||||||
public OptionsConfigurationBlock(IStatusChangeListener context, IProject project, Key[] allKeys, IWorkbenchPreferenceContainer container) {
|
public OptionsConfigurationBlock(IStatusChangeListener context, IProject project, Key[] allKeys, IWorkbenchPreferenceContainer container) {
|
||||||
fContext= context;
|
fContext= context;
|
||||||
fProject= project;
|
fProject= project;
|
||||||
|
@ -191,7 +191,7 @@ public abstract class OptionsConfigurationBlock {
|
||||||
} else {
|
} else {
|
||||||
fManager= container.getWorkingCopyManager();
|
fManager= container.getWorkingCopyManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fProject != null) {
|
if (fProject != null) {
|
||||||
fLookupOrder= new IScopeContext[] {
|
fLookupOrder= new IScopeContext[] {
|
||||||
new ProjectScope(fProject),
|
new ProjectScope(fProject),
|
||||||
|
@ -204,7 +204,7 @@ public abstract class OptionsConfigurationBlock {
|
||||||
DefaultScope.INSTANCE
|
DefaultScope.INSTANCE
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
checkIfOptionsComplete(allKeys);
|
checkIfOptionsComplete(allKeys);
|
||||||
if (fProject == null || hasProjectSpecificOptions(fProject)) {
|
if (fProject == null || hasProjectSpecificOptions(fProject)) {
|
||||||
fDisabledProjectSettings= null;
|
fDisabledProjectSettings= null;
|
||||||
|
@ -215,34 +215,34 @@ public abstract class OptionsConfigurationBlock {
|
||||||
fDisabledProjectSettings.put(curr, curr.getStoredValue(fLookupOrder, false, fManager));
|
fDisabledProjectSettings.put(curr, curr.getStoredValue(fLookupOrder, false, fManager));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
settingsUpdated();
|
settingsUpdated();
|
||||||
|
|
||||||
fCheckBoxes= new ArrayList<Button>();
|
fCheckBoxes= new ArrayList<Button>();
|
||||||
fComboBoxes= new ArrayList<Combo>();
|
fComboBoxes= new ArrayList<Combo>();
|
||||||
fTextBoxes= new ArrayList<Text>(2);
|
fTextBoxes= new ArrayList<Text>(2);
|
||||||
fLabels= new HashMap<Control, Label>();
|
fLabels= new HashMap<Control, Label>();
|
||||||
fExpandedComposites= new ArrayList<ExpandableComposite>();
|
fExpandedComposites= new ArrayList<ExpandableComposite>();
|
||||||
|
|
||||||
fRebuildCount= getRebuildCount();
|
fRebuildCount= getRebuildCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final IWorkbenchPreferenceContainer getPreferenceContainer() {
|
protected final IWorkbenchPreferenceContainer getPreferenceContainer() {
|
||||||
return fContainer;
|
return fContainer;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static Key getKey(String plugin, String key) {
|
protected static Key getKey(String plugin, String key) {
|
||||||
return new Key(plugin, key);
|
return new Key(plugin, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final static Key getCDTCoreKey(String key) {
|
protected final static Key getCDTCoreKey(String key) {
|
||||||
return getKey(CCorePlugin.PLUGIN_ID, key);
|
return getKey(CCorePlugin.PLUGIN_ID, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final static Key getCDTUIKey(String key) {
|
protected final static Key getCDTUIKey(String key) {
|
||||||
return getKey(CUIPlugin.PLUGIN_ID, key);
|
return getKey(CUIPlugin.PLUGIN_ID, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkIfOptionsComplete(Key[] allKeys) {
|
private void checkIfOptionsComplete(Key[] allKeys) {
|
||||||
for (int i= 0; i < allKeys.length; i++) {
|
for (int i= 0; i < allKeys.length; i++) {
|
||||||
if (allKeys[i].getStoredValue(fLookupOrder, false, fManager) == null) {
|
if (allKeys[i].getStoredValue(fLookupOrder, false, fManager) == null) {
|
||||||
|
@ -250,19 +250,19 @@ public abstract class OptionsConfigurationBlock {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getRebuildCount() {
|
private int getRebuildCount() {
|
||||||
return fManager.getWorkingCopy(DefaultScope.INSTANCE.getNode(CUIPlugin.PLUGIN_ID)).getInt(REBUILD_COUNT_KEY, 0);
|
return fManager.getWorkingCopy(DefaultScope.INSTANCE.getNode(CUIPlugin.PLUGIN_ID)).getInt(REBUILD_COUNT_KEY, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void incrementRebuildCount() {
|
private void incrementRebuildCount() {
|
||||||
fRebuildCount++;
|
fRebuildCount++;
|
||||||
fManager.getWorkingCopy(DefaultScope.INSTANCE.getNode(CUIPlugin.PLUGIN_ID)).putInt(REBUILD_COUNT_KEY, fRebuildCount);
|
fManager.getWorkingCopy(DefaultScope.INSTANCE.getNode(CUIPlugin.PLUGIN_ID)).putInt(REBUILD_COUNT_KEY, fRebuildCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void settingsUpdated() {
|
protected void settingsUpdated() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void selectOption(String key, String qualifier) {
|
public void selectOption(String key, String qualifier) {
|
||||||
for (int i= 0; i < fAllKeys.length; i++) {
|
for (int i= 0; i < fAllKeys.length; i++) {
|
||||||
Key curr= fAllKeys[i];
|
Key curr= fAllKeys[i];
|
||||||
|
@ -271,7 +271,7 @@ public abstract class OptionsConfigurationBlock {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void selectOption(Key key) {
|
public void selectOption(Key key) {
|
||||||
Control control= findControl(key);
|
Control control= findControl(key);
|
||||||
if (control != null) {
|
if (control != null) {
|
||||||
|
@ -288,7 +288,7 @@ public abstract class OptionsConfigurationBlock {
|
||||||
control.setFocus();
|
control.setFocus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasProjectSpecificOptions(IProject project) {
|
public boolean hasProjectSpecificOptions(IProject project) {
|
||||||
if (project != null) {
|
if (project != null) {
|
||||||
IScopeContext projectContext= new ProjectScope(project);
|
IScopeContext projectContext= new ProjectScope(project);
|
||||||
|
@ -300,49 +300,49 @@ public abstract class OptionsConfigurationBlock {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Shell getShell() {
|
protected Shell getShell() {
|
||||||
return fShell;
|
return fShell;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setShell(Shell shell) {
|
protected void setShell(Shell shell) {
|
||||||
fShell= shell;
|
fShell= shell;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract Control createContents(Composite parent);
|
protected abstract Control createContents(Composite parent);
|
||||||
|
|
||||||
protected Button addCheckBox(Composite parent, String label, Key key, String[] values, int indent) {
|
protected Button addCheckBox(Composite parent, String label, Key key, String[] values, int indent) {
|
||||||
ControlData data= new ControlData(key, values);
|
ControlData data= new ControlData(key, values);
|
||||||
|
|
||||||
GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
|
GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
|
||||||
gd.horizontalSpan= 3;
|
gd.horizontalSpan= 3;
|
||||||
gd.horizontalIndent= indent;
|
gd.horizontalIndent= indent;
|
||||||
|
|
||||||
Button checkBox= new Button(parent, SWT.CHECK);
|
Button checkBox= new Button(parent, SWT.CHECK);
|
||||||
checkBox.setFont(JFaceResources.getDialogFont());
|
checkBox.setFont(JFaceResources.getDialogFont());
|
||||||
checkBox.setText(label);
|
checkBox.setText(label);
|
||||||
checkBox.setData(data);
|
checkBox.setData(data);
|
||||||
checkBox.setLayoutData(gd);
|
checkBox.setLayoutData(gd);
|
||||||
checkBox.addSelectionListener(getSelectionListener());
|
checkBox.addSelectionListener(getSelectionListener());
|
||||||
|
|
||||||
makeScrollableCompositeAware(checkBox);
|
makeScrollableCompositeAware(checkBox);
|
||||||
|
|
||||||
String currValue= getValue(key);
|
String currValue= getValue(key);
|
||||||
checkBox.setSelection(data.getSelection(currValue) == 0);
|
checkBox.setSelection(data.getSelection(currValue) == 0);
|
||||||
|
|
||||||
fCheckBoxes.add(checkBox);
|
fCheckBoxes.add(checkBox);
|
||||||
|
|
||||||
return checkBox;
|
return checkBox;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Button addCheckBoxWithLink(Composite parent, String label, Key key, String[] values, int indent, int widthHint, SelectionListener listener) {
|
protected Button addCheckBoxWithLink(Composite parent, String label, Key key, String[] values, int indent, int widthHint, SelectionListener listener) {
|
||||||
ControlData data= new ControlData(key, values);
|
ControlData data= new ControlData(key, values);
|
||||||
|
|
||||||
GridData gd= new GridData(GridData.FILL, GridData.FILL, true, false);
|
GridData gd= new GridData(GridData.FILL, GridData.FILL, true, false);
|
||||||
gd.horizontalSpan= 3;
|
gd.horizontalSpan= 3;
|
||||||
gd.horizontalIndent= indent;
|
gd.horizontalIndent= indent;
|
||||||
|
|
||||||
Composite composite= new Composite(parent, SWT.NONE);
|
Composite composite= new Composite(parent, SWT.NONE);
|
||||||
GridLayout layout= new GridLayout();
|
GridLayout layout= new GridLayout();
|
||||||
layout.marginHeight= 0;
|
layout.marginHeight= 0;
|
||||||
|
@ -350,56 +350,56 @@ public abstract class OptionsConfigurationBlock {
|
||||||
layout.numColumns= 2;
|
layout.numColumns= 2;
|
||||||
composite.setLayout(layout);
|
composite.setLayout(layout);
|
||||||
composite.setLayoutData(gd);
|
composite.setLayoutData(gd);
|
||||||
|
|
||||||
Button checkBox= new Button(composite, SWT.CHECK);
|
Button checkBox= new Button(composite, SWT.CHECK);
|
||||||
checkBox.setFont(JFaceResources.getDialogFont());
|
checkBox.setFont(JFaceResources.getDialogFont());
|
||||||
checkBox.setData(data);
|
checkBox.setData(data);
|
||||||
checkBox.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, false, false));
|
checkBox.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, false, false));
|
||||||
checkBox.addSelectionListener(getSelectionListener());
|
checkBox.addSelectionListener(getSelectionListener());
|
||||||
|
|
||||||
gd= new GridData(GridData.FILL, GridData.CENTER, true, false);
|
gd= new GridData(GridData.FILL, GridData.CENTER, true, false);
|
||||||
gd.widthHint= widthHint;
|
gd.widthHint= widthHint;
|
||||||
|
|
||||||
Link link= new Link(composite, SWT.NONE);
|
Link link= new Link(composite, SWT.NONE);
|
||||||
link.setText(label);
|
link.setText(label);
|
||||||
link.setLayoutData(gd);
|
link.setLayoutData(gd);
|
||||||
if (listener != null) {
|
if (listener != null) {
|
||||||
link.addSelectionListener(listener);
|
link.addSelectionListener(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
makeScrollableCompositeAware(link);
|
makeScrollableCompositeAware(link);
|
||||||
makeScrollableCompositeAware(checkBox);
|
makeScrollableCompositeAware(checkBox);
|
||||||
|
|
||||||
String currValue= getValue(key);
|
String currValue= getValue(key);
|
||||||
checkBox.setSelection(data.getSelection(currValue) == 0);
|
checkBox.setSelection(data.getSelection(currValue) == 0);
|
||||||
|
|
||||||
fCheckBoxes.add(checkBox);
|
fCheckBoxes.add(checkBox);
|
||||||
|
|
||||||
return checkBox;
|
return checkBox;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Combo addComboBox(Composite parent, String label, Key key, String[] values, String[] valueLabels, int indent) {
|
protected Combo addComboBox(Composite parent, String label, Key key, String[] values, String[] valueLabels, int indent) {
|
||||||
GridData gd= new GridData(GridData.FILL, GridData.CENTER, true, false, 2, 1);
|
GridData gd= new GridData(GridData.FILL, GridData.CENTER, true, false, 2, 1);
|
||||||
gd.horizontalIndent= indent;
|
gd.horizontalIndent= indent;
|
||||||
|
|
||||||
Label labelControl= new Label(parent, SWT.LEFT);
|
Label labelControl= new Label(parent, SWT.LEFT);
|
||||||
labelControl.setFont(JFaceResources.getDialogFont());
|
labelControl.setFont(JFaceResources.getDialogFont());
|
||||||
labelControl.setText(label);
|
labelControl.setText(label);
|
||||||
labelControl.setLayoutData(gd);
|
labelControl.setLayoutData(gd);
|
||||||
|
|
||||||
Combo comboBox= newComboControl(parent, key, values, valueLabels);
|
Combo comboBox= newComboControl(parent, key, values, valueLabels);
|
||||||
comboBox.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
|
comboBox.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
|
||||||
|
|
||||||
fLabels.put(comboBox, labelControl);
|
fLabels.put(comboBox, labelControl);
|
||||||
|
|
||||||
return comboBox;
|
return comboBox;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Combo addInversedComboBox(Composite parent, String label, Key key, String[] values, String[] valueLabels, int indent) {
|
protected Combo addInversedComboBox(Composite parent, String label, Key key, String[] values, String[] valueLabels, int indent) {
|
||||||
GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
|
GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
|
||||||
gd.horizontalIndent= indent;
|
gd.horizontalIndent= indent;
|
||||||
gd.horizontalSpan= 3;
|
gd.horizontalSpan= 3;
|
||||||
|
|
||||||
Composite composite= new Composite(parent, SWT.NONE);
|
Composite composite= new Composite(parent, SWT.NONE);
|
||||||
GridLayout layout= new GridLayout();
|
GridLayout layout= new GridLayout();
|
||||||
layout.marginHeight= 0;
|
layout.marginHeight= 0;
|
||||||
|
@ -407,52 +407,52 @@ public abstract class OptionsConfigurationBlock {
|
||||||
layout.numColumns= 2;
|
layout.numColumns= 2;
|
||||||
composite.setLayout(layout);
|
composite.setLayout(layout);
|
||||||
composite.setLayoutData(gd);
|
composite.setLayoutData(gd);
|
||||||
|
|
||||||
Combo comboBox= newComboControl(composite, key, values, valueLabels);
|
Combo comboBox= newComboControl(composite, key, values, valueLabels);
|
||||||
comboBox.setFont(JFaceResources.getDialogFont());
|
comboBox.setFont(JFaceResources.getDialogFont());
|
||||||
comboBox.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
|
comboBox.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
|
||||||
|
|
||||||
Label labelControl= new Label(composite, SWT.LEFT | SWT.WRAP);
|
Label labelControl= new Label(composite, SWT.LEFT | SWT.WRAP);
|
||||||
labelControl.setText(label);
|
labelControl.setText(label);
|
||||||
labelControl.setLayoutData(new GridData());
|
labelControl.setLayoutData(new GridData());
|
||||||
|
|
||||||
fLabels.put(comboBox, labelControl);
|
fLabels.put(comboBox, labelControl);
|
||||||
return comboBox;
|
return comboBox;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Combo newComboControl(Composite composite, Key key, String[] values, String[] valueLabels) {
|
protected Combo newComboControl(Composite composite, Key key, String[] values, String[] valueLabels) {
|
||||||
ControlData data= new ControlData(key, values);
|
ControlData data= new ControlData(key, values);
|
||||||
|
|
||||||
Combo comboBox= new Combo(composite, SWT.READ_ONLY);
|
Combo comboBox= new Combo(composite, SWT.READ_ONLY);
|
||||||
comboBox.setItems(valueLabels);
|
comboBox.setItems(valueLabels);
|
||||||
comboBox.setData(data);
|
comboBox.setData(data);
|
||||||
comboBox.addSelectionListener(getSelectionListener());
|
comboBox.addSelectionListener(getSelectionListener());
|
||||||
comboBox.setFont(JFaceResources.getDialogFont());
|
comboBox.setFont(JFaceResources.getDialogFont());
|
||||||
|
|
||||||
makeScrollableCompositeAware(comboBox);
|
makeScrollableCompositeAware(comboBox);
|
||||||
|
|
||||||
String currValue= getValue(key);
|
String currValue= getValue(key);
|
||||||
comboBox.select(data.getSelection(currValue));
|
comboBox.select(data.getSelection(currValue));
|
||||||
|
|
||||||
fComboBoxes.add(comboBox);
|
fComboBoxes.add(comboBox);
|
||||||
return comboBox;
|
return comboBox;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Text addTextField(Composite parent, String label, Key key, int indent, int widthHint) {
|
protected Text addTextField(Composite parent, String label, Key key, int indent, int widthHint) {
|
||||||
Label labelControl= new Label(parent, SWT.WRAP);
|
Label labelControl= new Label(parent, SWT.WRAP);
|
||||||
labelControl.setText(label);
|
labelControl.setText(label);
|
||||||
labelControl.setFont(JFaceResources.getDialogFont());
|
labelControl.setFont(JFaceResources.getDialogFont());
|
||||||
labelControl.setLayoutData(new GridData());
|
labelControl.setLayoutData(new GridData());
|
||||||
|
|
||||||
Text textBox= new Text(parent, SWT.BORDER | SWT.SINGLE);
|
Text textBox= new Text(parent, SWT.BORDER | SWT.SINGLE);
|
||||||
textBox.setData(key);
|
textBox.setData(key);
|
||||||
textBox.setLayoutData(new GridData());
|
textBox.setLayoutData(new GridData());
|
||||||
|
|
||||||
makeScrollableCompositeAware(textBox);
|
makeScrollableCompositeAware(textBox);
|
||||||
|
|
||||||
fLabels.put(textBox, labelControl);
|
fLabels.put(textBox, labelControl);
|
||||||
|
|
||||||
String currValue= getValue(key);
|
String currValue= getValue(key);
|
||||||
if (currValue != null) {
|
if (currValue != null) {
|
||||||
textBox.setText(currValue);
|
textBox.setText(currValue);
|
||||||
}
|
}
|
||||||
|
@ -469,7 +469,7 @@ public abstract class OptionsConfigurationBlock {
|
||||||
fTextBoxes.add(textBox);
|
fTextBoxes.add(textBox);
|
||||||
return textBox;
|
return textBox;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ScrolledPageContent getParentScrolledComposite(Control control) {
|
protected ScrolledPageContent getParentScrolledComposite(Control control) {
|
||||||
Control parent= control.getParent();
|
Control parent= control.getParent();
|
||||||
while (!(parent instanceof ScrolledPageContent) && parent != null) {
|
while (!(parent instanceof ScrolledPageContent) && parent != null) {
|
||||||
|
@ -480,7 +480,7 @@ public abstract class OptionsConfigurationBlock {
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ExpandableComposite getParentExpandableComposite(Control control) {
|
protected ExpandableComposite getParentExpandableComposite(Control control) {
|
||||||
Control parent= control.getParent();
|
Control parent= control.getParent();
|
||||||
while (!(parent instanceof ExpandableComposite) && parent != null) {
|
while (!(parent instanceof ExpandableComposite) && parent != null) {
|
||||||
|
@ -491,14 +491,14 @@ public abstract class OptionsConfigurationBlock {
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void makeScrollableCompositeAware(Control control) {
|
private void makeScrollableCompositeAware(Control control) {
|
||||||
ScrolledPageContent parentScrolledComposite= getParentScrolledComposite(control);
|
ScrolledPageContent parentScrolledComposite= getParentScrolledComposite(control);
|
||||||
if (parentScrolledComposite != null) {
|
if (parentScrolledComposite != null) {
|
||||||
parentScrolledComposite.adaptChild(control);
|
parentScrolledComposite.adaptChild(control);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ExpandableComposite createStyleSection(Composite parent, String label, int nColumns) {
|
protected ExpandableComposite createStyleSection(Composite parent, String label, int nColumns) {
|
||||||
ExpandableComposite excomposite= new ExpandableComposite(parent, SWT.NONE,
|
ExpandableComposite excomposite= new ExpandableComposite(parent, SWT.NONE,
|
||||||
ExpandableComposite.TWISTIE | ExpandableComposite.CLIENT_INDENT);
|
ExpandableComposite.TWISTIE | ExpandableComposite.CLIENT_INDENT);
|
||||||
|
@ -516,14 +516,14 @@ public abstract class OptionsConfigurationBlock {
|
||||||
makeScrollableCompositeAware(excomposite);
|
makeScrollableCompositeAware(excomposite);
|
||||||
return excomposite;
|
return excomposite;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final void expandedStateChanged(ExpandableComposite expandable) {
|
protected final void expandedStateChanged(ExpandableComposite expandable) {
|
||||||
ScrolledPageContent parentScrolledComposite= getParentScrolledComposite(expandable);
|
ScrolledPageContent parentScrolledComposite= getParentScrolledComposite(expandable);
|
||||||
if (parentScrolledComposite != null) {
|
if (parentScrolledComposite != null) {
|
||||||
parentScrolledComposite.reflow(true);
|
parentScrolledComposite.reflow(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void restoreSectionExpansionStates(IDialogSettings settings) {
|
protected void restoreSectionExpansionStates(IDialogSettings settings) {
|
||||||
for (int i= 0; i < fExpandedComposites.size(); i++) {
|
for (int i= 0; i < fExpandedComposites.size(); i++) {
|
||||||
ExpandableComposite excomposite= fExpandedComposites.get(i);
|
ExpandableComposite excomposite= fExpandedComposites.get(i);
|
||||||
|
@ -534,19 +534,19 @@ public abstract class OptionsConfigurationBlock {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void storeSectionExpansionStates(IDialogSettings settings) {
|
protected void storeSectionExpansionStates(IDialogSettings settings) {
|
||||||
for (int i= 0; i < fExpandedComposites.size(); i++) {
|
for (int i= 0; i < fExpandedComposites.size(); i++) {
|
||||||
ExpandableComposite curr= fExpandedComposites.get(i);
|
ExpandableComposite curr= fExpandedComposites.get(i);
|
||||||
settings.put(SETTINGS_EXPANDED + String.valueOf(i), curr.isExpanded());
|
settings.put(SETTINGS_EXPANDED + String.valueOf(i), curr.isExpanded());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected SelectionListener getSelectionListener() {
|
protected SelectionListener getSelectionListener() {
|
||||||
if (fSelectionListener == null) {
|
if (fSelectionListener == null) {
|
||||||
fSelectionListener= new SelectionListener() {
|
fSelectionListener= new SelectionListener() {
|
||||||
public void widgetDefaultSelected(SelectionEvent e) {}
|
public void widgetDefaultSelected(SelectionEvent e) {}
|
||||||
|
|
||||||
public void widgetSelected(SelectionEvent e) {
|
public void widgetSelected(SelectionEvent e) {
|
||||||
controlChanged(e.widget);
|
controlChanged(e.widget);
|
||||||
}
|
}
|
||||||
|
@ -554,7 +554,7 @@ public abstract class OptionsConfigurationBlock {
|
||||||
}
|
}
|
||||||
return fSelectionListener;
|
return fSelectionListener;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ModifyListener getTextModifyListener() {
|
protected ModifyListener getTextModifyListener() {
|
||||||
if (fTextModifyListener == null) {
|
if (fTextModifyListener == null) {
|
||||||
fTextModifyListener= new ModifyListener() {
|
fTextModifyListener= new ModifyListener() {
|
||||||
|
@ -564,13 +564,13 @@ public abstract class OptionsConfigurationBlock {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
return fTextModifyListener;
|
return fTextModifyListener;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void controlChanged(Widget widget) {
|
protected void controlChanged(Widget widget) {
|
||||||
ControlData data= (ControlData) widget.getData();
|
ControlData data= (ControlData) widget.getData();
|
||||||
String newValue= null;
|
String newValue= null;
|
||||||
if (widget instanceof Button) {
|
if (widget instanceof Button) {
|
||||||
newValue= data.getValue(((Button)widget).getSelection());
|
newValue= data.getValue(((Button)widget).getSelection());
|
||||||
} else if (widget instanceof Combo) {
|
} else if (widget instanceof Combo) {
|
||||||
newValue= data.getValue(((Combo)widget).getSelectionIndex());
|
newValue= data.getValue(((Combo)widget).getSelectionIndex());
|
||||||
} else {
|
} else {
|
||||||
|
@ -579,30 +579,30 @@ public abstract class OptionsConfigurationBlock {
|
||||||
String oldValue= setValue(data.getKey(), newValue);
|
String oldValue= setValue(data.getKey(), newValue);
|
||||||
validateSettings(data.getKey(), oldValue, newValue);
|
validateSettings(data.getKey(), oldValue, newValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void textChanged(Text textControl) {
|
protected void textChanged(Text textControl) {
|
||||||
Key key= (Key) textControl.getData();
|
Key key= (Key) textControl.getData();
|
||||||
String number= textControl.getText();
|
String number= textControl.getText();
|
||||||
String oldValue= setValue(key, number);
|
String oldValue= setValue(key, number);
|
||||||
validateSettings(key, oldValue, number);
|
validateSettings(key, oldValue, number);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean checkValue(Key key, String value) {
|
protected boolean checkValue(Key key, String value) {
|
||||||
return value.equals(getValue(key));
|
return value.equals(getValue(key));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String getValue(Key key) {
|
protected String getValue(Key key) {
|
||||||
if (fDisabledProjectSettings != null) {
|
if (fDisabledProjectSettings != null) {
|
||||||
return fDisabledProjectSettings.get(key);
|
return fDisabledProjectSettings.get(key);
|
||||||
}
|
}
|
||||||
return key.getStoredValue(fLookupOrder, false, fManager);
|
return key.getStoredValue(fLookupOrder, false, fManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected boolean getBooleanValue(Key key) {
|
protected boolean getBooleanValue(Key key) {
|
||||||
return Boolean.valueOf(getValue(key)).booleanValue();
|
return Boolean.valueOf(getValue(key)).booleanValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String setValue(Key key, String value) {
|
protected String setValue(Key key, String value) {
|
||||||
if (fDisabledProjectSettings != null) {
|
if (fDisabledProjectSettings != null) {
|
||||||
return fDisabledProjectSettings.put(key, value);
|
return fDisabledProjectSettings.put(key, value);
|
||||||
|
@ -611,7 +611,7 @@ public abstract class OptionsConfigurationBlock {
|
||||||
key.setStoredValue(fLookupOrder[0], value, fManager);
|
key.setStoredValue(fLookupOrder[0], value, fManager);
|
||||||
return oldValue;
|
return oldValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String setValue(Key key, boolean value) {
|
protected String setValue(Key key, boolean value) {
|
||||||
return setValue(key, String.valueOf(value));
|
return setValue(key, String.valueOf(value));
|
||||||
}
|
}
|
||||||
|
@ -624,14 +624,14 @@ public abstract class OptionsConfigurationBlock {
|
||||||
protected String getStoredValue(Key key) {
|
protected String getStoredValue(Key key) {
|
||||||
return key.getStoredValue(fLookupOrder, false, fManager);
|
return key.getStoredValue(fLookupOrder, false, fManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update fields and validate.
|
* Update fields and validate.
|
||||||
* @param changedKey Key that changed, or null, if all changed.
|
* @param changedKey Key that changed, or null, if all changed.
|
||||||
*/
|
*/
|
||||||
protected abstract void validateSettings(Key changedKey, String oldValue, String newValue);
|
protected abstract void validateSettings(Key changedKey, String oldValue, String newValue);
|
||||||
|
|
||||||
|
|
||||||
protected String[] getTokens(String text, String separator) {
|
protected String[] getTokens(String text, String separator) {
|
||||||
StringTokenizer tok= new StringTokenizer(text, separator);
|
StringTokenizer tok= new StringTokenizer(text, separator);
|
||||||
int nTokens= tok.countTokens();
|
int nTokens= tok.countTokens();
|
||||||
|
@ -660,7 +660,7 @@ public abstract class OptionsConfigurationBlock {
|
||||||
}
|
}
|
||||||
return needsBuild;
|
return needsBuild;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void useProjectSpecificSettings(boolean enable) {
|
public void useProjectSpecificSettings(boolean enable) {
|
||||||
boolean hasProjectSpecificOption= fDisabledProjectSettings == null;
|
boolean hasProjectSpecificOption= fDisabledProjectSettings == null;
|
||||||
if (enable != hasProjectSpecificOption && fProject != null) {
|
if (enable != hasProjectSpecificOption && fProject != null) {
|
||||||
|
@ -684,22 +684,22 @@ public abstract class OptionsConfigurationBlock {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean areSettingsEnabled() {
|
public boolean areSettingsEnabled() {
|
||||||
return fDisabledProjectSettings == null || fProject == null;
|
return fDisabledProjectSettings == null || fProject == null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean performOk() {
|
public boolean performOk() {
|
||||||
return processChanges(fContainer);
|
return processChanges(fContainer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean performApply() {
|
public boolean performApply() {
|
||||||
return processChanges(null); // apply directly
|
return processChanges(null); // apply directly
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean processChanges(IWorkbenchPreferenceContainer container) {
|
protected boolean processChanges(IWorkbenchPreferenceContainer container) {
|
||||||
IScopeContext currContext= fLookupOrder[0];
|
IScopeContext currContext= fLookupOrder[0];
|
||||||
|
|
||||||
List<Key> changedOptions= new ArrayList<Key>();
|
List<Key> changedOptions= new ArrayList<Key>();
|
||||||
boolean needsBuild= getChanges(currContext, changedOptions);
|
boolean needsBuild= getChanges(currContext, changedOptions);
|
||||||
if (changedOptions.isEmpty()) {
|
if (changedOptions.isEmpty()) {
|
||||||
|
@ -745,24 +745,24 @@ public abstract class OptionsConfigurationBlock {
|
||||||
// do a re-index?
|
// do a re-index?
|
||||||
// CoreUtility.getBuildJob(fProject).schedule();
|
// CoreUtility.getBuildJob(fProject).schedule();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final String[] getFullBuildDialogStrings(boolean workspaceSettings) {
|
private final String[] getFullBuildDialogStrings(boolean workspaceSettings) {
|
||||||
// rebuild (re-index) is not implemented
|
// rebuild (re-index) is not implemented
|
||||||
// no builds triggered by our settings
|
// no builds triggered by our settings
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void performDefaults() {
|
public void performDefaults() {
|
||||||
for (int i= 0; i < fAllKeys.length; i++) {
|
for (int i= 0; i < fAllKeys.length; i++) {
|
||||||
Key curr= fAllKeys[i];
|
Key curr= fAllKeys[i];
|
||||||
String defValue= curr.getStoredValue(fLookupOrder, true, fManager);
|
String defValue= curr.getStoredValue(fLookupOrder, true, fManager);
|
||||||
setValue(curr, defValue);
|
setValue(curr, defValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
settingsUpdated();
|
settingsUpdated();
|
||||||
updateControls();
|
updateControls();
|
||||||
validateSettings(null, null, null);
|
validateSettings(null, null, null);
|
||||||
|
@ -777,15 +777,15 @@ public abstract class OptionsConfigurationBlock {
|
||||||
String origValue= curr.getStoredValue(fLookupOrder, false, null);
|
String origValue= curr.getStoredValue(fLookupOrder, false, null);
|
||||||
setValue(curr, origValue);
|
setValue(curr, origValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
settingsUpdated();
|
settingsUpdated();
|
||||||
updateControls();
|
updateControls();
|
||||||
validateSettings(null, null, null);
|
validateSettings(null, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void dispose() {
|
public void dispose() {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void updateControls() {
|
protected void updateControls() {
|
||||||
// update the UI
|
// update the UI
|
||||||
for (int i= fCheckBoxes.size() - 1; i >= 0; i--) {
|
for (int i= fCheckBoxes.size() - 1; i >= 0; i--) {
|
||||||
|
@ -798,30 +798,30 @@ public abstract class OptionsConfigurationBlock {
|
||||||
updateText(fTextBoxes.get(i));
|
updateText(fTextBoxes.get(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void updateCombo(Combo curr) {
|
protected void updateCombo(Combo curr) {
|
||||||
ControlData data= (ControlData) curr.getData();
|
ControlData data= (ControlData) curr.getData();
|
||||||
|
|
||||||
String currValue= getValue(data.getKey());
|
String currValue= getValue(data.getKey());
|
||||||
curr.select(data.getSelection(currValue));
|
curr.select(data.getSelection(currValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void updateCheckBox(Button curr) {
|
protected void updateCheckBox(Button curr) {
|
||||||
ControlData data= (ControlData) curr.getData();
|
ControlData data= (ControlData) curr.getData();
|
||||||
|
|
||||||
String currValue= getValue(data.getKey());
|
String currValue= getValue(data.getKey());
|
||||||
curr.setSelection(data.getSelection(currValue) == 0);
|
curr.setSelection(data.getSelection(currValue) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void updateText(Text curr) {
|
protected void updateText(Text curr) {
|
||||||
Key key= (Key) curr.getData();
|
Key key= (Key) curr.getData();
|
||||||
|
|
||||||
String currValue= getValue(key);
|
String currValue= getValue(key);
|
||||||
if (currValue != null) {
|
if (currValue != null) {
|
||||||
curr.setText(currValue);
|
curr.setText(currValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Button getCheckBox(Key key) {
|
protected Button getCheckBox(Key key) {
|
||||||
for (int i= fCheckBoxes.size() - 1; i >= 0; i--) {
|
for (int i= fCheckBoxes.size() - 1; i >= 0; i--) {
|
||||||
Button curr= fCheckBoxes.get(i);
|
Button curr= fCheckBoxes.get(i);
|
||||||
|
@ -830,9 +830,9 @@ public abstract class OptionsConfigurationBlock {
|
||||||
return curr;
|
return curr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Combo getComboBox(Key key) {
|
protected Combo getComboBox(Key key) {
|
||||||
for (int i= fComboBoxes.size() - 1; i >= 0; i--) {
|
for (int i= fComboBoxes.size() - 1; i >= 0; i--) {
|
||||||
Combo curr= fComboBoxes.get(i);
|
Combo curr= fComboBoxes.get(i);
|
||||||
|
@ -841,9 +841,9 @@ public abstract class OptionsConfigurationBlock {
|
||||||
return curr;
|
return curr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Text getTextControl(Key key) {
|
protected Text getTextControl(Key key) {
|
||||||
for (int i= fTextBoxes.size() - 1; i >= 0; i--) {
|
for (int i= fTextBoxes.size() - 1; i >= 0; i--) {
|
||||||
Text curr= fTextBoxes.get(i);
|
Text curr= fTextBoxes.get(i);
|
||||||
|
@ -852,9 +852,9 @@ public abstract class OptionsConfigurationBlock {
|
||||||
return curr;
|
return curr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Control findControl(Key key) {
|
protected Control findControl(Key key) {
|
||||||
Combo comboBox= getComboBox(key);
|
Combo comboBox= getComboBox(key);
|
||||||
if (comboBox != null) {
|
if (comboBox != null) {
|
||||||
|
@ -870,7 +870,7 @@ public abstract class OptionsConfigurationBlock {
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setComboEnabled(Key key, boolean enabled) {
|
protected void setComboEnabled(Key key, boolean enabled) {
|
||||||
Combo combo= getComboBox(key);
|
Combo combo= getComboBox(key);
|
||||||
Label label= fLabels.get(combo);
|
Label label= fLabels.get(combo);
|
||||||
|
|
Loading…
Add table
Reference in a new issue