本文整理汇总了Java中org.eclipse.gef.GraphicalViewer.setContextMenu方法的典型用法代码示例。如果您正苦于以下问题:Java GraphicalViewer.setContextMenu方法的具体用法?Java GraphicalViewer.setContextMenu怎么用?Java GraphicalViewer.setContextMenu使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.gef.GraphicalViewer
的用法示例。
在下文中一共展示了GraphicalViewer.setContextMenu方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initializeGraphicalViewer
import org.eclipse.gef.GraphicalViewer; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
protected void initializeGraphicalViewer() {
final GraphicalViewer viewer = getGraphicalViewer();
viewer.setEditPartFactory(editPartFactory);
initViewerAction(viewer);
initDragAndDrop(viewer);
viewer.setProperty(MouseWheelHandler.KeyGenerator.getKey(SWT.MOD1), MouseWheelZoomHandler.SINGLETON);
viewer.setProperty(SnapToGrid.PROPERTY_GRID_ENABLED, true);
viewer.setProperty(SnapToGrid.PROPERTY_GRID_VISIBLE, true);
viewer.setProperty(SnapToGeometry.PROPERTY_SNAP_ENABLED, true);
final MenuManager menuMgr = new ERDiagramPopupMenuManager(getActionRegistry(), diagram);
extensionLoader.addERDiagramPopupMenu(menuMgr, getActionRegistry());
viewer.setContextMenu(menuMgr);
viewer.setContents(diagram);
outlineMenuMgr = new ERDiagramOutlinePopupMenuManager(diagram, getActionRegistry(), outlinePage.getOutlineActionRegistory(), outlinePage.getViewer());
}
示例2: initializeGraphicalViewer
import org.eclipse.gef.GraphicalViewer; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
protected void initializeGraphicalViewer() {
GraphicalViewer viewer = this.getGraphicalViewer();
viewer.setEditPartFactory(editPartFactory);
this.initViewerAction(viewer);
this.initDragAndDrop(viewer);
viewer.setProperty(MouseWheelHandler.KeyGenerator.getKey(SWT.MOD1),
MouseWheelZoomHandler.SINGLETON);
viewer.setProperty(SnapToGrid.PROPERTY_GRID_ENABLED, true);
viewer.setProperty(SnapToGrid.PROPERTY_GRID_VISIBLE, true);
viewer.setProperty(SnapToGeometry.PROPERTY_SNAP_ENABLED, true);
MenuManager menuMgr = new ERDiagramPopupMenuManager(
this.getActionRegistry(), this.diagram, this);
this.extensionLoader.addERDiagramPopupMenu(menuMgr,
this.getActionRegistry());
viewer.setContextMenu(menuMgr);
viewer.setContents(diagram);
}
示例3: configureViewer
import org.eclipse.gef.GraphicalViewer; //导入方法依赖的package包/类
private void configureViewer(GraphicalViewer viewer) {
viewer.setEditPartFactory(new ComponentsEditPartFactory());
ContextMenuProvider cmProvider = new ComponentsEditorContextMenuProvider(
viewer, getActionRegistry());
viewer.setContextMenu(cmProvider);
getSite().registerContextMenu(cmProvider, viewer);
}
示例4: configureGraphicalViewer
import org.eclipse.gef.GraphicalViewer; //导入方法依赖的package包/类
/**
* Hook the evolution factory into the editor logic and override the standard edit part factory
*/
@Override
public void configureGraphicalViewer() {
super.configureGraphicalViewer();
GraphicalViewer viewer = getGraphicalViewer();
viewer.setEditPartFactory(new DwFeatureModelEditorEditPartFactory(viewer, this));
viewer.setContextMenu(new DwGraphicalFeatureModelEditorContextMenuProvider(getGraphicalViewer(), getActionRegistry()));
viewer.setKeyHandler(new GraphicalViewerKeyHandler(viewer).setParent(getCommonKeyHandler()));
}
示例5: configureGraphicalViewer
import org.eclipse.gef.GraphicalViewer; //导入方法依赖的package包/类
protected void configureGraphicalViewer() {
super.configureGraphicalViewer();
GraphicalViewer viewer = getGraphicalViewer();
ScalableRootEditPart root = new ScalableRootEditPart();
viewer.setRootEditPart(root);
viewer.setEditPartFactory(new GraphEditPartFactory(viewer));
viewer.setContents("Loading graph... This can take several minutes");
ContextMenuProvider cmProvider = new RevisionGraphMenuProvider(viewer, this);
viewer.setContextMenu(cmProvider);
getSite().setSelectionProvider(viewer);
IEditorInput input = getEditorInput();
if(input instanceof FileEditorInput) {
FileEditorInput fileEditorInput = (FileEditorInput) input;
showGraphFor(fileEditorInput.getFile());
} else if(input instanceof RevisionGraphEditorInput) {
RevisionGraphEditorInput editorInput = (RevisionGraphEditorInput) input;
showGraphFor(editorInput);
}
// zoom stuff
ZoomManager zoomManager = ((ScalableRootEditPart) viewer.getRootEditPart()).getZoomManager();
IAction zoomIn = new ZoomInAction(zoomManager);
IAction zoomOut = new ZoomOutAction(zoomManager);
getActionRegistry().registerAction(zoomIn);
getActionRegistry().registerAction(zoomOut);
// keyboard
getSite().getKeyBindingService().registerAction(zoomIn); // FIXME, deprecated
getSite().getKeyBindingService().registerAction(zoomOut); // FIXME, deprecated
List zoomContributions = Arrays.asList(new String[] {
ZoomManager.FIT_ALL,
ZoomManager.FIT_HEIGHT,
ZoomManager.FIT_WIDTH });
zoomManager.setZoomLevelContributions(zoomContributions);
// mouse wheel
viewer.setProperty(MouseWheelHandler.KeyGenerator.getKey(SWT.MOD1),
MouseWheelZoomHandler.SINGLETON);
}
示例6: configureGraphicalViewer
import org.eclipse.gef.GraphicalViewer; //导入方法依赖的package包/类
/**
* @see org.eclipse.gef.ui.parts.GraphicalEditor#configureGraphicalViewer()
*/
protected void configureGraphicalViewer() {
super.configureGraphicalViewer();
GraphicalViewer viewer = getGraphicalViewer();
viewer.setEditPartFactory(createDiagramEditPartFactory());
viewer.setRootEditPart(createRootEditPart());
viewer.setKeyHandler(createKeyHandler(viewer));
viewer.setContextMenu(createContextMenuProvider(viewer, getActionRegistry()));
// viewer.getKeyHandler().put(KeyStroke.getPressed(SWT.DEL, 127, 0),
// getActionRegistry().getAction(GEFActionConstants.DELETE));
}
示例7: prepareERDiagramPopupMenu
import org.eclipse.gef.GraphicalViewer; //导入方法依赖的package包/类
@Override
protected void prepareERDiagramPopupMenu(final GraphicalViewer viewer) {
final MenuManager menuMgr = new ERVirtualDiagramPopupMenuManager(getActionRegistry(), vdiagram);
extensionLoader.addERDiagramPopupMenu(menuMgr, getActionRegistry());
viewer.setContextMenu(menuMgr);
viewer.setContents(vdiagram);
}
示例8: configureGraphicalViewer
import org.eclipse.gef.GraphicalViewer; //导入方法依赖的package包/类
protected void configureGraphicalViewer() {
super.configureGraphicalViewer();
double[] zoomLevels;
List<String> zoomContributions;
GraphicalViewer viewer = getGraphicalViewer();
viewer.setEditPartFactory(gw4eEditPartFactory);
keyHandler = new KeyHandler();
keyHandler.put(KeyStroke.getPressed(SWT.DEL, 127, 0),
getActionRegistry().getAction(ActionFactory.DELETE.getId()));
keyHandler.put(KeyStroke.getPressed(SWT.F2, 0), getActionRegistry().getAction(GEFActionConstants.DIRECT_EDIT));
keyHandler.put(KeyStroke.getPressed('+', SWT.KEYPAD_ADD, 0),
getActionRegistry().getAction(GEFActionConstants.ZOOM_IN));
keyHandler.put(KeyStroke.getPressed('-', SWT.KEYPAD_SUBTRACT, 0),
getActionRegistry().getAction(GEFActionConstants.ZOOM_OUT));
getGraphicalViewer().setKeyHandler(new GraphicalViewerKeyHandler(getGraphicalViewer()).setParent(keyHandler));
ScalableRootEditPart rootEditPart = new ScalableRootEditPart();
viewer.setRootEditPart(rootEditPart);
ZoomManager manager = rootEditPart.getZoomManager();
getActionRegistry().registerAction(new ZoomInAction(manager));
getActionRegistry().registerAction(new ZoomOutAction(manager));
zoomLevels = new double[] { 0.25, 0.5, 0.75, 1.0, 1.5, 2.0, 2.5, 3.0, 4.0, 5.0, 10.0, 20.0 };
manager.setZoomLevels(zoomLevels);
zoomContributions = new ArrayList<String>();
zoomContributions.add(ZoomManager.FIT_ALL);
zoomContributions.add(ZoomManager.FIT_HEIGHT);
zoomContributions.add(ZoomManager.FIT_WIDTH);
manager.setZoomLevelContributions(zoomContributions);
getActionRegistry().registerAction(new ToggleGridAction(getGraphicalViewer()));
getActionRegistry().registerAction(new ToggleSnapToGeometryAction(getGraphicalViewer()));
getActionRegistry().registerAction(new ClearEdgeBendpointLayoutAction(this));
ContextMenuProvider provider = new ContextMenuProvider(this, viewer, getActionRegistry());
viewer.setContextMenu(provider);
}
示例9: configureContextMenu
import org.eclipse.gef.GraphicalViewer; //导入方法依赖的package包/类
protected void configureContextMenu() {
GraphicalViewer graphicalViewer = getGraphicalViewer();
ContextMenuProvider provider = new FilteringDiagramContextMenuProvider(this, graphicalViewer);
graphicalViewer.setContextMenu(provider);
getSite().registerContextMenu(ActionIds.DIAGRAM_EDITOR_CONTEXT_MENU, provider, viewer);
}
示例10: configureGraphicalViewer
import org.eclipse.gef.GraphicalViewer; //导入方法依赖的package包/类
@Override
protected void configureGraphicalViewer() {
super.configureGraphicalViewer();
GraphicalViewer graphicalViewer = getGraphicalViewer();
MainDesignerRootEditPart rootEditPart = new MainDesignerRootEditPart();
graphicalViewer.setRootEditPart(rootEditPart);
// set EditPartFactory
graphicalViewer.setEditPartFactory(createEditParFactory());
graphicalViewer.setKeyHandler(new GraphicalViewerKeyHandler(graphicalViewer));
graphicalViewer.setContextMenu(createContextMenuProvider(graphicalViewer));
ZoomManager zoomManager = (ZoomManager) graphicalViewer.getProperty(ZoomManager.class.toString());
getActionRegistry().registerAction(new ZoomInAction(zoomManager));
getActionRegistry().registerAction(new ZoomOutAction(zoomManager));
getActionRegistry().registerAction(new ZoomActualAction(zoomManager));
graphicalViewer.setProperty(MouseWheelHandler.KeyGenerator.getKey(SWT.MOD1), MouseWheelZoomHandler.SINGLETON);
graphicalViewer.setProperty("JRCONTEXT", jrContext);
}
示例11: createAdditionalActions
import org.eclipse.gef.GraphicalViewer; //导入方法依赖的package包/类
/**
* Creates the additional actions.
*/
protected void createAdditionalActions() {
GraphicalViewer graphicalViewer = getGraphicalViewer();
// Show Grid Action
Boolean isGridVisible = jrContext.getPropertyBoolean(RulersGridPreferencePage.P_PAGE_RULERGRID_SHOWGRID, true);
Boolean isSnapToGuides = jrContext.getPropertyBoolean(RulersGridPreferencePage.P_PAGE_RULERGRID_SNAPTOGUIDES, true);
Boolean isSnapToGrid = jrContext.getPropertyBoolean(RulersGridPreferencePage.P_PAGE_RULERGRID_SNAPTOGRID, true);
Boolean isSnapToGeometry = jrContext.getPropertyBoolean(RulersGridPreferencePage.P_PAGE_RULERGRID_SNAPTOGEOMETRY,
true);
int gspaceX = jrContext.getPropertyInteger(RulersGridPreferencePage.P_PAGE_RULERGRID_GRIDSPACEX, 10);
int gspaceY = jrContext.getPropertyInteger(RulersGridPreferencePage.P_PAGE_RULERGRID_GRIDSPACEY, 10);
graphicalViewer.setProperty(SnapToGrid.PROPERTY_GRID_ENABLED, isSnapToGrid.booleanValue());
graphicalViewer.setProperty(SnapToGrid.PROPERTY_GRID_VISIBLE, isGridVisible.booleanValue());
graphicalViewer.setProperty(SnapToGrid.PROPERTY_GRID_ORIGIN, new Point(30, 30));
graphicalViewer.setProperty(SnapToGrid.PROPERTY_GRID_SPACING, new Dimension(gspaceX, gspaceY));
graphicalViewer.setProperty(SnapToGuidesAction.ID, isSnapToGuides);
graphicalViewer.setProperty(SnapToGeometry.PROPERTY_SNAP_ENABLED, isSnapToGeometry.booleanValue());
IAction showGrid = new ShowGridAction(jrContext);
getActionRegistry().registerAction(showGrid);
SnapToGridAction snapGridAction = new SnapToGridAction(jrContext);
getActionRegistry().registerAction(snapGridAction);
SizeGridAction sizeGridAction = new SizeGridAction(jrContext);
getActionRegistry().registerAction(sizeGridAction);
// snap to geometry
IAction snapAction = new SnapToGeometryAction(jrContext);
getActionRegistry().registerAction(snapAction);
snapAction = new SnapToGuidesAction(jrContext);
getActionRegistry().registerAction(snapAction);
// show rullers
IAction showRulers = new ShowRullersAction(jrContext);
getActionRegistry().registerAction(showRulers);
// zoom manager actions
ZoomManager zoomManager = (ZoomManager) graphicalViewer.getProperty(ZoomManager.class.toString());
getActionRegistry().registerAction(new ZoomInAction(zoomManager));
getActionRegistry().registerAction(new ZoomOutAction(zoomManager));
getActionRegistry().registerAction(new ZoomActualAction(zoomManager));
graphicalViewer.setProperty(MouseWheelHandler.KeyGenerator.getKey(SWT.MOD1), MouseWheelZoomHandler.SINGLETON);
// set context menu
graphicalViewer.setContextMenu(new AppContextMenuProvider(graphicalViewer, getActionRegistry()));
graphicalViewer.setProperty("JRCONTEXT", jrContext);
LayoutManager.addActions(getActionRegistry(), this, getSelectionActions());
JaspersoftStudioPlugin.getDecoratorManager().registerActions(getActionRegistry(), getSelectionActions(),
getGraphicalViewer(), this);
JaspersoftStudioPlugin.getEditorSettingsManager().registerActions(getActionRegistry(), jrContext);
}
示例12: prepareERDiagramPopupMenu
import org.eclipse.gef.GraphicalViewer; //导入方法依赖的package包/类
protected void prepareERDiagramPopupMenu(final GraphicalViewer viewer) {
final MenuManager menuMgr = new ERDiagramPopupMenuManager(getActionRegistry(), diagram);
extensionLoader.addERDiagramPopupMenu(menuMgr, getActionRegistry());
viewer.setContextMenu(menuMgr);
}