Java 类org.eclipse.gef.Tool 实例源码

项目:OpenSPIFe    文件:ScaleTimelineMarkerTooltip.java   
/**
 * 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;
}
项目:OpenSPIFe    文件:HeatMapDataEditPartHoverEditPolicy.java   
@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;
                }
            }
        }
    }
}
项目:d-case_editor    文件:ModuleUtil.java   
/**
 * 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);
}
项目:ermasterr    文件:InsertImageTool.java   
@Override
public Tool createTool() {
    final InsertedImageTool tool = new InsertedImageTool();
    tool.setProperties(getToolProperties());

    return tool;
}
项目:ermaster-k    文件:InsertImageTool.java   
@Override
public Tool createTool() {
    InsertedImageTool tool = new InsertedImageTool();
    tool.setProperties(getToolProperties());

    return tool;
}
项目:statecharts    文件:DefaultSCTPaletteFactory.java   
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();
        }
    });
}
项目:erflute    文件:InsertImageTool.java   
@Override
public Tool createTool() {
    final InsertedImageTool tool = new InsertedImageTool();
    tool.setProperties(getToolProperties());

    return tool;
}
项目:OpenSPIFe    文件:HeatMapDataEditPartHoverEditPolicy.java   
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;
}
项目:ermaster-nhit    文件:InsertImageTool.java   
@Override
public Tool createTool() {
    InsertedImageTool tool = new InsertedImageTool();
    tool.setProperties(getToolProperties());

    return tool;
}
项目:UML-Testing-Tool    文件:ClassDiagramPaletteTest.java   
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;
}
项目:UML-Testing-Tool    文件:ClassDiagramPaletteTest.java   
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);
}
项目:NIEM-Modeling-Tool    文件:NiemUmlEditorTest.java   
@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));
}
项目:NIEM-Modeling-Tool    文件:PapyrusUtils.java   
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);
}
项目:NIEM-Modeling-Tool    文件:PapyrusUtils.java   
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));
}
项目:NIEM-Modeling-Tool    文件:PapyrusUtils.java   
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;
}
项目:subclipse    文件:RevisionGraphEditDomain.java   
public Tool getDefaultTool() {
    if (selectionTool == null)
        selectionTool = new RevisionGraphSelectionTool();
    return selectionTool;
}
项目:NEXCORE-UML-Modeler    文件:LifeLineEditPart.java   
/**
 * @see org.eclipse.gef.editparts.AbstractEditPart#isSelectable()
 */
@Override
public boolean isSelectable() {
    Tool activeTool = getViewer().getEditDomain().getActiveTool();
    return super.isSelectable();
}
项目:statecharts    文件:DefaultSCTPaletteFactory.java   
@Override
public Tool createTool() {
    if (tool == null)
        tool = new DirectEditCreationTool(elementType, directEdit);
    return tool;
}
项目:statecharts    文件:DefaultSCTPaletteFactory.java   
@Override
public Tool createTool() {
    if (tool == null)
        tool = new ConnectionCreationTool(elementType);
    return tool;
}
项目:OpenSPIFe    文件:ToolImpl.java   
public ToolListenerEvent(Tool tool, TYPE type) {
    super();
    this.tool = tool;
    this.type = type;
}
项目:OpenSPIFe    文件:ToolImpl.java   
public Tool getTool() {
    return tool;
}
项目:OpenSPIFe    文件:HeatMapDataEditPartHoverEditPolicy.java   
@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);
    }
}
项目:ROADDesigner    文件:SmcPaletteFactory.java   
/**
 * @generated
 */
public Tool createTool() {
    Tool tool = new UnspecifiedTypeCreationTool(elementTypes);
    tool.setProperties(getToolProperties());
    return tool;
}
项目:ROADDesigner    文件:SmcPaletteFactory.java   
/**
 * @generated
 */
public Tool createTool() {
    Tool tool = new UnspecifiedTypeConnectionTool(relationshipTypes);
    tool.setProperties(getToolProperties());
    return tool;
}
项目:birt    文件:CommandCombinedTemplateCreationEntry.java   
public Tool createTool( )
{
    return new PaletteEntryCreationTool( this.factory, paletteEntry );
}
项目:birt    文件:ReportCombinedTemplateCreationEntry.java   
public Tool createTool( )
{
    return new ReportCreationTool( this.factory, preHandle );
}
项目:birt    文件:DesignerPaletteFactory.java   
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;
        }

    };
}
项目:HelloBrazil    文件:Wc2014PaletteFactory.java   
/**
 * @generated
 */
public Tool createTool() {
    Tool tool = new UnspecifiedTypeCreationTool(elementTypes);
    tool.setProperties(getToolProperties());
    return tool;
}
项目:HelloBrazil    文件:Wc2014PaletteFactory.java   
/**
 * @generated
 */
public Tool createTool() {
    Tool tool = new UnspecifiedTypeConnectionTool(relationshipTypes);
    tool.setProperties(getToolProperties());
    return tool;
}
项目:glassmaker    文件:PaletteView.java   
public Tool createTool() {
    return null;
}
项目:NIEM-Modeling-Tool    文件:PapyrusUtils.java   
public static void doubleClick(final Tool theTool, final EditPartViewer theEditPartViewer) {
    theTool.mouseDoubleClick(newLeftClick(theEditPartViewer), theEditPartViewer);
}
项目:seg.jUCMNav    文件:BaseConnectionCreationToolEntry.java   
public Tool createTool() {
    return new BaseConnectionCreationTool((CreationFactory)getToolProperty(CreationTool.PROPERTY_CREATION_FACTORY));
}
项目:seg.jUCMNav    文件:PathToolEntry.java   
public Tool createTool() {
    return new PathTool(urn);
}
项目:seg.jUCMNav    文件:URNElementCreationEntry.java   
/**
 * @return a UCMElementCreationTool
 */
public Tool createTool() {
    return new URNElementCreationTool(myFactory);
}
项目:MMINT    文件:NECSIS14_ClassDiagramPaletteFactory.java   
/**
 * @generated
 */
public Tool createTool() {
    Tool tool = new UnspecifiedTypeCreationTool(elementTypes);
    tool.setProperties(getToolProperties());
    return tool;
}
项目:MMINT    文件:NECSIS14_ClassDiagramPaletteFactory.java   
/**
 * @generated
 */
public Tool createTool() {
    Tool tool = new UnspecifiedTypeConnectionTool(relationshipTypes);
    tool.setProperties(getToolProperties());
    return tool;
}
项目:MMINT    文件:NECSIS14_DatabaseSchemaPaletteFactory.java   
/**
 * @generated
 */
public Tool createTool() {
    Tool tool = new UnspecifiedTypeCreationTool(elementTypes);
    tool.setProperties(getToolProperties());
    return tool;
}
项目:MMINT    文件:RelationalDatabasePaletteFactory.java   
/**
 * @generated
 */
public Tool createTool() {
    Tool tool = new UnspecifiedTypeCreationTool(elementTypes);
    tool.setProperties(getToolProperties());
    return tool;
}
项目:MMINT    文件:RelationalDatabasePaletteFactory.java   
/**
 * @generated
 */
public Tool createTool() {
    Tool tool = new UnspecifiedTypeConnectionTool(relationshipTypes);
    tool.setProperties(getToolProperties());
    return tool;
}
项目:MMINT    文件:IStarPaletteFactory.java   
/**
 * @generated
 */
public Tool createTool() {
    Tool tool = new UnspecifiedTypeCreationTool(elementTypes);
    tool.setProperties(getToolProperties());
    return tool;
}