Search in sources :

Example 21 with MouseAdapter

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

the class CheckBoxCellEditor method activateCell.

/**
	 * As soon as the editor is activated, flip the current data value and commit it.<br/>
	 * The repaint will pick up the new value and flip the image.
	 */
@Override
protected Control activateCell(Composite parent, Object originalCanonicalValue, Character initialEditValue) {
    setCanonicalValue(originalCanonicalValue);
    checked = !checked;
    canvas = new Canvas(parent, SWT.NONE);
    canvas.addPaintListener(new PaintListener() {

        public void paintControl(PaintEvent paintEvent) {
            Rectangle bounds = canvas.getBounds();
            Rectangle rect = new Rectangle(0, 0, bounds.width, bounds.height);
            checkBoxCellPainter.paintIconImage(paintEvent.gc, rect, bounds.height / 2 - checkBoxCellPainter.getPreferredHeight(checked) / 2, checked);
        }
    });
    canvas.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseUp(MouseEvent e) {
            checked = !checked;
            canvas.redraw();
        }
    });
    commit(MoveDirectionEnum.NONE, false);
    return canvas;
}
Also used : PaintEvent(org.eclipse.swt.events.PaintEvent) MouseEvent(org.eclipse.swt.events.MouseEvent) PaintListener(org.eclipse.swt.events.PaintListener) Canvas(org.eclipse.swt.widgets.Canvas) Rectangle(org.eclipse.swt.graphics.Rectangle) MouseAdapter(org.eclipse.swt.events.MouseAdapter)

Example 22 with MouseAdapter

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

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

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

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

Aggregations

MouseAdapter (org.eclipse.swt.events.MouseAdapter)39 MouseEvent (org.eclipse.swt.events.MouseEvent)39 GridData (org.eclipse.swt.layout.GridData)20 SelectionEvent (org.eclipse.swt.events.SelectionEvent)17 Composite (org.eclipse.swt.widgets.Composite)15 GridLayout (org.eclipse.swt.layout.GridLayout)13 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)12 KeyEvent (org.eclipse.swt.events.KeyEvent)11 Button (org.eclipse.swt.widgets.Button)11 Point (org.eclipse.swt.graphics.Point)10 Text (org.eclipse.swt.widgets.Text)9 KeyAdapter (org.eclipse.swt.events.KeyAdapter)8 StyledText (org.eclipse.swt.custom.StyledText)6 SelectionListener (org.eclipse.swt.events.SelectionListener)6 Label (org.eclipse.swt.widgets.Label)6 TraverseEvent (org.eclipse.swt.events.TraverseEvent)5 TraverseListener (org.eclipse.swt.events.TraverseListener)5 ArrayList (java.util.ArrayList)4 Table (org.eclipse.swt.widgets.Table)4 Tree (org.eclipse.swt.widgets.Tree)4