Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Web Tools Project (WTP) » [FIXED] Save icon not getting enabled when editing from xml editor design view
[FIXED] Save icon not getting enabled when editing from xml editor design view [message #681396] Thu, 09 June 2011 12:41 Go to next message
Max Mising name is currently offline Max Mising name
Messages: 54
Registered: September 2010
Member
I have a perspective for our project which is a glorified file browser. It reuses a lot eclipse code (editors, commands, etc). When I edit an xml file in eclipse (3.6.1) from the "Design" page, if I hit enter or tab or click on a different attribute the editor becomes "dirty" and the save icon is enabled showing I can save the file. When I perform the same action in my perspective on an xml file in the "Design" page, the editor shows that it is dirty (has the *) but the save icons are not enabled and Ctrl+S doesn't work either. Although when I make any edits in the "Source" page in my perspective, everything works perfectly and I don't have any problems, it is only in the design page. Does anyone have any ideas as to why this could be happening? I am using the EditorRegistry to look up what editor to use based on file name.

Max

[Updated on: Mon, 11 July 2011 13:23]

Report message to a moderator

Re: Save icon not getting enabled when editing from xml editor design view [message #681779 is a reply to message #681396] Thu, 09 June 2011 16:44 Go to previous messageGo to next message
Nick Sandonato is currently offline Nick Sandonato
Messages: 125
Registered: July 2009
Senior Member
Hi Max,

I don't really have any ideas as to why this is happening, but you might have some luck tracking things down if you put a breakpoint in org.eclipse.ui.internal.handlers.SaveHandler#evaluate(IEvaluationContext). Something might be causing this to return an evaluation result of false.
Re: Save icon not getting enabled when editing from xml editor design view [message #681836 is a reply to message #681779] Thu, 09 June 2011 19:16 Go to previous messageGo to next message
Max Mising name is currently offline Max Mising name
Messages: 54
Registered: September 2010
Member
Thanks for the response! I can't seem to find org.eclipse.ui.internal.handlers.SaveHandler. Do you know what project/version that class exists in? I am on 3.6.1 and in my org.eclipse.ui.internal.handlers package in org.eclipse.ui.workbench project, there is no SaveHandler. Any idea where this might be?

Max
Re: Save icon not getting enabled when editing from xml editor design view [message #683373 is a reply to message #681836] Mon, 13 June 2011 11:59 Go to previous messageGo to next message
Nick Sandonato is currently offline Nick Sandonato
Messages: 125
Registered: July 2009
Senior Member
Sorry, Max. Missed the 3.6.1 part. SaveHandler is from 3.7. I think instead, you should put a breakpoint in org.eclipse.ui.internal.SaveAction#updateState().
Re: Save icon not getting enabled when editing from xml editor design view [message #684431 is a reply to message #683373] Wed, 15 June 2011 11:02 Go to previous messageGo to next message
Max Mising name is currently offline Max Mising name
Messages: 54
Registered: September 2010
Member
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?

Thanks,

Max
[FIXED] Save icon not getting enabled when editing from xml editor design view [message #695416 is a reply to message #684431] Mon, 11 July 2011 13:20 Go to previous message
Max Mising name is currently offline Max Mising name
Messages: 54
Registered: September 2010
Member
I ended up posting to RCP forum to see if anyone there might know why I was seeing this behavior and I actually ended up figuring it out on my own. Here is the link to the other forum: http://www.eclipse.org/forums/index.php/t/219216/

My realization:
Quote:

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.

[Updated on: Mon, 11 July 2011 13:22]

Report message to a moderator

Previous Topic:WST: Contributing a wizard page to "Add/Remove" module wizard
Next Topic:Where is WebModuleImportDataModel in Indigo?
Goto Forum:
  


Current Time: Thu Jul 24 06:57:18 EDT 2014

Powered by FUDForum. Page generated in 0.01753 seconds