1 package com.bull.eclipse.jonas.actions.ear; 2 3 import java.util.Enumeration ; 4 import java.util.Vector ; 5 6 import org.eclipse.jface.viewers.IStructuredContentProvider; 7 import org.eclipse.jface.viewers.LabelProvider; 8 import org.eclipse.jface.viewers.Viewer; 9 import org.eclipse.ui.PlatformUI; 10 import org.eclipse.ui.dialogs.ListSelectionDialog; 11 12 import com.bull.eclipse.jonas.JonasProject; 13 import com.bull.eclipse.jonas.actions.JonasProjectAbstractActionDelegate; 14 import com.bull.eclipse.jonas.utils.RarManagement; 15 import com.bull.eclipse.jonas.utils.UpdatePropsFile; 16 import com.bull.eclipse.newear.NewEarRunner; 17 18 19 20 public class ExportEarActionDelegate extends JonasProjectAbstractActionDelegate 21 { 22 static private Object [] oldSelection = null; 23 private JonasProject prj = null; 24 25 26 public boolean doActionOn(JonasProject prj) throws Exception { 27 this.prj = prj; 28 UpdatePropsFile.updatePropsProject(prj); 30 31 Vector ejbListe = prj.getJarEjbName(); 33 Vector listModules = new Vector (); 34 String [] rarListe = RarManagement.searchRarInProject(prj); 35 if (ejbListe != null) { 36 for (Enumeration e = ejbListe.elements() ; e.hasMoreElements() ;) { 37 String ejbName = (String ) e.nextElement(); 38 listModules.add("Ejb Module : " + ejbName); 39 } 40 } 41 if ((prj.getWebContext() != null) && (!prj.getWebContext().equals(""))) 42 listModules.add("Web module : " + prj.getWebContext()); 43 44 if (rarListe != null) { 45 for (int i=0;i<rarListe.length;i++) { 46 String rarName = rarListe[i]; 47 listModules.add("Rar Module : " + rarName); 48 } 49 } 50 51 final String [] listModulesJ2ee = (String []) listModules.toArray(new String [0]); 52 ListSelectionDialog lsd = 53 new ListSelectionDialog( 54 PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), 55 new Object (), 56 new IStructuredContentProvider() { 57 58 public void dispose() { 59 } 60 61 public Object [] getElements(Object inputElement) { 62 return listModulesJ2ee; 63 } 64 65 public void inputChanged(Viewer viewer1, Object obj, Object obj1) { 66 int i = 0; 67 } 68 69 }, new LabelProvider(), "Select modules to put in application"); 70 71 lsd.setTitle("Select j2ee modules"); 72 if (oldSelection == null) { 73 lsd.setInitialSelections(listModulesJ2ee); 74 } else { 75 lsd.setInitialSelections(oldSelection); 76 } 77 lsd.open(); 78 79 Object [] results_upd = lsd.getResult(); 80 81 oldSelection = results_upd; 82 83 int ret = lsd.getReturnCode(); 84 if (ret == 1) 86 throw new Exception ("Operation is cancelled"); 87 if ((results_upd == null) || (results_upd.length == 0)) 88 throw new Exception ("There is no element to build the application"); 89 90 Vector moduleEjbSel = new Vector (); 91 for(int i=0;i<oldSelection.length;i++) { 92 if (oldSelection[i].toString().startsWith("Ejb")) { 93 moduleEjbSel.add(oldSelection[i].toString().replaceAll("Ejb Module : ","")); 94 } 95 } 96 97 Vector moduleWebSel = new Vector (); 98 for(int i=0;i<oldSelection.length;i++) { 99 if (oldSelection[i].toString().startsWith("Web")) { 100 moduleWebSel.add(oldSelection[i].toString().replaceAll("Web Module : ","")); 101 } 102 } 103 104 Vector moduleRarSel = new Vector (); 105 for(int i=0;i<oldSelection.length;i++) { 106 if (oldSelection[i].toString().startsWith("Rar")) { 107 moduleRarSel.add(oldSelection[i].toString().replaceAll("Rar Module : ","")); 108 } 109 } 110 111 NewEarRunner runner = new NewEarRunner(prj,moduleEjbSel,moduleWebSel,moduleRarSel); 112 runner.RunNewear(); 113 114 117 return false; 118 } 119 120 } 121 122 | Popular Tags |