KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > kelp > common > dods > Generator


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

23 package org.enhydra.kelp.common.dods;
24
25 // Kelp imports
26
import org.enhydra.kelp.common.AbstractEchoGenerator;
27 import org.enhydra.kelp.common.PathUtil;
28 import org.enhydra.kelp.common.event.WriteListener;
29 import org.enhydra.kelp.common.node.OtterTemplateNode;
30 import org.enhydra.kelp.common.node.OtterFileNode;
31 import org.enhydra.kelp.common.node.OtterNode;
32 import org.enhydra.kelp.common.node.OtterNodeFactory;
33
34 // ToolBox imports
35
import org.enhydra.tool.common.FileUtil;
36 import org.enhydra.tool.common.PathHandle;
37 import org.enhydra.tool.common.Template;
38 import org.enhydra.tool.common.ToolException;
39 import org.enhydra.tool.configure.ConfigTool;
40 import org.enhydra.tool.common.event.ProgressListener;
41 //import org.enhydra.tool.common.ProgressMeter;
42

43 // Standard imports
44
import java.awt.Component JavaDoc;
45 import java.io.File JavaDoc;
46 import java.util.ArrayList JavaDoc;
47 import java.util.Arrays JavaDoc;
48 import java.util.ResourceBundle JavaDoc;
49
50 import java.io.*;
51 import javax.swing.*;
52 import org.enhydra.dods.xslt.*;
53 import org.enhydra.kelp.common.AbstractEchoBuilder;
54
55 //
56
public class Generator extends AbstractEchoBuilder {
57
58     static ResourceBundle JavaDoc res =
59         ResourceBundle.getBundle("org.enhydra.kelp.common.Res"); // nores
60
private Component JavaDoc owner = null;
61     private boolean doneDialog = false;
62     private CoreDodsTool coreDodsTool = null;
63
64     public Generator(WriteListener listener) {
65         super(listener);
66     }
67
68     protected void buildImpl() throws ToolException {
69
70     Exception JavaDoc ex = null;
71
72       if(getProject().getDomlFilePath().equals("")) {
73           refreshProgress(100, "");
74           JOptionPane.showMessageDialog(getOwner(), "A filed, denoted by 'Doml file', has to be set.");
75            return;
76       }
77
78    try {
79             refreshProgress(1, res.getString("Dods_starting"));
80             echo(res.getString("Dods_starting"));
81             if (isFresh()) {
82                 buildDods();
83             }
84             refreshProgress(100, "");
85             echo("--- Dods Generator finished --- ");
86
87         } catch (Exception JavaDoc e) {
88             ex = e;
89             echo(ex);
90         }
91   }
92
93     public void setOwner(Component JavaDoc c) {
94         owner = c;
95     }
96
97     public Component JavaDoc getOwner() {
98         return owner;
99     }
100
101     private String JavaDoc getEnhydraPath() {
102       return getProject().getEnhydraPath();
103     }
104
105     private String JavaDoc getProjectJavaPath() {
106       return getProject().getProjectJavaPath();
107     }
108
109     protected boolean isDoneDialog() {
110         boolean canDone = doneDialog;
111
112         if (getOwner() == null) {
113             canDone = false;
114         }
115         return canDone;
116     }
117
118     protected void setDoneDialog(boolean d) {
119         doneDialog = d;
120     }
121
122     private void echoWrite(String JavaDoc str) {
123       echo(str);
124     }
125
126     public void buildDods() {
127
128         DodsBuilder builder = null;
129
130         builder = new DodsBuilder(getWriteListener());
131
132         builder.addProgressListener(getProgressListeners()[0]);
133
134         invoke(builder);
135     }
136
137     private void invoke(AbstractEchoBuilder builder) {
138
139         ProgressListener[] pl = getProgressListeners();
140
141         if (pl != null) {
142             for (int i = 0; i < pl.length; i++) {
143                 builder.addProgressListener(pl[i]);
144             }
145         }
146         builder.setProject(getProject());
147         builder.setEcho(isEcho());
148         builder.buildInCurrentThread();
149         if (pl != null) {
150             for (int i = 0; i < pl.length; i++) {
151                 builder.removeProgressListener(pl[i]);
152             }
153         }
154     }
155
156   }
157
Popular Tags