Search in sources :

Example 46 with Listener

use of org.eclipse.swt.widgets.Listener in project tdi-studio-se by Talend.

the class TabFolderEditors method createComponents.

/**
     * qzhang Comment method "createComponents".
     */
private void createComponents() {
    CTabItem item = new CTabItem(tabFolderEditors, SWT.BORDER);
    //$NON-NLS-1$
    item.setText(Messages.getString("TabFolderEditors.FunParamTab.TitleText"));
    inOutMetaEditorContainer = new SashForm(tabFolderEditors, SWT.SMOOTH | SWT.HORIZONTAL | SWT.SHADOW_OUT);
    inOutMetaEditorContainer.setLayout(new RowLayout(SWT.HORIZONTAL));
    item.setControl(inOutMetaEditorContainer);
    createTableView();
    item = new CTabItem(tabFolderEditors, SWT.BORDER);
    //$NON-NLS-1$
    item.setText(Messages.getString("TabFolderEditors.PreviewTab.TitleText"));
    Composite composite = new Composite(tabFolderEditors, SWT.BORDER);
    GridLayout gridLayout = new GridLayout();
    gridLayout.numColumns = 1;
    composite.setLayout(gridLayout);
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));
    createPreview(composite, 700, 210);
    item.setControl(composite);
    tabFolderEditors.addListener(SWT.Selection, new Listener() {

        public void handleEvent(Event event) {
            lastSelectedTab = tabFolderEditors.getSelectionIndex();
        }
    });
    tabFolderEditors.setSelection(0);
}
Also used : SashForm(org.eclipse.swt.custom.SashForm) GridLayout(org.eclipse.swt.layout.GridLayout) Listener(org.eclipse.swt.widgets.Listener) Composite(org.eclipse.swt.widgets.Composite) RowLayout(org.eclipse.swt.layout.RowLayout) GridData(org.eclipse.swt.layout.GridData) Event(org.eclipse.swt.widgets.Event) SelectionEvent(org.eclipse.swt.events.SelectionEvent) CTabItem(org.eclipse.swt.custom.CTabItem)

Example 47 with Listener

use of org.eclipse.swt.widgets.Listener in project tdi-studio-se by Talend.

the class RowGeneratorUI method addParentListeners.

/**
     * qzhang Comment method "addParentListeners".
     * 
     * @param uiManager
     * @param uiProperties
     */
private void addParentListeners(final UIManager uiManager, final ExternalRowGeneratorUiProperties uiProperties) {
    rowGenUIParent.addListener(SWT.Close, new Listener() {

        @Override
        public void handleEvent(Event event) {
            if (uiManager.getRowGenResponse() == SWT.NONE) {
                uiManager.closeRowGenerator(SWT.CANCEL, false);
            }
        }
    });
    rowGenUIParent.addFocusListener(new FocusListener() {

        @Override
        public void focusGained(FocusEvent e) {
            updateBackground(false, true);
        }

        @Override
        public void focusLost(FocusEvent e) {
        }
    });
    // store size if not maximized
    if (rowGenUIParent instanceof Shell) {
        ((Shell) rowGenUIParent).addControlListener(new ControlListener() {

            @Override
            public void controlMoved(ControlEvent e) {
            }

            @Override
            public void controlResized(ControlEvent e) {
                if (!((Shell) e.getSource()).getMaximized()) {
                    ExternalRowGeneratorUiProperties.setBoundsRowGen(((Shell) e.getSource()).getBounds());
                }
            }
        });
    }
}
Also used : Shell(org.eclipse.swt.widgets.Shell) DisposeListener(org.eclipse.swt.events.DisposeListener) ControlListener(org.eclipse.swt.events.ControlListener) FocusListener(org.eclipse.swt.events.FocusListener) Listener(org.eclipse.swt.widgets.Listener) IModifiedBeanListener(org.talend.commons.ui.swt.tableviewer.IModifiedBeanListener) DisposeEvent(org.eclipse.swt.events.DisposeEvent) FocusEvent(org.eclipse.swt.events.FocusEvent) Event(org.eclipse.swt.widgets.Event) ControlEvent(org.eclipse.swt.events.ControlEvent) ModifiedBeanEvent(org.talend.commons.ui.swt.tableviewer.ModifiedBeanEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ControlListener(org.eclipse.swt.events.ControlListener) ControlEvent(org.eclipse.swt.events.ControlEvent) FocusListener(org.eclipse.swt.events.FocusListener) FocusEvent(org.eclipse.swt.events.FocusEvent)

Example 48 with Listener

use of org.eclipse.swt.widgets.Listener in project yyl_example by Relucent.

the class ImageViewer method addListeners.

void addListeners() {
    hBar.addListener(SWT.Selection, new Listener() {

        public void handleEvent(Event arg0) {
            hscroll();
        }
    });
    vBar.addListener(SWT.Selection, new Listener() {

        public void handleEvent(Event arg0) {
            vscroll();
        }
    });
    addListener(SWT.Resize, new Listener() {

        public void handleEvent(Event e) {
            resize();
        }
    });
    addListener(SWT.Paint, new Listener() {

        public void handleEvent(Event e) {
            paint(e);
        }
    });
}
Also used : Listener(org.eclipse.swt.widgets.Listener) Event(org.eclipse.swt.widgets.Event)

Example 49 with Listener

use of org.eclipse.swt.widgets.Listener in project yyl_example by Relucent.

the class ScrolledComposite_TEST method main.

public static void main(String[] args) {
    Display display = new Display();
    Color red = display.getSystemColor(SWT.COLOR_RED);
    Color blue = display.getSystemColor(SWT.COLOR_BLUE);
    Shell shell = new Shell(display);
    shell.setLayout(new FillLayout());
    // set the size of the scrolled content - method 1
    final ScrolledComposite sc1 = new ScrolledComposite(shell, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
    final Composite c1 = new Composite(sc1, SWT.NONE);
    sc1.setContent(c1);
    c1.setBackground(red);
    GridLayout layout = new GridLayout();
    layout.numColumns = 4;
    c1.setLayout(layout);
    Button b1 = new Button(c1, SWT.PUSH);
    b1.setText("first button");
    c1.setSize(c1.computeSize(SWT.DEFAULT, SWT.DEFAULT));
    // set the minimum width and height of the scrolled content - method 2
    final ScrolledComposite sc2 = new ScrolledComposite(shell, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
    sc2.setExpandHorizontal(true);
    sc2.setExpandVertical(true);
    final Composite c2 = new Composite(sc2, SWT.NONE);
    sc2.setContent(c2);
    c2.setBackground(blue);
    layout = new GridLayout();
    layout.numColumns = 4;
    c2.setLayout(layout);
    Button b2 = new Button(c2, SWT.PUSH);
    b2.setText("first button");
    sc2.setMinSize(c2.computeSize(SWT.DEFAULT, SWT.DEFAULT));
    Button add = new Button(shell, SWT.PUSH);
    add.setText("add children");
    final int[] index = new int[] { 0 };
    add.addListener(SWT.Selection, new Listener() {

        public void handleEvent(Event e) {
            index[0]++;
            Button button = new Button(c1, SWT.PUSH);
            button.setText("button " + index[0]);
            // reset size of content so children can be seen - method 1
            c1.setSize(c1.computeSize(SWT.DEFAULT, SWT.DEFAULT));
            c1.layout();
            button = new Button(c2, SWT.PUSH);
            button.setText("button " + index[0]);
            // reset the minimum width and height so children can be seen - method 2
            sc2.setMinSize(c2.computeSize(SWT.DEFAULT, SWT.DEFAULT));
            c2.layout();
        }
    });
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}
Also used : Shell(org.eclipse.swt.widgets.Shell) GridLayout(org.eclipse.swt.layout.GridLayout) Listener(org.eclipse.swt.widgets.Listener) Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) Button(org.eclipse.swt.widgets.Button) Color(org.eclipse.swt.graphics.Color) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) Event(org.eclipse.swt.widgets.Event) FillLayout(org.eclipse.swt.layout.FillLayout) Display(org.eclipse.swt.widgets.Display)

Example 50 with Listener

use of org.eclipse.swt.widgets.Listener in project Main by SpartanRefactoring.

the class SpartanWidgetHandler method setMovable.

static void setMovable(final Display d, final Control source, final Shell target) {
    final Listener l = new Listener() {

        Point origin;

        @Override
        public void handleEvent(final Event e) {
            switch(e.type) {
                case SWT.MouseUp:
                    origin = null;
                    break;
                case SWT.MouseDown:
                    origin = new Point(e.x, e.y);
                    break;
                case SWT.MouseMove:
                    if (origin != null) {
                        final Point p = d.map(target, null, e.x, e.y);
                        target.setLocation(p.x - origin.x, p.y - origin.y);
                    }
                    break;
                default:
                    break;
            }
        }
    };
    source.addListener(SWT.MouseDown, l);
    source.addListener(SWT.MouseUp, l);
    source.addListener(SWT.MouseMove, l);
}
Also used : Listener(org.eclipse.swt.widgets.Listener)

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