001: package org.webdocwf.util.loader.wizard;
002:
003: import java.awt.*;
004: import java.awt.event.*;
005: import javax.swing.*;
006: import javax.swing.border.*;
007: import java.io.*;
008: import java.util.*;
009:
010: public class OctopusLoaderPanel extends JPanel {
011:
012: private static final String LOG_MODE = " Log mode",
013: RESTART_INDICATOR = " Restart indicator",
014: USER_ID = " User Id", VARIABLES = " Variables",
015: LOG_FILE_DIRECTORY = " Log file directory",
016: LOG_FILE_NAME = " Log file name",
017: VENDOR_CONF_FILE = " Specific vendor conf file",
018: ON_ERRORCONTINUE = " On error continue",
019: ADDITIONAL_CLASSPATH = " Aditional classpath",
020: COMMIT_COUNT = " Comit count",
021: RETURN_CODE = " Return code",
022: PATH_TO_XML_FILE = " Path to loaderJob.olj file",
023: INCLUDE_TABLES = " Include List",
024: PATH_TO_CONF_JAR = " Path to conf files in jar";
025:
026: //dimensions
027: // private static Dimension bigButton = new Dimension(110, 25);
028: // private static Dimension smallComponent = new Dimension(150, 20);
029: // private static Dimension bigComponent = new Dimension(400, 20);
030: // private static Dimension veryBigComponent = new Dimension(650, 20);
031: // private static Dimension veryBigPlusButton = new Dimension(630, 20);
032: // private static Dimension panelComponenet = new Dimension(720, 40);
033:
034: JSplitPane main;
035:
036: Border loweredBorder = BorderFactory
037: .createEtchedBorder(EtchedBorder.LOWERED);
038: Border raisedBorder = BorderFactory
039: .createEtchedBorder(EtchedBorder.RAISED);
040: Border bevelBorder = BorderFactory.createLoweredBevelBorder();
041:
042: // private OctopusProjectFrame parent;
043: private JPanel commonPanel;
044: private OctopusLoaderData initData;
045: private HashMap fields;
046: private JTextArea traceArea;
047: private JTextField additionalPath;
048:
049: public OctopusLoaderPanel() {
050:
051: // this.parent = parent;
052: fields = new HashMap();
053: //generatorOptions
054: // JPanel loaderOptionsUp = new JPanel();
055: // JPanel loaderOptionsDown = new JPanel();
056:
057: //generator input data
058: JTabbedPane octopusLoaderData = new JTabbedPane();
059: commonPanel = new JPanel();
060: commonPanel.setLayout(new BoxLayout(commonPanel,
061: BoxLayout.Y_AXIS));
062: octopusLoaderData.addTab("Input Parameters", commonPanel);
063:
064: // loaderOptionsUp.setLayout(new BoxLayout(loaderOptionsUp, BoxLayout.Y_AXIS));
065: // loaderOptionsUp.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED));
066: // JButton help = createOctopusButton("Help", bigButton);
067: // help.setAction(new OctopusHelpAction());
068: // loaderOptionsUp.add(help);
069:
070: //generatorOptionsDown panel
071: // loaderOptionsDown.setLayout(new BoxLayout(loaderOptionsDown, BoxLayout.Y_AXIS));
072: // loaderOptionsDown.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED));
073: // JButton start = createOctopusButton("Start", bigButton);
074: // start.setAction(new StartOctopusLoader());
075: // JButton stop = createOctopusButton("Stop", bigButton);
076: // stop.setAction(new StopOctopusLoader());
077: // JButton save = createOctopusButton("Save", bigButton);
078: // save.setAction(new SaveProjectAction());
079: // loaderOptionsDown.add(Box.createRigidArea(new Dimension(0,5)));
080: // loaderOptionsDown.add(start);
081: // loaderOptionsDown.add(Box.createRigidArea(new Dimension(0,5)));
082: // loaderOptionsDown.add(stop);
083: // loaderOptionsDown.add(Box.createRigidArea(new Dimension(0,5)));
084: // loaderOptionsDown.add(save);
085: // loaderOptionsDown.add(Box.createRigidArea(new Dimension(0,15)));
086: // loaderOptionsDown.add(help);
087:
088: //generatorOptions
089: // JSplitPane generatorOptions = new JSplitPane(JSplitPane.VERTICAL_SPLIT, true,
090: // loaderOptionsUp, loaderOptionsDown);
091: // generatorOptions.setOneTouchExpandable(true);
092: // generatorOptions.setDividerLocation(0);
093:
094: //log mode
095: JLabel strLogMode = OctopusProjectFrame.createOctopusLabel(
096: LOG_MODE, OctopusGeneratorPanel.smallComponent);
097: JComboBox logMode = OctopusProjectFrame.createOctopusCombobox(
098: LOG_MODE, OctopusGeneratorPanel.veryBigComponent);
099: //restart indicator
100: JLabel strRestartIndicator = OctopusProjectFrame
101: .createOctopusLabel(RESTART_INDICATOR,
102: OctopusGeneratorPanel.smallComponent);
103: JTextField restartIndicator = OctopusProjectFrame
104: .createOctopusTextField(RESTART_INDICATOR,
105: OctopusGeneratorPanel.veryBigComponent);
106: //user id
107: JLabel strUserId = OctopusProjectFrame.createOctopusLabel(
108: USER_ID, OctopusGeneratorPanel.smallComponent);
109: JTextField userId = OctopusProjectFrame.createOctopusTextField(
110: USER_ID, OctopusGeneratorPanel.veryBigComponent);
111: //variables
112: JLabel strVariables = OctopusProjectFrame.createOctopusLabel(
113: VARIABLES, OctopusGeneratorPanel.smallComponent);
114: JTextField variables = OctopusProjectFrame
115: .createOctopusTextField(VARIABLES,
116: OctopusGeneratorPanel.veryBigComponent);
117: //log file directory
118: JLabel strLogFileDir = OctopusProjectFrame.createOctopusLabel(
119: LOG_FILE_DIRECTORY,
120: OctopusGeneratorPanel.smallComponent);
121: JTextField logFileDir = OctopusProjectFrame
122: .createOctopusTextField(LOG_FILE_DIRECTORY,
123: OctopusGeneratorPanel.veryBigPlusButton);
124: JButton logDirButton = OctopusProjectFrame.createOctopusButton(
125: "", new Dimension(20, 20));
126: logDirButton.setAction(new BrowseAction_LD());
127: //log file name
128: JLabel strLogFileName = OctopusProjectFrame.createOctopusLabel(
129: LOG_FILE_NAME, OctopusGeneratorPanel.smallComponent);
130: JTextField logFileName = OctopusProjectFrame
131: .createOctopusTextField(LOG_FILE_NAME,
132: OctopusGeneratorPanel.veryBigComponent);
133: //specific vendor conf file
134: JLabel strSpecVendorConf = OctopusProjectFrame
135: .createOctopusLabel(VENDOR_CONF_FILE,
136: OctopusGeneratorPanel.smallComponent);
137: JTextField specVendorConf = OctopusProjectFrame
138: .createOctopusTextField(VENDOR_CONF_FILE,
139: OctopusGeneratorPanel.veryBigPlusButton);
140: JButton specVendorButton = OctopusProjectFrame
141: .createOctopusButton("", new Dimension(20, 20));
142: specVendorButton.setAction(new BrowseAction_XML());
143: //on error continue
144: JLabel strOnError = OctopusProjectFrame.createOctopusLabel(
145: ON_ERRORCONTINUE, OctopusGeneratorPanel.smallComponent);
146: JTextField onError = OctopusProjectFrame
147: .createOctopusTextField(ON_ERRORCONTINUE,
148: OctopusGeneratorPanel.veryBigComponent);
149: //commit count
150: JLabel strCommitCount = OctopusProjectFrame.createOctopusLabel(
151: COMMIT_COUNT, OctopusGeneratorPanel.smallComponent);
152: JTextField commitCount = OctopusProjectFrame
153: .createOctopusTextField(COMMIT_COUNT,
154: OctopusGeneratorPanel.veryBigComponent);
155: //return code
156: JLabel strReturnCode = OctopusProjectFrame.createOctopusLabel(
157: RETURN_CODE, OctopusGeneratorPanel.smallComponent);
158: JTextField returnCode = OctopusProjectFrame
159: .createOctopusTextField(RETURN_CODE,
160: OctopusGeneratorPanel.veryBigComponent);
161: //pathe to olj file
162: JLabel strPathToOlj = OctopusProjectFrame.createOctopusLabel(
163: PATH_TO_XML_FILE, OctopusGeneratorPanel.smallComponent);
164: JTextField pathToOlj = OctopusProjectFrame
165: .createOctopusTextField(PATH_TO_XML_FILE,
166: OctopusGeneratorPanel.veryBigPlusButton);
167: JButton pathToOljButton = OctopusProjectFrame
168: .createOctopusButton("", new Dimension(20, 20));
169: pathToOljButton.setAction(new BrowseAction_OLJ());
170: //include list
171: JLabel strIncludeList = OctopusProjectFrame.createOctopusLabel(
172: INCLUDE_TABLES, OctopusGeneratorPanel.smallComponent);
173: JTextField includeList = OctopusProjectFrame
174: .createOctopusTextField(INCLUDE_TABLES,
175: OctopusGeneratorPanel.veryBigComponent);
176: //path to conf files in jar file
177: JLabel strPathToConf = OctopusProjectFrame.createOctopusLabel(
178: PATH_TO_CONF_JAR, OctopusGeneratorPanel.smallComponent);
179: JTextField pathToConf = OctopusProjectFrame
180: .createOctopusTextField(PATH_TO_CONF_JAR,
181: OctopusGeneratorPanel.veryBigComponent);
182: //additional classpaths
183: JLabel strAdditionalPath = OctopusProjectFrame
184: .createOctopusLabel(ADDITIONAL_CLASSPATH,
185: OctopusGeneratorPanel.smallComponent);
186: additionalPath = OctopusProjectFrame.createOctopusTextField(
187: ADDITIONAL_CLASSPATH,
188: OctopusGeneratorPanel.veryBigPlusButton);
189: JButton additionalPathButton = OctopusProjectFrame
190: .createOctopusButton("", new Dimension(20, 20));
191: additionalPathButton.setAction(new BrowseAction_AC());
192:
193: JPanel inputParamPanelLabel = new JPanel();
194: inputParamPanelLabel.setLayout(new BoxLayout(
195: inputParamPanelLabel, BoxLayout.Y_AXIS));
196: JPanel inputParamPanelField = new JPanel();
197: inputParamPanelField.setLayout(new BoxLayout(
198: inputParamPanelField, BoxLayout.Y_AXIS));
199:
200: commonPanel.add(Box.createRigidArea(new Dimension(0, 15)));
201: createRow(strLogMode, logMode, null);
202: fields.put(LOG_MODE, logMode);
203: createRow(strRestartIndicator, restartIndicator, null);
204: fields.put(RESTART_INDICATOR, restartIndicator);
205: createRow(strUserId, userId, null);
206: fields.put(USER_ID, userId);
207: createRow(strVariables, variables, null);
208: fields.put(VARIABLES, variables);
209: createRow(strLogFileDir, logFileDir, logDirButton);
210: fields.put(LOG_FILE_DIRECTORY, logFileDir);
211: createRow(strLogFileName, logFileName, null);
212: fields.put(LOG_FILE_NAME, logFileName);
213: createRow(strSpecVendorConf, specVendorConf, specVendorButton);
214: fields.put(VENDOR_CONF_FILE, specVendorConf);
215: createRow(strOnError, onError, null);
216: fields.put(ON_ERRORCONTINUE, onError);
217: createRow(strCommitCount, commitCount, null);
218: fields.put(COMMIT_COUNT, commitCount);
219: createRow(strReturnCode, returnCode, null);
220: fields.put(RETURN_CODE, returnCode);
221: createRow(strPathToOlj, pathToOlj, pathToOljButton);
222: fields.put(PATH_TO_XML_FILE, pathToOlj);
223: createRow(strIncludeList, includeList, null);
224: fields.put(INCLUDE_TABLES, includeList);
225: createRow(strPathToConf, pathToConf, null);
226: fields.put(PATH_TO_CONF_JAR, pathToConf);
227: createRow(strAdditionalPath, additionalPath,
228: additionalPathButton);
229: fields.put(ADDITIONAL_CLASSPATH, additionalPath);
230:
231: // JSplitPane generatorInputData = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true,
232: // generatorOptions, octopusLoaderData);
233: // JSplitPane generatorInputData = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true,
234: // new JPanel(), octopusLoaderData);
235:
236: // output panel
237: JPanel textAreaPanel = new JPanel();
238: textAreaPanel.setLayout(new BoxLayout(textAreaPanel,
239: BoxLayout.X_AXIS));
240: JPanel areaOptionPanel = new JPanel();
241: areaOptionPanel.setLayout(new BoxLayout(areaOptionPanel,
242: BoxLayout.Y_AXIS));
243: traceArea = new JTextArea(18, 130);
244: traceArea.setLineWrap(true);
245: traceArea.setEditable(false);
246: traceArea.setBorder(BorderFactory
247: .createEtchedBorder(EtchedBorder.RAISED));
248: JScrollPane scrollPane = new JScrollPane(traceArea,
249: ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
250: ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
251:
252: scrollPane.setBorder(setTitleOfBorder(
253: "Log TDT Loader output ... ", loweredBorder));
254: JButton fullScreen = OctopusProjectFrame.createOctopusButton(
255: "Full Screen", new Dimension(25, 25));
256: fullScreen.setAction(new FullScreenAction());
257: JButton normalScreen = OctopusProjectFrame.createOctopusButton(
258: "Normal Screen", new Dimension(25, 25));
259: normalScreen.setAction(new NormalScreenAction());
260: JButton saveScreen = OctopusProjectFrame.createOctopusButton(
261: "Save Trace", new Dimension(25, 25));
262: saveScreen.setAction(new SaveTraceAction());
263: JButton clearTrace = OctopusProjectFrame.createOctopusButton(
264: "Clear Trace", new Dimension(25, 25));
265: clearTrace.setAction(new ClearTraceAction());
266:
267: areaOptionPanel.add(fullScreen);
268: areaOptionPanel.add(normalScreen);
269: areaOptionPanel.add(saveScreen);
270: areaOptionPanel.add(clearTrace);
271: areaOptionPanel.add(Box.createVerticalGlue());
272: areaOptionPanel.setBorder(BorderFactory
273: .createEtchedBorder(EtchedBorder.LOWERED));
274:
275: // JPanel areaOptionMainPanel = new JPanel(new BorderLayout());
276: // areaOptionMainPanel.add(areaOptionPanel, BorderLayout.PAGE_START);
277:
278: textAreaPanel.add(areaOptionPanel);
279: textAreaPanel.add(scrollPane);
280: // main = new JSplitPane(JSplitPane.VERTICAL_SPLIT, true, generatorInputData,
281: // textAreaPanel);
282: main = new JSplitPane(JSplitPane.VERTICAL_SPLIT, true,
283: octopusLoaderData, textAreaPanel);
284: main.setOneTouchExpandable(true);
285: // main.setDividerLocation(450);
286:
287: // Container container = getContentPane();
288: setLayout(new BoxLayout(this , BoxLayout.X_AXIS));
289: add(main);
290: setBounds(0, 0, 970, 480);
291: }
292:
293: public JTextArea getTraceArea() {
294: return this .traceArea;
295: }
296:
297: private void createRow(JLabel label, JComponent component,
298: JButton button) {
299:
300: JPanel jp = new JPanel();
301: jp.setLayout(new BoxLayout(jp, BoxLayout.X_AXIS));
302:
303: jp.add(label);
304: jp.add(component);
305: if (button != null)
306: jp.add(button);
307: jp.add(Box.createHorizontalGlue());
308:
309: commonPanel.add(jp);
310: }
311:
312: private Border setTitleOfBorder(String title, Border border) {
313: Border inb = BorderFactory.createTitledBorder(border, title);
314: return inb;
315: }
316:
317: // private JButton createOctopusButton(String componentName, Dimension dimension) {
318: //
319: // JButton button = new JButton();
320: // if(!componentName.equalsIgnoreCase(""))
321: // button.setText(componentName);
322: //
323: // button.setAlignmentX(Component.LEFT_ALIGNMENT);
324: // button.setAlignmentY(Component.CENTER_ALIGNMENT);
325: // button.setMinimumSize(new Dimension(dimension));
326: // button.setMaximumSize(new Dimension(dimension));
327: // button.setPreferredSize(new Dimension(dimension));
328: //
329: // return button;
330: // }
331: //
332: // private JComboBox createOctopusCombobox(String componentName, Dimension dimension) {
333: //
334: // JComboBox comboBox = new JComboBox();
335: // comboBox.setName(componentName);
336: // comboBox.setAlignmentX(Component.LEFT_ALIGNMENT);
337: // comboBox.setAlignmentY(Component.CENTER_ALIGNMENT);
338: // comboBox.setMinimumSize(new Dimension(dimension));
339: // comboBox.setMaximumSize(new Dimension(dimension));
340: // comboBox.setPreferredSize(new Dimension(dimension));
341: //
342: // return comboBox;
343: // }
344: //
345: // private JLabel createOctopusLabel(String componentName, Dimension dimension) {
346: //
347: // JLabel label = new JLabel();
348: // label.setText(componentName);
349: // label.setAlignmentX(Component.LEFT_ALIGNMENT);
350: // label.setAlignmentY(Component.CENTER_ALIGNMENT);
351: // label.setMinimumSize(new Dimension(dimension));
352: // label.setMaximumSize(new Dimension(dimension));
353: // label.setPreferredSize(new Dimension(dimension));
354: //
355: // return label;
356: // }
357: //
358: // private JTextField createOctopusTextField(String componentName, Dimension dimension) {
359: //
360: // JTextField textField = new JTextField();
361: // textField.setName(componentName);
362: // textField.setAlignmentX(Component.LEFT_ALIGNMENT);
363: // textField.setAlignmentY(Component.CENTER_ALIGNMENT);
364: // textField.setMinimumSize(new Dimension(dimension));
365: // textField.setMaximumSize(new Dimension(dimension));
366: // textField.setPreferredSize(new Dimension(dimension));
367: //
368: // return textField;
369: // }
370:
371: public void setOctopusLoaderInit(OctopusLoaderData initData,
372: String xmlFile, String confJarStructure) {
373: this .initData = initData;
374: setField(LOG_MODE, initData.getLogMode(), "box");
375: setField(LOG_FILE_DIRECTORY, initData.getLogFileDir(),
376: "textfield");
377: setField(LOG_FILE_NAME, initData.getLogFileName(), "textfield");
378: setField(USER_ID, initData.getUserId(), "textfield");
379: setField(VARIABLES, initData.getVariables(), "textfield");
380: setField(RESTART_INDICATOR, initData.getRestartIndicator(),
381: "textfield");
382: setField(VENDOR_CONF_FILE, initData.getVendorConf(),
383: "textfield");
384: setField(ON_ERRORCONTINUE, initData.getOnErrorCon(),
385: "textfield");
386: setField(ADDITIONAL_CLASSPATH, initData.getAdditionalPaths(),
387: "textfield");
388: setField(COMMIT_COUNT, initData.getCommitCount(), "textfield");
389: setField(RETURN_CODE, initData.getReturnCode(), "textfield");
390: if (xmlFile != null)
391: setField(PATH_TO_XML_FILE, xmlFile, "textfield");
392: else
393: setField(PATH_TO_XML_FILE, initData.getPathToXml(),
394: "textfield");
395:
396: setField(INCLUDE_TABLES, initData.getIncludeTables(),
397: "textfield");
398: if (confJarStructure != null)
399: setField(PATH_TO_CONF_JAR, confJarStructure, "textfield");
400: else
401: setField(PATH_TO_CONF_JAR, initData.getConfJarStructure(),
402: "textfield");
403: }
404:
405: public OctopusLoaderData getOctopusLoaderInit() throws Exception {
406:
407: initData.setLogMode(getField(LOG_MODE, "box"));
408: initData.setLogFileName(getField(LOG_FILE_NAME, "label"));
409: initData.setLogFileDir(getField(LOG_FILE_DIRECTORY, "label"));
410: initData.setRestartIndicator(getField(RESTART_INDICATOR,
411: "label"));
412: initData.setUserId(getField(USER_ID, "label"));
413: initData.setVariables(getField(VARIABLES, "label"));
414: initData.setVendorConf(getField(VENDOR_CONF_FILE, "label"));
415: initData.setOnErrorCon(getField(ON_ERRORCONTINUE, "label"));
416: initData.setAdditionalPaths(getField(ADDITIONAL_CLASSPATH,
417: "label"));
418: initData.setCommitCount(getField(COMMIT_COUNT, "label"));
419: initData.setReturnCode(getField(RETURN_CODE, "label"));
420: initData.setPathToXml(getField(PATH_TO_XML_FILE, "label"));
421: initData.setIncludeTables(getField(INCLUDE_TABLES, "label"));
422: initData
423: .setConfJarStructure(getField(PATH_TO_CONF_JAR, "label"));
424:
425: return initData;
426: }
427:
428: private void setField(String fieldName, String value, String type) {
429: if (type.equalsIgnoreCase("textfield")) {
430: JTextField field = (JTextField) fields.get(fieldName);
431: field.setText(value);
432: } else {
433: JComboBox field = (JComboBox) fields.get(fieldName);
434: boolean setted = false;
435: for (int i = 0; i < OctopusLoaderData.getLogModes().length; i++) {
436: if (field.getItemCount() != OctopusLoaderData
437: .getLogModes().length)
438: field.addItem(OctopusLoaderData.getLogModes()[i]);
439: if (value.equalsIgnoreCase(OctopusLoaderData
440: .getLogModes()[i]))
441: field.setSelectedIndex(i);
442: }
443: if (!setted)
444: field.setSelectedIndex(1);
445: }
446: }
447:
448: private String getField(String fieldName, String type) {
449: if (type.equalsIgnoreCase("label")) {
450: JTextField field = (JTextField) fields.get(fieldName);
451: return field.getText().trim();
452: } else {
453: JComboBox field = (JComboBox) fields.get(fieldName);
454: return field.getSelectedItem().toString();
455: }
456: }
457:
458: private class FullScreenAction extends AbstractAction {
459:
460: /**
461: * This method starts the LoaderGenerator application
462: */
463: public FullScreenAction() {
464:
465: putValue(SMALL_ICON, new ImageIcon(getClass()
466: .getClassLoader().getResource(
467: "org/webdocwf/util/loader/"
468: + "wizard/images/Host16.gif")));
469: putValue(SHORT_DESCRIPTION, "Full Screen");
470: putValue(LONG_DESCRIPTION, "Set Trace to Full Screen");
471: putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('F',
472: Toolkit.getDefaultToolkit()
473: .getMenuShortcutKeyMask()));
474: putValue(MNEMONIC_KEY, new Integer('F'));
475: }
476:
477: /**
478: * This method check if the action is performed (event key pressed)
479: * @param e is event
480: */
481: public void actionPerformed(ActionEvent e) {
482: main.setDividerLocation(0);
483: }
484: }
485:
486: private class NormalScreenAction extends AbstractAction {
487:
488: /**
489: * This method starts the LoaderGenerator application
490: */
491: public NormalScreenAction() {
492:
493: putValue(SMALL_ICON, new ImageIcon(getClass()
494: .getClassLoader().getResource(
495: "org/webdocwf/util/loader/"
496: + "wizard/images/Unhost16.gif")));
497: putValue(SHORT_DESCRIPTION, "Normal Screen");
498: putValue(LONG_DESCRIPTION, "Back to normal screen");
499: putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('N',
500: Toolkit.getDefaultToolkit()
501: .getMenuShortcutKeyMask()));
502: putValue(MNEMONIC_KEY, new Integer('N'));
503: }
504:
505: /**
506: * This method check if the action is performed (event key pressed)
507: * @param e is event
508: */
509: public void actionPerformed(ActionEvent e) {
510: main.setDividerLocation(330);
511: }
512: }
513:
514: private class SaveTraceAction extends AbstractAction {
515:
516: /**
517: * This method starts the LoaderGenerator application
518: */
519: public SaveTraceAction() {
520:
521: putValue(SMALL_ICON, new ImageIcon(getClass()
522: .getClassLoader().getResource(
523: "org/webdocwf/util/loader/"
524: + "wizard/images/Save16.gif")));
525: putValue(SHORT_DESCRIPTION, "Save Trace");
526: putValue(LONG_DESCRIPTION, "Save Trace to file");
527: putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('S',
528: Toolkit.getDefaultToolkit()
529: .getMenuShortcutKeyMask()));
530: putValue(MNEMONIC_KEY, new Integer('S'));
531: }
532:
533: /**
534: * This method check if the action is performed (event key pressed)
535: * @param e is event
536: */
537: public void actionPerformed(ActionEvent e) {
538: JFileChooser fc = new JFileChooser();
539: fc.setDialogTitle("Save TDT log ...");
540: int returnVal = fc.showSaveDialog(null);
541: if (returnVal == JFileChooser.APPROVE_OPTION) {
542: File file = fc.getSelectedFile();
543: String text = traceArea.getText();
544: try {
545: Writer out = new BufferedWriter(
546: new FileWriter(file));
547: out.write(text);
548: out.close();
549: } catch (Exception ex) {
550: ex.printStackTrace();
551: }
552:
553: } else {
554: //do nothing
555: }
556: }
557: }
558:
559: private class ClearTraceAction extends AbstractAction {
560:
561: /**
562: * This method starts the LoaderGenerator application
563: */
564: public ClearTraceAction() {
565:
566: putValue(SMALL_ICON, new ImageIcon(getClass()
567: .getClassLoader().getResource(
568: "org/webdocwf/util/loader/"
569: + "wizard/images/Delete16.gif")));
570: putValue(SHORT_DESCRIPTION, "Clear Trace");
571: putValue(LONG_DESCRIPTION, "Clear Trace");
572: putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('L',
573: Toolkit.getDefaultToolkit()
574: .getMenuShortcutKeyMask()));
575: putValue(MNEMONIC_KEY, new Integer('L'));
576: }
577:
578: /**
579: * This method check if the action is performed (event key pressed)
580: * @param e is event
581: */
582: public void actionPerformed(ActionEvent e) {
583: traceArea.setText("");
584: }
585: }
586:
587: //additional paths
588: private class BrowseAction_AC extends AbstractAction {
589:
590: /**
591: * This method stop the LoaderGenerator application
592: */
593: public BrowseAction_AC() {
594: putValue(SMALL_ICON, new ImageIcon(getClass()
595: .getClassLoader().getResource(
596: "org/webdocwf/util/loader/"
597: + "wizard/images/Open16.gif")));
598: putValue(SHORT_DESCRIPTION, "Add .jar files");
599: putValue(LONG_DESCRIPTION,
600: "Add .jar (jdbc) files to system classpath");
601: putValue(MNEMONIC_KEY, new Integer('B'));
602: }
603:
604: /**
605: * This method check if the action is performed (event key pressed)
606: * @param e is event
607: */
608: public void actionPerformed(ActionEvent e) {
609: JFileChooser chooser = null;
610: File choice = null;
611: File current = new File(System.getProperty("user.dir"));
612: chooser = new JFileChooser(current);
613: chooser
614: .setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
615: chooser
616: .setFileFilter((javax.swing.filechooser.FileFilter) new JarFilter());
617: chooser.setDialogTitle("Select .jar file");
618: chooser.setAcceptAllFileFilterUsed(false);
619: String strFieldText = additionalPath.getText();
620: //
621: if (!strFieldText.equalsIgnoreCase(""))
622: strFieldText = strFieldText + ";";
623:
624: chooser.setCurrentDirectory(new File(strFieldText));
625: chooser.setApproveButtonText("Open");
626: int v = chooser.showOpenDialog(null);
627:
628: switch (v) {
629: case JFileChooser.APPROVE_OPTION:
630: if (chooser.getSelectedFile() != null) {
631: if (chooser.getSelectedFile().exists()) {
632: choice = chooser.getSelectedFile();
633: } else {
634: File parentFile = new File(chooser
635: .getSelectedFile().getParent());
636: choice = parentFile;
637: }
638: additionalPath.setText(strFieldText
639: + choice.getPath());
640: }
641: break;
642:
643: case JFileChooser.CANCEL_OPTION:
644: case JFileChooser.ERROR_OPTION:
645:
646: chooser.removeAll();
647: chooser = null;
648: current = null;
649:
650: }
651: }
652: }
653:
654: private class OctopusHelpAction extends AbstractAction {
655:
656: /**
657: * Action which creates new help frame
658: */
659: public OctopusHelpAction() {
660: putValue(NAME, "Help");
661: putValue(SMALL_ICON, new ImageIcon(getClass()
662: .getClassLoader().getResource(
663: "org/webdocwf/util/loader/"
664: + "wizard/images/Help16.gif")));
665: putValue(SHORT_DESCRIPTION, "Help for running the program");
666: putValue(LONG_DESCRIPTION, "Help for running the program");
667: putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('H',
668: Toolkit.getDefaultToolkit()
669: .getMenuShortcutKeyMask()));
670: putValue(MNEMONIC_KEY, new Integer('H'));
671: }
672:
673: /**
674: * Creating event for new windows help frame
675: * @param e is creating events
676: */
677: public void actionPerformed(ActionEvent e) {
678: try {
679: OctopusGeneratorHelpFrame helpFrame = new OctopusGeneratorHelpFrame();
680: helpFrame
681: .setIconImage(new ImageIcon(
682: getClass()
683: .getClassLoader()
684: .getResource(
685: "org/webdocwf/util/loader/"
686: + "wizard/images/Enhydra16.gif"))
687: .getImage());
688: helpFrame.setVisible(true);
689: } catch (Exception ex) {
690: String message = "Error while creating action for OctopusHelp button. Message : "
691: + ex.getMessage();
692: JOptionPane.showMessageDialog(null, message + "\n",
693: "Error", 0);
694: System.exit(0);
695: }
696: }
697: }
698:
699: //log dir
700: private class BrowseAction_LD extends AbstractAction {
701:
702: /**
703: * This method stop the LoaderGenerator application
704: */
705: public BrowseAction_LD() {
706: // putValue(NAME, "browse");
707: putValue(SMALL_ICON, new ImageIcon(getClass()
708: .getClassLoader().getResource(
709: "org/webdocwf/util/loader/"
710: + "wizard/images/Open16.gif")));
711: putValue(SHORT_DESCRIPTION, "Browse for Log file directory");
712: putValue(LONG_DESCRIPTION, "Browse for Log file directory");
713: putValue(MNEMONIC_KEY, new Integer('B'));
714: }
715:
716: /**
717: * This method check if the action is performed (event key pressed)
718: * @param e is event
719: */
720: public void actionPerformed(ActionEvent e) {
721: JFileChooser chooser = null;
722: File choice = null;
723: File current = new File(System.getProperty("user.dir"));
724: chooser = new JFileChooser(current);
725: chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
726: chooser
727: .setFileFilter((javax.swing.filechooser.FileFilter) new DirectoryFilter());
728: chooser.setDialogTitle("Select Log File Directory");
729: chooser.setApproveButtonText("Open");
730: String strFieldText = "";
731:
732: chooser.setCurrentDirectory(new File(strFieldText));
733: int v = chooser.showOpenDialog(null);
734: // parent.requestFocus();
735:
736: switch (v) {
737: case JFileChooser.APPROVE_OPTION:
738: if (chooser.getSelectedFile() != null) {
739: if (chooser.getSelectedFile().exists()) {
740: choice = chooser.getSelectedFile();
741: } else {
742: File parentFile = new File(chooser
743: .getSelectedFile().getParent());
744: choice = parentFile;
745: }
746: setField(LOG_FILE_DIRECTORY, choice.getPath(),
747: "textfield");
748: }
749: break;
750:
751: case JFileChooser.CANCEL_OPTION:
752: case JFileChooser.ERROR_OPTION:
753:
754: }
755: }
756: }
757:
758: private class BrowseAction_XML extends AbstractAction {
759:
760: /**
761: * This method stop the LoaderGenerator application
762: */
763: public BrowseAction_XML() {
764: // putValue(NAME, "browse");
765: putValue(SMALL_ICON, new ImageIcon(getClass()
766: .getClassLoader().getResource(
767: "org/webdocwf/util/loader/"
768: + "wizard/images/Open16.gif")));
769: putValue(SHORT_DESCRIPTION, "Browse for .xml file");
770: putValue(LONG_DESCRIPTION, "Browse for .xml file");
771: putValue(MNEMONIC_KEY, new Integer('B'));
772: }
773:
774: /**
775: * This method check if the action is performed (event key pressed)
776: * @param e is event
777: */
778: public void actionPerformed(ActionEvent e) {
779: JFileChooser chooser = null;
780: File choice = null;
781: File current = new File(System.getProperty("user.dir"));
782: chooser = new JFileChooser(current);
783: chooser
784: .setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
785: chooser
786: .setFileFilter((javax.swing.filechooser.FileFilter) new XmlFilter());
787: chooser.setDialogTitle("Select .xml file");
788: chooser.setAcceptAllFileFilterUsed(false);
789: String strFieldText = "";
790:
791: chooser.setCurrentDirectory(new File(strFieldText));
792: chooser.setApproveButtonText("Open");
793: int v = chooser.showOpenDialog(null);
794:
795: // parent.requestFocus();
796: switch (v) {
797: case JFileChooser.APPROVE_OPTION:
798: if (chooser.getSelectedFile() != null) {
799: if (chooser.getSelectedFile().exists()) {
800: choice = chooser.getSelectedFile();
801: } else {
802: File parentFile = new File(chooser
803: .getSelectedFile().getParent());
804: choice = parentFile;
805: }
806: setField(VENDOR_CONF_FILE, choice.getPath(),
807: "textfield");
808: }
809: break;
810:
811: case JFileChooser.CANCEL_OPTION:
812: case JFileChooser.ERROR_OPTION:
813:
814: chooser.removeAll();
815: chooser = null;
816: current = null;
817: }
818: }
819: }
820:
821: private class BrowseAction_OLJ extends AbstractAction {
822:
823: /**
824: * This method stop the LoaderGenerator application
825: */
826: public BrowseAction_OLJ() {
827: // putValue(NAME, "browse");
828: putValue(SMALL_ICON, new ImageIcon(getClass()
829: .getClassLoader().getResource(
830: "org/webdocwf/util/loader/"
831: + "wizard/images/Open16.gif")));
832: putValue(SHORT_DESCRIPTION, "Browse for LoaderJob.olj file");
833: putValue(LONG_DESCRIPTION, "Browse for LoaderJob.olj file");
834: putValue(MNEMONIC_KEY, new Integer('B'));
835: }
836:
837: /**
838: * This method check if the action is performed (event key pressed)
839: * @param e is event
840: */
841: public void actionPerformed(ActionEvent e) {
842: JFileChooser chooser = null;
843: File choice = null;
844: File current = new File(System.getProperty("user.dir"));
845: chooser = new JFileChooser(current);
846: chooser
847: .setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
848: chooser
849: .setFileFilter((javax.swing.filechooser.FileFilter) new OctopusFileFilter());
850: chooser.setDialogTitle("Select .olj file");
851: chooser.setAcceptAllFileFilterUsed(false);
852: String strFieldText = "";
853:
854: chooser.setCurrentDirectory(new File(strFieldText));
855: chooser.setApproveButtonText("Open");
856: int v = chooser.showOpenDialog(null);
857:
858: // parent.requestFocus();
859: switch (v) {
860: case JFileChooser.APPROVE_OPTION:
861: if (chooser.getSelectedFile() != null) {
862: if (chooser.getSelectedFile().exists()) {
863: choice = chooser.getSelectedFile();
864: } else {
865: File parentFile = new File(chooser
866: .getSelectedFile().getParent());
867: choice = parentFile;
868: }
869: setField(PATH_TO_XML_FILE, choice.getPath(),
870: "textfield");
871: }
872: break;
873:
874: case JFileChooser.CANCEL_OPTION:
875: case JFileChooser.ERROR_OPTION:
876:
877: chooser.removeAll();
878: chooser = null;
879: current = null;
880:
881: }
882: }
883: }
884:
885: }
|