Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » Add File to project - Event
Add File to project - Event [message #1816845] Fri, 08 November 2019 03:49 Go to next message
Eclipse UserFriend
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 04:15 Go to previous messageGo to next message
Eclipse UserFriend
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.
Re: Add File to project - Event [message #1816849 is a reply to message #1816846] Fri, 08 November 2019 05:12 Go to previous messageGo to next message
Eclipse UserFriend
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 10:42 Go to previous message
Eclipse UserFriend
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...
Previous Topic:Internal Java Error at startup
Next Topic:Trouble Installing Eclipse
Goto Forum:
  


Current Time: Sat Aug 30 21:22:16 EDT 2025

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

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

Back to the top