/** * The best way to think about this method is to imaging that you are shooting * an arrow through a violation indicator on the timeline. When that arrow gets * pinned to the timeline, it will be going through one or more violations * (or even no violations if you didn't shoot at a violation). To find out which * violations you "pinned," use this method. * * @param scaleTimelineMarkerEditPart * @return the overlapping edit parts */ public static List<EditPart> getOverlappingEditParts(ScaleTimelineMarkerEditPart scaleTimelineMarkerEditPart) { Tool tool = scaleTimelineMarkerEditPart.getViewer().getEditDomain().getActiveTool(); List<EditPart> editParts = null; if(tool instanceof TimelineTool) { TimelineTool timelineTool = (TimelineTool)tool; editParts = timelineTool.getEditPartsForRequest (new Request(TimelineConstants.REQ_ERASE_TOOLTIP_FEEDBACK)); } /* * there is a case where a child tooltip is displayed from a parent * and as such the above timeline tool method to get the edit parts fails * because it uses the current viewer for the tool (the current viewer is * null in this case). */ if(editParts == null) { editParts = new ArrayList<EditPart>(); editParts.add(scaleTimelineMarkerEditPart); } return editParts; }
@Override public void eraseTargetFeedback(Request request) { super.eraseTargetFeedback(request); if (request instanceof LocationRequest && tooltipShell != null && !tooltipShell.isDisposed()) { Timeline activeEditPart = TimelineUtils.getTimeline(this); if (activeEditPart != null) { EditDomain editDomain = activeEditPart.getEditDomain(); Tool tool = editDomain.getActiveTool(); if(tool instanceof TimelineTool) { TimelineTool timelineTool = (TimelineTool)tool; if(timelineTool != null && timelineTool.getTargetUnderMouse() != null && !timelineTool.getTargetUnderMouse().equals(this.getHost())) { tooltipShell.dispose(); tooltipShell = null; } } } } }
/** * Returns the current cursor location for Diagram. * * @param argumentEditPart * the argument edit part. * @return the current point. */ public static Point getCurrentLocation(ArgumentEditPart argumentEditPart) { IDiagramGraphicalViewer viewer = DcaseEditorUtil .getCurrentDcaseEditor().getDiagramGraphicalViewer(); FigureCanvas canvas = (FigureCanvas) viewer.getControl(); // the position of scrollable diagram. Point viewPoint = canvas.getViewport().getViewLocation(); Tool tool = argumentEditPart.getViewer().getEditDomain() .getActiveTool(); AbstractTool aTool = (AbstractTool) tool; Point toolLocation = null; try { Method method = AbstractTool.class.getDeclaredMethod("getLocation"); //$NON-NLS-1$ method.setAccessible(true); toolLocation = ((org.eclipse.draw2d.geometry.Point) method .invoke(aTool)).getCopy(); } catch (Exception e) { MessageWriter.writeMessageToConsole( Messages.AddPatternContributionItem_0, MessageTypeImpl.CREATE_PATTERN_FAILED); return new Point(0, 0); } return new Point(viewPoint.x + toolLocation.x, viewPoint.y + toolLocation.y); }
@Override public Tool createTool() { final InsertedImageTool tool = new InsertedImageTool(); tool.setProperties(getToolProperties()); return tool; }
@Override public Tool createTool() { InsertedImageTool tool = new InsertedImageTool(); tool.setProperties(getToolProperties()); return tool; }
public CreationToolEntry(String label, String shortDesc, IElementType elementType, ImageDescriptor iconSmall, ImageDescriptor iconLarge, boolean directEdit) { super(label, shortDesc, null, iconSmall, iconLarge); this.elementType = elementType; this.directEdit = directEdit; // Use of 'dummy' PaletteToolEntry here is required because of an // instanceof check in PaletteToolTransferDragSourceListener setTemplate(new PaletteToolEntry(null, null, null) { @Override public Tool createTool() { return CreationToolEntry.this.createTool(); } }); }
private Tool getCurrentTool() { if(timeline != null) { List<TimelineViewer> timelineViewers = timeline.getTimelineViewers(); for(TimelineViewer timelineViewer : timelineViewers) { EditDomain editDomain = timelineViewer.getEditDomain(); if(editDomain != null) { return editDomain.getActiveTool(); } } } return null; }
private Tool findThePaletteTool(final EditPartViewer theEditPartViewer, final String toolPath) { final EditDomain theDomain = theEditPartViewer.getEditDomain(); final PaletteViewer thePaletteViewer = theDomain.getPaletteViewer(); final ToolEntry toolEntry = findByLabel(thePaletteViewer.getPaletteRoot(), toolPath); thePaletteViewer.setActiveTool(toolEntry); final Tool theTool = toolEntry.createTool(); theTool.setViewer(theEditPartViewer); theTool.setEditDomain(theDomain); return theTool; }
private void doubleClick(final Tool theTool, final EditPartViewer theEditPartViewer) { final Event theEvent = new Event(); theEvent.widget = theEditPartViewer.getControl(); final MouseEvent mouseEvent = new MouseEvent(theEvent); mouseEvent.button = 1; theTool.mouseDoubleClick(mouseEvent, theEditPartViewer); }
@Ignore @Theory public void should_add_a_niem_property_to_the_diagram(final NIEMAttributeData attributeData) throws ServiceException, InterruptedException { final IMultiDiagramEditor theActiveEditor = (IMultiDiagramEditor) get_the_active_editor(); final EditPart theExchangeEditPart = navigate(theActiveEditor, THE_EXCHANGE_NAME); final EditPartViewer theViewer = theExchangeEditPart.getViewer(); doubleClick(findThePaletteTool(theExchangeEditPart, "Nodes/Class"), theViewer); final Tool thePaletteTool = findThePaletteTool(theExchangeEditPart, attributeData.thePalettePath); leftClick(thePaletteTool, theViewer); final GraphicalEditPart theContainingType = (GraphicalEditPart) findByName(theExchangeEditPart, "Class1"); final GraphicalEditPart theAttributeCompartment = (GraphicalEditPart) theContainingType.getChildren().get(1); // theViewer.reveal(theAttributeCompartment); // theViewer.select(theAttributeCompartment); leftClick(thePaletteTool, theAttributeCompartment); // final Request request = new Request(); // request.setType(RequestConstants.REQ_DIRECT_EDIT); // theAttributeCompartment.performRequest(request); final NamedElement theNewAttribute = findNamedElements( getUmlResource(theActiveEditor.getServicesRegistry().getService(ModelSet.class)), join(asList("Data", THE_PIM_NAME, THE_EXCHANGE_NAME, "Class1", attributeData.theNewAttributeName), NamedElement.SEPARATOR)).iterator().next(); assertThat(theNewAttribute, has_applied_stereotype(attributeData.theExpectedStereotype)); }
public static void leftClick(final Tool theTool, final EditPartViewer theViewer) { theTool.mouseDown(newLeftClick(theViewer), theViewer); // theTool.mouseDrag(newLeftClick(theViewer), theViewer); // theTool.mouseUp(newLeftClick(theViewer), theViewer); theViewer.getEditDomain().setActiveTool(theTool); }
public static void leftClick(final Tool theTool, final GraphicalEditPart theEditPart) { final EditPartViewer theViewer = theEditPart.getViewer(); final Event e = new Event(); final Control theControl = theViewer.getControl(); final Point theLocation = theControl.toDisplay(0, 0); e.x = theLocation.x; e.y = theLocation.y; e.widget = theControl; e.button = 1; theControl.notifyListeners(SWT.MouseEnter, e); theControl.notifyListeners(SWT.MouseDown, e); theControl.notifyListeners(SWT.MouseUp, e); // final IFigure aFigure = theEditPart.getFigure(); // final DomainEventDispatcher dispatcher = (DomainEventDispatcher) aFigure.internalGetEventDispatcher(); // MouseEvent me = newLeftClick(theViewer); // final Node theNode = (Node) theEditPart.getAdapter(Node.class); // final Bounds b = (Bounds) theNode.getLayoutConstraint(); // me.x = b.getX(); // me.y = b.getY(); // dispatcher.dispatchMouseMoved(me); // dispatcher.dispatchMouseEntered(me); // me = newLeftClick(theViewer); // me.x = b.getX(); // me.y = b.getY(); // dispatcher.dispatchMousePressed(me); // me = newLeftClick(theViewer); // me.x = b.getX(); // me.y = b.getY(); // dispatcher.dispatchMouseReleased(me); // aFigure.internalGetEventDispatcher().dispatchMouseReleased(newMouseEvent(theEditPartViewer)); // aFigure.handleMousePressed(newMouseEvent(aFigure, theEditPartViewer)); // aFigure.handleMouseReleased(newMouseEvent(aFigure, theEditPartViewer)); }
public static Tool findThePaletteTool(final EditPart theEditPart, final String toolPath) { final EditPartViewer theEditPartViewer = theEditPart.getViewer(); final PaletteViewer thePaletteViewer = theEditPartViewer.getEditDomain().getPaletteViewer(); final ToolEntry toolEntry = findByLabel(thePaletteViewer.getPaletteRoot(), toolPath); thePaletteViewer.setActiveTool(toolEntry); final Tool theTool = toolEntry.createTool(); theTool.setViewer(theEditPartViewer); theTool.setEditDomain(theEditPartViewer.getEditDomain()); return theTool; }
public Tool getDefaultTool() { if (selectionTool == null) selectionTool = new RevisionGraphSelectionTool(); return selectionTool; }
/** * @see org.eclipse.gef.editparts.AbstractEditPart#isSelectable() */ @Override public boolean isSelectable() { Tool activeTool = getViewer().getEditDomain().getActiveTool(); return super.isSelectable(); }
@Override public Tool createTool() { if (tool == null) tool = new DirectEditCreationTool(elementType, directEdit); return tool; }
@Override public Tool createTool() { if (tool == null) tool = new ConnectionCreationTool(elementType); return tool; }
public ToolListenerEvent(Tool tool, TYPE type) { super(); this.tool = tool; this.type = type; }
public Tool getTool() { return tool; }
@Override public void run() { Tool tool = getCurrentTool(); HeatMapDataEditPart heatMapDataEditPart = null; if(tool != null && tool instanceof TimelineTool) { TimelineTool timelineTool = (TimelineTool)tool; EditPart editPart = timelineTool.getTargetUnderMouse(); if(editPart != null && editPart instanceof HeatMapDataEditPart) { heatMapDataEditPart = (HeatMapDataEditPart)editPart; } } final boolean toolOverTemporalNodeEditPart = heatMapDataEditPart != null && heatMapDataEditPart.equals(lastHostEditPart); long timeTooltipHasBeenShown = System.currentTimeMillis() - lastTimeTooltipDisplayed; boolean visible = false; boolean disposed = true; if(tooltipShell != null && !tooltipShell.isDisposed()) { visible = tooltipShell.isVisible(); disposed = tooltipShell.isDisposed(); synchronized(tooltipShell) { if (timeTooltipHasBeenShown >= HeatMapDataEditPartHoverEditPolicy.tooltipDisplayTime) { if((tooltipShell != null && !disposed && visible) || !toolOverTemporalNodeEditPart) { tooltipShell.setVisible(false); tooltipShell = null; } } } } if(tooltipShell != null && timerRunnable != null && !disposed && visible) { // keep checking to make sure it's still ok to show the tooltip. tooltipShell.getDisplay().timerExec(refreshRate, timerRunnable); } }
/** * @generated */ public Tool createTool() { Tool tool = new UnspecifiedTypeCreationTool(elementTypes); tool.setProperties(getToolProperties()); return tool; }
/** * @generated */ public Tool createTool() { Tool tool = new UnspecifiedTypeConnectionTool(relationshipTypes); tool.setProperties(getToolProperties()); return tool; }
public Tool createTool( ) { return new PaletteEntryCreationTool( this.factory, paletteEntry ); }
public Tool createTool( ) { return new ReportCreationTool( this.factory, preHandle ); }
public Tool createTool( ) { return new ReportCreationTool( factory, null ) { protected void performCreation( int button ) { DNDService.getInstance( ).performDrop( getTemplate( ), getTargetEditPart( ), DND.DROP_DEFAULT, new DNDLocation( getLocation( ) ) ); } public void performCreation( EditPart editPart ) { DNDService.getInstance( ).performDrop( getTemplate( ), editPart, DND.DROP_DEFAULT, new DNDLocation( getLocation( ) ) ); } protected boolean handleMove( ) { updateTargetUnderMouse( ); boolean canMove = DNDService.getInstance( ) .validDrop( getTemplate( ), getTargetEditPart( ), DND.DROP_DEFAULT, new DNDLocation( getLocation( ) ) ); if ( canMove ) { updateTargetRequest( ); setCurrentCommand( getCommand( ) ); showTargetFeedback( ); } else { setCurrentCommand( null ); } return canMove; } }; }
public Tool createTool() { return null; }
public static void doubleClick(final Tool theTool, final EditPartViewer theEditPartViewer) { theTool.mouseDoubleClick(newLeftClick(theEditPartViewer), theEditPartViewer); }
public Tool createTool() { return new BaseConnectionCreationTool((CreationFactory)getToolProperty(CreationTool.PROPERTY_CREATION_FACTORY)); }
public Tool createTool() { return new PathTool(urn); }
/** * @return a UCMElementCreationTool */ public Tool createTool() { return new URNElementCreationTool(myFactory); }