Search in sources :

Example 86 with ModifyListener

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

the class SetPstmtValueDialog method createFileComposite.

/**
	 * 
	 * Create file group
	 * 
	 * @param parentComp Composite
	 */
private void createFileComposite(Composite parentComp) {
    Group group = new Group(parentComp, SWT.NONE);
    {
        group.setText(Messages.btnSelectFile);
        group.setLayoutData(new GridData(GridData.FILL_BOTH));
        GridLayout layout = new GridLayout();
        layout.numColumns = 3;
        group.setLayout(layout);
    }
    selectFileBtn = new Button(group, SWT.RADIO | SWT.LEFT);
    selectFileBtn.setText(Messages.btnSelectFile);
    selectFileBtn.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 3, 1, -1, -1));
    selectFileBtn.setSelection(false);
    selectFileBtn.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            if (selectFileBtn.getSelection()) {
                browseBtn.setEnabled(true);
                fileCharsetCombo.setEnabled(true);
                inputTextBtn.setSelection(false);
                paraValueText.setEnabled(false);
                paraValueText.setText("");
                setNullBtn.setSelection(false);
                setNullBtn.setEnabled(false);
            }
            validate();
        }
    });
    Label fileNameLbl = new Label(group, SWT.NONE);
    fileNameLbl.setText(Messages.importFileNameLBL);
    filePathText = new Text(group, SWT.BORDER);
    filePathText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
    filePathText.setEnabled(false);
    browseBtn = new Button(group, SWT.NONE);
    browseBtn.setText(Messages.btnBrowse);
    browseBtn.setLayoutData(CommonUITool.createGridData(1, 1, 80, -1));
    browseBtn.setEnabled(false);
    browseBtn.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            FileDialog dlg = new FileDialog(getShell(), SWT.OPEN);
            dlg.setFilterPath(filePathText.getText());
            String file = dlg.open();
            if (file != null) {
                filePathText.setText(file);
            }
            validate();
        }
    });
    final Label fileCharsetLabel = new Label(group, SWT.NONE);
    fileCharsetLabel.setText(Messages.lblFileCharset);
    fileCharsetCombo = new Combo(group, SWT.NONE);
    {
        GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
        gridData.horizontalSpan = 2;
        fileCharsetCombo.setLayoutData(gridData);
        fileCharsetCombo.setItems(QueryOptions.getAllCharset(null));
        String charset = StringUtil.getDefaultCharset();
        fileCharsetCombo.setText(charset);
        fileCharsetCombo.addModifyListener(new ModifyListener() {

            public void modifyText(ModifyEvent event) {
                validate();
            }
        });
    }
}
Also used : Group(org.eclipse.swt.widgets.Group) ModifyListener(org.eclipse.swt.events.ModifyListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) StyledText(org.eclipse.swt.custom.StyledText) Text(org.eclipse.swt.widgets.Text) Combo(org.eclipse.swt.widgets.Combo) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) FileDialog(org.eclipse.swt.widgets.FileDialog)

Example 87 with ModifyListener

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

the class PstmtSQLDialog method handleType.

/**
	 * Handle type
	 *
	 * @param item TableItem
	 */
protected void handleType(final TableItem item, final int editColumn) {
    String[][] typeMapping = DataType.getTypeMapping(database.getDatabaseInfo(), true, true);
    LinkedList<String> typeList = new LinkedList<String>();
    for (int i = 0; i < typeMapping.length; i++) {
        String type = typeMapping[i][0];
        if (!type.startsWith(DataType.DATATYPE_OBJECT)) {
            typeList.add(type);
        }
    }
    // add default precision
    typeList.addFirst("NUMERIC(38,12)");
    sortTypeList(typeList);
    addColumnToList(typeList);
    String[] items = typeList.toArray(new String[] {});
    final Combo typeCombo = new Combo(parameterTypeTable, SWT.BORDER | SWT.FULL_SELECTION);
    typeCombo.setItems(items);
    typeCombo.setVisibleItemCount(20);
    final String paraName = item.getText(0);
    typeCombo.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent event) {
            validateType(paraName, typeCombo.getText(), editColumn);
        }
    });
    typeCombo.addFocusListener(new FocusAdapter() {

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

        public void keyTraversed(TraverseEvent event) {
            if (event.detail == SWT.TRAVERSE_RETURN) {
                if (isChanging) {
                    return;
                }
                isChanging = true;
                //					if (validateType(paraName, typeCombo.getText(), editColumn)) {
                item.setText(editColumn, typeCombo.getText());
                //					}
                typeCombo.dispose();
                isChanging = false;
                validate();
                event.doit = true;
            } else if (event.detail == SWT.TRAVERSE_ESCAPE) {
                if (isChanging) {
                    return;
                }
                isChanging = true;
                typeCombo.dispose();
                event.doit = false;
                isChanging = false;
            }
        }
    });
    tableEditor.setEditor(typeCombo, item, editColumn);
    typeCombo.setText(item.getText(editColumn));
    typeCombo.setFocus();
}
Also used : FocusAdapter(org.eclipse.swt.events.FocusAdapter) TraverseEvent(org.eclipse.swt.events.TraverseEvent) ModifyListener(org.eclipse.swt.events.ModifyListener) TraverseListener(org.eclipse.swt.events.TraverseListener) Combo(org.eclipse.swt.widgets.Combo) FocusEvent(org.eclipse.swt.events.FocusEvent) LinkedList(java.util.LinkedList) Point(org.eclipse.swt.graphics.Point) ModifyEvent(org.eclipse.swt.events.ModifyEvent)

Example 88 with ModifyListener

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

the class RenameColumnDialog method createDialogArea.

/**
	 * @see org.eclipse.jface.dialogs.TitleAreaDialog#createDialogArea(org.eclipse.swt.widgets.Composite)
	 * @param parent The parent composite to contain the dialog area
	 * @return the dialog area control
	 */
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 = 2;
    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);
    Label label1 = new Label(composite, SWT.LEFT);
    label1.setText(Messages.bind(Messages.renameNewTableName, Messages.metaAttribute));
    label1.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    newText = new Text(composite, SWT.BORDER);
    newText.setTextLimit(ValidateUtil.MAX_SCHEMA_NAME_LENGTH);
    newText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
    newText.setText(column);
    newText.selectAll();
    newText.setFocus();
    newText.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent event) {
            setErrorMessage(null);
            okButton.setEnabled(false);
            String newTable = newText.getText().trim();
            if (!ValidateUtil.isValidIdentifier(newTable)) {
                setErrorMessage(Messages.bind(Messages.renameInvalidTableNameMSG, Messages.metaAttribute, newTable));
                return;
            } else if (newTable.equalsIgnoreCase(column)) {
                return;
            }
            okButton.setEnabled(true);
        }
    });
    setTitle(Messages.bind(Messages.renameMSGTitle, Messages.metaAttribute));
    setMessage(Messages.bind(Messages.renameDialogMSG, Messages.metaAttribute));
    return parent;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text)

Example 89 with ModifyListener

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

the class RenameTableDialog method createDialogArea.

/**
	 * @see org.eclipse.jface.dialogs.TitleAreaDialog#createDialogArea(org.eclipse.swt.widgets.Composite)
	 * @param parent The parent composite to contain the dialog area
	 * @return the dialog area control
	 */
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);
    Label label1 = new Label(composite, SWT.LEFT);
    label1.setText(Messages.bind(Messages.renameNewTableName, tableOrView));
    GridData data = new GridData();
    data.widthHint = 120;
    data.horizontalSpan = 1;
    data.verticalSpan = 1;
    label1.setLayoutData(data);
    newTableText = 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;
    newTableText.setLayoutData(data);
    newTableText.setText(oldName);
    newTableText.selectAll();
    newTableText.setFocus();
    newTableText.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent event) {
            setErrorMessage(null);
            getButton(IDialogConstants.OK_ID).setEnabled(false);
            String newTable = newTableText.getText();
            if (isPhysical && !ValidateUtil.isValidIdentifier(newTable)) {
                setErrorMessage(Messages.bind(Messages.renameInvalidTableNameMSG, tableOrView, newTable));
                return;
            }
            if (-1 != existNameList.indexOf(newTable.toLowerCase(Locale.getDefault()))) {
                if (isTable) {
                    setErrorMessage(Messages.bind(Messages.errExistTable, newTable));
                } else {
                    setErrorMessage(Messages.bind(Messages.errExistView, newTable));
                }
                return;
            }
            getButton(IDialogConstants.OK_ID).setEnabled(true);
        }
    });
    newTableText.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 = newTableText.getText().trim();
                if (StringUtil.isEqualNotIgnoreNull(oldName, newSchemaName)) {
                    buttonPressed(IDialogConstants.CANCEL_ID);
                } else {
                    buttonPressed(IDialogConstants.OK_ID);
                }
            }
        }
    });
    setTitle(Messages.bind(Messages.renameMSGTitle, tableOrView));
    setMessage(Messages.bind(Messages.renameDialogMSG, tableOrView));
    return parent;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) ModifyListener(org.eclipse.swt.events.ModifyListener) Listener(org.eclipse.swt.widgets.Listener) Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Event(org.eclipse.swt.widgets.Event) Text(org.eclipse.swt.widgets.Text)

Example 90 with ModifyListener

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

the class PstmtDataDialog method handleType.

protected void handleType(final TableItem item) {
    String[][] typeMapping = DataType.getTypeMapping(database.getDatabaseInfo(), true, true);
    List<String> typeList = new ArrayList<String>();
    for (int i = 0; i < typeMapping.length; i++) {
        String type = typeMapping[i][0];
        if (!type.startsWith(DataType.DATATYPE_OBJECT)) {
            typeList.add(type);
        }
    }
    String[] items = typeList.toArray(new String[] {});
    final int editColumn = 1;
    final Combo typeCombo = new Combo(parameterTable, SWT.BORDER | SWT.FULL_SELECTION);
    typeCombo.setItems(items);
    typeCombo.setVisibleItemCount(20);
    final String paraName = item.getText(0);
    typeCombo.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent event) {
            validateType(paraName, typeCombo.getText());
        }
    });
    typeCombo.addFocusListener(new FocusAdapter() {

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

        public void keyTraversed(TraverseEvent event) {
            if (event.detail == SWT.TRAVERSE_RETURN) {
                if (isChanging) {
                    return;
                }
                isChanging = true;
                if (validateType(paraName, typeCombo.getText())) {
                    item.setText(editColumn, typeCombo.getText());
                }
                typeCombo.dispose();
                isChanging = false;
                validate();
                event.doit = true;
                handleValue(item);
            } else if (event.detail == SWT.TRAVERSE_ESCAPE) {
                if (isChanging) {
                    return;
                }
                isChanging = true;
                typeCombo.dispose();
                event.doit = false;
                isChanging = false;
            }
        }
    });
    tableEditor.setEditor(typeCombo, item, editColumn);
    typeCombo.setText(item.getText(editColumn));
    typeCombo.setFocus();
}
Also used : FocusAdapter(org.eclipse.swt.events.FocusAdapter) TraverseEvent(org.eclipse.swt.events.TraverseEvent) ModifyListener(org.eclipse.swt.events.ModifyListener) TraverseListener(org.eclipse.swt.events.TraverseListener) ArrayList(java.util.ArrayList) Combo(org.eclipse.swt.widgets.Combo) FocusEvent(org.eclipse.swt.events.FocusEvent) Point(org.eclipse.swt.graphics.Point) ModifyEvent(org.eclipse.swt.events.ModifyEvent)

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