Search in sources :

Example 61 with FocusEvent

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

the class DataTypeCellEditor method createControl.

protected Control createControl(Composite parent) {
    comboBox = new DataTypeCombo(parent, getStyle());
    comboBox.setFont(parent.getFont());
    populateComboBoxItems();
    //		comboBox.addKeyListener(new KeyAdapter() {
    //			public void keyPressed(KeyEvent event) {
    //				if (event.character == '\r') {
    //					applyEditorValueAndDeactivate();
    //				}
    //				keyReleaseOccured(event);
    //			}
    //
    //			public void keyReleased(KeyEvent event) {
    //			}
    //		});
    comboBox.addModifyListener(getModifyListener());
    comboBox.addSelectionListener(new SelectionAdapter() {

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

        public void widgetSelected(SelectionEvent event) {
            value = comboBox.getText();
        }
    });
    comboBox.addTraverseListener(new TraverseListener() {

        public void keyTraversed(TraverseEvent event) {
            if (event.detail == SWT.TRAVERSE_ESCAPE || event.detail == SWT.TRAVERSE_RETURN) {
                event.doit = false;
            }
        }
    });
    comboBox.addFocusListener(new FocusAdapter() {

        public void focusLost(FocusEvent event) {
            applyEditorValueAndDeactivate();
            DataTypeCellEditor.this.focusLost();
        }
    });
    return comboBox;
}
Also used : FocusAdapter(org.eclipse.swt.events.FocusAdapter) TraverseEvent(org.eclipse.swt.events.TraverseEvent) TraverseListener(org.eclipse.swt.events.TraverseListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) FocusEvent(org.eclipse.swt.events.FocusEvent)

Example 62 with FocusEvent

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

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

the class RenameResourceAndCloseEditorAction method createTextEditor.

/**
	 * Create the text editor widget.
	 * 
	 * @param resource
	 *            the resource to rename
	 */
private void createTextEditor(final IResource resource) {
    // Create text editor parent. This draws a nice bounding rect.
    textEditorParent = createParent();
    textEditorParent.setVisible(false);
    final int inset = getCellEditorInset(textEditorParent);
    if (inset > 0) {
        textEditorParent.addListener(SWT.Paint, new Listener() {

            public void handleEvent(Event e) {
                Point textSize = textEditor.getSize();
                Point parentSize = textEditorParent.getSize();
                e.gc.drawRectangle(0, 0, Math.min(textSize.x + 4, parentSize.x - 1), parentSize.y - 1);
            }
        });
    }
    // Create inner text editor.
    textEditor = new Text(textEditorParent, SWT.NONE);
    textEditor.setFont(navigatorTree.getFont());
    textEditorParent.setBackground(textEditor.getBackground());
    textEditor.addListener(SWT.Modify, new Listener() {

        public void handleEvent(Event e) {
            Point textSize = textEditor.computeSize(SWT.DEFAULT, SWT.DEFAULT);
            // Add extra space for new
            textSize.x += textSize.y;
            // characters.
            Point parentSize = textEditorParent.getSize();
            textEditor.setBounds(2, inset, Math.min(textSize.x, parentSize.x - 4), parentSize.y - 2 * inset);
            textEditorParent.redraw();
        }
    });
    textEditor.addListener(SWT.Traverse, new Listener() {

        public void handleEvent(Event event) {
            // traverse events
            switch(event.detail) {
                case SWT.TRAVERSE_ESCAPE:
                    // Do nothing in this case
                    disposeTextWidget();
                    event.doit = true;
                    event.detail = SWT.TRAVERSE_NONE;
                    break;
                case SWT.TRAVERSE_RETURN:
                    saveChangesAndDispose(resource);
                    event.doit = true;
                    event.detail = SWT.TRAVERSE_NONE;
                    break;
            }
        }
    });
    textEditor.addFocusListener(new FocusAdapter() {

        public void focusLost(FocusEvent fe) {
            saveChangesAndDispose(resource);
            closeRelatedEditors();
        }
    });
    if (textActionHandler != null) {
        textActionHandler.addText(textEditor);
    }
}
Also used : FocusAdapter(org.eclipse.swt.events.FocusAdapter) Listener(org.eclipse.swt.widgets.Listener) FocusEvent(org.eclipse.swt.events.FocusEvent) Event(org.eclipse.swt.widgets.Event) Text(org.eclipse.swt.widgets.Text) Point(org.eclipse.swt.graphics.Point) FocusEvent(org.eclipse.swt.events.FocusEvent) Point(org.eclipse.swt.graphics.Point)

Example 64 with FocusEvent

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

the class QAPage method addTgtLengthGroup.

/**
	 * 添加目标文本段长度限制检查
	 * @param tParent
	 */
private void addTgtLengthGroup(Composite tParent) {
    Group group = new Group(tParent, SWT.NONE);
    group.setText(Messages.getString("preference.QAPage.group"));
    group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    group.setLayout(new GridLayout());
    HsImageLabel tgtLengthSetLbl = new HsImageLabel(Messages.getString("preference.QAPage.tgtLengthSetLbl"), Activator.getImageDescriptor(ImageConstant.PREFERENCE_QA_Page_tgtLengthSet));
    Composite tgtLengthLblCmp = tgtLengthSetLbl.createControl(group);
    tgtLengthLblCmp.setLayout(new GridLayout(3, false));
    tgtLengthLblCmp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    Composite tgtLengthSetCmp = new Composite(tgtLengthLblCmp, SWT.NONE);
    GridLayoutFactory.fillDefaults().extendedMargins(0, 0, 0, 0).equalWidth(false).numColumns(3).applyTo(tgtLengthSetCmp);
    GridDataFactory.fillDefaults().span(3, SWT.DEFAULT).grab(true, true).applyTo(tgtLengthSetCmp);
    GridData txtData = new GridData(SWT.LEFT, SWT.CENTER, false, false);
    txtData.widthHint = 200;
    minBtn = new Button(tgtLengthSetCmp, SWT.CHECK);
    minBtn.setText(Messages.getString("preference.QAPage.minBtn"));
    minTxt = new Text(tgtLengthSetCmp, SWT.BORDER);
    minTxt.setLayoutData(txtData);
    Label label = new Label(tgtLengthSetCmp, SWT.NONE);
    label.setText("%");
    maxBtn = new Button(tgtLengthSetCmp, SWT.CHECK);
    maxBtn.setText(Messages.getString("preference.QAPage.maxBtn"));
    maxTxt = new Text(tgtLengthSetCmp, SWT.BORDER);
    maxTxt.setLayoutData(txtData);
    label = new Label(tgtLengthSetCmp, SWT.NONE);
    label.setText("%");
    tgtLengthSetLbl.computeSize();
    minTxt.addFocusListener(new FocusAdapter() {

        @Override
        public void focusLost(FocusEvent e) {
            validMinValue(isNumericRegex);
        }
    });
    maxTxt.addFocusListener(new FocusAdapter() {

        @Override
        public void focusLost(FocusEvent e) {
            validMaxValue(isNumericRegex);
        }
    });
    minBtn.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            validMinValue(isNumericRegex);
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            validMinValue(isNumericRegex);
        }
    });
    maxBtn.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            validMaxValue(isNumericRegex);
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            validMaxValue(isNumericRegex);
        }
    });
}
Also used : Group(org.eclipse.swt.widgets.Group) FocusAdapter(org.eclipse.swt.events.FocusAdapter) Composite(org.eclipse.swt.widgets.Composite) HsImageLabel(net.heartsome.cat.common.ui.HsImageLabel) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) FocusEvent(org.eclipse.swt.events.FocusEvent) GridLayout(org.eclipse.swt.layout.GridLayout) HsImageLabel(net.heartsome.cat.common.ui.HsImageLabel) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 65 with FocusEvent

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

the class StyledTextCellEditor method createTextControl.

protected StyledText createTextControl(Composite parent) {
    TagStyleManager tagStyleManager = xliffEditor.getTagStyleManager();
    IStyle cellStyle = this.hsCellEditor.getCellStyle();
    int styled = HorizontalAlignmentEnum.getSWTStyle(cellStyle);
    styled |= SWT.MULTI | SWT.WRAP;
    viewer = new SegmentViewer(parent, styled, tagStyleManager.getTagStyle());
    // 添加标记样式改变监听
    // addTagStyleChangeListener();
    // 注册标记样式调节器
    net.heartsome.cat.ts.ui.innertag.tagstyle.TagStyleConfigurator.configure(viewer);
    // TagStyleConfigurator.configure(viewer);
    // 将原来直接创建StyledText的方式改为由TextViewer提供
    final StyledText textControl = viewer.getTextWidget();
    initStyle(textControl, cellStyle);
    textControl.addFocusListener(new FocusListener() {

        public void focusLost(FocusEvent e) {
        }

        public void focusGained(FocusEvent e) {
            getActionHandler().updateGlobalActionHandler();
        }
    });
    viewer.getDocument().addDocumentListener(new IDocumentListener() {

        public void documentChanged(DocumentEvent e) {
            // 自动行高
            autoResize();
        }

        public void documentAboutToBeChanged(DocumentEvent event) {
        }
    });
    // 实现编辑模式下添加右键菜单
    // dispose textControl前应去掉右键menu,因为右键menu是和nattable共享的,不能在这儿dispose,说见close()方法
    final Menu menu = (Menu) xliffEditor.getTable().getData(Menu.class.getName());
    textControl.setMenu(menu);
    return textControl;
}
Also used : IStyle(net.sourceforge.nattable.style.IStyle) ISegmentViewer(net.heartsome.cat.ts.ui.innertag.ISegmentViewer) SegmentViewer(net.heartsome.cat.ts.ui.innertag.SegmentViewer) StyledText(org.eclipse.swt.custom.StyledText) IDocumentListener(org.eclipse.jface.text.IDocumentListener) Menu(org.eclipse.swt.widgets.Menu) DocumentEvent(org.eclipse.jface.text.DocumentEvent) FocusListener(org.eclipse.swt.events.FocusListener) FocusEvent(org.eclipse.swt.events.FocusEvent)

Aggregations

FocusEvent (org.eclipse.swt.events.FocusEvent)115 FocusAdapter (org.eclipse.swt.events.FocusAdapter)64 SelectionEvent (org.eclipse.swt.events.SelectionEvent)54 FocusListener (org.eclipse.swt.events.FocusListener)47 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)42 GridData (org.eclipse.swt.layout.GridData)38 Composite (org.eclipse.swt.widgets.Composite)34 Text (org.eclipse.swt.widgets.Text)33 GridLayout (org.eclipse.swt.layout.GridLayout)32 Label (org.eclipse.swt.widgets.Label)26 Menu (org.eclipse.swt.widgets.Menu)22 KeyEvent (org.eclipse.swt.events.KeyEvent)21 Button (org.eclipse.swt.widgets.Button)21 Point (org.eclipse.swt.graphics.Point)20 ModifyEvent (org.eclipse.swt.events.ModifyEvent)19 MenuManager (org.eclipse.jface.action.MenuManager)18 ModifyListener (org.eclipse.swt.events.ModifyListener)18 Combo (org.eclipse.swt.widgets.Combo)17 Group (org.eclipse.swt.widgets.Group)17 SelectionListener (org.eclipse.swt.events.SelectionListener)15