Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Define save action in plugin
Define save action in plugin [message #1713645] Thu, 05 November 2015 16:51 Go to next message
David M. Karr is currently offline David M. KarrFriend
Messages: 522
Registered: July 2009
Senior Member
I've inherited a somewhat complex codebase for an Eclipse plugin for editing files for a particular configuration language.

While editing files of that type, the plugin immediately reports syntactical or semantic errors very well.

However, I noticed that there are situations where when a file is saved, it needs to run a save action to check for syntax/semantics. I can figure out how to make it run those checks, but I'm not sure how to configure save actions within the plugin.

I know how to configure save actions in the user interface, but this has to be defined within the plugin itself. I noticed some info about "cleanup actions" in the JDT, but these files aren't Java.

How would I do this, and are there some good examples of this I can see?
Re: Define save action in plugin [message #1713658 is a reply to message #1713645] Thu, 05 November 2015 18:53 Go to previous messageGo to next message
David M. Karr is currently offline David M. KarrFriend
Messages: 522
Registered: July 2009
Senior Member
Would it be reasonable to do something like this (from Eclipse help pages)?:
IResourceChangeListener listener = new MyResourceChangeReporter();
   ResourcesPlugin.getWorkspace().addResourceChangeListener(
      listener, IResourceChangeEvent.POST_CHANGE);

However, I note that it says on the same page that the workspace is locked during the processing of this event. I don't believe that running the parser as a result of this event will write to any workspace files, but I'll have to make sure about that. The other minor annoyance is that I'll have to run the parser on all the files in every project being managed by this plugin, as I'll have no way to tell if any particular resource change would have an impact on my language files, or even be related at all.
Re: Define save action in plugin [message #1713705 is a reply to message #1713658] Fri, 06 November 2015 07:06 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 28891
Registered: July 2009
Senior Member
David,

Validation is more normally (properly?) designed as a builder.

On 05/11/2015 7:53 PM, David M. Karr wrote:
> Would it be reasonable to do something like this (from Eclipse help
> pages)?:
> IResourceChangeListener listener = new MyResourceChangeReporter();
> ResourcesPlugin.getWorkspace().addResourceChangeListener(
> listener, IResourceChangeEvent.POST_CHANGE);
> However, I note that it says on the same page that the workspace is
> locked during the processing of this event. I don't believe that
> running the parser as a result of this event will write to any
> workspace files, but I'll have to make sure about that. The other
> minor annoyance is that I'll have to run the parser on all the files
> in every project being managed by this plugin, as I'll have no way to
> tell if any particular resource change would have an impact on my
> language files, or even be related at all.
Previous Topic:How to get ""org.eclipse.ui.navigator.navigatorContent" extension point
Next Topic:Any way to safely step through plugin code that results in popup menus?
Goto Forum:
  


Current Time: Sun Oct 22 06:24:29 GMT 2017

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

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