graphicalViewer.setContents(getModel());
setPartName(getModel().getRootProject().getName());
// Add contextuel Menu
LayoutActions layoutActions = new LayoutActions(this);
ContextMenuProvider contextMenuProvider = new ContextMenuProvider(getGraphicalViewer()) {
/**
* @see org.eclipse.gef.ContextMenuProvider#buildContextMenu(org.eclipse.jface.action.IMenuManager)
*/
@Override
public void buildContextMenu(IMenuManager menuManager) {
GEFActionConstants.addStandardActionGroups(menuManager);
if (menuManager.isEnabled()) {
// Undo, Redo action
menuManager.appendToGroup(GEFActionConstants.GROUP_UNDO, getActionRegistry().getAction(ActionFactory.UNDO.getId()));
menuManager.appendToGroup(GEFActionConstants.GROUP_UNDO, getActionRegistry().getAction(ActionFactory.REDO.getId()));
// Layout actions
menuManager.appendToGroup(GEFActionConstants.GROUP_REST, getActionRegistry().getAction(
LayoutActions.DIRECTED_GRAPH_LAYOUT_ACTION_ID));
menuManager.appendToGroup(GEFActionConstants.GROUP_REST, getActionRegistry().getAction(
LayoutActions.GRID_LAYOUT_ACTION_ID));
menuManager.appendToGroup(GEFActionConstants.GROUP_REST, getActionRegistry().getAction(
LayoutActions.HORIZONTAL_LAYOUT_ACTION_ID));
menuManager.appendToGroup(GEFActionConstants.GROUP_REST, getActionRegistry().getAction(
LayoutActions.HORIZONTAL_SHIFT_LAYOUT_ACTION_ID));
menuManager.appendToGroup(GEFActionConstants.GROUP_REST, getActionRegistry().getAction(
LayoutActions.HORIZONTAL_TREE_LAYOUT_ACTION_ID));
menuManager.appendToGroup(GEFActionConstants.GROUP_REST, getActionRegistry().getAction(
LayoutActions.RADIAL_LAYOUT_ACTION_ID));
menuManager.appendToGroup(GEFActionConstants.GROUP_REST, getActionRegistry().getAction(
LayoutActions.SPRING_LAYOUT_ACTION_ID));
menuManager.appendToGroup(GEFActionConstants.GROUP_REST, getActionRegistry().getAction(
LayoutActions.TREE_LAYOUT_ACTION_ID));
menuManager.appendToGroup(GEFActionConstants.GROUP_REST, getActionRegistry().getAction(
LayoutActions.VERTICAL_LAYOUT_ACTION_ID));
}
}
};
getGraphicalViewer().setContextMenu(contextMenuProvider);
layoutActions.applyDefaultLayout();
if (logger.isLoggable(Level.FINE)) {
//$ANALYSIS-IGNORE
logger.fine("GraphicalViewer initialized");
}