KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > kelp > forte > actions > AppWizardAction


1 /*
2  * Enhydra Java Application Server Project
3  *
4  * The contents of this file are subject to the Enhydra Public License
5  * Version 1.1 (the "License"); you may not use this file except in
6  * compliance with the License. You may obtain a copy of the License on
7  * the Enhydra web site ( http://www.enhydra.org/ ).
8  *
9  * Software distributed under the License is distributed on an "AS IS"
10  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
11  * the License for the specific terms governing rights and limitations
12  * under the License.
13  *
14  * The Initial Developer of the Enhydra Application Server is Lutris
15  * Technologies, Inc. The Enhydra Application Server and portions created
16  * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
17  * All Rights Reserved.
18  *
19  * Contributor(s):
20  * Lisa Reese
21  *
22  */

23 package org.enhydra.kelp.forte.actions;
24
25 // OpenIDE
26
import org.openide.util.HelpCtx;
27 import org.openide.util.NbBundle;
28 import org.openide.util.actions.CallableSystemAction;
29 import org.openide.DialogDescriptor;
30 import org.openide.TopManager;
31 import org.openide.loaders.DataObject;
32 import org.openide.loaders.DataObjectNotFoundException;
33 import org.openide.filesystems.FileSystem;
34 import org.openide.filesystems.FileObject;
35 import org.openide.cookies.ViewCookie;
36 import org.openide.filesystems.Repository;
37 import org.openide.filesystems.JarFileSystem;
38 import org.openide.util.actions.SystemAction;
39 import org.openide.util.actions.CallableSystemAction;
40
41 // ToolBox
42
import org.enhydra.tool.codegen.Generator;
43 import org.enhydra.tool.codegen.GeneratorException;
44 import org.enhydra.tool.codegen.internal.Enhydra3AppGenerator;
45 import org.enhydra.tool.codegen.internal.WebAppGenerator;
46 import org.enhydra.tool.codegen.internal.ServiceGenerator;
47 import org.enhydra.tool.codegen.wizard.CodeGenWizard;
48 import org.enhydra.tool.codegen.wizard.GenSelectionEvent;
49 import org.enhydra.tool.codegen.wizard.GenSelectionListener;
50 import org.enhydra.tool.common.wizard.TBWizardButtonPanel;
51 import org.enhydra.tool.common.event.HelpListener;
52 import org.enhydra.tool.common.event.HelpEvent;
53 import org.enhydra.tool.ToolBoxInfo;
54
55 // AddinCore
56
import org.enhydra.kelp.KelpInfo;
57 import org.enhydra.kelp.common.codegen.CodeGenException;
58 import org.enhydra.kelp.common.codegen.ProjectGenUtil;
59 import org.enhydra.kelp.common.codegen.Enhydra3AppUtil;
60 import org.enhydra.kelp.common.codegen.ServiceUtil;
61 import org.enhydra.kelp.common.codegen.WebAppUtil;
62
63 // AddinForte
64
import org.enhydra.kelp.forte.node.ForteProject;
65 import org.enhydra.kelp.forte.node.XMLCDataObject;
66 import org.enhydra.kelp.forte.XMLCSettings;
67
68 // JDK
69
import java.awt.Dialog JavaDoc;
70 import java.awt.event.ActionListener JavaDoc;
71 import java.awt.event.ActionEvent JavaDoc;
72 import java.net.URL JavaDoc;
73 import java.net.MalformedURLException JavaDoc;
74 import java.io.File JavaDoc;
75 import java.util.ArrayList JavaDoc;
76 import java.io.IOException JavaDoc;
77 import java.beans.PropertyVetoException JavaDoc;
78 import javax.swing.JOptionPane JavaDoc;
79 import java.util.ResourceBundle JavaDoc;
80
81 import java.io.FileOutputStream JavaDoc;
82 import java.io.FileNotFoundException JavaDoc;
83
84 /**
85  * Action that can always be invoked and work procedurally.
86  *
87  * @author rees0234
88  */

89 public class AppWizardAction extends CallableSystemAction
90     implements HelpListener, GenSelectionListener {
91
92     private static String JavaDoc anchor = "Idunno";
93     private ProjectGenUtil util = null;
94
95     public static final int NOAPP = -1;
96     public static final int WEBAPP = 0;
97     public static final int SERVICE = 1;
98     public static final int ENHYDRA = 2;
99
100     protected static int apptype = NOAPP;
101
102     public static int getAppType()
103     {
104         return apptype;
105     }
106
107     public void performAction() {
108         String JavaDoc[] options = TBWizardButtonPanel.getOptions();
109
110         try {
111             CodeGenWizard wizard = new CodeGenWizard();
112             wizard.getInnerPanel().initPreferredSize();
113             DialogDescriptor dscr =
114                 new DialogDescriptor(wizard.getInnerPanel(),
115                                      wizard.getTitle(), true, options,
116                                      options[1],
117                                      DialogDescriptor.BOTTOM_ALIGN,
118                                      HelpCtx.DEFAULT_HELP,
119                                      wizard.createButtonListener());
120             Dialog JavaDoc dlg = TopManager.getDefault().createDialog(dscr);
121
122             wizard.addSelectionListener(this);
123             wizard.addHelpListener(this);
124             wizard.getInnerPanel().preShow();
125             wizard.setAllowRootEdit(false);
126             dlg.show();
127             if (util == null) {
128               // cancelled prior to selection
129
} else if (wizard.getOption() != JOptionPane.CANCEL_OPTION)
130
131             {
132                 ForteProject project = new ForteProject();
133                // FileSystem system = project.getRootFileSystem();
134
FileObject readme = null;
135                 FileObject rootFile = project.getRootFolder();
136                 String JavaDoc src = XMLCSettings.getDefault().getRoot();
137               //refresh all the project dir so we can find the generated files:
138
rootFile.refresh();
139                 try {
140                     rootFile.getFileObject(src);
141                 } catch (IllegalArgumentException JavaDoc e) {
142                     System.err.println(e);
143                     return;
144                 }
145                 if (rootFile.getChildren().length <= 0)
146                     return;
147
148                 XMLCSettings.getDefault().setSource(org.enhydra.kelp.common.Constants.DIR_SRC);
149
150                 util.importFiles(wizard.getGeneratedFiles());
151                 //add enhydra stuff to classpath:
152
Repository rep = TopManager.getDefault().getRepository();
153                 String JavaDoc classpath = project.getClassPath();
154                 if (apptype == WEBAPP || apptype == ENHYDRA)
155                 {
156
157                     String JavaDoc target = null;
158                     StringBuffer JavaDoc buf = new StringBuffer JavaDoc();
159                     buf.append(ToolBoxInfo.getEnhydraRoot()).append(File.separatorChar).append("lib").
160                     append(File.separatorChar);
161                     String JavaDoc base = buf.toString();
162                     buf.delete(0, buf.length());
163                     buf.append(base).append("enhydra.jar");
164                     target = buf.toString();
165                     buf.delete(0, buf.length());
166 // if (! project.cpContains(target))
167
{
168                         JarFileSystem jar = new JarFileSystem();
169                         jar.setJarFile(new File JavaDoc(target));
170                         rep.addFileSystem(jar);
171                     }
172                     buf.append(ToolBoxInfo.getEnhydraRoot()).append(File.separatorChar).append("lib").
173                     append(File.separatorChar).append("build").append(File.separatorChar);
174                     base = buf.toString();
175                     buf.delete(0, buf.length());
176                     buf.append(base).append("toolbox.jar");
177                     target = buf.toString();
178                     buf.delete(0, buf.length());
179 // if (! project.cpContains(target))
180
{
181                         JarFileSystem jar = new JarFileSystem();
182                         jar.setJarFile(new File JavaDoc(target));
183                         rep.addFileSystem(jar);
184                     }
185                     buf.append(ToolBoxInfo.getEnhydraRoot()).append(File.separatorChar).append("lib").
186                     append(File.separatorChar);
187                     base = buf.toString();
188                     buf.delete(0, buf.length());
189                     buf.append(base).append("xmlc.jar");
190                     target = buf.toString();
191                     buf.delete(0, buf.length());
192 // if (! project.cpContains(target))
193
{
194                         JarFileSystem jar = new JarFileSystem();
195                         jar.setJarFile(new File JavaDoc(target));
196                         rep.addFileSystem(jar);
197                     }
198                     //SV
199
buf.append(ToolBoxInfo.getEnhydraRoot()).append(File.separatorChar).append("lib").
200                     append(File.separatorChar);
201                     base = buf.toString();
202                     buf.delete(0, buf.length());
203                     buf.append(base).append("servlet.jar");
204                     target = buf.toString();
205                     buf.delete(0, buf.length());
206 // if (! project.cpContains(target))
207
{
208                         JarFileSystem jar = new JarFileSystem();
209                         jar.setJarFile(new File JavaDoc(target));
210                         rep.addFileSystem(jar);
211                     }
212                     //SV
213
buf.append(ToolBoxInfo.getEnhydraRoot()).append(File.separatorChar).append("lib").
214                     append(File.separatorChar);
215                     base = buf.toString();
216                     buf.delete(0, buf.length());
217 // vl 20.07.03
218
// buf.append(base).append("xerces.jar");
219
buf.append(base).append("xercesImpl.jar");
220                     target = buf.toString();
221                     buf.delete(0, buf.length());
222 // if (! project.cpContains(target))
223
{
224                         JarFileSystem jar = new JarFileSystem();
225                         jar.setJarFile(new File JavaDoc(target));
226                         rep.addFileSystem(jar);
227                     }
228                     buf.append(ToolBoxInfo.getEnhydraRoot()).append(File.separatorChar).append("lib").
229                     append(File.separatorChar);
230                     base = buf.toString();
231                     buf.delete(0, buf.length());
232 // vl 20.07.03
233
buf.append(base).append("xml-apis.jar");
234                     target = buf.toString();
235                     buf.delete(0, buf.length());
236                     {
237                         JarFileSystem jar = new JarFileSystem();
238                         jar.setJarFile(new File JavaDoc(target));
239                         rep.addFileSystem(jar);
240                     }
241                     
242                     buf.append(base).append("dom3-xml-apis.jar");
243                     target = buf.toString();
244                     buf.delete(0, buf.length());
245                     {
246                         JarFileSystem jar = new JarFileSystem();
247                         jar.setJarFile(new File JavaDoc(target));
248                         rep.addFileSystem(jar);
249                     }
250 // vl 20.07.03
251
buf.append(ToolBoxInfo.getEnhydraRoot()).append(File.separatorChar).append("lib").
252                     append(File.separatorChar);
253                     base = buf.toString();
254                     buf.delete(0, buf.length());
255                     buf.append(base).append("tomcat.jar");
256                     target = buf.toString();
257                     buf.delete(0, buf.length());
258 // if (! project.cpContains(target))
259
{
260                         JarFileSystem jar = new JarFileSystem();
261                         jar.setJarFile(new File JavaDoc(target));
262                         rep.addFileSystem(jar);
263                     }
264                     buf.append(ToolBoxInfo.getEnhydraRoot()).append(File.separatorChar).append("lib").
265                     append(File.separatorChar);
266                     base = buf.toString();
267                     buf.delete(0, buf.length());
268                     buf.append(base).append("core.jar");
269                     target = buf.toString();
270                     buf.delete(0, buf.length());
271 // if (! project.cpContains(target))
272
{
273                         JarFileSystem jar = new JarFileSystem();
274                         jar.setJarFile(new File JavaDoc(target));
275                         rep.addFileSystem(jar);
276                     }
277                     buf.append(ToolBoxInfo.getEnhydraRoot()).append(File.separatorChar).append("lib").
278                     append(File.separatorChar);
279                     base = buf.toString();
280                     buf.delete(0, buf.length());
281                     buf.append(base).append("util.jar");
282                     target = buf.toString();
283                     buf.delete(0, buf.length());
284 // if (! project.cpContains(target))
285
{
286                         JarFileSystem jar = new JarFileSystem();
287                         jar.setJarFile(new File JavaDoc(target));
288                         rep.addFileSystem(jar);
289                     }
290                     buf.append(ToolBoxInfo.getEnhydraRoot()).append(File.separatorChar).append("lib").
291                     append(File.separatorChar);
292                     base = buf.toString();
293                     buf.delete(0, buf.length());
294                     buf.append(base).append("gnu-regexp.jar");
295                     target = buf.toString();
296                     buf.delete(0, buf.length());
297 // if (! project.cpContains(target))
298
{
299                         JarFileSystem jar = new JarFileSystem();
300                         jar.setJarFile(new File JavaDoc(target));
301                         rep.addFileSystem(jar);
302                     }
303 /* vl 19.07.03
304                     buf.append(ToolBoxInfo.getEnhydraRoot()).append(File.separatorChar).append("lib").
305                     append(File.separatorChar);
306                     base = buf.toString();
307                     buf.delete(0, buf.length());
308                     buf.append(base).append("wireless.jar");
309                     target = buf.toString();
310                     buf.delete(0, buf.length());
311 // if (! project.cpContains(target))
312                     {
313                         JarFileSystem jar = new JarFileSystem();
314                         jar.setJarFile(new File(target));
315                         rep.addFileSystem(jar);
316                     }
317                     buf.append(ToolBoxInfo.getEnhydraRoot()).append(File.separatorChar).append("lib").
318                     append(File.separatorChar);
319                     base = buf.toString();
320                     buf.delete(0, buf.length());
321                     buf.append(base).append("xhtml.jar");
322                     target = buf.toString();
323                     buf.delete(0, buf.length());
324 // if (! project.cpContains(target))
325                     {
326                         JarFileSystem jar = new JarFileSystem();
327                         jar.setJarFile(new File(target));
328                         rep.addFileSystem(jar);
329                     }
330 */

331                     buf.append(ToolBoxInfo.getEnhydraRoot()).append(File.separatorChar).append("lib").
332                     append(File.separatorChar);
333                     base = buf.toString();
334                     buf.delete(0, buf.length());
335                     buf.append(base).append("xhtml.jar");
336                     target = buf.toString();
337                     buf.delete(0, buf.length());
338                     {
339                         JarFileSystem jar = new JarFileSystem();
340                         jar.setJarFile(new File JavaDoc(target));
341                         rep.addFileSystem(jar);
342                     }
343                     buf.append(ToolBoxInfo.getEnhydraRoot()).append(File.separatorChar).append("lib").
344                     append(File.separatorChar).append("dom").append(File.separatorChar);
345                     base = buf.toString();
346                     buf.delete(0, buf.length());
347                     buf.append(base).append("xmlc-chtml.jar");
348                     target = buf.toString();
349                     buf.delete(0, buf.length());
350                     {
351                         JarFileSystem jar = new JarFileSystem();
352                         jar.setJarFile(new File JavaDoc(target));
353                         rep.addFileSystem(jar);
354                     }
355                     buf.append(ToolBoxInfo.getEnhydraRoot()).append(File.separatorChar).append("lib").
356                     append(File.separatorChar).append("dom").append(File.separatorChar);
357                     base = buf.toString();
358                     buf.delete(0, buf.length());
359                     buf.append(base).append("xmlc-voicexml.jar");
360                     target = buf.toString();
361                     buf.delete(0, buf.length());
362                     {
363                         JarFileSystem jar = new JarFileSystem();
364                         jar.setJarFile(new File JavaDoc(target));
365                         rep.addFileSystem(jar);
366                     }
367                     buf.append(ToolBoxInfo.getEnhydraRoot()).append(File.separatorChar).append("lib").
368                     append(File.separatorChar).append("dom").append(File.separatorChar);
369                     base = buf.toString();
370                     buf.delete(0, buf.length());
371                     buf.append(base).append("xmlc-wml.jar");
372                     target = buf.toString();
373                     buf.delete(0, buf.length());
374                     {
375                         JarFileSystem jar = new JarFileSystem();
376                         jar.setJarFile(new File JavaDoc(target));
377                         rep.addFileSystem(jar);
378                     }
379 // vl 19.07.03
380
//Dusan 24.11.2002.
381
buf.append(ToolBoxInfo.getEnhydraRoot()).append(File.separatorChar).append("dods").
382                     append(File.separatorChar).append("lib").append(File.separatorChar);
383                     base = buf.toString();
384                     buf.delete(0, buf.length());
385                     buf.append(base).append("dods.jar");
386                     target = buf.toString();
387                     buf.delete(0, buf.length());
388                     {
389                       JarFileSystem jar = new JarFileSystem();
390                       jar.setJarFile(new File JavaDoc(target));
391                       rep.addFileSystem(jar);
392                     }
393                     buf.append(ToolBoxInfo.getEnhydraRoot()).append(File.separatorChar).append("dods").
394                     append(File.separatorChar).append("lib").append(File.separatorChar);
395                     base = buf.toString();
396                     buf.delete(0, buf.length());
397                     buf.append(base).append("dbmanager.jar");
398                     target = buf.toString();
399                     buf.delete(0, buf.length());
400
401                     {
402                       JarFileSystem jar = new JarFileSystem();
403                       jar.setJarFile(new File JavaDoc(target));
404                       rep.addFileSystem(jar);
405                     }
406                     buf.append(ToolBoxInfo.getEnhydraRoot()).append(File.separatorChar).append("dods").
407                     append(File.separatorChar).append("lib").append(File.separatorChar);
408                     base = buf.toString();
409                     buf.delete(0, buf.length());
410                     buf.append(base).append("dbmanager-api.jar");
411                     target = buf.toString();
412                     buf.delete(0, buf.length());
413
414                     {
415                       JarFileSystem jar = new JarFileSystem();
416                       jar.setJarFile(new File JavaDoc(target));
417                       rep.addFileSystem(jar);
418                     }
419                     buf.append(ToolBoxInfo.getEnhydraRoot()).append(File.separatorChar).append("dods").
420                     append(File.separatorChar).append("lib").append(File.separatorChar);
421                     base = buf.toString();
422                     buf.delete(0, buf.length());
423                     buf.append(base).append("dsconnection.jar");
424                     target = buf.toString();
425                     buf.delete(0, buf.length());
426
427                     {
428                       JarFileSystem jar = new JarFileSystem();
429                       jar.setJarFile(new File JavaDoc(target));
430                       rep.addFileSystem(jar);
431                     }
432                     buf.append(ToolBoxInfo.getEnhydraRoot()).append(File.separatorChar).append("dods").
433                     append(File.separatorChar).append("lib").append(File.separatorChar);
434                     base = buf.toString();
435                     buf.delete(0, buf.length());
436                     buf.append(base).append("stdcaches.jar");
437                     target = buf.toString();
438                     buf.delete(0, buf.length());
439
440                     {
441                       JarFileSystem jar = new JarFileSystem();
442                       jar.setJarFile(new File JavaDoc(target));
443                       rep.addFileSystem(jar);
444                     }
445                     buf.append(ToolBoxInfo.getEnhydraRoot()).append(File.separatorChar).append("dods").
446                     append(File.separatorChar).append("lib").append(File.separatorChar);
447                     base = buf.toString();
448                     buf.delete(0, buf.length());
449                     buf.append(base).append("stdconnection.jar");
450                     target = buf.toString();
451                     buf.delete(0, buf.length());
452
453                     {
454                       JarFileSystem jar = new JarFileSystem();
455                       jar.setJarFile(new File JavaDoc(target));
456                       rep.addFileSystem(jar);
457                     }
458                     buf.append(ToolBoxInfo.getEnhydraRoot()).append(File.separatorChar).append("dods").
459                     append(File.separatorChar).append("lib").append(File.separatorChar);
460                     base = buf.toString();
461                     buf.delete(0, buf.length());
462                     buf.append(base).append("stdtransaction.jar");
463                     target = buf.toString();
464                     buf.delete(0, buf.length());
465
466                     {
467                       JarFileSystem jar = new JarFileSystem();
468                       jar.setJarFile(new File JavaDoc(target));
469                       rep.addFileSystem(jar);
470                     }
471                     buf.append(ToolBoxInfo.getEnhydraRoot()).append(File.separatorChar).
472                     append("lib").append(File.separatorChar);
473                     base = buf.toString();
474                     buf.delete(0, buf.length());
475                     buf.append(base).append("log4j.jar");
476                     target = buf.toString();
477                     buf.delete(0, buf.length());
478                     {
479                       JarFileSystem jar = new JarFileSystem();
480                       jar.setJarFile(new File JavaDoc(target));
481                       rep.addFileSystem(jar);
482                     }
483
484 // }
485
// vl 03.08.03
486

487                     //Disabling ant module
488
char sep = File.separatorChar;
489                     File JavaDoc fant = new File JavaDoc(System.getProperty("netbeans.user")+sep+"system"+
490                       sep+"Modules"+sep+"org-apache-tools-ant-module.xml");
491                     try{
492                     FileOutputStream JavaDoc fosant = new FileOutputStream JavaDoc(fant);
493                     fosant.write(("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"+
494                     "<!DOCTYPE module PUBLIC \"-//NetBeans//DTD Module Status 1.0//EN\""+
495                     " \"http://www.netbeans.org/dtds/module-status-1_0.dtd\">"+
496                     "<module name=\"org.apache.tools.ant.module\">"+
497                     " <param name=\"autoload\">false</param>"+
498                     " <param name=\"enabled\">false</param>"+
499                     " <param name=\"jar\">ant.jar</param>"+
500                     " <param name=\"origin\">installation</param>"+
501                     " <param name=\"release\">2</param>"+
502                     " <param name=\"reloadable\">false</param>"+
503                     " <param name=\"specversion\">2.7.2</param>"+
504                     "</module>").getBytes());
505                     } catch (FileNotFoundException JavaDoc ex) {
506                     } catch (IOException JavaDoc ex) {
507                     }
508
509                   }
510
511 // vl 03.08.03
512
readme = rootFile.getFileObject("readme", "html");
513                 XMLCDataObject target = null;
514                           //open readme.html:
515
try {
516                         target = (XMLCDataObject)DataObject.find(readme);
517                  } catch (DataObjectNotFoundException e) {
518                       System.err.println(e);
519                  }
520                  if (target != null)
521                  {
522                    ViewCookie viewit = (ViewCookie)target.getCookie(ViewCookie.class);
523                    if (viewit != null)
524                         viewit.view();
525                  }
526             }
527
528         } catch (GeneratorException e) {
529             e.printStackTrace(System.err);
530         } catch (CodeGenException e) {
531             e.printStackTrace(System.err);
532         } catch (IOException JavaDoc e) {
533             System.err.println(e);
534         } catch (PropertyVetoException JavaDoc e) {
535             System.err.println(e);
536         }
537         //force menu's enabled as this is not happening "naturally":
538
((XMLCAction)SystemAction.get(XMLCAction.class)).setEnabled(true);
539         ((DeploymentAction)SystemAction.get(DeploymentAction.class)).setEnabled(true);
540
541     }
542
543     public String JavaDoc getName() {
544         return CodeGenWizard.getDefaultTitle();
545     }
546
547     public boolean isEnabled()
548     {
549         return (new ForteProject().getRootFolder() != null);
550     }
551
552     protected String JavaDoc iconResource() {
553         return "smallicon.gif";
554     }
555
556     public HelpCtx getHelpCtx() {
557         return HelpCtx.DEFAULT_HELP;
558
559         // If you will provide context help then use:
560
// return new HelpCtx (AppWizardAction.class);
561
}
562
563     /**
564      * Perform extra initialization of this action's singleton.
565      * PLEASE do not use constructors for this purpose!
566      */

567     protected void initialize() {
568         super.initialize();
569         putProperty(javax.swing.Action.SHORT_DESCRIPTION,
570                     NbBundle.getMessage(AppWizardAction.class,
571                                         "HINT_AppWiz_Action"));
572     }
573
574     // implements GenSelectionListener
575
public void onSelection(GenSelectionEvent event) {
576         ForteProject project = new ForteProject();
577         Generator gen = event.getGenerator();
578         CodeGenWizard wizard = event.getWizard();
579         try {
580             if (gen instanceof WebAppGenerator) {
581                 util = new WebAppUtil(project, (WebAppGenerator) gen);
582                 apptype = WEBAPP;
583             } else if (gen instanceof ServiceGenerator) {
584                 util = new ServiceUtil(project, (ServiceGenerator) gen);
585                 apptype = SERVICE;
586             } else if (gen instanceof Enhydra3AppGenerator) {
587                 util = new Enhydra3AppUtil(project,
588                                            (Enhydra3AppGenerator) gen);
589                 apptype = ENHYDRA;
590             }
591             if (getAddinSteps().length > 0)
592                 util.getGenerator().setAddinSteps(getAddinSteps());
593             String JavaDoc javaPath = System.getProperty("java.home");
594             //assume parent is root jdk dir as java.home points to jre:
595
if (javaPath.endsWith(File.separatorChar + "jre"))
596                 javaPath = javaPath.substring(0, javaPath.length() - 4);
597             else
598             {
599                 StringBuffer JavaDoc buf = new StringBuffer JavaDoc(javaPath);
600                 while (buf.charAt(buf.length() - 1) != File.separatorChar)
601                 {
602                     buf.deleteCharAt(buf.length() - 1);
603                 }
604                 buf.deleteCharAt(buf.length() - 1);
605                 javaPath = buf.toString();
606             }
607             util.getGenerator().setJavaPath(javaPath);
608
609             wizard.setCodeGen(util.getCodeGen());
610         } catch (CodeGenException e) {
611             e.printStackTrace(System.err);
612         }
613     }
614
615     // implements HelpListener
616
public void onHelp(HelpEvent event) {
617         URL JavaDoc url = null;
618         String JavaDoc[] home = new String JavaDoc[2];
619         home[0] = System.getProperty("netbeans.home");
620         home[1] = System.getProperty("netbeans.user");
621         StringBuffer JavaDoc buf = new StringBuffer JavaDoc();
622         buf.append(KelpInfo.getAddinHelpURL(home));
623         buf.append('#').append(anchor);
624         try {
625           url = new URL JavaDoc(buf.toString());
626           TopManager.getDefault().showUrl(url);
627         } catch (MalformedURLException JavaDoc e) {
628           e.printStackTrace(System.err);
629         }
630     }
631
632     // Steps added to generated readme.html file.
633
private String JavaDoc[] getAddinSteps() {
634         ResourceBundle JavaDoc bundle = NbBundle.getBundle(AppWizardAction.class);
635         ArrayList JavaDoc list = new ArrayList JavaDoc();
636         String JavaDoc[] steps = new String JavaDoc[0];
637
638         if (apptype == WEBAPP)
639         {
640             list.add(bundle.getString("readmeWeb1"));
641             list.add(bundle.getString("readmeWeb2"));
642             list.add(bundle.getString("readmeWeb3"));
643             list.add(bundle.getString("readmeWeb4"));
644         }
645         else if (apptype == SERVICE)
646         {
647             return steps;
648         }
649
650         else
651         {
652             list.add(bundle.getString("readmeEnApp1"));
653             list.add(bundle.getString("readmeEnApp2"));
654             list.add(bundle.getString("readmeEnApp3"));
655             list.add(bundle.getString("readmeEnApp4"));
656         }
657
658         list.trimToSize();
659
660         steps = new String JavaDoc[list.size()];
661         steps = (String JavaDoc[]) list.toArray(steps);
662         list.clear();
663         return steps;
664     }
665
666
667 }
668
Popular Tags