use of org.eclipse.jface.action.IContributionManager in project yamcs-studio by yamcs.
the class StatusLineContributionItem method updateManager.
private void updateManager() {
if (this.text.length() == 0) {
if (isVisible()) {
setVisible(false);
IContributionManager contributionManager = getParent();
if (contributionManager != null) {
contributionManager.update(true);
}
}
} else {
// Always update if using 'CALC_TRUE_WIDTH'
if (!isVisible() || charWidth == CALC_TRUE_WIDTH) {
setVisible(true);
IContributionManager contributionManager = getParent();
if (contributionManager != null) {
contributionManager.update(true);
}
}
}
}
use of org.eclipse.jface.action.IContributionManager in project jbosstools-openshift by jbosstools.
the class UIUtils method registerContributionManager.
/**
* Register a {@link ContributionManager}. The contribution manager gets
* unregistered on control disposal
*
* @param id
* the id
* @param contributionManager
* the contribution manager
* @param control
* the control
*
* @see ContributionManager
* @see IMenuService
* @see DisposeListener
*/
public static void registerContributionManager(final String id, final IContributionManager contributionManager, final Control control) {
Assert.isNotNull(id);
Assert.isNotNull(contributionManager);
Assert.isTrue(control != null && !control.isDisposed());
final IMenuService menuService = (IMenuService) PlatformUI.getWorkbench().getService(IMenuService.class);
menuService.populateContributionManager((ContributionManager) contributionManager, id);
contributionManager.update(true);
control.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
menuService.releaseContributions((ContributionManager) contributionManager);
}
});
}
use of org.eclipse.jface.action.IContributionManager in project webtools.sourceediting by eclipse.
the class ViewerTestHTML method createPartControl.
/**
* @see org.eclipse.ui.IWorkbenchPart#createPartControl(Composite)
*/
public void createPartControl(Composite parent) {
IContributionManager mgr = getViewSite().getActionBars().getMenuManager();
addActions(mgr);
// create source viewer & its content type-specific viewer
// configuration
fSourceViewer = new StructuredTextViewer(parent, null, null, false, SWT.NONE);
fConfig = new StructuredTextViewerConfigurationHTML();
// set up the viewer with a document & viewer config
setupViewerForNew();
setupViewerPreferences();
}
use of org.eclipse.jface.action.IContributionManager in project webtools.sourceediting by eclipse.
the class ConfigurableContentOutlinePage method setConfiguration.
/**
* Configures (or reconfigures) the page according to the given
* configuration.
*
* @param configuration
*/
public void setConfiguration(ContentOutlineConfiguration configuration) {
// intentionally do not check to see if the new configuration != old
// configuration
unconfigure();
fConfiguration = configuration;
if (getTreeViewer() != null && getControl() != null && !getControl().isDisposed()) {
// (re)set the providers
ILabelProvider labelProvider = getConfiguration().getLabelProvider(getTreeViewer());
if (labelProvider instanceof IStyledLabelProvider) {
getTreeViewer().setLabelProvider(new DelegatingStyledCellLabelProvider((IStyledLabelProvider) labelProvider));
} else {
getTreeViewer().setLabelProvider(labelProvider);
}
getTreeViewer().setContentProvider(getConfiguration().getContentProvider(getTreeViewer()));
// view toolbar
IContributionManager toolbar = getSite().getActionBars().getToolBarManager();
if (toolbar != null) {
IContributionItem[] toolbarItems = getConfiguration().getToolbarContributions(getTreeViewer());
if (toolbarItems != null) {
for (int i = 0; i < toolbarItems.length; i++) {
toolbar.add(toolbarItems[i]);
}
toolbar.update(true);
}
}
// view menu
IContributionManager menu = getSite().getActionBars().getMenuManager();
if (menu != null) {
IContributionItem[] menuItems = getConfiguration().getMenuContributions(getTreeViewer());
if (menuItems != null) {
for (int i = 0; i < menuItems.length; i++) {
menuItems[i].setVisible(true);
menu.add(menuItems[i]);
menuItems[i].update();
}
menu.update(true);
}
}
// add the allowed DnD listeners and types
TransferDragSourceListener[] dragListeners = getConfiguration().getTransferDragSourceListeners(getTreeViewer());
if (fDragAdapter != null && dragListeners.length > 0) {
for (int i = 0; i < dragListeners.length; i++) {
fDragAdapter.addDragSourceListener(dragListeners[i]);
}
fActiveDragListeners = dragListeners;
fDragSource.addDragListener(fDragAdapter);
fDragSource.setTransfer(fDragAdapter.getTransfers());
}
TransferDropTargetListener[] dropListeners = getConfiguration().getTransferDropTargetListeners(getTreeViewer());
if (fDropAdapter != null && dropListeners.length > 0) {
for (int i = 0; i < dropListeners.length; i++) {
fDropAdapter.addDropTargetListener(dropListeners[i]);
}
fActiveDropListeners = dropListeners;
fDropTarget.addDropListener(fDropAdapter);
fDropTarget.setTransfer(fDropAdapter.getTransfers());
}
// add the key listeners
KeyListener[] listeners = getConfiguration().getKeyListeners(getTreeViewer());
if (listeners != null) {
for (int i = 0; i < listeners.length; i++) {
getControl().addKeyListener(listeners[i]);
}
}
}
if (fInput != null) {
setInput(fInput);
}
}
use of org.eclipse.jface.action.IContributionManager in project webtools.sourceediting by eclipse.
the class ViewerTestJSP method createPartControl.
/**
* @see org.eclipse.ui.IWorkbenchPart#createPartControl(Composite)
*/
public void createPartControl(Composite parent) {
IContributionManager mgr = getViewSite().getActionBars().getMenuManager();
addActions(mgr);
// create source viewer & its content type-specific viewer
// configuration
fSourceViewer = new StructuredTextViewer(parent, null, null, false, SWT.NONE);
fConfig = new StructuredTextViewerConfigurationJSP();
// set up the viewer with a document & viewer config
setupViewerForNew();
setupViewerPreferences();
}
Aggregations