Search in sources :

Example 61 with MouseEvent

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

the class ComboBoxCellEditor method activateCell.

@Override
protected Control activateCell(Composite parent, Object originalCanonicalValue, Character initialEditValue) {
    this.originalCanonicalValue = originalCanonicalValue;
    combo = new NatCombo(parent, getCellStyle(), maxVisibleItems);
    combo.setItems(getDisplayValues());
    if (originalCanonicalValue != null) {
        combo.setSelection(new String[] { getDisplayValue() });
    }
    combo.addKeyListener(new KeyAdapter() {

        @Override
        public void keyPressed(KeyEvent event) {
            if ((event.keyCode == SWT.CR && event.stateMask == 0) || (event.keyCode == SWT.KEYPAD_CR && event.stateMask == 0)) {
                commit(MoveDirectionEnum.NONE);
            } else if (event.keyCode == SWT.ESC && event.stateMask == 0) {
                close();
            }
        }
    });
    combo.addTraverseListener(new TraverseListener() {

        public void keyTraversed(TraverseEvent event) {
            if (event.keyCode == SWT.TAB && event.stateMask == SWT.SHIFT) {
                commit(MoveDirectionEnum.LEFT);
            } else if (event.keyCode == SWT.TAB && event.stateMask == 0) {
                commit(MoveDirectionEnum.RIGHT);
            }
        }
    });
    combo.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseDown(MouseEvent e) {
            commit(MoveDirectionEnum.NONE);
        }
    });
    return combo;
}
Also used : KeyEvent(org.eclipse.swt.events.KeyEvent) NatCombo(net.sourceforge.nattable.widget.NatCombo) TraverseEvent(org.eclipse.swt.events.TraverseEvent) MouseEvent(org.eclipse.swt.events.MouseEvent) TraverseListener(org.eclipse.swt.events.TraverseListener) KeyAdapter(org.eclipse.swt.events.KeyAdapter) MouseAdapter(org.eclipse.swt.events.MouseAdapter)

Example 62 with MouseEvent

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

the class QAResultViewPart method createTable.

public void createTable() {
    table = new KTable(parent, SWT.FULL_SELECTION | SWT.V_SCROLL | SWT.H_SCROLL | SWTX.FILL_WITH_LASTCOL | SWT.WRAP);
    tableModel = new KtableModel();
    table.setModel(tableModel);
    table.setLayoutData(new GridData(GridData.FILL_BOTH));
    table.setColorRightBorder(Display.getCurrent().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
    table.setColorLeftBorder(Display.getCurrent().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
    table.setColorTopBorder(Display.getCurrent().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
    table.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
    table.addMouseListener(new MouseAdapter() {

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

        public void keyPressed(KeyEvent e) {
            if (e.keyCode == QAConstant.QA_CENTERKEY_1 || e.keyCode == QAConstant.QA_CENTERKEY_2) {
                locationRow();
            }
        }
    });
    table.addCellResizeListener(new KTableCellResizeListener() {

        public void rowResized(int arg0, int arg1) {
            tableModel.textRenderer.clearRowHeiMap();
            table.redraw();
        }

        public void columnResized(int arg0, int arg1) {
            tableModel.textRenderer.clearRowHeiMap();
            table.redraw();
        }
    });
    table.addControlListener(new ControlAdapter() {

        @Override
        public void controlResized(ControlEvent e) {
            tableModel.textRenderer.clearRowHeiMap();
            table.redraw();
        }
    });
    table.addMouseWheelListener(new MouseWheelListener() {

        public void mouseScrolled(MouseEvent e) {
            tableModel.textRenderer.clearRowHeiMap();
            table.redraw();
        }
    });
    createPropMenu();
}
Also used : MouseEvent(org.eclipse.swt.events.MouseEvent) KTableCellResizeListener(de.kupzog.ktable.KTableCellResizeListener) ControlAdapter(org.eclipse.swt.events.ControlAdapter) KeyAdapter(org.eclipse.swt.events.KeyAdapter) MouseAdapter(org.eclipse.swt.events.MouseAdapter) MouseWheelListener(org.eclipse.swt.events.MouseWheelListener) KTable(de.kupzog.ktable.KTable) Point(org.eclipse.swt.graphics.Point) KeyEvent(org.eclipse.swt.events.KeyEvent) GridData(org.eclipse.swt.layout.GridData) ControlEvent(org.eclipse.swt.events.ControlEvent)

Example 63 with MouseEvent

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

the class CustomFilterDialog method initCustomFilterList.

/**
	 * 初始化自定义过滤器列表
	 * @param comp
	 *            父容器
	 */
private void initCustomFilterList(Composite comp) {
    customFilterList = new List(comp, SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER);
    GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
    gridData.widthHint = 110;
    gridData.heightHint = 250;
    customFilterList.setLayoutData(gridData);
    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 64 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 65 with MouseEvent

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

the class ProductInfoDialog method addListeners.

/**
	 * Adds listeners to the given styled text
	 * 
	 * @param styledText the StyledText object
	 */
protected void addListeners(StyledText styledText) {
    styledText.addMouseListener(new MouseAdapter() {

        public void mouseDown(MouseEvent event) {
            if (event.button != 1) {
                return;
            }
            mouseDown = true;
        }

        public void mouseUp(MouseEvent event) {
            mouseDown = false;
            StyledText text = (StyledText) event.widget;
            int offset = text.getCaretOffset();
            if (dragEvent) {
                // don't activate a link during a drag/mouse up operation
                dragEvent = false;
                if (item != null && item.isLinkAt(offset)) {
                    text.setCursor(handCursor);
                }
            } else if (item != null && item.isLinkAt(offset)) {
                text.setCursor(busyCursor);
                String url = item.getLinkAt(offset);
                if (StringUtil.isEmpty(url)) {
                    LOGGER.warn("The url is a null or empty string : {}.", url);
                } else {
                    openLink(url);
                }
                StyleRange selectionRange = getCurrentRange(text);
                if (selectionRange == null) {
                    LOGGER.warn("The selectionRange is a null.");
                } else {
                    text.setSelectionRange(selectionRange.start, selectionRange.length);
                    text.setCursor(null);
                }
            }
        }
    });
    styledText.addMouseMoveListener(new MouseMoveListener() {

        public void mouseMove(MouseEvent event) {
            if (mouseDown) {
                if (!dragEvent) {
                    StyledText text = (StyledText) event.widget;
                    text.setCursor(null);
                }
                dragEvent = true;
                return;
            }
            StyledText text = (StyledText) event.widget;
            int offset = -1;
            try {
                offset = text.getOffsetAtLocation(new Point(event.x, event.y));
            } catch (IllegalArgumentException ex) {
                offset = -1;
            }
            if (offset == -1) {
                text.setCursor(null);
            } else if (item != null && item.isLinkAt(offset)) {
                text.setCursor(handCursor);
            } else {
                text.setCursor(null);
            }
        }
    });
    styledText.addTraverseListener(new TraverseListener() {

        public void keyTraversed(TraverseEvent event) {
            StyledText text = (StyledText) event.widget;
            switch(event.detail) {
                case SWT.TRAVERSE_ESCAPE:
                    event.doit = true;
                    break;
                case SWT.TRAVERSE_TAB_NEXT:
                    // Previously traverse out in the backward direction?
                    Point nextSelection = text.getSelection();
                    int charCount = text.getCharCount();
                    if ((nextSelection.x == charCount) && (nextSelection.y == charCount)) {
                        text.setSelection(0);
                    }
                    StyleRange nextRange = findNextRange(text);
                    if (nextRange == null) {
                        // Next time in start at beginning, also used by
                        // TRAVERSE_TAB_PREVIOUS to indicate we traversed out
                        // in the forward direction
                        text.setSelection(0);
                        event.doit = true;
                    } else {
                        text.setSelectionRange(nextRange.start, nextRange.length);
                        event.doit = true;
                        event.detail = SWT.TRAVERSE_NONE;
                    }
                    break;
                case SWT.TRAVERSE_TAB_PREVIOUS:
                    // Previously traverse out in the forward direction?
                    Point previousSelection = text.getSelection();
                    if ((previousSelection.x == 0) && (previousSelection.y == 0)) {
                        text.setSelection(text.getCharCount());
                    }
                    StyleRange previousRange = findPreviousRange(text);
                    if (previousRange == null) {
                        // Next time in start at the end, also used by
                        // TRAVERSE_TAB_NEXT to indicate we traversed out
                        // in the backward direction
                        text.setSelection(text.getCharCount());
                        event.doit = true;
                    } else {
                        text.setSelectionRange(previousRange.start, previousRange.length);
                        event.doit = true;
                        event.detail = SWT.TRAVERSE_NONE;
                    }
                    break;
                default:
                    break;
            }
        }
    });
    // Listen for Tab and Space to allow keyboard navigation
    styledText.addKeyListener(new KeyAdapter() {

        public void keyPressed(KeyEvent event) {
            StyledText text = (StyledText) event.widget;
            if (event.character == ' ' || event.keyCode == SWT.CR || event.keyCode == SWT.KEYPAD_CR) {
                if (item == null) {
                    LOGGER.warn("AboutItem is a null.");
                    return;
                }
                // Be sure we are in the selection
                int offset = text.getSelection().x + 1;
                if (item.isLinkAt(offset)) {
                    text.setCursor(busyCursor);
                    String url = item.getLinkAt(offset);
                    if (StringUtil.isEmpty(url)) {
                        LOGGER.warn("The url is a null or empty string : {}.", url);
                    } else {
                        openLink(url);
                    }
                    StyleRange selectionRange = getCurrentRange(text);
                    if (selectionRange == null) {
                        LOGGER.warn("The selectionRange is a null.");
                    } else {
                        text.setSelectionRange(selectionRange.start, selectionRange.length);
                        text.setCursor(null);
                    }
                }
            }
        }
    });
}
Also used : KeyEvent(org.eclipse.swt.events.KeyEvent) MouseMoveListener(org.eclipse.swt.events.MouseMoveListener) MouseEvent(org.eclipse.swt.events.MouseEvent) StyledText(org.eclipse.swt.custom.StyledText) TraverseEvent(org.eclipse.swt.events.TraverseEvent) TraverseListener(org.eclipse.swt.events.TraverseListener) StyleRange(org.eclipse.swt.custom.StyleRange) KeyAdapter(org.eclipse.swt.events.KeyAdapter) MouseAdapter(org.eclipse.swt.events.MouseAdapter) Point(org.eclipse.swt.graphics.Point)

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