Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » [FIXED] Save icon issues between pages in multi page editor
[FIXED] Save icon issues between pages in multi page editor [message #694465] Fri, 08 July 2011 16:46 Go to next message
Max Mising name is currently offline Max Mising nameFriend
Messages: 54
Registered: September 2010
Member
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:

org.eclipse.wst.common.core
org.eclipse.wst.common.environment
org.eclipse.wst.common.frameworks
org.eclipse.wst.common.project.facet.core
org.eclipse.wst.common.ui
org.eclipse.wst.common.uriresolver
org.eclipse.wst.sse.core
org.eclipse.wst.sse.ui
org.eclipse.wst.validation
org.eclipse.wst.xml.core
org.eclipse.wst.xml.ui

Someone on the other forum told me to debug org.eclipse.ui.internal.SaveAction#updateState() which I did and this was my response:

Quote:

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.

Thanks

Max


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

Max

[Updated on: Mon, 11 July 2011 16:55]

Report message to a moderator

Re: Save icon issues between pages in multi page editor [message #695366 is a reply to message #694465] Mon, 11 July 2011 15:23 Go to previous message
Max Mising name is currently offline Max Mising nameFriend
Messages: 54
Registered: September 2010
Member
I found out some more information. Looks in the design page the handler for the save command is null and is set in the source page. The reason for this seems to be in MultiPageEditorPart.activateSite() after a pageChange line 865. Apparently the Design page is not an IEditorPart and so instead of hitting line 959 and pass in the editor site (which makes sure the handler is set), it hits 979 which passes in null for the site and sets the handler in the command to null which causes isEnabled() to return false. I have no idea why this is happening in my app but Eclipse seems to be working. Does anyone know why the org.eclipse.ui.file.save command's handler doesn't get set to null in Eclipse when switching to the Design page of an xml file?

Max
Previous Topic:Query Regarding org.eclipse.nebula.widgets.calendarcombo.CalendarCombo Date Format behavior
Next Topic: internationalize an existing preference page
Goto Forum:
  


Current Time: Thu Apr 25 22:33:30 GMT 2024

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

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

Back to the top