Search in sources :

Example 11 with MouseListener

use of org.eclipse.swt.events.MouseListener 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 12 with MouseListener

use of org.eclipse.swt.events.MouseListener 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)

Example 13 with MouseListener

use of org.eclipse.swt.events.MouseListener in project eclipse.platform.text by eclipse.

the class AnnotationRulerColumn method createControl.

@Override
public Control createControl(CompositeRuler parentRuler, Composite parentControl) {
    fParentRuler = parentRuler;
    fCachedTextViewer = parentRuler.getTextViewer();
    fCachedTextWidget = fCachedTextViewer.getTextWidget();
    fHitDetectionCursor = parentControl.getDisplay().getSystemCursor(SWT.CURSOR_HAND);
    fCanvas = createCanvas(parentControl);
    fCanvas.addPaintListener(new PaintListener() {

        @Override
        public void paintControl(PaintEvent event) {
            if (fCachedTextViewer != null)
                doubleBufferPaint(event.gc);
        }
    });
    fCanvas.addDisposeListener(new DisposeListener() {

        @Override
        public void widgetDisposed(DisposeEvent e) {
            handleDispose();
            fCachedTextViewer = null;
            fCachedTextWidget = null;
        }
    });
    fMouseListener = new MouseListener() {

        @Override
        public void mouseUp(MouseEvent event) {
            int lineNumber;
            if (isPropagatingMouseListener()) {
                fParentRuler.setLocationOfLastMouseButtonActivity(event.x, event.y);
                lineNumber = fParentRuler.getLineOfLastMouseButtonActivity();
            } else
                lineNumber = fParentRuler.toDocumentLineNumber(event.y);
            if (1 == event.button)
                mouseClicked(lineNumber);
        }

        @Override
        public void mouseDown(MouseEvent event) {
            int lineNumber;
            if (isPropagatingMouseListener()) {
                fParentRuler.setLocationOfLastMouseButtonActivity(event.x, event.y);
                lineNumber = fParentRuler.getLineOfLastMouseButtonActivity();
            } else
                lineNumber = fParentRuler.toDocumentLineNumber(event.y);
            if (1 == event.button)
                AnnotationRulerColumn.this.mouseDown(lineNumber);
        }

        @Override
        public void mouseDoubleClick(MouseEvent event) {
            int lineNumber;
            if (isPropagatingMouseListener()) {
                fParentRuler.setLocationOfLastMouseButtonActivity(event.x, event.y);
                lineNumber = fParentRuler.getLineOfLastMouseButtonActivity();
            } else
                lineNumber = fParentRuler.toDocumentLineNumber(event.y);
            if (1 == event.button)
                mouseDoubleClicked(lineNumber);
        }
    };
    fCanvas.addMouseListener(fMouseListener);
    fCanvas.addMouseMoveListener(new MouseMoveListener() {

        @Override
        public void mouseMove(MouseEvent e) {
            handleMouseMove(e);
        }
    });
    fCanvas.addMouseWheelListener(new MouseWheelListener() {

        @Override
        public void mouseScrolled(MouseEvent e) {
            handleMouseScrolled(e);
        }
    });
    if (fCachedTextViewer != null) {
        VisibleLinesTracker.track(fCachedTextViewer, lineHeightChangeHandler);
        fCachedTextViewer.addTextListener(fLineListener);
        // on word wrap toggle a "resized" ControlEvent is fired: suggest a redraw of the ruler
        fCachedTextWidget.addControlListener(new ControlAdapter() {

            @Override
            public void controlResized(ControlEvent e) {
                if (fCachedTextWidget != null && fCachedTextWidget.getWordWrap()) {
                    redraw();
                }
            }
        });
    }
    return fCanvas;
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) MouseMoveListener(org.eclipse.swt.events.MouseMoveListener) PaintEvent(org.eclipse.swt.events.PaintEvent) MouseListener(org.eclipse.swt.events.MouseListener) MouseEvent(org.eclipse.swt.events.MouseEvent) ControlAdapter(org.eclipse.swt.events.ControlAdapter) PaintListener(org.eclipse.swt.events.PaintListener) MouseWheelListener(org.eclipse.swt.events.MouseWheelListener) DisposeEvent(org.eclipse.swt.events.DisposeEvent) ControlEvent(org.eclipse.swt.events.ControlEvent)

Example 14 with MouseListener

use of org.eclipse.swt.events.MouseListener in project eclipse.platform.text by eclipse.

the class LineNumberRulerColumn method createControl.

@Override
public Control createControl(CompositeRuler parentRuler, Composite parentControl) {
    fParentRuler = parentRuler;
    fCachedTextViewer = parentRuler.getTextViewer();
    fCachedTextWidget = fCachedTextViewer.getTextWidget();
    // on word wrap toggle a "resized" ControlEvent is fired: suggest a redraw of the line ruler
    fCachedTextWidget.addControlListener(new ControlAdapter() {

        @Override
        public void controlResized(ControlEvent e) {
            if (fCachedTextWidget != null && fCachedTextWidget.getWordWrap()) {
                postRedraw();
            }
        }
    });
    // track when StyledText is redrawn to check if some line height changed. In this case, the ruler must be redrawn
    // to draw line number with well height.
    VisibleLinesTracker.track(fCachedTextViewer, lineHeightChangeHandler);
    fCanvas = new Canvas(parentControl, SWT.NO_FOCUS) {

        @Override
        public void addMouseListener(MouseListener listener) {
            // see bug 40889, bug 230073 and AnnotationRulerColumn#isPropagatingMouseListener()
            if (listener == fMouseHandler)
                super.addMouseListener(listener);
            else {
                TypedListener typedListener = null;
                if (listener != null)
                    typedListener = new TypedListener(listener);
                addListener(SWT.MouseDoubleClick, typedListener);
            }
        }
    };
    fCanvas.setBackground(getBackground(fCanvas.getDisplay()));
    fCanvas.setForeground(fForeground);
    fCanvas.addPaintListener(new PaintListener() {

        @Override
        public void paintControl(PaintEvent event) {
            if (fCachedTextViewer != null)
                doubleBufferPaint(event.gc);
        }
    });
    fCanvas.addDisposeListener(new DisposeListener() {

        @Override
        public void widgetDisposed(DisposeEvent e) {
            handleDispose();
            fCachedTextViewer = null;
            fCachedTextWidget = null;
        }
    });
    fMouseHandler = new MouseHandler();
    fCanvas.addMouseListener(fMouseHandler);
    fCanvas.addMouseMoveListener(fMouseHandler);
    fCanvas.addMouseWheelListener(fMouseHandler);
    if (fCachedTextViewer != null) {
        VisibleLinesTracker.track(fCachedTextViewer, lineHeightChangeHandler);
        fCachedTextViewer.addTextListener(fInternalListener);
        if (fFont == null) {
            if (fCachedTextWidget != null && !fCachedTextWidget.isDisposed())
                fFont = fCachedTextWidget.getFont();
        }
    }
    if (fFont != null)
        fCanvas.setFont(fFont);
    updateNumberOfDigits();
    computeIndentations();
    return fCanvas;
}
Also used : TypedListener(org.eclipse.swt.widgets.TypedListener) DisposeListener(org.eclipse.swt.events.DisposeListener) MouseListener(org.eclipse.swt.events.MouseListener) PaintEvent(org.eclipse.swt.events.PaintEvent) ControlAdapter(org.eclipse.swt.events.ControlAdapter) PaintListener(org.eclipse.swt.events.PaintListener) Canvas(org.eclipse.swt.widgets.Canvas) ControlEvent(org.eclipse.swt.events.ControlEvent) DisposeEvent(org.eclipse.swt.events.DisposeEvent)

Example 15 with MouseListener

use of org.eclipse.swt.events.MouseListener in project eclipse.platform.swt by eclipse.

the class CurvesTab method createControlPanel.

/**
 * Creates the widgets used to control the drawing.
 */
@Override
public void createControlPanel(Composite parent) {
    if (cursor == null) {
        cursor = parent.getDisplay().getSystemCursor(SWT.CURSOR_HAND);
    }
    mouseMoveListener = e -> {
        if (hovering && mouseDown) {
            example.canvas.setCursor(cursor);
        } else if (isHovering(e)) {
            example.canvas.setCursor(cursor);
            hovering = true;
        } else {
            example.canvas.setCursor(null);
            hovering = false;
        }
        if (quadPtMoved) {
            quadDiffX = quadDiffX + e.x - (int) quadXPos - quadHndl.x;
            quadDiffY = quadDiffY + e.y - (int) quadYPos - quadHndl.y;
            quadHndl.x = e.x - (int) quadXPos;
            quadHndl.y = e.y - (int) quadYPos;
        } else if (quadEndPtMoved) {
            quadEndDiffX = quadEndDiffX + e.x - (int) quadXPos - quadEndHndl.x;
            quadEndDiffY = quadEndDiffY + e.y - (int) quadYPos - quadEndHndl.y;
            quadEndHndl.x = e.x - (int) quadXPos;
            quadEndHndl.y = e.y - (int) quadYPos;
        } else if (cubPt1Moved) {
            cubDiffX1 = cubDiffX1 + e.x - (int) cubXPos - cubHndl1.x;
            cubDiffY1 = cubDiffY1 + e.y - (int) cubYPos - cubHndl1.y;
            cubHndl1.x = e.x - (int) cubXPos;
            cubHndl1.y = e.y - (int) cubYPos;
        } else if (cubPt2Moved) {
            cubDiffX2 = cubDiffX2 + e.x - (int) cubXPos - cubHndl2.x;
            cubDiffY2 = cubDiffY2 + e.y - (int) cubYPos - cubHndl2.y;
            cubHndl2.x = e.x - (int) cubXPos;
            cubHndl2.y = e.y - (int) cubYPos;
        } else if (cubEndPtMoved) {
            cubEndDiffX = cubEndDiffX + e.x - (int) cubXPos - cubEndHndl.x;
            cubEndDiffY = cubEndDiffY + e.y - (int) cubYPos - cubEndHndl.y;
            cubEndHndl.x = e.x - (int) cubXPos;
            cubEndHndl.y = e.y - (int) cubYPos;
        }
        example.redraw();
    };
    mouseListener = new MouseListener() {

        @Override
        public void mouseDoubleClick(MouseEvent e) {
        }

        /**
         * Sent when a mouse button is pressed.
         *
         * @param e an event containing information about the mouse button press
         */
        @Override
        public void mouseDown(MouseEvent e) {
            Rectangle quad = new Rectangle(quadHndl.x + (int) quadXPos - 1, quadHndl.y + (int) quadYPos - 1, quadHndl.width + 2, quadHndl.height + 2);
            Rectangle quadEnd = new Rectangle(quadEndHndl.x + (int) quadXPos - 1, quadEndHndl.y + (int) quadYPos - 1, quadEndHndl.width + 2, quadEndHndl.height + 2);
            Rectangle cub1 = new Rectangle(cubHndl1.x + (int) cubXPos - 1, cubHndl1.y + (int) cubYPos - 1, cubHndl1.width + 2, cubHndl1.height + 2);
            Rectangle cub2 = new Rectangle(cubHndl2.x + (int) cubXPos - 1, cubHndl2.y + (int) cubYPos - 1, cubHndl2.width + 2, cubHndl2.height + 2);
            Rectangle cubEnd = new Rectangle(cubEndHndl.x + (int) cubXPos - 1, cubEndHndl.y + (int) cubYPos - 1, cubEndHndl.width + 2, cubEndHndl.height + 2);
            if (quad.contains(e.x, e.y)) {
                quadPtMoved = true;
                mouseDown = true;
            } else if (quadEnd.contains(e.x, e.y)) {
                quadEndPtMoved = true;
                mouseDown = true;
            } else if (cub1.contains(e.x, e.y)) {
                cubPt1Moved = true;
                mouseDown = true;
            } else if (cub2.contains(e.x, e.y)) {
                cubPt2Moved = true;
                mouseDown = true;
            } else if (cubEnd.contains(e.x, e.y)) {
                cubEndPtMoved = true;
                mouseDown = true;
            }
        }

        /**
         * Sent when a mouse button is released.
         *
         * @param e an event containing information about the mouse button release
         */
        @Override
        public void mouseUp(MouseEvent e) {
            mouseDown = false;
            if (isHovering(e)) {
                example.canvas.setCursor(cursor);
            } else {
                example.canvas.setCursor(null);
            }
            if (quadPtMoved)
                quadPtMoved = false;
            if (quadEndPtMoved)
                quadEndPtMoved = false;
            if (cubPt1Moved)
                cubPt1Moved = false;
            if (cubPt2Moved)
                cubPt2Moved = false;
            if (cubEndPtMoved)
                cubEndPtMoved = false;
            example.redraw();
        }
    };
    example.canvas.addMouseMoveListener(mouseMoveListener);
    example.canvas.addMouseListener(mouseListener);
}
Also used : MouseListener(org.eclipse.swt.events.MouseListener) MouseEvent(org.eclipse.swt.events.MouseEvent) Rectangle(org.eclipse.swt.graphics.Rectangle)

Aggregations

MouseListener (org.eclipse.swt.events.MouseListener)32 MouseEvent (org.eclipse.swt.events.MouseEvent)31 KeyEvent (org.eclipse.swt.events.KeyEvent)11 KeyListener (org.eclipse.swt.events.KeyListener)9 Point (org.eclipse.swt.graphics.Point)9 GridData (org.eclipse.swt.layout.GridData)9 GridLayout (org.eclipse.swt.layout.GridLayout)7 ControlEvent (org.eclipse.swt.events.ControlEvent)6 FocusEvent (org.eclipse.swt.events.FocusEvent)6 ModifyEvent (org.eclipse.swt.events.ModifyEvent)6 ModifyListener (org.eclipse.swt.events.ModifyListener)6 SelectionEvent (org.eclipse.swt.events.SelectionEvent)6 Composite (org.eclipse.swt.widgets.Composite)6 FocusListener (org.eclipse.swt.events.FocusListener)5 MouseMoveListener (org.eclipse.swt.events.MouseMoveListener)5 PaintEvent (org.eclipse.swt.events.PaintEvent)5 PaintListener (org.eclipse.swt.events.PaintListener)5 Button (org.eclipse.swt.widgets.Button)5 VerifyEvent (org.eclipse.swt.events.VerifyEvent)4 Rectangle (org.eclipse.swt.graphics.Rectangle)4