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);
}
}
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);
}
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);
}
}
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) {
}
});
}
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) {
}
});
}
Aggregations