Search in sources :

Example 21 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 22 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)

Example 23 with TableEditor

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

the class JdbcOptionComposite method createJdbcTableGroup.

/**
	 *
	 * Create JDBC table group
	 *
	 * @param composite the composite
	 */
private void createJdbcTableGroup(Composite composite) {
    final String[] columnNameArr = new String[] { Messages.tblColJdbcAttrName, Messages.tblColJdbcAttrValue };
    jdbcInfoTv = CommonUITool.createCommonTableViewer(composite, null, columnNameArr, CommonUITool.createGridData(GridData.FILL_BOTH, 3, 1, -1, 150));
    jdbcInfoTv.setInput(jdbcListData);
    TableLayout tableLayout = new TableLayout();
    jdbcInfoTv.getTable().setLayout(tableLayout);
    tableLayout.addColumnData(new ColumnWeightData(35, true));
    tableLayout.addColumnData(new ColumnWeightData(65, true));
    editor = new TableEditor(jdbcInfoTv.getTable());
    editor.horizontalAlignment = SWT.LEFT;
    editor.grabHorizontal = true;
    jdbcInfoTv.getTable().addListener(SWT.MouseUp, new Listener() {

        public void handleEvent(Event event) {
            if (event.button != 1) {
                return;
            }
            Point pt = new Point(event.x, event.y);
            int newIndex = jdbcInfoTv.getTable().getSelectionIndex();
            if (jdbcInfoTv.getTable().getItemCount() <= newIndex || newIndex < 0) {
                return;
            }
            final TableItem item = jdbcInfoTv.getTable().getItem(newIndex);
            if (item == null) {
                return;
            }
            for (int i = 0; i < 2; i++) {
                Rectangle rect = item.getBounds(i);
                if (rect.contains(pt)) {
                    focusCell(item, newIndex, i);
                    break;
                }
            }
        }
    });
}
Also used : ColumnWeightData(org.eclipse.jface.viewers.ColumnWeightData) Listener(org.eclipse.swt.widgets.Listener) TraverseListener(org.eclipse.swt.events.TraverseListener) MouseListener(org.eclipse.swt.events.MouseListener) TableItem(org.eclipse.swt.widgets.TableItem) Rectangle(org.eclipse.swt.graphics.Rectangle) Event(org.eclipse.swt.widgets.Event) TraverseEvent(org.eclipse.swt.events.TraverseEvent) MouseEvent(org.eclipse.swt.events.MouseEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Point(org.eclipse.swt.graphics.Point) TableLayout(org.eclipse.jface.viewers.TableLayout) TableEditor(org.eclipse.swt.custom.TableEditor)

Example 24 with TableEditor

use of org.eclipse.swt.custom.TableEditor in project azure-tools-for-java by Microsoft.

the class WindowsAzureActivityLogView method addDeployment.

public void addDeployment(String key, String description, Date startDate) {
    if (rows.containsKey(key)) {
        rows.remove(key);
    }
    TableItem item = new TableItem(table, SWT.NONE);
    item.setText(new String[] { description, null, null, dateFormat.format(startDate) });
    ProgressBar bar = new ProgressBar(table, SWT.NONE);
    bar.setSelection(0);
    TableEditor editor = new TableEditor(table);
    editor.grabHorizontal = editor.grabVertical = true;
    editor.setEditor(bar, item, 1);
    Link link = new Link(table, SWT.LEFT);
    link.setText("");
    link.setBackground(item.getBackground());
    rows.put(key, new TableRowDescriptor(item, bar, link));
}
Also used : TableItem(org.eclipse.swt.widgets.TableItem) ProgressBar(org.eclipse.swt.widgets.ProgressBar) TableEditor(org.eclipse.swt.custom.TableEditor) Link(org.eclipse.swt.widgets.Link)

Example 25 with TableEditor

use of org.eclipse.swt.custom.TableEditor in project MonjaDB by Kanatoko.

the class MDocumentList method onTableDoubleClick.

//--------------------------------------------------------------------------------
private void onTableDoubleClick(final int x, final int y) {
    //system.indexes is ignored
    if (dataManager.getCollName().equals("system.indexes")) {
        return;
    }
    final TableEditor editor = new TableEditor(table);
    shell.getDisplay().asyncExec(new Runnable() {

        public void run() {
            //*****
            Point point = new Point(x, y);
            final TableItem item = table.getItem(point);
            if (item == null) {
                return;
            }
            int columnIndex = -1;
            for (int i = 0; i < table.getColumnCount(); ++i) {
                if (item.getBounds(i).contains(point)) {
                    columnIndex = i;
                    break;
                }
            }
            if (//ObjectId
            columnIndex == -1 || columnIndex == 0) {
                return;
            }
            final Class clazz = getCurrentClass(item, columnIndex);
            if (clazz == CodeWScope.class || clazz == BSONTimestamp.class || clazz == byte[].class || clazz == MinKey.class || clazz == MaxKey.class) {
                return;
            }
            final Text text = new Text(table, SWT.NONE | SWT.BORDER);
            text.setText(item.getText(columnIndex));
            //text.selectAll();
            editor.horizontalAlignment = SWT.LEFT;
            editor.grabHorizontal = true;
            editor.setEditor(text, item, columnIndex);
            final int selectedColumn = columnIndex;
            Listener textListener = new Listener() {

                public void handleEvent(final Event e) {
                    switch(e.type) {
                        case SWT.FocusOut:
                            updateDocument(item, selectedColumn, clazz, text.getText());
                            text.dispose();
                            break;
                        case SWT.Traverse:
                            switch(e.detail) {
                                case SWT.TRAVERSE_RETURN:
                                    //item.setText( selectedColumn, text.getText() );
                                    updateDocument(item, selectedColumn, clazz, text.getText());
                                //break;
                                case SWT.TRAVERSE_ESCAPE:
                                    text.dispose();
                                    e.doit = false;
                            }
                            break;
                    }
                }
            };
            text.addListener(SWT.FocusOut, textListener);
            text.addListener(SWT.Traverse, textListener);
            //text.selectAll();
            text.setFocus();
        }
    });
//*****
}
Also used : MinKey(org.bson.types.MinKey) ModifyListener(org.eclipse.swt.events.ModifyListener) BSONTimestamp(org.bson.types.BSONTimestamp) KeyEvent(org.eclipse.swt.events.KeyEvent) ModifyEvent(org.eclipse.swt.events.ModifyEvent) MouseEvent(org.eclipse.swt.events.MouseEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Point(org.eclipse.swt.graphics.Point) TableEditor(org.eclipse.swt.custom.TableEditor) CodeWScope(org.bson.types.CodeWScope)

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