org.eclipse.gef.editparts.ScalableFreeformRootEditPart Java Examples
The following examples show how to use
org.eclipse.gef.editparts.ScalableFreeformRootEditPart.
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: ERDiagramLayoutEditPolicy.java From ermaster-b with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} */ @Override protected void showSizeOnDropFeedback(CreateRequest request) { Point p = new Point(request.getLocation().getCopy()); ZoomManager zoomManager = ((ScalableFreeformRootEditPart) this .getHost().getRoot()).getZoomManager(); double zoom = zoomManager.getZoom(); IFigure feedback = getSizeOnDropFeedback(request); Dimension size = request.getSize().getCopy(); feedback.translateToRelative(size); feedback.setBounds(new Rectangle((int) (p.x * zoom), (int) (p.y * zoom), size.width, size.height) .expand(getCreationFeedbackOffset(request))); }
Example #2
Source File: TableViewComponentEditPolicy.java From ermaster-b with Apache License 2.0 | 6 votes |
private int getColumnIndex(DirectEditRequest editRequest) { ZoomManager zoomManager = ((ScalableFreeformRootEditPart) this .getHost().getRoot()).getZoomManager(); double zoom = zoomManager.getZoom(); IFigure figure = ((TableViewEditPart) this.getHost()).getFigure(); int center = (int) (figure.getBounds().y + (figure.getBounds().height / 2) * zoom); int index = 0; if (editRequest.getLocation().y >= center) { TableView newTableView = (TableView) this.getHost().getModel(); index = newTableView.getColumns().size(); } return index; }
Example #3
Source File: ColumnSelectionHandlesEditPolicy.java From ermasterr with Apache License 2.0 | 6 votes |
private int getColumnIndex(final DirectEditRequest editRequest) { final ZoomManager zoomManager = ((ScalableFreeformRootEditPart) getHost().getRoot()).getZoomManager(); final double zoom = zoomManager.getZoom(); final ColumnEditPart columnEditPart = (ColumnEditPart) getHost(); Column column = (Column) columnEditPart.getModel(); final TableView newTableView = (TableView) getHost().getParent().getModel(); final List<Column> columns = newTableView.getColumns(); if (column.getColumnHolder() instanceof ColumnGroup) { column = (ColumnGroup) column.getColumnHolder(); } int index = columns.indexOf(column); final Rectangle columnRectangle = getColumnRectangle(); final int center = (int) ((columnRectangle.y + (columnRectangle.height / 2)) * zoom); if (editRequest.getLocation().y >= center) { index++; } return index; }
Example #4
Source File: ERDiagramEditor.java From ermaster-b with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} */ @Override public Object getAdapter(Class type) { if (type == ZoomManager.class) { return ((ScalableFreeformRootEditPart) getGraphicalViewer() .getRootEditPart()).getZoomManager(); } if (type == IContentOutlinePage.class) { return this.outlinePage; } if (type == IGotoMarker.class) { return this.gotoMaker; } if (type == IPropertySheetPage.class) { return this.propertySheetPage; } return super.getAdapter(type); }
Example #5
Source File: ImageInfo.java From ermasterr with Apache License 2.0 | 6 votes |
private static Map<TableView, Location> getTableLocationMap(final ScalableFreeformRootEditPart rootEditPart, final int translateX, final int translateY, final ERDiagram diagram) { final Map<TableView, Location> tableLocationMap = new HashMap<TableView, Location>(); final Category category = diagram.getCurrentCategory(); for (final Object child : rootEditPart.getContents().getChildren()) { final NodeElementEditPart editPart = (NodeElementEditPart) child; final NodeElement nodeElement = (NodeElement) editPart.getModel(); if (!(nodeElement instanceof TableView)) { continue; } if (category == null || category.isVisible(nodeElement, diagram)) { final IFigure figure = editPart.getFigure(); final Rectangle figureRectangle = figure.getBounds(); final Location location = new Location(figureRectangle.x + translateX, figureRectangle.y + translateY, figureRectangle.width, figureRectangle.height); tableLocationMap.put((TableView) nodeElement, location); } } return tableLocationMap; }
Example #6
Source File: ERDiagramOutlinePage.java From ermaster-b with Apache License 2.0 | 6 votes |
private void showThumbnail() { if (quickMode) { return; } // RootEditPart�̃r���[���\�[�X�Ƃ��ăT���l�C�����쐬 ScalableFreeformRootEditPart editPart = (ScalableFreeformRootEditPart) this.graphicalViewer .getRootEditPart(); if (this.thumbnail != null) { this.thumbnail.deactivate(); } this.thumbnail = new ScrollableThumbnail((Viewport) editPart .getFigure()); this.thumbnail.setSource(editPart .getLayer(LayerConstants.PRINTABLE_LAYERS)); this.lws.setContents(this.thumbnail); }
Example #7
Source File: MainDiagramEditor.java From erflute with Apache License 2.0 | 6 votes |
@Override public Object getAdapter(@SuppressWarnings("rawtypes") Class type) { if (type == ZoomManager.class) { return ((ScalableFreeformRootEditPart) getGraphicalViewer().getRootEditPart()).getZoomManager(); } if (type == IContentOutlinePage.class) { return outlinePage; } if (type == IGotoMarker.class) { return gotoMaker; } if (type == IPropertySheetPage.class) { return propertySheetPage; } return super.getAdapter(type); }
Example #8
Source File: ColumnSelectionHandlesEditPolicy.java From erflute with Apache License 2.0 | 6 votes |
private int getColumnIndex(DirectEditRequest editRequest) { final ZoomManager zoomManager = ((ScalableFreeformRootEditPart) getHost().getRoot()).getZoomManager(); final double zoom = zoomManager.getZoom(); final ColumnEditPart columnEditPart = (ColumnEditPart) getHost(); ERColumn column = (ERColumn) columnEditPart.getModel(); final TableView newTableView = (TableView) getHost().getParent().getModel(); final List<ERColumn> columns = newTableView.getColumns(); if (column.getColumnHolder() instanceof ColumnGroup) { column = (ColumnGroup) column.getColumnHolder(); } int index = columns.indexOf(column); final Rectangle columnRectangle = getColumnRectangle(); final int center = (int) ((columnRectangle.y + (columnRectangle.height / 2)) * zoom); if (editRequest.getLocation().y >= center) { index++; } return index; }
Example #9
Source File: TableViewGraphicalNodeEditPolicy.java From erflute with Apache License 2.0 | 5 votes |
@Override public void showTargetFeedback(Request request) { final ERDiagram diagram = ERModelUtil.getDiagram(getHost().getRoot().getContents()); if (diagram.isTooltip()) { final ZoomManager zoomManager = ((ScalableFreeformRootEditPart) getHost().getRoot()).getZoomManager(); final double zoom = zoomManager.getZoom(); final TableView tableView = (TableView) getHost().getModel(); final Rectangle tableBounds = getHostFigure().getBounds(); final String name = TableViewEditPart.getTableViewName(tableView, diagram); final Label label = new Label(); label.setText(name); label.setBorder(new SimpleRaisedBorder()); label.setBackgroundColor(ColorConstants.orange); label.setOpaque(true); final Dimension dim = FigureUtilities.getTextExtents(name, Display.getCurrent().getSystemFont()); label.setBounds(new Rectangle( (int) (zoom * (tableBounds.x + 33)), (int) (zoom * (tableBounds.y + 5)), (int) (dim.width * 1.5), 20)); addFeedback(label); } super.showTargetFeedback(request); }
Example #10
Source File: ColumnSelectionHandlesEditPolicy.java From ermaster-b with Apache License 2.0 | 5 votes |
private int getColumnIndex(DirectEditRequest editRequest) { ZoomManager zoomManager = ((ScalableFreeformRootEditPart) this .getHost().getRoot()).getZoomManager(); double zoom = zoomManager.getZoom(); ColumnEditPart columnEditPart = (ColumnEditPart) this.getHost(); Column column = (Column) columnEditPart.getModel(); TableView newTableView = (TableView) this.getHost().getParent() .getModel(); List<Column> columns = newTableView.getColumns(); if (column.getColumnHolder() instanceof ColumnGroup) { column = (ColumnGroup) column.getColumnHolder(); } int index = columns.indexOf(column); Rectangle columnRectangle = this.getColumnRectangle(); int center = (int) ((columnRectangle.y + (columnRectangle.height / 2)) * zoom); if (editRequest.getLocation().y >= center) { index++; } return index; }
Example #11
Source File: TableViewGraphicalNodeEditPolicy.java From ermaster-b with Apache License 2.0 | 5 votes |
@Override public void showTargetFeedback(Request request) { ERDiagram diagram = ERModelUtil.getDiagram(this.getHost().getRoot().getContents()); if (diagram.isTooltip()) { ZoomManager zoomManager = ((ScalableFreeformRootEditPart) this .getHost().getRoot()).getZoomManager(); double zoom = zoomManager.getZoom(); TableView tableView = (TableView) this.getHost().getModel(); Rectangle tableBounds = this.getHostFigure().getBounds(); String name = TableViewEditPart.getTableViewName(tableView, diagram); Label label = new Label(); label.setText(name); label.setBorder(new SimpleRaisedBorder()); label.setBackgroundColor(ColorConstants.orange); label.setOpaque(true); Dimension dim = FigureUtilities.getTextExtents(name, Display .getCurrent().getSystemFont()); label.setBounds(new Rectangle((int) (zoom * (tableBounds.x + 33)), (int) (zoom * (tableBounds.y + 5)), (int) (dim.width * 1.5), 20)); this.addFeedback(label); } super.showTargetFeedback(request); }
Example #12
Source File: ExportToHtmlAction.java From ermaster-b with Apache License 2.0 | 5 votes |
public static Map<TableView, Location> getTableLocationMap( GraphicalViewer viewer, ERDiagram diagram) { Map<TableView, Location> tableLocationMap = new HashMap<TableView, Location>(); ScalableFreeformRootEditPart rootEditPart = (ScalableFreeformRootEditPart) viewer .getEditPartRegistry().get(LayerManager.ID); IFigure rootFigure = ((LayerManager) rootEditPart) .getLayer(LayerConstants.PRINTABLE_LAYERS); int translateX = ExportToImageAction .translateX(rootFigure.getBounds().x); int translateY = ExportToImageAction .translateY(rootFigure.getBounds().y); Category category = diagram.getCurrentCategory(); for (Object child : rootEditPart.getContents().getChildren()) { NodeElementEditPart editPart = (NodeElementEditPart) child; NodeElement nodeElement = (NodeElement) editPart.getModel(); if (!(nodeElement instanceof TableView)) { continue; } if (category == null || category.isVisible(nodeElement, diagram)) { IFigure figure = editPart.getFigure(); Rectangle figureRectangle = figure.getBounds(); Location location = new Location( figureRectangle.x + translateX, figureRectangle.y + translateY, figureRectangle.width, figureRectangle.height); tableLocationMap.put((TableView) nodeElement, location); } } return tableLocationMap; }
Example #13
Source File: Activator.java From ermaster-b with Apache License 2.0 | 5 votes |
public void run() { Shell shell = new Shell(display); shell.setLayout(new GridLayout(1, false)); ERDiagramEditPartFactory editPartFactory = new ERDiagramEditPartFactory(); viewer = new ScrollingGraphicalViewer(); viewer.setControl(new FigureCanvas(shell)); ScalableFreeformRootEditPart rootEditPart = new PagableFreeformRootEditPart( diagram); viewer.setRootEditPart(rootEditPart); viewer.setEditPartFactory(editPartFactory); viewer.setContents(diagram); }
Example #14
Source File: GraphicalEditorWithFlyoutPalette.java From birt with Eclipse Public License 1.0 | 5 votes |
protected void hookZoom( ScalableFreeformRootEditPart root ) { List zoomLevels = new ArrayList( 3 ); zoomLevels.add( ZoomManager.FIT_ALL ); zoomLevels.add( ZoomManager.FIT_WIDTH ); zoomLevels.add( ZoomManager.FIT_HEIGHT ); root.getZoomManager( ).setZoomLevelContributions( zoomLevels ); IAction zoomIn = new ZoomInAction( root.getZoomManager( ) ); IAction zoomOut = new ZoomOutAction( root.getZoomManager( ) ); getActionRegistry( ).registerAction( zoomIn ); getActionRegistry( ).registerAction( zoomOut ); getSite( ).getKeyBindingService( ).registerAction( zoomIn ); getSite( ).getKeyBindingService( ).registerAction( zoomOut ); }
Example #15
Source File: ERDiagramLayoutEditPolicy.java From erflute with Apache License 2.0 | 5 votes |
@Override protected void showSizeOnDropFeedback(CreateRequest request) { final Point p = new Point(request.getLocation().getCopy()); final ZoomManager zoomManager = ((ScalableFreeformRootEditPart) getHost().getRoot()).getZoomManager(); final double zoom = zoomManager.getZoom(); final IFigure feedback = getSizeOnDropFeedback(request); final Dimension size = request.getSize().getCopy(); feedback.translateToRelative(size); feedback.setBounds(new Rectangle((int) (p.x * zoom), (int) (p.y * zoom), size.width, size.height) .expand(getCreationFeedbackOffset(request))); }
Example #16
Source File: ERDiagramEditor.java From ermasterr with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ @Override public Object getAdapter(final Class type) { if (type == ZoomManager.class) { return ((ScalableFreeformRootEditPart) getGraphicalViewer().getRootEditPart()).getZoomManager(); } else if (type == IContentOutlinePage.class) { return outlinePage; } return super.getAdapter(type); }
Example #17
Source File: TableViewComponentEditPolicy.java From erflute with Apache License 2.0 | 5 votes |
private int getColumnIndex(DirectEditRequest editRequest) { final ZoomManager zoomManager = ((ScalableFreeformRootEditPart) getHost().getRoot()).getZoomManager(); final double zoom = zoomManager.getZoom(); final IFigure figure = ((TableViewEditPart) getHost()).getFigure(); final int center = (int) (figure.getBounds().y + (figure.getBounds().height / 2) * zoom); int index = 0; if (editRequest.getLocation().y >= center) { final TableView newTableView = (TableView) getHost().getModel(); index = newTableView.getColumns().size(); } return index; }
Example #18
Source File: ERDiagramOutlinePage.java From erflute with Apache License 2.0 | 5 votes |
private void showThumbnail() { if (quickMode) { return; } final ScalableFreeformRootEditPart editPart = (ScalableFreeformRootEditPart) graphicalViewer.getRootEditPart(); if (thumbnail != null) { thumbnail.deactivate(); } this.thumbnail = new ScrollableThumbnail((Viewport) editPart.getFigure()); thumbnail.setSource(editPart.getLayer(LayerConstants.PRINTABLE_LAYERS)); lws.setContents(thumbnail); }
Example #19
Source File: NoWindowTest.java From ermasterr with Apache License 2.0 | 5 votes |
private static void run(final Display display, final int x) { final Shell shell = new Shell(display); shell.setBounds(0, 0, 350, 350); shell.setLayout(new FillLayout(SWT.VERTICAL)); // display.syncExec(new Runnable() { // public void run() { final ERDiagramEditPartFactory editPartFactory = new ERDiagramEditPartFactory(); final GraphicalViewer viewer = new ScrollingGraphicalViewer(); viewer.setControl(new FigureCanvas(shell)); final ScalableFreeformRootEditPart rootEditPart = new PagableFreeformRootEditPart(diagram); viewer.setRootEditPart(rootEditPart); viewer.setEditPartFactory(editPartFactory); viewer.setContents(diagram); viewer.getContents().refresh(); // } // }); shell.pack(); shell.open(); int count = 0; while (count < x) { if (!display.readAndDispatch()) { try { Thread.sleep(1000); count++; } catch (final InterruptedException e) { e.printStackTrace(); } } } viewer.getContents().deactivate(); // display.dispose(); }
Example #20
Source File: ERDiagramLayoutEditPolicy.java From ermasterr with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ @Override protected void showSizeOnDropFeedback(final CreateRequest request) { final Point p = new Point(request.getLocation().getCopy()); final ZoomManager zoomManager = ((ScalableFreeformRootEditPart) getHost().getRoot()).getZoomManager(); final double zoom = zoomManager.getZoom(); final IFigure feedback = getSizeOnDropFeedback(request); final Dimension size = request.getSize().getCopy(); feedback.translateToRelative(size); feedback.setBounds(new Rectangle((int) (p.x * zoom), (int) (p.y * zoom), size.width, size.height).expand(getCreationFeedbackOffset(request))); }
Example #21
Source File: TableViewGraphicalNodeEditPolicy.java From ermasterr with Apache License 2.0 | 5 votes |
@Override public void showTargetFeedback(final Request request) { final ERDiagram diagram = (ERDiagram) getHost().getRoot().getContents().getModel(); if (diagram.isTooltip()) { final ZoomManager zoomManager = ((ScalableFreeformRootEditPart) getHost().getRoot()).getZoomManager(); final double zoom = zoomManager.getZoom(); final TableView tableView = (TableView) getHost().getModel(); final Rectangle tableBounds = getHostFigure().getBounds(); final String name = TableViewEditPart.getTableViewName(tableView, diagram); final Label label = new Label(); label.setText(name); label.setBorder(new SimpleRaisedBorder()); label.setBackgroundColor(ColorConstants.orange); label.setOpaque(true); final Dimension dim = FigureUtilities.getTextExtents(name, Display.getCurrent().getSystemFont()); label.setBounds(new Rectangle((int) (zoom * (tableBounds.x + 33)), (int) (zoom * (tableBounds.y + 5)), (int) (dim.width * 1.5), 20)); addFeedback(label); } super.showTargetFeedback(request); }
Example #22
Source File: RelationBendpointEditPolicy.java From erflute with Apache License 2.0 | 4 votes |
@Override protected void showMoveBendpointFeedback(BendpointRequest bendpointrequest) { final Relationship relation = (Relationship) getHost().getModel(); final RelationEditPart editPart = (RelationEditPart) getHost(); if (relation.getSourceWalker() == relation.getTargetWalker()) { if (bendpointrequest.getIndex() != 1) { return; } final Point point = bendpointrequest.getLocation(); getConnection().translateToRelative(point); final Bendpoint rate = getRate(point); rate.setRelative(true); final float rateX = (100f - (rate.getX() / 2)) / 100; final float rateY = (100f - (rate.getY() / 2)) / 100; final ERTableEditPart tableEditPart = (ERTableEditPart) editPart.getSource(); final Rectangle bounds = tableEditPart.getFigure().getBounds(); final Rectangle rect = new Rectangle(); rect.x = (int) (bounds.x + (bounds.width * rateX)); rect.y = (int) (bounds.y + (bounds.height * rateY)); rect.width = (int) (bounds.width * rate.getX() / 100); rect.height = (int) (bounds.height * rate.getY() / 100); relation.setSourceLocationp(100, (int) (100 * rateY)); relation.setTargetLocationp((int) (100 * rateX), 100); final LayerManager manager = (LayerManager) tableEditPart.getRoot(); final IFigure layer = manager.getLayer(LayerConstants.PRIMARY_LAYER); getFeedbackLayer().setBounds(layer.getBounds()); final List<?> children = getFeedbackLayer().getChildren(); children.clear(); getFeedbackLayer().repaint(); final ZoomManager zoomManager = ((ScalableFreeformRootEditPart) getHost().getRoot()).getZoomManager(); final double zoom = zoomManager.getZoom(); final Polyline feedbackFigure = new Polyline(); feedbackFigure.addPoint(new Point((int) (rect.x * zoom), (int) (rect.y * zoom))); feedbackFigure.addPoint(new Point((int) (rect.x * zoom), (int) ((rect.y + rect.height) * zoom))); feedbackFigure.addPoint(new Point((int) ((rect.x + rect.width) * zoom), (int) ((rect.y + rect.height) * zoom))); feedbackFigure.addPoint(new Point((int) ((rect.x + rect.width) * zoom), (int) (rect.y * zoom))); feedbackFigure.addPoint(new Point((int) (rect.x * zoom), (int) (rect.y * zoom))); feedbackFigure.setLineStyle(SWT.LINE_DASH); feedbackFigure.translateToRelative(feedbackFigure.getLocation()); addFeedback(feedbackFigure); } else { super.showMoveBendpointFeedback(bendpointrequest); } }
Example #23
Source File: LinkGroupsPage.java From birt with Eclipse Public License 1.0 | 4 votes |
private Composite createCubeArea( Composite parent ) { Composite viewerContent = new Composite( parent, SWT.BORDER ); GridData gd = new GridData( GridData.FILL_BOTH ); gd.widthHint = 500; gd.heightHint = 300; viewerContent.setLayoutData( gd ); viewerContent.setLayout( new FillLayout( ) ); viewer = new ScrollingGraphicalViewer( ); EditDomain editDomain = new EditDomain( ); ScalableFreeformRootEditPart root = new ScalableFreeformRootEditPart( ); viewer.setRootEditPart( root ); viewer.setEditDomain( editDomain ); viewer.createControl( viewerContent ); viewer.getControl( ).setBackground( ColorConstants.listBackground ); factory = new GraphicalEditPartsFactory( ); viewer.setEditPartFactory( factory ); viewer.setKeyHandler( new GraphicalViewerKeyHandler( viewer ) ); viewer.addSelectionChangedListener( new ISelectionChangedListener( ) { public void selectionChanged( SelectionChangedEvent event ) { if ( event.getSelection( ) != null ) { StructuredSelection selection = (StructuredSelection) event.getSelection( ); if ( selection.getFirstElement( ) instanceof HierarchyNodeEditPart || selection.getFirstElement( ) instanceof DatasetNodeEditPart ) { Object obj = selection.getFirstElement( ); if ( obj instanceof HierarchyNodeEditPart ) { TabularHierarchyHandle hierarchy = (TabularHierarchyHandle) ( (HierarchyNodeEditPart) obj ).getModel( ); if ( hierarchy.getPrimaryKeys( ) != null && hierarchy.getPrimaryKeys( ).size( ) > 0 ) { filterButton.setEnabled( false ); } else filterButton.setEnabled( true ); } else filterButton.setEnabled( true ); } else filterButton.setEnabled( false ); } else filterButton.setEnabled( false ); } } ); load( ); return viewerContent; }
Example #24
Source File: MainDiagramEditor.java From erflute with Apache License 2.0 | 4 votes |
@SuppressWarnings("unchecked") protected void initViewerAction(GraphicalViewer viewer) { final ScalableFreeformRootEditPart rootEditPart = new PagableFreeformRootEditPart(diagram); viewer.setRootEditPart(rootEditPart); final ZoomManager manager = rootEditPart.getZoomManager(); final double[] zoomLevels = new double[] { 0.1, 0.25, 0.5, 0.75, 0.8, 1.0, 1.5, 2.0, 2.5, 3.0, 4.0, 5.0, 10.0, 20.0 }; manager.setZoomLevels(zoomLevels); final List<String> zoomContributions = new ArrayList<>(); zoomContributions.add(ZoomManager.FIT_ALL); zoomContributions.add(ZoomManager.FIT_HEIGHT); zoomContributions.add(ZoomManager.FIT_WIDTH); manager.setZoomLevelContributions(zoomContributions); final ZoomInAction zoomInAction = new ZoomInAction(manager); final ZoomOutAction zoomOutAction = new ZoomOutAction(manager); final ZoomAdjustAction zoomAdjustAction = new ZoomAdjustAction(manager); getActionRegistry().registerAction(zoomInAction); getActionRegistry().registerAction(zoomOutAction); getActionRegistry().registerAction(zoomAdjustAction); addKeyHandler(zoomInAction); addKeyHandler(zoomOutAction); final IFigure gridLayer = rootEditPart.getLayer(LayerConstants.GRID_LAYER); gridLayer.setForegroundColor(DesignResources.GRID_COLOR); IAction action = new ToggleGridAction(viewer); getActionRegistry().registerAction(action); action = new ChangeBackgroundColorAction(this, diagram); getActionRegistry().registerAction(action); getSelectionActions().add(action.getId()); action = new ToggleMainColumnAction(this); getActionRegistry().registerAction(action); action = new LockEditAction(this); getActionRegistry().registerAction(action); action = new ExportToDBAction(this); getActionRegistry().registerAction(action); this.actionBarContributor = new ERDiagramActionBarContributor(zoomComboContributionItem); }
Example #25
Source File: NoWindowTest.java From ermaster-b with Apache License 2.0 | 4 votes |
private static void run(Display display, int x) { Shell shell = new Shell(display); shell.setBounds(0, 0, 350, 350); shell.setLayout(new FillLayout(SWT.VERTICAL)); // display.syncExec(new Runnable() { // public void run() { ERDiagramEditPartFactory editPartFactory = new ERDiagramEditPartFactory(); GraphicalViewer viewer = new ScrollingGraphicalViewer(); viewer.setControl(new FigureCanvas(shell)); ScalableFreeformRootEditPart rootEditPart = new PagableFreeformRootEditPart( diagram); viewer.setRootEditPart(rootEditPart); viewer.setEditPartFactory(editPartFactory); viewer.setContents(diagram); viewer.getContents().refresh(); // } // }); shell.pack(); shell.open(); int count = 0; while (count < x) { if (!display.readAndDispatch()) { try { Thread.sleep(1000); count++; } catch (InterruptedException e) { e.printStackTrace(); } } } viewer.getContents().deactivate(); // display.dispose(); }
Example #26
Source File: ERDiagramEditor.java From ermaster-b with Apache License 2.0 | 4 votes |
@SuppressWarnings("unchecked") protected void initViewerAction(GraphicalViewer viewer) { ScalableFreeformRootEditPart rootEditPart = new PagableFreeformRootEditPart( this.diagram); viewer.setRootEditPart(rootEditPart); ZoomManager manager = rootEditPart.getZoomManager(); double[] zoomLevels = new double[] { 0.1, 0.25, 0.5, 0.75, 0.8, 1.0, 1.5, 2.0, 2.5, 3.0, 4.0, 5.0, 10.0, 20.0 }; manager.setZoomLevels(zoomLevels); List<String> zoomContributions = new ArrayList<String>(); zoomContributions.add(ZoomManager.FIT_ALL); zoomContributions.add(ZoomManager.FIT_HEIGHT); zoomContributions.add(ZoomManager.FIT_WIDTH); manager.setZoomLevelContributions(zoomContributions); ZoomInAction zoomInAction = new ZoomInAction(manager); ZoomOutAction zoomOutAction = new ZoomOutAction(manager); ZoomAdjustAction zoomAdjustAction = new ZoomAdjustAction(manager); this.getActionRegistry().registerAction(zoomInAction); this.getActionRegistry().registerAction(zoomOutAction); this.getActionRegistry().registerAction(zoomAdjustAction); this.addKeyHandler(zoomInAction); this.addKeyHandler(zoomOutAction); IFigure gridLayer = rootEditPart.getLayer(LayerConstants.GRID_LAYER); gridLayer.setForegroundColor(Resources.GRID_COLOR); IAction action = new ToggleGridAction(viewer); this.getActionRegistry().registerAction(action); action = new ChangeBackgroundColorAction(this, this.diagram); this.getActionRegistry().registerAction(action); this.getSelectionActions().add(action.getId()); action = new EditExcelAction(this, this.diagram); this.getActionRegistry().registerAction(action); this.getSelectionActions().add(action.getId()); action = new ToggleMainColumnAction(this); this.getActionRegistry().registerAction(action); action = new LockEditAction(this); this.getActionRegistry().registerAction(action); action = new ExportToDBAction(this); this.getActionRegistry().registerAction(action); this.actionBarContributor = new ERDiagramActionBarContributor( this.zoomComboContributionItem); // action = new ToggleRulerVisibilityAction(viewer); // this.getActionRegistry().registerAction(action); // // action = new ToggleSnapToGeometryAction(viewer); // this.getActionRegistry().registerAction(action); }
Example #27
Source File: RelationBendpointEditPolicy.java From ermaster-b with Apache License 2.0 | 4 votes |
/** * {@inheritDoc} */ @Override protected void showMoveBendpointFeedback(BendpointRequest bendpointrequest) { Relation relation = (Relation) getHost().getModel(); RelationEditPart editPart = (RelationEditPart) this.getHost(); if (relation.getSource() == relation.getTarget()) { if (bendpointrequest.getIndex() != 1) { return; } Point point = bendpointrequest.getLocation(); this.getConnection().translateToRelative(point); Bendpoint rate = this.getRate(point); rate.setRelative(true); float rateX = (100f - (rate.getX() / 2)) / 100; float rateY = (100f - (rate.getY() / 2)) / 100; ERTableEditPart tableEditPart = (ERTableEditPart) editPart .getSource(); Rectangle bounds = tableEditPart.getFigure().getBounds(); Rectangle rect = new Rectangle(); rect.x = (int) (bounds.x + (bounds.width * rateX)); rect.y = (int) (bounds.y + (bounds.height * rateY)); rect.width = (int) (bounds.width * rate.getX() / 100); rect.height = (int) (bounds.height * rate.getY() / 100); relation.setSourceLocationp(100, (int) (100 * rateY)); relation.setTargetLocationp((int) (100 * rateX), 100); LayerManager manager = (LayerManager) tableEditPart.getRoot(); IFigure layer = manager.getLayer(LayerConstants.PRIMARY_LAYER); this.getFeedbackLayer().setBounds(layer.getBounds()); List children = this.getFeedbackLayer().getChildren(); children.clear(); this.getFeedbackLayer().repaint(); ZoomManager zoomManager = ((ScalableFreeformRootEditPart) this .getHost().getRoot()).getZoomManager(); double zoom = zoomManager.getZoom(); Polyline feedbackFigure = new Polyline(); feedbackFigure.addPoint(new Point((int) (rect.x * zoom), (int) (rect.y * zoom))); feedbackFigure.addPoint(new Point((int) (rect.x * zoom), (int) ((rect.y + rect.height) * zoom))); feedbackFigure.addPoint(new Point( (int) ((rect.x + rect.width) * zoom), (int) ((rect.y + rect.height) * zoom))); feedbackFigure .addPoint(new Point((int) ((rect.x + rect.width) * zoom), (int) (rect.y * zoom))); feedbackFigure.addPoint(new Point((int) (rect.x * zoom), (int) (rect.y * zoom))); feedbackFigure.setLineStyle(SWT.LINE_DASH); feedbackFigure.translateToRelative(feedbackFigure.getLocation()); this.addFeedback(feedbackFigure); } else { super.showMoveBendpointFeedback(bendpointrequest); } }
Example #28
Source File: TableViewComponentEditPolicy.java From ermasterr with Apache License 2.0 | 4 votes |
private int getColumnIndex(final DirectEditRequest editRequest) { final ZoomManager zoomManager = ((ScalableFreeformRootEditPart) getHost().getRoot()).getZoomManager(); final double zoom = zoomManager.getZoom(); final IFigure figure = ((TableViewEditPart) getHost()).getFigure(); final int center = (int) (figure.getBounds().y + (figure.getBounds().height / 2) * zoom); int index = 0; if (editRequest.getLocation().y >= center) { final TableView newTableView = (TableView) getHost().getModel(); index = newTableView.getColumns().size(); } return index; }
Example #29
Source File: RelationBendpointEditPolicy.java From ermasterr with Apache License 2.0 | 4 votes |
/** * {@inheritDoc} */ @Override protected void showMoveBendpointFeedback(final BendpointRequest bendpointrequest) { final Relation relation = (Relation) getHost().getModel(); final RelationEditPart editPart = (RelationEditPart) getHost(); if (relation.getSource() == relation.getTarget()) { if (bendpointrequest.getIndex() != 1) { return; } final Point point = bendpointrequest.getLocation(); getConnection().translateToRelative(point); final Bendpoint rate = getRate(point); rate.setRelative(true); final float rateX = (100f - (rate.getX() / 2)) / 100; final float rateY = (100f - (rate.getY() / 2)) / 100; final ERTableEditPart tableEditPart = (ERTableEditPart) editPart.getSource(); final Rectangle bounds = tableEditPart.getFigure().getBounds(); final Rectangle rect = new Rectangle(); rect.x = (int) (bounds.x + (bounds.width * rateX)); rect.y = (int) (bounds.y + (bounds.height * rateY)); rect.width = bounds.width * rate.getX() / 100; rect.height = bounds.height * rate.getY() / 100; relation.setSourceLocationp(100, (int) (100 * rateY)); relation.setTargetLocationp((int) (100 * rateX), 100); final LayerManager manager = (LayerManager) tableEditPart.getRoot(); final IFigure layer = manager.getLayer(LayerConstants.PRIMARY_LAYER); getFeedbackLayer().setBounds(layer.getBounds()); final List children = getFeedbackLayer().getChildren(); children.clear(); getFeedbackLayer().repaint(); final ZoomManager zoomManager = ((ScalableFreeformRootEditPart) getHost().getRoot()).getZoomManager(); final double zoom = zoomManager.getZoom(); final Polyline feedbackFigure = new Polyline(); feedbackFigure.addPoint(new Point((int) (rect.x * zoom), (int) (rect.y * zoom))); feedbackFigure.addPoint(new Point((int) (rect.x * zoom), (int) ((rect.y + rect.height) * zoom))); feedbackFigure.addPoint(new Point((int) ((rect.x + rect.width) * zoom), (int) ((rect.y + rect.height) * zoom))); feedbackFigure.addPoint(new Point((int) ((rect.x + rect.width) * zoom), (int) (rect.y * zoom))); feedbackFigure.addPoint(new Point((int) (rect.x * zoom), (int) (rect.y * zoom))); feedbackFigure.setLineStyle(SWT.LINE_DASH); feedbackFigure.translateToRelative(feedbackFigure.getLocation()); addFeedback(feedbackFigure); } else { super.showMoveBendpointFeedback(bendpointrequest); } }
Example #30
Source File: ERDiagramEditor.java From ermasterr with Apache License 2.0 | 4 votes |
@SuppressWarnings("unchecked") private void initViewerAction(final GraphicalViewer viewer) { final ScalableFreeformRootEditPart rootEditPart = new PagableFreeformRootEditPart(diagram); viewer.setRootEditPart(rootEditPart); final ZoomManager manager = rootEditPart.getZoomManager(); final double[] zoomLevels = new double[] {0.1, 0.25, 0.5, 0.75, 0.8, 1.0, 1.5, 2.0, 2.5, 3.0, 4.0, 5.0, 10.0, 20.0}; manager.setZoomLevels(zoomLevels); final List<String> zoomContributions = new ArrayList<String>(); zoomContributions.add(ZoomManager.FIT_ALL); zoomContributions.add(ZoomManager.FIT_HEIGHT); zoomContributions.add(ZoomManager.FIT_WIDTH); manager.setZoomLevelContributions(zoomContributions); final ZoomInAction zoomInAction = new ZoomInAction(manager); final ZoomOutAction zoomOutAction = new ZoomOutAction(manager); final ZoomAdjustAction zoomAdjustAction = new ZoomAdjustAction(manager); getActionRegistry().registerAction(zoomInAction); getActionRegistry().registerAction(zoomOutAction); getActionRegistry().registerAction(zoomAdjustAction); addKeyHandler(zoomInAction); addKeyHandler(zoomOutAction); final IFigure gridLayer = rootEditPart.getLayer(LayerConstants.GRID_LAYER); gridLayer.setForegroundColor(Resources.GRID_COLOR); IAction action = new ToggleGridAction(viewer); getActionRegistry().registerAction(action); action = new ToggleSnapToGeometryAction(viewer); getActionRegistry().registerAction(action); action = new ChangeBackgroundColorAction(this, diagram); getActionRegistry().registerAction(action); getSelectionActions().add(action.getId()); action = new TooltipAction(this); getActionRegistry().registerAction(action); action = new LockEditAction(this); getActionRegistry().registerAction(action); action = new ExportToDBAction(this); getActionRegistry().registerAction(action); actionBarContributor = new ERDiagramActionBarContributor(); actionBarContributor.init(getEditorSite().getActionBars(), getSite().getPage()); // action = new ToggleRulerVisibilityAction(viewer); // this.getActionRegistry().registerAction(action); }