Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » How to change model in properties sheet without having an update command on the undo-stack?
How to change model in properties sheet without having an update command on the undo-stack? [message #778711] Fri, 13 January 2012 17:16 Go to next message
Ingo Mohr is currently offline Ingo MohrFriend
Messages: 23
Registered: September 2011
Junior Member
I have a properties sheet in which I want to edit some aspects of the model element represented by a pictogram element.

When I change the model, the AbstractFeatureProvider.updateIfPossible(IUpdateContext context) is invoked which causes the CommandExec.executeCommand to create, execute an update command that is parked on top of the undo-stack. So, when I want to undo my change made to the model, I have to undo the "update" first and then undo my change.

Is there a way to avoid having the update-call on the undo-stack?

Regards,
Ingo
Re: How to change model in properties sheet without having an update command on the undo-stack? [message #778768 is a reply to message #778711] Fri, 13 January 2012 19:47 Go to previous messageGo to next message
Nicolas Buezas is currently offline Nicolas BuezasFriend
Messages: 5
Registered: January 2012
Junior Member
Hi,
I'm not expert, and it may not be what you want, but when I have to change model in properties sheet I do it with listeners, for example:

...
Text callFromText = factory.createText(composite, "");
callFromText.addModifyListener(getCallFromListener());
...
private ModifyListener getCallFromListener(){

		return new ModifyListener() {

	    	@Override
	    	public void modifyText(ModifyEvent e) {
	    		String txtCallFromText = callFromText.getText();

	    		if (txtCallFromText == null) {
	    			txtCallFromText = "";
	    		}	

	    		final String txtNewCallFromText = txtCallFromText;

	    	IFeature feature = new AbstractFeature(getDiagramTypeProvider().getFeatureProvider()){	    				

	    			@Override
	    			public void execute(IContext context) {
                                        // transitions contains the bo asociate to pe selected
    					TransitionType transicionCall = (TransitionType) transition;
                                        // I can change the model here
    					transicionCall.setFrom(txtNewCallFromText);
	    			}

	    			
	    			@Override
	    			public boolean canExecute(IContext context) {
	    				return true;
	    			}
	    		};

	    		CustomContext context = new CustomContext();
	    		execute(feature, context);
	    	}

	    };

	}


I hope it helps you.
Regards.
Nicolás.

[Updated on: Fri, 13 January 2012 21:41]

Report message to a moderator

Re: How to change model in properties sheet without having an update command on the undo-stack? [message #779797 is a reply to message #778768] Mon, 16 January 2012 15:25 Go to previous messageGo to next message
Ingo Mohr is currently offline Ingo MohrFriend
Messages: 23
Registered: September 2011
Junior Member
Hey Nicolás,
thanks for your hint.

However, the suggested implementation leads to an "Update" command on the undo-stack too. (I changed my implementation accordingly. The DomainModelChangeListener triggers DefaultNotificationService.updatePictogramElements(PictogramElement[]) which leads to the following stacktrace:

ExecutionPlanDiagramFeatureProviderExec(AbstractFeatureProvider).updateIfPossible(IUpdateContext) line: 259
ExecutionPlanDiagramFeatureProviderExec(AbstractFeatureProvider).updateIfPossibleAndNeeded(IUpdateContext) line: 338
DefaultNotificationService.updatePictogramElements(PictogramElement[]) line: 63
DomainModelChangeListener$1.run() line: 119
RunnableLock.run() line: 35
UISynchronizer(Synchronizer).runAsyncMessages(boolean) line: 135

The implementation of method "updateIfPossible" leads to an "Update" command on the undo stack which I don't want to have (since I would have to undo two commands when I changed only 1 thing (using one command).

Or did I miss something?

Regards,
Ingo
Re: How to change model in properties sheet without having an update command on the undo-stack? [message #780303 is a reply to message #779797] Tue, 17 January 2012 15:09 Go to previous message
Nicolas Buezas is currently offline Nicolas BuezasFriend
Messages: 5
Registered: January 2012
Junior Member
Hey Ingo,
I don't know how to solve that problem for the moment. If I come up with something, I will tell you.
I'm sorry.

Regards.
Nicolás.
Previous Topic:API not usable without editor in running eclipse UI?!
Next Topic:Problem with transparancy in Styles
Goto Forum:
  


Current Time: Thu Apr 25 08:49:05 GMT 2024

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

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

Back to the top