Search in sources :

Example 86 with Listener

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);
}
Also used : Group(org.eclipse.swt.widgets.Group) GridLayout(org.eclipse.swt.layout.GridLayout) Listener(org.eclipse.swt.widgets.Listener) Composite(org.eclipse.swt.widgets.Composite) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label) Event(org.eclipse.swt.widgets.Event) Text(org.eclipse.swt.widgets.Text)

Example 87 with Listener

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);
}
Also used : Listener(org.eclipse.swt.widgets.Listener) Event(org.eclipse.swt.widgets.Event) Text(org.eclipse.swt.widgets.Text)

Example 88 with 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();
        }
    });
}
Also used : Group(org.eclipse.swt.widgets.Group) GridLayout(org.eclipse.swt.layout.GridLayout) Listener(org.eclipse.swt.widgets.Listener) Composite(org.eclipse.swt.widgets.Composite) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label) Event(org.eclipse.swt.widgets.Event) Combo(org.eclipse.swt.widgets.Combo)

Example 89 with Listener

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();
        }
    });
}
Also used : Group(org.eclipse.swt.widgets.Group) GridLayout(org.eclipse.swt.layout.GridLayout) Listener(org.eclipse.swt.widgets.Listener) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) Event(org.eclipse.swt.widgets.Event)

Example 90 with Listener

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);
}
Also used : ModifyListener(org.eclipse.swt.events.ModifyListener) Listener(org.eclipse.swt.widgets.Listener) Rectangle(org.eclipse.swt.graphics.Rectangle) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Event(org.eclipse.swt.widgets.Event) Text(org.eclipse.swt.widgets.Text) Point(org.eclipse.swt.graphics.Point)

Aggregations

Listener (org.eclipse.swt.widgets.Listener)214 Event (org.eclipse.swt.widgets.Event)199 SelectionEvent (org.eclipse.swt.events.SelectionEvent)101 GridData (org.eclipse.swt.layout.GridData)95 Composite (org.eclipse.swt.widgets.Composite)82 GridLayout (org.eclipse.swt.layout.GridLayout)78 Point (org.eclipse.swt.graphics.Point)60 SelectionListener (org.eclipse.swt.events.SelectionListener)58 Button (org.eclipse.swt.widgets.Button)58 Label (org.eclipse.swt.widgets.Label)53 Text (org.eclipse.swt.widgets.Text)49 Table (org.eclipse.swt.widgets.Table)46 DisposeListener (org.eclipse.swt.events.DisposeListener)37 DisposeEvent (org.eclipse.swt.events.DisposeEvent)36 Rectangle (org.eclipse.swt.graphics.Rectangle)35 FocusEvent (org.eclipse.swt.events.FocusEvent)34 TableColumn (org.eclipse.swt.widgets.TableColumn)34 Shell (org.eclipse.swt.widgets.Shell)31 KeyEvent (org.eclipse.swt.events.KeyEvent)30 Group (org.eclipse.swt.widgets.Group)30