Search in sources :

Example 1 with ExtendedModifyEvent

use of org.eclipse.swt.custom.ExtendedModifyEvent 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 2 with ExtendedModifyEvent

use of org.eclipse.swt.custom.ExtendedModifyEvent 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 3 with ExtendedModifyEvent

use of org.eclipse.swt.custom.ExtendedModifyEvent 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) {
            mapperManager.fireCurrentDirectEditApply();
            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 4 with ExtendedModifyEvent

use of org.eclipse.swt.custom.ExtendedModifyEvent in project pentaho-kettle by pentaho.

the class StyledTextComp method addUndoRedoSupport.

// Start Functions for Undo / Redo on wSrcipt
private void addUndoRedoSupport() {
    styledText.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent event) {
            if (styledText.getSelectionCount() == styledText.getCharCount()) {
                bFullSelection = true;
                try {
                    event.wait(2);
                } catch (Exception e) {
                // Ignore errors
                }
            }
        }

        public void widgetDefaultSelected(SelectionEvent event) {
        }
    });
    styledText.addExtendedModifyListener(new ExtendedModifyListener() {

        public void modifyText(ExtendedModifyEvent event) {
            int iEventLength = event.length;
            int iEventStartPostition = event.start;
            // Unterscheidung um welche Art es sich handelt Delete or Insert
            String newText = styledText.getText();
            String repText = event.replacedText;
            String oldText = "";
            int iEventType = -1;
            // if((event.length!=newText.length()) || newText.length()==1){
            if ((event.length != newText.length()) || (bFullSelection)) {
                if (repText != null && repText.length() > 0) {
                    oldText = newText.substring(0, event.start) + repText + newText.substring(event.start + event.length);
                    iEventType = UndoRedoStack.DELETE;
                    iEventLength = repText.length();
                } else {
                    oldText = newText.substring(0, event.start) + newText.substring(event.start + event.length);
                    iEventType = UndoRedoStack.INSERT;
                }
                if ((oldText != null && oldText.length() > 0) || (iEventStartPostition == event.length)) {
                    UndoRedoStack urs = new UndoRedoStack(iEventStartPostition, newText, oldText, iEventLength, iEventType);
                    if (undoStack.size() == MAX_STACK_SIZE) {
                        undoStack.remove(undoStack.size() - 1);
                    }
                    undoStack.add(0, urs);
                }
            }
            bFullSelection = false;
        }
    });
}
Also used : ExtendedModifyEvent(org.eclipse.swt.custom.ExtendedModifyEvent) ExtendedModifyListener(org.eclipse.swt.custom.ExtendedModifyListener) SelectionEvent(org.eclipse.swt.events.SelectionEvent) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 5 with ExtendedModifyEvent

use of org.eclipse.swt.custom.ExtendedModifyEvent in project knime-core by knime.

the class StyledTextEditor method createStyledText.

private Control createStyledText(final Composite parent) {
    m_styledText = new StyledText(parent, SWT.MULTI | SWT.WRAP | SWT.FULL_SELECTION);
    // by default we are a workflow annotation editor
    // can be changed by changing the default font (setDefaultFont(Font))
    m_styledText.setFont(AnnotationEditPart.getWorkflowAnnotationDefaultFont());
    m_styledText.setAlignment(SWT.LEFT);
    m_styledText.setText("");
    m_styledText.setTabs(TAB_SIZE);
    m_styledText.addVerifyKeyListener(new VerifyKeyListener() {

        @Override
        public void verifyKey(final VerifyEvent event) {
            if (event.character == SWT.CR && (event.stateMask & SWT.MOD1) != 0) {
                event.doit = false;
            }
        }
    });
    // forward some events to the cell editor
    m_styledText.addKeyListener(new KeyAdapter() {

        @Override
        public void keyReleased(final KeyEvent e) {
            keyReleaseOccured(e);
        }
    });
    m_styledText.addFocusListener(new FocusAdapter() {

        /**
         * {@inheritDoc}
         */
        @Override
        public void focusLost(final org.eclipse.swt.events.FocusEvent e) {
            // effect of an opening font editor, for instance)
            if (m_allowFocusLost.get()) {
                lostFocus();
            }
        }
    });
    m_styledText.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(final ModifyEvent e) {
            // super marks it dirty (otherwise no commit at the end)
            fireEditorValueChanged(true, true);
        }
    });
    m_styledText.addExtendedModifyListener(new ExtendedModifyListener() {

        @Override
        public void modifyText(final ExtendedModifyEvent event) {
            if (event.length > 0) {
                textInserted(event.start, event.length);
            }
        }
    });
    m_styledText.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetSelected(final SelectionEvent e) {
            selectionChanged();
        }

        @Override
        public void widgetDefaultSelected(final SelectionEvent e) {
            selectionChanged();
        }
    });
    m_styledText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    addMenu(m_styledText);
    // toolbar gets created first - enable its style buttons!
    selectionChanged();
    return m_styledText;
}
Also used : FocusAdapter(org.eclipse.swt.events.FocusAdapter) ExtendedModifyEvent(org.eclipse.swt.custom.ExtendedModifyEvent) StyledText(org.eclipse.swt.custom.StyledText) ExtendedModifyListener(org.eclipse.swt.custom.ExtendedModifyListener) ModifyListener(org.eclipse.swt.events.ModifyListener) VerifyKeyListener(org.eclipse.swt.custom.VerifyKeyListener) ExtendedModifyListener(org.eclipse.swt.custom.ExtendedModifyListener) KeyAdapter(org.eclipse.swt.events.KeyAdapter) KeyEvent(org.eclipse.swt.events.KeyEvent) ModifyEvent(org.eclipse.swt.events.ModifyEvent) ExtendedModifyEvent(org.eclipse.swt.custom.ExtendedModifyEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) GridData(org.eclipse.swt.layout.GridData) VerifyEvent(org.eclipse.swt.events.VerifyEvent) SelectionListener(org.eclipse.swt.events.SelectionListener)

Aggregations

ExtendedModifyEvent (org.eclipse.swt.custom.ExtendedModifyEvent)5 ExtendedModifyListener (org.eclipse.swt.custom.ExtendedModifyListener)5 VerifyKeyListener (org.eclipse.swt.custom.VerifyKeyListener)4 KeyEvent (org.eclipse.swt.events.KeyEvent)4 ModifyEvent (org.eclipse.swt.events.ModifyEvent)4 ModifyListener (org.eclipse.swt.events.ModifyListener)4 VerifyEvent (org.eclipse.swt.events.VerifyEvent)4 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 FocusEvent (org.eclipse.swt.events.FocusEvent)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 SelectionEvent (org.eclipse.swt.events.SelectionEvent)2 SelectionListener (org.eclipse.swt.events.SelectionListener)2 StyledText (org.eclipse.swt.custom.StyledText)1