IntListParameterpublic class IntListParameter extends Parameter
Fields Summary |
---|
org.eclipse.swt.widgets.Combo | list | private final int[] | values | private final String | name |
Constructors Summary |
---|
public IntListParameter(org.eclipse.swt.widgets.Composite composite, String name, String[] labels, int[] values)
this(composite, name, COConfigurationManager.getIntParameter(name), labels, values);
| public IntListParameter(org.eclipse.swt.widgets.Composite composite, String name, int defaultValue, String[] labels, int[] values)
super(name);
this.name = name;
this.values = values;
if(labels.length != values.length)
return;
int value = COConfigurationManager.getIntParameter(name,defaultValue);
int index = findIndex(value,values);
list = new Combo(composite,SWT.SINGLE | SWT.READ_ONLY);
for(int i = 0 ; i < labels.length ;i++) {
list.add(labels[i]);
}
setIndex(index);
list.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event e) {
setIndex(list.getSelectionIndex());
}
});
|
Methods Summary |
---|
private int | findIndex(int value, int[] values)
for(int i = 0 ; i < values.length ;i++) {
if(values[i] == value)
return i;
}
return 0;
| public org.eclipse.swt.widgets.Control | getControl()
return list;
| public java.lang.Object | getValueObject()
return new Integer(COConfigurationManager.getIntParameter(name));
| protected void | setIndex(int index)
int selected_value = values[index];
Utils.execSWTThread(new AERunnable() {
public void runSupport() {
if (list == null || list.isDisposed()) {
return;
}
if (list.getSelectionIndex() != index) {
list.select(index);
}
}
});
if (COConfigurationManager.getIntParameter(name) != selected_value) {
COConfigurationManager.setParameter(name, selected_value);
}
| public void | setLayoutData(java.lang.Object layoutData)
list.setLayoutData(layoutData);
| public void | setValue(java.lang.Object value)
if (value instanceof Number) {
int i = ((Number)value).intValue();
setIndex(findIndex(i, values));
}
|
|