Search in sources :

Example 31 with MouseEvent

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

the class QueryExecuter method bindEvents.

private void bindEvents() {
    selectableSupport.getTableCursor().addMouseListener(new MouseListener() {

        public void mouseUp(MouseEvent e) {
        }

        public void mouseDown(MouseEvent e) {
        }

        public void mouseDoubleClick(MouseEvent e) {
            performEdit();
        }
    });
    selectableSupport.getTableCursor().addKeyListener(new KeyListener() {

        public void keyReleased(KeyEvent e) {
        }

        public void keyPressed(KeyEvent e) {
            if (e.character == SWT.CR) {
                performEdit();
            }
        }
    });
    selectableSupport.getTableCursor().addKeyListener(new org.eclipse.swt.events.KeyAdapter() {

        public void keyReleased(KeyEvent event) {
            if (isEditMode() && event.keyCode == SWT.DEL) {
                deleteRecord(tblResult, null);
            } else if (((event.stateMask & SWT.CTRL) != 0 || (event.stateMask & SWT.COMMAND) != 0) && (event.keyCode == 'c' || event.character == '')) {
                // key press 'ctrl + c' is intercept by editor text so add
                // here
                copySelectedItems();
            } else if ((event.stateMask & SWT.CTRL) != 0 && event.keyCode == 'a') {
                selectableSupport.selectAll();
            }
        }
    });
}
Also used : KeyEvent(org.eclipse.swt.events.KeyEvent) MouseListener(org.eclipse.swt.events.MouseListener) MouseEvent(org.eclipse.swt.events.MouseEvent) KeyListener(org.eclipse.swt.events.KeyListener)

Example 32 with MouseEvent

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

the class SelectedLoactionComparator method redrawMoreButton.

public void redrawMoreButton() {
    if (moreButton != null && !moreButton.isDisposed()) {
        moreButton.dispose();
    }
    if (showMoreOperator != null) {
        if (tableCursor != null && !tableCursor.isDisposed() && tableCursor.getRow() != null) {
            final int rowIndex = table.indexOf(tableCursor.getRow());
            final int columnIndex = tableCursor.getColumn();
            if (showMoreOperator.isShowButton(rowIndex, columnIndex)) {
                moreButton = new Button(tableCursor, SWT.None);
                moreButton.setText("...");
                Rectangle location = tableCursor.getBounds();
                int x = location.width - detailButtonWidth;
                if (x < 0) {
                    x = 0;
                }
                moreButton.setBounds(x, 0, detailButtonWidth, location.height);
                moreButton.addSelectionListener(new SelectionListener() {

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

                    public void widgetDefaultSelected(SelectionEvent e) {
                        if (showMoreOperator != null) {
                            showMoreOperator.handleButtonEvent(rowIndex, columnIndex);
                        }
                    }
                });
                moreButton.addMouseListener(new MouseListener() {

                    public void mouseUp(MouseEvent e) {
                        handleMouseUp(e);
                    }

                    public void mouseDown(MouseEvent e) {
                    }

                    public void mouseDoubleClick(MouseEvent e) {
                    }
                });
            }
        }
    }
}
Also used : MouseListener(org.eclipse.swt.events.MouseListener) MouseEvent(org.eclipse.swt.events.MouseEvent) Button(org.eclipse.swt.widgets.Button) Rectangle(org.eclipse.swt.graphics.Rectangle) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Point(org.eclipse.swt.graphics.Point) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 33 with MouseEvent

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

the class BrokerEnvStatusView method createTable.

/**
	 * This method initializes table
	 *
	 */
private void createTable() {
    tableViewer = new TableViewer(composite, SWT.FULL_SELECTION);
    tableViewer.getTable().setHeaderVisible(true);
    tableViewer.getTable().setLinesVisible(true);
    BrokerTblColumnSetHelp bcsh = BrokerTblColumnSetHelp.getInstance();
    bcsh.loadSetting(BrokerTblColumnSetHelp.StatusColumn.BrokerEnvStatusColumn, BrokerEnvStatusColumn.values());
    TableLayout tlayout = new TableLayout();
    for (BrokerEnvStatusColumn column : BrokerEnvStatusColumn.values()) {
        if (column.getValue() == -1) {
            tlayout.addColumnData(new ColumnWeightData(0, 0, false));
        } else {
            tlayout.addColumnData(new ColumnWeightData(10, 40, true));
        }
    }
    tableViewer.getTable().setLayout(tlayout);
    tableViewer.getTable().addMouseListener(new MouseAdapter() {

        public void mouseDoubleClick(MouseEvent event) {
            int index = -1;
            if ((index = tableViewer.getTable().getSelectionIndex()) >= 0) {
                TableItem tableItem = tableViewer.getTable().getItem(index);
                String brokename = tableItem.getText(0).trim();
                ICubridNode input = null;
                for (ICubridNode node : cubridNode.getChildren()) {
                    if (node.getLabel().equalsIgnoreCase(brokename)) {
                        input = node;
                        break;
                    }
                }
                LayoutManager.getInstance().setCurrentSelectedNode(input);
                IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
                if (null == window) {
                    return;
                }
                IWorkbenchPage activePage = window.getActivePage();
                IViewPart viewPart = window.getActivePage().findView(BrokerStatusView.ID);
                if (null != viewPart) {
                    activePage.hideView(viewPart);
                }
                try {
                    activePage.showView(BrokerStatusView.ID);
                } catch (PartInitException e1) {
                    LOGGER.error(e1.getMessage(), e1);
                }
            }
        }
    });
    makeTableColumn();
    tableViewer.setContentProvider(new BrokersStatusContentProvider());
    ServerInfo serverInfo = cubridNode.getServer().getServerInfo();
    BrokersStatusLabelProvider brokersStatusLabelProvider = new BrokersStatusLabelProvider();
    brokersStatusLabelProvider.setServerInfo(serverInfo);
    tableViewer.setLabelProvider(brokersStatusLabelProvider);
}
Also used : ColumnWeightData(org.eclipse.jface.viewers.ColumnWeightData) IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IViewPart(org.eclipse.ui.IViewPart) MouseEvent(org.eclipse.swt.events.MouseEvent) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) TableItem(org.eclipse.swt.widgets.TableItem) MouseAdapter(org.eclipse.swt.events.MouseAdapter) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) BrokerEnvStatusColumn(com.cubrid.cubridmanager.ui.broker.editor.internal.BrokerEnvStatusColumn) BrokerTblColumnSetHelp(com.cubrid.cubridmanager.ui.broker.editor.internal.BrokerTblColumnSetHelp) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) PartInitException(org.eclipse.ui.PartInitException) TableViewer(org.eclipse.jface.viewers.TableViewer) TableLayout(org.eclipse.jface.viewers.TableLayout)

Example 34 with MouseEvent

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

the class CubridNavigatorView method addListener.

/**
	 *
	 * Add listener
	 *
	 */
protected void addListener() {
    tv.getTree().addMouseListener(new MouseAdapter() {

        public void mouseDown(MouseEvent event) {
            if (toolTip.isVisible()) {
                toolTip.setVisible(false);
            }
        }

        public void mouseUp(MouseEvent event) {
            if (event.button == 1 && LayoutManager.getInstance().isUseClickOnce()) {
                ISelection selection = tv.getSelection();
                if (selection == null || selection.isEmpty()) {
                    return;
                }
                Object obj = ((IStructuredSelection) selection).getFirstElement();
                if (!(obj instanceof ICubridNode)) {
                    return;
                }
                ICubridNode cubridNode = (ICubridNode) obj;
                LayoutManager.getInstance().getWorkbenchContrItem().openEditorOrView(cubridNode);
            }
        }
    });
    tv.getTree().addMouseTrackListener(new MouseTrackAdapter() {

        public void mouseHover(MouseEvent event) {
            if (toolTip.isVisible()) {
                toolTip.setVisible(false);
            }
            int x = event.x;
            int y = event.y;
            TreeItem item = tv.getTree().getItem(new Point(x, y));
            if (item == null) {
                return;
            }
            showToolTip(item);
        }
    });
    tv.getTree().addSelectionListener(new SelectionListener() {

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

        public void widgetSelected(SelectionEvent event) {
            if (toolTip.isVisible()) {
                toolTip.setVisible(false);
            }
            TreeItem[] items = tv.getTree().getSelection();
            if (items == null || items.length == 0) {
                return;
            }
            showToolTip(items[0]);
            if (items.length == 1) {
                showSchemaInfo(items[0]);
            } else {
                showSchemaInfo(null);
            }
        }
    });
    addDragDropSupport(tv.getTree());
    tv.getTree().addKeyListener(new KeyListener() {

        public void keyReleased(KeyEvent e) {
        }

        public void keyPressed(KeyEvent e) {
            // prevent to make events by key press for a long time
            if (e.character == ' ') {
                TreeItem[] items = tv.getTree().getSelection();
                if (items == null || items.length == 0) {
                    return;
                }
                if (items.length == 1) {
                    showSchemaInfo(items[0]);
                } else {
                    showSchemaInfo(null);
                }
            }
            lastKeyInputTimestamp = System.currentTimeMillis();
            // by showing object information tab on the query editor.
            if (e.keyCode == SWT.F2) {
                TreeItem[] items = tv.getTree().getSelection();
                if (items == null || items.length == 0) {
                    return;
                }
                for (TreeItem item : items) {
                    Object obj = item.getData();
                    if (obj instanceof ICubridNode) {
                        ICubridNode node = (ICubridNode) obj;
                        if (NodeType.USER_TABLE.equals(node.getType()) || NodeType.SYSTEM_TABLE.equals(node.getType()) || NodeType.USER_VIEW.equals(node.getType()) || NodeType.SYSTEM_VIEW.equals(node.getType())) {
                            DefaultSchemaNode table = (DefaultSchemaNode) obj;
                            OpenTargetAction action = new OpenTargetAction();
                            action.showObjectInfo(table);
                        } else if (NodeType.TABLE_FOLDER.equals(node.getType())) {
                            CubridNavigatorView view = CubridNavigatorView.getNavigatorView(ID_CQB);
                            if (view == null) {
                                view = CubridNavigatorView.getNavigatorView(ID_CM);
                            }
                            if (view == null) {
                                return;
                            }
                            TreeViewer treeViewer = view.getViewer();
                            //if not expand ,expand the node and wait until all children be added
                            if (!treeViewer.getExpandedState(node)) {
                                treeViewer.expandToLevel(node, 1);
                                while (node.getChildren().size() == 0) {
                                    try {
                                        Thread.sleep(500);
                                    } catch (Exception ignored) {
                                    }
                                }
                            }
                            CubridDatabase database = (CubridDatabase) node.getParent();
                            OpenTargetAction action = new OpenTargetAction();
                            action.showTableDashboard(database);
                        }
                    }
                }
            }
        }
    });
}
Also used : MouseEvent(org.eclipse.swt.events.MouseEvent) TreeItem(org.eclipse.swt.widgets.TreeItem) TreeViewer(org.eclipse.jface.viewers.TreeViewer) MouseAdapter(org.eclipse.swt.events.MouseAdapter) MouseTrackAdapter(org.eclipse.swt.events.MouseTrackAdapter) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) Point(org.eclipse.swt.graphics.Point) DefaultSchemaNode(com.cubrid.common.ui.spi.model.DefaultSchemaNode) OpenTargetAction(com.cubrid.common.ui.common.action.OpenTargetAction) KeyEvent(org.eclipse.swt.events.KeyEvent) ISelection(org.eclipse.jface.viewers.ISelection) SelectionEvent(org.eclipse.swt.events.SelectionEvent) KeyListener(org.eclipse.swt.events.KeyListener) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 35 with MouseEvent

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

the class QueryPlanCompositeWithHistory method initialize.

/**
	 * Initializing a Plan Tab
	 */
private void initialize() {
    createPlanToolbar();
    //create the plan tab folder and history sash
    plansHistorySash = new SashForm(this, SWT.HORIZONTAL);
    plansHistorySash.setLayout(new GridLayout(2, true));
    plansHistorySash.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    //create left plan tab folder
    plansTabFolder = new CTabFolder(plansHistorySash, SWT.BOTTOM | SWT.CLOSE);
    plansTabFolder.setSimple(false);
    plansTabFolder.setUnselectedImageVisible(true);
    plansTabFolder.setUnselectedCloseVisible(true);
    plansTabFolder.setSelectionBackground(CombinedQueryEditorComposite.BACK_COLOR);
    plansTabFolder.setSelectionForeground(ResourceManager.getColor(SWT.COLOR_BLACK));
    plansTabFolder.setLayout(new GridLayout(1, true));
    plansTabFolder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    TabContextMenuManager tabContextMenuManager = new TabContextMenuManager(plansTabFolder);
    tabContextMenuManager.createContextMenu();
    //create the right plan history table
    planHistoryTable = new Table(plansHistorySash, SWT.MULTI | SWT.FULL_SELECTION | SWT.BORDER);
    planHistoryTable.setLayout(new GridLayout(1, true));
    planHistoryTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    planHistoryTable.setHeaderVisible(true);
    planHistoryTable.setLinesVisible(true);
    planHistoryTable.addMouseListener(new MouseListener() {

        public void mouseDoubleClick(MouseEvent event) {
            int selectionIndex = planHistoryTable.getSelectionIndex();
            if (selectionIndex < 0) {
                return;
            }
            TableItem tableItem = planHistoryTable.getItem(planHistoryTable.getSelectionIndex());
            if (tableItem == null) {
                return;
            }
            int uid = Integer.valueOf(tableItem.getText(0));
            StructQueryPlan sq = planHistoryList.get(uid - 1);
            PlanTabItem tabItem = findPlanTab(uid);
            if (tabItem == null) {
                tabItem = newPlanTab(uid);
            }
            plansTabFolder.setSelection(tabItem);
            printPlan(tabItem, sq);
        }

        public void mouseDown(MouseEvent event) {
        }

        public void mouseUp(MouseEvent event) {
        }
    });
    int i = 0;
    planHistoryTblCols[i] = new TableColumn(planHistoryTable, SWT.RIGHT);
    // No
    planHistoryTblCols[i].setText(Messages.qedit_plan_history_col1);
    planHistoryTblCols[i].setMoveable(true);
    planHistoryTblCols[i].setWidth(20);
    addNumberSorter(planHistoryTable, planHistoryTblCols[i]);
    sortType.put(planHistoryTblCols[i], "NUMBER");
    planHistoryTblCols[++i] = new TableColumn(planHistoryTable, SWT.LEFT);
    // Date
    planHistoryTblCols[i].setText(Messages.qedit_plan_history_col2);
    planHistoryTblCols[i].setMoveable(true);
    planHistoryTblCols[i].setWidth(100);
    addStringSorter(planHistoryTable, planHistoryTblCols[i]);
    sortType.put(planHistoryTblCols[i], "STRING");
    planHistoryTblCols[++i] = new TableColumn(planHistoryTable, SWT.RIGHT);
    // Cost
    planHistoryTblCols[i].setText(Messages.qedit_plan_history_col4);
    planHistoryTblCols[i].setMoveable(true);
    planHistoryTblCols[i].setWidth(90);
    addNumberSorter(planHistoryTable, planHistoryTblCols[i]);
    sortType.put(planHistoryTblCols[i], "NUMBER");
    planHistoryTblCols[++i] = new TableColumn(planHistoryTable, SWT.LEFT);
    // Cost
    planHistoryTblCols[i].setText(Messages.qedit_plan_history_col3);
    planHistoryTblCols[i].setMoveable(false);
    planHistoryTblCols[i].setWidth(90);
    addStringSorter(planHistoryTable, planHistoryTblCols[i]);
    sortType.put(planHistoryTblCols[i], "STRING");
    sashPlanWeight = new int[] { 80, 20 };
    plansHistorySash.setWeights(sashPlanWeight);
    newPlanTab(1);
    plansTabFolder.setSelection(0);
    hideHistoryPane();
    refreshToolbarStatus(QueryOptions.getQueryPlanDisplayType());
}
Also used : CTabFolder(org.eclipse.swt.custom.CTabFolder) Table(org.eclipse.swt.widgets.Table) MouseEvent(org.eclipse.swt.events.MouseEvent) TableItem(org.eclipse.swt.widgets.TableItem) TableColumn(org.eclipse.swt.widgets.TableColumn) SashForm(org.eclipse.swt.custom.SashForm) GridLayout(org.eclipse.swt.layout.GridLayout) MouseListener(org.eclipse.swt.events.MouseListener) GridData(org.eclipse.swt.layout.GridData) StructQueryPlan(com.cubrid.common.core.queryplan.StructQueryPlan) TabContextMenuManager(com.cubrid.common.ui.spi.util.TabContextMenuManager)

Aggregations

MouseEvent (org.eclipse.swt.events.MouseEvent)100 MouseAdapter (org.eclipse.swt.events.MouseAdapter)50 GridData (org.eclipse.swt.layout.GridData)37 MouseListener (org.eclipse.swt.events.MouseListener)32 SelectionEvent (org.eclipse.swt.events.SelectionEvent)32 Point (org.eclipse.swt.graphics.Point)32 KeyEvent (org.eclipse.swt.events.KeyEvent)27 Composite (org.eclipse.swt.widgets.Composite)26 GridLayout (org.eclipse.swt.layout.GridLayout)25 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)20 Button (org.eclipse.swt.widgets.Button)20 FocusEvent (org.eclipse.swt.events.FocusEvent)18 PaintEvent (org.eclipse.swt.events.PaintEvent)18 Event (org.eclipse.swt.widgets.Event)15 Label (org.eclipse.swt.widgets.Label)15 Text (org.eclipse.swt.widgets.Text)14 MouseMoveListener (org.eclipse.swt.events.MouseMoveListener)13 PaintListener (org.eclipse.swt.events.PaintListener)13 KeyListener (org.eclipse.swt.events.KeyListener)12 ModifyEvent (org.eclipse.swt.events.ModifyEvent)12