Search in sources :

Example 16 with TableEditor

use of org.eclipse.swt.custom.TableEditor in project dbeaver by serge-rider.

the class EditForeignKeyPage method createPageContents.

@Override
protected Control createPageContents(Composite parent) {
    final Composite panel = UIUtils.createPlaceholder(parent, 1, 5);
    panel.setLayoutData(new GridData(GridData.FILL_BOTH));
    {
        final Composite tableGroup = UIUtils.createPlaceholder(panel, 2, 5);
        tableGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        UIUtils.createLabelText(tableGroup, CoreMessages.dialog_struct_edit_fk_label_table, ownTable.getFullyQualifiedName(DBPEvaluationContext.UI), SWT.READ_ONLY | SWT.BORDER);
        if (ownerTableNode != null) {
            try {
                createSchemaSelector(tableGroup);
            } catch (Throwable e) {
                log.debug("Can't create schema selector", e);
            }
        }
    }
    {
        DBNNode rootNode = ownerTableNode == null ? DBeaverCore.getInstance().getNavigatorModel().getRoot() : ownerTableNode.getParentNode();
        UIUtils.createControlLabel(panel, CoreMessages.dialog_struct_edit_fk_label_ref_table);
        tableList = new ItemListControl(panel, SWT.SINGLE | SWT.SHEET | SWT.BORDER, null, rootNode, null);
        tableList.loadData();
        final GridData gd = new GridData(GridData.FILL_BOTH);
        gd.widthHint = 500;
        gd.heightHint = 150;
        tableList.setLayoutData(gd);
        tableList.getSelectionProvider().addSelectionChangedListener(new ISelectionChangedListener() {

            @Override
            public void selectionChanged(SelectionChangedEvent event) {
                handleRefTableSelect(event.getSelection());
            }
        });
    }
    final Composite pkGroup = UIUtils.createPlaceholder(panel, 2);
    {
        pkGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        uniqueKeyCombo = UIUtils.createLabelCombo(pkGroup, CoreMessages.dialog_struct_edit_fk_combo_unik, SWT.DROP_DOWN | SWT.READ_ONLY);
        uniqueKeyCombo.setEnabled(false);
        uniqueKeyCombo.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                handleUniqueKeySelect();
            }
        });
    }
    {
        UIUtils.createControlLabel(panel, CoreMessages.dialog_struct_edit_fk_label_columns);
        columnsTable = new Table(panel, SWT.SINGLE | SWT.FULL_SELECTION | SWT.BORDER);
        columnsTable.setHeaderVisible(true);
        columnsTable.setLinesVisible(true);
        final GridData gd = new GridData(GridData.FILL_BOTH);
        gd.widthHint = 500;
        gd.heightHint = 100;
        columnsTable.setLayoutData(gd);
        UIUtils.createTableColumn(columnsTable, SWT.LEFT, CoreMessages.dialog_struct_edit_fk_column_column);
        UIUtils.createTableColumn(columnsTable, SWT.LEFT, CoreMessages.dialog_struct_edit_fk_column_col_type);
        UIUtils.createTableColumn(columnsTable, SWT.LEFT, CoreMessages.dialog_struct_edit_fk_column_ref_col);
        UIUtils.createTableColumn(columnsTable, SWT.LEFT, CoreMessages.dialog_struct_edit_fk_column_ref_col_type);
        UIUtils.packColumns(columnsTable);
        final TableEditor tableEditor = new TableEditor(columnsTable);
        tableEditor.horizontalAlignment = SWT.CENTER;
        tableEditor.verticalAlignment = SWT.TOP;
        tableEditor.grabHorizontal = true;
        tableEditor.minimumWidth = 50;
        columnsTable.addMouseListener(new ColumnsMouseListener(tableEditor, columnsTable));
    }
    final Composite cascadeGroup = UIUtils.createPlaceholder(panel, 4, 5);
    {
        // Cascades
        cascadeGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        final Combo onDeleteCombo = UIUtils.createLabelCombo(cascadeGroup, CoreMessages.dialog_struct_edit_fk_combo_on_delete, SWT.DROP_DOWN | SWT.READ_ONLY);
        onDeleteCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        final Combo onUpdateCombo = UIUtils.createLabelCombo(cascadeGroup, CoreMessages.dialog_struct_edit_fk_combo_on_update, SWT.DROP_DOWN | SWT.READ_ONLY);
        onUpdateCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        for (DBSForeignKeyModifyRule modifyRule : supportedModifyRules) {
            onDeleteCombo.add(modifyRule.getName());
            onUpdateCombo.add(modifyRule.getName());
        }
        onDeleteCombo.select(0);
        onUpdateCombo.select(0);
        onDeleteRule = onUpdateRule = supportedModifyRules[0];
        onDeleteCombo.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                onDeleteRule = supportedModifyRules[onDeleteCombo.getSelectionIndex()];
            }
        });
        onUpdateCombo.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                onUpdateRule = supportedModifyRules[onUpdateCombo.getSelectionIndex()];
            }
        });
    }
    return panel;
}
Also used : DBNNode(org.jkiss.dbeaver.model.navigator.DBNNode) CCombo(org.eclipse.swt.custom.CCombo) CSmartCombo(org.jkiss.dbeaver.ui.controls.CSmartCombo) ItemListControl(org.jkiss.dbeaver.ui.controls.itemlist.ItemListControl) TableEditor(org.eclipse.swt.custom.TableEditor) GridData(org.eclipse.swt.layout.GridData)

Example 17 with TableEditor

use of org.eclipse.swt.custom.TableEditor in project cubrid-manager by CUBRID.

the class AddFKDialog method createComposite.

/**
	 * Create composite
	 * 
	 * @param parent Composite
	 */
private void createComposite(Composite parent) {
    Composite compositeFK = new Composite(parent, SWT.NONE);
    {
        compositeFK.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
        final GridLayout gridLayout = new GridLayout();
        gridLayout.numColumns = 2;
        compositeFK.setLayout(gridLayout);
    }
    Label fkNameLabel = new Label(compositeFK, SWT.NONE);
    fkNameLabel.setLayoutData(new GridData(170, SWT.DEFAULT));
    fkNameLabel.setText(Messages.lblFKName);
    fkNameText = new Text(compositeFK, SWT.BORDER);
    fkNameText.setTextLimit(ValidateUtil.MAX_SCHEMA_NAME_LENGTH);
    fkNameText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    Label targetLabel = new Label(compositeFK, SWT.NONE);
    targetLabel.setText(Messages.lblFTableName);
    foreignTableCombo = new Combo(compositeFK, SWT.READ_ONLY);
    foreignTableCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
    foreignTableCombo.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(org.eclipse.swt.events.SelectionEvent event) {
            getPKTableData();
        }
    });
    Label fkDescLabel = new Label(compositeFK, SWT.NONE);
    fkDescLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1));
    fkDescLabel.setText(Messages.lblFTablePK);
    pkForeignTable = new Table(compositeFK, SWT.FULL_SELECTION | SWT.BORDER | SWT.SINGLE);
    final GridData gdPkForeignTable = new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1);
    gdPkForeignTable.heightHint = 70;
    pkForeignTable.setLayoutData(gdPkForeignTable);
    pkForeignTable.setHeaderVisible(true);
    pkForeignTable.setLinesVisible(true);
    CommonUITool.hackForYosemite(pkForeignTable);
    TableColumn tblcol = new TableColumn(pkForeignTable, SWT.LEFT);
    tblcol.setWidth(120);
    tblcol.setText(Messages.colName);
    tblcol = new TableColumn(pkForeignTable, SWT.LEFT);
    tblcol.setWidth(221);
    tblcol.setText(Messages.colDataType);
    Label descLable = new Label(compositeFK, SWT.NONE);
    descLable.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1));
    descLable.setText(Messages.lblSelectColumns);
    fkTable = new Table(compositeFK, SWT.FULL_SELECTION | SWT.BORDER | SWT.SINGLE);
    final GridData gdFkTable = new GridData(SWT.FILL, SWT.FILL, false, true, 2, 1);
    gdFkTable.heightHint = 100;
    fkTable.setLayoutData(gdFkTable);
    fkTable.setHeaderVisible(true);
    fkTable.setLinesVisible(true);
    CommonUITool.hackForYosemite(fkTable);
    fkTable.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {

        public void widgetSelected(org.eclipse.swt.events.SelectionEvent event) {
            final TableItem item = (TableItem) event.item;
            setErrorMessage(null);
            String oldpkName = item.getText(fkTableColCount - 1);
            if (oldCombo != null) {
                oldCombo.dispose();
            }
            final CCombo combo = new CCombo(fkTable, SWT.NONE);
            TableEditor editor = new TableEditor(fkTable);
            combo.setEditable(false);
            combo.setText(oldpkName);
            //$NON-NLS-1$
            combo.add("");
            if (pkForeignTable.getItemCount() != 0) {
                for (int i = 0, n = pkForeignTable.getItemCount(); i < n; i++) {
                    combo.add(pkForeignTable.getItem(i).getText(0));
                }
            }
            editor.grabHorizontal = true;
            editor.setEditor(combo, item, fkTableColCount - 1);
            combo.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {

                public void widgetSelected(org.eclipse.swt.events.SelectionEvent event) {
                    String pkColumn = combo.getText();
                    if (("").equals(pkColumn)) {
                        item.setText(fkTableColCount - 1, pkColumn);
                        return;
                    }
                    String dataType = DataType.getShownType(refSchema.getDBAttributeByName(pkColumn, false).getType());
                    if (dataType.equals(item.getText(1))) {
                        item.setText(fkTableColCount - 1, pkColumn);
                    } else {
                        setErrorMessage(Messages.errDataTypeInCompatible);
                        combo.setFocus();
                    }
                }
            });
            oldCombo = combo;
        }
    });
    tblcol = new TableColumn(fkTable, SWT.LEFT);
    tblcol.setWidth(122);
    tblcol.setText(Messages.colName);
    tblcol = new TableColumn(fkTable, SWT.LEFT);
    tblcol.setWidth(220);
    tblcol.setText(Messages.colDataType);
    TableColumn tblcombocol = new TableColumn(fkTable, SWT.LEFT);
    tblcombocol.setWidth(171);
    tblcombocol.setText(Messages.colRefColumn);
    final Composite composite = new Composite(compositeFK, SWT.NONE);
    composite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
    GridLayout gridLayout = new GridLayout();
    gridLayout.makeColumnsEqualWidth = true;
    gridLayout.numColumns = 2;
    composite.setLayout(gridLayout);
    final Group onUpdateGroup = new Group(composite, SWT.NONE);
    onUpdateGroup.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
    onUpdateGroup.setText(Messages.grpOnUpdate);
    onUpdateGroup.setLayout(new GridLayout());
    boolean isSupportSetNull = CompatibleUtil.isSupportSetNull(database.getDatabaseInfo());
    // database.getServer().getServerInfo().compareVersionKey("8.3.0") >= 0;
    if (isSupportSetNull) {
        updateBTNs = new Button[4];
    } else {
        updateBTNs = new Button[3];
    }
    buttonMap = new HashMap<Button, String>();
    updateBTNs[0] = new Button(onUpdateGroup, SWT.RADIO);
    updateBTNs[0].setLayoutData(new GridData(100, SWT.DEFAULT));
    //$NON-NLS-1$
    updateBTNs[0].setText("CASCADE");
    updateBTNs[0].setEnabled(false);
    updateBTNs[1] = new Button(onUpdateGroup, SWT.RADIO);
    updateBTNs[1].setSelection(true);
    //$NON-NLS-1$
    updateBTNs[1].setText("RESTRICT");
    updateBTNs[2] = new Button(onUpdateGroup, SWT.RADIO);
    //$NON-NLS-1$
    updateBTNs[2].setText("NO ACTION");
    if (isSupportSetNull) {
        updateBTNs[3] = new Button(onUpdateGroup, SWT.RADIO);
        //$NON-NLS-1$
        updateBTNs[3].setText("SET NULL");
    }
    //$NON-NLS-1$
    buttonMap.put(updateBTNs[0], "CASCADE");
    //$NON-NLS-1$
    buttonMap.put(updateBTNs[1], "RESTRICT");
    //$NON-NLS-1$
    buttonMap.put(updateBTNs[2], "NO ACTION");
    if (isSupportSetNull) {
        //$NON-NLS-1$
        buttonMap.put(updateBTNs[3], "SET NULL");
    }
    final Group onDeleteGroup = new Group(composite, SWT.NONE);
    final GridData gdOnDeleteGroup = new GridData(SWT.FILL, SWT.CENTER, false, false);
    onDeleteGroup.setLayoutData(gdOnDeleteGroup);
    onDeleteGroup.setLayout(new GridLayout());
    onDeleteGroup.setText(Messages.grpOnDelete);
    if (isSupportSetNull) {
        deleteBTNs = new Button[4];
    } else {
        deleteBTNs = new Button[3];
    }
    deleteBTNs[0] = new Button(onDeleteGroup, SWT.RADIO);
    deleteBTNs[0].setLayoutData(new GridData(100, SWT.DEFAULT));
    //$NON-NLS-1$
    deleteBTNs[0].setText("CASCADE");
    deleteBTNs[1] = new Button(onDeleteGroup, SWT.RADIO);
    deleteBTNs[1].setSelection(true);
    //$NON-NLS-1$
    deleteBTNs[1].setText("RESTRICT");
    deleteBTNs[2] = new Button(onDeleteGroup, SWT.RADIO);
    //$NON-NLS-1$
    deleteBTNs[2].setText("NO ACTION");
    if (isSupportSetNull) {
        deleteBTNs[3] = new Button(onDeleteGroup, SWT.RADIO);
        //$NON-NLS-1$
        deleteBTNs[3].setText("SET NULL");
    }
    //$NON-NLS-1$
    buttonMap.put(deleteBTNs[0], "CASCADE");
    //$NON-NLS-1$
    buttonMap.put(deleteBTNs[1], "RESTRICT");
    //$NON-NLS-1$
    buttonMap.put(deleteBTNs[2], "NO ACTION");
    if (isSupportSetNull) {
        //$NON-NLS-1$
        buttonMap.put(deleteBTNs[3], "SET NULL");
    }
    final Group group = new Group(composite, SWT.NONE);
    final GridData gdGroup = new GridData(SWT.FILL, SWT.TOP, true, false, 2, 1);
    group.setLayoutData(gdGroup);
    gridLayout = new GridLayout();
    gridLayout.numColumns = 3;
    group.setLayout(gridLayout);
    onCacheObjectButton = new Button(group, SWT.CHECK);
    onCacheObjectButton.setLayoutData(new GridData());
    onCacheObjectButton.setText(Messages.btnOnCacheObject);
    final Label cacheObjectColumnLabel = new Label(group, SWT.NONE);
    {
        final GridData gdCacheObjectColumnLabel = new GridData();
        gdCacheObjectColumnLabel.horizontalIndent = 20;
        cacheObjectColumnLabel.setLayoutData(gdCacheObjectColumnLabel);
        cacheObjectColumnLabel.setText(Messages.lblCacheColumnName);
    }
    newColumnNameText = new Text(group, SWT.BORDER);
    newColumnNameText.setEnabled(false);
    final GridData gdNewColumnNameText = new GridData(SWT.FILL, SWT.CENTER, true, false);
    newColumnNameText.setLayoutData(gdNewColumnNameText);
    onCacheObjectButton.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(final SelectionEvent event) {
            if (onCacheObjectButton.getSelection()) {
                newColumnNameText.setEnabled(true);
            } else {
                //$NON-NLS-1$
                newColumnNameText.setText("");
                newColumnNameText.setEnabled(false);
            }
        }
    });
}
Also used : SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Group(org.eclipse.swt.widgets.Group) Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) TableItem(org.eclipse.swt.widgets.TableItem) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) CCombo(org.eclipse.swt.custom.CCombo) Combo(org.eclipse.swt.widgets.Combo) TableColumn(org.eclipse.swt.widgets.TableColumn) TableEditor(org.eclipse.swt.custom.TableEditor) GridLayout(org.eclipse.swt.layout.GridLayout) CCombo(org.eclipse.swt.custom.CCombo) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Example 18 with TableEditor

use of org.eclipse.swt.custom.TableEditor 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 19 with TableEditor

use of org.eclipse.swt.custom.TableEditor in project cubrid-manager by CUBRID.

the class InsertTableDataDialog method createAttrTable.

/**
	 * Create the table attribute table
	 */
private void createAttrTable() {
    attrTable = new Table(sashForm, SWT.BORDER | SWT.FULL_SELECTION);
    attrTable.setLayoutData(new GridData(GridData.FILL_BOTH));
    attrTable.setHeaderVisible(true);
    attrTable.setLinesVisible(true);
    TableLayout layout = new TableLayout();
    layout.addColumnData(new ColumnWeightData(20, 120));
    layout.addColumnData(new ColumnWeightData(20, 120));
    layout.addColumnData(new ColumnWeightData(20, 120));
    layout.addColumnData(new ColumnWeightData(40, 160));
    attrTable.setLayout(layout);
    TableColumn[] tblColumns = new TableColumn[4];
    tblColumns[0] = new TableColumn(attrTable, SWT.NONE);
    tblColumns[0].setText(Messages.metaAttribute);
    tblColumns[1] = new TableColumn(attrTable, SWT.NONE);
    tblColumns[1].setText(Messages.metaDomain);
    tblColumns[2] = new TableColumn(attrTable, SWT.NONE);
    tblColumns[2].setText(Messages.metaConstaints);
    tblColumns[3] = new TableColumn(attrTable, SWT.NONE);
    tblColumns[3].setText(Messages.metaValue);
    TableItem item;
    for (int i = 0, n = schemaInfo.getAttributes().size(); i < n; i++) {
        DBAttribute da = (DBAttribute) schemaInfo.getAttributes().get(i);
        String type = DataType.getShownType(da.getType());
        if (type.toUpperCase(Locale.getDefault()).startsWith(DataType.DATATYPE_BLOB) || type.toUpperCase(Locale.getDefault()).startsWith(DataType.DATATYPE_CLOB)) {
            continue;
        }
        item = new TableItem(attrTable, SWT.NONE);
        item.setText(0, da.getName());
        item.setText(1, type);
        item.setText(2, getConstaintString(da));
    }
    packTable();
    tableEditor = new TableEditor(attrTable);
    tableEditor.horizontalAlignment = SWT.LEFT;
    tableEditor.grabHorizontal = true;
    attrTable.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            // Identify the selected row
            TableItem item = (TableItem) event.item;
            if (item == null) {
                return;
            }
            handleValue(item);
        }
    });
}
Also used : ColumnWeightData(org.eclipse.jface.viewers.ColumnWeightData) Table(org.eclipse.swt.widgets.Table) TableItem(org.eclipse.swt.widgets.TableItem) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) TableColumn(org.eclipse.swt.widgets.TableColumn) TableEditor(org.eclipse.swt.custom.TableEditor) DBAttribute(com.cubrid.common.core.common.model.DBAttribute) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) TableLayout(org.eclipse.jface.viewers.TableLayout)

Example 20 with TableEditor

use of org.eclipse.swt.custom.TableEditor in project cubrid-manager by CUBRID.

the class PstmtDataDialog method createParameterTable.

protected void createParameterTable(Composite parent, boolean isMulti) {
    Composite composite = new Composite(parent, SWT.NONE);
    {
        GridLayout gridLayout = new GridLayout();
        gridLayout.numColumns = 2;
        composite.setLayout(gridLayout);
        GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
        composite.setLayoutData(gridData);
    }
    parameterTable = new Table(composite, SWT.BORDER | SWT.FULL_SELECTION);
    {
        GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
        gridData.heightHint = 100;
        parameterTable.setLayoutData(gridData);
        parameterTable.setHeaderVisible(true);
        parameterTable.setLinesVisible(true);
        TableColumn[] tblColumns = new TableColumn[3];
        tblColumns[0] = new TableColumn(parameterTable, SWT.NONE);
        tblColumns[0].setText(Messages.colParaName);
        tblColumns[0].setWidth(130);
        tblColumns[1] = new TableColumn(parameterTable, SWT.NONE);
        tblColumns[1].setText(Messages.colParaType);
        tblColumns[1].setWidth(110);
        tblColumns[2] = new TableColumn(parameterTable, SWT.NONE);
        tblColumns[2].setWidth(130);
        if (isMulti) {
            tblColumns[2].setText(Messages.colFileColumn);
        } else {
            tblColumns[2].setText(Messages.colParaValue);
        }
        tableEditor = new TableEditor(parameterTable);
        tableEditor.horizontalAlignment = SWT.LEFT;
        tableEditor.grabHorizontal = true;
        parameterTable.addListener(SWT.MouseUp, new Listener() {

            public void handleEvent(Event event) {
                if (event.button != 1) {
                    return;
                }
                handle(event);
            }
        });
    }
    Button clearButton = new Button(composite, SWT.NONE);
    {
        GridData gridData = new GridData();
        gridData.verticalAlignment = SWT.TOP;
        clearButton.setLayoutData(gridData);
        if (isMulti) {
            clearButton.setText(Messages.btnClearColumn);
        } else {
            clearButton.setText(Messages.btnClearValue);
        }
        clearButton.addSelectionListener(new SelectionAdapter() {

            public void widgetSelected(SelectionEvent event) {
                for (int i = 0; i < parameterTable.getItemCount(); i++) {
                    parameterTable.getItem(i).setText(2, "");
                }
                getButton(IDialogConstants.OK_ID).setEnabled(false);
            }
        });
    }
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Table(org.eclipse.swt.widgets.Table) Listener(org.eclipse.swt.widgets.Listener) TraverseListener(org.eclipse.swt.events.TraverseListener) 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) FocusEvent(org.eclipse.swt.events.FocusEvent) Event(org.eclipse.swt.widgets.Event) TraverseEvent(org.eclipse.swt.events.TraverseEvent) ModifyEvent(org.eclipse.swt.events.ModifyEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) TableColumn(org.eclipse.swt.widgets.TableColumn) TableEditor(org.eclipse.swt.custom.TableEditor) Point(org.eclipse.swt.graphics.Point)

Aggregations

TableEditor (org.eclipse.swt.custom.TableEditor)39 TableItem (org.eclipse.swt.widgets.TableItem)16 SelectionEvent (org.eclipse.swt.events.SelectionEvent)15 GridData (org.eclipse.swt.layout.GridData)11 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)10 Point (org.eclipse.swt.graphics.Point)10 GridLayout (org.eclipse.swt.layout.GridLayout)7 Button (org.eclipse.swt.widgets.Button)7 CCombo (org.eclipse.swt.custom.CCombo)6 MouseEvent (org.eclipse.swt.events.MouseEvent)6 Event (org.eclipse.swt.widgets.Event)6 Listener (org.eclipse.swt.widgets.Listener)6 TraverseEvent (org.eclipse.swt.events.TraverseEvent)5 TraverseListener (org.eclipse.swt.events.TraverseListener)5 Rectangle (org.eclipse.swt.graphics.Rectangle)5 Composite (org.eclipse.swt.widgets.Composite)5 Label (org.eclipse.swt.widgets.Label)5 Table (org.eclipse.swt.widgets.Table)5 Text (org.eclipse.swt.widgets.Text)5 TableLayout (org.eclipse.jface.viewers.TableLayout)4