use of org.eclipse.swt.events.VerifyEvent 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.events.VerifyEvent 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.events.VerifyEvent 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;
}
});
}
use of org.eclipse.swt.events.VerifyEvent in project dbeaver by dbeaver.
the class ExtendedDirectEditManager method initCellEditor.
/**
* @see org.eclipse.gef.tools.DirectEditManager#initCellEditor()
*/
@Override
protected void initCellEditor() {
Text text = (Text) getCellEditor().getControl();
// add the verifyListener to apply changes to the control size
verifyListener = new VerifyListener() {
/**
* Changes the size of the editor control to reflect the changed
* text
*/
@Override
public void verifyText(VerifyEvent event) {
Text text = (Text) getCellEditor().getControl();
String oldText = text.getText();
String leftText = oldText.substring(0, event.start);
String rightText = oldText.substring(event.end, oldText.length());
GC gc = new GC(text);
if (leftText == null)
leftText = "";
if (rightText == null)
rightText = "";
String s = leftText + event.text + rightText;
Point size = gc.textExtent(leftText + event.text + rightText);
gc.dispose();
if (size.x != 0)
size = text.computeSize(size.x, SWT.DEFAULT);
else {
// just make it square
size.x = size.y;
}
getCellEditor().getControl().setSize(size.x, size.y);
}
};
text.addVerifyListener(verifyListener);
// set the initial value of the
originalValue = this.label.getText();
getCellEditor().setValue(originalValue);
// calculate the font size of the underlying
IFigure figure = getEditPart().getFigure();
figureFont = figure.getFont();
FontData data = figureFont.getFontData()[0];
Dimension fontSize = new Dimension(0, data.getHeight());
// set the font to be used
this.label.translateToAbsolute(fontSize);
data.setHeight(fontSize.height);
figureFont = new Font(null, data);
// set the validator for the CellEditor
getCellEditor().setValidator(validator);
text.setFont(figureFont);
text.selectAll();
}
use of org.eclipse.swt.events.VerifyEvent in project eclipse.platform.text by eclipse.
the class AbstractControlContentAssistSubjectAdapter method installControlListener.
/**
* Installs <code>fControlListener</code>, which handles VerifyEvents and KeyEvents by
* passing them to {@link #fVerifyKeyListeners} and {@link #fKeyListeners}.
*/
private void installControlListener() {
if (DEBUG)
// $NON-NLS-1$ //$NON-NLS-2$
System.out.println("AbstractControlContentAssistSubjectAdapter#installControlListener() -> k: " + fKeyListeners.size() + ", v: " + fVerifyKeyListeners.size());
if (fControlListener != null)
return;
fControlListener = new Listener() {
@Override
public void handleEvent(Event e) {
if (!getControl().isFocusControl())
// SWT.TRAVERSE_MNEMONIC events can also come in to inactive widgets
return;
VerifyEvent verifyEvent = new VerifyEvent(e);
KeyEvent keyEvent = new KeyEvent(e);
switch(e.type) {
case SWT.Traverse:
if (DEBUG)
// $NON-NLS-1$
dump("before traverse", e, verifyEvent);
verifyEvent.doit = true;
for (VerifyKeyListener verifyKeyListener : fVerifyKeyListeners) {
verifyKeyListener.verifyKey(verifyEvent);
if (!verifyEvent.doit) {
e.detail = SWT.TRAVERSE_NONE;
e.doit = true;
if (DEBUG)
// $NON-NLS-1$
dump("traverse eaten by verify", e, verifyEvent);
return;
}
if (DEBUG)
// $NON-NLS-1$
dump("traverse OK", e, verifyEvent);
}
break;
case SWT.KeyDown:
for (VerifyKeyListener verifyKeyListener : fVerifyKeyListeners) {
verifyKeyListener.verifyKey(verifyEvent);
if (!verifyEvent.doit) {
e.doit = verifyEvent.doit;
if (DEBUG)
// $NON-NLS-1$
dump("keyDown eaten by verify", e, verifyEvent);
return;
}
}
if (DEBUG)
// $NON-NLS-1$
dump("keyDown OK", e, verifyEvent);
for (KeyListener keyListener : fKeyListeners) {
keyListener.keyPressed(keyEvent);
}
break;
default:
Assert.isTrue(false);
}
}
/**
* Dump the given events to "standard" output.
*
* @param who who dump's
* @param e the event
* @param ve the verify event
*/
private void dump(String who, Event e, VerifyEvent ve) {
// $NON-NLS-1$
StringBuilder sb = new StringBuilder("--- [AbstractControlContentAssistSubjectAdapter]\n");
sb.append(who);
// $NON-NLS-1$
sb.append(" - e: keyCode=" + e.keyCode + hex(e.keyCode));
// $NON-NLS-1$
sb.append("; character=" + e.character + hex(e.character));
// $NON-NLS-1$
sb.append("; stateMask=" + e.stateMask + hex(e.stateMask));
// $NON-NLS-1$
sb.append("; doit=" + e.doit);
// $NON-NLS-1$
sb.append("; detail=" + e.detail + hex(e.detail));
// $NON-NLS-1$
sb.append("; widget=" + e.widget);
// $NON-NLS-1$
sb.append("\n");
// $NON-NLS-1$
sb.append(" verifyEvent keyCode=" + e.keyCode + hex(e.keyCode));
// $NON-NLS-1$
sb.append("; character=" + e.character + hex(e.character));
// $NON-NLS-1$
sb.append("; stateMask=" + e.stateMask + hex(e.stateMask));
// $NON-NLS-1$
sb.append("; doit=" + ve.doit);
// $NON-NLS-1$
sb.append("; widget=" + e.widget);
System.out.println(sb);
}
private String hex(int i) {
// $NON-NLS-1$
return "[0x" + Integer.toHexString(i) + ']';
}
};
getControl().addListener(SWT.Traverse, fControlListener);
getControl().addListener(SWT.KeyDown, fControlListener);
if (DEBUG)
// $NON-NLS-1$
System.out.println("AbstractControlContentAssistSubjectAdapter#installControlListener() - installed");
}
Aggregations