1 26 27 package org.objectweb.openccm.packaging.cmdline; 28 29 import org.objectweb.openccm.packaging.AssemblyPackager; 31 import org.objectweb.openccm.packaging.CCMMenuBar; 32 import org.objectweb.openccm.packaging.CCMSplitPane; 33 import org.objectweb.openccm.packaging.ComponentPackager; 34 import org.objectweb.openccm.packaging.FileOperations; 35 36 import org.objectweb.util.cmdline.api.CommandLine; 37 import org.objectweb.util.cmdline.lib.ApplicationBase; 38 import org.objectweb.util.cmdline.lib.DefaultCommandLine; 39 40 import org.objectweb.apollon.gui.ApollonFrame; 41 42 48 public class PATApplication 49 extends ApplicationBase 50 { 51 57 58 private boolean displayGUI_; 59 60 61 private boolean CARMaker_; 62 63 64 private boolean AARMaker_; 65 66 72 75 public 76 PATApplication() 77 { 78 super( 80 new DefaultCommandLine( 81 new String [] { "ccm_assembling", "car_maker" , "aar_maker" } 82 ,new String [0] 83 ,true 84 ,new String [] { 85 "Packaging/Assembling Tool providing a GUI and console-based engines (default is GUI)." 86 ,"car_maker is a shortcut for 'ccm_assembling -CAR'" 87 ,"aar_maker is a shortcut for 'ccm_assembling -AAR'" 88 ,"[additional] arguments should be descriptor files to be opened or used for CAR/AAR creation." 89 } 90 ,true 91 ) 92 ); 93 94 getCommandLine().addOption(new OptionCAR(this)); 96 getCommandLine().addOption(new OptionAAR(this)); 97 98 this.displayGUI_ = true; 100 } 101 102 108 114 119 public String 120 getIdentity() 121 { 122 return "OpenCCM's Packaging/Assembling Tools"; 123 } 124 125 132 public void 133 runMain(String [] args) 134 { 135 try { 136 String [] arguments = getCommandLine().parse(args); 138 139 int status = start(arguments); 141 142 } catch(org.objectweb.util.misc.api.ExceptionWrapper exc) { 145 report_exception(exc.getException()); 146 } catch(Exception exc) { 147 report_exception(exc); 148 } 149 } 150 151 158 public int 159 start(String [] args) 160 { 161 boolean result = process(args); 162 return 0; 163 164 } 166 167 177 public void 178 displayGUI(boolean displayGUI) 179 { 180 this.displayGUI_ = displayGUI; 181 } 182 183 188 public void 189 setCARMaker(boolean CAR) 190 { 191 this.CARMaker_ = CAR; 192 } 193 194 199 public void 200 setAARMaker(boolean AAR) 201 { 202 this.AARMaker_ = AAR; 203 } 204 205 212 public boolean 213 process (String [] filenames) 214 { 215 if (this.displayGUI_) 216 { 217 ApollonFrame frame 219 = new ApollonFrame(); 220 221 frame.set_split_panel(new CCMSplitPane()); 223 224 CCMMenuBar ccm_menubar 226 = new CCMMenuBar(frame); 227 228 frame.setVisible(true); 229 230 for (int i=0 ; i<filenames.length ; i++) 232 { 233 java.io.File file 234 = new java.io.File (filenames[i]); 235 236 FileOperations.open_file(file, frame); 237 } 238 synchronized (this) 239 { 240 try 241 { 242 this.wait(); 243 } catch (InterruptedException e) {} 244 } 245 } 246 for (int i=0 ; i<filenames.length ; i++) 247 { 248 String file_used = filenames[i]; 249 System.err.println(file_used); 250 251 java.io.File file 253 = new java.io.File (file_used); 254 255 org.objectweb.apollon.framework.Bean zeus_instance 256 = null; 257 258 if (CARMaker_) 259 { 260 try 262 { 263 zeus_instance 264 = org.objectweb.openccm.descriptor. 265 softpkg.beans. 266 SoftpkgBeanImpl 267 .unmarshalBean(file); 268 ComponentPackager maker = new ComponentPackager(); 270 maker.make_zip(zeus_instance,file_used); 271 272 } catch (Exception e) { 273 getConsole().getErrorStream().println( 274 "CAR builder ignored "+file); 275 } 276 } 277 if (AARMaker_) 278 { 279 try 281 { 282 zeus_instance 283 = org.objectweb.openccm.descriptor. 284 componentassembly.beans. 285 ComponentassemblyBeanImpl 286 .unmarshalBean(file); 287 AssemblyPackager maker = new AssemblyPackager(); 289 maker.make_zip(zeus_instance,file_used); 290 291 } catch (Exception e) { 292 getConsole().getErrorStream().println( 293 "AAR builder ignored "+file); 294 } 295 } 296 } 297 return true; 298 } 299 300 306 311 public static void 312 main(String [] args) 313 { 314 PATApplication application = new PATApplication(); 315 application.runMain(args); 316 } 317 } 318 | Popular Tags |