org.eclipse.gef.SnapToGrid Java Examples
The following examples show how to use
org.eclipse.gef.SnapToGrid.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ERDiagramEditor.java From ermasterr with Apache License 2.0 | 6 votes |
/** * {@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()); }
Example #2
Source File: MainDiagramEditor.java From erflute with Apache License 2.0 | 6 votes |
@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); prepareERDiagramPopupMenu(viewer); prepareERDiagramOutlinePopupMenu(); this.gotoMaker = new ERDiagramGotoMarker(this); }
Example #3
Source File: ERDiagramEditPart.java From ermasterr with Apache License 2.0 | 5 votes |
@Override public Object getAdapter(final Class key) { if (key == SnapToHelper.class) { final List<SnapToHelper> helpers = new ArrayList<SnapToHelper>(); helpers.add(new SnapToGeometry(this)); if (Boolean.TRUE.equals(getViewer().getProperty(SnapToGeometry.PROPERTY_SNAP_ENABLED))) { helpers.add(new SnapToGrid(this)); } // if (Boolean.TRUE.equals(getViewer().getProperty( // SnapToGrid.PROPERTY_GRID_ENABLED))) { // helpers.add(new SnapToGrid(this)); // } if (helpers.size() == 0) { return null; } else { return new CompoundSnapToHelper(helpers.toArray(new SnapToHelper[0])); } } return super.getAdapter(key); }
Example #4
Source File: ERDiagramEditor.java From ermaster-b with Apache License 2.0 | 5 votes |
/** * {@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.extensionLoader.addERDiagramPopupMenu(menuMgr, this .getActionRegistry()); viewer.setContextMenu(menuMgr); // if (diagram.getCurrentErmodel() == null) { // viewer.setContents(diagram); // } else { // // �Ƃ肠����OFF���āA�ŏ��Ƀt�H�[�J�X�����������Ƃ��ɃR���e���c���l�߂� // } this.outlineMenuMgr = new ERDiagramOutlinePopupMenuManager( this.diagram, this.getActionRegistry(), this.outlinePage .getOutlineActionRegistory(), this.outlinePage .getViewer()); this.gotoMaker = new ERDiagramGotoMarker(this); }
Example #5
Source File: EROneDiagramEditor.java From ermaster-b with Apache License 2.0 | 5 votes |
@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 ERDiagramOnePopupMenuManager(this.getActionRegistry(), this.model); this.extensionLoader.addERDiagramPopupMenu(menuMgr, this.getActionRegistry()); viewer.setContextMenu(menuMgr); viewer.setContents(model); // viewer.getRootEditPart().setContents(editPartFactory.); this.outlineMenuMgr = new ERDiagramOutlinePopupMenuManager( this.diagram, this.getActionRegistry(), this.outlinePage.getOutlineActionRegistory(), this.outlinePage.getViewer()); this.gotoMaker = new ERDiagramGotoMarker(this); }
Example #6
Source File: GMFTools.java From bonita-studio with GNU General Public License v2.0 | 4 votes |
/** * returns the the appropriate snap helper(s), this method will always reach * for the first reachable DiagramEditPart using the passed edit part, then * use this Diagram edit part to get the snap helper * * @param editPart * , edit part to get the snap helper for * @return */ static public Object getSnapHelper(GraphicalEditPart editPart) { // get the diagram Edit Part GraphicalEditPart diagramEditPart = editPart; if (diagramEditPart == null) { return null; } List<SnapToHelper> snapStrategies = new ArrayList<>(); EditPartViewer viewer = diagramEditPart.getViewer(); Boolean val = (Boolean) editPart.getViewer().getProperty(RulerProvider.PROPERTY_RULER_VISIBILITY); if (val != null && val.booleanValue()) { snapStrategies.add(new SnapToGuidesEx(diagramEditPart)); } val = (Boolean) viewer.getProperty(SnapToGeometry.PROPERTY_SNAP_ENABLED); if (val != null && val.booleanValue()) { snapStrategies.add(new CustomSnapToGeometryEx(diagramEditPart)); } val = (Boolean) viewer.getProperty(SnapToGrid.PROPERTY_GRID_ENABLED); if (val != null && val.booleanValue()) { snapStrategies.add(new SnapToGridEx(diagramEditPart)); } if (snapStrategies.size() == 0) { return null; } if (snapStrategies.size() == 1) { return snapStrategies.get(0); } SnapToHelper ss[] = new SnapToHelper[snapStrategies.size()]; for (int i = 0; i < snapStrategies.size(); i++) { ss[i] = snapStrategies.get(i); } return new CompoundSnapToHelperEx(ss); }