|[FIXED] Save icon issues between pages in multi page editor [message #694465]
||Fri, 08 July 2011 16:46
| Max Mising name
Registered: September 2010
About a month ago, I posted to the WTP forum about the xml editor having issues with the save icon but no one has responded with any ideas as to why this could happen. |
In my application, I have a file editing perspective which reuses lots of eclipse built in editors, the xml editor being one of them. The behavior I get is that when I open an xml file, it starts in the "Design" page. I edit an attribute and the editor shows the * in the title like it needs to be saved, but the save icons (which I include by referencing commandId=org.eclipse.ui.file.save in my plugin.xml) do not become enabled. If I then switch to the "Source" page, they get enabled and I can save. I do not get this issue when using Eclipse, it works as expected and I can save edits made in the "Design" page which makes me think I am not including a needed project or activating a context or doing something that might cause it to not work properly. I am using the EditorRegistry to open the proper editor based on file name so I am not using a custom editor or anything. The projections I have included specifically for xml editing are:
Someone on the other forum told me to debug org.eclipse.ui.internal.SaveAction#updateState() which I did and this was my response:
So I put the breakpoint in and when I am in the design page, make an edit and hit enter, it ends up calling SaveAction.setEnabled(true) on line 98 (I also put a breakpoint on line 95 just to make sure but it never hits) which is what I would expect. But the icon still doesn't show enabled. Then when I switch to source page, the icon magically becomes enabled even though nothing in SaveAction has changed.
I ended up putting a breakpoint in ToolItem.setEnabled(...) and noticed that when i switch pages, it gets toggled for Save. The Save CommandContributionItem.updateToolItem() function gets called when I switch pages and somehow when I go to "design" CommandContributionItem.isEnabled() returns false and when I go to "source" it returns true (CommandContributionItem line 661-665). Unfortunately for some reason I can't debug CommandContributionItem even though I can see the source. Not sure why eclipse doesn't let me put breakpoints in the class but it is making it harder to figure out what is happening. Does anyone have any ideas?
I never got a response back from that thread. I was hoping someone in this forum might know of any reasons that this may occur.
Here is a link to the original thread. I've also attached 2 screenshots of the different pages after an edit.
Edit: I ended up figuring out that in Eclipse, there is an IDEWorkbenchWindowAdvisor which creates a WorkbenchActionBuilder for the ActionBarAdvisor. That class creates SaveAction object which becomes a global action object. I made my ActionBarAdivsor create the action object in makeActions and it all works now. The SaveAction I was seeing before was one created for the right click save menu option on the editor. Which is why the handler is null in the "Design" page (there is no menu option to save then). So those SaveActions created for right click menus were effecting the my save CommandContributionItems enable state. When I created the SaveAction like WorkbenchActionBuilder in my ActionBarAdvisor, those right click menu SaveActions stopped effecting the main menu/toolbar items.
Thanks to anyone who took time to look at my post
[Updated on: Mon, 11 July 2011 16:55]
Report message to a moderator
Powered by FUDForum
. Page generated in 0.13339 seconds