eclipse - How to use an IResourceChangeListener to detect a file rename and set the EditorPart name dynamically? -


iresourcechangelistener listens changes in project workspace example if editor part file name has changed.

i want know how access particular editorpart , change title name accordingly (e.g. .setpartname), or maybe refresh editor shows new name automatically.

ideal if iresourcechangelistener has rename event type not seem case.

reference question.

the iresourcechangelistener fire rename/move events using combination of removed kind , moved_to flag). can test in iresourcedelta with

@override public void resourcechanged(final iresourcechangeevent event) {   iresourcedelta delta = event.getdelta();    // change our file    delta = delta.findmember(ipath of file being edited);   if (delta == null)     return;    if delta.getkind() == iresourcedelta.removed    {      if ((delta.getflags() & iresourcedelta.moved_to) != 0)       {         ipath newpath = delta.getmovedtopath();          ... handle new path       }    } } 

the code handle new path might like:

ifile file = resourcesplugin.getworkspace().getroot().getfile(newpath); if (file != null)  {    setinput(new fileeditorinput(file));     setpartname(newpath.lastsegment());     ... else required   } 

Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -