use of org.eclipse.swt.events.FocusEvent in project yamcs-studio by yamcs.
the class OPIRuntimePreferencePage method createFieldEditors.
@Override
protected void createFieldEditors() {
final Composite parent = getFieldEditorParent();
macrosEditor = new StringTableFieldEditor(PreferencesHelper.RUN_MACROS, "Macros: ", parent, new String[] { "Name", "Value" }, new boolean[] { true, true }, new MacroEditDialog(parent.getShell()), new int[] { 120, 120 }) {
@Override
public boolean isValid() {
String reason;
for (String[] row : items) {
reason = Verifier.checkElementName(row[0]);
if (reason != null) {
wrongMacroName = row[0];
return false;
}
}
return true;
}
@Override
protected void doStore() {
if (!isValid())
return;
super.doStore();
}
@Override
protected void doFillIntoGrid(Composite parent, int numColumns) {
super.doFillIntoGrid(parent, numColumns);
tableEditor.getTableViewer().getTable().addKeyListener(new KeyAdapter() {
@Override
public void keyReleased(KeyEvent e) {
boolean valid = isValid();
fireStateChanged(IS_VALID, !valid, valid);
}
});
tableEditor.getTableViewer().getTable().addFocusListener(new FocusListener() {
@Override
public void focusLost(FocusEvent e) {
boolean valid = isValid();
fireStateChanged(IS_VALID, !valid, valid);
}
@Override
public void focusGained(FocusEvent e) {
boolean valid = isValid();
fireStateChanged(IS_VALID, !valid, valid);
}
});
}
};
addField(macrosEditor);
IntegerFieldEditor guiRefreshCycleEditor = new IntegerFieldEditor(PreferencesHelper.OPI_GUI_REFRESH_CYCLE, "OPI GUI Refresh Cycle (ms)", parent);
guiRefreshCycleEditor.setValidRange(10, 5000);
guiRefreshCycleEditor.getTextControl(parent).setToolTipText("The fastest refresh cycle for OPI GUI in millisecond");
addField(guiRefreshCycleEditor);
IntegerFieldEditor pulsingMinorPeriodFieldEditor = new IntegerFieldEditor(PreferencesHelper.PULSING_ALARM_MINOR_PERIOD, "Time period of MINOR alarm if pulsing alarm selected (ms)", parent);
pulsingMinorPeriodFieldEditor.setValidRange(100, 10000);
pulsingMinorPeriodFieldEditor.getTextControl(parent).setToolTipText("If the pulsing alarm box is checked for a widget that monitors a PV, " + "then what is the time period of the pulse with the PV is in MINOR alarm severity");
addField(pulsingMinorPeriodFieldEditor);
IntegerFieldEditor pulsingMajorPeriodFieldEditor = new IntegerFieldEditor(PreferencesHelper.PULSING_ALARM_MAJOR_PERIOD, "Time period of MAJOR alarm if pulsing alarm selected (ms)", parent);
pulsingMajorPeriodFieldEditor.setValidRange(100, 10000);
pulsingMajorPeriodFieldEditor.getTextControl(parent).setToolTipText("If the pulsing alarm box is checked for a widget that monitors a PV, " + "then what is the time period of the pulse with the PV is in MAJOR alarm severity");
addField(pulsingMajorPeriodFieldEditor);
String[] allPVFactories = SimplePVLayer.getAllPVFactoryExtensions();
String[][] entries = new String[allPVFactories.length][2];
for (int i = 0; i < allPVFactories.length; i++) {
entries[i][0] = allPVFactories[i];
entries[i][1] = allPVFactories[i];
}
ComboFieldEditor pvConnectionLayerEditor = new ComboFieldEditor(PreferencesHelper.PV_CONNECTION_LAYER, "PV Connection Layer", entries, parent);
addField(pvConnectionLayerEditor);
ComboFieldEditor popupConsoleEditor = new ComboFieldEditor(PreferencesHelper.POPUP_CONSOLE, "Console Popup Level", new String[][] { { "Error, Warning and Info", ConsolePopupLevel.ALL.toString() }, { "Only Info", ConsolePopupLevel.ONLY_INFO.toString() }, { "Don't Popup", ConsolePopupLevel.NO_POP.toString() } }, parent);
addField(popupConsoleEditor);
StringFieldEditor pythonPathEditor = new StringFieldEditor(PreferencesHelper.PYTHON_PATH, "PYTHONPATH", parent);
pythonPathEditor.getTextControl(parent).setToolTipText("The path to search python modules");
addField(pythonPathEditor);
BooleanFieldEditor showCompactModeDialogEditor = new BooleanFieldEditor(PreferencesHelper.SHOW_COMPACT_MODE_DIALOG, "Show tip dialog about how to exit compact mode", parent);
addField(showCompactModeDialogEditor);
BooleanFieldEditor showFullScreenDialogEditor = new BooleanFieldEditor(PreferencesHelper.SHOW_FULLSCREEN_DIALOG, "Show tip dialog about how to exit fullscreen", parent);
addField(showFullScreenDialogEditor);
BooleanFieldEditor startWindowInCompactEditor = new BooleanFieldEditor(PreferencesHelper.START_WINDOW_IN_COMPACT_MODE, "Start application window in compact mode.", parent);
addField(startWindowInCompactEditor);
}
use of org.eclipse.swt.events.FocusEvent in project yamcs-studio by yamcs.
the class PartZoomComboContributionItem method createControl.
/**
* Creates and returns the control for this contribution item under the
* given parent composite.
*
* @param parent
* the parent composite
* @return the new control
*/
protected Control createControl(Composite parent) {
combo = new Combo(parent, SWT.DROP_DOWN);
combo.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
handleWidgetSelected(e);
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
handleWidgetDefaultSelected(e);
}
});
combo.addFocusListener(new FocusListener() {
@Override
public void focusGained(FocusEvent e) {
// do nothing
}
@Override
public void focusLost(FocusEvent e) {
refresh(false);
}
});
// Initialize width of combo
combo.setItems(initStrings);
toolitem.setWidth(computeWidth(combo));
refresh(true);
return combo;
}
use of org.eclipse.swt.events.FocusEvent in project cubrid-manager by CUBRID.
the class BrokerConfigEditComposite method registerContextMenu.
/**
* Register context menu
*/
private void registerContextMenu() {
final Table confTable = confTableViewer.getTable();
confTable.addFocusListener(new FocusAdapter() {
@Override
public void focusGained(FocusEvent event) {
ActionManager.getInstance().changeFocusProvider(confTable);
}
});
final MenuManager menuManager = new MenuManager();
menuManager.setRemoveAllWhenShown(true);
final Menu contextMenu = menuManager.createContextMenu(confTable);
confTable.setMenu(contextMenu);
final Menu menu = new Menu(editorPart.getSite().getShell(), SWT.POP_UP);
final MenuItem itemEditAnnotation = new MenuItem(menu, SWT.PUSH);
itemEditAnnotation.setText(Messages.cubridBrokerConfEditorTableMenuEditAnnotation);
itemEditAnnotation.addSelectionListener(new SelectionAdapter() {
@SuppressWarnings("all")
public void widgetSelected(SelectionEvent event) {
// It seems like MenuEvent can't get the mouse click Point
// so use the point which table MouseDown event marked
final Point pt = clickPoint;
int selectIndex = confTable.getSelectionIndex();
if (selectIndex < 0) {
return;
}
final TableItem item = confTable.getItem(selectIndex);
if (item == null) {
return;
}
for (int i = 0, len = confTable.getColumnCount(); i < len; i++) {
Rectangle rect = item.getBounds(i);
if (rect.contains(pt)) {
if (i == 0) {
openErrorBox(editorPart.getSite().getShell(), Messages.cubridBrokerConfEditAnnotationDialogOpenErrorMsg);
return;
}
IStructuredSelection selection = (IStructuredSelection) confTableViewer.getSelection();
HashMap<String, String> valueMap = (HashMap<String, String>) selection.getFirstElement();
String brokerName = confListData.get(0).get(String.valueOf(i));
String parentPropertyKey = valueMap.get("0");
String parentKey = " ";
if (selectIndex == 0) {
parentKey += brokerName;
} else {
parentKey += brokerName + "->" + parentPropertyKey;
}
String annotationKey = i + ANNOTATION;
CubridBrokerConfEditAnnotationDialog dialog = new CubridBrokerConfEditAnnotationDialog(editorPart.getSite().getShell(), parentKey, annotationKey, valueMap);
if (dialog.open() == OK_ID) {
editorPart.setDirty(true);
}
}
}
}
});
final MenuItem itemAddBrokerConf = new MenuItem(menu, SWT.PUSH);
itemAddBrokerConf.setText(Messages.cubridBrokerConfEditorAddBrokerConfItemLabel);
itemAddBrokerConf.setImage(CommonUIPlugin.getImage("icons/action/column_insert.png"));
itemAddBrokerConf.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
addBrokerConfColumn();
editorPart.setDirty(true);
}
});
final MenuItem itemDeleteBrokerConf = new MenuItem(menu, SWT.PUSH);
itemDeleteBrokerConf.setText(Messages.cubridBrokerConfEditorDeleteBrokerConfItemLabel);
itemDeleteBrokerConf.setImage(CommonUIPlugin.getImage("icons/action/column_delete.png"));
itemDeleteBrokerConf.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
// It seems like MenuEvent can't get the mouse click Point
// so use the point which table MouseDown event marked
final Point pt = clickPoint;
final TableItem item = findSelectItem(confTable);
if (item == null) {
return;
}
int columnCount = confTable.getColumnCount();
for (int i = 0; i < columnCount; i++) {
Rectangle rect = item.getBounds(i);
if (rect.contains(pt)) {
Map<String, String> valueMap = confListData.get(0);
String confName = valueMap.get(String.valueOf(i));
String msg = Messages.bind(Messages.cubridBrokerConfEditorDeleteBrokerConfConfirm, confName);
if (!CommonUITool.openConfirmBox(msg)) {
return;
}
confTable.getColumn(i).dispose();
for (int j = 1; j < columnCount; j++) {
confTable.getColumn(j).setText(Messages.cubridBrokerConfEditorBrokerTitle + (j - 1));
}
// delete data from cubridBrokerConfig, so regenerate cubridBrokerConfListData from cubridBrokerConfig
editorPart.getBrokerConfPersistUtil().deleteBrokerPropertyByBrokerName(brokerConfig, confName);
confListData.clear();
confListData.addAll(editorPart.parseBrokerConfigToCommonTableValue(brokerConfig));
confTableViewer.refresh();
editorPart.setDirty(true);
return;
}
}
}
});
menu.addMenuListener(new MenuAdapter() {
public void menuShown(MenuEvent event) {
// It seems like MenuEvent can't get the mouse click Point
// so use the point which table MouseDown event marked
final Point pt = clickPoint;
// It will allow that the click timing is more than 300 msec.
if (System.currentTimeMillis() - clickPointTiming > 300) {
itemEditAnnotation.setEnabled(false);
itemDeleteBrokerConf.setEnabled(false);
itemAddBrokerConf.setEnabled(false);
return;
}
int selectIndex = confTable.getSelectionIndex();
if (selectIndex < 0) {
itemEditAnnotation.setEnabled(false);
itemDeleteBrokerConf.setEnabled(false);
itemAddBrokerConf.setEnabled(true);
return;
}
final TableItem item = confTable.getItem(selectIndex);
if (item == null) {
return;
}
for (int i = 0, len = confTable.getColumnCount(); i < len; i++) {
Rectangle rect = item.getBounds(i);
if (rect.contains(pt)) {
boolean enableToAccess = i > 0;
itemEditAnnotation.setEnabled(enableToAccess);
itemDeleteBrokerConf.setEnabled(enableToAccess);
}
}
itemAddBrokerConf.setEnabled(true);
}
});
confTable.setMenu(menu);
}
use of org.eclipse.swt.events.FocusEvent in project cubrid-manager by CUBRID.
the class ConnectionComposite method createDbInfoGroup.
private void createDbInfoGroup(Composite composite) {
Group dbInfoGroup = new Group(composite, SWT.NONE);
dbInfoGroup.setText(Messages.grpDbInfo);
dbInfoGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
dbInfoGroup.setLayout(createGridLayout(3));
Label databaseLabel = new Label(dbInfoGroup, SWT.LEFT);
databaseLabel.setText(Messages.lblLoginDatabaseName);
databaseLabel.setLayoutData(createGridData(1, 1, -1, -1));
if (isMultiBroker) {
databaseCombo = new Combo(dbInfoGroup, SWT.LEFT | SWT.BORDER);
databaseCombo.setLayoutData(createGridData(GridData.FILL_HORIZONTAL, 2, 1, 100, -1));
} else {
databaseText = new Text(dbInfoGroup, SWT.LEFT | SWT.BORDER);
databaseText.setLayoutData(createGridData(GridData.FILL_HORIZONTAL, 2, 1, 100, -1));
}
Label userNameLabel = new Label(dbInfoGroup, SWT.LEFT);
userNameLabel.setText(Messages.lblDbUserName);
userNameLabel.setLayoutData(createGridData(1, 1, -1, -1));
userNameText = new Text(dbInfoGroup, SWT.LEFT | SWT.BORDER);
userNameText.setLayoutData(createGridData(GridData.FILL_HORIZONTAL, 2, 1, 100, -1));
Label passwordLabel = new Label(dbInfoGroup, SWT.LEFT);
passwordLabel.setText(Messages.lblDbPassword);
passwordLabel.setLayoutData(createGridData(1, 1, -1, -1));
passwordText = new Text(dbInfoGroup, SWT.LEFT | SWT.PASSWORD | SWT.BORDER);
passwordText.setTextLimit(ValidateUtil.MAX_PASSWORD_LENGTH);
passwordText.setLayoutData(createGridData(GridData.FILL_HORIZONTAL, 2, 1, 100, -1));
passwordText.addFocusListener(new FocusAdapter() {
public void focusGained(FocusEvent event) {
passwordText.selectAll();
passwordText.setFocus();
}
});
new Label(dbInfoGroup, SWT.NONE).setLayoutData(createGridData(1, 1, 0, 0));
int span = 2;
if (isIncludingSavePwd) {
btnSavePassword = new Button(dbInfoGroup, SWT.CHECK);
btnSavePassword.setLayoutData(createGridData(GridData.BEGINNING, 1, 1, -1, -1));
btnSavePassword.setText(Messages.btnSavePassword);
span = 1;
}
btnAutoCommit = new Button(dbInfoGroup, SWT.CHECK);
btnAutoCommit.setLayoutData(createGridData(GridData.BEGINNING, span, 1, -1, -1));
btnAutoCommit.setText(autoCommitLabel);
}
use of org.eclipse.swt.events.FocusEvent in project cubrid-manager by CUBRID.
the class AutoIncrementCellEditor method createControl.
protected Control createControl(Composite parent) {
composite = new Composite(parent, SWT.NONE);
{
GridLayout gl = new GridLayout(3, false);
gl.marginHeight = 0;
gl.marginBottom = 0;
gl.marginTop = 0;
gl.marginLeft = 0;
gl.marginRight = 0;
gl.marginWidth = 0;
composite.setLayout(gl);
}
startVal = new Text(composite, SWT.BORDER);
startVal.setLayoutData(new GridData(50, -1));
startVal.setToolTipText(Messages.lblAutoIncrStart);
new Label(composite, SWT.NONE).setText(",");
increVal = new Text(composite, SWT.BORDER);
increVal.setLayoutData(new GridData(15, -1));
increVal.setToolTipText(Messages.lblAutoIncrIncr);
KeyAdapter keyAdapter = new KeyAdapter() {
public void keyReleased(KeyEvent e) {
if (e.character == '\r') {
deactivateWidget();
}
}
};
startVal.addKeyListener(keyAdapter);
increVal.addKeyListener(keyAdapter);
ModifyListener modifyListener = new ModifyListener() {
public void modifyText(ModifyEvent e) {
value = getAutoIncrementValue();
markDirty();
valueChanged(true, true);
}
};
startVal.addModifyListener(modifyListener);
increVal.addModifyListener(modifyListener);
FocusAdapter focusAdapter = new FocusAdapter() {
public void focusGained(FocusEvent e) {
deactivateWidget();
AutoIncrementCellEditor.this.focusLost();
}
};
parent.addFocusListener(focusAdapter);
return composite;
}
Aggregations