Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Refresh Connections after command execution
Refresh Connections after command execution [message #734743] Sun, 09 October 2011 13:44 Go to next message
Goood Guy is currently offline Goood Guy
Messages: 126
Registered: September 2011
Senior Member
is there a way to repaint the connections of an editpart after a command has been executed?
i want to drag a connection between two nodes, but the source end of the connection should be delegated to a child. it's already working except that the connection source is attached to the parent and not the child until i drag some another node onto the diagram. then, the connections are showed properly. i want to repaint the connections automatically. how can i achieve this?



my custom editpolicy:
public class GoalItemSemanticEditPolicyOverride extends
		GoalItemSemanticEditPolicy {
	protected Command getCompleteCreateRelationshipCommand(
			CreateRelationshipRequest req) {
		super.getCompleteCreateRelationshipCommand(req);
		if (XkaosElementTypes.GoalRefinementGoals_4013 == req.getElementType()) {


			return getGEFWrapper(new GoalRefinementsCreateCommandOverride(req,
					req.getSource(), req.getTarget()));
		}
		return null;
	}



my custom command:

public class GoalRefinementsCreateCommandOverride extends
	GoalRefinementGoalsCreateCommand {
	protected CommandResult doExecuteWithResult(IProgressMonitor monitor,
			IAdaptable info) throws ExecutionException {
		if (!canExecute()) {
			throw new ExecutionException(
					"Invalid arguments in create link command"); //$NON-NLS-1$
		}

		if (getUncastedSource() != null && getUncastedTarget() != null) {
						}
			
			if(getUncastedSource() instanceof Goal && getUncastedTarget() instanceof Goal){
				GoalRefinement gr = XkaosFactory.eINSTANCE.createGoalRefinement();
				((Goal )getUncastedSource()).getRefinements().add(gr);
				gr.getGoals().add((Goal) getUncastedTarget());
				
				//TODO repaint root
				
			}
			
			if(getUncastedSource() instanceof Goal && getUncastedTarget() instanceof DomProperty){
				GoalRefinement gr = XkaosFactory.eINSTANCE.createGoalRefinement();
				((Goal )getUncastedSource()).getRefinements().add(gr);
				gr.getDomproperties().add((DomProperty) getUncastedTarget());
			}
		}
		return CommandResult.newOKCommandResult();

	}
Re: Refresh Connections after command execution [message #735409 is a reply to message #734743] Tue, 11 October 2011 13:26 Go to previous messageGo to next message
Goood Guy is currently offline Goood Guy
Messages: 126
Registered: September 2011
Senior Member
thats how it works:
((KaosSpecificationCanonicalEditPolicy)(editpart.getParent().getEditPolicy(EditPolicyRoles.CANONICAL_ROLE))).refresh();
Re: Refresh Connections after command execution [message #983267 is a reply to message #735409] Tue, 13 November 2012 15:21 Go to previous message
Mirco Franzago is currently offline Mirco Franzago
Messages: 12
Registered: November 2012
Junior Member
Goood Guy wrote on Tue, 11 October 2011 19:26
thats how it works:
((KaosSpecificationCanonicalEditPolicy)(editpart.getParent().getEditPolicy(EditPolicyRoles.CANONICAL_ROLE))).refresh();


If I put this instruction in my code, eclipse say to me that editpart cannot be resolved... it's no visible in my code.

[Updated on: Tue, 13 November 2012 15:44]

Report message to a moderator

Previous Topic:Implicitly Connecting Nodes
Next Topic:GMF and Dawn
Goto Forum:
  


Current Time: Thu Jul 24 02:35:48 EDT 2014

Powered by FUDForum. Page generated in 0.01548 seconds