Search in sources :

Example 1 with VerifyKeyListener

use of org.eclipse.swt.custom.VerifyKeyListener in project tdi-studio-se by Talend.

the class ReconcilerViewer method initializeViewer.

protected void initializeViewer(IDocument document) {
    fAnnotationPreferences = EditorsPlugin.getDefault().getMarkerAnnotationPreferences();
    setDocument(document);
    installViewerConfiguration();
    setEditable(true);
    Font font = JFaceResources.getFontRegistry().get(JFaceResources.TEXT_FONT);
    getTextWidget().setFont(font);
    Control control = getControl();
    GridData data = new GridData(GridData.FILL_BOTH);
    control.setLayoutData(data);
    prependVerifyKeyListener(new VerifyKeyListener() {

        @Override
        public void verifyKey(VerifyEvent event) {
            handleVerifyKeyPressed(event);
        }
    });
    addDocumentListener(document);
    addMenu();
}
Also used : IInformationControl(org.eclipse.jface.text.IInformationControl) SourceViewerInformationControl(org.eclipse.jdt.internal.ui.text.java.hover.SourceViewerInformationControl) Control(org.eclipse.swt.widgets.Control) VerifyKeyListener(org.eclipse.swt.custom.VerifyKeyListener) GridData(org.eclipse.swt.layout.GridData) VerifyEvent(org.eclipse.swt.events.VerifyEvent) Font(org.eclipse.swt.graphics.Font)

Example 2 with VerifyKeyListener

use of org.eclipse.swt.custom.VerifyKeyListener in project tdi-studio-se by Talend.

the class StyledTextHandler method addListeners.

/**
     * DOC amaumont Comment method "addListeners".
     */
private void addListeners() {
    styledText.addFocusListener(new FocusListener() {

        public void focusGained(FocusEvent e) {
            refreshProposalSize();
        }

        public void focusLost(FocusEvent e) {
        }
    });
    styledText.addControlListener(new ControlListener() {

        public void controlMoved(ControlEvent e) {
        }

        public void controlResized(ControlEvent e) {
            refreshProposalSize();
        }
    });
    styledText.addExtendedModifyListener(new ExtendedModifyListener() {

        public void modifyText(ExtendedModifyEvent event) {
            // System.out.println("ExtendedModifyListener modify text");
            updateCellExpression();
        }
    });
    styledText.getContent().addTextChangeListener(new TextChangeListener() {

        public void textChanged(TextChangedEvent event) {
            highlightLineOfCursorPosition(styledText.getSelection());
        }

        public void textChanging(TextChangingEvent event) {
        // System.out.println("textChanging");
        }

        public void textSet(TextChangedEvent event) {
        // System.out.println("textSet");
        }
    });
    styledText.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            highlightLineOfCursorPosition(styledText.getSelection());
        }
    });
    styledText.addKeyListener(new KeyListener() {

        public void keyPressed(KeyEvent e) {
            highlightLineOfCursorPosition(styledText.getSelection());
        }

        public void keyReleased(KeyEvent e) {
        // TODO Auto-generated method stub
        }
    });
    styledText.addVerifyKeyListener(new VerifyKeyListener() {

        public void verifyKey(VerifyEvent verifyEvent) {
            if (verifyEvent.character == '\r' && contentProposalAdapter != null && contentProposalAdapter.isProposalOpened()) {
                verifyEvent.doit = false;
            } else {
                verifyEvent.doit = true;
            }
        }
    });
    styledText.addMouseListener(new MouseListener() {

        public void mouseDoubleClick(MouseEvent e) {
            highlightLineOfCursorPosition(styledText.getSelection());
        }

        public void mouseDown(MouseEvent e) {
            highlightLineOfCursorPosition(styledText.getSelection());
        }

        public void mouseUp(MouseEvent e) {
        }
    });
}
Also used : ExtendedModifyEvent(org.eclipse.swt.custom.ExtendedModifyEvent) MouseEvent(org.eclipse.swt.events.MouseEvent) ExtendedModifyListener(org.eclipse.swt.custom.ExtendedModifyListener) ModifyListener(org.eclipse.swt.events.ModifyListener) ExtendedModifyListener(org.eclipse.swt.custom.ExtendedModifyListener) VerifyKeyListener(org.eclipse.swt.custom.VerifyKeyListener) TextChangingEvent(org.eclipse.swt.custom.TextChangingEvent) FocusEvent(org.eclipse.swt.events.FocusEvent) TextChangedEvent(org.eclipse.swt.custom.TextChangedEvent) KeyEvent(org.eclipse.swt.events.KeyEvent) ModifyEvent(org.eclipse.swt.events.ModifyEvent) ExtendedModifyEvent(org.eclipse.swt.custom.ExtendedModifyEvent) MouseListener(org.eclipse.swt.events.MouseListener) ControlListener(org.eclipse.swt.events.ControlListener) VerifyKeyListener(org.eclipse.swt.custom.VerifyKeyListener) KeyListener(org.eclipse.swt.events.KeyListener) ControlEvent(org.eclipse.swt.events.ControlEvent) TextChangeListener(org.eclipse.swt.custom.TextChangeListener) FocusListener(org.eclipse.swt.events.FocusListener) VerifyEvent(org.eclipse.swt.events.VerifyEvent)

Example 3 with VerifyKeyListener

use of org.eclipse.swt.custom.VerifyKeyListener in project cubrid-manager by CUBRID.

the class SQLEditorComposite method addListener.

/**
	 * Add listener for text
	 */
private void addListener() {
    text.addModifyListener(new ModifyListener() {

        IAction undoAction = ActionManager.getInstance().getAction(UndoAction.ID);

        IAction redoAction = ActionManager.getInstance().getAction(RedoAction.ID);

        public void modifyText(ModifyEvent event) {
            setDirty(true);
            if (!undoAction.isEnabled()) {
                FocusAction.changeActionStatus(undoAction, text);
            }
            if (!redoAction.isEnabled()) {
                FocusAction.changeActionStatus(redoAction, text);
            }
            ServerInfo serverInfo = queryEditor == null || queryEditor.getSelectedServer() == null ? null : queryEditor.getSelectedServer().getServerInfo();
            boolean isLowerCase = QueryOptions.getKeywordLowercase(serverInfo);
            boolean isNoAutoUpperCase = QueryOptions.getNoAutoUppercaseKeyword(serverInfo);
            if (!isLowerCase && !isNoAutoUpperCase) {
                autoReplaceKeyword();
            }
        }

        // FIXME extract method?
        // replace keyword to upper case automatically
        public void autoReplaceKeyword() {
            if (pendingCompletionsListener) {
                return;
            }
            int pos = text.getCaretOffset() - 1;
            if (pos <= 0) {
                return;
            }
            String currentKey = text.getText(pos, pos);
            if (currentKey == null || currentKey.length() <= 0) {
                return;
            }
            char cur = currentKey.charAt(0);
            if (cur != ' ' && cur != '(' && cur != '\t' && cur != '\n' && cur != '\r' && cur != ',') {
                return;
            }
            pos--;
            if (pos < 0) {
                return;
            }
            int spos = pos - 20;
            if (spos < 0) {
                spos = 0;
            }
            String txt = text.getText(spos, pos);
            spos = pos + 1;
            for (int i = txt.length() - 1; i >= 0; i--) {
                char c = txt.charAt(i);
                if (c == ' ' || c == '\t' || c == '\n' || c == '(') {
                    break;
                }
                spos--;
            }
            int epos = pos;
            if (spos < 0 || epos < 0 || spos > epos) {
                return;
            }
            String currentKeyword = text.getText(spos, epos);
            if (currentKeyword == null) {
                return;
            }
            int len = currentKeyword.length();
            for (int i = 0; i < QuerySyntax.KEYWORDS_AUTO_UPPER.length; i++) {
                String keyword = QuerySyntax.KEYWORDS_AUTO_UPPER[i];
                if (keyword.equalsIgnoreCase(currentKeyword)) {
                    pendingCompletionsListener = true;
                    text.replaceTextRange(spos, len, keyword.toUpperCase());
                    pendingCompletionsListener = false;
                    break;
                }
            }
        }
    });
    text.addVerifyKeyListener(new VerifyKeyListener() {

        public void verifyKey(VerifyEvent event) {
            if ((event.stateMask & SWT.SHIFT) != 0 && event.keyCode == SWT.TAB) {
                event.doit = false;
                return;
            }
            if (((event.stateMask & SWT.CTRL) != 0 || (event.stateMask & SWT.COMMAND) != 0) && (event.keyCode == SWT.CR || event.keyCode == SWT.KEYPAD_CR)) {
                event.doit = false;
                return;
            }
            if (((event.stateMask & SWT.CTRL) != 0 || (event.stateMask & SWT.COMMAND) != 0) && (event.stateMask & SWT.ALT) != 0) {
                event.doit = false;
                return;
            }
            if (event.keyCode == SWT.TAB) {
                event.doit = false;
            } else {
                event.doit = true;
            }
        }
    });
    text.addKeyListener(new KeyAdapter() {

        public void keyPressed(KeyEvent event) {
            if ((event.stateMask & SWT.COMMAND) != 0) {
                //for Mac
                if ((event.stateMask & SWT.SHIFT) != 0) {
                    if (event.keyCode == SWT.CR || event.keyCode == SWT.KEYPAD_CR) {
                        queryEditor.runQuery(false);
                        return;
                    }
                }
            }
            if (event.keyCode == SWT.F5 || (event.stateMask & SWT.CTRL) != 0 && event.keyCode == 'e') {
                queryEditor.runQuery(false);
            } else if (event.keyCode == SWT.F6 || (event.stateMask & SWT.CTRL) != 0 && event.keyCode == 'l') {
                queryEditor.runQuery(true);
            } else if (event.keyCode == SWT.F7) {
                queryEditor.getCombinedQueryComposite().showQueryHistory();
            } else if (event.keyCode == SWT.F8) {
                queryEditor.runMultiQuery();
            } else if (event.keyCode == SWT.F1) {
                ActionManager.getInstance().getAction(HelpDocumentAction.ID).run();
            } else if (event.keyCode == SWT.F3) {
                if ((event.stateMask & SWT.SHIFT) == 0) {
                    TextEditorFindReplaceMediator.findNext();
                } else {
                    TextEditorFindReplaceMediator.findPrevious();
                }
            } else if (event.keyCode == SWT.F9) {
                queryEditor.setTuningModeButton(!queryEditor.isTuningModeButton());
            } else if (event.keyCode == SWT.F11) {
                queryEditor.getCombinedQueryComposite().rotateQueryPlanDisplayMode();
            } else if ((event.stateMask & SWT.CTRL) == 0 && (event.stateMask & SWT.SHIFT) == 0 && (event.stateMask & SWT.ALT) == 0 && event.keyCode == SWT.ESC) {
                int cursorOffset = text.getCaretOffset();
                text.setSelectionRange(cursorOffset, 0);
            } else if ((event.stateMask & SWT.CTRL) != 0 && (event.stateMask & SWT.SHIFT) == 0 && (event.stateMask & SWT.ALT) == 0 && event.keyCode == ',') {
                new QuickBuilderDialog(getShell(), SWT.NONE).open();
            } else if ((event.stateMask & SWT.CTRL) != 0 && event.keyCode == ' ') {
                contentAssistant.showPossibleCompletions();
            } else if ((event.stateMask & SWT.CTRL) != 0 && event.keyCode == 'r') {
                recentlyUsedSQLcontentAssistant.showPossibleCompletions();
            } else if ((event.stateMask & SWT.CTRL) != 0 && event.keyCode == 'd') {
                deleteRow();
            } else if ((event.stateMask & SWT.CTRL) != 0 && (event.stateMask & SWT.ALT) != 0 && event.keyCode == SWT.ARROW_DOWN) {
                duplicateRow();
            } else if ((event.stateMask & SWT.CTRL) != 0 && (event.stateMask & SWT.SHIFT) != 0 && event.keyCode == 't') {
                //add sql tab
                queryEditor.addEditorTab();
            } else if (((event.stateMask & SWT.CTRL) != 0 && (event.stateMask & SWT.SHIFT) != 0) && (event.keyCode == 'f' || event.keyCode == 'F')) {
                format();
            } else if ((event.stateMask & SWT.ALT) != 0 && event.keyCode == '/') {
                contentAssist();
            } else if ((event.stateMask & SWT.CTRL) != 0 && event.keyCode == 'o') {
                // Open a SQL file...
                ActionManager.getInstance().getAction(QueryOpenAction.ID).run();
            } else if ((event.stateMask & SWT.CTRL) != 0 && event.keyCode == 's') {
                // Save SQL to a file...
                try {
                    save();
                } catch (IOException e) {
                    MessageDialog.openError(getShell(), Messages.error, Messages.errCanNotSaveASQLFile);
                }
            } else if ((event.stateMask & SWT.CTRL) != 0 && (event.stateMask & SWT.SHIFT) == 0) {
                if (event.keyCode == '/') {
                    inputComment(false, false);
                } else if (event.keyCode == 'z') {
                    event.doit = false;
                    undo();
                } else if (event.keyCode == 'y') {
                    redo();
                } else if (event.keyCode == 'f' || event.keyCode == 'h') {
                    find();
                } else if ((event.stateMask & SWT.ALT) != 0 && (event.keyCode == SWT.CR || event.keyCode == SWT.KEYPAD_CR)) {
                    // NOPMD
                    queryEditor.runQueryPlanInCursorLine();
                } else if (event.keyCode == SWT.CR || event.keyCode == SWT.KEYPAD_CR) {
                    queryEditor.runQueryInCursorLine();
                } else if (event.keyCode == 'g') {
                    gotoLine();
                }
            } else if ((event.stateMask & SWT.CTRL) != 0 && (event.stateMask & SWT.SHIFT) != 0) {
                if ((event.stateMask & SWT.ALT) != 0 && (event.keyCode == SWT.CR || event.keyCode == SWT.KEYPAD_CR)) {
                    // NOPMD
                    queryEditor.runQuery(true);
                } else if (event.keyCode == SWT.CR || event.keyCode == SWT.KEYPAD_CR) {
                    queryEditor.runQuery(false);
                } else if (event.keyCode == 'x') {
                    toUpperCase();
                } else if (event.keyCode == 'y') {
                    toLowerCase();
                }
            } else if ((event.stateMask & SWT.SHIFT) == 0 && event.keyCode == SWT.TAB) {
                indent();
            } else if ((event.stateMask & SWT.SHIFT) != 0 && event.keyCode == SWT.TAB) {
                unindent();
            }
            if (SQLContentAssistProcessor.isShowProposal(event.character)) {
                contentAssistant.showPossibleCompletions();
                useCompletions = true;
            } else if ((event.character >= 'A' && event.character <= 'Z') || (event.character >= 'a' && event.character <= 'z')) {
                if (useCompletions) {
                    contentAssistant.showPossibleCompletions();
                }
                useCompletions = false;
            } else if (event.character == ' ' || event.character == '\t' || event.keyCode == SWT.KEYPAD_CR || event.keyCode == SWT.CR || event.keyCode == SWT.BS || (text.getText().trim().length() < 1)) {
                useCompletions = true;
            }
            // ctrl + alt + 1 ~ 9 : change editor tab
            if ((event.stateMask & SWT.CTRL) != 0 && (event.stateMask & SWT.ALT) != 0 && (event.keyCode >= '1' && event.keyCode <= '9')) {
                IWorkbenchPage page = LayoutUtil.getActivePage();
                if (page != null) {
                    int index = event.keyCode - '1';
                    IEditorReference[] refs = page.getEditorReferences();
                    for (int i = 0, selected = 0; i < refs.length; i++) {
                        IEditorReference ref = refs[i];
                        if (QueryEditorPart.ID.equals(ref.getId())) {
                            if (index == selected) {
                                IEditorPart part = ref.getEditor(true);
                                page.activate(part);
                            }
                            selected++;
                        }
                    }
                }
            } else if ((event.stateMask & SWT.CTRL) != 0 && (event.keyCode >= '1' && event.keyCode <= '9')) {
                // ctrl + 1 ~ 9 : change middle tab
                ITabSelection selector = queryEditor.getCombinedQueryComposite();
                selector.select(event.keyCode - '1', -1);
            } else if ((event.stateMask & SWT.ALT) != 0 && (event.keyCode >= '1' && event.keyCode <= '9')) {
                // alt + 1 ~ 9 : change bottom tab
                ITabSelection selector = queryEditor.getCombinedQueryComposite();
                selector.select(-1, event.keyCode - '1');
            }
        }
    });
    text.addSelectionListener(new SelectionAdapter() {

        /**
			 * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
			 * @param event an event containing information about the selection
			 */
        public void widgetSelected(SelectionEvent event) {
            IAction copyAction = ActionManager.getInstance().getAction(CopyAction.ID);
            copyAction.setEnabled(false);
            IAction cutAction = ActionManager.getInstance().getAction(CutAction.ID);
            cutAction.setEnabled(false);
            IAction reformatColumnsAliasAction = ActionManager.getInstance().getAction(ReformatColumnsAliasAction.ID);
            reformatColumnsAliasAction.setEnabled(false);
            // show schema info view with a selected text
            IAction showSchemaAction = ActionManager.getInstance().getAction(ShowSchemaAction.ID);
            showSchemaAction.setEnabled(false);
            if (event.getSource() instanceof StyledText) {
                StyledText stext = (StyledText) event.getSource();
                if (stext != null && stext.getSelectionText() != null && stext.getSelectionText().length() > 0) {
                    copyAction.setEnabled(true);
                    cutAction.setEnabled(true);
                    reformatColumnsAliasAction.setEnabled(true);
                    CubridDatabase db = queryEditor.getSelectedDatabase();
                    if (DatabaseNavigatorMenu.SELF_DATABASE_ID.equals(db.getId()) && ApplicationType.CUBRID_MANAGER.equals(PerspectiveManager.getInstance().getCurrentMode())) {
                        showSchemaAction.setEnabled(false);
                    } else {
                        showSchemaAction.setEnabled(true);
                    }
                }
            }
        }
    });
    text.addFocusListener(new FocusAdapter() {

        public void focusGained(FocusEvent event) {
            ActionManager.getInstance().changeFocusProvider(text);
        }
    });
    TextEditorFindReplaceMediator editorDialogMediator = new TextEditorFindReplaceMediator();
    text.addFocusListener(editorDialogMediator);
}
Also used : FocusAdapter(org.eclipse.swt.events.FocusAdapter) StyledText(org.eclipse.swt.custom.StyledText) ModifyListener(org.eclipse.swt.events.ModifyListener) IAction(org.eclipse.jface.action.IAction) VerifyKeyListener(org.eclipse.swt.custom.VerifyKeyListener) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) KeyAdapter(org.eclipse.swt.events.KeyAdapter) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) IOException(java.io.IOException) IEditorPart(org.eclipse.ui.IEditorPart) FocusEvent(org.eclipse.swt.events.FocusEvent) KeyEvent(org.eclipse.swt.events.KeyEvent) ModifyEvent(org.eclipse.swt.events.ModifyEvent) QuickBuilderDialog(com.cubrid.common.ui.query.builder.quickbuilder.QuickBuilderDialog) IEditorReference(org.eclipse.ui.IEditorReference) TextEditorFindReplaceMediator(com.cubrid.tool.editor.TextEditorFindReplaceMediator) SelectionEvent(org.eclipse.swt.events.SelectionEvent) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase) VerifyEvent(org.eclipse.swt.events.VerifyEvent)

Example 4 with VerifyKeyListener

use of org.eclipse.swt.custom.VerifyKeyListener in project tdi-studio-se by Talend.

the class StyledTextHandler method addListeners.

/**
     * DOC amaumont Comment method "addListeners".
     */
private void addListeners() {
    styledText.addFocusListener(new FocusListener() {

        public void focusGained(FocusEvent e) {
            refreshProposalSize();
        }

        public void focusLost(FocusEvent e) {
        }
    });
    styledText.addControlListener(new ControlListener() {

        public void controlMoved(ControlEvent e) {
        }

        public void controlResized(ControlEvent e) {
            refreshProposalSize();
        }
    });
    styledText.addExtendedModifyListener(new ExtendedModifyListener() {

        public void modifyText(ExtendedModifyEvent event) {
            updateCellExpression();
        // System.out.println("ExtendedModifyListener modify text");
        }
    });
    styledText.getContent().addTextChangeListener(new TextChangeListener() {

        public void textChanged(TextChangedEvent event) {
            highlightLineOfCursorPosition(styledText.getSelection());
        }

        public void textChanging(TextChangingEvent event) {
        // System.out.println("textChanging");
        }

        public void textSet(TextChangedEvent event) {
        // System.out.println("textSet");
        }
    });
    styledText.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            highlightLineOfCursorPosition(styledText.getSelection());
        }
    });
    styledText.addKeyListener(new KeyListener() {

        public void keyPressed(KeyEvent e) {
            highlightLineOfCursorPosition(styledText.getSelection());
        }

        public void keyReleased(KeyEvent e) {
        // TODO Auto-generated method stub
        }
    });
    styledText.addVerifyKeyListener(new VerifyKeyListener() {

        public void verifyKey(VerifyEvent verifyEvent) {
            if (verifyEvent.character == '\r' && contentProposalAdapter != null && contentProposalAdapter.isProposalOpened()) {
                verifyEvent.doit = false;
            } else {
                verifyEvent.doit = true;
            }
        }
    });
    styledText.addMouseListener(new MouseListener() {

        public void mouseDoubleClick(MouseEvent e) {
            highlightLineOfCursorPosition(styledText.getSelection());
        }

        public void mouseDown(MouseEvent e) {
            highlightLineOfCursorPosition(styledText.getSelection());
        }

        public void mouseUp(MouseEvent e) {
        }
    });
}
Also used : ExtendedModifyEvent(org.eclipse.swt.custom.ExtendedModifyEvent) MouseEvent(org.eclipse.swt.events.MouseEvent) ExtendedModifyListener(org.eclipse.swt.custom.ExtendedModifyListener) ModifyListener(org.eclipse.swt.events.ModifyListener) ExtendedModifyListener(org.eclipse.swt.custom.ExtendedModifyListener) VerifyKeyListener(org.eclipse.swt.custom.VerifyKeyListener) TextChangingEvent(org.eclipse.swt.custom.TextChangingEvent) FocusEvent(org.eclipse.swt.events.FocusEvent) TextChangedEvent(org.eclipse.swt.custom.TextChangedEvent) KeyEvent(org.eclipse.swt.events.KeyEvent) ModifyEvent(org.eclipse.swt.events.ModifyEvent) ExtendedModifyEvent(org.eclipse.swt.custom.ExtendedModifyEvent) MouseListener(org.eclipse.swt.events.MouseListener) ControlListener(org.eclipse.swt.events.ControlListener) VerifyKeyListener(org.eclipse.swt.custom.VerifyKeyListener) KeyListener(org.eclipse.swt.events.KeyListener) ControlEvent(org.eclipse.swt.events.ControlEvent) TextChangeListener(org.eclipse.swt.custom.TextChangeListener) FocusListener(org.eclipse.swt.events.FocusListener) VerifyEvent(org.eclipse.swt.events.VerifyEvent)

Example 5 with VerifyKeyListener

use of org.eclipse.swt.custom.VerifyKeyListener in project tdi-studio-se by Talend.

the class SQLBuilderEditorComposite method createEditorArea.

/**
     * Creates UI for editor.
     * 
     * @param parent
     */
private void createEditorArea(Composite parent) {
    // create divider line
    Composite div1 = new Composite(parent, SWT.NONE);
    GridData lgid = new GridData();
    lgid.grabExcessHorizontalSpace = true;
    lgid.horizontalAlignment = GridData.FILL;
    lgid.heightHint = 1;
    lgid.verticalIndent = 1;
    div1.setLayoutData(lgid);
    div1.setBackground(parent.getShell().getDisplay().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW));
    // create text viewer
    GridData gid = new GridData();
    gid.grabExcessHorizontalSpace = true;
    gid.grabExcessVerticalSpace = true;
    gid.horizontalAlignment = GridData.FILL;
    gid.verticalAlignment = GridData.FILL;
    colorText = new ColorStyledText(parent, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL, CorePlugin.getDefault().getPreferenceStore(), language);
    IPreferenceStore preferenceStore = CorePlugin.getDefault().getPreferenceStore();
    String fontType = preferenceStore.getString(TalendDesignerPrefConstants.MEMO_TEXT_FONT);
    FontData fontData = new FontData(fontType);
    Font font = new Font(null, fontData);
    addResourceDisposeListener(colorText, font);
    colorText.setFont(font);
    GridData gd = new GridData(GridData.FILL_BOTH);
    colorText.setLayoutData(gd);
    colorText.setText(this.connParam.getQuery());
    colorText.addVerifyKeyListener(new VerifyKeyListener() {

        @Override
        public void verifyKey(VerifyEvent event) {
            if (event.stateMask == SWT.CTRL && event.keyCode == 13) {
                event.doit = false;
                execSQLAction.run();
            }
        }
    });
    colorText.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            isModified = true;
        }
    });
}
Also used : ModifyEvent(org.eclipse.swt.events.ModifyEvent) Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) VerifyKeyListener(org.eclipse.swt.custom.VerifyKeyListener) FontData(org.eclipse.swt.graphics.FontData) GridData(org.eclipse.swt.layout.GridData) ColorStyledText(org.talend.commons.ui.swt.colorstyledtext.ColorStyledText) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) VerifyEvent(org.eclipse.swt.events.VerifyEvent) Font(org.eclipse.swt.graphics.Font)

Aggregations

VerifyKeyListener (org.eclipse.swt.custom.VerifyKeyListener)6 VerifyEvent (org.eclipse.swt.events.VerifyEvent)6 ModifyEvent (org.eclipse.swt.events.ModifyEvent)5 ModifyListener (org.eclipse.swt.events.ModifyListener)5 FocusEvent (org.eclipse.swt.events.FocusEvent)4 KeyEvent (org.eclipse.swt.events.KeyEvent)4 ExtendedModifyEvent (org.eclipse.swt.custom.ExtendedModifyEvent)3 ExtendedModifyListener (org.eclipse.swt.custom.ExtendedModifyListener)3 TextChangeListener (org.eclipse.swt.custom.TextChangeListener)3 TextChangedEvent (org.eclipse.swt.custom.TextChangedEvent)3 TextChangingEvent (org.eclipse.swt.custom.TextChangingEvent)3 ControlEvent (org.eclipse.swt.events.ControlEvent)3 ControlListener (org.eclipse.swt.events.ControlListener)3 FocusListener (org.eclipse.swt.events.FocusListener)3 KeyListener (org.eclipse.swt.events.KeyListener)3 MouseEvent (org.eclipse.swt.events.MouseEvent)3 MouseListener (org.eclipse.swt.events.MouseListener)3 Font (org.eclipse.swt.graphics.Font)2 GridData (org.eclipse.swt.layout.GridData)2 QuickBuilderDialog (com.cubrid.common.ui.query.builder.quickbuilder.QuickBuilderDialog)1