Search in sources :

Example 31 with VerifyEvent

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;
                }
            }
        });
    }
}
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 32 with VerifyEvent

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();
}
Also used : VerifyListener(org.eclipse.swt.events.VerifyListener) FontData(org.eclipse.swt.graphics.FontData) Text(org.eclipse.swt.widgets.Text) Point(org.eclipse.swt.graphics.Point) Dimension(org.eclipse.draw2d.geometry.Dimension) GC(org.eclipse.swt.graphics.GC) VerifyEvent(org.eclipse.swt.events.VerifyEvent) Font(org.eclipse.swt.graphics.Font) IFigure(org.eclipse.draw2d.IFigure)

Example 33 with VerifyEvent

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

Example 34 with VerifyEvent

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;
}
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 35 with VerifyEvent

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;
}
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)

Aggregations

VerifyEvent (org.eclipse.swt.events.VerifyEvent)57 VerifyListener (org.eclipse.swt.events.VerifyListener)41 Text (org.eclipse.swt.widgets.Text)29 GridData (org.eclipse.swt.layout.GridData)21 ModifyEvent (org.eclipse.swt.events.ModifyEvent)19 ModifyListener (org.eclipse.swt.events.ModifyListener)18 SelectionEvent (org.eclipse.swt.events.SelectionEvent)18 Composite (org.eclipse.swt.widgets.Composite)18 Label (org.eclipse.swt.widgets.Label)18 GridLayout (org.eclipse.swt.layout.GridLayout)17 VerifyKeyListener (org.eclipse.swt.custom.VerifyKeyListener)14 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)14 Point (org.eclipse.swt.graphics.Point)14 KeyEvent (org.eclipse.swt.events.KeyEvent)12 Button (org.eclipse.swt.widgets.Button)11 FocusEvent (org.eclipse.swt.events.FocusEvent)10 StyledText (org.eclipse.swt.custom.StyledText)7 MouseEvent (org.eclipse.swt.events.MouseEvent)7 Font (org.eclipse.swt.graphics.Font)7 Pattern (java.util.regex.Pattern)6