简体   繁体   中英

How can I change the name of *.xml file in the eclipse IDE's project explorer with one of its element

I m trying to write an eclipse plugin which is suppose to render xml file some different manner. What actually I want is to replace the name of the file displayed in the project explorer with one of its element without originally change the file name. for example I have a file named 1234.xml with content

<name> dinesh </dinesh>
<college> NITT </college>

So I want to change the name of 1234.xml to dinesh.xml in the project explorer.

Can anybody tell me what are the possible ways I can achieve this. I am new to eclipse plugin development. So please provide me as much information as possible.

There is no automatic way (I mean refactor) for this, so you must manually do it:

  1. Change name of file 1234.xml to dinesh.xml

  2. Search in your project all references to 1234.xml with CTRL + H / file search and appropiate patterns: 在此处输入图片说明

  3. Change all references found of 1234.xml to dinesh.xml

  4. If some issue appears search for 1234 in all the files to check if file was references only by name

Well I find the answer of what I wanted to do...

I have extended decorator extension point of eclipse to provide custom label provider for the desired files ...

One more thing to access the xml attribute use regex instead of xml parsing . It will make things bit faster than xml parsing ...

Thanks

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM