use of org.eclipse.swt.events.VerifyEvent in project cubrid-manager by CUBRID.
the class IndexTableItemEditor method init.
/**
*
* Initial the table column editor
*
*/
private void init() {
final TableEditor editor = new TableEditor(table);
editor.horizontalAlignment = SWT.LEFT;
editor.grabHorizontal = true;
if (columnEditorType == COLUMN_EDITOR_TYPE_CCOMBO) {
combo = new CCombo(table, SWT.NONE);
combo.setEditable(false);
combo.addListener(SWT.Selection, this);
combo.addListener(SWT.FocusOut, this);
combo.addListener(SWT.Traverse, this);
editor.setEditor(combo, item, column);
//$NON-NLS-1$
combo.add("ASC");
//$NON-NLS-1$
combo.add("DESC");
if (item.getText(column).equals("ASC")) {
//$NON-NLS-1$
combo.select(0);
} else {
combo.select(1);
}
combo.setFocus();
} else if (columnEditorType == COLUMN_EDITOR_TYPE_TEXT) {
text = new Text(table, SWT.MULTI | SWT.WRAP);
text.setTextLimit(10);
text.addListener(SWT.FocusOut, this);
text.addListener(SWT.Traverse, this);
editor.setEditor(text, item, column);
text.setText(item.getText(column));
text.selectAll();
text.setFocus();
text.addVerifyListener(new VerifyListener() {
public void verifyText(VerifyEvent event) {
event.doit = false;
char ch = event.character;
if (Character.isDigit(ch)) {
event.doit = true;
}
if (ch == '\b' || ch == SWT.DEL) {
event.doit = true;
}
}
});
}
}
use of org.eclipse.swt.events.VerifyEvent in project dbeaver by serge-rider.
the class ExtendedDirectEditManager method initCellEditor.
/**
* @see org.eclipse.gef.tools.DirectEditManager#initCellEditor()
*/
@Override
protected void initCellEditor() {
Text text = (Text) getCellEditor().getControl();
//add the verifyListener to apply changes to the control size
verifyListener = new VerifyListener() {
/**
* Changes the size of the editor control to reflect the changed
* text
*/
@Override
public void verifyText(VerifyEvent event) {
Text text = (Text) getCellEditor().getControl();
String oldText = text.getText();
String leftText = oldText.substring(0, event.start);
String rightText = oldText.substring(event.end, oldText.length());
GC gc = new GC(text);
if (leftText == null)
leftText = "";
if (rightText == null)
rightText = "";
String s = leftText + event.text + rightText;
Point size = gc.textExtent(leftText + event.text + rightText);
gc.dispose();
if (size.x != 0)
size = text.computeSize(size.x, SWT.DEFAULT);
else {
//just make it square
size.x = size.y;
}
getCellEditor().getControl().setSize(size.x, size.y);
}
};
text.addVerifyListener(verifyListener);
//set the initial value of the
originalValue = this.label.getText();
getCellEditor().setValue(originalValue);
//calculate the font size of the underlying
IFigure figure = getEditPart().getFigure();
figureFont = figure.getFont();
FontData data = figureFont.getFontData()[0];
Dimension fontSize = new Dimension(0, data.getHeight());
//set the font to be used
this.label.translateToAbsolute(fontSize);
data.setHeight(fontSize.height);
figureFont = new Font(null, data);
//set the validator for the CellEditor
getCellEditor().setValidator(validator);
text.setFont(figureFont);
text.selectAll();
}
use of org.eclipse.swt.events.VerifyEvent in project cubrid-manager by CUBRID.
the class ShardGeneralInfoPanel method initial.
private void initial() {
masterShmIdText.addModifyListener(modifyListener);
masterShmIdText.addVerifyListener(new VerifyListener() {
public void verifyText(VerifyEvent event) {
if ("".equals(event.text)) {
return;
}
if (ValidateUtil.isNumber(event.text)) {
event.doit = true;
} else {
event.doit = false;
}
}
});
adminLogFileText.addModifyListener(modifyListener);
}
use of org.eclipse.swt.events.VerifyEvent in project cubrid-manager by CUBRID.
the class BrokerParameterDialog method createRefreshComp.
/**
* Creates the refresh composite
*
* @param parent the parent composite
* @return the composite
*/
private Control createRefreshComp(Composite parent) {
Composite refreshComp = new Composite(parent, SWT.None);
refreshComp.setLayout(new GridLayout());
final GridData gdRefreshComp = new GridData(SWT.FILL, SWT.TOP, true, false);
refreshComp.setLayoutData(gdRefreshComp);
final Label tipLbl = new Label(refreshComp, SWT.NONE);
final GridData gdTipLbl = new GridData(SWT.LEFT, SWT.TOP, true, false);
tipLbl.setText(Messages.refreshTitle);
tipLbl.setLayoutData(gdTipLbl);
final Composite radioComp = new Composite(refreshComp, SWT.None);
final GridData gdRadioComp = new GridData(SWT.FILL, SWT.TOP, true, false);
radioComp.setLayoutData(gdRadioComp);
radioComp.setLayout(new GridLayout(3, false));
refreshBtn = new Button(radioComp, SWT.CHECK);
refreshBtn.setText(Messages.refreshOnLbl);
refreshBtn.setSelection(false);
intervalTxt = new Text(radioComp, SWT.BORDER | SWT.RIGHT);
final GridData gdIntervalTxt = new GridData(SWT.FILL, SWT.CENTER, true, false);
intervalTxt.setLayoutData(gdIntervalTxt);
intervalTxt.setText("1");
intervalTxt.setEnabled(false);
final Label secLbl = new Label(radioComp, SWT.NONE);
final GridData gdSecLbl = new GridData(SWT.LEFT, SWT.TOP, true, false);
secLbl.setText(Messages.refreshUnitLbl);
tipLbl.setLayoutData(gdSecLbl);
refreshBtn.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
if (refreshBtn.getSelection()) {
intervalTxt.setEnabled(true);
} else {
intervalTxt.setEnabled(false);
}
}
});
intervalTxt.addVerifyListener(new VerifyListener() {
public void verifyText(VerifyEvent event) {
if (!"".equals(event.text) && !ValidateUtil.isNumber(event.text)) {
event.doit = false;
return;
}
}
});
return refreshComp;
}
use of org.eclipse.swt.events.VerifyEvent in project cubrid-manager by CUBRID.
the class BrokerParameterPropertyPage method createRefreshComp.
/**
* Creates the refresh Composite
*
* @param parent the parent composite
* @return the composite
*/
private Control createRefreshComp(Composite parent) {
Composite refreshComp = new Composite(parent, SWT.None);
refreshComp.setLayout(new GridLayout());
final GridData gdRefreshComp = new GridData(SWT.FILL, SWT.TOP, true, false);
refreshComp.setLayoutData(gdRefreshComp);
final Label tipLbl = new Label(refreshComp, SWT.NONE);
final GridData gdTipLbl = new GridData(SWT.LEFT, SWT.TOP, true, false);
tipLbl.setText(Messages.refreshTitle);
tipLbl.setLayoutData(gdTipLbl);
final Composite radioComp = new Composite(refreshComp, SWT.None);
final GridData gdRadioComp = new GridData(SWT.FILL, SWT.TOP, true, false);
radioComp.setLayoutData(gdRadioComp);
radioComp.setLayout(new GridLayout(3, false));
refreshBtn = new Button(radioComp, SWT.CHECK);
refreshBtn.setText(Messages.refreshOnLbl);
refreshBtn.setSelection(false);
intervalTxt = new Text(radioComp, SWT.BORDER | SWT.RIGHT);
final GridData gdIntervalTxt = new GridData(SWT.FILL, SWT.CENTER, true, false);
intervalTxt.setLayoutData(gdIntervalTxt);
intervalTxt.setText("1");
intervalTxt.setEnabled(false);
final Label secLbl = new Label(radioComp, SWT.NONE);
final GridData gdSecLbl = new GridData(SWT.LEFT, SWT.TOP, true, false);
secLbl.setText(Messages.refreshUnitLbl);
tipLbl.setLayoutData(gdSecLbl);
refreshBtn.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
if (refreshBtn.getSelection()) {
intervalTxt.setEnabled(true);
} else {
intervalTxt.setEnabled(false);
}
}
});
intervalTxt.addVerifyListener(new VerifyListener() {
public void verifyText(VerifyEvent event) {
if (!"".equals(event.text) && !ValidateUtil.isNumber(event.text)) {
event.doit = false;
return;
}
}
});
return refreshComp;
}
Aggregations