preferences: generify classes
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/formatter/FormatterModifyTabPage.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/formatter/FormatterModifyTabPage.java
index 1bdfd68..a4bfb99 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/formatter/FormatterModifyTabPage.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/formatter/FormatterModifyTabPage.java
@@ -192,8 +192,8 @@
public void updatePreview() {
if (previewViewer != null) {
FormatterPreviewUtils.updatePreview(previewViewer,
- getPreviewContent(), dialog.getFormatterFactory(), dialog
- .getPreferences());
+ getPreviewContent(), dialog.getFormatterFactory(),
+ dialog.getPreferences());
}
}
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/formatter/IFormatterControlManager.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/formatter/IFormatterControlManager.java
index 64685eb..f7b36e4 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/formatter/IFormatterControlManager.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/formatter/IFormatterControlManager.java
@@ -18,7 +18,7 @@
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Text;
-public interface IFormatterControlManager extends IPreferenceDelegate {
+public interface IFormatterControlManager extends IPreferenceDelegate<String> {
public interface IInitializeListener {
void initialize();
@@ -28,9 +28,9 @@
void removeInitializeListener(IInitializeListener listener);
- Button createCheckbox(Composite parent, Object key, String text);
+ Button createCheckbox(Composite parent, String key, String text);
- Button createCheckbox(Composite parent, Object key, String text, int hspan);
+ Button createCheckbox(Composite parent, String key, String text, int hspan);
/**
* @param parent
@@ -40,12 +40,12 @@
* @return
* @deprecated
*/
- Combo createCombo(Composite parent, Object key, String label, String[] items);
+ Combo createCombo(Composite parent, String key, String label, String[] items);
- Combo createCombo(Composite parent, Object key, String label,
+ Combo createCombo(Composite parent, String key, String label,
String[] itemValues, String[] itemLabels);
- Text createNumber(Composite parent, Object key, String label);
+ Text createNumber(Composite parent, String key, String label);
void enableControl(Control control, boolean enabled);
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/formatter/internal/FormatterControlManager.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/formatter/internal/FormatterControlManager.java
index 5220679..15f9da7 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/formatter/internal/FormatterControlManager.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/formatter/internal/FormatterControlManager.java
@@ -34,22 +34,22 @@
public class FormatterControlManager implements IFormatterControlManager,
IStatusChangeListener {
- private final IPreferenceDelegate delegate;
- private final ControlBindingManager bindingManager;
+ private final IPreferenceDelegate<String> delegate;
+ private final ControlBindingManager<String> bindingManager;
private final IStatusChangeListener listener;
- public FormatterControlManager(IPreferenceDelegate delegate,
+ public FormatterControlManager(IPreferenceDelegate<String> delegate,
IStatusChangeListener listener) {
this.delegate = delegate;
- this.bindingManager = new ControlBindingManager(delegate, this);
+ this.bindingManager = new ControlBindingManager<String>(delegate, this);
this.listener = listener;
}
- public Button createCheckbox(Composite parent, Object key, String text) {
+ public Button createCheckbox(Composite parent, String key, String text) {
return createCheckbox(parent, key, text, 1);
}
- public Button createCheckbox(Composite parent, Object key, String text,
+ public Button createCheckbox(Composite parent, String key, String text,
int hspan) {
Button button = SWTFactory.createCheckButton(parent, text, null, false,
hspan);
@@ -57,7 +57,7 @@
return button;
}
- public Combo createCombo(Composite parent, Object key, String label,
+ public Combo createCombo(Composite parent, String key, String label,
String[] items) {
final Label labelControl = SWTFactory.createLabel(parent, label, 1);
Combo combo = SWTFactory.createCombo(parent,
@@ -67,7 +67,7 @@
return combo;
}
- public Combo createCombo(Composite parent, Object key, String label,
+ public Combo createCombo(Composite parent, String key, String label,
String[] itemValues, String[] itemLabels) {
final Label labelControl = SWTFactory.createLabel(parent, label, 1);
Combo combo = SWTFactory.createCombo(parent,
@@ -77,7 +77,7 @@
return combo;
}
- public Text createNumber(Composite parent, Object key, String label) {
+ public Text createNumber(Composite parent, String key, String label) {
final Label labelControl = SWTFactory.createLabel(parent, label, 1);
Text text = SWTFactory.createText(parent, SWT.BORDER, 1,
Util.EMPTY_STRING);
@@ -137,19 +137,19 @@
}
}
- public boolean getBoolean(Object key) {
+ public boolean getBoolean(String key) {
return delegate.getBoolean(key);
}
- public String getString(Object key) {
+ public String getString(String key) {
return delegate.getString(key);
}
- public void setBoolean(Object key, boolean value) {
+ public void setBoolean(String key, boolean value) {
delegate.setBoolean(key, value);
}
- public void setString(Object key, String value) {
+ public void setString(String key, String value) {
delegate.setString(key, value);
}
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/formatter/internal/FormatterDialogPreferences.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/formatter/internal/FormatterDialogPreferences.java
index 4efaa2d..1523ef1 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/formatter/internal/FormatterDialogPreferences.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/formatter/internal/FormatterDialogPreferences.java
@@ -18,24 +18,24 @@
import org.eclipse.dltk.compiler.util.Util;
import org.eclipse.dltk.ui.preferences.IPreferenceDelegate;
-public class FormatterDialogPreferences implements IPreferenceDelegate {
+public class FormatterDialogPreferences implements IPreferenceDelegate<String> {
private final Map<String, String> preferences = new HashMap<String, String>();
- public String getString(Object key) {
+ public String getString(String key) {
final String value = preferences.get(key);
return value != null ? value : Util.EMPTY_STRING;
}
- public boolean getBoolean(Object key) {
+ public boolean getBoolean(String key) {
return Boolean.valueOf(getString(key)).booleanValue();
}
- public void setString(Object key, String value) {
- preferences.put((String) key, value);
+ public void setString(String key, String value) {
+ preferences.put(key, value);
}
- public void setBoolean(Object key, boolean value) {
+ public void setBoolean(String key, boolean value) {
setString(key, String.valueOf(value));
}
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/preferences/AbstractConfigurationBlock.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/preferences/AbstractConfigurationBlock.java
index f8afaa7..99b9e7b 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/preferences/AbstractConfigurationBlock.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/preferences/AbstractConfigurationBlock.java
@@ -23,9 +23,9 @@
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
import org.eclipse.dltk.internal.corext.util.Messages;
-import org.eclipse.dltk.ui.dialogs.StatusInfo;
import org.eclipse.dltk.internal.ui.dialogs.StatusUtil;
import org.eclipse.dltk.internal.ui.preferences.ScrolledPageContent;
+import org.eclipse.dltk.ui.dialogs.StatusInfo;
import org.eclipse.dltk.ui.util.PixelConverter;
import org.eclipse.dltk.ui.util.SWTFactory;
import org.eclipse.jface.dialogs.Dialog;
@@ -99,7 +99,7 @@
/** The preference setting for keeping no section open. */
private static final String __NONE = "__none"; //$NON-NLS-1$
- private Set fSections = new HashSet();
+ private Set<ExpandableComposite> fSections = new HashSet<ExpandableComposite>();
private boolean fIsBeingManaged = false;
@@ -113,10 +113,9 @@
if (e.getState()) {
try {
fIsBeingManaged = true;
- for (Iterator iter = fSections.iterator(); iter
- .hasNext();) {
- ExpandableComposite composite = (ExpandableComposite) iter
- .next();
+ for (Iterator<ExpandableComposite> iter = fSections
+ .iterator(); iter.hasNext();) {
+ ExpandableComposite composite = iter.next();
if (composite != source)
composite.setExpanded(false);
}
@@ -124,8 +123,8 @@
fIsBeingManaged = false;
}
if (fLastOpenKey != null && fDialogSettingsStore != null)
- fDialogSettingsStore.setValue(fLastOpenKey, source
- .getText());
+ fDialogSettingsStore.setValue(fLastOpenKey,
+ source.getText());
} else {
if (!fIsBeingManaged && fLastOpenKey != null
&& fDialogSettingsStore != null)
@@ -179,8 +178,8 @@
* composite within that, to ensure that expanding the sections will
* always have enough space, unless there already is a
* <code>ScrolledComposite</code> along the parent chain of
- * <code>parent</code>, in which case a normal <code>Composite</code>
- * is created.
+ * <code>parent</code>, in which case a normal <code>Composite</code> is
+ * created.
* <p>
* The receiver keeps a reference to the inner body composite, so that
* new sections can be added via <code>createSection</code>.
@@ -254,7 +253,7 @@
private OverlayPreferenceStore fStore;
- private Map fCheckBoxes = new HashMap();
+ private Map<Button, String> fCheckBoxes = new HashMap<Button, String>();
private ArrayList fRadioButtons = new ArrayList();
@@ -266,8 +265,7 @@
public void widgetSelected(SelectionEvent e) {
Button button = (Button) e.widget;
- fStore.setValue((String) fCheckBoxes.get(button), button
- .getSelection());
+ fStore.setValue(fCheckBoxes.get(button), button.getSelection());
}
};
@@ -300,12 +298,12 @@
}
};
- private Map fTextFields = new HashMap();
+ private Map<Text, String> fTextFields = new HashMap<Text, String>();
private ModifyListener fTextFieldListener = new ModifyListener() {
public void modifyText(ModifyEvent e) {
Text text = (Text) e.widget;
- fStore.setValue((String) fTextFields.get(text), text.getText());
+ fStore.setValue(fTextFields.get(text), text.getText());
}
};
@@ -328,7 +326,7 @@
private org.eclipse.dltk.ui.dialogs.StatusInfo fStatus;
private final PreferencePage fMainPage;
-
+
protected Shell getShell() {
return fMainPage.getShell();
}
@@ -469,10 +467,10 @@
}
/**
- * Returns an array of size 2: - first element is of type <code>Label</code> -
- * second element is of type <code>Text</code> Use
- * <code>getLabelControl</code> and <code>getTextControl</code> to get
- * the 2 controls.
+ * Returns an array of size 2: - first element is of type <code>Label</code>
+ * - second element is of type <code>Text</code> Use
+ * <code>getLabelControl</code> and <code>getTextControl</code> to get the 2
+ * controls.
*
* @param composite
* the parent composite
@@ -485,8 +483,7 @@
* @param indentation
* the field's indentation
* @param isNumber
- * <code>true</code> iff this text field is used to edit a
- * number
+ * <code>true</code> iff this text field is used to edit a number
* @return the controls added
*/
protected Control[] addLabelledTextField(Composite composite, String label,
@@ -643,23 +640,18 @@
private IStatus validatePositiveNumber(String number) {
StatusInfo status = new StatusInfo();
if (number.length() == 0) {
- status
- .setError(PreferencesMessages.DLTKEditorPreferencePage_empty_input);
+ status.setError(PreferencesMessages.DLTKEditorPreferencePage_empty_input);
} else {
try {
int value = Integer.parseInt(number);
if (value < 0)
- status
- .setError(Messages
- .format(
- PreferencesMessages.DLTKEditorPreferencePage_invalid_input,
- number));
+ status.setError(Messages
+ .format(PreferencesMessages.DLTKEditorPreferencePage_invalid_input,
+ number));
} catch (NumberFormatException e) {
- status
- .setError(Messages
- .format(
- PreferencesMessages.DLTKEditorPreferencePage_invalid_input,
- number));
+ status.setError(Messages
+ .format(PreferencesMessages.DLTKEditorPreferencePage_invalid_input,
+ number));
}
}
return status;
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/preferences/AbstractOptionsBlock.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/preferences/AbstractOptionsBlock.java
index dbe05ed..2d33a1f 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/preferences/AbstractOptionsBlock.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/preferences/AbstractOptionsBlock.java
@@ -21,18 +21,19 @@
import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
public abstract class AbstractOptionsBlock extends OptionsConfigurationBlock
- implements IPreferenceDelegate {
+ implements IPreferenceDelegate<PreferenceKey> {
private final List<PreferenceKey> keys = new ArrayList<PreferenceKey>();
- private ControlBindingManager bindManager;
+ private ControlBindingManager<PreferenceKey> bindManager;
public AbstractOptionsBlock(IStatusChangeListener context,
IProject project, PreferenceKey[] allKeys,
IWorkbenchPreferenceContainer container) {
super(context, project, allKeys, container);
- this.bindManager = new ControlBindingManager(this, context);
+ this.bindManager = new ControlBindingManager<PreferenceKey>(this,
+ context);
}
public Control createContents(Composite parent) {
@@ -189,8 +190,8 @@
* org.eclipse.dltk.ui.preferences.IPreferenceDelegate#getBoolean(java.lang
* .Object)
*/
- public final boolean getBoolean(Object key) {
- return getBooleanValue((PreferenceKey) key);
+ public final boolean getBoolean(PreferenceKey key) {
+ return getBooleanValue(key);
}
/*
@@ -198,8 +199,8 @@
* org.eclipse.dltk.ui.preferences.IPreferenceDelegate#getString(java.lang
* .Object)
*/
- public final String getString(Object key) {
- return getValue((PreferenceKey) key);
+ public final String getString(PreferenceKey key) {
+ return getValue(key);
}
/*
@@ -207,8 +208,8 @@
* org.eclipse.dltk.ui.preferences.IPreferenceDelegate#setBoolean(java.lang
* .Object, boolean)
*/
- public final void setBoolean(Object key, boolean value) {
- super.setValue((PreferenceKey) key, value);
+ public final void setBoolean(PreferenceKey key, boolean value) {
+ super.setValue(key, value);
}
/*
@@ -216,8 +217,8 @@
* org.eclipse.dltk.ui.preferences.IPreferenceDelegate#setString(java.lang
* .Object, java.lang.String)
*/
- public final void setString(Object key, String value) {
- setValue((PreferenceKey) key, value);
+ public final void setString(PreferenceKey key, String value) {
+ setValue(key, value);
}
protected final IProject getProject() {
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/preferences/ControlBindingManager.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/preferences/ControlBindingManager.java
index 6fe5a28..b904f59 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/preferences/ControlBindingManager.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/preferences/ControlBindingManager.java
@@ -24,20 +24,20 @@
/**
*/
-public class ControlBindingManager {
- private IStatusChangeListener changeListener;
+public class ControlBindingManager<KEY> {
+ final IStatusChangeListener changeListener;
- private Map checkBoxControls;
- private Map comboControls;
- private final Map comboValueProviders = new IdentityHashMap();
+ private Map<Button, KEY> checkBoxControls;
+ private Map<Combo, KEY> comboControls;
+ private final Map<Combo, IComboSelectedValueProvider> comboValueProviders = new IdentityHashMap<Combo, IComboSelectedValueProvider>();
private DependencyManager dependencyManager;
- private IPreferenceDelegate preferenceDelegate;
- private Map radioControls;
+ final IPreferenceDelegate<KEY> preferenceDelegate;
+ private Map<Button, KEY> radioControls;
- private Map textControls;
- private final Map textTransformers = new HashMap();
+ private Map<Text, KEY> textControls;
+ private final Map<Text, ITextConverter> textTransformers = new HashMap<Text, ITextConverter>();
private ValidatorManager validatorManager;
public static class DependencyMode {
@@ -51,12 +51,12 @@
int indexOf(String value);
}
- public ControlBindingManager(IPreferenceDelegate delegate,
+ public ControlBindingManager(IPreferenceDelegate<KEY> delegate,
IStatusChangeListener listener) {
- this.checkBoxControls = new HashMap();
- this.comboControls = new HashMap();
- this.textControls = new HashMap();
- this.radioControls = new HashMap();
+ this.checkBoxControls = new HashMap<Button, KEY>();
+ this.comboControls = new HashMap<Combo, KEY>();
+ this.textControls = new HashMap<Text, KEY>();
+ this.radioControls = new HashMap<Button, KEY>();
this.validatorManager = new ValidatorManager();
this.dependencyManager = new DependencyManager();
@@ -65,7 +65,7 @@
this.preferenceDelegate = delegate;
}
- public void bindControl(final Combo combo, final Object key) {
+ public void bindControl(final Combo combo, final KEY key) {
bindControl(combo, key, new IComboSelectedValueProvider() {
public String getValueAt(int index) {
@@ -85,7 +85,7 @@
});
}
- public void bindControl(Combo combo, Object key, final String[] itemValues) {
+ public void bindControl(Combo combo, KEY key, final String[] itemValues) {
bindControl(combo, key, new IComboSelectedValueProvider() {
public String getValueAt(int index) {
return itemValues[index];
@@ -102,7 +102,7 @@
});
}
- public void bindControl(final Combo combo, final Object key,
+ public void bindControl(final Combo combo, final KEY key,
final IComboSelectedValueProvider itemValueProvider) {
if (key != null) {
comboControls.put(combo, key);
@@ -116,16 +116,15 @@
public void widgetSelected(SelectionEvent e) {
int index = combo.getSelectionIndex();
- preferenceDelegate.setString(key, itemValueProvider
- .getValueAt(index));
+ preferenceDelegate.setString(key,
+ itemValueProvider.getValueAt(index));
changeListener.statusChanged(StatusInfo.OK_STATUS);
}
});
}
- public void bindControl(final Button button, final Object key,
- Control[] slaves) {
+ public void bindControl(final Button button, final KEY key, Control[] slaves) {
if (key != null) {
checkBoxControls.put(button, key);
}
@@ -146,12 +145,12 @@
});
}
- public void bindControl(final Text text, final Object key,
+ public void bindControl(final Text text, final KEY key,
IFieldValidator validator) {
bindControl(text, key, validator, null);
}
- public void bindControl(final Text text, final Object key,
+ public void bindControl(final Text text, final KEY key,
IFieldValidator validator, final ITextConverter transformer) {
if (key != null) {
if (textControls.containsKey(key)) {
@@ -193,7 +192,7 @@
});
}
- public void bindRadioControl(final Button button, final String key,
+ public void bindRadioControl(final Button button, final KEY key,
final Object enable, Control[] dependencies) {
if (key != null) {
radioControls.put(button, key);
@@ -227,9 +226,9 @@
public IStatus getStatus() {
IStatus status = StatusInfo.OK_STATUS;
- Iterator iter = textControls.keySet().iterator();
+ Iterator<Text> iter = textControls.keySet().iterator();
while (iter.hasNext()) {
- IStatus s = validateText((Text) iter.next());
+ IStatus s = validateText(iter.next());
status = StatusUtil.getMoreSevere(s, status);
}
@@ -247,9 +246,9 @@
protected void updateStatus(IStatus status) {
if (!status.matches(IStatus.ERROR)) {
- Iterator iter = textControls.keySet().iterator();
+ Iterator<Text> iter = textControls.keySet().iterator();
while (iter.hasNext()) {
- IStatus s = validateText((Text) iter.next());
+ IStatus s = validateText(iter.next());
status = StatusUtil.getMoreSevere(s, status);
}
}
@@ -258,21 +257,20 @@
}
private void initCheckBoxes() {
- Iterator it = checkBoxControls.keySet().iterator();
+ Iterator<Button> it = checkBoxControls.keySet().iterator();
while (it.hasNext()) {
- final Button button = (Button) it.next();
- final Object key = checkBoxControls.get(button);
+ final Button button = it.next();
+ final KEY key = checkBoxControls.get(button);
button.setSelection(preferenceDelegate.getBoolean(key));
}
}
private void initCombos() {
- for (Iterator it = comboControls.entrySet().iterator(); it.hasNext();) {
- final Map.Entry entry = (Map.Entry) it.next();
- final Combo combo = (Combo) entry.getKey();
- final Object key = entry.getValue();
+ for (final Map.Entry<Combo, KEY> entry : comboControls.entrySet()) {
+ final Combo combo = entry.getKey();
+ final KEY key = entry.getValue();
final String value = preferenceDelegate.getString(key);
- final IComboSelectedValueProvider valueProvider = (IComboSelectedValueProvider) comboValueProviders
+ final IComboSelectedValueProvider valueProvider = comboValueProviders
.get(combo);
if (valueProvider != null) {
int index = valueProvider.indexOf(value);
@@ -286,10 +284,10 @@
}
private void initRadioControls() {
- Iterator it = radioControls.keySet().iterator();
+ Iterator<Button> it = radioControls.keySet().iterator();
while (it.hasNext()) {
- Button button = (Button) it.next();
- Object key = radioControls.get(button);
+ Button button = it.next();
+ KEY key = radioControls.get(button);
String enable = (String) button.getData();
String value = preferenceDelegate.getString(key);
@@ -303,13 +301,12 @@
}
private void initTextControls() {
- Iterator it = textControls.keySet().iterator();
+ Iterator<Text> it = textControls.keySet().iterator();
while (it.hasNext()) {
- final Text text = (Text) it.next();
- final Object key = textControls.get(text);
+ final Text text = it.next();
+ final KEY key = textControls.get(text);
String value = preferenceDelegate.getString(key);
- final ITextConverter textTransformer = (ITextConverter) textTransformers
- .get(text);
+ final ITextConverter textTransformer = textTransformers.get(text);
if (textTransformer != null) {
value = textTransformer.convertPreference(value);
}
@@ -330,7 +327,7 @@
/**
*/
class DependencyManager {
- private List masterSlaveListeners = new ArrayList();
+ private List<SelectionListener> masterSlaveListeners = new ArrayList<SelectionListener>();
public void createDependency(final Button master,
final Control[] slaves, final DependencyMode mode) {
@@ -359,29 +356,26 @@
}
public void initialize() {
- Iterator it = masterSlaveListeners.iterator();
+ Iterator<SelectionListener> it = masterSlaveListeners.iterator();
while (it.hasNext()) {
- ((SelectionListener) it.next()).widgetSelected(null);
+ it.next().widgetSelected(null);
}
}
}
- /**
- */
- class ValidatorManager {
-
- private Map map = new HashMap();
+ @SuppressWarnings("serial")
+ static class ValidatorManager extends HashMap<Control, IFieldValidator> {
public IFieldValidator getValidator(Control control) {
- return (IFieldValidator) map.get(control);
+ return get(control);
}
public void registerValidator(Text text, IFieldValidator validator) {
- map.put(text, validator);
+ put(text, validator);
}
public void unregisterValidator(Text text) {
- map.remove(text);
+ remove(text);
}
}
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/preferences/IPreferenceDelegate.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/preferences/IPreferenceDelegate.java
index 1d464bb..b5c3d24 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/preferences/IPreferenceDelegate.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/preferences/IPreferenceDelegate.java
@@ -16,25 +16,25 @@
* @see AbstractOptionsBlock
* @see ImprovedAbstractConfigurationBlock
*/
-public interface IPreferenceDelegate {
+public interface IPreferenceDelegate<KEY> {
/**
* Returns the string value for the given preference key
*/
- String getString(Object key);
+ String getString(KEY key);
/**
* Returns the boolean value for the given preference key
*/
- boolean getBoolean(Object key);
+ boolean getBoolean(KEY key);
/**
* Set a boolean preference value
*/
- void setBoolean(Object key, boolean value);
+ void setBoolean(KEY key, boolean value);
/**
* Set a string preference value
*/
- void setString(Object key, String value);
+ void setString(KEY key, String value);
}
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/preferences/ImprovedAbstractConfigurationBlock.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/preferences/ImprovedAbstractConfigurationBlock.java
index 3bcec55..5e28a81 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/preferences/ImprovedAbstractConfigurationBlock.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/preferences/ImprovedAbstractConfigurationBlock.java
@@ -28,19 +28,20 @@
* Configures preferences.
*/
public abstract class ImprovedAbstractConfigurationBlock implements
- IPreferenceConfigurationBlock, IPreferenceDelegate {
+ IPreferenceConfigurationBlock, IPreferenceDelegate<String> {
private PreferencePage page;
private OverlayPreferenceStore store;
- private ControlBindingManager bindManager;
+ private final ControlBindingManager<String> bindManager;
public ImprovedAbstractConfigurationBlock(OverlayPreferenceStore store,
final PreferencePage page) {
this.page = page;
this.store = store;
- bindManager = new ControlBindingManager(this, getStatusListener());
+ bindManager = new ControlBindingManager<String>(this,
+ getStatusListener());
addOverlayKeys();
}
@@ -60,20 +61,20 @@
// do nothing
}
- public boolean getBoolean(Object key) {
- return store.getBoolean((String) key);
+ public boolean getBoolean(String key) {
+ return store.getBoolean(key);
}
- public String getString(Object key) {
- return store.getString((String) key);
+ public String getString(String key) {
+ return store.getString(key);
}
- public void setBoolean(Object key, boolean value) {
- store.setValue((String) key, value);
+ public void setBoolean(String key, boolean value) {
+ store.setValue(key, value);
}
- public void setString(Object key, String value) {
- store.setValue((String) key, value);
+ public void setString(String key, String value) {
+ store.setValue(key, value);
}
/**