label = new Label( parent, SWT.BORDER ); label.setText( "0 object(s)" ); parent.addListener( SWT.Resize, new Listener() { public void handleEvent( Event e ) { layout();
composite.addListener( SWT.Resize, new Listener() { public void handleEvent( Event e ) { Rectangle rect = composite.getClientArea();
composite.addListener( SWT.Resize, new Listener() { public void handleEvent( Event e ) { Rectangle rect = composite.getClientArea();
composite.addListener( SWT.Resize, new Listener() { public void handleEvent( Event e ) { Rectangle rect = composite.getClientArea();
@Override public void addListener( int type, Listener l ) { browser.addListener( type, l ); }
composite.addListener(SWT.Resize, new Listener() { public void handleEvent(Event e) { changeImage();
protected CompositeEditorHelper(Composite composite) { this.composite = composite; composite.addListener(SWT.Selection, this); composite.addListener(SWT.DefaultSelection, this); composite.addListener(SWT.Dispose, this); compositeEditor = createControlEditor(composite); compositeEditor.horizontalAlignment = SWT.LEFT; compositeEditor.grabHorizontal = true; }
/** * Initialize */ public TableTooltips(TableViewSWT tv, Composite composite) { this.tv = tv; this.composite = composite; mainShell = composite.getShell(); composite.addListener(SWT.Dispose, this); composite.addListener(SWT.KeyDown, this); composite.addListener(SWT.MouseMove, this); composite.addListener(SWT.MouseHover, this); composite.addListener(SWT.MouseExit, this); mainShell.addListener(SWT.Deactivate, this); tv.getComposite().addListener(SWT.Deactivate, this); }
/** * Performs an asynchronous layout on the given composite anytime that it is resized. * <p> * This can often fix graphical glitches with resize-to-fit layouts, such as a `TableColumnLayout`. */ public static void asyncLayoutOnResize(Composite cmp) { cmp.addListener(SWT.Resize, e -> asyncLayout(cmp)); // trigger the first one by hand asyncLayout(cmp); }
/** * Create the control of the inner editor. * * Must be called by subclass. */ public Composite createInnerPartControl(Composite parent, final IEditorPart e) { Composite content = new Composite(parent, SWT.NONE); content.setLayout(new FillLayout()); e.createPartControl(content); parent.addListener(SWT.Activate, event -> { if (event.type == SWT.Activate) { activateEditor(e); } }); return content; }
private void installCompositeListeners(Composite c) { if (!c.isDisposed()) { printAddListener(c, "PAINT"); //$NON-NLS-1$ c.addPaintListener(paintListener); printAddListener(c, "MOUSETRACK"); //$NON-NLS-1$ c.addMouseTrackListener(mouseTrackListener); printAddListener(c, "SWT.MenuDetect"); //$NON-NLS-1$ c.addListener(SWT.MenuDetect, compositeListener); printAddListener(c, "SWT.MouseDown"); //$NON-NLS-1$ c.addListener(SWT.MouseDown, compositeListener); printAddListener(c, "SWT.MouseDoubleClick"); //$NON-NLS-1$ c.addListener(SWT.MouseDoubleClick, compositeListener); } }
private void installCompositeListeners(Composite c) { if (!c.isDisposed()) { printAddListener(c, "PAINT"); //$NON-NLS-1$ c.addPaintListener(paintListener); printAddListener(c, "MOUSETRACK"); //$NON-NLS-1$ c.addMouseTrackListener(mouseTrackListener); printAddListener(c, "SWT.MenuDetect"); //$NON-NLS-1$ c.addListener(SWT.MenuDetect, compositeListener); printAddListener(c, "SWT.MouseDown"); //$NON-NLS-1$ c.addListener(SWT.MouseDown, compositeListener); printAddListener(c, "SWT.MouseDoubleClick"); //$NON-NLS-1$ c.addListener(SWT.MouseDoubleClick, compositeListener); } }
private void installCompositeListeners(Composite c) { if(!c.isDisposed()) { printAddListener(c, "PAINT"); //$NON-NLS-1$ c.addPaintListener(paintListener); printAddListener(c, "MOUSETRACK"); //$NON-NLS-1$ c.addMouseTrackListener(mouseTrackListener); printAddListener(c, "SWT.MenuDetect"); //$NON-NLS-1$ c.addListener(SWT.MenuDetect, compositeListener); printAddListener(c, "SWT.MouseDown"); //$NON-NLS-1$ c.addListener(SWT.MouseDown, compositeListener); printAddListener(c, "SWT.MouseDoubleClick"); //$NON-NLS-1$ c.addListener(SWT.MouseDoubleClick, compositeListener); } }
private void installActivationListener() { if (activationListener == null) { activationListener = new Listener() { @Override public void handleEvent(Event event) { boolean wasHeaderActive = event.widget != getContainer(); int activePage = getActivePage(); if (SharedHeaderFormEditor.this.wasHeaderActive != wasHeaderActive && activePage != -1 && pages.get(activePage) instanceof IEditorPart) { if (wasHeaderActive) { deactivateSite(true, true); } else { activateSite(); } } SharedHeaderFormEditor.this.wasHeaderActive = wasHeaderActive; } }; getContainer().addListener(SWT.Activate, activationListener); getHeaderForm().getForm().getForm().getHead().addListener(SWT.Activate, activationListener); } }
/** * <p> * Adds a {@link Listener} for the defined eventType. The listener will be notified when the event occurs anywhere * on the {@link Composite}. It doesn't matter if the {@link Composite} holds controls or not. * </p> * * @since 0.10 */ public void addGroupedListener( int eventType, Listener listener ) throws IllegalArgumentException, IllegalStateException { whenNull( listener ).throwIllegalArgument( "Listener must not be null" ); Composite facade = getFacade(); facade.addListener( eventType, listener ); }
/** * @param area * @param event id * @param listener */ public static void addListenerAndChildren(Composite area, int event, Listener listener) { area.addListener(event, listener); Control[] children = area.getChildren(); for (int i = 0; i < children.length; i++) { Control child = children[i]; if (child instanceof Composite) { addListenerAndChildren((Composite) child, event, listener); } else { child.addListener(event, listener); } } }
/** * Initializes automatic resize of the tree control columns. The size of these will be adjusted when a node is * expanded or collapsed and when the tree changes size. * * @param tree * the tree to resize */ private void installAutomaticResize(final Tree tree) { Listener listener = new Listener() { public void handleEvent(Event e) { packColumnsAsync(tree); } }; // Automatically resize columns when we expand tree nodes. tree.addListener(SWT.Collapse, listener); tree.addListener(SWT.Expand, listener); tree.getParent().addListener(SWT.Resize, listener); }
private Composite getHostPane() { if (hostPane != null) { setHostSize(); // Always start with the persisted size return hostPane; } // Create one hostPane = new Composite(trimStackTB.getShell(), SWT.NONE); hostPane.setData(ShellActivationListener.DIALOG_IGNORE_KEY, Boolean.TRUE); setHostSize(); hostPane.addListener(SWT.Traverse, escapeListener); // Set a special layout that allows resizing fixedSides = getFixedSides(); hostPane.setLayout(new TrimPaneLayout(toolControl, fixedSides)); return hostPane; }
private void installActivationListener() { if (activationListener == null) { activationListener = event -> { boolean wasHeaderActive = event.widget != getContainer(); int activePage = getActivePage(); if (SharedHeaderFormEditor.this.wasHeaderActive != wasHeaderActive && activePage != -1 && pages.get(activePage) instanceof IEditorPart) { if (wasHeaderActive) { deactivateSite(true, true); } else { activateSite(); } } SharedHeaderFormEditor.this.wasHeaderActive = wasHeaderActive; }; getContainer().addListener(SWT.Activate, activationListener); getHeaderForm().getForm().getForm().getHead().addListener(SWT.Activate, activationListener); } }
public static void main(String[] args) { Display display = new Display(); final Shell shell = new Shell(display); shell.open(); final Composite b = new Composite(shell, SWT.NONE); b.setBounds(20, 20, 80, 80); b.setBackground(display.getSystemColor(SWT.COLOR_BLUE)); b.addListener(SWT.MouseDown, new Listener() { public void handleEvent(Event e) { Tracker tracker = new Tracker(b.getParent(), SWT.RESIZE); tracker.setStippled(true); Rectangle rect = b.getBounds(); tracker.setRectangles(new Rectangle[] { rect }); if (tracker.open()) { Rectangle after = tracker.getRectangles()[0]; b.setBounds(after); } tracker.dispose(); } }); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }