KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > webdocwf > util > loader > wizard > WizardFrame


1 package org.webdocwf.util.loader.wizard;
2
3 import java.awt.Color JavaDoc;
4 import java.awt.Dimension JavaDoc;
5 import java.awt.Toolkit JavaDoc;
6 import java.awt.event.ActionEvent JavaDoc;
7 import java.awt.event.MouseAdapter JavaDoc;
8 import java.awt.event.MouseEvent JavaDoc;
9 import java.awt.event.MouseListener JavaDoc;
10 import java.io.File JavaDoc;
11 import java.io.FileInputStream JavaDoc;
12 import java.io.InputStream JavaDoc;
13
14 import javax.swing.AbstractAction JavaDoc;
15 import javax.swing.ImageIcon JavaDoc;
16 import javax.swing.JButton JavaDoc;
17 import javax.swing.JDesktopPane JavaDoc;
18 import javax.swing.JFileChooser JavaDoc;
19 import javax.swing.JFrame JavaDoc;
20 import javax.swing.JMenu JavaDoc;
21 import javax.swing.JMenuBar JavaDoc;
22 import javax.swing.JMenuItem JavaDoc;
23 import javax.swing.JOptionPane JavaDoc;
24 import javax.swing.JPopupMenu JavaDoc;
25 import javax.swing.JToolBar JavaDoc;
26 import javax.swing.KeyStroke JavaDoc;
27 import javax.swing.UIManager JavaDoc;
28
29
30 public class WizardFrame extends JFrame JavaDoc {
31     private WizardFrame wizardFrame;
32     private JDesktopPane JavaDoc desktop;
33     private JPopupMenu JavaDoc popUp;
34     private static boolean startOctopusLoader = false;
35     private static String JavaDoc pathToXmlFile = "";
36     private static boolean startOctopusProject = false;
37     private static String JavaDoc pathToProjectFile = "";
38     private static String JavaDoc confJarStructure = "";
39     private static int defaultProjectNameCounter = 1;
40     private static final String JavaDoc DEFAULT_PROJECT_NAME = "Untitled project";
41
42     public WizardFrame(String JavaDoc title) {
43         super(title);
44         wizardFrame = this;
45         setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
46         desktop = new JDesktopPane JavaDoc();
47         setContentPane(desktop);
48
49         // Install our custom desktop manager.
50
//ZK commented this
51
//desktop.setDesktopManager(new SampleDesktopMgr());
52
desktop.setBackground(new Color JavaDoc(210, 210, 210));
53
54         createMenuBar();
55         createPopupMenu();
56
57         if (startOctopusLoader) {
58             try {
59                 OctopusProjectFrame octopusProject = createOctopusProjectFrame(DEFAULT_PROJECT_NAME+defaultProjectNameCounter++);
60                 //redefine settings
61
octopusProject.getLoaderPanel().setOctopusLoaderInit(
62                     new OctopusLoaderData(),
63                     pathToXmlFile,
64                     confJarStructure);
65                 octopusProject.setActiveTab(1);
66                 desktop.add(octopusProject);
67                 octopusProject.setVisible(true);
68                 octopusProject.requestFocus();
69             } catch (Exception JavaDoc ex) {
70                 String JavaDoc message = "Error while starting OctopusWizard . Message : ";
71                 message += ex.getMessage();
72                 JOptionPane.showMessageDialog(desktop, message + "\n", "Error", 0);
73                 System.exit(0);
74             }
75         } else if( startOctopusProject ) {
76                 try {
77                 OctopusProperties properties = new OctopusProperties();
78                 InputStream JavaDoc is=new FileInputStream JavaDoc(pathToProjectFile);
79                 properties.load(is);
80                 String JavaDoc name = properties.getOctopusProperty("ProjectName");
81                 if (name == null || name.trim().equals(""))
82                                     name = DEFAULT_PROJECT_NAME+defaultProjectNameCounter++;
83                 OctopusProjectFrame octopusProject = createOctopusProjectFrame(name);
84                 confJarStructure = properties.getOctopusProperty("Generator.ConfJarStructure");
85                 OctopusGeneratorData generatorData = new OctopusGeneratorData(confJarStructure);
86                 
87                 //set data
88
setGeneratorData(properties,generatorData);
89                 
90                 octopusProject.getGeneratorPanel().setOctopusGeneratorInit(
91                     generatorData,
92                     confJarStructure);
93                 //set data
94
OctopusLoaderData loaderData = new OctopusLoaderData();
95                 setLoaderData(properties,loaderData);
96 //
97

98                 
99                 octopusProject.getLoaderPanel().setOctopusLoaderInit(
100                     loaderData,
101                     null,
102                     confJarStructure);
103                 
104                 desktop.add(octopusProject);
105                 octopusProject.setVisible(true);
106                 octopusProject.requestFocus();
107             } catch (Exception JavaDoc ex) {
108                 String JavaDoc message = "Error while starting OctopusWizard . Message : ";
109                 message += ex.getMessage();
110                 JOptionPane.showMessageDialog(desktop, message + "\n", "Error", 0);
111                 System.exit(0);
112             }
113         }
114     }
115
116     protected void createMenuBar() {
117         JMenuBar JavaDoc mb = new JMenuBar JavaDoc();
118         JMenu JavaDoc menu = new JMenu JavaDoc("Project");
119         menu.setMnemonic('P');
120         JMenu JavaDoc menu2 = new JMenu JavaDoc("IDEOptions");
121         menu2.setMnemonic('I');
122         JMenu JavaDoc menu3 = new JMenu JavaDoc("Help");
123         menu3.setMnemonic('H');
124
125         menu.add(new NewOctopusProjectItem()); // add Octopus Project frame as new project
126
menu.add(new OpenOctopusProjectItem()); // add Octopus Project frame as open project
127
menu.add(new ExitOctopusApplicationItem()); // add exit
128
menu2.add(new LnFActionMetal()); // add look and feel option
129
menu2.add(new LnFActionMotif());
130         menu2.add(new LnFActionWindows());
131         menu2.add(new LnFActionJava());
132         menu3.add(new OctopusHelpAction("Help"));
133         menu3.addSeparator();
134         menu3.add(new OctopusAboutAction());
135
136         setJMenuBar(mb);
137         mb.add(menu);
138         mb.add(menu2);
139         mb.add(menu3);
140     }
141
142
143     public void createPopupMenu() {
144         JMenuItem JavaDoc menuItem;
145
146         //Create the popup menu.
147
JPopupMenu JavaDoc popup = new JPopupMenu JavaDoc();
148         JMenuItem JavaDoc popupItem = new JMenuItem JavaDoc("Start new Octopus project");
149         popupItem.setAction(new NewOctopusProjectItem());
150         JMenuItem JavaDoc popupItem2 = new JMenuItem JavaDoc("Open existing Octopus project");
151         popupItem2.setAction(new OpenOctopusProjectItem());
152         JMenuItem JavaDoc popupItem3 = new JMenuItem JavaDoc("Exit Octopus Application");
153         popupItem3.setAction(new ExitOctopusApplicationItem());
154
155         popup.add(popupItem);
156         popup.add(popupItem2);
157         popup.add(popupItem3);
158
159         //Add listener to the destop area so the popup menu can come up.
160
MouseListener JavaDoc popupListener = new PopupListener(popup);
161         desktop.addMouseListener(popupListener);
162     }
163
164     public static void main(String JavaDoc[] args) {
165
166         OctopusSplash octopusSplash = new OctopusSplash("splash_octopus.gif", null);
167
168         if (args.length > 0 && args.length < 5) {
169             for (int i = 0; i < args.length - 1; i = i + 1) {
170                 if (args[i].equalsIgnoreCase("-sol")) {
171                     pathToXmlFile = args[++i];
172                     if (!pathToXmlFile.equalsIgnoreCase(""))
173                         startOctopusLoader = true;
174                 }
175                 if (args[i].equalsIgnoreCase("-sop")) {
176                     pathToProjectFile = args[++i];
177                     if (!pathToProjectFile.equalsIgnoreCase(""))
178                         startOctopusProject = true;
179                 }
180                 if (args[i].equalsIgnoreCase("-cjs")) {
181                     confJarStructure = args[++i];
182                 }
183             }
184         }
185         try {
186             UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
187         } catch (Exception JavaDoc e) {
188             e.printStackTrace();
189         }
190         WizardFrame wizardFrame = new WizardFrame("Enhydra Octopus Application");
191
192 // wizardFrame.addWindowListener(new WindowAdapter() {
193
// public void windowClosing(WindowEvent we) {
194
// System.exit(0);
195
// }
196
// });
197

198         wizardFrame.setIconImage(
199             new ImageIcon JavaDoc(WizardFrame.class.getResource("images/Enhydra16.gif")).getImage());
200
201         Dimension JavaDoc dimension = Toolkit.getDefaultToolkit().getScreenSize();
202         wizardFrame.setBounds(0, 0, dimension.width - 20, dimension.height - 40);
203
204         try {
205             Thread.sleep(2500);
206         } catch (Exception JavaDoc e) {
207             e.printStackTrace();
208         }
209         OctopusSplash.getSplash().hideSplash();
210         octopusSplash = null;
211         wizardFrame.setVisible(true);
212     }
213
214     private OctopusProjectFrame createOctopusProjectFrame(String JavaDoc name) throws Exception JavaDoc {
215         
216         //create menu
217
JMenuBar JavaDoc mb = new JMenuBar JavaDoc();
218         JMenu JavaDoc menu = new JMenu JavaDoc("Application");
219         menu.setMnemonic('A');
220         JMenuItem JavaDoc startGenerator = new JMenuItem JavaDoc("Start Generator");
221         JMenuItem JavaDoc startLoader = new JMenuItem JavaDoc("Start Loader");
222         JMenuItem JavaDoc save = new JMenuItem JavaDoc("Save project");
223         JMenuItem JavaDoc stop = new JMenuItem JavaDoc("Close project");
224         JMenuItem JavaDoc help = new JMenuItem JavaDoc("Help");
225         menu.add(startGenerator);
226         menu.add(startLoader);
227         menu.addSeparator();
228         menu.add(save);
229         menu.add(stop);
230         menu.addSeparator();
231         menu.add(help);
232         mb.add(menu);
233         
234         //create toolbar
235
JButton JavaDoc startGeneratorButton =
236                     OctopusProjectFrame.createOctopusButton(
237                         "Start Generator",
238                         OctopusGeneratorPanel.toolBarButton);
239         JButton JavaDoc startLoaderButton =
240             OctopusProjectFrame.createOctopusButton(
241                 "Start Loader",
242                 OctopusGeneratorPanel.toolBarButton);
243         JButton JavaDoc stopButton =
244             OctopusProjectFrame.createOctopusButton("Stop", OctopusGeneratorPanel.toolBarButton);
245         JButton JavaDoc saveButton =
246             OctopusProjectFrame.createOctopusButton("Save", OctopusGeneratorPanel.toolBarButton);
247         JButton JavaDoc helpButton =
248             OctopusProjectFrame.createOctopusButton("Help", OctopusGeneratorPanel.toolBarButton);
249         JToolBar JavaDoc toolBar = new JToolBar JavaDoc("Octopus toolbar");
250         toolBar.add(startGeneratorButton);
251 // toolBar.addSeparator();
252
toolBar.add(startLoaderButton);
253         toolBar.addSeparator();
254         toolBar.add(saveButton);
255 // toolBar.addSeparator();
256
toolBar.add(stopButton);
257         toolBar.addSeparator();
258         toolBar.add(helpButton);
259         //create generator panel
260
OctopusGeneratorPanel generatorPanel = new OctopusGeneratorPanel();
261         generatorPanel.setOctopusGeneratorInit(
262             new OctopusGeneratorData(confJarStructure),
263             confJarStructure);
264         //create loader panel
265
OctopusLoaderPanel loaderPanel = new OctopusLoaderPanel();
266         loaderPanel.setOctopusLoaderInit(new OctopusLoaderData(), null, confJarStructure);
267         //create octopus project frame
268
OctopusProjectFrame octopusProject =
269             new OctopusProjectFrame(name, loaderPanel, generatorPanel, toolBar);
270         octopusProject.getRootPane().setJMenuBar(mb);
271         //set actions for menu
272
startGenerator.setAction(new StartOctopusGeneratorAction(octopusProject, "Start Generator"));
273         startLoader.setAction(new StartOctopusLoaderAction(octopusProject, "Start Loader"));
274         stop.setAction(new CloseOctopusProjectAction(octopusProject, "Close"));
275         save.setAction(new SaveProjectAction(octopusProject, "Save"));
276         help.setAction(new OctopusHelpAction("Help"));
277         //set actions for toolbar
278
startGeneratorButton.setAction(new StartOctopusGeneratorAction(octopusProject, ""));
279         startLoaderButton.setAction(new StartOctopusLoaderAction(octopusProject, ""));
280         stopButton.setAction(new CloseOctopusProjectAction(octopusProject, ""));
281         saveButton.setAction(new SaveProjectAction(octopusProject, ""));
282         helpButton.setAction(new OctopusHelpAction(""));
283         //return frame
284
return octopusProject;
285     }
286
287     private class ExitOctopusApplicationItem extends AbstractAction JavaDoc {
288         /**
289          * Action which creates new frame
290          */

291         public ExitOctopusApplicationItem() {
292             putValue(NAME, "Exit");
293             putValue(
294                 ACCELERATOR_KEY,
295                 KeyStroke.getKeyStroke('X', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
296             putValue(
297             SMALL_ICON,
298             new ImageIcon JavaDoc(
299                 getClass().getClassLoader().getResource(
300                     "org/webdocwf/util/loader/" + "wizard/images/Stop.gif")));
301             putValue(SHORT_DESCRIPTION, "Exit Enhydra Octopus Application");
302             putValue(LONG_DESCRIPTION, "Exit Enhydra Octopus Application");
303             putValue(MNEMONIC_KEY, new Integer JavaDoc('X'));
304         }
305
306         public void actionPerformed(ActionEvent JavaDoc e) {
307             try {
308                 if(
309                             JOptionPane.showConfirmDialog(null, "Are you are sure want to exit?", "Exit", JOptionPane.INFORMATION_MESSAGE) == 0
310                             )
311                             {
312                                 System.exit(0);
313                             }
314             } catch (Exception JavaDoc ex) {
315                 String JavaDoc message =
316                     "Error while creating action for ExitOctopusApplicationItem menu item. Message :"
317                         + ex.getMessage();
318                 JOptionPane.showMessageDialog(desktop, message + "\n", "Error", 0);
319             }
320
321         }
322     }
323
324     private class NewOctopusProjectItem extends AbstractAction JavaDoc {
325         /**
326          * Action which creates new frame
327          */

328         public NewOctopusProjectItem() {
329             putValue(NAME, "New Octopus Project");
330             putValue(
331                 ACCELERATOR_KEY,
332                 KeyStroke.getKeyStroke('N', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
333             putValue(
334             SMALL_ICON,
335             new ImageIcon JavaDoc(
336                 getClass().getClassLoader().getResource(
337                     "org/webdocwf/util/loader/" + "wizard/images/New.gif")));
338             putValue(SHORT_DESCRIPTION, "Octopus project");
339             putValue(LONG_DESCRIPTION, "Start Octopus project");
340             putValue(MNEMONIC_KEY, new Integer JavaDoc('N'));
341         }
342
343         public void actionPerformed(ActionEvent JavaDoc e) {
344             try {
345                 String JavaDoc name = (String JavaDoc) JOptionPane.showInputDialog(null,
346                         "Project name : ",
347                         "New project...",
348                         JOptionPane.INFORMATION_MESSAGE,
349                         null,
350                         null,
351                         DEFAULT_PROJECT_NAME+defaultProjectNameCounter++);
352              if( name != null ) {
353                 if (name == null || name.trim().equals(""))
354                     name = DEFAULT_PROJECT_NAME+defaultProjectNameCounter++;
355                 OctopusProjectFrame octopusProject = createOctopusProjectFrame(name);
356                 desktop.add(octopusProject);
357                 octopusProject.setVisible(true);
358                 octopusProject.requestFocus();
359              } else {
360                 //cancel pressed
361
}
362
363             } catch (Exception JavaDoc ex) {
364                 String JavaDoc message =
365                     "Error while creating action for NewOctopusProject menu item. Message :"
366                         + ex.getMessage();
367                 JOptionPane.showMessageDialog(desktop, message + "\n", "Error", 0);
368             }
369
370         }
371     }
372
373     private class OpenOctopusProjectItem extends AbstractAction JavaDoc {
374         /**
375          * Action which creates new frame
376          */

377         public OpenOctopusProjectItem() {
378             putValue(NAME, "Open existing Octopus Project");
379             putValue(
380                 ACCELERATOR_KEY,
381                 KeyStroke.getKeyStroke('O', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
382             putValue(
383             SMALL_ICON,
384             new ImageIcon JavaDoc(
385                 getClass().getClassLoader().getResource(
386                     "org/webdocwf/util/loader/" + "wizard/images/Open.gif")));
387             putValue(SHORT_DESCRIPTION, "Octopus project");
388             putValue(LONG_DESCRIPTION, "Open Octopus project");
389             putValue(MNEMONIC_KEY, new Integer JavaDoc('0'));
390         }
391
392         public void actionPerformed(ActionEvent JavaDoc e) {
393             try {
394                 File JavaDoc current = new File JavaDoc(System.getProperty("user.dir"));
395                 JFileChooser JavaDoc chooser = new JFileChooser JavaDoc(current);
396                 chooser.setDialogTitle("Open Octopus project ...");
397                 chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
398                 chooser.setFileFilter(
399                     (javax
400
JavaDoc                        .swing
401                         .filechooser
402                         .FileFilter) new OctopusFileFilter(OctopusFileFilter
403                         .OPF));
404                 chooser.setAcceptAllFileFilterUsed(false);
405
406                 chooser.setApproveButtonText("Open");
407                 int v = chooser.showOpenDialog(desktop);
408
409                 switch (v) {
410                     case JFileChooser.APPROVE_OPTION :
411                         if (chooser.getSelectedFile() != null) {
412                             openProject(chooser.getSelectedFile());
413                         }
414                         break;
415                     case JFileChooser.CANCEL_OPTION :
416                     case JFileChooser.ERROR_OPTION :
417                         chooser.removeAll();
418                         chooser = null;
419                         current = null;
420
421                 }
422
423             } catch (Exception JavaDoc ex) {
424                 String JavaDoc message =
425                     "Error while creating action for OpenOctopusProject menu item. Message :"
426                         + ex.getMessage();
427                 JOptionPane.showMessageDialog(desktop, message + "\n", "Error", 0);
428             }
429         }
430             
431             private void openProject(File JavaDoc projectFile) throws Exception JavaDoc {
432                 OctopusProperties properties = new OctopusProperties();
433                 InputStream JavaDoc is=new FileInputStream JavaDoc(projectFile);
434                 properties.load(is);
435                 String JavaDoc name = properties.getOctopusProperty("ProjectName");
436                 if (name == null || name.trim().equals(""))
437                                     name = DEFAULT_PROJECT_NAME+defaultProjectNameCounter++;
438                 OctopusProjectFrame octopusProject = createOctopusProjectFrame(name);
439                 confJarStructure = properties.getOctopusProperty("Generator.ConfJarStructure");
440                 OctopusGeneratorData generatorData = new OctopusGeneratorData(confJarStructure);
441                 setGeneratorData(properties,generatorData);
442                 
443                 octopusProject.getGeneratorPanel().setOctopusGeneratorInit(
444                     generatorData,
445                     confJarStructure);
446                 //set data
447
OctopusLoaderData loaderData = new OctopusLoaderData();
448                 setLoaderData(properties,loaderData);
449                                 
450                 
451                 octopusProject.getLoaderPanel().setOctopusLoaderInit(
452                     loaderData,
453                     null,
454                     confJarStructure);
455                 
456                 desktop.add(octopusProject);
457                 octopusProject.setVisible(true);
458                 octopusProject.requestFocus();
459             }
460     }
461
462     private class LnFActionMetal extends AbstractAction JavaDoc {
463
464         public LnFActionMetal() {
465
466             putValue(NAME, "Metal Look&Feel");
467             putValue(
468                 ACCELERATOR_KEY,
469                 KeyStroke.getKeyStroke('M', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
470             putValue(SHORT_DESCRIPTION, "Metal Look & Feel");
471             putValue(LONG_DESCRIPTION, "Set Metal Look & Feel Model");
472             putValue(MNEMONIC_KEY, new Integer JavaDoc('M'));
473         }
474
475         public void actionPerformed(ActionEvent JavaDoc e) {
476             LnFListener lnf = new LnFListener(wizardFrame);
477             lnf.actionPerformed(e);
478         }
479     }
480
481     private class LnFActionMotif extends AbstractAction JavaDoc {
482
483         public LnFActionMotif() {
484
485             putValue(NAME, "Motif Look&Feel");
486             putValue(
487                 ACCELERATOR_KEY,
488                 KeyStroke.getKeyStroke('F', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
489             putValue(SHORT_DESCRIPTION, "Motif Look & Feel");
490             putValue(LONG_DESCRIPTION, "Set Motif Look & Feel Model");
491             putValue(MNEMONIC_KEY, new Integer JavaDoc('F'));
492         }
493
494         public void actionPerformed(ActionEvent JavaDoc e) {
495             LnFListener lnf = new LnFListener(wizardFrame);
496             lnf.actionPerformed(e);
497         }
498     }
499
500     private class LnFActionWindows extends AbstractAction JavaDoc {
501
502         public LnFActionWindows() {
503
504             putValue(NAME, "Windows Look&Feel");
505             putValue(
506                 ACCELERATOR_KEY,
507                 KeyStroke.getKeyStroke('W', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
508             putValue(SHORT_DESCRIPTION, "Windows Look & Feel");
509             putValue(LONG_DESCRIPTION, "Set Windows Look & Feel Model");
510             putValue(MNEMONIC_KEY, new Integer JavaDoc('W'));
511         }
512
513         public void actionPerformed(ActionEvent JavaDoc e) {
514             LnFListener lnf = new LnFListener(wizardFrame);
515             lnf.actionPerformed(e);
516         }
517     }
518
519     private class LnFActionJava extends AbstractAction JavaDoc {
520
521         public LnFActionJava() {
522
523             putValue(NAME, "Java Look&Feel");
524             putValue(
525                 ACCELERATOR_KEY,
526                 KeyStroke.getKeyStroke('J', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
527             putValue(SHORT_DESCRIPTION, "Java Look & Feel");
528             putValue(LONG_DESCRIPTION, "Set Java Look & Feel Model");
529             putValue(MNEMONIC_KEY, new Integer JavaDoc('J'));
530         }
531
532         public void actionPerformed(ActionEvent JavaDoc e) {
533             LnFListener lnf = new LnFListener(wizardFrame);
534             lnf.actionPerformed(e);
535         }
536     }
537
538     class PopupListener extends MouseAdapter JavaDoc {
539         JPopupMenu JavaDoc popup;
540
541         PopupListener(JPopupMenu JavaDoc popupMenu) {
542             popup = popupMenu;
543         }
544
545         public void mousePressed(MouseEvent JavaDoc e) {
546             showPopup(e);
547         }
548
549         public void mouseReleased(MouseEvent JavaDoc e) {
550             showPopup(e);
551         }
552
553         private void showPopup(MouseEvent JavaDoc e) {
554             if (e.isPopupTrigger()) {
555                 popup.show(e.getComponent(), e.getX(), e.getY());
556             }
557         }
558     }
559
560     private class OctopusHelpAction extends AbstractAction JavaDoc {
561
562         /**
563          * Action which creates new help frame
564          */

565         public OctopusHelpAction(String JavaDoc label) {
566             putValue(NAME, label);
567             putValue(
568                 SMALL_ICON,
569                 new ImageIcon JavaDoc(
570                     getClass().getClassLoader().getResource(
571                         "org/webdocwf/util/loader/" + "wizard/images/Help16.gif")));
572             putValue(SHORT_DESCRIPTION, "Help for running the program");
573             putValue(LONG_DESCRIPTION, "Help for running the program");
574             putValue(
575                 ACCELERATOR_KEY,
576                 KeyStroke.getKeyStroke('H', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
577             putValue(MNEMONIC_KEY, new Integer JavaDoc('H'));
578         }
579
580         /**
581          * Creating event for new windows help frame
582          * @param e is creating events
583          */

584         public void actionPerformed(ActionEvent JavaDoc e) {
585             try {
586                 OctopusGeneratorHelpFrame helpFrame = new OctopusGeneratorHelpFrame();
587                 helpFrame.setIconImage(
588                     new ImageIcon JavaDoc(
589                         getClass().getClassLoader().getResource(
590                             "org/webdocwf/util/loader/" + "wizard/images/Enhydra16.gif"))
591                         .getImage());
592                 helpFrame.setVisible(true);
593             } catch (Exception JavaDoc ex) {
594                 String JavaDoc message =
595                     "Error while creating action for OctopusHelp menu item. Message :"
596                         + ex.getMessage();
597                 JOptionPane.showMessageDialog(desktop, message + "\n", "Error", 0);
598                 System.exit(0);
599             }
600         }
601     }
602
603     private OctopusAboutFrame createOctopusAboutFrame() {
604         OctopusAboutFrame frame = new OctopusAboutFrame(this.desktop);
605         setDefaultCloseOperation(DISPOSE_ON_CLOSE);
606         return frame;
607     }
608
609     private class OctopusAboutAction extends AbstractAction JavaDoc {
610         /**
611          * Action which creates new about frame
612          */

613         public OctopusAboutAction() {
614             putValue(NAME, "About");
615             putValue(
616                 SMALL_ICON,
617                 new ImageIcon JavaDoc(
618                     getClass().getClassLoader().getResource(
619                         "org/webdocwf/util/loader/" + "wizard/images/About16.gif")));
620             putValue(SHORT_DESCRIPTION, "About the program");
621             putValue(LONG_DESCRIPTION, "About the program");
622             putValue(
623                 ACCELERATOR_KEY,
624                 KeyStroke.getKeyStroke('A', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
625             putValue(MNEMONIC_KEY, new Integer JavaDoc('A'));
626         }
627
628         /**
629          * Creating event for new windows about frame
630          * @param e is creating events
631          */

632         public void actionPerformed(ActionEvent JavaDoc e) {
633             try {
634                 OctopusAboutFrame aboutFrame = createOctopusAboutFrame();
635                 // aboutFrame.setIconImage(new ImageIcon(getClass().getClassLoader().getResource("org/webdocwf/util/loader/"+
636
// "wizard/images/Enhydra16.gif")).getImage());
637
desktop.add(aboutFrame);
638                 aboutFrame.setVisible(true);
639
640             } catch (Exception JavaDoc ex) {
641                 String JavaDoc message =
642                     "Error while creating action for OctopusAbout menu item. Message :"
643                         + ex.getMessage();
644                 JOptionPane.showMessageDialog(desktop, message + "\n", "Error", 0);
645                 System.exit(0);
646             }
647         }
648     }
649
650     private void setLoaderData(OctopusProperties properties, OctopusLoaderData loaderData) throws Exception JavaDoc {
651         try {
652             loaderData.setAdditionalPaths(properties.getOctopusProperty("Loader.AdditionalPaths"));
653             loaderData.setCommitCount(properties.getOctopusProperty("Loader.CommitCount"));
654             loaderData.setConfJarStructure(properties.getOctopusProperty("Loader.ConfJarStructure"));
655             loaderData.setIncludeTables(properties.getOctopusProperty("Loader.IncludeTables"));
656             loaderData.setLogFileDir(properties.getOctopusProperty("Loader.LogFileDir"));
657             loaderData.setLogFileName(properties.getOctopusProperty("Loader.LogFileName"));
658             loaderData.setLogMode(properties.getOctopusProperty("Loader.LogMode"));
659             loaderData.setOnErrorCon(properties.getOctopusProperty("Loader.ErrorConntinue"));
660             loaderData.setPathToXml(properties.getOctopusProperty("Loader.PathToXml"));
661             loaderData.setRestartIndicator(properties.getOctopusProperty("Loader.RestartIndicator"));
662             loaderData.setReturnCode(properties.getOctopusProperty("Loader.ReturnCode"));
663             loaderData.setUserId(properties.getOctopusProperty("Loader.UserId"));
664             loaderData.setVariables(properties.getOctopusProperty("Loader.Variables"));
665             loaderData.setVendorConf(properties.getOctopusProperty("Loader.VendorConf"));
666         }catch(Exception JavaDoc e) {
667             throw e;
668         }
669     }
670
671     private void setGeneratorData(OctopusProperties properties, OctopusGeneratorData generatorData) throws Exception JavaDoc {
672         try {
673             generatorData.setAdditionalPaths(properties.getOctopusProperty("Generator.AdditionalPaths"));
674             generatorData.setConfJarStructure(properties.getOctopusProperty("Generator.ConfJarStructure"));
675             generatorData.setDomlGenerate(properties.getOctopusProperty("Generator.DomlGenerate"));
676             generatorData.setDomlPath(properties.getOctopusProperty("Generator.DomlPath"));
677             generatorData.setFullMode(properties.getOctopusProperty("Generator.FullMode"));
678             generatorData.setGeneratorOutput(properties.getOctopusProperty("Generator.GeneratorOutput"));
679             generatorData.setIncludeTableList(properties.getOctopusProperty("Generator.IncludeTableList"));
680             generatorData.setPackageName(properties.getOctopusProperty("Generator.PackageName"));
681             generatorData.setSourceDatabase(properties.getOctopusProperty("Generator.SourceDatabase"));
682             generatorData.setSourceDriverName(properties.getOctopusProperty("Generator.SourceDriverName"));
683             generatorData.setSourcePassword(properties.getOctopusProperty("Generator.SourcePassword"));
684             generatorData.setSourceType(properties.getOctopusProperty("Generator.SourceType"));
685             generatorData.setSourceUser(properties.getOctopusProperty("Generator.SourceUser"));
686             generatorData.setSqlGenerate(properties.getOctopusProperty("Generator.SqlGenerate"));
687             generatorData.setSqlStmtCreateFK(properties.getOctopusProperty("Generator.SqlStmtCreateFK"));
688             generatorData.setSqlStmtCreateIndex(properties.getOctopusProperty("Generator.SqlStmtCreateIndex"));
689             generatorData.setSqlStmtCreatePK(properties.getOctopusProperty("Generator.SqlStmtCreatePK"));
690             generatorData.setSqlStmtCreateTable(properties.getOctopusProperty("Generator.SqlStmtCreateTable"));
691             generatorData.setSqlStmtDropIntegrity(properties.getOctopusProperty("Generator.SqlStmtDropIntegrity"));
692             generatorData.setSqlStmtDropTable(properties.getOctopusProperty("Generator.SqlStmtDropTable"));
693             generatorData.setSqlStmtForAllVendors(properties.getOctopusProperty("Generator.SqlStmtForAllVendors"));
694             generatorData.setTargetDatabase(properties.getOctopusProperty("Generator.TargetDatabase"));
695             generatorData.setTargetDriverName(properties.getOctopusProperty("Generator.TargetDriverName"));
696             generatorData.setTargetPassword(properties.getOctopusProperty("Generator.TargetPassword"));
697             generatorData.setTargetType(properties.getOctopusProperty("Generator.TargetType"));
698             generatorData.setTargetUser(properties.getOctopusProperty("Generator.TargetUser"));
699             generatorData.setValueMode(properties.getOctopusProperty("Generator.ValueMode"));
700             generatorData.setXmlGenerate(properties.getOctopusProperty("Generator.XmlGenerate"));
701             
702             generatorData.setLogMode(properties.getOctopusProperty("Generator.LogMode"));
703             generatorData.setLogFileDir(properties.getOctopusProperty("Generator.LogFileDir"));
704             generatorData.setLogFileName(properties.getOctopusProperty("Generator.LogFileName"));
705         }catch(Exception JavaDoc e) {
706             throw e;
707         }
708     }
709
710
711 }
Popular Tags