public void newFileDropDown() { // Drop down a list below the "New" icon (new.png) // First problem: where is that icon? XulToolbarbutton button = (XulToolbarbutton) this.mainToolbar.getElementById( "file-new" ); Object object = button.getManagedObject(); if ( object instanceof ToolItem ) { // OK, let's determine the location of this widget... // ToolItem item = (ToolItem) object; Rectangle bounds = item.getBounds(); org.eclipse.swt.graphics.Point p = item.getParent().toDisplay( new org.eclipse.swt.graphics.Point( bounds.x, bounds.y ) ); fileMenus.setLocation( p.x, p.y + bounds.height ); fileMenus.setVisible( true ); } }
@Override public void widgetSelected( SelectionEvent e ) { Menu menu = new Menu( shell ); for ( final PerspectiveData perspectiveData : perspectiveList ) { MenuItem item = new MenuItem( menu, SWT.CHECK ); if ( perspectiveData.isHidden() ) { item.setEnabled( false ); } if ( activePerspective.getId().equals( perspectiveData.getId() ) ) { item.setSelection( true ); } item.setText( perspectiveData.getName() ); item.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected( SelectionEvent selectionEvent ) { Spoon.getInstance().loadPerspective( perspectiveData.getId() ); swtToolbar.forceFocus(); } } ); } ToolItem item = (ToolItem) e.widget; Rectangle rect = item.getBounds(); Point pt = item.getParent().toDisplay( new Point( rect.x, rect.y + rect.height ) ); menu.setLocation( pt.x, pt.y ); menu.setVisible( true ); } } );
Rectangle rect = item.getBounds(); org.eclipse.swt.graphics.Point pt = item.getParent().toDisplay( new org.eclipse.swt.graphics.Point( rect.x, rect.y + rect.height ) );
@Override public boolean matches( Widget widget ) { if( widget instanceof ToolItem ) { ToolItem item = ( ToolItem )widget; ToolBar toolBar = item.getParent(); return toolBar.getItem( 0 ) == item; } return false; } };
@Override public Node getParentNode() { ToolItem item = getToolItem(); ToolBar parent = item.getParent(); if (parent != null) { Element element = getElement(parent); return element; } return null; }
public Node getParentNode() { ToolItem item = getToolItem(); ToolBar parent = item.getParent(); if (parent != null) { Element element = getElement(parent); return element; } return null; }
@Override public boolean matches( Widget widget ) { if( widget instanceof ToolItem ) { ToolItem item = ( ToolItem )widget; ToolBar toolBar = item.getParent(); return toolBar.getItem( toolBar.getItemCount() - 1 ) == item; } return false; } };
public static Control getParent(Widget item){ if(item instanceof Control){ return ((Control) item).getParent(); }else if(item instanceof ToolItem){ return ((ToolItem) item).getParent(); }else if(item instanceof CoolItem){ return ((CoolItem) item).getParent(); }else{ throw new ActionException("Can not get parent from type " + item.getClass()); } }
static int /*long*/ MenuItemSelectedProc (int /*long*/ widget, int /*long*/ user_data) { Display display = Display.getCurrent (); ToolItem item = (ToolItem) display.getWidget (user_data); if (item != null) { return item.getParent ().menuItemSelected (widget, item); } return 0; }
void renderInitialization( final ToolItem toolItem ) throws IOException { JSWriter writer = JSWriter.getWriterFor( toolItem ); ToolBar toolBar = toolItem.getParent(); Boolean flat = Boolean.valueOf( ( toolBar.getStyle() & SWT.FLAT ) != 0 ); Boolean vertical = Boolean.valueOf( ( toolBar.getStyle() & SWT.VERTICAL ) != 0 ); writer.newWidget( QX_TYPE, new Object[]{ flat, vertical } ); writer.call( toolBar, "add", new Object[]{ toolItem } ); }
static long /*int*/ MenuItemSelectedProc (long /*int*/ widget, long /*int*/ user_data) { Display display = Display.getCurrent (); ToolItem item = (ToolItem) display.getWidget (user_data); if (item != null) { return item.getParent ().menuItemSelected (widget, item); } return 0; }
static int /*long*/ MenuItemSelectedProc (int /*long*/ widget, int /*long*/ user_data) { Display display = Display.getCurrent (); ToolItem item = (ToolItem) display.getWidget (user_data); if (item != null) { return item.getParent ().menuItemSelected (widget, item); } return 0; }
public void setImage( Image i ) { if (i != null) i.setBackground(item.getParent().getBackground()); item.setImage(i); }
public ProfilePreferenceTree(Composite parentComposite) { super(parentComposite, FormatterMessages.ModifyDialog_filter_label, FormatterMessages.ModifyDialog_filter_hint); // calculate rigth margin width ToolBar modifyAllToolbar= ModifyAll.createToolItem(parentComposite, fImages).getParent(); fRightMargin= modifyAllToolbar.computeSize(SWT.DEFAULT, SWT.DEFAULT).x - 12; modifyAllToolbar.dispose(); }
@Override public void widgetSelected(SelectionEvent e) { fControl.setFocus(); Rectangle rect= dropDown.getBounds(); Point pt= dropDown.getParent().toDisplay(new Point(rect.x, rect.y)); menu.setLocation(pt.x, pt.y + rect.height); menu.setVisible(true); } });
@Override public void runWithEvent(Event event) { if (event.widget instanceof ToolItem) { ToolItem toolItem= (ToolItem) event.widget; Control control= toolItem.getParent(); Menu menu= getMenu(control); Rectangle bounds= toolItem.getBounds(); Point topLeft= new Point(bounds.x, bounds.y + bounds.height); menu.setLocation(control.toDisplay(topLeft)); menu.setVisible(true); } }
/** Returns this corner's position on the given ToolItem in display coordinates. */ public Point getPosition(ToolItem item) { ToolBar toolbar = item.getParent(); return toolbar.getDisplay().map(toolbar, null, getPosition(item.getBounds())); }
static Image getImage( ToolItem item ) { Image result; if( item.getEnabled() && item.getParent().getEnabled() ) { result = item.getImage(); } else { result = item.getDisabledImage(); if( result == null ) { result = item.getImage(); } } return result; }
static Image getImage( final ToolItem toolItem ) { Image result; if( toolItem.getEnabled() && toolItem.getParent().getEnabled() ) { result = toolItem.getImage(); } else { result = toolItem.getDisabledImage(); if( result == null ) { result = toolItem.getImage(); } } return result; }
private void updateToolItems( PageDescriptor descriptor, String title ) { for( ToolItem toolItem : pageSwitcher.getItems() ) { if( toolItem.getData() == descriptor ) { toolItem.setText( title ); toolItem.getParent().getParent().layout( true, true ); } } }