本文整理汇总了Java中org.eclipse.gef.Tool类的典型用法代码示例。如果您正苦于以下问题:Java Tool类的具体用法?Java Tool怎么用?Java Tool使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Tool类属于org.eclipse.gef包,在下文中一共展示了Tool类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getOverlappingEditParts
import org.eclipse.gef.Tool; //导入依赖的package包/类
/**
* 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;
}
示例2: eraseTargetFeedback
import org.eclipse.gef.Tool; //导入依赖的package包/类
@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;
}
}
}
}
}
示例3: getCurrentLocation
import org.eclipse.gef.Tool; //导入依赖的package包/类
/**
* 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);
}
示例4: createTool
import org.eclipse.gef.Tool; //导入依赖的package包/类
@Override
public Tool createTool() {
final InsertedImageTool tool = new InsertedImageTool();
tool.setProperties(getToolProperties());
return tool;
}
示例5: createTool
import org.eclipse.gef.Tool; //导入依赖的package包/类
@Override
public Tool createTool() {
InsertedImageTool tool = new InsertedImageTool();
tool.setProperties(getToolProperties());
return tool;
}
示例6: CreationToolEntry
import org.eclipse.gef.Tool; //导入依赖的package包/类
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();
}
});
}
示例7: getCurrentTool
import org.eclipse.gef.Tool; //导入依赖的package包/类
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;
}
示例8: findThePaletteTool
import org.eclipse.gef.Tool; //导入依赖的package包/类
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;
}
示例9: doubleClick
import org.eclipse.gef.Tool; //导入依赖的package包/类
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);
}
示例10: should_add_a_niem_property_to_the_diagram
import org.eclipse.gef.Tool; //导入依赖的package包/类
@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));
}
示例11: leftClick
import org.eclipse.gef.Tool; //导入依赖的package包/类
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);
}
示例12: findThePaletteTool
import org.eclipse.gef.Tool; //导入依赖的package包/类
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;
}
示例13: getDefaultTool
import org.eclipse.gef.Tool; //导入依赖的package包/类
public Tool getDefaultTool() {
if (selectionTool == null)
selectionTool = new RevisionGraphSelectionTool();
return selectionTool;
}
示例14: isSelectable
import org.eclipse.gef.Tool; //导入依赖的package包/类
/**
* @see org.eclipse.gef.editparts.AbstractEditPart#isSelectable()
*/
@Override
public boolean isSelectable() {
Tool activeTool = getViewer().getEditDomain().getActiveTool();
return super.isSelectable();
}
示例15: createTool
import org.eclipse.gef.Tool; //导入依赖的package包/类
@Override
public Tool createTool() {
if (tool == null)
tool = new DirectEditCreationTool(elementType, directEdit);
return tool;
}