org.eclipse.gef.Tool Java Examples

The following examples show how to use org.eclipse.gef.Tool. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: NextElementEditPolicy.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
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();
		}
	}
}
 
Example #2
Source File: DefaultSCTPaletteFactory.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
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();
		}
	});
}
 
Example #3
Source File: InsertImageTool.java    From ermaster-b with Apache License 2.0 5 votes vote down vote up
@Override
public Tool createTool() {
	InsertedImageTool tool = new InsertedImageTool();
	tool.setProperties(getToolProperties());

	return tool;
}
 
Example #4
Source File: ProcessPaletteFactory.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated
*/
public Tool createTool() {

	Tool tool = new BonitaUnspecifiedTypeConnectionTool(BonitaConnectionTypes.getRelationTypes());
	tool.setProperties(getToolProperties());
	return tool;
}
 
Example #5
Source File: ProcessPaletteFactory.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* 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;
}
 
Example #6
Source File: CustomPasteCommand.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 
 */
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;
	}
}
 
Example #7
Source File: CustomPasteCommand.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 
 */
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;
	}
}
 
Example #8
Source File: ProcessEditPolicyEntries.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
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);
		}
	}
}
 
Example #9
Source File: InsertImageTool.java    From erflute with Apache License 2.0 5 votes vote down vote up
@Override
public Tool createTool() {
    final InsertedImageTool tool = new InsertedImageTool();
    tool.setProperties(getToolProperties());

    return tool;
}
 
Example #10
Source File: InsertImageTool.java    From ermasterr with Apache License 2.0 5 votes vote down vote up
@Override
public Tool createTool() {
    final InsertedImageTool tool = new InsertedImageTool();
    tool.setProperties(getToolProperties());

    return tool;
}
 
Example #11
Source File: ZoomInToolEntry.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
@Override
public Tool createTool() {
	return new CustomZoomTool(true);
}
 
Example #12
Source File: ZoomOutToolEntry.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
@Override
public Tool createTool() {
	return new CustomZoomTool(false);
}
 
Example #13
Source File: NextElementEditPolicy.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
public NextElementEditPolicy() {
	figures = new ArrayList<IFigure>();
	tools = new ArrayList<Tool>();
}
 
Example #14
Source File: DesignerPaletteFactory.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
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;
		}

	};
}
 
Example #15
Source File: ReportCombinedTemplateCreationEntry.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
public Tool createTool( )
{
	return new ReportCreationTool( this.factory, preHandle );
}
 
Example #16
Source File: ToolAndToolEntry.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
public ToolAndToolEntry(Tool tool, ToolEntry toolEntry){
	this.tool = tool;
	this.toolEntry = toolEntry;
}
 
Example #17
Source File: ToolAndToolEntry.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
/**
 * @return the tool
 */
public Tool getTool() {
	return tool;
}
 
Example #18
Source File: ToolAndToolEntry.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
/**
 * @param tool the tool to set
 */
public void setTool(Tool tool) {
	this.tool = tool;
}
 
Example #19
Source File: CommandCombinedTemplateCreationEntry.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
public Tool createTool( )
{
	return new PaletteEntryCreationTool( this.factory, paletteEntry );
}
 
Example #20
Source File: DefaultSCTPaletteFactory.java    From statecharts with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public Tool createTool() {
	if (tool == null)
		tool = new ConnectionCreationTool(elementType);
	return tool;
}
 
Example #21
Source File: DefaultSCTPaletteFactory.java    From statecharts with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public Tool createTool() {
	if (tool == null)
		tool = new DirectEditCreationTool(elementType, directEdit);
	return tool;
}