KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > bull > eclipse > jonas > actions > AbstractExportActionDelegate


1 package com.bull.eclipse.jonas.actions;
2
3  
4 import org.eclipse.jface.action.IAction;
5 import org.eclipse.jface.viewers.ISelection;
6 import org.eclipse.ui.IActionDelegate;
7
8
9 /*
10  * Abstract class for copying EAR/JAR/WAR files to the corresponding
11  * autoload directory of JONAS_BASE.
12  */

13
14 public abstract class AbstractExportActionDelegate implements IActionDelegate
15 {
16
17     private ISelection selection;
18
19     public void run( IAction a )
20     {
21         /*
22         if( selection instanceof IStructuredSelection
23         && !selection.isEmpty() ) {
24             Object o = ((IStructuredSelection)selection).getFirstElement();
25             JonasLauncherPlugin.log("Object = " + o);
26             if( o instanceof IFile ) {
27                 IFile f = (IFile)o;
28                 File source = f.getLocation().toFile();
29                 String jonasBase = JonasLauncherPlugin.getDefault().getBaseDir();
30                 File target = new File( jonasBase + "/" + targetDir() + "/" + f.getName());
31                 try {
32                     FileUtil.copyFile( source, target );
33                 }
34                 catch( IOException e ) {
35                     JonasLauncherPlugin.log( "JOPE: "
36                         + "error copying " + source + " to " + target );
37                 }
38             } else
39                 if( o instanceof IFolder ) {
40                     IFolder f = (IFolder)o;
41                     File buildXML = f.getLocation().append("build.xml").toFile();
42                     JonasLauncherPlugin.log("Folder = " + buildXML);
43                     if (!buildXML.exists())
44                         MessageDialog.openInformation( null, "JOPE",
45                                 "This package is not an EJB package" );
46                 } else {
47                 MessageDialog.openInformation( null, "JOPE",
48                     "Unable to operate on this selection (not a IFile and IFolder)" );
49                 }
50         } else {
51             Shell shell = JavaPlugin.getActiveWorkbenchShell();
52             MessageDialog.openInformation( shell, "JOPE",
53                 "Unable to operate on this selection" );
54         }
55         */

56     }
57     
58
59     public void selectionChanged( IAction a, ISelection sel )
60     {
61         selection = sel;
62     }
63
64
65     /*
66      * @return the directory structure subordinate to
67      * JONAS_BASE into which should be copied this particluar
68      * EAR/JAR/WAR file. (No leading or trailing file-separator
69      * characters should be included in the returned String.)
70      */

71     abstract public String JavaDoc targetDir();
72
73 }
74
75
Popular Tags