Search in sources :

Example 6 with TextChangedEvent

use of org.eclipse.swt.custom.TextChangedEvent in project dbeaver by serge-rider.

the class DisplayedContent method setText.

/**
 * @see org.eclipse.swt.custom.StyledTextContent#setText(java.lang.String)
 */
@Override
public void setText(String text) {
    data.setLength(0);
    data.append(text, 0, Math.min(text.length(), Math.max(0, linesTimesColumns)));
    TextChangedEvent changedEvent = new TextChangedEvent(this);
    for (TextChangeListener textListener : textListeners) {
        textListener.textSet(changedEvent);
    }
}
Also used : TextChangeListener(org.eclipse.swt.custom.TextChangeListener) TextChangedEvent(org.eclipse.swt.custom.TextChangedEvent)

Example 7 with TextChangedEvent

use of org.eclipse.swt.custom.TextChangedEvent in project dbeaver by dbeaver.

the class DisplayedContent method shiftLines.

/**
 * Shifts full lines of text and fills the new empty space with text
 *
 * @param text    to replace new empty lines. Its size determines the number of lines to shift
 * @param forward shifts lines either forward or backward
 */
public void shiftLines(String text, boolean forward) {
    if (text.length() == 0)
        return;
    int linesInText = (text.length() - 1) / numberOfColumns + 1;
    int currentLimit = Math.min(data.length(), linesTimesColumns);
    TextChangingEvent event = new TextChangingEvent(this);
    event.start = forward ? 0 : currentLimit;
    event.newText = text;
    event.replaceCharCount = 0;
    event.newCharCount = text.length();
    event.replaceLineCount = 0;
    event.newLineCount = linesInText;
    for (TextChangeListener myTextListener : textListeners) myTextListener.textChanging(event);
    data.insert(event.start, text);
    TextChangedEvent changedEvent = new TextChangedEvent(this);
    for (TextChangeListener myTextListener : textListeners) myTextListener.textChanged(changedEvent);
    event = new TextChangingEvent(this);
    // event.start = forward ? linesTimesColumns : 0;
    event.start = forward ? linesTimesColumns - 1 : 0;
    event.newText = "";
    event.replaceCharCount = linesInText * numberOfColumns - linesTimesColumns + currentLimit;
    event.newCharCount = 0;
    event.replaceLineCount = linesInText;
    event.newLineCount = 0;
    for (TextChangeListener myTextListener : textListeners) myTextListener.textChanging(event);
    // data.delete(event.start, event.start + event.replaceCharCount);
    if (forward)
        data.delete(linesTimesColumns, linesTimesColumns + event.replaceCharCount);
    else
        data.delete(0, event.replaceCharCount);
    changedEvent = new TextChangedEvent(this);
    for (TextChangeListener myTextListener : textListeners) myTextListener.textChanged(changedEvent);
}
Also used : TextChangingEvent(org.eclipse.swt.custom.TextChangingEvent) TextChangeListener(org.eclipse.swt.custom.TextChangeListener) TextChangedEvent(org.eclipse.swt.custom.TextChangedEvent)

Example 8 with TextChangedEvent

use of org.eclipse.swt.custom.TextChangedEvent in project dbeaver by dbeaver.

the class DisplayedContent method setText.

/**
 * @see org.eclipse.swt.custom.StyledTextContent#setText(java.lang.String)
 */
@Override
public void setText(String text) {
    data.setLength(0);
    data.append(text, 0, Math.min(text.length(), Math.max(0, linesTimesColumns)));
    TextChangedEvent changedEvent = new TextChangedEvent(this);
    for (TextChangeListener textListener : textListeners) {
        textListener.textSet(changedEvent);
    }
}
Also used : TextChangeListener(org.eclipse.swt.custom.TextChangeListener) TextChangedEvent(org.eclipse.swt.custom.TextChangedEvent)

Example 9 with TextChangedEvent

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

use of org.eclipse.swt.custom.TextChangedEvent 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)

Aggregations

TextChangeListener (org.eclipse.swt.custom.TextChangeListener)12 TextChangedEvent (org.eclipse.swt.custom.TextChangedEvent)12 TextChangingEvent (org.eclipse.swt.custom.TextChangingEvent)8 ExtendedModifyEvent (org.eclipse.swt.custom.ExtendedModifyEvent)3 ExtendedModifyListener (org.eclipse.swt.custom.ExtendedModifyListener)3 StyledTextContent (org.eclipse.swt.custom.StyledTextContent)3 VerifyKeyListener (org.eclipse.swt.custom.VerifyKeyListener)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 KeyEvent (org.eclipse.swt.events.KeyEvent)3 KeyListener (org.eclipse.swt.events.KeyListener)3 ModifyEvent (org.eclipse.swt.events.ModifyEvent)3 ModifyListener (org.eclipse.swt.events.ModifyListener)3 MouseEvent (org.eclipse.swt.events.MouseEvent)3 MouseListener (org.eclipse.swt.events.MouseListener)3 VerifyEvent (org.eclipse.swt.events.VerifyEvent)3 Test (org.junit.Test)3