本文整理汇总了Java中org.eclipse.gef.tools.CreationTool类的典型用法代码示例。如果您正苦于以下问题:Java CreationTool类的具体用法?Java CreationTool怎么用?Java CreationTool使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CreationTool类属于org.eclipse.gef.tools包,在下文中一共展示了CreationTool类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getToolEntryForClass
import org.eclipse.gef.tools.CreationTool; //导入依赖的package包/类
/**
* Try to find if the palette can create an element of a certain class. Because of current visibility restrictions, we can't actually look for factories or
* try to create such an element. For now, we have to simply look for the template class used by the CombinedTemplateCreationEntry. Ideally, we should
* search for the appropriate model creation factory.
*
* @param c
* The template to find in one of UcmPaletteRoot's CombinedTemplateCreationEntry
* @return the CreationTool that was found in the palette or null if none could be found
*/
private CreationTool getToolEntryForClass(Class c) {
Stack s = new Stack();
List l = getPaletteRoot().getChildren();
for (int i = 0; i < l.size(); i++)
s.push(l.get(i));
while (s.size() > 0) {
Object o = s.pop();
if (o instanceof PaletteContainer) {
l = ((PaletteContainer) o).getChildren();
for (int i = 0; i < l.size(); i++)
s.push(l.get(i));
} else if (o instanceof CombinedTemplateCreationEntry) {
Object template = ((CombinedTemplateCreationEntry) o).getTemplate();
if (template == c) {
return (CreationTool) ((CombinedTemplateCreationEntry) o).createTool();
}
}
}
return null;
}
示例2: testReqComp1
import org.eclipse.gef.tools.CreationTool; //导入依赖的package包/类
/**
* Test #1 for requirement: ReqComp
*
* Author: jkealey
*/
public void testReqComp1() {
// Is there a tool to create a ComponentRef in the palette?
CreationTool createtool = getToolEntryForClass(ComponentRef.class);
assertNotNull("No palette entry creates ComponentRef", createtool); //$NON-NLS-1$
// verify that both the componentref and component element are not in the model
assertEquals("Should be only one component in model", 1, urn.getUrndef().getComponents().size()); //$NON-NLS-1$
assertEquals("Should be only one component reference in model", 1, getMap().getContRefs().size()); //$NON-NLS-1$
// verify that the edit part tree is empty.
assertEquals("MapAndPathGraphEditPart should have only two children", 2, getMapEditPart(0).getChildren().size()); //$NON-NLS-1$
// simulate a CreateRequest that we would have liked to have obtained from the palette
CreateRequest cr = getCreateRequest(new ModelCreationFactory(urn, ComponentRef.class, ComponentKind.TEAM), new Point(10, 100));
assertNotNull("Unable to build create request", cr); //$NON-NLS-1$
// create a command using this CreateRequest. Note that this is a compound command that not only creates the component but positions it properly.
Command cmd = getMapEditPart(0).getCommand(cr);
assertNotNull("Can't get command to obtain a new ComponentRef", cmd); //$NON-NLS-1$
// execute the command, adding the componentref to the model
getGraphicalViewer().getEditDomain().getCommandStack().execute(cmd);
// because this test is not hooked up as a command stack change listener
// JK: I'm not even sure how this should be done but we should do it.
getMapEditPart(0).refreshChildren();
// verify that both the componentref and component element have been added in the model.
assertEquals("No component added to model", 2, urn.getUrndef().getComponents().size()); //$NON-NLS-1$
assertEquals("No component ref added to model", 2, getMap().getContRefs().size()); //$NON-NLS-1$
// verify that the edit part tree has changed.
assertEquals("MapAndPathGraphEditPart should have exactly four children (2*component+label)", 4, getMapEditPart(0).getChildren().size()); //$NON-NLS-1$
}
示例3: testReqElemDynamicStub1
import org.eclipse.gef.tools.CreationTool; //导入依赖的package包/类
/**
* Test #1 for requirement ReqElemDynamicStub
*
* Author: jkealey
*/
public void testReqElemDynamicStub1() {
// Is there a tool to create a Stub in the palette? without rewriting stuff, we can't get access to the creationfactory. assume dynamic exists if stub
// exists
CreationTool createtool = getToolEntryForClass(Stub.class);
assertNotNull("No palette entry creates Stub", createtool); //$NON-NLS-1$
}
示例4: testReqElemStaticStub1
import org.eclipse.gef.tools.CreationTool; //导入依赖的package包/类
/**
* Test #1 for requirement ReqElemStaticStub
*
* Author: jkealey
*/
public void testReqElemStaticStub1() {
// Is there a tool to create a Stub in the palette? without rewriting stuff, we can't get access to the creationfactory. assume static exists if stub
// exists
CreationTool createtool = getToolEntryForClass(Stub.class);
assertNotNull("No palette entry creates Stub", createtool); //$NON-NLS-1$
}
示例5: getTemplate
import org.eclipse.gef.tools.CreationTool; //导入依赖的package包/类
protected Object getTemplate() {
List selection = getViewer().getSelectedEditParts();
if (selection.size() == 1) {
EditPart editpart = (EditPart) getViewer().getSelectedEditParts().get(0);
Object model = editpart.getModel();
if (model instanceof PaletteTemplateEntry)
return ((PaletteTemplateEntry) model).getTemplate();
if (model instanceof CombinedTemplateCreationEntry)
return ((CombinedTemplateCreationEntry) model).getToolProperty(CreationTool.PROPERTY_CREATION_FACTORY);
}
return null;
}
示例6: testReqElemAndFork1
import org.eclipse.gef.tools.CreationTool; //导入依赖的package包/类
/**
* Test #1 for requirement ReqElemAndFork
*
* Author: jkealey
*/
public void testReqElemAndFork1() {
// Is there a tool to create a AndFork in the palette?
CreationTool createtool = getToolEntryForClass(AndFork.class);
assertNotNull("No palette entry creates AndFork", createtool); //$NON-NLS-1$
}
示例7: testReqElemAndJoin1
import org.eclipse.gef.tools.CreationTool; //导入依赖的package包/类
/**
* Test #1 for requirement ReqElemAndJoin
*
* Author: jkealey
*/
public void testReqElemAndJoin1() {
// Is there a tool to create a AndJoin in the palette?
CreationTool createtool = getToolEntryForClass(AndJoin.class);
assertNotNull("No palette entry creates AndJoin", createtool); //$NON-NLS-1$
}
示例8: testReqElemDirectionArrow1
import org.eclipse.gef.tools.CreationTool; //导入依赖的package包/类
/**
* Test #1 for requirement ReqElemDirectionArrow
*
* Author: jkealey
*/
public void testReqElemDirectionArrow1() {
// Is there a tool to create a DirectionArrow in the palette?
CreationTool createtool = getToolEntryForClass(DirectionArrow.class);
assertNotNull("No palette entry creates DirectionArrow", createtool); //$NON-NLS-1$
}
示例9: testReqElemOrFork1
import org.eclipse.gef.tools.CreationTool; //导入依赖的package包/类
/**
* Test #1 for requirement ReqElemOrFork
*
* Author: jkealey
*/
public void testReqElemOrFork1() {
// Is there a tool to create a OrFork in the palette?
CreationTool createtool = getToolEntryForClass(OrFork.class);
assertNotNull("No palette entry creates OrFork", createtool); //$NON-NLS-1$
}
示例10: testReqElemOrJoin1
import org.eclipse.gef.tools.CreationTool; //导入依赖的package包/类
/**
* Test #1 for requirement ReqElemOrJoin
*
* Author: jkealey
*/
public void testReqElemOrJoin1() {
// Is there a tool to create a OrJoin in the palette?
CreationTool createtool = getToolEntryForClass(OrJoin.class);
assertNotNull("No palette entry creates OrJoin", createtool); //$NON-NLS-1$
}
示例11: testReqElemResponsibility1
import org.eclipse.gef.tools.CreationTool; //导入依赖的package包/类
/**
* Test #1 for requirement ReqElemResponsibility
*
* Author: jkealey
*/
public void testReqElemResponsibility1() {
// Is there a tool to create a RespRef in the palette?
CreationTool createtool = getToolEntryForClass(RespRef.class);
assertNotNull("No palette entry creates RespRef", createtool); //$NON-NLS-1$
}
示例12: testReqElemTimer1
import org.eclipse.gef.tools.CreationTool; //导入依赖的package包/类
/**
* Test #1 for requirement ReqElemTimer
*
* Author: jkealey
*/
public void testReqElemTimer1() {
// Is there a tool to create a Timer in the palette?
CreationTool createtool = getToolEntryForClass(Timer.class);
assertNotNull("No palette entry creates Timer", createtool); //$NON-NLS-1$
}
示例13: testReqElemWait1
import org.eclipse.gef.tools.CreationTool; //导入依赖的package包/类
/**
* Test #1 for requirement ReqElemWait
*
* Author: jkealey
*/
public void testReqElemWait1() {
// Is there a tool to create a WaitingPlace in the palette?
CreationTool createtool = getToolEntryForClass(WaitingPlace.class);
assertNotNull("No palette entry creates WaitingPlace", createtool); //$NON-NLS-1$
}
示例14: createTool
import org.eclipse.gef.tools.CreationTool; //导入依赖的package包/类
public Tool createTool() {
return new BaseConnectionCreationTool((CreationFactory)getToolProperty(CreationTool.PROPERTY_CREATION_FACTORY));
}
示例15: CreationToolEntry
import org.eclipse.gef.tools.CreationTool; //导入依赖的package包/类
/**
* Constructor for CreationToolEntry.
*
* @param label
* the label
* @param shortDesc
* the description
* @param factory
* the CreationFactory
* @param iconSmall
* the small icon
* @param iconLarge
* the large icon
*/
public CreationToolEntry(String label, String shortDesc,
CreationFactory factory, ImageDescriptor iconSmall,
ImageDescriptor iconLarge) {
super(label, shortDesc, iconSmall, iconLarge, CreationTool.class);
this.factory = factory;
setToolProperty(CreationTool.PROPERTY_CREATION_FACTORY, factory);
}