use of org.eclipse.gef.ui.actions.ToggleRulerVisibilityAction in project jbosstools-hibernate by jbosstools.
the class DiagramViewer method configureGraphicalViewer.
protected void configureGraphicalViewer() {
super.configureGraphicalViewer();
//
loadProperties();
// Actions
IAction showRulers = new ToggleRulerVisibilityAction(getGraphicalViewer());
getActionRegistry().registerAction(showRulers);
IAction snapAction = new ToggleSnapToGeometryAction(getGraphicalViewer());
getActionRegistry().registerAction(snapAction);
IAction showGrid = new ToggleGridAction(getGraphicalViewer());
getActionRegistry().registerAction(showGrid);
}
use of org.eclipse.gef.ui.actions.ToggleRulerVisibilityAction in project yamcs-studio by yamcs.
the class OPIEditor method configureGraphicalViewer.
@Override
protected void configureGraphicalViewer() {
super.configureGraphicalViewer();
var viewer = (ScrollingGraphicalViewer) getGraphicalViewer();
viewer.setEditPartFactory(new WidgetEditPartFactory(ExecutionMode.EDIT_MODE));
ScalableFreeformRootEditPart root = new ScalableFreeformRootEditPart() {
@Override
public Object getAdapter(@SuppressWarnings("rawtypes") final Class key) {
if (key == AutoexposeHelper.class) {
return new ViewportAutoexposeHelper(this);
}
return super.getAdapter(key);
}
};
// set clipping strategy for connection layer of connection can be hide
// when its source or target is not showing.
var connectionLayer = (ConnectionLayer) root.getLayer(LayerConstants.CONNECTION_LAYER);
connectionLayer.setClippingStrategy(new PatchedConnectionLayerClippingStrategy(connectionLayer));
viewer.setRootEditPart(root);
viewer.setKeyHandler(new GraphicalViewerKeyHandler(viewer).setParent(getCommonKeyHandler()));
ContextMenuProvider cmProvider = new OPIEditorContextMenuProvider(viewer, getActionRegistry());
viewer.setContextMenu(cmProvider);
getSite().registerContextMenu(cmProvider, viewer);
// Grid Action
IAction action = new ToggleGridAction(getGraphicalViewer()) {
@Override
public boolean isChecked() {
return getDisplayModel().isShowGrid();
}
@Override
public void run() {
getCommandStack().execute(new SetWidgetPropertyCommand(displayModel, DisplayModel.PROP_SHOW_GRID, !isChecked()));
}
};
getActionRegistry().registerAction(action);
// Ruler Action
configureRuler();
action = new ToggleRulerVisibilityAction(getGraphicalViewer()) {
@Override
public boolean isChecked() {
return getDisplayModel().isShowRuler();
}
@Override
public void run() {
getCommandStack().execute(new SetWidgetPropertyCommand(displayModel, DisplayModel.PROP_SHOW_RULER, !isChecked()));
}
};
getActionRegistry().registerAction(action);
// Snap to Geometry Action
IAction geometryAction = new ToggleSnapToGeometryAction(getGraphicalViewer()) {
@Override
public boolean isChecked() {
return getDisplayModel().isSnapToGeometry();
}
@Override
public void run() {
getCommandStack().execute(new SetWidgetPropertyCommand(displayModel, DisplayModel.PROP_SNAP_GEOMETRY, !isChecked()));
}
};
getActionRegistry().registerAction(geometryAction);
// configure zoom actions
var zm = root.getZoomManager();
if (zm != null) {
List<String> zoomLevels = new ArrayList<>(3);
zoomLevels.add(ZoomManager.FIT_ALL);
zoomLevels.add(ZoomManager.FIT_WIDTH);
zoomLevels.add(ZoomManager.FIT_HEIGHT);
zm.setZoomLevelContributions(zoomLevels);
zm.setZoomLevels(createZoomLevels());
IAction zoomIn = new ZoomInAction(zm);
IAction zoomOut = new ZoomOutAction(zm);
getActionRegistry().registerAction(zoomIn);
getActionRegistry().registerAction(zoomOut);
}
/* scroll-wheel zoom */
getGraphicalViewer().setProperty(MouseWheelHandler.KeyGenerator.getKey(SWT.MOD1), MouseWheelZoomHandler.SINGLETON);
// status line listener
getGraphicalViewer().addSelectionChangedListener(new ISelectionChangedListener() {
private IStatusLineManager statusLine = ((ActionBarContributor) getEditorSite().getActionBarContributor()).getActionBars().getStatusLineManager();
@Override
public void selectionChanged(SelectionChangedEvent event) {
updateStatusLine(statusLine);
}
});
}
Aggregations