Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Add File to project - Event
Add File to project - Event [message #1816845] Fri, 08 November 2019 08:49 Go to next message
Mihnea-Costache Marin is currently offline Mihnea-Costache MarinFriend
Messages: 68
Registered: September 2019
Member
Hello,

Is there a way to find the event when a user creates a new file(file -> other(header/source/..)? I know how to capture the event of the resource changed, but how can I specifically get the added file event?

Thank you!
Re: Add File to project - Event [message #1816846 is a reply to message #1816845] Fri, 08 November 2019 09:15 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
All changes to the workspace produce resource deltas so definitely adding any new file will produce a delta. Of course the delta is a tree and you must visit (IResourceDeltaVisitor) the delta tree to see all the things that have changed, including IResourceDelta.ADDED.

Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Add File to project - Event [message #1816849 is a reply to message #1816846] Fri, 08 November 2019 10:12 Go to previous messageGo to next message
Mihnea-Costache Marin is currently offline Mihnea-Costache MarinFriend
Messages: 68
Registered: September 2019
Member
Where should the code be placed? Some say to place it in the view class, but I am using the CommonNavigator class as a view so I cannot edit it.

Should I create a new view class that extends from the CommonNavigator?

Thank you!
Re: Add File to project - Event [message #1816860 is a reply to message #1816849] Fri, 08 November 2019 15:42 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
You must listen to the workspace itself. E.g., in an EMF generated editor we have a listener like this:

https://git.eclipse.org/c/emf/org.eclipse.emf.git/tree/plugins/org.eclipse.emf.ecore.editor/src/org/eclipse/emf/ecore/presentation/EcoreEditor.java#n507

Add it like this:

https://git.eclipse.org/c/emf/org.eclipse.emf.git/tree/plugins/org.eclipse.emf.ecore.editor/src/org/eclipse/emf/ecore/presentation/EcoreEditor.java#n1928

And remove it when the editor is disposed:

https://git.eclipse.org/c/emf/org.eclipse.emf.git/tree/plugins/org.eclipse.emf.ecore.editor/src/org/eclipse/emf/ecore/presentation/EcoreEditor.java#n2108

I'm not sure how you code is structured to say where you should add logic...


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Internal Java Error at startup
Next Topic:Trouble Installing Eclipse
Goto Forum:
  


Current Time: Fri Apr 26 18:27:23 GMT 2024

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

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

Back to the top