use of org.eclipse.jface.action.MenuManager in project archi by archimatetool.
the class ZestView method makeLocalToolBar.
/**
* Populate the ToolBar
*/
private void makeLocalToolBar() {
IActionBars bars = getViewSite().getActionBars();
IToolBarManager manager = bars.getToolBarManager();
fDrillDownManager.addNavigationActions(manager);
manager.add(new Separator());
manager.add(fActionPinContent);
manager.add(new Separator());
manager.add(fActionLayout);
final IMenuManager menuManager = bars.getMenuManager();
IMenuManager depthMenuManager = new MenuManager(Messages.ZestView_3);
menuManager.add(depthMenuManager);
// Depth Actions
fDepthActions = new Action[6];
for (int i = 0; i < fDepthActions.length; i++) {
fDepthActions[i] = createDepthAction(i, i + 1);
depthMenuManager.add(fDepthActions[i]);
}
// Set depth from prefs
int depth = ArchiZestPlugin.INSTANCE.getPreferenceStore().getInt(IPreferenceConstants.VISUALISER_DEPTH);
getContentProvider().setDepth(depth);
fDepthActions[depth].setChecked(true);
// Set filter based on Viewpoint
IMenuManager viewpointMenuManager = new MenuManager(Messages.ZestView_5);
menuManager.add(viewpointMenuManager);
// Get viewpoint from prefs
String viewpointID = ArchiZestPlugin.INSTANCE.getPreferenceStore().getString(IPreferenceConstants.VISUALISER_VIEWPOINT);
getContentProvider().setViewpointFilter(ViewpointManager.INSTANCE.getViewpoint(viewpointID));
// Viewpoint actions
fViewpointActions = new ArrayList<IAction>();
for (IViewpoint vp : ViewpointManager.INSTANCE.getAllViewpoints()) {
IAction action = createViewpointMenuAction(vp);
fViewpointActions.add(action);
viewpointMenuManager.add(action);
// Set checked
if (vp.getID().equals(viewpointID)) {
action.setChecked(true);
}
}
// Set filter based on Relationship
IMenuManager relationshipMenuManager = new MenuManager(Messages.ZestView_6);
menuManager.add(relationshipMenuManager);
// Get relationship from prefs
String relationshipID = ArchiZestPlugin.INSTANCE.getPreferenceStore().getString(IPreferenceConstants.VISUALISER_RELATIONSHIP);
EClass eClass = (EClass) IArchimatePackage.eINSTANCE.getEClassifier(relationshipID);
getContentProvider().setRelationshipFilter(eClass);
// Relationship actions, first the "None" relationship
fRelationshipActions = new ArrayList<IAction>();
IAction action = createRelationshipMenuAction(null);
if (eClass == null) {
action.setChecked(true);
}
fRelationshipActions.add(action);
relationshipMenuManager.add(action);
// Then get all relationships and sort them
ArrayList<EClass> actionList = new ArrayList<EClass>(Arrays.asList(ArchimateModelUtils.getRelationsClasses()));
actionList.sort((o1, o2) -> o1.getName().compareTo(o2.getName()));
for (EClass rel : actionList) {
action = createRelationshipMenuAction(rel);
fRelationshipActions.add(action);
relationshipMenuManager.add(action);
// Set checked
if (eClass != null && rel.getName().equals(eClass.getName())) {
action.setChecked(true);
}
}
// Orientation
IMenuManager orientationMenuManager = new MenuManager(Messages.ZestView_32);
menuManager.add(orientationMenuManager);
// Direction
fDirectionActions = new Action[3];
fDirectionActions[0] = createOrientationMenuAction(0, Messages.ZestView_33, ZestViewerContentProvider.DIR_BOTH);
orientationMenuManager.add(fDirectionActions[0]);
fDirectionActions[1] = createOrientationMenuAction(1, Messages.ZestView_34, ZestViewerContentProvider.DIR_IN);
orientationMenuManager.add(fDirectionActions[1]);
fDirectionActions[2] = createOrientationMenuAction(2, Messages.ZestView_35, ZestViewerContentProvider.DIR_OUT);
orientationMenuManager.add(fDirectionActions[2]);
// Set direction from prefs
int direction = ArchiZestPlugin.INSTANCE.getPreferenceStore().getInt(IPreferenceConstants.VISUALISER_DIRECTION);
getContentProvider().setDirection(direction);
fDirectionActions[direction].setChecked(true);
menuManager.add(new Separator());
menuManager.add(fActionSelectInModelTree);
menuManager.add(fActionCopyImageToClipboard);
menuManager.add(fActionExportImageToFile);
}
use of org.eclipse.jface.action.MenuManager in project xtext-eclipse by eclipse.
the class OutlinePage method configureContextMenu.
/**
* @since 2.4
*/
protected void configureContextMenu() {
MenuManager menuManager = new MenuManager(CONTEXT_MENU_ID, CONTEXT_MENU_ID);
menuManager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
menuManager.setRemoveAllWhenShown(true);
Menu contextMenu = menuManager.createContextMenu(getTreeViewer().getTree());
getTreeViewer().getTree().setMenu(contextMenu);
getSite().registerContextMenu(MENU_ID, menuManager, getTreeViewer());
}
use of org.eclipse.jface.action.MenuManager in project archi by archimatetool.
the class UserPropertiesManagerDialog method hookContextMenu.
/**
* Hook into a right-click menu
*/
private void hookContextMenu() {
// $NON-NLS-1$
MenuManager menuMgr = new MenuManager("#PropertiesManagerPopupMenu");
menuMgr.setRemoveAllWhenShown(true);
menuMgr.addMenuListener(new IMenuListener() {
public void menuAboutToShow(IMenuManager manager) {
fillContextMenu(manager);
}
});
Menu menu = menuMgr.createContextMenu(fTableViewer.getControl());
fTableViewer.getControl().setMenu(menu);
}
use of org.eclipse.jface.action.MenuManager in project archi by archimatetool.
the class HeapStatusWidget method createContextMenu.
/**
* Creates the context menu
*/
private void createContextMenu() {
MenuManager menuMgr = new MenuManager();
menuMgr.setRemoveAllWhenShown(true);
menuMgr.addMenuListener(new IMenuListener() {
public void menuAboutToShow(IMenuManager menuMgr) {
fillMenu(menuMgr);
}
});
Menu menu = menuMgr.createContextMenu(this);
setMenu(menu);
}
use of org.eclipse.jface.action.MenuManager in project archi by archimatetool.
the class StyledTextControl method hookContextMenu.
/**
* Hook into a right-click menu
*/
private void hookContextMenu() {
// $NON-NLS-1$
MenuManager menuMgr = new MenuManager("#PopupMenu1");
menuMgr.setRemoveAllWhenShown(true);
menuMgr.addMenuListener(new IMenuListener() {
public void menuAboutToShow(IMenuManager manager) {
fillContextMenu(manager);
}
});
Menu menu = menuMgr.createContextMenu(fStyledText);
fStyledText.setMenu(menu);
}
Aggregations