Java源码示例:org.eclipse.gef.Tool
示例1
protected void hideFeedback() {
for (IFigure figure : figures) {
if (figure != null && figure.getParent() != null) {
layer.remove(figure);
if(figure instanceof DraggableElement)
((DraggableElement) figure).freeHandle();
if(figure instanceof CustomConnectionHandle){
((CustomConnectionHandle) figure).freeHandle();
}
}
}
figures.clear();
for(Tool tool : tools){
if(tool != null){
if(tool instanceof BonitaUnspecifiedTypeCreationTool)
tool.deactivate();
}
}
}
示例2
@Override
public Tool createTool() {
final InsertedImageTool tool = new InsertedImageTool();
tool.setProperties(getToolProperties());
return tool;
}
示例3
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();
}
});
}
示例4
@Override
public Tool createTool() {
final InsertedImageTool tool = new InsertedImageTool();
tool.setProperties(getToolProperties());
return tool;
}
示例5
private void fillList(PaletteContainer container, List<ToolAndToolEntry> list) {
for (Object child : container.getChildren()) {
if (child instanceof ToolEntry) {
ToolEntry entry = (ToolEntry)child;
/*create only one tool per entry*/
Tool tool1 = entry.createTool();
if(tool1 != null){
tool1.setEditDomain(domain);
if ( tool1 instanceof UnspecifiedTypeCreationTool) {
UnspecifiedTypeCreationTool tool = (UnspecifiedTypeCreationTool)tool1;
CreateUnspecifiedTypeRequest request = (CreateUnspecifiedTypeRequest) tool.createCreateRequest();
EClass targetEClass = ((List<IElementType>)request.getElementTypes()).get(0).getEClass();
if ((ProcessPackage.Literals.FLOW_ELEMENT.isSuperTypeOf(targetEClass))
|| ProcessPackage.Literals.TEXT_ANNOTATION.isSuperTypeOf(targetEClass)) {
list.add(new ToolAndToolEntry(tool1, entry));
} else {
tool1.deactivate();
}
}else if(tool1 instanceof UnspecifiedTypeConnectionTool){
list.add(new ToolAndToolEntry(tool1, entry));
} else if(tool1 != null){
tool1.deactivate();
}
}
} else if (child instanceof PaletteContainer) {
fillList((PaletteContainer)child, list);
}
}
}
示例6
/**
*
*/
protected Point getPartAbsoluteCursorLocation() {
org.eclipse.draw2d.geometry.Point toolLocation = null;
try {
Tool tool = selectedTargetEditPart.getViewer().getEditDomain().getActiveTool();
AbstractTool aTool = (AbstractTool) tool;
Method m = AbstractTool.class.getDeclaredMethod("getLocation"); //$NON-NLS-1$
m.setAccessible(true);
toolLocation = ((org.eclipse.draw2d.geometry.Point) m.invoke(aTool)).getCopy();
IFigure parentFigure = selectedTargetEditPart.getFigure().getParent();
while( parentFigure != null ) {
if(parentFigure instanceof Viewport) {
Viewport viewport = (Viewport)parentFigure;
toolLocation.translate(viewport.getHorizontalRangeModel().getValue(),
viewport.getVerticalRangeModel().getValue());
parentFigure = parentFigure.getParent();
} else {
parentFigure = parentFigure.getParent();
}
}
return toolLocation;
} catch (Exception e) {
BonitaStudioLog.log("can't find exact location for pasting"); //$NON-NLS-1$
return null;
}
}
示例7
/**
*
*/
protected Point getViewerRelativeCursorLocation() {
org.eclipse.draw2d.geometry.Point toolLocation = null;
try {
Tool tool = selectedTargetEditPart.getViewer().getEditDomain().getActiveTool();
AbstractTool aTool = (AbstractTool) tool;
Method m = AbstractTool.class.getDeclaredMethod("getLocation"); //$NON-NLS-1$
m.setAccessible(true);
toolLocation = ((org.eclipse.draw2d.geometry.Point) m.invoke(aTool)).getCopy();
return toolLocation;
} catch (Exception e) {
BonitaStudioLog.log("can't find exact location for pasting"); //$NON-NLS-1$
return null;
}
}
示例8
/**
* Used a custom tool to have a better feedback.
* @generated
*/
public Tool createTool() {
Tool tool = new BonitaUnspecifiedTypeProcessCreationTool(BonitaConnectionTypes.getTypesFor(elementTypes));
tool.setProperties(getToolProperties());
return tool;
}
示例9
/**
* @generated
*/
public Tool createTool() {
Tool tool = new BonitaUnspecifiedTypeConnectionTool(BonitaConnectionTypes.getRelationTypes());
tool.setProperties(getToolProperties());
return tool;
}
示例10
@Override
public Tool createTool() {
InsertedImageTool tool = new InsertedImageTool();
tool.setProperties(getToolProperties());
return tool;
}
示例11
@Override
public Tool createTool() {
if (tool == null)
tool = new DirectEditCreationTool(elementType, directEdit);
return tool;
}
示例12
@Override
public Tool createTool() {
if (tool == null)
tool = new ConnectionCreationTool(elementType);
return tool;
}
示例13
public Tool createTool( )
{
return new PaletteEntryCreationTool( this.factory, paletteEntry );
}
示例14
public Tool createTool( )
{
return new ReportCreationTool( this.factory, preHandle );
}
示例15
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;
}
};
}
示例16
@Override
public Tool createTool() {
return new CustomZoomTool(true);
}
示例17
@Override
public Tool createTool() {
return new CustomZoomTool(false);
}
示例18
public NextElementEditPolicy() {
figures = new ArrayList<IFigure>();
tools = new ArrayList<Tool>();
}
示例19
public ToolAndToolEntry(Tool tool, ToolEntry toolEntry){
this.tool = tool;
this.toolEntry = toolEntry;
}
示例20
/**
* @return the tool
*/
public Tool getTool() {
return tool;
}
示例21
/**
* @param tool the tool to set
*/
public void setTool(Tool tool) {
this.tool = tool;
}