use of org.eclipse.swt.widgets.Listener in project knime-core by knime.
the class EditorUISettingsDialog method createGridPanel.
private void createGridPanel(final Composite parent) {
Group border = new Group(parent, SWT.SHADOW_IN);
border.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
border.setLayout(new GridLayout(2, true));
border.setText(" Grid Size ");
Composite horiz = new Composite(border, SWT.BORDER_SOLID);
horiz.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
horiz.setLayout(new GridLayout(2, false));
Label h = new Label(horiz, SWT.NONE);
h.setText("horizontal spacing (px):");
h.setToolTipText("Preference page default value is " + WorkflowEditor.getPrefGridXSize());
h.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
m_xGrid = new Text(horiz, SWT.SINGLE | SWT.BORDER);
m_xGrid.setTextLimit(10);
m_xGrid.setToolTipText("Preference page default value is " + WorkflowEditor.getPrefGridXSize());
m_xGrid.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, true));
m_xGrid.addListener(SWT.Modify, new Listener() {
@Override
public void handleEvent(final Event event) {
settingsChanged();
}
});
addSelectOnFocusToText(m_xGrid);
Composite vert = new Composite(border, SWT.NONE);
vert.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
vert.setLayout(new GridLayout(2, true));
Label v = new Label(vert, SWT.NONE);
v.setText("vertical spacing (px):");
v.setToolTipText("Preference page default value is " + WorkflowEditor.getPrefGridYSize());
v.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
m_yGrid = new Text(vert, SWT.SINGLE | SWT.BORDER);
m_yGrid.setTextLimit(10);
m_yGrid.setToolTipText("Preference page default value is " + WorkflowEditor.getPrefGridYSize());
m_yGrid.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, true));
m_yGrid.getFont();
m_yGrid.addListener(SWT.Modify, new Listener() {
@Override
public void handleEvent(final Event event) {
settingsChanged();
}
});
addSelectOnFocusToText(m_yGrid);
}
use of org.eclipse.swt.widgets.Listener in project knime-core by knime.
the class EditorUISettingsDialog method addSelectOnFocusToText.
/**
* Add listener to argument text object to do a select-all when focus is gained.
*/
private static void addSelectOnFocusToText(final Text text) {
Listener listener = new Listener() {
@Override
public void handleEvent(final Event e) {
switch(e.type) {
case // selected via keyboard, bug 4322
SWT.FocusIn:
Text t = (Text) e.widget;
t.selectAll();
break;
case SWT.FocusOut:
t = (Text) e.widget;
t.clearSelection();
break;
default:
}
}
};
text.addListener(SWT.FocusIn, listener);
text.addListener(SWT.FocusOut, listener);
}
use of org.eclipse.swt.widgets.Listener in project knime-core by knime.
the class EditorUISettingsDialog method createNodeConnectionsPanel.
private void createNodeConnectionsPanel(final Composite parent) {
Group border = new Group(parent, SWT.SHADOW_IN);
border.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
border.setLayout(new GridLayout(2, true));
border.setText(" Node Connections ");
m_curvedConnections = new Button(border, SWT.CHECK);
m_curvedConnections.setText("Curved connections");
m_curvedConnections.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false));
m_curvedConnections.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(final Event arg0) {
settingsChanged();
}
});
Composite conn = new Composite(border, SWT.NONE);
conn.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
conn.setLayout(new GridLayout(2, true));
Label v = new Label(conn, SWT.NONE);
v.setText("Connection line width:");
v.setToolTipText("Preference page default value is " + WorkflowEditor.getPrefConnectionLineWidth());
v.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, true));
m_connectionWidth = new Combo(conn, SWT.READ_ONLY);
m_connectionWidth.setBounds(50, 50, 150, 65);
m_connectionWidth.setItems(new String[] { "1", "2", "3" });
m_connectionWidth.setToolTipText("Preference page default value is " + WorkflowEditor.getPrefConnectionLineWidth());
m_connectionWidth.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, true));
m_connectionWidth.getFont();
m_connectionWidth.addListener(SWT.Modify, new Listener() {
@Override
public void handleEvent(final Event event) {
settingsChanged();
}
});
}
use of org.eclipse.swt.widgets.Listener in project knime-core by knime.
the class EditorUISettingsDialog method createEnablePanel.
private void createEnablePanel(final Composite parent) {
Group border = new Group(parent, SWT.SHADOW_IN);
border.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
border.setLayout(new GridLayout(1, true));
border.setText(" Enable Grid ");
m_snapToGrid = new Button(border, SWT.CHECK);
m_snapToGrid.setText("Snap to grid (Alt-key disables snapping temporarily while moving nodes)");
m_snapToGrid.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, true, false));
m_snapToGrid.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(final Event arg0) {
settingsChanged();
}
});
m_showGrid = new Button(border, SWT.CHECK);
m_showGrid.setText("Show grid lines");
m_showGrid.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, true, false));
m_showGrid.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(final Event arg0) {
settingsChanged();
}
});
}
use of org.eclipse.swt.widgets.Listener in project knime-core by knime.
the class MultilineMetaGUIElement method attachScrollbarListener.
/**
* @param text
*/
private void attachScrollbarListener(Text text) {
Listener scrollBarListener = new Listener() {
@Override
public void handleEvent(final Event event) {
Text t = (Text) event.widget;
Rectangle r1 = t.getClientArea();
Rectangle r2 = t.computeTrim(r1.x, r1.y, r1.width, r1.height);
Point p = t.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
t.getHorizontalBar().setVisible(r2.width <= p.x);
t.getVerticalBar().setVisible(r2.height <= p.y);
if (event.type == SWT.Modify) {
t.getParent().layout(true);
t.showSelection();
}
}
};
text.addListener(SWT.Resize, scrollBarListener);
text.addListener(SWT.Modify, scrollBarListener);
}
Aggregations