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