Skip to main content


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 17:44 Go to next message
Simon Schwichtenberg is currently offline Simon SchwichtenbergFriend
Messages: 127
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 17:26 Go to previous messageGo to next message
Simon Schwichtenberg is currently offline Simon SchwichtenbergFriend
Messages: 127
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 20:21 Go to previous message
Mirco Franzago is currently offline Mirco FranzagoFriend
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 20:44]

Report message to a moderator

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


Current Time: Tue Apr 23 07:00:39 GMT 2024

Powered by FUDForum. Page generated in 0.02927 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top