?? combofactory.java
字號:
package ExampleViewer.common;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import ExampleViewer.form.FieldMode;
/**
* @author
*
*
*/
public class ComboFactory {
/**
* @param parent
* @param mode
* @param layoutData
*/
static public Control create(Composite parent,
int style,
boolean bAllowValuesNotInList,
Object layoutData) {
boolean bReadOnly = ((style & SWT.READ_ONLY) != 0 ? true : false);
if (!bReadOnly) {
if (bAllowValuesNotInList)
style &= ~SWT.READ_ONLY;
else
style |= SWT.READ_ONLY;
Combo combo = new Combo(parent, style);
if (bReadOnly)
combo.setBackground(parent.getBackground());
combo.setEnabled(!bReadOnly);
if (layoutData != null) combo.setLayoutData(layoutData);
return combo;
} else {
return TextFactory.create(parent, style, layoutData,FieldMode.Read);
}
}
/**
* @param values
*/
public static void setItems(Control control, String[] values) {
if (control instanceof Combo) {
Combo combo = (Combo )control;
combo.setItems(values);
}
}
public static void selectItem(Control control, String value) {
if (control instanceof Combo) {
Combo combo = (Combo )control;
int index = combo.indexOf(value);
if (index >= 0) {
combo.select(index);
}
}
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -