Search in sources :

Example 1 with MouseTrackListener

use of org.eclipse.swt.events.MouseTrackListener in project tdi-studio-se by Talend.

the class ReviewComponentDialog method createRatingComp.

private void createRatingComp(Composite parent) {
    initImages();
    final Composite rateBtnComp = new Composite(parent, SWT.NONE);
    final GridLayout rateLayout = new GridLayout();
    rateLayout.numColumns = 5;
    rateBtnComp.setLayout(rateLayout);
    rateBtnComp.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    for (int i = 0; i < 5; i++) {
        final Button rateButton = new Button(rateBtnComp, SWT.NONE);
        rateButton.setLayoutData(new GridData(30, SWT.DEFAULT));
        rateButton.setImage(imageMap.get(1));
        rateButton.setData(0);
        rateBtnMap.put(i, rateButton);
        rateButton.addMouseTrackListener(new MouseTrackListener() {

            public void mouseHover(MouseEvent e) {
                handleMouseHover(rateButton);
            }

            public void mouseExit(MouseEvent e) {
                handleMouseExit(rateButton);
            }

            public void mouseEnter(MouseEvent e) {
            }
        });
        rateButton.addMouseListener(new MouseListener() {

            public void mouseUp(MouseEvent e) {
            }

            public void mouseDown(MouseEvent e) {
                handleMouseDown(rateButton);
                checkInput();
            }

            public void mouseDoubleClick(MouseEvent e) {
            }
        });
    }
    rateLabel = new Label(parent, SWT.NONE);
    rateLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    rateLabel.setText("Please select your rating*");
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) MouseEvent(org.eclipse.swt.events.MouseEvent) MouseListener(org.eclipse.swt.events.MouseListener) Composite(org.eclipse.swt.widgets.Composite) Button(org.eclipse.swt.widgets.Button) MouseTrackListener(org.eclipse.swt.events.MouseTrackListener) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label) Point(org.eclipse.swt.graphics.Point)

Example 2 with MouseTrackListener

use of org.eclipse.swt.events.MouseTrackListener in project tdi-studio-se by Talend.

the class DataMapTableView method addListeners.

/**
     * DOC amaumont Comment method "addListeners".
     */
protected void addListeners() {
    final UIManager uiManager = mapperManager.getUiManager();
    MouseTrackListener mouseTracker = new MouseTrackListener() {

        @Override
        public void mouseEnter(MouseEvent e) {
        }

        @Override
        public void mouseExit(MouseEvent e) {
            setDefaultCursor();
            resizeHelper.stopDrag();
        }

        @Override
        public void mouseHover(MouseEvent e) {
        }
    };
    this.addMouseTrackListener(mouseTracker);
    SelectionListener scrollListener = new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent event) {
            uiManager.refreshBackground(true, false);
        }
    };
    tableForEntries.getVerticalBar().addSelectionListener(scrollListener);
    // /////////////////////////////////////////////////////////////////
    addManualTableResizeListeners(uiManager);
    // /////////////////////////////////////////////////////////////////
    // /////////////////////////////////////////////////////////////////
    Listener onSelectDataMapTableViewListener = new Listener() {

        @Override
        public void handleEvent(Event event) {
            switch(event.type) {
                case SWT.MouseDown:
                    onSelectDataMapTableView();
                    break;
                default:
            }
        }
    };
    this.addListener(SWT.MouseDown, onSelectDataMapTableViewListener);
    headerComposite.addListener(SWT.MouseDown, onSelectDataMapTableViewListener);
    nameLabel.addListener(SWT.MouseDown, onSelectDataMapTableViewListener);
    // /////////////////////////////////////////////////////////////////
    // /////////////////////////////////////////////////////////////////
    minimizeButton.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
        // TODO Auto-generated method stub
        }

        @Override
        public void widgetSelected(SelectionEvent e) {
            minimizeTable(!abstractDataMapTable.isMinimized());
        }
    });
    // /////////////////////////////////////////////////////////////////
    initShowMessageErrorListener(tableForEntries);
}
Also used : MouseEvent(org.eclipse.swt.events.MouseEvent) SelectionListener(org.eclipse.swt.events.SelectionListener) ControlListener(org.eclipse.swt.events.ControlListener) Listener(org.eclipse.swt.widgets.Listener) ModifyListener(org.eclipse.swt.events.ModifyListener) DisposeListener(org.eclipse.swt.events.DisposeListener) ITableCellValueModifiedListener(org.talend.commons.ui.runtime.swt.tableviewer.behavior.ITableCellValueModifiedListener) IModifiedBeanListener(org.talend.commons.ui.swt.tableviewer.IModifiedBeanListener) ICellEditorListener(org.eclipse.jface.viewers.ICellEditorListener) MouseListener(org.eclipse.swt.events.MouseListener) MouseTrackListener(org.eclipse.swt.events.MouseTrackListener) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) IListenableListListener(org.talend.commons.utils.data.list.IListenableListListener) FocusListener(org.eclipse.swt.events.FocusListener) ILineSelectionListener(org.talend.commons.ui.runtime.swt.tableviewer.selection.ILineSelectionListener) KeyListener(org.eclipse.swt.events.KeyListener) MouseTrackListener(org.eclipse.swt.events.MouseTrackListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) LineSelectionEvent(org.talend.commons.ui.runtime.swt.tableviewer.selection.LineSelectionEvent) UIManager(org.talend.designer.dbmap.managers.UIManager) FocusEvent(org.eclipse.swt.events.FocusEvent) KeyEvent(org.eclipse.swt.events.KeyEvent) MouseEvent(org.eclipse.swt.events.MouseEvent) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) ControlEvent(org.eclipse.swt.events.ControlEvent) ModifiedBeanEvent(org.talend.commons.ui.swt.tableviewer.ModifiedBeanEvent) DisposeEvent(org.eclipse.swt.events.DisposeEvent) ModifyEvent(org.eclipse.swt.events.ModifyEvent) ListenableListEvent(org.talend.commons.utils.data.list.ListenableListEvent) TableCellValueModifiedEvent(org.talend.commons.ui.runtime.swt.tableviewer.behavior.TableCellValueModifiedEvent) Event(org.eclipse.swt.widgets.Event) SelectionEvent(org.eclipse.swt.events.SelectionEvent) LineSelectionEvent(org.talend.commons.ui.runtime.swt.tableviewer.selection.LineSelectionEvent) SelectionListener(org.eclipse.swt.events.SelectionListener) ILineSelectionListener(org.talend.commons.ui.runtime.swt.tableviewer.selection.ILineSelectionListener)

Example 3 with MouseTrackListener

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

the class InformationWindow method createContents.

protected Control createContents(Composite parent) {
    final Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayout(new FillLayout());
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));
    infoText = new StyledText(composite, SWT.None);
    infoText.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
    infoText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_INFO_FOREGROUND));
    infoText.setEditable(false);
    infoText.setEnabled(false);
    infoText.addMouseTrackListener(new MouseTrackListener() {

        public void mouseHover(MouseEvent e) {
            increaseAlpha();
        }

        public void mouseExit(MouseEvent e) {
            reduceAlpha();
        }

        public void mouseEnter(MouseEvent e) {
            increaseAlpha();
        }
    });
    parentShell.addControlListener(new ControlListener() {

        public void controlResized(ControlEvent e) {
            updateLocation();
        }

        public void controlMoved(ControlEvent e) {
            updateLocation();
        }
    });
    if (Platform.getOS().equals(Platform.OS_WIN32)) {
        parentShell.addPaintListener(new PaintListener() {

            public void paintControl(PaintEvent e) {
                updateLocation();
            }
        });
    }
    this.getShell().setAlpha(minAlpha);
    updateLocation();
    return parent;
}
Also used : StyledText(org.eclipse.swt.custom.StyledText) MouseEvent(org.eclipse.swt.events.MouseEvent) PaintEvent(org.eclipse.swt.events.PaintEvent) CombinedQueryEditorComposite(com.cubrid.common.ui.query.control.CombinedQueryEditorComposite) Composite(org.eclipse.swt.widgets.Composite) PaintListener(org.eclipse.swt.events.PaintListener) MouseTrackListener(org.eclipse.swt.events.MouseTrackListener) GridData(org.eclipse.swt.layout.GridData) ControlListener(org.eclipse.swt.events.ControlListener) FillLayout(org.eclipse.swt.layout.FillLayout) ControlEvent(org.eclipse.swt.events.ControlEvent)

Example 4 with MouseTrackListener

use of org.eclipse.swt.events.MouseTrackListener in project translationstudio8 by heartsome.

the class Grid method initListeners.

/**
     * Initialize all listeners.
     */
private void initListeners() {
    disposeListener = new Listener() {

        public void handleEvent(Event e) {
            onDispose(e);
        }
    };
    addListener(SWT.Dispose, disposeListener);
    addPaintListener(new PaintListener() {

        public void paintControl(PaintEvent e) {
            onPaint(e);
        }
    });
    addListener(SWT.Resize, new Listener() {

        public void handleEvent(Event e) {
            onResize();
        }
    });
    if (getVerticalBar() != null) {
        getVerticalBar().addListener(SWT.Selection, new Listener() {

            public void handleEvent(Event e) {
                onScrollSelection();
            }
        });
    }
    if (getHorizontalBar() != null) {
        getHorizontalBar().addListener(SWT.Selection, new Listener() {

            public void handleEvent(Event e) {
                onScrollSelection();
            }
        });
    }
    addListener(SWT.KeyDown, new Listener() {

        public void handleEvent(Event e) {
            onKeyDown(e);
        }
    });
    addTraverseListener(new TraverseListener() {

        public void keyTraversed(TraverseEvent e) {
            e.doit = true;
        }
    });
    addMouseListener(new MouseListener() {

        public void mouseDoubleClick(MouseEvent e) {
            onMouseDoubleClick(e);
        }

        public void mouseDown(MouseEvent e) {
            onMouseDown(e);
        }

        public void mouseUp(MouseEvent e) {
            onMouseUp(e);
        }
    });
    addMouseMoveListener(new MouseMoveListener() {

        public void mouseMove(MouseEvent e) {
            onMouseMove(e);
        }
    });
    addMouseTrackListener(new MouseTrackListener() {

        public void mouseEnter(MouseEvent e) {
        }

        public void mouseExit(MouseEvent e) {
            onMouseExit(e);
        }

        public void mouseHover(MouseEvent e) {
        }
    });
    addFocusListener(new FocusListener() {

        public void focusGained(FocusEvent e) {
            onFocusIn();
            redraw();
        }

        public void focusLost(FocusEvent e) {
            redraw();
        }
    });
    // Special code to reflect mouse wheel events if using an external
    // scroller
    addListener(SWT.MouseWheel, new Listener() {

        public void handleEvent(Event e) {
            onMouseWheel(e);
        }
    });
}
Also used : MouseMoveListener(org.eclipse.swt.events.MouseMoveListener) MouseMoveListener(org.eclipse.swt.events.MouseMoveListener) TraverseListener(org.eclipse.swt.events.TraverseListener) MouseListener(org.eclipse.swt.events.MouseListener) MouseTrackListener(org.eclipse.swt.events.MouseTrackListener) SelectionListener(org.eclipse.swt.events.SelectionListener) PaintListener(org.eclipse.swt.events.PaintListener) FocusListener(org.eclipse.swt.events.FocusListener) TypedListener(org.eclipse.swt.widgets.TypedListener) Listener(org.eclipse.swt.widgets.Listener) DropTargetListener(org.eclipse.swt.dnd.DropTargetListener) TreeListener(org.eclipse.swt.events.TreeListener) PaintEvent(org.eclipse.swt.events.PaintEvent) TraverseEvent(org.eclipse.swt.events.TraverseEvent) MouseListener(org.eclipse.swt.events.MouseListener) MouseEvent(org.eclipse.swt.events.MouseEvent) PaintListener(org.eclipse.swt.events.PaintListener) TraverseListener(org.eclipse.swt.events.TraverseListener) MouseTrackListener(org.eclipse.swt.events.MouseTrackListener) FocusEvent(org.eclipse.swt.events.FocusEvent) DropTargetEvent(org.eclipse.swt.dnd.DropTargetEvent) PaintEvent(org.eclipse.swt.events.PaintEvent) TraverseEvent(org.eclipse.swt.events.TraverseEvent) MouseEvent(org.eclipse.swt.events.MouseEvent) AccessibleEvent(org.eclipse.swt.accessibility.AccessibleEvent) Event(org.eclipse.swt.widgets.Event) AccessibleControlEvent(org.eclipse.swt.accessibility.AccessibleControlEvent) TreeEvent(org.eclipse.swt.events.TreeEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) FocusListener(org.eclipse.swt.events.FocusListener) FocusEvent(org.eclipse.swt.events.FocusEvent)

Example 5 with MouseTrackListener

use of org.eclipse.swt.events.MouseTrackListener in project translationstudio8 by heartsome.

the class XLFEditor method hookListener.

/**
	 * 初始化监听器。
	 */
private void hookListener() {
    // 添加文本修改监听器,用于调整文本框大小,使其高度自适应文本内容。
    textModifyListener = new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            StyledText st = (StyledText) e.widget;
            GridData gd = (GridData) st.getLayoutData();
            if (gd == null) {
                gd = new GridData(GridData.FILL_BOTH);
            }
            Point computeSize = st.computeSize(st.getSize().x, SWT.DEFAULT, false);
            // 此行代码是为了保持列宽不变。减 10 是因为 computeSize 后宽度每次会增加 5 个像素,
            // 因此需要减去上次和本次增加的共10像素。为什么会这样原因不明。
            gd.widthHint = computeSize.x - 10;
            st.setLayoutData(gd);
            editorContentComposite.layout();
            oScrolledComposite.setMinSize(editorContentComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
        }
    };
    // 添加鼠标跟踪监听器,用于监听鼠标位置,根据编辑器模式切换光标样式。
    mouseTrackListener = new MouseTrackListener() {

        private void setArrowCursor(MouseEvent arg0) {
            Widget srcWidget = arg0.widget;
            if (isEditModel && srcWidget instanceof StyledText) {
                ((StyledText) srcWidget).setCursor(cursorIbeam);
            } else {
                ((StyledText) srcWidget).setCursor(cursorArrow);
            }
        }

        public void mouseEnter(MouseEvent arg0) {
            setArrowCursor(arg0);
        }

        public void mouseExit(MouseEvent arg0) {
            setArrowCursor(arg0);
        }

        public void mouseHover(MouseEvent arg0) {
            setArrowCursor(arg0);
        }
    };
    mouseListener = new MouseListener() {

        public void mouseDoubleClick(MouseEvent arg0) {
            // 切换为编辑模式
            isEditModel = true;
            System.out.println("It's running edit model.");
            Control ctrl = arg0.display.getCursorControl();
            ctrl.setCursor(cursorIbeam);
        }

        public void mouseDown(MouseEvent arg0) {
            int inx = (Integer) arg0.widget.getData(DATAKEY_INDEX);
            setSelectionRowColor(inx);
            // 选中模式下要隐藏光标。
            if (!isEditModel) {
                // 通过为容器组件设置焦点,实现在选中模式时隐藏文本框组件中闪烁的光标
                txtComposites[inx].forceFocus();
            }
        }

        public void mouseUp(MouseEvent arg0) {
        }
    };
    keyListener = new KeyListener() {

        public void keyPressed(KeyEvent arg0) {
            // 按 Esc 键切换到选择模式。
            if (arg0.keyCode == SWT.ESC) {
                isEditModel = false;
                Control ctrl = arg0.display.getCursorControl();
                ctrl.setCursor(cursorArrow);
            }
        }

        public void keyReleased(KeyEvent arg0) {
        }
    };
}
Also used : KeyEvent(org.eclipse.swt.events.KeyEvent) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Control(org.eclipse.swt.widgets.Control) StyledText(org.eclipse.swt.custom.StyledText) MouseEvent(org.eclipse.swt.events.MouseEvent) MouseListener(org.eclipse.swt.events.MouseListener) ModifyListener(org.eclipse.swt.events.ModifyListener) MouseTrackListener(org.eclipse.swt.events.MouseTrackListener) GridData(org.eclipse.swt.layout.GridData) Widget(org.eclipse.swt.widgets.Widget) KeyListener(org.eclipse.swt.events.KeyListener) Point(org.eclipse.swt.graphics.Point)

Aggregations

MouseEvent (org.eclipse.swt.events.MouseEvent)5 MouseTrackListener (org.eclipse.swt.events.MouseTrackListener)5 MouseListener (org.eclipse.swt.events.MouseListener)4 GridData (org.eclipse.swt.layout.GridData)3 StyledText (org.eclipse.swt.custom.StyledText)2 ControlEvent (org.eclipse.swt.events.ControlEvent)2 ControlListener (org.eclipse.swt.events.ControlListener)2 FocusEvent (org.eclipse.swt.events.FocusEvent)2 FocusListener (org.eclipse.swt.events.FocusListener)2 KeyEvent (org.eclipse.swt.events.KeyEvent)2 KeyListener (org.eclipse.swt.events.KeyListener)2 ModifyEvent (org.eclipse.swt.events.ModifyEvent)2 ModifyListener (org.eclipse.swt.events.ModifyListener)2 PaintEvent (org.eclipse.swt.events.PaintEvent)2 PaintListener (org.eclipse.swt.events.PaintListener)2 SelectionEvent (org.eclipse.swt.events.SelectionEvent)2 SelectionListener (org.eclipse.swt.events.SelectionListener)2 Point (org.eclipse.swt.graphics.Point)2 Composite (org.eclipse.swt.widgets.Composite)2 Event (org.eclipse.swt.widgets.Event)2