1 26 package org.objectweb.openccm.explorer.Deployment; 27 28 import java.net.URL ; 29 30 import org.objectweb.openccm.explorer.menu.JFileChooserSingleton; 31 import org.objectweb.openccm.explorer.menu.OpenCCMBrowserConstants; 32 import org.objectweb.util.explorer.api.MenuItem; 33 import org.objectweb.util.explorer.api.MenuItemTreeView; 34 import org.objectweb.util.explorer.api.TreeView; 35 import org.objectweb.util.explorer.swing.gui.api.DialogAction; 36 import org.objectweb.util.explorer.swing.gui.api.DialogBox; 37 import org.objectweb.util.explorer.swing.gui.lib.DefaultDialogBox; 38 import org.objectweb.util.explorer.swing.gui.lib.FileChooserBox; 39 import org.omg.Components.Deployment.AssemblyFactory; 40 41 52 public class CreateAssembly 53 implements MenuItem, DialogAction { 54 55 61 62 protected FileChooserBox archive_ = null; 63 64 65 protected AssemblyFactory assemblyFactory_ = null; 66 67 73 79 protected AssemblyFactory getAssemblyFactory(TreeView treeView){ 80 return (AssemblyFactory)treeView.getSelectedObject(); 81 } 82 83 89 public int getStatus(TreeView arg0){ 90 return MenuItem.ENABLED_STATUS; 91 } 92 93 public void actionPerformed(MenuItemTreeView e) throws Exception { 94 assemblyFactory_ = getAssemblyFactory(e); 95 96 DialogBox dialog = new DefaultDialogBox("Create an assembly"); 97 archive_ = new FileChooserBox("Archive",JFileChooserSingleton.getInstance(OpenCCMBrowserConstants.ASSEMBLY_ARCHIVE_FILE_CHOOSER),true,true); 98 dialog.addElementBox(archive_); 99 dialog.setValidateAction(this); 100 dialog.show(); 101 } 102 103 109 112 public void executeAction() throws Exception { 113 URL theURL = null; 114 if(archive_.getFile()!=null){ 115 java.net.ServerSocket s = new java.net.ServerSocket (0); 118 (new Thread (new MicroServerHttp(s))).start(); 119 theURL= new URL ("http://" + java.net.InetAddress.getLocalHost().getHostAddress() + ':' + s.getLocalPort() + '/' + archive_.getFile().getAbsolutePath()); 120 } else { 121 if(archive_.getURL()!=null){ 122 theURL = archive_.getURL(); 124 } 125 } 126 if(theURL!=null){ 127 assemblyFactory_.create_assembly(theURL.toString()); 128 } 129 } 130 } | Popular Tags |