KickJava   Java API By Example, From Geeks To Geeks.

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


1 package org.webdocwf.util.loader.wizard;
2
3 import java.awt.*;
4 import java.awt.event.*;
5 import javax.swing.*;
6 import javax.swing.border.*;
7 import java.io.*;
8 import java.util.*;
9
10 public class OctopusLoaderPanel
11     extends JPanel {
12
13   private static final String JavaDoc LOG_MODE = " Log mode",
14       RESTART_INDICATOR = " Restart indicator",
15       USER_ID = " User Id",
16       VARIABLES = " Variables",
17       LOG_FILE_DIRECTORY = " Log file directory",
18       LOG_FILE_NAME = " Log file name",
19       VENDOR_CONF_FILE = " Specific vendor conf file",
20       ON_ERRORCONTINUE = " On error continue",
21       ADDITIONAL_CLASSPATH = " Aditional classpath",
22       COMMIT_COUNT = " Comit count",
23       RETURN_CODE = " Return code",
24       PATH_TO_XML_FILE = " Path to loaderJob.olj file",
25       INCLUDE_TABLES = " Include List",
26       PATH_TO_CONF_JAR = " Path to conf files in jar";
27
28   //dimensions
29
// private static Dimension bigButton = new Dimension(110, 25);
30
// private static Dimension smallComponent = new Dimension(150, 20);
31
// private static Dimension bigComponent = new Dimension(400, 20);
32
// private static Dimension veryBigComponent = new Dimension(650, 20);
33
// private static Dimension veryBigPlusButton = new Dimension(630, 20);
34
// private static Dimension panelComponenet = new Dimension(720, 40);
35

36   JSplitPane main;
37
38   Border loweredBorder = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED);
39   Border raisedBorder = BorderFactory.createEtchedBorder(EtchedBorder.RAISED);
40   Border bevelBorder = BorderFactory.createLoweredBevelBorder();
41
42 // private OctopusProjectFrame parent;
43
private JPanel commonPanel;
44   private OctopusLoaderData initData;
45   private HashMap fields;
46   private JTextArea traceArea;
47   private JTextField additionalPath;
48
49   public OctopusLoaderPanel() {
50
51 // this.parent = parent;
52
fields = new HashMap();
53     //generatorOptions
54
// JPanel loaderOptionsUp = new JPanel();
55
// JPanel loaderOptionsDown = new JPanel();
56

57     //generator input data
58
JTabbedPane octopusLoaderData = new JTabbedPane();
59     commonPanel = new JPanel();
60     commonPanel.setLayout(new BoxLayout(commonPanel, BoxLayout.Y_AXIS));
61     octopusLoaderData.addTab("Input Parameters", commonPanel);
62
63 // loaderOptionsUp.setLayout(new BoxLayout(loaderOptionsUp, BoxLayout.Y_AXIS));
64
// loaderOptionsUp.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED));
65
// JButton help = createOctopusButton("Help", bigButton);
66
// help.setAction(new OctopusHelpAction());
67
// loaderOptionsUp.add(help);
68

69     //generatorOptionsDown panel
70
// loaderOptionsDown.setLayout(new BoxLayout(loaderOptionsDown, BoxLayout.Y_AXIS));
71
// loaderOptionsDown.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED));
72
// JButton start = createOctopusButton("Start", bigButton);
73
// start.setAction(new StartOctopusLoader());
74
// JButton stop = createOctopusButton("Stop", bigButton);
75
// stop.setAction(new StopOctopusLoader());
76
// JButton save = createOctopusButton("Save", bigButton);
77
// save.setAction(new SaveProjectAction());
78
// loaderOptionsDown.add(Box.createRigidArea(new Dimension(0,5)));
79
// loaderOptionsDown.add(start);
80
// loaderOptionsDown.add(Box.createRigidArea(new Dimension(0,5)));
81
// loaderOptionsDown.add(stop);
82
// loaderOptionsDown.add(Box.createRigidArea(new Dimension(0,5)));
83
// loaderOptionsDown.add(save);
84
// loaderOptionsDown.add(Box.createRigidArea(new Dimension(0,15)));
85
// loaderOptionsDown.add(help);
86

87     //generatorOptions
88
// JSplitPane generatorOptions = new JSplitPane(JSplitPane.VERTICAL_SPLIT, true,
89
// loaderOptionsUp, loaderOptionsDown);
90
// generatorOptions.setOneTouchExpandable(true);
91
// generatorOptions.setDividerLocation(0);
92

93     //log mode
94
JLabel strLogMode = OctopusProjectFrame.createOctopusLabel(LOG_MODE, OctopusGeneratorPanel.smallComponent);
95     JComboBox logMode = OctopusProjectFrame.createOctopusCombobox(LOG_MODE, OctopusGeneratorPanel.veryBigComponent);
96     //restart indicator
97
JLabel strRestartIndicator = OctopusProjectFrame.createOctopusLabel(RESTART_INDICATOR, OctopusGeneratorPanel.smallComponent);
98     JTextField restartIndicator = OctopusProjectFrame.createOctopusTextField(RESTART_INDICATOR, OctopusGeneratorPanel.veryBigComponent);
99     //user id
100
JLabel strUserId = OctopusProjectFrame.createOctopusLabel(USER_ID, OctopusGeneratorPanel.smallComponent);
101     JTextField userId = OctopusProjectFrame.createOctopusTextField(USER_ID, OctopusGeneratorPanel.veryBigComponent);
102     //variables
103
JLabel strVariables = OctopusProjectFrame.createOctopusLabel(VARIABLES, OctopusGeneratorPanel.smallComponent);
104     JTextField variables = OctopusProjectFrame.createOctopusTextField(VARIABLES, OctopusGeneratorPanel.veryBigComponent);
105     //log file directory
106
JLabel strLogFileDir = OctopusProjectFrame.createOctopusLabel(LOG_FILE_DIRECTORY, OctopusGeneratorPanel.smallComponent);
107     JTextField logFileDir = OctopusProjectFrame.createOctopusTextField(LOG_FILE_DIRECTORY, OctopusGeneratorPanel.veryBigPlusButton);
108     JButton logDirButton = OctopusProjectFrame.createOctopusButton("", new Dimension(20, 20));
109     logDirButton.setAction(new BrowseAction_LD());
110     //log file name
111
JLabel strLogFileName = OctopusProjectFrame.createOctopusLabel(LOG_FILE_NAME, OctopusGeneratorPanel.smallComponent);
112     JTextField logFileName = OctopusProjectFrame.createOctopusTextField(LOG_FILE_NAME, OctopusGeneratorPanel.veryBigComponent);
113     //specific vendor conf file
114
JLabel strSpecVendorConf = OctopusProjectFrame.createOctopusLabel(VENDOR_CONF_FILE, OctopusGeneratorPanel.smallComponent);
115     JTextField specVendorConf = OctopusProjectFrame.createOctopusTextField(VENDOR_CONF_FILE, OctopusGeneratorPanel.veryBigPlusButton);
116     JButton specVendorButton = OctopusProjectFrame.createOctopusButton("", new Dimension(20, 20));
117     specVendorButton.setAction(new BrowseAction_XML());
118     //on error continue
119
JLabel strOnError = OctopusProjectFrame.createOctopusLabel(ON_ERRORCONTINUE, OctopusGeneratorPanel.smallComponent);
120     JTextField onError = OctopusProjectFrame.createOctopusTextField(ON_ERRORCONTINUE, OctopusGeneratorPanel.veryBigComponent);
121     //commit count
122
JLabel strCommitCount = OctopusProjectFrame.createOctopusLabel(COMMIT_COUNT, OctopusGeneratorPanel.smallComponent);
123     JTextField commitCount = OctopusProjectFrame.createOctopusTextField(COMMIT_COUNT, OctopusGeneratorPanel.veryBigComponent);
124     //return code
125
JLabel strReturnCode = OctopusProjectFrame.createOctopusLabel(RETURN_CODE, OctopusGeneratorPanel.smallComponent);
126     JTextField returnCode = OctopusProjectFrame.createOctopusTextField(RETURN_CODE, OctopusGeneratorPanel.veryBigComponent);
127     //pathe to olj file
128
JLabel strPathToOlj = OctopusProjectFrame.createOctopusLabel(PATH_TO_XML_FILE, OctopusGeneratorPanel.smallComponent);
129     JTextField pathToOlj = OctopusProjectFrame.createOctopusTextField(PATH_TO_XML_FILE, OctopusGeneratorPanel.veryBigPlusButton);
130     JButton pathToOljButton = OctopusProjectFrame.createOctopusButton("", new Dimension(20, 20));
131     pathToOljButton.setAction(new BrowseAction_OLJ());
132     //include list
133
JLabel strIncludeList = OctopusProjectFrame.createOctopusLabel(INCLUDE_TABLES, OctopusGeneratorPanel.smallComponent);
134     JTextField includeList = OctopusProjectFrame.createOctopusTextField(INCLUDE_TABLES, OctopusGeneratorPanel.veryBigComponent);
135     //path to conf files in jar file
136
JLabel strPathToConf = OctopusProjectFrame.createOctopusLabel(PATH_TO_CONF_JAR, OctopusGeneratorPanel.smallComponent);
137     JTextField pathToConf = OctopusProjectFrame.createOctopusTextField(PATH_TO_CONF_JAR, OctopusGeneratorPanel.veryBigComponent);
138     //additional classpaths
139
JLabel strAdditionalPath = OctopusProjectFrame.createOctopusLabel(ADDITIONAL_CLASSPATH, OctopusGeneratorPanel.smallComponent);
140      additionalPath = OctopusProjectFrame.createOctopusTextField(ADDITIONAL_CLASSPATH, OctopusGeneratorPanel.veryBigPlusButton);
141      JButton additionalPathButton = OctopusProjectFrame.createOctopusButton("", new Dimension(20, 20));
142      additionalPathButton.setAction(new BrowseAction_AC());
143
144     JPanel inputParamPanelLabel = new JPanel();
145     inputParamPanelLabel.setLayout(new BoxLayout(inputParamPanelLabel, BoxLayout.Y_AXIS));
146     JPanel inputParamPanelField = new JPanel();
147     inputParamPanelField.setLayout(new BoxLayout(inputParamPanelField, BoxLayout.Y_AXIS));
148
149     commonPanel.add(Box.createRigidArea(new Dimension(0, 15)));
150     createRow(strLogMode, logMode, null);
151     fields.put(LOG_MODE, logMode);
152     createRow(strRestartIndicator, restartIndicator, null);
153     fields.put(RESTART_INDICATOR, restartIndicator);
154     createRow(strUserId, userId, null);
155     fields.put(USER_ID, userId);
156     createRow(strVariables, variables, null);
157     fields.put(VARIABLES, variables);
158     createRow(strLogFileDir, logFileDir, logDirButton);
159     fields.put(LOG_FILE_DIRECTORY, logFileDir);
160     createRow(strLogFileName, logFileName, null);
161     fields.put(LOG_FILE_NAME, logFileName);
162     createRow(strSpecVendorConf, specVendorConf, specVendorButton);
163     fields.put(VENDOR_CONF_FILE, specVendorConf);
164     createRow(strOnError, onError, null);
165     fields.put(ON_ERRORCONTINUE, onError);
166     createRow(strCommitCount, commitCount, null);
167     fields.put(COMMIT_COUNT, commitCount);
168     createRow(strReturnCode, returnCode, null);
169     fields.put(RETURN_CODE, returnCode);
170     createRow(strPathToOlj, pathToOlj, pathToOljButton);
171     fields.put(PATH_TO_XML_FILE, pathToOlj);
172     createRow(strIncludeList, includeList, null);
173     fields.put(INCLUDE_TABLES, includeList);
174     createRow(strPathToConf, pathToConf, null);
175     fields.put(PATH_TO_CONF_JAR, pathToConf);
176      createRow(strAdditionalPath, additionalPath, additionalPathButton);
177      fields.put(ADDITIONAL_CLASSPATH, additionalPath);
178
179 // JSplitPane generatorInputData = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true,
180
// generatorOptions, octopusLoaderData);
181
// JSplitPane generatorInputData = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true,
182
// new JPanel(), octopusLoaderData);
183

184     // output panel
185
JPanel textAreaPanel = new JPanel();
186     textAreaPanel.setLayout(new BoxLayout(textAreaPanel, BoxLayout.X_AXIS));
187     JPanel areaOptionPanel = new JPanel();
188     areaOptionPanel.setLayout(new BoxLayout(areaOptionPanel, BoxLayout.Y_AXIS));
189     traceArea = new JTextArea(18, 130);
190     traceArea.setLineWrap(true);
191     traceArea.setEditable(false);
192     traceArea.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED));
193     JScrollPane scrollPane = new JScrollPane(traceArea,
194         ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
195         ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
196
197     scrollPane.setBorder(setTitleOfBorder("Log TDT Loader output ... ", loweredBorder));
198     JButton fullScreen = OctopusProjectFrame.createOctopusButton("Full Screen", new Dimension(25, 25));
199     fullScreen.setAction(new FullScreenAction());
200     JButton normalScreen = OctopusProjectFrame.createOctopusButton("Normal Screen", new Dimension(25, 25));
201     normalScreen.setAction(new NormalScreenAction());
202     JButton saveScreen = OctopusProjectFrame.createOctopusButton("Save Trace", new Dimension(25, 25));
203     saveScreen.setAction(new SaveTraceAction());
204     JButton clearTrace = OctopusProjectFrame.createOctopusButton("Clear Trace", new Dimension(25, 25));
205     clearTrace.setAction(new ClearTraceAction());
206      
207     areaOptionPanel.add(fullScreen);
208     areaOptionPanel.add(normalScreen);
209     areaOptionPanel.add(saveScreen);
210     areaOptionPanel.add(clearTrace);
211     areaOptionPanel.add(Box.createVerticalGlue());
212     areaOptionPanel.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED));
213
214 // JPanel areaOptionMainPanel = new JPanel(new BorderLayout());
215
// areaOptionMainPanel.add(areaOptionPanel, BorderLayout.PAGE_START);
216

217     textAreaPanel.add(areaOptionPanel);
218     textAreaPanel.add(scrollPane);
219 // main = new JSplitPane(JSplitPane.VERTICAL_SPLIT, true, generatorInputData,
220
// textAreaPanel);
221
main = new JSplitPane(JSplitPane.VERTICAL_SPLIT, true, octopusLoaderData,
222             textAreaPanel);
223     main.setOneTouchExpandable(true);
224 // main.setDividerLocation(450);
225

226 // Container container = getContentPane();
227
setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
228     add(main);
229     setBounds(0, 0, 970, 480);
230   }
231
232   public JTextArea getTraceArea() {
233     return this.traceArea;
234   }
235
236   private void createRow(JLabel label, JComponent component, JButton button) {
237
238     JPanel jp = new JPanel();
239     jp.setLayout(new BoxLayout(jp, BoxLayout.X_AXIS));
240
241     jp.add(label);
242     jp.add(component);
243     if(button != null)
244       jp.add(button);
245     jp.add(Box.createHorizontalGlue());
246
247     commonPanel.add(jp);
248   }
249
250   private Border setTitleOfBorder(String JavaDoc title, Border border) {
251     Border inb = BorderFactory.createTitledBorder(border, title);
252     return inb;
253   }
254
255 // private JButton createOctopusButton(String componentName, Dimension dimension) {
256
//
257
// JButton button = new JButton();
258
// if(!componentName.equalsIgnoreCase(""))
259
// button.setText(componentName);
260
//
261
// button.setAlignmentX(Component.LEFT_ALIGNMENT);
262
// button.setAlignmentY(Component.CENTER_ALIGNMENT);
263
// button.setMinimumSize(new Dimension(dimension));
264
// button.setMaximumSize(new Dimension(dimension));
265
// button.setPreferredSize(new Dimension(dimension));
266
//
267
// return button;
268
// }
269
//
270
// private JComboBox createOctopusCombobox(String componentName, Dimension dimension) {
271
//
272
// JComboBox comboBox = new JComboBox();
273
// comboBox.setName(componentName);
274
// comboBox.setAlignmentX(Component.LEFT_ALIGNMENT);
275
// comboBox.setAlignmentY(Component.CENTER_ALIGNMENT);
276
// comboBox.setMinimumSize(new Dimension(dimension));
277
// comboBox.setMaximumSize(new Dimension(dimension));
278
// comboBox.setPreferredSize(new Dimension(dimension));
279
//
280
// return comboBox;
281
// }
282
//
283
// private JLabel createOctopusLabel(String componentName, Dimension dimension) {
284
//
285
// JLabel label = new JLabel();
286
// label.setText(componentName);
287
// label.setAlignmentX(Component.LEFT_ALIGNMENT);
288
// label.setAlignmentY(Component.CENTER_ALIGNMENT);
289
// label.setMinimumSize(new Dimension(dimension));
290
// label.setMaximumSize(new Dimension(dimension));
291
// label.setPreferredSize(new Dimension(dimension));
292
//
293
// return label;
294
// }
295
//
296
// private JTextField createOctopusTextField(String componentName, Dimension dimension) {
297
//
298
// JTextField textField = new JTextField();
299
// textField.setName(componentName);
300
// textField.setAlignmentX(Component.LEFT_ALIGNMENT);
301
// textField.setAlignmentY(Component.CENTER_ALIGNMENT);
302
// textField.setMinimumSize(new Dimension(dimension));
303
// textField.setMaximumSize(new Dimension(dimension));
304
// textField.setPreferredSize(new Dimension(dimension));
305
//
306
// return textField;
307
// }
308

309   public void setOctopusLoaderInit(OctopusLoaderData initData, String JavaDoc xmlFile,
310       String JavaDoc confJarStructure) {
311     this.initData = initData;
312     setField(LOG_MODE, initData.getLogMode(), "box");
313     setField(LOG_FILE_DIRECTORY, initData.getLogFileDir(), "textfield");
314     setField(LOG_FILE_NAME, initData.getLogFileName(), "textfield");
315     setField(USER_ID, initData.getUserId(), "textfield");
316     setField(VARIABLES, initData.getVariables(), "textfield");
317     setField(RESTART_INDICATOR, initData.getRestartIndicator(), "textfield");
318     setField(VENDOR_CONF_FILE, initData.getVendorConf(), "textfield");
319     setField(ON_ERRORCONTINUE, initData.getOnErrorCon(), "textfield");
320     setField(ADDITIONAL_CLASSPATH, initData.getAdditionalPaths(), "textfield");
321     setField(COMMIT_COUNT, initData.getCommitCount(), "textfield");
322     setField(RETURN_CODE, initData.getReturnCode(), "textfield");
323     if(xmlFile != null)
324       setField(PATH_TO_XML_FILE, xmlFile, "textfield");
325     else
326       setField(PATH_TO_XML_FILE, initData.getPathToXml(), "textfield");
327
328     setField(INCLUDE_TABLES, initData.getIncludeTables(), "textfield");
329     if(confJarStructure != null)
330       setField(PATH_TO_CONF_JAR, confJarStructure, "textfield");
331     else
332       setField(PATH_TO_CONF_JAR, initData.getConfJarStructure(), "textfield");
333   }
334
335   public OctopusLoaderData getOctopusLoaderInit() throws Exception JavaDoc {
336      
337     initData.setLogMode(getField(LOG_MODE, "box"));
338     initData.setLogFileName(getField(LOG_FILE_NAME, "label"));
339     initData.setLogFileDir(getField(LOG_FILE_DIRECTORY, "label"));
340     initData.setRestartIndicator(getField(RESTART_INDICATOR, "label"));
341     initData.setUserId(getField(USER_ID, "label"));
342     initData.setVariables(getField(VARIABLES, "label"));
343     initData.setVendorConf(getField(VENDOR_CONF_FILE, "label"));
344     initData.setOnErrorCon(getField(ON_ERRORCONTINUE, "label"));
345     initData.setAdditionalPaths(getField(ADDITIONAL_CLASSPATH, "label"));
346     initData.setCommitCount(getField(COMMIT_COUNT, "label"));
347     initData.setReturnCode(getField(RETURN_CODE, "label"));
348     initData.setPathToXml(getField(PATH_TO_XML_FILE, "label"));
349     initData.setIncludeTables(getField(INCLUDE_TABLES, "label"));
350     initData.setConfJarStructure(getField(PATH_TO_CONF_JAR, "label"));
351
352     return initData;
353   }
354
355   private void setField(String JavaDoc fieldName, String JavaDoc value, String JavaDoc type) {
356     if(type.equalsIgnoreCase("textfield")) {
357       JTextField field = (JTextField)fields.get(fieldName);
358       field.setText(value);
359     } else {
360       JComboBox field = (JComboBox)fields.get(fieldName);
361         boolean setted = false;
362       for(int i = 0; i < OctopusLoaderData.getLogModes().length; i++) {
363           if( field.getItemCount() != OctopusLoaderData.getLogModes().length )
364             field.addItem(OctopusLoaderData.getLogModes()[i]);
365         if( value.equalsIgnoreCase(OctopusLoaderData.getLogModes()[i]))
366             field.setSelectedIndex(i);
367       }
368         if(!setted)
369                 field.setSelectedIndex(1);
370     }
371   }
372
373   private String JavaDoc getField(String JavaDoc fieldName, String JavaDoc type) {
374     if(type.equalsIgnoreCase("label")) {
375       JTextField field = (JTextField)fields.get(fieldName);
376       return field.getText().trim();
377     } else {
378       JComboBox field = (JComboBox)fields.get(fieldName);
379       return field.getSelectedItem().toString();
380     }
381   }
382
383   private class FullScreenAction
384       extends AbstractAction {
385
386     /**
387      * This method starts the LoaderGenerator application
388      */

389     public FullScreenAction() {
390
391       putValue(SMALL_ICON,
392           new ImageIcon(getClass().getClassLoader().getResource("org/webdocwf/util/loader/" +
393           "wizard/images/Host16.gif")));
394       putValue(SHORT_DESCRIPTION, "Full Screen");
395       putValue(LONG_DESCRIPTION, "Set Trace to Full Screen");
396       putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('F',
397           Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
398       putValue(MNEMONIC_KEY, new Integer JavaDoc('F'));
399     }
400
401     /**
402      * This method check if the action is performed (event key pressed)
403      * @param e is event
404      */

405     public void actionPerformed(ActionEvent e) {
406       main.setDividerLocation(0);
407     }
408   }
409
410   private class NormalScreenAction
411       extends AbstractAction {
412
413     /**
414      * This method starts the LoaderGenerator application
415      */

416     public NormalScreenAction() {
417
418       putValue(SMALL_ICON,
419           new ImageIcon(getClass().getClassLoader().getResource("org/webdocwf/util/loader/" +
420           "wizard/images/Unhost16.gif")));
421       putValue(SHORT_DESCRIPTION, "Normal Screen");
422       putValue(LONG_DESCRIPTION, "Back to normal screen");
423       putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('N',
424           Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
425       putValue(MNEMONIC_KEY, new Integer JavaDoc('N'));
426     }
427
428     /**
429      * This method check if the action is performed (event key pressed)
430      * @param e is event
431      */

432     public void actionPerformed(ActionEvent e) {
433       main.setDividerLocation(330);
434     }
435   }
436
437   private class SaveTraceAction
438       extends AbstractAction {
439
440     /**
441      * This method starts the LoaderGenerator application
442      */

443     public SaveTraceAction() {
444
445       putValue(SMALL_ICON,
446           new ImageIcon(getClass().getClassLoader().getResource("org/webdocwf/util/loader/" +
447           "wizard/images/Save16.gif")));
448       putValue(SHORT_DESCRIPTION, "Save Trace");
449       putValue(LONG_DESCRIPTION, "Save Trace to file");
450       putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('S',
451           Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
452       putValue(MNEMONIC_KEY, new Integer JavaDoc('S'));
453     }
454
455     /**
456      * This method check if the action is performed (event key pressed)
457      * @param e is event
458      */

459     public void actionPerformed(ActionEvent e) {
460       JFileChooser fc = new JFileChooser();
461       fc.setDialogTitle("Save TDT log ...");
462       int returnVal = fc.showSaveDialog(null);
463       if(returnVal == JFileChooser.APPROVE_OPTION) {
464         File file = fc.getSelectedFile();
465         String JavaDoc text = traceArea.getText();
466         try {
467           Writer out = new BufferedWriter(new FileWriter(file));
468           out.write(text);
469           out.close();
470         }
471         catch(Exception JavaDoc ex) {
472           ex.printStackTrace();
473         }
474
475       } else {
476       //do nothing
477
}
478     }
479   }
480
481   private class ClearTraceAction
482       extends AbstractAction {
483
484     /**
485      * This method starts the LoaderGenerator application
486      */

487     public ClearTraceAction() {
488
489       putValue(SMALL_ICON,
490           new ImageIcon(getClass().getClassLoader().getResource("org/webdocwf/util/loader/" +
491           "wizard/images/Delete16.gif")));
492       putValue(SHORT_DESCRIPTION, "Clear Trace");
493       putValue(LONG_DESCRIPTION, "Clear Trace");
494       putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('L',
495           Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
496       putValue(MNEMONIC_KEY, new Integer JavaDoc('L'));
497     }
498
499     /**
500      * This method check if the action is performed (event key pressed)
501      * @param e is event
502      */

503     public void actionPerformed(ActionEvent e) {
504       traceArea.setText("");
505     }
506   }
507
508   //additional paths
509
private class BrowseAction_AC
510       extends AbstractAction {
511
512     /**
513      * This method stop the LoaderGenerator application
514      */

515     public BrowseAction_AC() {
516       putValue(SMALL_ICON,
517           new ImageIcon(getClass().getClassLoader().
518           getResource("org/webdocwf/util/loader/" +
519           "wizard/images/Open16.gif")));
520       putValue(SHORT_DESCRIPTION, "Add .jar files");
521       putValue(LONG_DESCRIPTION, "Add .jar (jdbc) files to system classpath");
522       putValue(MNEMONIC_KEY, new Integer JavaDoc('B'));
523     }
524
525     /**
526      * This method check if the action is performed (event key pressed)
527      * @param e is event
528      */

529     public void actionPerformed(ActionEvent e) {
530       JFileChooser chooser = null;
531       File choice = null;
532       File current = new File(System.getProperty("user.dir"));
533       chooser = new JFileChooser(current);
534       chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
535       chooser.setFileFilter((javax.swing.filechooser.FileFilter JavaDoc)new JarFilter());
536       chooser.setDialogTitle("Select .jar file");
537       chooser.setAcceptAllFileFilterUsed(false);
538       String JavaDoc strFieldText = additionalPath.getText();
539 //
540
if(!strFieldText.equalsIgnoreCase(""))
541         strFieldText = strFieldText + ";";
542
543       chooser.setCurrentDirectory(new File(strFieldText));
544       chooser.setApproveButtonText("Open");
545       int v = chooser.showOpenDialog(null);
546
547       switch(v) {
548         case JFileChooser.APPROVE_OPTION:
549           if(chooser.getSelectedFile() != null) {
550             if(chooser.getSelectedFile().exists()) {
551               choice = chooser.getSelectedFile();
552             } else {
553               File parentFile = new File(chooser.getSelectedFile().getParent());
554               choice = parentFile;
555             }
556             additionalPath.setText(strFieldText + choice.getPath());
557           }
558           break;
559
560         case JFileChooser.CANCEL_OPTION:
561         case JFileChooser.ERROR_OPTION:
562
563           chooser.removeAll();
564           chooser = null;
565           current = null;
566
567       }
568     }
569   }
570
571
572
573   private class OctopusHelpAction
574       extends AbstractAction {
575
576     /**
577      * Action which creates new help frame
578      */

579     public OctopusHelpAction() {
580       putValue(NAME, "Help");
581       putValue(SMALL_ICON,
582           new ImageIcon(getClass().getClassLoader().getResource("org/webdocwf/util/loader/" +
583           "wizard/images/Help16.gif")));
584       putValue(SHORT_DESCRIPTION, "Help for running the program");
585       putValue(LONG_DESCRIPTION, "Help for running the program");
586       putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('H',
587           Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
588       putValue(MNEMONIC_KEY, new Integer JavaDoc('H'));
589     }
590
591     /**
592      * Creating event for new windows help frame
593      * @param e is creating events
594      */

595     public void actionPerformed(ActionEvent e) {
596       try {
597         OctopusGeneratorHelpFrame helpFrame = new OctopusGeneratorHelpFrame();
598         helpFrame.setIconImage(new ImageIcon(getClass().getClassLoader().getResource(
599             "org/webdocwf/util/loader/" +
600             "wizard/images/Enhydra16.gif")).getImage());
601         helpFrame.setVisible(true);
602       }
603       catch(Exception JavaDoc ex) {
604             String JavaDoc message = "Error while creating action for OctopusHelp button. Message : "+ex.getMessage();
605             JOptionPane.showMessageDialog(null, message + "\n", "Error", 0);
606             System.exit(0);
607       }
608     }
609   }
610
611
612   //log dir
613
private class BrowseAction_LD
614       extends AbstractAction {
615
616     /**
617      * This method stop the LoaderGenerator application
618      */

619     public BrowseAction_LD() {
620 // putValue(NAME, "browse");
621
putValue(SMALL_ICON,
622           new ImageIcon(getClass().getClassLoader().
623           getResource("org/webdocwf/util/loader/" +
624           "wizard/images/Open16.gif")));
625       putValue(SHORT_DESCRIPTION, "Browse for Log file directory");
626       putValue(LONG_DESCRIPTION, "Browse for Log file directory");
627       putValue(MNEMONIC_KEY, new Integer JavaDoc('B'));
628     }
629
630     /**
631      * This method check if the action is performed (event key pressed)
632      * @param e is event
633      */

634     public void actionPerformed(ActionEvent e) {
635       JFileChooser chooser = null;
636       File choice = null;
637       File current = new File(System.getProperty("user.dir"));
638       chooser = new JFileChooser(current);
639       chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
640       chooser.setFileFilter((javax.swing.filechooser.FileFilter JavaDoc)new DirectoryFilter());
641       chooser.setDialogTitle("Select Log File Directory");
642       chooser.setApproveButtonText("Open");
643       String JavaDoc strFieldText = "";
644
645       chooser.setCurrentDirectory(new File(strFieldText));
646       int v = chooser.showOpenDialog(null);
647 // parent.requestFocus();
648

649       switch(v) {
650         case JFileChooser.APPROVE_OPTION:
651           if(chooser.getSelectedFile() != null) {
652             if(chooser.getSelectedFile().exists()) {
653               choice = chooser.getSelectedFile();
654             } else {
655               File parentFile = new File(chooser.getSelectedFile().getParent());
656               choice = parentFile;
657             }
658             setField(LOG_FILE_DIRECTORY, choice.getPath(), "textfield");
659           }
660           break;
661
662         case JFileChooser.CANCEL_OPTION:
663         case JFileChooser.ERROR_OPTION:
664
665       }
666     }
667   }
668
669   private class BrowseAction_XML
670       extends AbstractAction {
671
672     /**
673      * This method stop the LoaderGenerator application
674      */

675     public BrowseAction_XML() {
676 // putValue(NAME, "browse");
677
putValue(SMALL_ICON,
678           new ImageIcon(getClass().getClassLoader().
679           getResource("org/webdocwf/util/loader/" +
680           "wizard/images/Open16.gif")));
681       putValue(SHORT_DESCRIPTION, "Browse for .xml file");
682       putValue(LONG_DESCRIPTION, "Browse for .xml file");
683       putValue(MNEMONIC_KEY, new Integer JavaDoc('B'));
684     }
685
686     /**
687      * This method check if the action is performed (event key pressed)
688      * @param e is event
689      */

690     public void actionPerformed(ActionEvent e) {
691       JFileChooser chooser = null;
692       File choice = null;
693       File current = new File(System.getProperty("user.dir"));
694       chooser = new JFileChooser(current);
695       chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
696       chooser.setFileFilter((javax.swing.filechooser.FileFilter JavaDoc)new XmlFilter());
697       chooser.setDialogTitle("Select .xml file");
698       chooser.setAcceptAllFileFilterUsed(false);
699       String JavaDoc strFieldText = "";
700
701       chooser.setCurrentDirectory(new File(strFieldText));
702       chooser.setApproveButtonText("Open");
703       int v = chooser.showOpenDialog(null);
704
705 // parent.requestFocus();
706
switch(v) {
707         case JFileChooser.APPROVE_OPTION:
708           if(chooser.getSelectedFile() != null) {
709             if(chooser.getSelectedFile().exists()) {
710               choice = chooser.getSelectedFile();
711             } else {
712               File parentFile = new File(chooser.getSelectedFile().getParent());
713               choice = parentFile;
714             }
715             setField(VENDOR_CONF_FILE, choice.getPath(), "textfield");
716           }
717           break;
718
719         case JFileChooser.CANCEL_OPTION:
720         case JFileChooser.ERROR_OPTION:
721
722           chooser.removeAll();
723           chooser = null;
724           current = null;
725       }
726     }
727   }
728
729   private class BrowseAction_OLJ
730       extends AbstractAction {
731
732     /**
733      * This method stop the LoaderGenerator application
734      */

735     public BrowseAction_OLJ() {
736 // putValue(NAME, "browse");
737
putValue(SMALL_ICON,
738           new ImageIcon(getClass().getClassLoader().
739           getResource("org/webdocwf/util/loader/" +
740           "wizard/images/Open16.gif")));
741       putValue(SHORT_DESCRIPTION, "Browse for LoaderJob.olj file");
742       putValue(LONG_DESCRIPTION, "Browse for LoaderJob.olj file");
743       putValue(MNEMONIC_KEY, new Integer JavaDoc('B'));
744     }
745
746     /**
747      * This method check if the action is performed (event key pressed)
748      * @param e is event
749      */

750     public void actionPerformed(ActionEvent e) {
751       JFileChooser chooser = null;
752       File choice = null;
753       File current = new File(System.getProperty("user.dir"));
754       chooser = new JFileChooser(current);
755       chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
756       chooser.setFileFilter((javax.swing.filechooser.FileFilter JavaDoc)new OctopusFileFilter());
757       chooser.setDialogTitle("Select .olj file");
758       chooser.setAcceptAllFileFilterUsed(false);
759       String JavaDoc strFieldText = "";
760
761       chooser.setCurrentDirectory(new File(strFieldText));
762       chooser.setApproveButtonText("Open");
763       int v = chooser.showOpenDialog(null);
764
765 // parent.requestFocus();
766
switch(v) {
767         case JFileChooser.APPROVE_OPTION:
768           if(chooser.getSelectedFile() != null) {
769             if(chooser.getSelectedFile().exists()) {
770               choice = chooser.getSelectedFile();
771             } else {
772               File parentFile = new File(chooser.getSelectedFile().getParent());
773               choice = parentFile;
774             }
775             setField(PATH_TO_XML_FILE, choice.getPath(), "textfield");
776           }
777           break;
778
779         case JFileChooser.CANCEL_OPTION:
780         case JFileChooser.ERROR_OPTION:
781
782           chooser.removeAll();
783           chooser = null;
784           current = null;
785
786       }
787     }
788   }
789
790 }
Popular Tags