Java Code Examples for org.eclipse.swt.widgets.ToolItem#getBounds()
The following examples show how to use
org.eclipse.swt.widgets.ToolItem#getBounds() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbapGitStagingView.java From ADT_Frontend with MIT License | 6 votes |
/** * Action for switching a repository */ private void createRepositorySelectionToolbarAction() { this.actionSwitchRepository = new Action(Messages.AbapGitStaging_switch_repository, SWT.DROP_DOWN) { @Override public void runWithEvent(Event event) { Widget widget = event.widget; if (widget instanceof ToolItem) { ToolItem item = (ToolItem) widget; Rectangle bounds = item.getBounds(); event.detail = SWT.ARROW; event.x = bounds.x; event.y = bounds.y + bounds.height; item.notifyListeners(SWT.Selection, event); } } }; this.actionSwitchRepository .setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(AbapGitUIPlugin.PLUGIN_ID, "icons/obj/repository.png")); //$NON-NLS-1$ this.actionSwitchRepository.setMenuCreator(new SwitchRepositoryMenuCreator(this, this.stagingUtil)); }
Example 2
Source File: PulldownHandler.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 6 votes |
public Object execute(ExecutionEvent event) throws ExecutionException { // open the button's dropdown menu Object trigger = event.getTrigger(); if (trigger instanceof Event) { Widget widget = ((Event) trigger).widget; if (widget instanceof ToolItem) { ToolItem toolItem = (ToolItem) widget; Listener[] listeners = toolItem.getListeners(SWT.Selection); if (listeners.length > 0) { Listener listener = listeners[0]; // should be only one listener // send an event to the widget to open the menu // see CommandContributionItem.openDropDownMenu(Event) Event e = new Event(); e.type = SWT.Selection; e.widget = widget; e.detail = 4; // dropdown detail e.y = toolItem.getBounds().height; // position menu listener.handleEvent(e); } } } return null; }
Example 3
Source File: DropDownAction.java From n4js with Eclipse Public License 1.0 | 5 votes |
@Override public void runWithEvent(final Event event) { if (event.widget instanceof ToolItem) { final ToolItem toolItem = (ToolItem) event.widget; final Control control = toolItem.getParent(); @SuppressWarnings("hiding") final Menu menu = getMenu(control); final Rectangle bounds = toolItem.getBounds(); final Point topLeft = new Point(bounds.x, bounds.y + bounds.height); menu.setLocation(control.toDisplay(topLeft)); menu.setVisible(true); } }
Example 4
Source File: ShowHistoryAction.java From n4js with Eclipse Public License 1.0 | 5 votes |
@Override public void runWithEvent(Event event) { if (event.widget instanceof ToolItem) { final ToolItem toolItem = (ToolItem) event.widget; final Control control = toolItem.getParent(); final Menu menu = getMenuCreator().getMenu(control); final Rectangle bounds = toolItem.getBounds(); final Point topLeft = new Point(bounds.x, bounds.y + bounds.height); menu.setLocation(control.toDisplay(topLeft)); menu.setVisible(true); } }
Example 5
Source File: DropDownSelectionListener.java From AppleCommander with GNU General Public License v2.0 | 5 votes |
/** * Handle selection events. */ public void widgetSelected(SelectionEvent event) { /** * A selection event will be fired when a drop down tool * item is selected in the main area and in the drop * down arrow. Examine the event detail to determine * where the widget was selected. */ if (event.detail == SWT.ARROW) { /* * The drop down arrow was selected. */ if (visible) { // Hide the menu to give the Arrow the appearance of being a toggle button. setMenuVisible(false); } else { // Position the menu below and vertically aligned with the the drop down tool button. final ToolItem toolItem = (ToolItem) event.widget; final ToolBar toolBar = toolItem.getParent(); Rectangle toolItemBounds = toolItem.getBounds(); Point point = toolBar.toDisplay(new Point(toolItemBounds.x, toolItemBounds.y)); menu.setLocation(point.x, point.y + toolItemBounds.height); setMenuVisible(true); } } else { /* * Main area of drop down tool item selected. * An application would invoke the code to perform the action for the tool item. */ } }
Example 6
Source File: XFindPanel.java From xds-ide with Eclipse Public License 1.0 | 5 votes |
private Point getToolItemLocation(ToolItem item) { Rectangle rect = item.getBounds(); Point point = new Point(rect.x, rect.y + rect.height); point = toolBar.toDisplay(point); if (Util.isMac()) { point.y += 5; } return point; }
Example 7
Source File: SWTEnvironment.java From tuxguitar with GNU Lesser General Public License v2.1 | 5 votes |
public int getToolItemWidth(ToolItem control) { int style = control.getStyle(); if((style & SWT.SEPARATOR) == 0 && PLATFORM_COCOA.equals(SWT.getPlatform())) { return ((style & SWT.HORIZONTAL) != 0 ? control.getBounds().width : control.getBounds().height); } return control.getWidth(); }
Example 8
Source File: SWTToolBar.java From tuxguitar with GNU Lesser General Public License v2.1 | 5 votes |
private int findLeftMargin(ToolItem item) { ToolItem previousItem = findPreviousItem(item); if( previousItem != null ) { Rectangle itemBounds = item.getBounds(); Rectangle previousBounds = previousItem.getBounds(); // left + right margins return Math.max(0, (findPosition(itemBounds) - (findPosition(previousBounds) + findSize(previousBounds)))); } return 0; }
Example 9
Source File: NewCoolbarItem.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
@Override public void widgetSelected(final SelectionEvent event) { final ToolItem item = (ToolItem) event.widget; final Rectangle rect = item.getBounds(); final Point pt = item.getParent().toDisplay(new Point(rect.x, rect.y)); menu.setLocation(pt.x, pt.y + rect.height); menu.setVisible(true); }
Example 10
Source File: MainToolBar.java From arx with Apache License 2.0 | 4 votes |
/** * Performs layouting. */ private void layout() { // Disable redrawing toolbar.setRedraw(false); // Adjust size of items and composite Rectangle bounds = toolbar.getBounds(); int remaining = toolbar.getBounds().width; for (final ToolItem item : toolitems) { remaining -= item.getBounds().width; } remaining -= OFFSET; infoComposite.setSize(remaining, bounds.height); infoItem.setWidth(remaining); int locationY = (infoComposite.getBounds().height - labelSelected.getBounds().height)/2; // Layout label int locationX = remaining - labelApplied.getSize().x; labelApplied.setLocation(locationX, locationY); if (locationX < 0) labelApplied.setVisible(false); else labelApplied.setVisible(true); // Layout label locationX -= labelSelected.getSize().x + OFFSET; labelSelected.setLocation(locationX, locationY); if (locationX < 0) labelSelected.setVisible(false); else labelSelected.setVisible(true); // Layout label locationX -= labelTransformations.getSize().x + OFFSET; labelTransformations.setLocation(locationX, locationY); if (locationX < 0) labelTransformations.setVisible(false); else labelTransformations.setVisible(true); // Layout label locationX -= labelAttribute.getSize().x + OFFSET; labelAttribute.setLocation(locationX, locationY); if (locationX < 0) labelAttribute.setVisible(false); else labelAttribute.setVisible(true); // Redraw toolbar.setRedraw(true); }