java - IResourceChangeEvent - how to identify a project delete/rename -
how can distinguish, within iresourcechangelistener
added via resourceplugin.getworkspace().addresourcechangelistener(...)
project deleted / renamed?
through trying things out, seem iresourcechangeevent.getdelta() -> iresourcedelta
answer.
from eclipse api:
after-the-fact batch reports of arbitrary creations, deletions , modifications 1 or more resources expressed hierarchical resource delta. event type post_change, , getdelta returns hierarchical delta. resource delta rooted @ workspace root. these events broadcast interested parties after set of resource changes , happen whether or not autobuilding enabled. workspace closed alter during notification of these events. delta reported in event cycle identical across listeners registered type of event.
edit: adding findings far
so, event.gettype()
post_change
, there needs either
a delta contains kid iresourcedelta
has getkind() == removed
deletion, , delta getresource().gettype() == project
know it's project ( iresourcedelta
should not have children )
a getdelta()
contains 2 children iresourcedelta
have getkind() == removed
, getkind() == added
, getresource().gettype() == project
, , iresourcedelta
contain no children deltas (i've observed when file renamed/deleted, iproject
resource belongs 1 on first row of children of parent delta
...)
can confirm supposition? if necessary tree depth search children realize if event of project rename/delete or file/folder?
you need add together resource alter listener via resourceplugin.getworkspace().addresourcechangelistener(listener, iresourcechangeevent.post_change)
in listener, utilize iresourcedeltavisitor
visit changes in delta via event.getdelta().accept(...)
the visitor should projects removed
if expecting project removed , created same name (as happens files & folders during build events), in add-on removed
, replaced
in delta
java eclipse eclipse-rcp eclipse-plugin
No comments:
Post a Comment