1 7 package com.bull.eclipse.jonas.actions.rar; 8 9 15 16 import java.io.File ; 17 import java.io.IOException ; 18 19 import org.eclipse.core.resources.IResource; 20 import org.eclipse.jdt.internal.ui.JavaPlugin; 21 import org.eclipse.jface.dialogs.InputDialog; 22 23 import com.bull.eclipse.jonas.JonasPluginResources; 24 import com.bull.eclipse.jonas.JonasProject; 25 import com.bull.eclipse.jonas.actions.JonasProjectAbstractActionDelegate; 26 import com.bull.eclipse.jonas.utils.FileUtil; 27 import com.bull.eclipse.jonas.utils.TemplateDirUtil; 28 29 public class CreateRarActionDelegate extends JonasProjectAbstractActionDelegate { 30 31 32 public boolean doActionOn(JonasProject prj) throws Exception { 33 InputDialog id = new InputDialog( 34 JavaPlugin.getActiveWorkbenchShell(), 35 JonasPluginResources.JONAS_RAR_CREATION_LABEL, 36 JonasPluginResources.JONAS_RAR_NAME_LABEL, 37 null, 38 null); 39 id.open(); 40 String rarName = id.getValue(); 41 File raDir = prj.getProject().getLocation().append("resourceAdapter").toFile(); 42 boolean createDir = true; 43 if (!raDir.exists()) 44 createDir = raDir.mkdir(); 45 if (!createDir) 46 throw new IOException ("Error until creation resource adapter directory"); 47 File raNewDir = new File (raDir,rarName + File.separator + "META-INF"); 48 if (!raNewDir.exists()) 49 createDir = raNewDir.mkdirs(); 50 if (!createDir) 51 throw new IOException ("Error until creation specific resource adapter directory"); 52 FileUtil.copy(new File (TemplateDirUtil.getTemplateDir().concat(File.separator).concat("ra.xml")), new File (raNewDir + File.separator + "ra.xml")); 53 FileUtil.copy(new File (TemplateDirUtil.getTemplateDir().concat(File.separator).concat("jonas-ra.xml")), new File (raNewDir + File.separator + "jonas-ra.xml")); 54 prj.getProject().refreshLocal( IResource.DEPTH_INFINITE, null ); 55 56 return false; 57 } 58 59 60 } 61 | Popular Tags |