use of org.jboss.tools.hibernate.ui.diagram.rulers.DiagramRulerProvider in project jbosstools-hibernate by jbosstools.
the class DiagramViewer method initializeGraphicalViewer.
protected void initializeGraphicalViewer() {
final GraphicalViewer viewer = getGraphicalViewer();
viewer.setEditPartFactory(new OrmEditPartFactory());
//
viewer.setKeyHandler(new GraphicalViewerKeyHandler(viewer).setParent(getCommonKeyHandler()));
//
List<String> zoomLevels = new ArrayList<String>(3);
zoomLevels.add(ZoomManager.FIT_ALL);
zoomLevels.add(ZoomManager.FIT_WIDTH);
zoomLevels.add(ZoomManager.FIT_HEIGHT);
gefRootEditPart.getZoomManager().setZoomLevelContributions(zoomLevels);
IAction zoomIn = new ZoomInAction(gefRootEditPart.getZoomManager());
IAction zoomOut = new ZoomOutAction(gefRootEditPart.getZoomManager());
getActionRegistry().registerAction(zoomIn);
getActionRegistry().registerAction(zoomOut);
//
viewer.setRootEditPart(gefRootEditPart);
viewer.addDropTargetListener(createTransferDropTargetListener());
viewer.setContents(getOrmDiagram());
PopupMenuProvider provider = new PopupMenuProvider(viewer, getActionRegistry());
viewer.setContextMenu(provider);
// $NON-NLS-1$
getSite().registerContextMenu("FlowDiagramContextmenu", provider, viewer);
// Scroll-wheel Zoom
viewer.setProperty(MouseWheelHandler.KeyGenerator.getKey(SWT.MOD1), MouseWheelZoomHandler.SINGLETON);
// Ruler properties
DiagramRuler ruler = getOrmDiagram().getRuler(PositionConstants.WEST);
RulerProvider rulerProvider = null;
if (ruler != null) {
rulerProvider = new DiagramRulerProvider(ruler);
}
getGraphicalViewer().setProperty(RulerProvider.PROPERTY_VERTICAL_RULER, rulerProvider);
ruler = getOrmDiagram().getRuler(PositionConstants.NORTH);
rulerProvider = null;
if (ruler != null) {
rulerProvider = new DiagramRulerProvider(ruler);
}
getGraphicalViewer().setProperty(RulerProvider.PROPERTY_HORIZONTAL_RULER, rulerProvider);
getGraphicalViewer().setProperty(RulerProvider.PROPERTY_RULER_VISIBILITY, new Boolean(getOrmDiagram().getRulerVisibility()));
loadProperties();
updateConnectionRouterActions();
}
use of org.jboss.tools.hibernate.ui.diagram.rulers.DiagramRulerProvider in project jbosstools-hibernate by jbosstools.
the class DiagramViewer method loadProperties.
protected boolean loadProperties() {
if (getOrmDiagram() == null || getGraphicalViewer() == null) {
return false;
}
// Ruler properties
DiagramRuler ruler = getOrmDiagram().getRuler(PositionConstants.WEST);
RulerProvider provider = null;
if (ruler != null) {
provider = new DiagramRulerProvider(ruler);
}
getGraphicalViewer().setProperty(RulerProvider.PROPERTY_VERTICAL_RULER, provider);
ruler = getOrmDiagram().getRuler(PositionConstants.NORTH);
provider = null;
if (ruler != null) {
provider = new DiagramRulerProvider(ruler);
}
getGraphicalViewer().setProperty(RulerProvider.PROPERTY_HORIZONTAL_RULER, provider);
getGraphicalViewer().setProperty(RulerProvider.PROPERTY_RULER_VISIBILITY, new Boolean(getOrmDiagram().getRulerVisibility()));
// Snap to Geometry property
getGraphicalViewer().setProperty(SnapToGeometry.PROPERTY_SNAP_ENABLED, new Boolean(getOrmDiagram().isSnapToGeometryEnabled()));
// Grid properties
getGraphicalViewer().setProperty(SnapToGrid.PROPERTY_GRID_ENABLED, new Boolean(getOrmDiagram().isGridEnabled()));
// We keep grid visibility and enablement in sync
getGraphicalViewer().setProperty(SnapToGrid.PROPERTY_GRID_VISIBLE, new Boolean(getOrmDiagram().isGridEnabled()));
// Zoom
ZoomManager manager = (ZoomManager) getGraphicalViewer().getProperty(ZoomManager.class.toString());
if (manager != null) {
manager.setZoom(getOrmDiagram().getZoom());
}
return true;
}
Aggregations