Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » Identify create or delete file, using IResourceDelta object
Identify create or delete file, using IResourceDelta object [message #1069604] Tue, 16 July 2013 08:21
Krishnaveni S is currently offline Krishnaveni SFriend
Messages: 4
Registered: April 2012
Junior Member

I am using Resource Change Listener to track the changes done to my
project. This listener is invoked if I delete, or create or save any
changes to a file, in the project. I have the ResourceDelta object. With
this, how can I find if the file is being created or is going to be deleted.
Below is my code:

In the activator class of my plugin I have:

IResourceChangeListener listener = new MyResourceChangeListener();

In the MyResourceChangeListener class I have:

if (event.getType() == IResourceChangeEvent.POST_CHANGE) {
System.out.println("this is post change event");
final IResourceDelta delta = event.getDelta();


if (delta.getKind() == IResourceDelta.ADDED) {
System.out.println("this is ADD event");

if (delta.getKind() == IResourceDelta.CHANGED) {
System.out.println("this is CHANGED event");

if ((delta.getFlags() & IResourceDelta.CONTENT) == 0) {
System.out.println("this is CONTENT event");
Output is always as below, either i create a class, delete a class, or
make changes and save a class :

this is post change event
this is CHANGED event
this is CONTENT event

How can I differentiate between save, delete or create events.

PS: I deleted a project in the workspace, this time i got a pre_delete
event. How can i git this triggered for files/classes in a projec as well.
Previous Topic:Eclipse, Annotation "@Asynchronous"
Next Topic:A few newcomer questions
Goto Forum:

Current Time: Tue Jun 19 11:00:24 GMT 2018

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

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

Back to the top