List of usage examples for org.eclipse.jface.action IContributionItem fill
void fill(Composite parent);
From source file:de.fhg.igd.eclipse.ui.util.extension.AbstractExtensionContribution.java
License:Apache License
/** * @see ContributionItem#fill(Composite) *//*from w ww. ja v a 2 s . c o m*/ @Override public void fill(Composite parent) { if (extension == null) { extension = initExtension(); } fillWithFactories(parent, getFactories()); List<ExtensionObjectFactoryCollection<T, F>> collections = extension.getFactoryCollections(); boolean sep = false; if (!collections.isEmpty()) { for (ExtensionObjectFactoryCollection<T, F> collection : collections) { if ((filter == null || filter.acceptCollection(collection)) && (collection.allowAddNew() || collection.allowRemove())) { if (!sep) { // add a separator new Separator().fill(parent); sep = true; } IAction action = createCollectionAction(collection); IContributionItem item = new ActionContributionItem(action); item.fill(parent); } } } dirty = false; }
From source file:de.fhg.igd.eclipse.ui.util.extension.AbstractExtensionContribution.java
License:Apache License
/** * Fill the composite with factory actions * /* w w w. j a v a2s .c o m*/ * @param parent the parent composite * @param factories the available factories */ protected void fillWithFactories(Composite parent, List<F> factories) { for (F factory : factories) { IAction action = getFactoryAction(factory); IContributionItem item = new ActionContributionItem(action); item.fill(parent); } }
From source file:eu.esdihumboldt.hale.ui.util.DynamicActionsContribution.java
License:Open Source License
/** * @see ContributionItem#fill(Composite) *//* w w w.ja v a 2 s .co m*/ @Override public void fill(Composite parent) { for (IAction action : getActions()) { if (action == null) { new Separator().fill(parent); } else { IContributionItem item = new ActionContributionItem(action); item.fill(parent); } } }
From source file:org.eclipse.ui.internal.menus.DynamicMenuContributionItem.java
License:Open Source License
public void fill(Composite parent) { IContributionItem contributionItem = getContributionItem(); if (contributionItem != null) contributionItem.fill(parent); }
From source file:org.nightlabs.base.ui.util.RCPUtil.java
License:Open Source License
/** * Adds a new {@link org.eclipse.ui.internal.layout.IWindowTrim} * to the {@link org.eclipse.ui.internal.layout.TrimLayout} of the given shell * and prepends it to the the trim with the given id (pependTo). * The new trim will be filled with the contents of the given contributionItem. * * @param shell The shell to add the trim to. * @param contributionItem The contributionItem to fill the trim with. * @param prependTo The id of the trim the new trim should be prepended to. *//*w ww. ja va 2 s . c o m*/ @SuppressWarnings("restriction") //$NON-NLS-1$ public static void addContributionItemTrim(Shell shell, IContributionItem contributionItem, String prependTo) { if (shell != null && (shell.getLayout() instanceof org.eclipse.ui.internal.layout.TrimLayout)) { // This is how the WorkbenchWindow add the progress and heapstatus controls // can't be that wrong :-) org.eclipse.ui.internal.layout.TrimLayout layout = (org.eclipse.ui.internal.layout.TrimLayout) shell .getLayout(); Composite comp = new Composite(shell, SWT.NONE); contributionItem.fill(comp); org.eclipse.ui.internal.WindowTrimProxy trimProxy = new org.eclipse.ui.internal.WindowTrimProxy(comp, contributionItem.getId(), contributionItem.getClass().getSimpleName(), SWT.BOTTOM | SWT.TOP) { @Override public void handleClose() { getControl().dispose(); } @Override public boolean isCloseable() { return true; } }; org.eclipse.ui.internal.layout.IWindowTrim prependTrim = layout.getTrim(prependTo); trimProxy.setWidthHint(comp.computeSize(SWT.DEFAULT, SWT.DEFAULT).x); trimProxy.setHeightHint(comp.computeSize(SWT.DEFAULT, SWT.DEFAULT).y); layout.addTrim(SWT.BOTTOM, trimProxy, prependTrim); comp.setVisible(true); } }
From source file:org.opentravel.schemas.widgets.ButtonBarManager.java
License:Apache License
@Override public void update(final boolean force) { if (isDirty() || force) { if (buttonBarExist()) { // clean contains all active items without double separators final IContributionItem[] items = getItems(); final List<IContributionItem> clean = new ArrayList<IContributionItem>(items.length); IContributionItem separator = null; for (int i = 0; i < items.length; ++i) { final IContributionItem ci = items[i]; if (!isChildVisible(ci)) { continue; }// w w w . j ava 2 s. c o m if (ci.isSeparator()) { // delay creation until necessary // (handles both adjacent separators, and separator at // end) separator = ci; } else { if (separator != null) { if (clean.size() > 0) { clean.add(separator); } separator = null; } clean.add(ci); } } // determine obsolete items (removed or non active) List<Button> mi = buttonBar.getButtons(); final List<Button> toRemove = new ArrayList<Button>(mi.size()); for (final Button b : mi) { // there may be null items in a buttonbar if (b == null) { continue; } final Object data = b.getData(); if (data == null || !clean.contains(data) || (data instanceof IContributionItem && ((IContributionItem) data).isDynamic())) { toRemove.add(b); } } // Turn redraw off if the number of items to be added // is above a certain threshold, to minimize flicker, // otherwise the buttonbar can be seen to redraw after each item. // Do this before any modifications are made. // We assume each contribution item will contribute at least one // buttonbar item. final boolean useRedraw = (clean.size() - (mi.size() - toRemove.size())) >= 3; try { if (useRedraw) { buttonBar.setRedraw(false); } // remove obsolete items for (int i = toRemove.size(); --i >= 0;) { final Button item = toRemove.get(i); if (!item.isDisposed()) { item.dispose(); } } // add new items IContributionItem src, dest; mi = buttonBar.getButtons(); int firstDif = 0; // skipping all the items that are the same till the first difference for (int i = 0; i < items.length; i++) { src = items[i]; // get corresponding item in SWT widget if (i < mi.size()) { dest = (IContributionItem) mi.get(i).getData(); } else { dest = null; } if (dest != null && src.equals(dest)) { continue; } if (dest != null && dest.isSeparator() && src.isSeparator()) { mi.get(i).setData(src); continue; } firstDif = i; break; } // removing the rest of the list because we need to recreate it for (int i = firstDif; i < mi.size(); i++) { mi.get(i).dispose(); } for (int i = firstDif; i < items.length; i++) { src = items[i]; src.fill(buttonBar); } setDirty(false); // turn redraw back on if we turned it off above } finally { if (useRedraw) { buttonBar.setRedraw(true); } } final Point beforePack = buttonBar.getSize(); buttonBar.pack(true); buttonBar.layoutButtons(); final Point afterPack = buttonBar.getSize(); // If the BB didn't change size then we're done if (beforePack.equals(afterPack)) { return; } // OK, we need to re-layout the BB buttonBar.getParent().layout(); } } }
From source file:org.zend.php.zendserver.deployment.ui.editors.OverviewPage.java
protected void updateTestingActions(Composite parent, IContributionItem[] items) { for (IContributionItem item : items) { item.fill(parent); }/* w w w . ja v a2 s. c om*/ }