org.eclipse.gef.editparts.AbstractGraphicalEditPart Java Examples

The following examples show how to use org.eclipse.gef.editparts.AbstractGraphicalEditPart. 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: AppEditPartFactory.java    From olca-app with Mozilla Public License 2.0 6 votes vote down vote up
@Override
public EditPart createEditPart(EditPart context, Object model) {
	AbstractGraphicalEditPart part = null;
	if (model instanceof ProductSystemNode)
		part = new ProductSystemPart();
	else if (model instanceof ProcessNode)
		part = new ProcessPart();
	else if (model instanceof ExchangeNode)
		part = new ExchangePart();
	else if (model instanceof IONode)
		part = new IOPart();
	else if (model instanceof Link)
		part = new LinkPart();
	if (part != null)
		part.setModel(model);
	return part;
}
 
Example #2
Source File: MessageFlowFactory.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
public static void editMessageFlowName(Message message, AbstractCatchMessageEvent target, DiagramEditPart dep) {
    EditPart targetEP = findEditPart(dep, target);
    Optional<MessageFlowEditPart> connectionPart = ((AbstractGraphicalEditPart) targetEP).getTargetConnections().stream()
            .filter(MessageFlowEditPart.class::isInstance)
            .map(MessageFlowEditPart.class::cast)
            .findFirst();
    if (connectionPart.isPresent()) {
        MessageFlow messageFlowToEdit = (MessageFlow) connectionPart.get().resolveSemanticElement();
        EMFModelUpdater<MessageFlow> updater = new EMFModelUpdater<>();
        MessageFlow workingCopy = updater.from(messageFlowToEdit).getWorkingCopy();
        workingCopy.setName(message.getName());
        updater.update();
        dep.refresh();
    }
}
 
Example #3
Source File: MessageFlowFactory.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
public static void removeMessageFlow(TransactionalEditingDomain editingDomain, AbstractCatchMessageEvent target,
        DiagramEditPart dep) {

    EditPart ep = findEditPart(dep, target);
    CompositeCommand command = new CompositeCommand("Remove MessageFlows");

    for (Object connection : ((AbstractGraphicalEditPart) ep).getTargetConnections()) {
        if (connection instanceof MessageFlowEditPart) {
            MessageFlowEditPart connectionPart = (MessageFlowEditPart) connection;
            MessageFlow flow = (MessageFlow) connectionPart.resolveSemanticElement();
            SetCommand c = new SetCommand(editingDomain, flow.getTarget(),
                    ProcessPackage.Literals.ABSTRACT_CATCH_MESSAGE_EVENT__EVENT, null);
            editingDomain.getCommandStack().execute(c);
            command.add(new DeleteCommand(editingDomain, connectionPart.getPrimaryView()));
            DestroyElementRequest req = new DestroyElementRequest(editingDomain, flow, false);
            DestroyElementCommand rmComd = new DestroyElementCommand(req);
            command.add(rmComd);
        }
    }

    dep.getDiagramEditDomain().getDiagramCommandStack().execute(new ICommandProxy(command.reduce()));
    dep.getDiagramEditDomain().getDiagramCommandStack().flush();
    dep.refresh();
}
 
Example #4
Source File: CustomPasteCommand.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected CommandResult doExecuteWithResult(final IProgressMonitor progressMonitor, final IAdaptable info) throws ExecutionException {
	if (Clipboard.hasThingsToCopy()) {
		AbstractGraphicalEditPart partUnderCursor = (AbstractGraphicalEditPart) selectedTargetEditPart.getViewer().findObjectAt(getViewerRelativeCursorLocation());

		if(selectedTargetEditPart instanceof CustomSubProcessEvent2EditPart){
			if(!((CustomSubprocessEventCompartmentEditPart)((CustomSubProcessEvent2EditPart)selectedTargetEditPart).getChildren().get(1)).getCompartmentFigure().isExpanded()){
				return CommandResult.newCancelledCommandResult();
			}
		}

		if (!(partUnderCursor instanceof IGraphicalEditPart) || !targetElement.equals(((IGraphicalEditPart) partUnderCursor).resolveSemanticElement())) {
			locationStrategy = LocationStrategy.OFFSET;
		} else {
			locationStrategy = LocationStrategy.MOUSE;
		}
		final List<IGraphicalEditPart> nodesToCopy = GMFTools.addMissingConnectionsAndBoundaries(Clipboard.getToCopy());

		performPaste(progressMonitor, nodesToCopy);


		return CommandResult.newOKCommandResult();
	} else {
		return CommandResult.newCancelledCommandResult();
	}
}
 
Example #5
Source File: ListEditPart.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
public void refreshFigure( )
{
	refreshBorder( getListHandleAdapt( ).getHandle( ),
			(BaseBorder) getFigure( ).getBorder( ) );
	( (ListFigure) getFigure( ) ).setRecommendSize( getListHandleAdapt( ).getSize( ) );
	( (SectionBorder) ( getFigure( ).getBorder( ) ) ).setPaddingInsets( getListHandleAdapt( ).getPadding( getFigure( ).getInsets( ) ) );

	refreshMargin( );

	refreshBackground( (DesignElementHandle) getModel( ) );
	
	( (AbstractGraphicalEditPart) getParent( ) ).setLayoutConstraint( this,
			getFigure( ),
			getConstraint( ) );
	
	markDirty( );
}
 
Example #6
Source File: ExternalXtextLabelEditPart.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void refreshBounds() {
	int dx = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue();
	int dy = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue();
	Rectangle bounds = new Rectangle(dx, dy, -1, -1);
	((AbstractGraphicalEditPart) getParent()).setLayoutConstraint(this, getFigure(), new EdgeLabelLocator(
			((AbstractConnectionEditPart) getParent()).getConnectionFigure(), bounds, getKeyPoint()));
}
 
Example #7
Source File: ListBandEditPart.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public void refreshChildren( )
{
	super.refreshChildren( );
	( (AbstractGraphicalEditPart) getParent( ) ).setLayoutConstraint( this,
			getFigure( ),
			getConstraint( ) );
}
 
Example #8
Source File: LabelEditPart.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public void refreshFigure( )
{
	StyleHandle style = ( (DesignElementHandle) getModel( ) ).getPrivateStyle( );
	//( (LabelFigure) getFigure( ) ).setDirection( style.getTextDirection( ) ); // bidi_hcg
	( (LabelFigure) getFigure( ) ).setDirection( getTextDirection( ) ); // bidi_hcg
	( (LabelFigure) getFigure( ) ).setText( getText( ) );
	( (LabelFigure) getFigure( ) ).setFont( getFont( ) );

	( (LabelFigure) getFigure( ) ).setTextUnderline( style.getTextUnderline( ) );
	( (LabelFigure) getFigure( ) ).setTextLineThrough( style.getTextLineThrough( ) );
	( (LabelFigure) getFigure( ) ).setTextOverline( style.getTextOverline( ) );
	( (LabelFigure) getFigure( ) ).setTextAlign( style.getTextAlign( ) );
	( (LabelFigure) getFigure( ) ).setVerticalAlign( style.getVerticalAlign( ) );

	( (LabelFigure) getFigure( ) ).setDisplay( style.getDisplay( ) );

	( (LabelFigure) getFigure( ) ).setRecommendSize( getLabelAdapter( ).getSize( ) );

	( (LabelFigure) getFigure( ) ).setFixLayout( isFixLayout( ) );
	( (AbstractGraphicalEditPart) getParent( ) ).setLayoutConstraint( this,
			getFigure( ),
			getConstraint( ) );

	( (LabelFigure) getFigure( ) ).setForegroundColor( ColorManager.getColor( getForegroundColor( (ReportItemHandle) getModel( ) ) ) );

	refreshBorder( (DesignElementHandle) getModel( ), new LineBorder( ) );

	Insets pist = getLabelAdapter( ).getPadding( getFigure( ).getInsets( ) );

	( (LineBorder) ( getFigure( ).getBorder( ) ) ).setPaddingInsets( pist );

	if ( !hasText( ) )
		( (LabelFigure) getFigure( ) ).setForegroundColor( ReportColorConstants.ShadowLineColor );
	else
		( (LabelFigure) getFigure( ) ).setForegroundColor( ColorManager.getColor( getForegroundColor( (ReportItemHandle) getModel( ) ) ) );

	refreshBackground( (DesignElementHandle) getModel( ) );

	refreshMargin( );
}
 
Example #9
Source File: MultipleEditPart.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public void refreshFigure( )
{
	((MultipleLayout)getFigure( ).getLayoutManager( )).markDirty( );
	( (AbstractGraphicalEditPart) getParent( ) ).setLayoutConstraint( this,
			getFigure( ),
			getConstraint( ) );
	//do noting
}
 
Example #10
Source File: ExtendedEditPart.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public void refreshFigure( )
{
	refreshBorder( (DesignElementHandle) getModel( ), new LineBorder( ) );
	getExtendedElementUI( ).updateFigure( getExtendedItemHandle( ),
			getFigure( ) );

	( (AbstractGraphicalEditPart) getParent( ) ).setLayoutConstraint( this,
			getFigure( ),
			getConstraint( ) );
}
 
Example #11
Source File: MovablePanningSelectionTool.java    From erflute with Apache License 2.0 5 votes vote down vote up
private void openDetailByKeyCode(KeyEvent event, AbstractGraphicalEditPart targetEditPart) {
    if (targetEditPart != null && isOpenDetailKeyCode(event)) {
        final Request request = new Request();
        request.setType(RequestConstants.REQ_OPEN);
        targetEditPart.performRequest(request);
    }
}
 
Example #12
Source File: ImageEditPart.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
public void refreshFigure( )
{
	refreshBorder( (DesignElementHandle) getModel( ), new LineBorder( ) );

	Insets pist = getImageAdapter( ).getPadding( getFigure( ).getInsets( ) );

	( (LineBorder) ( getFigure( ).getBorder( ) ) ).setPaddingInsets( pist );

	Image image = null;
	try
	{
		image = getImageAdapter( ).getImage( );
	}
	catch ( SWTException e )
	{
		// Do nothing
	}

	( (ImageFigure) this.getFigure( ) ).setStretched( image != null );
	if ( image == null )
	{
		image = ReportPlatformUIImages.getImage( IReportGraphicConstants.ICON_MISSING_IMG );
	}

	( (ImageFigure) this.getFigure( ) ).setImage( image );

	if ( getImageAdapter( ).getSize( ) != null )
	{
		this.getFigure( ).setSize( getImageAdapter( ).getSize( ) );
	}
	else if ( image != null )
	{
		Dimension rawSize = getImageAdapter( ).getRawSize( );

		if ( rawSize.height == 0 && rawSize.width == 0 )
		{
			this.getFigure( )
					.setSize( new Dimension( image.getBounds( ).width,
							image.getBounds( ).height ) );
		}
		else if ( rawSize.height == 0 )
		{
			this.getFigure( ).setSize( new Dimension( rawSize.width,
					(int)(image.getBounds( ).height *((double)rawSize.width/image.getBounds( ).width) ) ));
		}
		else
		{
			this.getFigure( )
					.setSize( new Dimension( (int)(image.getBounds( ).width*((double)rawSize.height/image.getBounds( ).height) ) ,
							rawSize.height ) );
		}

	}

	refreshBackgroundColor( (DesignElementHandle) getModel( ) );

	refreshMargin( );

	( (AbstractGraphicalEditPart) getParent( ) ).setLayoutConstraint( this,
			getFigure( ),
			getConstraint( ) );
}
 
Example #13
Source File: EditorGuideDragTracker.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
public Cursor getCurrentCursor() 
{
	return ((AbstractGraphicalEditPart)getSourceEditPart()).getFigure().getCursor();
}
 
Example #14
Source File: ColumnEditPart.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
public IFigure getChopFigure( )
{
	return ( (AbstractGraphicalEditPart) this.getParent( ) ).getFigure( );
}
 
Example #15
Source File: HierarchyColumnEditPart.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
public IFigure getChopFigure( )
{
	return ( (AbstractGraphicalEditPart) this.getParent( ) ).getFigure( );
}
 
Example #16
Source File: AttributeEditPart.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
public IFigure getChopFigure( )
{
	return ( (AbstractGraphicalEditPart) this.getParent( ) ).getFigure( );
}
 
Example #17
Source File: CFGNodeEditPart.java    From JAADAS with GNU General Public License v3.0 4 votes vote down vote up
public void updateSize(AbstractGraphicalEditPart part, IFigure child, Rectangle rect){
	this.setLayoutConstraint(part, child, rect);
}