I created the SmartComboFieldEditor class to allow me to elegantly get and set the ComboFieldEditor value using the backup data store behind the scenes.
package wat.core.plugin; import org.eclipse.jface.preference.ComboFieldEditor; import org.eclipse.swt.widgets.Composite; public class SmartComboFieldEditor extends ComboFieldEditor { public SmartComboFieldEditor(String name, String labelText, String[][] entryNamesAndValues, Composite parent) { super(name, labelText, entryNamesAndValues, parent); } public String getSelectedValue() { doStore(); return getPreferenceStore().getString(getPreferenceName()); } public void setSelectedValue(String newValue) { getPreferenceStore().setValue(getPreferenceName(), newValue); doLoad(); } }
Then you can override the propertyChange and performOK methods as follows:
public void propertyChange(PropertyChangeEvent event) { super.propertyChange(event); if (event.getSource() == combo1) { if (combo1.getSelectedValue().equals("Some Value")) { combo2.setSelectedValue("Some Other Value"); } } }
source share