Search in sources :

Example 11 with VerifyListener

use of org.eclipse.swt.events.VerifyListener 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;
                }
            }
        });
    }
}
Also used : CCombo(org.eclipse.swt.custom.CCombo) VerifyListener(org.eclipse.swt.events.VerifyListener) Text(org.eclipse.swt.widgets.Text) TableEditor(org.eclipse.swt.custom.TableEditor) VerifyEvent(org.eclipse.swt.events.VerifyEvent)

Example 12 with VerifyListener

use of org.eclipse.swt.events.VerifyListener 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;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) VerifyListener(org.eclipse.swt.events.VerifyListener) Composite(org.eclipse.swt.widgets.Composite) Button(org.eclipse.swt.widgets.Button) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Text(org.eclipse.swt.widgets.Text) VerifyEvent(org.eclipse.swt.events.VerifyEvent)

Example 13 with VerifyListener

use of org.eclipse.swt.events.VerifyListener 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);
}
Also used : VerifyListener(org.eclipse.swt.events.VerifyListener) VerifyEvent(org.eclipse.swt.events.VerifyEvent)

Example 14 with VerifyListener

use of org.eclipse.swt.events.VerifyListener 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;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) VerifyListener(org.eclipse.swt.events.VerifyListener) Composite(org.eclipse.swt.widgets.Composite) Button(org.eclipse.swt.widgets.Button) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Text(org.eclipse.swt.widgets.Text) VerifyEvent(org.eclipse.swt.events.VerifyEvent)

Example 15 with VerifyListener

use of org.eclipse.swt.events.VerifyListener in project tesb-studio-se by Talend.

the class ServiceMetadataCustomPropertiesTable method createTableViewer.

private void createTableViewer() {
    tableViewer = new TableViewer(table);
    tableViewer.setUseHashlookup(true);
    tableViewer.setColumnProperties(columnNames);
    CellEditor[] editors = new CellEditor[columnNames.length];
    TextCellEditor textEditor = new TextCellEditor(table) {

        protected Object doGetValue() {
            Object value = super.doGetValue();
            return null == value || ((String) value).trim().isEmpty() ? COLUMN_PROPERTY_NAME_DEFAULT_VALUE : value;
        }
    };
    ((Text) textEditor.getControl()).setTextLimit(64);
    ((Text) textEditor.getControl()).addVerifyListener(new VerifyListener() {

        public void verifyText(VerifyEvent e) {
            //$NON-NLS-1$
            e.doit = !e.text.equals("\"");
        //              e.doit = !e.text.trim().isEmpty();
        }
    });
    editors[0] = textEditor;
    textEditor = new TextCellEditor(table);
    ((Text) textEditor.getControl()).setTextLimit(64);
    ((Text) textEditor.getControl()).addVerifyListener(new VerifyListener() {

        public void verifyText(VerifyEvent e) {
            //$NON-NLS-1$
            e.doit = !e.text.equals("\"");
        }
    });
    editors[1] = textEditor;
    tableViewer.setCellEditors(editors);
    tableViewer.setCellModifier(new PropertyCellModifier(this));
}
Also used : VerifyListener(org.eclipse.swt.events.VerifyListener) CellEditor(org.eclipse.jface.viewers.CellEditor) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) Text(org.eclipse.swt.widgets.Text) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) TableViewer(org.eclipse.jface.viewers.TableViewer) VerifyEvent(org.eclipse.swt.events.VerifyEvent)

Aggregations

VerifyEvent (org.eclipse.swt.events.VerifyEvent)15 VerifyListener (org.eclipse.swt.events.VerifyListener)15 Text (org.eclipse.swt.widgets.Text)10 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)7 SelectionEvent (org.eclipse.swt.events.SelectionEvent)7 Button (org.eclipse.swt.widgets.Button)6 Composite (org.eclipse.swt.widgets.Composite)6 GridData (org.eclipse.swt.layout.GridData)5 Label (org.eclipse.swt.widgets.Label)5 Point (org.eclipse.swt.graphics.Point)4 FocusAdapter (org.eclipse.swt.events.FocusAdapter)3 FocusEvent (org.eclipse.swt.events.FocusEvent)3 ModifyEvent (org.eclipse.swt.events.ModifyEvent)3 ModifyListener (org.eclipse.swt.events.ModifyListener)3 GridLayout (org.eclipse.swt.layout.GridLayout)3 Combo (org.eclipse.swt.widgets.Combo)3 List (java.util.List)2 Matcher (java.util.regex.Matcher)2 StyledText (org.eclipse.swt.custom.StyledText)2 KeyEvent (org.eclipse.swt.events.KeyEvent)2