Search in sources :

Example 91 with ModifyListener

use of org.eclipse.swt.events.ModifyListener in project cubrid-manager by CUBRID.

the class InsertTableDataDialog method handleValue.

private void handleValue(final TableItem item) {
    // Clean up any previous editor control
    Control oldEditor = tableEditor.getEditor();
    if (oldEditor != null) {
        oldEditor.dispose();
    }
    final Text newEditor = new Text(attrTable, SWT.MULTI | SWT.WRAP);
    newEditor.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent event) {
            validate(newEditor.getText(), item);
        }
    });
    newEditor.addFocusListener(new FocusAdapter() {

        public void focusLost(FocusEvent event) {
            if (isChanging) {
                return;
            }
            isChanging = true;
            if (validate(newEditor.getText(), item)) {
                item.setText(EDIT_COLUMN, newEditor.getText());
            }
            newEditor.dispose();
            validate();
            isChanging = false;
        }
    });
    //add listener for key pressed
    newEditor.addTraverseListener(new TraverseListener() {

        public void keyTraversed(TraverseEvent event) {
            if (event.detail == SWT.TRAVERSE_RETURN) {
                if (isChanging) {
                    return;
                }
                isChanging = true;
                if (validate(newEditor.getText(), item)) {
                    item.setText(EDIT_COLUMN, newEditor.getText());
                }
                newEditor.dispose();
                validate();
                isChanging = false;
                event.doit = true;
                int selItem = (attrTable.getSelectionIndex() + 1) % attrTable.getItemCount();
                if (selItem == 0) {
                    getButton(BTN_INSERT_ID).setFocus();
                } else {
                    attrTable.setSelection(selItem);
                    handleValue(attrTable.getItem(selItem));
                }
            } else if (event.detail == SWT.TRAVERSE_ESCAPE) {
                if (isChanging) {
                    return;
                }
                isChanging = true;
                newEditor.dispose();
                event.doit = false;
                isChanging = false;
            }
        }
    });
    tableEditor.setEditor(newEditor, item, EDIT_COLUMN);
    newEditor.setText(item.getText(EDIT_COLUMN));
    newEditor.selectAll();
    newEditor.setFocus();
}
Also used : FocusAdapter(org.eclipse.swt.events.FocusAdapter) Control(org.eclipse.swt.widgets.Control) ModifyEvent(org.eclipse.swt.events.ModifyEvent) TraverseEvent(org.eclipse.swt.events.TraverseEvent) ModifyListener(org.eclipse.swt.events.ModifyListener) TraverseListener(org.eclipse.swt.events.TraverseListener) StyledText(org.eclipse.swt.custom.StyledText) Text(org.eclipse.swt.widgets.Text) FocusEvent(org.eclipse.swt.events.FocusEvent)

Example 92 with ModifyListener

use of org.eclipse.swt.events.ModifyListener in project cubrid-manager by CUBRID.

the class PstmtDataDialog method createSqlTextComposite.

private void createSqlTextComposite(Composite parent) {
    Group sqlGroup = new Group(parent, SWT.NONE);
    {
        sqlGroup.setText(Messages.grpSql);
        GridData gridData = new GridData(GridData.FILL_BOTH);
        gridData.heightHint = 160;
        sqlGroup.setLayoutData(gridData);
        GridLayout layout = new GridLayout();
        layout.numColumns = 2;
        sqlGroup.setLayout(layout);
    }
    sqlTxt = new StyledText(sqlGroup, SWT.BORDER | SWT.WRAP | SWT.V_SCROLL);
    {
        GridData gridData = new GridData(GridData.FILL_BOTH);
        sqlTxt.setLayoutData(gridData);
        sqlTxt.addModifyListener(new ModifyListener() {

            public void modifyText(ModifyEvent event) {
                if (validSql()) {
                    analyzeButton.setEnabled(true);
                } else {
                    analyzeButton.setEnabled(false);
                }
            }
        });
        CommonUITool.registerContextMenu(sqlTxt, true);
    }
    Composite composite = new Composite(sqlGroup, SWT.NONE);
    {
        GridLayout gridLayout = new GridLayout();
        gridLayout.marginWidth = 0;
        gridLayout.marginHeight = 0;
        composite.setLayout(gridLayout);
        GridData gridData = new GridData();
        gridData.verticalAlignment = SWT.TOP;
        composite.setLayoutData(gridData);
    }
    Button clearButton = new Button(composite, SWT.NONE);
    {
        GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
        clearButton.setLayoutData(gridData);
        clearButton.setText(Messages.btnClear);
        clearButton.addSelectionListener(new SelectionAdapter() {

            public void widgetSelected(SelectionEvent event) {
                sqlTxt.setText("");
                validate();
            }
        });
    }
    analyzeButton = new Button(composite, SWT.NONE);
    {
        GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
        analyzeButton.setLayoutData(gridData);
        analyzeButton.setText(Messages.btnAnalyze);
        analyzeButton.setEnabled(false);
        analyzeButton.addSelectionListener(new SelectionAdapter() {

            public void widgetSelected(SelectionEvent event) {
                analyzeSql();
                validate();
            }
        });
    }
}
Also used : Group(org.eclipse.swt.widgets.Group) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) StyledText(org.eclipse.swt.custom.StyledText) ModifyListener(org.eclipse.swt.events.ModifyListener) Composite(org.eclipse.swt.widgets.Composite) Button(org.eclipse.swt.widgets.Button) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Example 93 with ModifyListener

use of org.eclipse.swt.events.ModifyListener in project cubrid-manager by CUBRID.

the class AddColumnDialog method createDialogArea.

protected Control createDialogArea(Composite parent) {
    Composite parentComp = (Composite) super.createDialogArea(parent);
    Composite composite = new Composite(parentComp, SWT.NONE);
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));
    GridLayout layout = new GridLayout();
    layout.numColumns = 3;
    layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
    layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
    layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
    layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
    composite.setLayout(layout);
    // new name
    Label label1 = new Label(composite, SWT.LEFT);
    label1.setText(Messages.lbAddColumnName);
    GridData data = new GridData();
    data.horizontalSpan = 1;
    data.verticalSpan = 1;
    label1.setLayoutData(data);
    newColumnText = new Text(composite, SWT.BORDER);
    data = new GridData();
    data.horizontalSpan = 2;
    data.verticalSpan = 1;
    data.grabExcessHorizontalSpace = true;
    data.verticalAlignment = GridData.FILL;
    data.horizontalAlignment = GridData.FILL;
    // data type
    Label labelType = new Label(composite, SWT.LEFT);
    labelType.setText(Messages.lbDataType);
    GridData data2 = new GridData();
    data2.horizontalSpan = 1;
    data2.verticalSpan = 1;
    labelType.setLayoutData(data2);
    dataTypeCombo = new Combo(composite, SWT.LEFT | SWT.READ_ONLY | SWT.BORDER);
    dataTypeCombo.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 2, 1, 100, -1));
    dataTypeCombo.setItems(this.listDataTypes());
    dataTypeCombo.setText("STRING");
    dataTypeValue = dataTypeCombo.getText();
    newColumnText.setLayoutData(data);
    newColumnText.setText(columnValue);
    newColumnText.selectAll();
    newColumnText.setFocus();
    newColumnText.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent event) {
            setErrorMessage(null);
            getButton(IDialogConstants.OK_ID).setEnabled(false);
            String newcolumn = newColumnText.getText();
            if (!ValidateUtil.isValidIdentifier(newcolumn)) {
                setErrorMessage(Messages.bind(Messages.errInvalidColumnName, tableOrViewKey, newcolumn));
                return;
            }
            if (-1 != columnList.indexOf(newcolumn.toLowerCase(Locale.getDefault()))) {
                setErrorMessage(Messages.bind(Messages.errExistColumnName, newcolumn));
                return;
            }
            getButton(IDialogConstants.OK_ID).setEnabled(true);
        }
    });
    newColumnText.addListener(SWT.KeyDown, new Listener() {

        public void handleEvent(Event e) {
            if (e.type == SWT.KeyDown && e.character == SWT.CR) {
                /* For bug TOOLS-2698 */
                String newSchemaName = newColumnText.getText().trim();
                if (StringUtil.isEqualNotIgnoreNull(columnValue, newSchemaName)) {
                    buttonPressed(IDialogConstants.CANCEL_ID);
                } else {
                    buttonPressed(IDialogConstants.OK_ID);
                }
            }
        }
    });
    setTitle(Messages.bind(Messages.titleAddColumn, tableOrViewKey));
    setMessage(Messages.bind(Messages.titleAddColumn, tableOrViewKey));
    return parent;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Listener(org.eclipse.swt.widgets.Listener) ModifyListener(org.eclipse.swt.events.ModifyListener) Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label) Event(org.eclipse.swt.widgets.Event) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Text(org.eclipse.swt.widgets.Text) Combo(org.eclipse.swt.widgets.Combo)

Example 94 with ModifyListener

use of org.eclipse.swt.events.ModifyListener in project cubrid-manager by CUBRID.

the class EditVirtualTableDialog method createTableInformationGroup.

private void createTableInformationGroup(Composite compositeGenaral) {
    final Group group = new Group(compositeGenaral, SWT.NONE);
    group.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    GridLayout gridLayout = new GridLayout();
    gridLayout.numColumns = 2;
    group.setLayout(gridLayout);
    group.setText(Messages.lblTableInfo);
    final Label tableNameLabel = new Label(group, SWT.NONE);
    tableNameLabel.setData(Messages.dataNewKey, null);
    tableNameLabel.setText(Messages.lblTableName);
    final SchemaInfo newSchemaInfo = getNewSchemaInfo();
    tableNameComp = new Composite(group, SWT.NONE);
    {
        GridLayout gl = new GridLayout();
        gl.numColumns = 2;
        gl.marginWidth = 0;
        tableNameComp.setLayout(gl);
        tableNameComp.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
        tableNameText = new Text(tableNameComp, SWT.BORDER);
        {
            GridData gd = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
            tableNameText.setLayoutData(gd);
        }
        tableNameText.addModifyListener(new ModifyListener() {

            public void modifyText(ModifyEvent event) {
                if (tableNameText.getText().length() == 0) {
                    CommonUITool.hideErrorBaloon(errorBaloon);
                } else if (verifyTableName()) {
                    String tableName = tableNameText.getText();
                    newSchemaInfo.setClassname(tableName);
                }
            }
        });
        tableNameText.addFocusListener(new FocusAdapter() {

            public void focusLost(FocusEvent e) {
                CommonUITool.hideErrorBaloon(errorBaloon);
            }
        });
    }
    //char set
    if (supportCharset) {
        Composite collationComposite = new Composite(tableNameComp, SWT.NONE);
        collationComposite.setLayout(new GridLayout(2, false));
        final Label collationLabel = new Label(collationComposite, SWT.NONE);
        collationLabel.setText(Messages.lblCollation);
        collationCombo = new Combo(collationComposite, SWT.READ_ONLY);
        collationCombo.setLayout(new FillLayout());
        collationCombo.setVisibleItemCount(10);
        fillCollationCombo();
        String collation = collationCombo.getText();
        newSchemaInfo.setCollation(collation);
        collationCombo.addSelectionListener(new SelectionListener() {

            public void widgetSelected(SelectionEvent e) {
                String collation = collationCombo.getText();
                newSchemaInfo.setCollation(collation);
            }

            public void widgetDefaultSelected(SelectionEvent e) {
            }
        });
        if (!isNewTableFlag && newSchemaInfo.getCollation() != null) {
            collationCombo.setText(newSchemaInfo.getCollation());
        }
    } else {
        new Label(tableNameComp, SWT.NONE);
    }
    if (erSchema.isPhysicModel()) {
        //desc info
        final Label tableDescLabel = new Label(group, SWT.NONE);
        tableDescLabel.setText(Messages.lblTableDesc);
        tableDescText = new Text(group, SWT.BORDER);
        tableDescText.setTextLimit(612);
        tableDescText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
        //		tableDescText.setLayoutData(new FillLayout());
        if (newSchemaInfo != null && newSchemaInfo.getDescription() != null) {
            tableDescText.setText(newSchemaInfo.getDescription());
        }
        tableDescText.addFocusListener(new FocusAdapter() {

            public void focusGained(FocusEvent e) {
            }

            public void focusLost(FocusEvent e) {
                CommonUITool.hideErrorBaloon(errorBaloon);
            }
        });
        tableDescText.setEditable(true);
    }
}
Also used : Group(org.eclipse.swt.widgets.Group) FocusAdapter(org.eclipse.swt.events.FocusAdapter) Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) Combo(org.eclipse.swt.widgets.Combo) FillLayout(org.eclipse.swt.layout.FillLayout) FocusEvent(org.eclipse.swt.events.FocusEvent) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) SchemaInfo(com.cubrid.common.core.common.model.SchemaInfo) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 95 with ModifyListener

use of org.eclipse.swt.events.ModifyListener in project cubrid-manager by CUBRID.

the class FilterResultContrItem method createControl.

/**
	 * Create the content
	 *
	 * @param parent Composite
	 * @return Control
	 */
protected Control createControl(Composite parent) {
    Composite comp = new Composite(parent, SWT.NONE);
    GridData gridData = new GridData(GridData.FILL, GridData.FILL, true, true);
    comp.setLayoutData(gridData);
    final GridLayout gdLayout = new GridLayout(5, false);
    gdLayout.marginHeight = 0;
    gdLayout.marginWidth = 0;
    gdLayout.horizontalSpacing = 0;
    gdLayout.verticalSpacing = 0;
    gdLayout.marginRight = 10;
    comp.setLayout(gdLayout);
    Label lbl = new Label(comp, SWT.NONE);
    lbl.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    lbl.setText(" " + Messages.lblFilterSearch + " ");
    text = new Text(comp, SWT.NONE | SWT.BORDER | SWT.LEFT);
    text.setLayoutData(CommonUITool.createGridData(1, 1, 100, -1));
    text.addKeyListener(new KeyAdapter() {

        public void keyPressed(KeyEvent e) {
            if (e.keyCode == SWT.CR || e.keyCode == SWT.KEYPAD_CR) {
                doFilter();
            }
        }
    });
    dropDownButton = new Button(comp, SWT.FLAT | SWT.DOWN);
    dropDownButton.setText(Messages.lblFilterSearchOption);
    dropDownButton.addListener(SWT.Selection, new Listener() {

        public void handleEvent(Event event) {
            handleSelectionEvent();
        }
    });
    Label lblLimit = new Label(comp, SWT.NONE);
    lblLimit.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    lblLimit.setText(" " + Messages.lblSearchLimit + " ");
    pageLimitCombo = new Combo(comp, SWT.READ_ONLY);
    pageLimitCombo.setItems(new String[] { "1000", "5000", "10000" });
    pageLimitCombo.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    pageLimitCombo.setText("" + pageLimit);
    pageLimitCombo.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            int limit = StringUtil.intValue(pageLimitCombo.getText());
            ServerInfo serverInfo = qe.getDatabase().getServer().getServerInfo();
            QueryOptions.setSearchUnitCount(serverInfo, limit);
        }
    });
    loadMenuItems();
    return comp;
}
Also used : Listener(org.eclipse.swt.widgets.Listener) ModifyListener(org.eclipse.swt.events.ModifyListener) Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) KeyAdapter(org.eclipse.swt.events.KeyAdapter) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) Combo(org.eclipse.swt.widgets.Combo) KeyEvent(org.eclipse.swt.events.KeyEvent) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) Event(org.eclipse.swt.widgets.Event) KeyEvent(org.eclipse.swt.events.KeyEvent) ModifyEvent(org.eclipse.swt.events.ModifyEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Aggregations

ModifyListener (org.eclipse.swt.events.ModifyListener)308 ModifyEvent (org.eclipse.swt.events.ModifyEvent)296 GridData (org.eclipse.swt.layout.GridData)209 GridLayout (org.eclipse.swt.layout.GridLayout)185 Text (org.eclipse.swt.widgets.Text)185 Composite (org.eclipse.swt.widgets.Composite)171 Label (org.eclipse.swt.widgets.Label)165 SelectionEvent (org.eclipse.swt.events.SelectionEvent)158 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)127 Button (org.eclipse.swt.widgets.Button)101 Combo (org.eclipse.swt.widgets.Combo)65 Group (org.eclipse.swt.widgets.Group)50 SelectionListener (org.eclipse.swt.events.SelectionListener)48 File (java.io.File)30 KeyEvent (org.eclipse.swt.events.KeyEvent)26 StyledText (org.eclipse.swt.custom.StyledText)24 FileDialog (org.eclipse.swt.widgets.FileDialog)23 Point (org.eclipse.swt.graphics.Point)22 DirectoryDialog (org.eclipse.swt.widgets.DirectoryDialog)21 ArrayList (java.util.ArrayList)18