use of org.eclipse.gef.ui.actions.DirectEditAction in project tdi-studio-se by Talend.
the class AbstractTalendEditor method configureGraphicalViewer.
@Override
protected void configureGraphicalViewer() {
super.configureGraphicalViewer();
/** * Manage the view in the Outline ** */
ScrollingGraphicalViewer viewer = (ScrollingGraphicalViewer) getGraphicalViewer();
viewer.setSelectionManager(new TalendSelectionManager());
TalendScalableFreeformRootEditPart root = new TalendScalableFreeformRootEditPart(getEditorInput());
List<String> zoomLevels = new ArrayList<String>();
zoomLevels.add(ZoomManager.FIT_ALL);
zoomLevels.add(ZoomManager.FIT_WIDTH);
zoomLevels.add(ZoomManager.FIT_HEIGHT);
root.getZoomManager().setZoomLevelContributions(zoomLevels);
// root.getZoomManager().setZoomAnimationStyle(ZoomManager.ANIMATE_NEVER);
IAction zoomIn = new ZoomInAction(root.getZoomManager());
IAction zoomOut = new ZoomOutAction(root.getZoomManager());
getActionRegistry().registerAction(zoomIn);
getActionRegistry().registerAction(zoomOut);
IHandlerService service = (IHandlerService) getEditorSite().getService(IHandlerService.class);
service.activateHandler(zoomIn.getActionDefinitionId(), new ActionHandler(zoomIn));
service.activateHandler(zoomOut.getActionDefinitionId(), new ActionHandler(zoomOut));
IAction directEditAction = new DirectEditAction(this);
getActionRegistry().registerAction(directEditAction);
getSelectionActions().add(directEditAction.getId());
IAction copyAction = new GEFCopyAction(this);
getActionRegistry().registerAction(copyAction);
getSelectionActions().add(copyAction.getId());
// setAction(copyAction.getId(), copyAction);
IAction pasteAction = new GEFPasteAction(this);
getActionRegistry().registerAction(pasteAction);
getSelectionActions().add(pasteAction.getId());
// setAction(pasteAction.getId(), pasteAction);
IAction deleteAction = new GEFDeleteAction(this);
getActionRegistry().registerAction(deleteAction);
getSelectionActions().add(deleteAction.getId());
// setAction(deleteAction.getId(), deleteAction);
IAction undoAction = new GEFUndoAction(this);
getActionRegistry().registerAction(undoAction);
getSelectionActions().add(undoAction.getId());
IAction redoAction = new GEFRedoAction(this);
getActionRegistry().registerAction(redoAction);
getSelectionActions().add(redoAction.getId());
IAction setRefAction = new ConnectionSetAsMainRef(this);
getActionRegistry().registerAction(setRefAction);
getSelectionActions().add(setRefAction.getId());
IAction modifyMergeAction = new ModifyMergeOrderAction(this);
getActionRegistry().registerAction(modifyMergeAction);
getSelectionActions().add(modifyMergeAction.getId());
IAction modifyOutputOrderAction = new ModifyOutputOrderAction(this);
getActionRegistry().registerAction(modifyOutputOrderAction);
getSelectionActions().add(modifyOutputOrderAction.getId());
List<IAction> calcOrderActions = ModifyConnectionOrderAction.getOrderActions(this);
for (IAction orderAction : calcOrderActions) {
getActionRegistry().registerAction(orderAction);
getSelectionActions().add(orderAction.getId());
}
viewer.setRootEditPart(root);
PartFactory partFactory = new PartFactory();
// set the factory to use for creating EditParts for elements in the model
getGraphicalViewer().setEditPartFactory(partFactory);
getGraphicalViewer().setKeyHandler(new NodePartKeyHander(getGraphicalViewer()).setParent(getCommonKeyHandler()));
// GraphicalViewer graViewer = getGraphicalViewer();
// graViewer.setKeyHandler(new GraphicalViewerKeyHandler(graViewer));
initializeActivationCodeTrigger();
/** * Management of the context menu ** */
ContextMenuProvider cmProvider = new TalendEditorContextMenuProvider(this, viewer, getActionRegistry());
viewer.setContextMenu(cmProvider);
/** * Management of the Zoom ** */
/*
* ZoomManager manager = (ZoomManager) getGraphicalViewer().getProperty(ZoomManager.class.toString()); if
* (manager != null) { manager.setZoom(getProcess().getZoom()); }
*/
// Scroll-wheel Zoom
getGraphicalViewer().setProperty(MouseWheelHandler.KeyGenerator.getKey(SWT.MOD1), MouseWheelZoomHandler.SINGLETON);
/** * Snap To Grid ** */
// Grid properties
getGraphicalViewer().setProperty(SnapToGrid.PROPERTY_GRID_SPACING, new Dimension(AbstractTalendEditor.GRID_SIZE, AbstractTalendEditor.GRID_SIZE));
getGraphicalViewer().setProperty(SnapToGrid.PROPERTY_GRID_ENABLED, new Boolean(true));
// We keep grid visibility and enablement in sync
getGraphicalViewer().setProperty(SnapToGrid.PROPERTY_GRID_VISIBLE, new Boolean(true));
IAction showGrid = new ToggleGridAction(getGraphicalViewer());
getActionRegistry().registerAction(showGrid);
/** * Snap To Geometry ** */
getGraphicalViewer().setProperty(SnapToGeometry.PROPERTY_SNAP_ENABLED, new Boolean(false));
IAction snapAction = new ToggleSnapToGeometryAction(getGraphicalViewer());
getActionRegistry().registerAction(snapAction);
configurationSubJob(viewer);
}
use of org.eclipse.gef.ui.actions.DirectEditAction in project archi by archimatetool.
the class AbstractDiagramEditor method createActions.
/**
* Add some extra Actions - *after* the graphical viewer has been created
*/
@SuppressWarnings("unchecked")
protected void createActions(GraphicalViewer viewer) {
ActionRegistry registry = getActionRegistry();
IAction action;
// Zoom Manager tweaking
ZoomManager zoomManager = (ZoomManager) getAdapter(ZoomManager.class);
double[] zoomLevels = { .25, .5, .75, 1, 1.5, 2, 3, 4, 6, 8 };
zoomManager.setZoomLevels(zoomLevels);
List<String> zoomContributionLevels = new ArrayList<String>();
zoomContributionLevels.add(ZoomManager.FIT_ALL);
zoomContributionLevels.add(ZoomManager.FIT_WIDTH);
zoomContributionLevels.add(ZoomManager.FIT_HEIGHT);
zoomManager.setZoomLevelContributions(zoomContributionLevels);
// Zoom Actions
IAction zoomIn = new ZoomInAction(zoomManager);
IAction zoomOut = new ZoomOutAction(zoomManager);
IAction zoomNormal = new ZoomNormalAction(zoomManager);
registry.registerAction(zoomIn);
registry.registerAction(zoomOut);
registry.registerAction(zoomNormal);
// Add these zoom actions to the key binding service
IHandlerService service = getEditorSite().getService(IHandlerService.class);
service.activateHandler(zoomIn.getActionDefinitionId(), new ActionHandler(zoomIn));
service.activateHandler(zoomOut.getActionDefinitionId(), new ActionHandler(zoomOut));
service.activateHandler(zoomNormal.getActionDefinitionId(), new ActionHandler(zoomNormal));
// Add our own Select All Action so we can select connections as well
action = new SelectAllAction(this);
registry.registerAction(action);
// Add our own Print Action
action = new PrintDiagramAction(this);
registry.registerAction(action);
// Direct Edit Rename
action = new DirectEditAction(this);
// Set this for Global Handler
action.setId(ActionFactory.RENAME.getId());
registry.registerAction(action);
getSelectionActions().add(action.getId());
getUpdateCommandStackActions().add((UpdateAction) action);
// Change the Delete Action label
action = registry.getAction(ActionFactory.DELETE.getId());
action.setText(Messages.AbstractDiagramEditor_2);
action.setToolTipText(action.getText());
getUpdateCommandStackActions().add((UpdateAction) action);
// Paste
PasteAction pasteAction = new PasteAction(this, viewer);
registry.registerAction(pasteAction);
getSelectionActions().add(pasteAction.getId());
// Paste Special
PasteSpecialAction pasteSpecialAction = new PasteSpecialAction(this, viewer);
registry.registerAction(pasteSpecialAction);
getSelectionActions().add(pasteSpecialAction.getId());
// Cut
action = new CutAction(this, pasteAction);
registry.registerAction(action);
getSelectionActions().add(action.getId());
getUpdateCommandStackActions().add((UpdateAction) action);
// Copy
action = new CopyAction(this, pasteAction);
registry.registerAction(action);
getSelectionActions().add(action.getId());
getUpdateCommandStackActions().add((UpdateAction) action);
// Use Grid Action
action = new ToggleGridEnabledAction();
registry.registerAction(action);
// Show Grid Action
action = new ToggleGridVisibleAction();
registry.registerAction(action);
// Snap to Alignment Guides
action = new ToggleSnapToAlignmentGuidesAction();
registry.registerAction(action);
// Ruler
// IAction showRulers = new ToggleRulerVisibilityAction(getGraphicalViewer());
// registry.registerAction(showRulers);
action = new MatchWidthAction(this);
registry.registerAction(action);
getSelectionActions().add(action.getId());
action = new MatchHeightAction(this);
registry.registerAction(action);
getSelectionActions().add(action.getId());
action = new AlignmentAction((IWorkbenchPart) this, PositionConstants.LEFT);
registry.registerAction(action);
getSelectionActions().add(action.getId());
action = new AlignmentAction((IWorkbenchPart) this, PositionConstants.RIGHT);
registry.registerAction(action);
getSelectionActions().add(action.getId());
action = new AlignmentAction((IWorkbenchPart) this, PositionConstants.TOP);
registry.registerAction(action);
getSelectionActions().add(action.getId());
action = new AlignmentAction((IWorkbenchPart) this, PositionConstants.BOTTOM);
registry.registerAction(action);
getSelectionActions().add(action.getId());
action = new AlignmentAction((IWorkbenchPart) this, PositionConstants.CENTER);
registry.registerAction(action);
getSelectionActions().add(action.getId());
action = new AlignmentAction((IWorkbenchPart) this, PositionConstants.MIDDLE);
registry.registerAction(action);
getSelectionActions().add(action.getId());
// Default Size
action = new DefaultEditPartSizeAction(this);
registry.registerAction(action);
getSelectionActions().add(action.getId());
getUpdateCommandStackActions().add((UpdateAction) action);
// Reset Aspect Ratio
action = new ResetAspectRatioAction(this);
registry.registerAction(action);
getSelectionActions().add(action.getId());
getUpdateCommandStackActions().add((UpdateAction) action);
// Properties
action = new PropertiesAction(this);
registry.registerAction(action);
getSelectionActions().add(action.getId());
// Fill Colour
action = new FillColorAction(this);
registry.registerAction(action);
getSelectionActions().add(action.getId());
getUpdateCommandStackActions().add((UpdateAction) action);
// Connection Line Width
action = new ConnectionLineWidthAction(this);
registry.registerAction(action);
getSelectionActions().add(action.getId());
getUpdateCommandStackActions().add((UpdateAction) action);
// Connection Line Color
action = new LineColorAction(this);
registry.registerAction(action);
getSelectionActions().add(action.getId());
getUpdateCommandStackActions().add((UpdateAction) action);
// Font
action = new FontAction(this);
registry.registerAction(action);
getSelectionActions().add(action.getId());
getUpdateCommandStackActions().add((UpdateAction) action);
// Font Colour
action = new FontColorAction(this);
registry.registerAction(action);
getSelectionActions().add(action.getId());
getUpdateCommandStackActions().add((UpdateAction) action);
// Opacity
action = new OpacityAction(this);
registry.registerAction(action);
getSelectionActions().add(action.getId());
getUpdateCommandStackActions().add((UpdateAction) action);
// Export As Image
action = new ExportAsImageAction(viewer);
registry.registerAction(action);
// Export As Image to Clipboard
action = new ExportAsImageToClipboardAction(viewer);
registry.registerAction(action);
// Connection Router types
action = new ConnectionRouterAction.BendPointConnectionRouterAction(this);
registry.registerAction(action);
// Doesn't work with Connection to Connection
// action = new ConnectionRouterAction.ShortestPathConnectionRouterAction(this);
registry.registerAction(action);
action = new ConnectionRouterAction.ManhattanConnectionRouterAction(this);
registry.registerAction(action);
// Send Backward
action = new SendBackwardAction(this);
registry.registerAction(action);
getSelectionActions().add(action.getId());
getUpdateCommandStackActions().add((UpdateAction) action);
// Bring Forward
action = new BringForwardAction(this);
registry.registerAction(action);
getSelectionActions().add(action.getId());
getUpdateCommandStackActions().add((UpdateAction) action);
// Send to Back
action = new SendToBackAction(this);
registry.registerAction(action);
getSelectionActions().add(action.getId());
getUpdateCommandStackActions().add((UpdateAction) action);
// Bring To Front
action = new BringToFrontAction(this);
registry.registerAction(action);
getSelectionActions().add(action.getId());
getUpdateCommandStackActions().add((UpdateAction) action);
// Text Alignment Actions
for (TextAlignmentAction a : TextAlignmentAction.createActions(this)) {
registry.registerAction(a);
getSelectionActions().add(a.getId());
getUpdateCommandStackActions().add(a);
}
// Text Position Actions
for (TextPositionAction a : TextPositionAction.createActions(this)) {
registry.registerAction(a);
getSelectionActions().add(a.getId());
getUpdateCommandStackActions().add(a);
}
// Lock Object
action = new LockObjectAction(this);
registry.registerAction(action);
getSelectionActions().add(action.getId());
getUpdateCommandStackActions().add((UpdateAction) action);
// Border Color
action = new BorderColorAction(this);
registry.registerAction(action);
getSelectionActions().add(action.getId());
getUpdateCommandStackActions().add((UpdateAction) action);
// Full Screen
if (!PlatformUtils.isMac()) {
action = new FullScreenAction(this);
registry.registerAction(action);
}
// Select Element in Tree
action = new SelectElementInTreeAction(this);
registry.registerAction(action);
getSelectionActions().add(action.getId());
}
use of org.eclipse.gef.ui.actions.DirectEditAction in project yamcs-studio by yamcs.
the class OPIEditor method createActions.
@SuppressWarnings("unchecked")
@Override
protected void createActions() {
super.createActions();
getEditorSite().getService(IContextService.class).activateContext("org.csstudio.opibuilder.opiEditor");
var registry = getActionRegistry();
IAction action;
action = new CopyTemplateAction(this);
registry.registerAction(action);
action = new MatchWidthAction(this);
registry.registerAction(action);
getSelectionActions().add(action.getId());
action = new MatchHeightAction(this);
registry.registerAction(action);
getSelectionActions().add(action.getId());
action = new DirectEditAction((IWorkbenchPart) this);
registry.registerAction(action);
getSelectionActions().add(action.getId());
var id = ActionFactory.DELETE.getId();
action = getActionRegistry().getAction(id);
action.setActionDefinitionId("org.eclipse.ui.edit.delete");
action = new PasteWidgetsAction(this);
registry.registerAction(action);
action = new CopyWidgetsAction(this);
registry.registerAction(action);
getSelectionActions().add(action.getId());
action = new CutWidgetsAction(this, (DeleteAction) registry.getAction(ActionFactory.DELETE.getId()));
registry.registerAction(action);
getSelectionActions().add(action.getId());
action = new PrintDisplayAction(this);
registry.registerAction(action);
getSelectionActions().add(action.getId());
id = ActionFactory.SELECT_ALL.getId();
action = getActionRegistry().getAction(id);
action.setActionDefinitionId("org.eclipse.ui.edit.selectAll");
id = ActionFactory.UNDO.getId();
action = getActionRegistry().getAction(id);
action.setActionDefinitionId("org.eclipse.ui.edit.undo");
id = ActionFactory.REDO.getId();
action = getActionRegistry().getAction(id);
action.setActionDefinitionId("org.eclipse.ui.edit.redo");
action = new AlignmentAction((IWorkbenchPart) this, PositionConstants.LEFT);
registry.registerAction(action);
getSelectionActions().add(action.getId());
action = new AlignmentAction((IWorkbenchPart) this, PositionConstants.RIGHT);
registry.registerAction(action);
getSelectionActions().add(action.getId());
action = new AlignmentAction((IWorkbenchPart) this, PositionConstants.TOP);
registry.registerAction(action);
getSelectionActions().add(action.getId());
action = new AlignmentAction((IWorkbenchPart) this, PositionConstants.BOTTOM);
registry.registerAction(action);
getSelectionActions().add(action.getId());
action = new AlignmentAction((IWorkbenchPart) this, PositionConstants.CENTER);
registry.registerAction(action);
getSelectionActions().add(action.getId());
action = new AlignmentAction((IWorkbenchPart) this, PositionConstants.MIDDLE);
registry.registerAction(action);
getSelectionActions().add(action.getId());
for (var dt : DistributeType.values()) {
action = new DistributeWidgetsAction(this, dt);
registry.registerAction(action);
getSelectionActions().add(action.getId());
}
for (var orderType : OrderType.values()) {
action = new ChangeOrderAction(this, orderType);
registry.registerAction(action);
getSelectionActions().add(action.getId());
}
for (var orientationType : OrientationType.values()) {
action = new ChangeOrientationAction(this, orientationType);
registry.registerAction(action);
getSelectionActions().add(action.getId());
}
action = new RunOPIAction();
registry.registerAction(action);
var pastePropAction = new PastePropertiesAction(this);
registry.registerAction(pastePropAction);
getSelectionActions().add(pastePropAction.getId());
action = new CopyPropertiesAction(this);
registry.registerAction(action);
getSelectionActions().add(action.getId());
action = new ReplaceWidgetsAction(this);
registry.registerAction(action);
getSelectionActions().add(action.getId());
}
Aggregations