KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > bull > eclipse > jonas > actions > rar > CreateRarActionDelegate


1 /*
2  * Created on 2 juin 2003
3  *
4  * To change the template for this generated file go to
5  * Window>Preferences>Java>Code Generation>Code and Comments
6  */

7 package com.bull.eclipse.jonas.actions.rar;
8
9 /**
10  * @author Emmanuel RIAS
11  *
12  * To change the template for this generated type comment go to
13  * Window>Preferences>Java>Code Generation>Code and Comments
14  */

15
16 import java.io.File JavaDoc;
17 import java.io.IOException JavaDoc;
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 JavaDoc {
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 JavaDoc rarName = id.getValue();
41         File JavaDoc 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 JavaDoc("Error until creation resource adapter directory");
47         File JavaDoc raNewDir = new File JavaDoc(raDir,rarName + File.separator + "META-INF");
48         if (!raNewDir.exists())
49             createDir = raNewDir.mkdirs();
50         if (!createDir)
51             throw new IOException JavaDoc("Error until creation specific resource adapter directory");
52         FileUtil.copy(new File JavaDoc(TemplateDirUtil.getTemplateDir().concat(File.separator).concat("ra.xml")), new File JavaDoc(raNewDir + File.separator + "ra.xml"));
53         FileUtil.copy(new File JavaDoc(TemplateDirUtil.getTemplateDir().concat(File.separator).concat("jonas-ra.xml")), new File JavaDoc(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