KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > columba > core > gui > externaltools > ExternalToolsWizardModelListener


1 //The contents of this file are subject to the Mozilla Public License Version 1.1
2
//(the "License"); you may not use this file except in compliance with the
3
//License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
4
//
5
//Software distributed under the License is distributed on an "AS IS" basis,
6
//WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
7
//for the specific language governing rights and
8
//limitations under the License.
9
//
10
//The Original Code is "The Columba Project"
11
//
12
//The Initial Developers of the Original Code are Frederik Dietz and Timo Stich.
13
//Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
14
//
15
//All Rights Reserved.
16
package org.columba.core.gui.externaltools;
17
18 import java.io.File JavaDoc;
19
20 import net.javaprog.ui.wizard.DataModel;
21 import net.javaprog.ui.wizard.WizardModelEvent;
22 import net.javaprog.ui.wizard.WizardModelListener;
23
24 import org.columba.core.config.Config;
25 import org.columba.core.xml.XmlElement;
26
27
28 /**
29  * To change the template for this generated type comment go to
30  * Window - Preferences - Java - Code Generation - Code and Comments
31  *
32  * @author fdietz
33  */

34 class ExternalToolsWizardModelListener implements WizardModelListener {
35     protected DataModel data;
36     protected boolean finished = false;
37
38     public ExternalToolsWizardModelListener(DataModel data) {
39         this.data = data;
40     }
41
42     public void wizardFinished(WizardModelEvent e) {
43        
44         // get location of executable
45
File JavaDoc sourceFile = (File JavaDoc) data.getData("Location.source");
46
47         // get plugin ID
48
String JavaDoc id = (String JavaDoc) data.getData("id");
49
50         // get configuration
51
XmlElement root = Config.getInstance().get("external_tools").getElement("tools");
52
53         for (int i = 0; i < root.count(); i++) {
54             XmlElement child = root.getElement(i);
55
56             if (child.getAttribute("name").equals(id)) {
57                 // set configuration of this plugin
58
child.addAttribute("first_time", "false");
59                 child.addAttribute("location", sourceFile.getPath());
60
61                 // exit for-loop
62
break;
63             }
64         }
65
66         finished = true;
67     }
68
69     public void stepShown(WizardModelEvent e) {
70     }
71
72     public void wizardCanceled(WizardModelEvent e) {
73     }
74
75     public void wizardModelChanged(WizardModelEvent e) {
76     }
77
78     public boolean isFinished() {
79         return finished;
80     }
81 }
82
Popular Tags