List of usage examples for org.eclipse.jface.action ToolBarManager getControl
public ToolBar getControl()
From source file:com.aptana.ide.server.ui.views.GenericServersView.java
License:Open Source License
/** * @see org.eclipse.ui.IWorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite) */// w ww. j av a 2 s . c om public void createPartControl(Composite parent) { GridLayout gridLayout = new GridLayout(); gridLayout.marginWidth = 0; gridLayout.marginHeight = 0; parent.setLayout(gridLayout); createTableViewer(parent); // PreferenceUtils.registerBackgroundColorPreference(serverViewer.getControl(), // "com.aptana.ide.core.ui.background.color.serversView"); //$NON-NLS-1$ createPopupMenu(); createToolbar(); ToolBarManager toolBarManager = (ToolBarManager) getViewSite().getActionBars().getToolBarManager(); final Image smallGlobe = ServerUIPlugin.getImageDescriptor("icons/server/small_globe.png").createImage(); //$NON-NLS-1$ final Image jaxerImage = ServerUIPlugin.getImageDescriptor("icons/server/jaxer_decorator.gif") //$NON-NLS-1$ .createImage(); final ToolBar control = toolBarManager.getControl(); final ToolbarTooltip toolbarTooltip = new ToolbarTooltip(control, "com.aptana.ide.server.ui.servers_context_view") { //$NON-NLS-1$ @Override protected Composite createToolTipContentArea(Event event, Composite parent) { Composite sm = new Composite(parent, SWT.NONE); sm.setLayout(GridLayoutFactory.fillDefaults().margins(10, 10).create()); FormText ts = new FormText(sm, SWT.NONE); ts.setImage("jaxer", jaxerImage); //$NON-NLS-1$ ts.setImage("web", smallGlobe); //$NON-NLS-1$ ts.setText(Messages.GenericServersView_LEGEND, true, false); ts.setLayoutData(new GridData(320, 75)); return sm; } }; this.serverViewer.getControl().addDisposeListener(new DisposeListener() { public void widgetDisposed(DisposeEvent e) { smallGlobe.dispose(); jaxerImage.dispose(); toolbarTooltip.deactivate(); } }); TreeViewerSorter.bind(serverViewer); }
From source file:com.archimatetool.editor.actions.AbstractDropDownAction.java
License:Open Source License
/** * Show the menu at the bottom of a Toolbar Manager * @param manager//from w w w. jav a2s . co m */ public void showMenu(ToolBarManager manager) { showMenu(manager.getControl()); }
From source file:com.architexa.org.eclipse.gef.ui.palette.customize.PaletteCustomizerDialog.java
License:Open Source License
/** * Uses a ToolBarManager to create the ToolBar in the outline part of the * dialog. The Actions used in the ToolBarManager are those that are * created in {@link #createOutlineActions()}. * /* w w w . ja va 2 s .c o m*/ * @param parent The Composite to which the ToolBar is to be added * @return The newly created ToolBar */ protected Control createOutlineToolBar(Composite parent) { // A customized composite for the toolbar final Composite composite = new Composite(parent, SWT.NONE) { public Rectangle getClientArea() { Rectangle area = super.getClientArea(); area.x += 2; area.y += 2; area.height -= 2; area.width -= 4; return area; } public Point computeSize(int wHint, int hHint, boolean changed) { Point size = super.computeSize(wHint, hHint, changed); size.x += 4; size.y += 2; return size; } }; composite.setFont(parent.getFont()); composite.setLayout(new FillLayout()); // A paint listener that draws an etched border around the toolbar composite.addPaintListener(new PaintListener() { public void paintControl(PaintEvent e) { Rectangle area = composite.getBounds(); GC gc = e.gc; gc.setLineStyle(SWT.LINE_SOLID); gc.setForeground(ColorConstants.buttonDarker); gc.drawLine(area.x, area.y, area.x + area.width - 2, area.y); gc.drawLine(area.x, area.y, area.x, area.y + area.height - 1); gc.drawLine(area.x + area.width - 2, area.y, area.x + area.width - 2, area.y + area.height - 1); gc.setForeground(ColorConstants.buttonLightest); gc.drawLine(area.x + 1, area.y + 1, area.x + area.width - 3, area.y + 1); gc.drawLine(area.x + area.width - 1, area.y + 1, area.x + area.width - 1, area.y + area.height - 1); gc.drawLine(area.x + 1, area.y + 1, area.x + 1, area.y + area.height - 1); } }); // Create the ToolBarManager and add all the actions to it ToolBarManager tbMgr = new ToolBarManager(SWT.FLAT | SWT.HORIZONTAL); List actions = getOutlineActions(); for (int i = 0; i < actions.size(); i++) { tbMgr.add(new ToolbarDropdownContributionItem(((IAction) actions.get(i)))); } tbMgr.createControl(composite); tbMgr.getControl().setFont(composite.getFont()); // By default, the ToolBarManager does not set text on ToolItems. Since, // we want to display the text, we will have to do it manually. ToolItem[] items = tbMgr.getControl().getItems(); for (int i = 0; i < items.length; i++) { ToolItem item = items[i]; item.setText(((IAction) actions.get(i)).getText()); } return tbMgr.getControl(); }
From source file:com.google.code.t4eclipse.core.eclipse.helper.EclipseToolBarHelper.java
License:Open Source License
/** * only for debugging purpose//w w w . ja va 2 s.co m * * @return all eclipse toolbars */ public String[] printAllToolBar() { ArrayList<String> list = new ArrayList<String>(); Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); Object data = shell.getData(); if (data instanceof ApplicationWindow) { ApplicationWindow window = (ApplicationWindow) data; CoolBarManager coolMng = window.getCoolBarManager(); if (coolMng != null) { IContributionItem[] items = coolMng.getItems(); for (int i = 0; i < items.length; i++) { if (items[i] instanceof ToolBarContributionItem) { ToolBarContributionItem item = (ToolBarContributionItem) items[i]; ToolBarManager toolMng = (ToolBarManager) item.getToolBarManager(); ToolBar tb = toolMng.getControl(); ToolItem[] toolItems = tb.getItems(); for (int j = 0; j < toolItems.length; j++) { ToolItem toolItem = toolItems[j]; list.add(getToolItemStr(toolItem)); } } } } } return list.toArray(new String[0]); }
From source file:com.google.code.t4eclipse.core.eclipse.helper.EclipseToolBarHelper.java
License:Open Source License
private ToolItem locateToolItem(ToolBarManager toolMng, String id) { return locateToolItem(toolMng.getControl(), id); }
From source file:com.google.code.t4eclipse.core.utility.MenuUtility.java
License:Open Source License
public static ToolBar getviewToolBar(IWorkbenchPart part) { IViewSite site = (IViewSite) part.getSite(); IActionBars bars = site.getActionBars(); ToolBarManager toolBarManager = (ToolBarManager) bars.getToolBarManager(); return toolBarManager.getControl(); }
From source file:com.google.code.t4eclipse.tools.ktable.model.EclipseModelDataProvider.java
License:Open Source License
public MainToolBarItemModel[] getToolBarModelList() { Shell shell = PlatformUI.getWorkbench().getWorkbenchWindows()[0].getShell(); Object data = shell.getData(); if (data instanceof ApplicationWindow) { Vector<MainToolBarItemModel> v = new Vector<MainToolBarItemModel>(); ApplicationWindow window = (ApplicationWindow) data; CoolBarManager coolMng = window.getCoolBarManager(); if (coolMng != null) { //coolMng. IContributionItem[] items = coolMng.getItems(); if (items != null) { for (int i = 0; i < items.length; i++) { //System.out.println(items[i].getClass().getName()); if (items[i] instanceof ToolBarContributionItem) { ToolBarContributionItem item = (ToolBarContributionItem) items[i]; ToolBarManager toolMng = (ToolBarManager) item.getToolBarManager(); ToolBar tb = toolMng.getControl(); if (tb != null) { ToolItem[] toolItems = tb.getItems(); if (toolItems != null) { for (int j = 0; j < toolItems.length; j++) { MainToolBarItemModel model = new MainToolBarItemModel(toolItems[j]); v.add(model); }//from w w w.j a v a 2 s .c o m } } } } return v.toArray(new MainToolBarItemModel[] {}); } } } return null; }
From source file:com.google.code.t4eclipse.tools.ktable.model.EclipseModelDataProvider.java
License:Open Source License
@SuppressWarnings({ "unused", "null" })
public LocalToolBarItemModel[] getLocalToolBarList(String viewID) {
IViewPart vp = EclipseWorkPartHelper.getDefault().getViewInCurrentpage(viewID);
IActionBars bars = vp.getViewSite().getActionBars();
//bars.getToolBarManager()
if (vp != null) {
Vector<LocalToolBarItemModel> v = new Vector<LocalToolBarItemModel>();
IToolBarManager toolbarM = vp.getViewSite().getActionBars().getToolBarManager();
if (toolbarM instanceof ToolBarManager) {
ToolBarManager tbm = (ToolBarManager) toolbarM;
ToolBar tb = tbm.getControl();
ToolItem[] items = tb.getItems();
for (ToolItem item : items) {
LocalToolBarItemModel model = getToolBarModel(item);
if (model != null) {
v.add(model);/* w w w .j a v a 2 s. c o m*/
}
}
return v.toArray(new LocalToolBarItemModel[] {});
}
}
return null;
}
From source file:com.google.code.t4eclipse.tools.model.ModelData.java
License:Open Source License
/** * this method contruct the LocalViewToolBarModel of a specail view<br> * assert: a view with viewID as its id exist on current eclipse page.<br> * * @param viewID/*from w w w.ja v a 2 s .c o m*/ * the id of the view. * @return A not null arraylist. (but may be empty) */ public static List<LocalViewToolBarModel> getLocalToolBarModel(String viewID) { List<LocalViewToolBarModel> list = new ArrayList<LocalViewToolBarModel>(); // add content of the list. IViewPart vp = EclipseWorkPartHelper.getDefault().getViewInCurrentpage(viewID); if (vp != null) { IToolBarManager toolbarM = vp.getViewSite().getActionBars().getToolBarManager(); if (toolbarM instanceof ToolBarManager) { ToolBarManager tbm = (ToolBarManager) toolbarM; ToolBar tb = tbm.getControl(); ToolItem[] items = tb.getItems(); for (ToolItem item : items) { LocalViewToolBarModel model = getToolBarModel(item); if (model != null) { list.add(model); } } } } // end of add return list; }
From source file:com.google.code.t4eclipse.tools.utility.EclipseToolBarUtility.java
License:Open Source License
public static List<EclipseToolBarModel> getToolBarModel() { ArrayList<EclipseToolBarModel> list = new ArrayList<EclipseToolBarModel>(); Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); Object data = shell.getData(); if (data instanceof ApplicationWindow) { ApplicationWindow window = (ApplicationWindow) data; CoolBarManager coolMng = window.getCoolBarManager(); if (coolMng != null) { IContributionItem[] items = coolMng.getItems(); if (items != null) { for (int i = 0; i < items.length; i++) { if (items[i] instanceof ToolBarContributionItem) { ToolBarContributionItem item = (ToolBarContributionItem) items[i]; ToolBarManager toolMng = (ToolBarManager) item.getToolBarManager(); ToolBar tb = toolMng.getControl(); if (tb != null) { ToolItem[] toolItems = tb.getItems(); if (toolItems != null) { for (int j = 0; j < toolItems.length; j++) { EclipseToolBarModel m = new EclipseToolBarModel(); ToolItem toolItem = toolItems[j]; m.Enabled = toolItem.isEnabled(); m.ID = getString(getActionId(toolItem)); m.ToolTip = getString(toolItem.getToolTipText()); if ((toolItem.getStyle() & SWT.CHECK) != 0 || (toolItem.getStyle() & SWT.RADIO) != 0) m.Selected = Boolean.valueOf(toolItem.getSelection()).toString(); else { m.Selected = ""; }//from www . j a v a 2 s.c om list.add(m); } } } } } } } } return list; }