Wednesday, August 24, 2011

දයාබර අම්මේ.....



සිහි කරන්නට ප්ර්‍ථම මතකය කළෙමි තැත්  මම ඔබ ගැන
දිවුණි මතකය දශක දෙකකට පැයට සැතපුම් වේගයෙන් 
දැණුනි මනසට සිනිදු සිතුවිලි  කිරි සුවඳ සහ මුසු වෙමින්
දිටිමි මා පොඩි පැටෙකු විලසින ළී අසෙකු මත සුරතළින්....

දිටිමි මෑතින් සිටිනු ඔබ මා දෙසම නෙත් දෙක යොමුවමින්
මවක් යනු පින් කඳක් බව ඔබ හැඟෙව්වේ මිතුරකු ලෙසින්
එදා මට ඒ දැණුන සෙනෙහස දැනේ අදටත් නොඅඩුවෙන් 
ණය ගැතියි මම ජාති ජාතිත්  ඒ පෙවූ කිරි නාමයෙන්......














Tuesday, August 23, 2011

Change the Icon of Eclipse internal XML Editor

Eclipse IDE is very popular since it can be easily configurable according to the developer's  requirements. Creating plugins for third party applications made our life too easy.So during this summer I thought of involving Google Summer of codes 2011 program and contribute for the project Apache Cayenne. Here My task was to create an external editor for Eclipse which supports Cayenne Modeler which is a Java bases application.
     There I had to deal with a bit tricky problem which I have to filter cayenne related xml files and load them with the cayenne icon.But When we double click it should be opened with default eclipse xml editor. Initially I thought it is going to be a bit harder task and thought of writing a new mxl editor for eclipse. But after few hours research i found an easy way of implementing this.
Pre-Requirements for this example : Basic knowledge is Eclipse PDE.



        
            
                
            
        



                         
            
            
         
 
As describes in above plugin.xml file we are using an external editor call "testing.other.validator" which has the content type binding called "internal.editor". In this binding it filter all xml files which has the root element as "domian-map". In your case you can ad the root element of your preferred xml files which you want to load it with your own icon. So after it find that specific xml file in your eclipse workspace it loads that xml file with the the "cayenne.png" as in above example. Once you double click on this icon the launcher is executed.(Actually it's open method is fired)

Follwoing is the Launcher class mentioned in pulugin.xml.
public void open(IPath file) {
 System.out.println("Launch Successful : file Location = "+ file.toString());
 File fileToOpen = file.toFile();
 if (fileToOpen.exists() && fileToOpen.isFile()) {
   IFileStore fileStore = EFS.getLocalFileSystem().getStore(fileToOpen.toURI());
   IWorkbenchPage page = PlatformUI.getWorkbench()
.getActiveWorkbenchWindow().getActivePage( );
 try {
            // Select the appropriate internal editor and launch the file
     IDE.openInternalEditorOnFileStore(page, fileStore);
 } catch (PartInitException e) {
  logger.error("error while opening cayenne file");
     }
}