/** * @see org.eclipse.gef.GraphicalViewer#findHandleAt(org.eclipse.draw2d.geometry.Point) */ public Handle findHandleAt(org.eclipse.draw2d.geometry.Point p) { final GraphicalEditPart gep = (GraphicalEditPart) findObjectAtExcluding( p, new ArrayList()); if (gep == null || !(gep instanceof GuideEditPart)) return null; return new Handle() { public DragTracker getDragTracker() { return ((GuideEditPart) gep).getDragTracker(null); } public org.eclipse.draw2d.geometry.Point getAccessibleLocation() { return null; } }; }
/** * @see org.eclipse.jface.action.IAction#run() */ public void run() { JDRulerEditPart rulerEditPart = (JDRulerEditPart) viewer.getRootEditPart().getChildren().get(0); RulerProvider provider = rulerEditPart.getRulerProvider(); // Determine where the guide should be created int[] positions = provider.getGuidePositions(); Arrays.sort(positions); int index = 0; int newPosition = GuideEditPart.MIN_DISTANCE_BW_GUIDES + 1; int desiredDifference = (GuideEditPart.MIN_DISTANCE_BW_GUIDES * 2) + 1; boolean found = positions.length > 0 && positions[0] > desiredDifference; while (index < positions.length - 1 && !found) { if (positions[index + 1] - positions[index] > desiredDifference) { newPosition += positions[index]; found = true; } index++; } if (!found && positions.length > 0) newPosition += positions[positions.length - 1]; PositionDialog dlg = new PositionDialog(UIUtils.getShell(), newPosition); if (dlg.open() == Window.OK) newPosition = dlg.getPosition(); JDRulerFigure rf = rulerEditPart.getRulerFigure(); newPosition += rf.isHorizontal() ? rf.getHoffset() : rf.getVoffset(); // Create the guide and reveal it viewer.getEditDomain().getCommandStack().execute(provider.getCreateGuideCommand(newPosition)); viewer.reveal((EditPart) viewer.getEditPartRegistry().get(provider.getGuideAt(newPosition))); }
/** * @see org.eclipse.gef.GraphicalViewer#findHandleAt(org.eclipse.draw2d.geometry.Point) */ public Handle findHandleAt(org.eclipse.draw2d.geometry.Point p) { final GraphicalEditPart gep = (GraphicalEditPart) findObjectAtExcluding(p, new ArrayList<Object>()); if (gep == null || !(gep instanceof GuideEditPart)) return null; return new Handle() { public DragTracker getDragTracker() { return ((GuideEditPart) gep).getDragTracker(null); } public org.eclipse.draw2d.geometry.Point getAccessibleLocation() { return null; } }; }
public JDRulerDragTracker(JDRulerEditPart source) { this.source = source; guide = new GuideFigure(!source.isHorizontal()); guide.setVisible(false); guideline = new GuideEditPart.GuideLineFigure(); guideline.setVisible(false); }
protected boolean isCreationValid() { if (getState() == STATE_INVALID) return false; int position = getCurrentPosition(); Iterator<?> guides = source.getRulerProvider().getGuides().iterator(); while (guides.hasNext()) { int guidePos = source.getRulerProvider().getGuidePosition(guides.next()); if (Math.abs(guidePos - position) < GuideEditPart.MIN_DISTANCE_BW_GUIDES) { return false; } } return true; }
public void refreshTableColumns() { final ERDiagram diagram = getDiagram(); final IndexFigure indexFigure = (IndexFigure) getFigure(); final ERIndex index = (ERIndex) getModel(); final int notationLevel = diagram.getDiagramContents().getSettings().getNotationLevel(); final TableViewEditPart parent = (TableViewEditPart) getParent(); final List<?> figures = parent.getContentPane().getChildren(); boolean isFirst = false; if (!(figures.get(figures.size() - 1) instanceof IndexFigure)) { if (notationLevel != DiagramSettings.NOTATION_LEVLE_TITLE) { isFirst = true; parent.getContentPane().add(new GuideEditPart.GuideLineFigure()); final Label indexHeader = new Label(); indexHeader.setLabelAlignment(PositionConstants.LEFT); indexHeader.setText("<< index >>"); indexHeader.setBorder(new MarginBorder(new Insets(4, 3, 0, 0))); parent.getContentPane().add(indexHeader); } } parent.getContentPane().add(figure); if (notationLevel != DiagramSettings.NOTATION_LEVLE_TITLE) { final TableFigure tableFigure = (TableFigure) parent.getFigure(); addColumnFigure(diagram, tableFigure, indexFigure, index, isFirst, false); if (selected) { indexFigure.setBackgroundColor(ColorConstants.titleBackground); indexFigure.setForegroundColor(ColorConstants.titleForeground); } } else { indexFigure.clearLabel(); return; } }
/** * @see org.eclipse.jface.action.IAction#run() */ public void run() { RulerProvider provider = ((RulerEditPart) viewer.getRootEditPart() .getChildren().get(0)).getRulerProvider(); // Determine where the guide should be created int[] positions = provider.getGuidePositions(); Arrays.sort(positions); int index = 0; int newPosition = GuideEditPart.MIN_DISTANCE_BW_GUIDES + 1; int desiredDifference = (GuideEditPart.MIN_DISTANCE_BW_GUIDES * 2) + 1; boolean found = positions.length > 0 && positions[0] > desiredDifference; while (index < positions.length - 1 && !found) { if (positions[index + 1] - positions[index] > desiredDifference) { newPosition += positions[index]; found = true; } index++; } if (!found && positions.length > 0) newPosition += positions[positions.length - 1]; // Create the guide and reveal it viewer.getEditDomain().getCommandStack() .execute(provider.getCreateGuideCommand(newPosition)); viewer.reveal((EditPart) viewer.getEditPartRegistry().get( provider.getGuideAt(newPosition))); }