Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » Define save action in plugin
Define save action in plugin [message #1713645] Thu, 05 November 2015 11:51 Go to next message
Eclipse UserFriend
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 13:53 Go to previous messageGo to next message
Eclipse UserFriend
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 02:06 Go to previous message
Eclipse UserFriend
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:Eclipse Indigo (3.8) does not start with Mac 10.10
Next Topic:Get menu button with specific id
Goto Forum:
  


Current Time: Wed Mar 19 05:17:55 EDT 2025

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

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

Back to the top