Search in sources :

Example 66 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 67 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 68 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)

Example 69 with TableEditor

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

the class FavoriteQueryNavigatorView method createTableGroup.

private void createTableGroup(Composite composite) {
    final String[] columnNames = new String[] { "", com.cubrid.common.ui.query.Messages.msgBatchRunSqlFile, com.cubrid.common.ui.query.Messages.msgBatchRunMemo, com.cubrid.common.ui.query.Messages.msgBatchRunRegdate };
    tv = CommonUITool.createCommonTableViewer(composite, null, columnNames, CommonUITool.createGridData(GridData.FILL_BOTH, 3, 1, -1, 200));
    tv.setInput(FavoriteQueryPersistUtil.getInstance().getListData());
    {
        TableLayout tableLayout = new TableLayout();
        tableLayout.addColumnData(new ColumnPixelData(0));
        tableLayout.addColumnData(new ColumnPixelData(209));
        tableLayout.addColumnData(new ColumnPixelData(80));
        tableLayout.addColumnData(new ColumnPixelData(118));
        tv.getTable().setLayout(tableLayout);
    }
    editor = new TableEditor(tv.getTable());
    editor.horizontalAlignment = SWT.LEFT;
    editor.grabHorizontal = true;
    tv.getTable().addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            widgetDefaultSelected(e);
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            updateButtonStatus();
        }
    });
    tv.getTable().addListener(SWT.MouseUp, new Listener() {

        public void handleEvent(Event event) {
            if (event.button != 1) {
                return;
            }
            updateButtonStatus();
            Point pt = new Point(event.x, event.y);
            int newIndex = tv.getTable().getSelectionIndex();
            if (tv.getTable().getItemCount() <= newIndex || newIndex < 0) {
                return;
            }
            final TableItem item = tv.getTable().getItem(newIndex);
            if (item == null) {
                return;
            }
            Rectangle rect = item.getBounds(2);
            if (rect.contains(pt)) {
                focusCell(item, newIndex, 2);
            }
        }
    });
    tv.addDoubleClickListener(new IDoubleClickListener() {

        public void doubleClick(DoubleClickEvent event) {
            ISelection selection = event.getSelection();
            openSelectedFile(selection);
        }
    });
    createContextMenu();
}
Also used : IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) TraverseListener(org.eclipse.swt.events.TraverseListener) MenuListener(org.eclipse.swt.events.MenuListener) SelectionListener(org.eclipse.swt.events.SelectionListener) Listener(org.eclipse.swt.widgets.Listener) TableItem(org.eclipse.swt.widgets.TableItem) ColumnPixelData(org.eclipse.jface.viewers.ColumnPixelData) Rectangle(org.eclipse.swt.graphics.Rectangle) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) Point(org.eclipse.swt.graphics.Point) TableEditor(org.eclipse.swt.custom.TableEditor) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ISelection(org.eclipse.jface.viewers.ISelection) MenuEvent(org.eclipse.swt.events.MenuEvent) TraverseEvent(org.eclipse.swt.events.TraverseEvent) Event(org.eclipse.swt.widgets.Event) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) TableLayout(org.eclipse.jface.viewers.TableLayout) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 70 with TableEditor

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

the class SchemaInfoEditorPart method setTableEditor.

/**
	 * 
	 * Set table editor
	 * 
	 * @param table Table
	 * @param columnIndex index
	 */
private void setTableEditor(final Table table, final int columnIndex) {
    final TableEditor editor = new TableEditor(table);
    editor.horizontalAlignment = SWT.LEFT;
    editor.grabHorizontal = true;
    table.addListener(SWT.MouseUp, new Listener() {

        public void handleEvent(Event event) {
            if (event.button != 1) {
                return;
            }
            Point pt = new Point(event.x, event.y);
            int topIndex = table.getTopIndex();
            int selectedIndex = table.getSelectionIndex();
            if (selectedIndex < 0 || topIndex > selectedIndex) {
                return;
            }
            final TableItem item = table.getItem(selectedIndex);
            if (item == null) {
                return;
            }
            Rectangle rect = item.getBounds(columnIndex);
            if (rect.contains(pt)) {
                Control oldEditor = editor.getEditor();
                if (oldEditor != null) {
                    oldEditor.dispose();
                }
                final StyledText newEditor = new StyledText(table, SWT.READ_ONLY);
                newEditor.addListener(SWT.FocusOut, new Listener() {

                    public void handleEvent(final Event event) {
                        if (event.type == SWT.FocusOut) {
                            newEditor.dispose();
                        }
                    }
                });
                com.cubrid.common.ui.spi.util.CommonUITool.registerContextMenu(newEditor, false);
                newEditor.setText(item.getText(columnIndex));
                newEditor.selectAll();
                newEditor.setFocus();
                editor.setEditor(newEditor, item, columnIndex);
            }
        }
    });
}
Also used : Control(org.eclipse.swt.widgets.Control) IMenuListener(org.eclipse.jface.action.IMenuListener) Listener(org.eclipse.swt.widgets.Listener) StyledText(org.eclipse.swt.custom.StyledText) TableItem(org.eclipse.swt.widgets.TableItem) Rectangle(org.eclipse.swt.graphics.Rectangle) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent) Event(org.eclipse.swt.widgets.Event) Point(org.eclipse.swt.graphics.Point) TableEditor(org.eclipse.swt.custom.TableEditor)

Aggregations

TableEditor (org.eclipse.swt.custom.TableEditor)124 TableItem (org.eclipse.swt.widgets.TableItem)60 GridData (org.eclipse.swt.layout.GridData)52 Table (org.eclipse.swt.widgets.Table)49 Button (org.eclipse.swt.widgets.Button)41 Text (org.eclipse.swt.widgets.Text)40 GridLayout (org.eclipse.swt.layout.GridLayout)36 Point (org.eclipse.swt.graphics.Point)33 SelectionEvent (org.eclipse.swt.events.SelectionEvent)31 Composite (org.eclipse.swt.widgets.Composite)30 Label (org.eclipse.swt.widgets.Label)29 TableColumn (org.eclipse.swt.widgets.TableColumn)27 CCombo (org.eclipse.swt.custom.CCombo)26 SWT (org.eclipse.swt.SWT)23 Control (org.eclipse.swt.widgets.Control)23 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)20 Rectangle (org.eclipse.swt.graphics.Rectangle)17 FocusEvent (org.eclipse.swt.events.FocusEvent)15 ModifyEvent (org.eclipse.swt.events.ModifyEvent)14 ModifyListener (org.eclipse.swt.events.ModifyListener)14