Search in sources :

Example 46 with MouseEvent

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

the class CustomMatchConditionDialog method initCustomFilterList.

/**
	 * 初始化已保存的条件列表
	 * @param comp 父容器
	 */
private void initCustomFilterList(Composite comp) {
    customFilterList = new List(comp, SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER);
    customFilterList.setLayoutData(new GridData(GridData.FILL_BOTH));
    setListData(customFilterList, customFilters);
    customFilterList.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseDoubleClick(MouseEvent e) {
            // 调编辑的方法
            edit();
        }
    });
}
Also used : MouseEvent(org.eclipse.swt.events.MouseEvent) GridData(org.eclipse.swt.layout.GridData) MouseAdapter(org.eclipse.swt.events.MouseAdapter) ArrayList(java.util.ArrayList) List(org.eclipse.swt.widgets.List)

Example 47 with MouseEvent

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

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

the class Grid method onMouseUp.

/**
     * Mouse up handler.
     *
     * @param e event
     */
private void onMouseUp(MouseEvent e) {
    cellSelectedOnLastMouseDown = false;
    if (resizingColumn) {
        resizingColumn = false;
        // resets cursor if
        handleHoverOnColumnResizer(e.x, e.y);
        // necessary
        return;
    }
    if (resizingRow) {
        resizingRow = false;
        // resets cursor if
        handleHoverOnRowResizer(e.x, e.y);
        // necessary
        return;
    }
    if (pushingColumn) {
        pushingColumn = false;
        columnBeingPushed.getHeaderRenderer().setMouseDown(false);
        columnBeingPushed.getHeaderRenderer().setHover(false);
        redraw();
        if (pushingAndHovering) {
            columnBeingPushed.fireListeners();
        }
        setCapture(false);
        return;
    }
    if (draggingColumn) {
        handleColumnDrop();
        return;
    }
    if (cellDragSelectionOccuring || cellRowDragSelectionOccuring || cellColumnDragSelectionOccuring) {
        cellDragSelectionOccuring = false;
        cellRowDragSelectionOccuring = false;
        cellColumnDragSelectionOccuring = false;
        setCursor(null);
        if (followupCellSelectionEventOwed) {
            Event se = new Event();
            se.button = e.button;
            se.item = getItem(new Point(e.x, e.y));
            se.stateMask = e.stateMask;
            se.x = e.x;
            se.y = e.y;
            notifyListeners(SWT.Selection, se);
            followupCellSelectionEventOwed = false;
        }
    }
}
Also used : 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) Point(org.eclipse.swt.graphics.Point)

Example 49 with MouseEvent

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

the class ColumnCategoriesDialog method addListenersToListViewer.

private void addListenersToListViewer() {
    listViewer.getControl().addMouseListener(new MouseAdapter() {

        @Override
        public void mouseDoubleClick(MouseEvent e) {
            removeSelected();
        }
    });
    listViewer.getControl().addKeyListener(new KeyAdapter() {

        @Override
        public void keyPressed(KeyEvent e) {
            boolean controlMask = (e.stateMask & SWT.CONTROL) == SWT.CONTROL;
            if (controlMask && e.keyCode == SWT.ARROW_UP) {
                moveSelectedUp();
                e.doit = false;
            } else if (controlMask && e.keyCode == SWT.ARROW_DOWN) {
                moveSelectedDown();
                e.doit = false;
            }
        }

        @Override
        public void keyReleased(KeyEvent e) {
            if (e.character == ' ')
                removeSelected();
        }
    });
}
Also used : KeyEvent(org.eclipse.swt.events.KeyEvent) MouseEvent(org.eclipse.swt.events.MouseEvent) KeyAdapter(org.eclipse.swt.events.KeyAdapter) MouseAdapter(org.eclipse.swt.events.MouseAdapter)

Example 50 with MouseEvent

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

the class ColumnChooserDialog method populateDialogArea.

@Override
public void populateDialogArea(Composite parent) {
    GridDataFactory.fillDefaults().grab(true, true).applyTo(parent);
    parent.setLayout(new GridLayout(4, false));
    createLabels(parent, availableLabel, selectedLabel);
    availableTree = new Tree(parent, SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.Expand);
    GridData gridData = GridDataFactory.fillDefaults().grab(true, true).create();
    availableTree.setLayoutData(gridData);
    availableTree.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseDoubleClick(MouseEvent e) {
            addSelected();
        }
    });
    availableTree.addKeyListener(new KeyAdapter() {

        @Override
        public void keyReleased(KeyEvent e) {
            if (e.character == ' ')
                addSelected();
        }
    });
    Composite buttonComposite = new Composite(parent, SWT.NONE);
    buttonComposite.setLayout(new GridLayout(1, true));
    Button addButton = new Button(buttonComposite, SWT.PUSH);
    addButton.setImage(GUIHelper.getImage("arrow_right"));
    gridData = GridDataFactory.fillDefaults().grab(false, true).align(SWT.CENTER, SWT.CENTER).create();
    addButton.setLayoutData(gridData);
    addButton.addSelectionListener(new SelectionListener() {

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

        public void widgetSelected(SelectionEvent e) {
            addSelected();
        }
    });
    Button removeButton = new Button(buttonComposite, SWT.PUSH);
    removeButton.setImage(GUIHelper.getImage("arrow_left"));
    gridData = GridDataFactory.copyData(gridData);
    removeButton.setLayoutData(gridData);
    removeButton.addSelectionListener(new SelectionListener() {

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

        public void widgetSelected(SelectionEvent e) {
            removeSelected();
        }
    });
    selectedTree = new Tree(parent, SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.Expand);
    gridData = GridDataFactory.fillDefaults().grab(true, true).create();
    selectedTree.setLayoutData(gridData);
    selectedTree.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseDoubleClick(MouseEvent e) {
            removeSelected();
        }
    });
    selectedTree.addKeyListener(new KeyAdapter() {

        @Override
        public void keyPressed(KeyEvent e) {
            boolean controlMask = (e.stateMask & SWT.CONTROL) == SWT.CONTROL;
            if (controlMask && e.keyCode == SWT.ARROW_UP) {
                moveSelectedUp();
                e.doit = false;
            } else if (controlMask && e.keyCode == SWT.ARROW_DOWN) {
                moveSelectedDown();
                e.doit = false;
            }
        }

        @Override
        public void keyReleased(KeyEvent e) {
            if (e.character == ' ')
                removeSelected();
        }
    });
    selectedTree.addTreeListener(new TreeListener() {

        public void treeCollapsed(TreeEvent event) {
            selectedTreeCollapsed(event);
        }

        public void treeExpanded(TreeEvent event) {
            selectedTreeExpanded(event);
        }
    });
    selectedTree.addSelectionListener(new SelectionListener() {

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

        public void widgetSelected(SelectionEvent event) {
            toggleColumnGroupSelection((TreeItem) event.item);
        }
    });
    Composite upDownbuttonComposite = new Composite(parent, SWT.NONE);
    upDownbuttonComposite.setLayout(new GridLayout(1, true));
    Button upButton = new Button(upDownbuttonComposite, SWT.PUSH);
    upButton.setImage(GUIHelper.getImage("arrow_up"));
    gridData = GridDataFactory.fillDefaults().grab(false, true).align(SWT.CENTER, SWT.CENTER).create();
    upButton.setLayoutData(gridData);
    upButton.addSelectionListener(new SelectionListener() {

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

        public void widgetSelected(SelectionEvent e) {
            moveSelectedUp();
        }
    });
    Button downButton = new Button(upDownbuttonComposite, SWT.PUSH);
    downButton.setImage(GUIHelper.getImage("arrow_down"));
    gridData = GridDataFactory.copyData(gridData);
    downButton.setLayoutData(gridData);
    downButton.addSelectionListener(new SelectionListener() {

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

        public void widgetSelected(SelectionEvent e) {
            moveSelectedDown();
        }
    });
}
Also used : ISelectionTreeListener(net.sourceforge.nattable.columnChooser.ISelectionTreeListener) TreeListener(org.eclipse.swt.events.TreeListener) MouseEvent(org.eclipse.swt.events.MouseEvent) Composite(org.eclipse.swt.widgets.Composite) TreeItem(org.eclipse.swt.widgets.TreeItem) KeyAdapter(org.eclipse.swt.events.KeyAdapter) MouseAdapter(org.eclipse.swt.events.MouseAdapter) KeyEvent(org.eclipse.swt.events.KeyEvent) TreeEvent(org.eclipse.swt.events.TreeEvent) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Tree(org.eclipse.swt.widgets.Tree) SelectionListener(org.eclipse.swt.events.SelectionListener)

Aggregations

MouseEvent (org.eclipse.swt.events.MouseEvent)75 MouseAdapter (org.eclipse.swt.events.MouseAdapter)39 GridData (org.eclipse.swt.layout.GridData)30 SelectionEvent (org.eclipse.swt.events.SelectionEvent)29 MouseListener (org.eclipse.swt.events.MouseListener)25 Point (org.eclipse.swt.graphics.Point)25 KeyEvent (org.eclipse.swt.events.KeyEvent)22 Composite (org.eclipse.swt.widgets.Composite)22 GridLayout (org.eclipse.swt.layout.GridLayout)21 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)18 Button (org.eclipse.swt.widgets.Button)15 FocusEvent (org.eclipse.swt.events.FocusEvent)14 PaintEvent (org.eclipse.swt.events.PaintEvent)12 Text (org.eclipse.swt.widgets.Text)12 KeyListener (org.eclipse.swt.events.KeyListener)11 ModifyEvent (org.eclipse.swt.events.ModifyEvent)11 ModifyListener (org.eclipse.swt.events.ModifyListener)11 TraverseEvent (org.eclipse.swt.events.TraverseEvent)11 Event (org.eclipse.swt.widgets.Event)11 Label (org.eclipse.swt.widgets.Label)11