001: /*
002: * Enhydra Java Application Server Project
003: *
004: * The contents of this file are subject to the Enhydra Public License
005: * Version 1.1 (the "License"); you may not use this file except in
006: * compliance with the License. You may obtain a copy of the License on
007: * the Enhydra web site ( http://www.enhydra.org/ ).
008: *
009: * Software distributed under the License is distributed on an "AS IS"
010: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
011: * the License for the specific terms governing rights and limitations
012: * under the license.
013: *
014: * The Initial Developer of the Enhydra Application Server is Lutris
015: * Technologies, Inc. The Enhydra Application Server and portions created
016: * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
017: * All Rights Reserved.
018: *
019: * Contributor(s):
020: * Paul Mahar
021: *
022: */
023: package org.enhydra.kelp.common.dods;
024:
025: // Kelp imports
026: import org.enhydra.kelp.common.AbstractEchoGenerator;
027: import org.enhydra.kelp.common.PathUtil;
028: import org.enhydra.kelp.common.event.WriteListener;
029: import org.enhydra.kelp.common.node.OtterTemplateNode;
030: import org.enhydra.kelp.common.node.OtterFileNode;
031: import org.enhydra.kelp.common.node.OtterNode;
032: import org.enhydra.kelp.common.node.OtterNodeFactory;
033:
034: // ToolBox imports
035: import org.enhydra.tool.common.FileUtil;
036: import org.enhydra.tool.common.PathHandle;
037: import org.enhydra.tool.common.Template;
038: import org.enhydra.tool.common.ToolException;
039: import org.enhydra.tool.configure.ConfigTool;
040: import org.enhydra.tool.common.event.ProgressListener; //import org.enhydra.tool.common.ProgressMeter;
041:
042: // Standard imports
043: import java.awt.Component;
044: import java.io.File;
045: import java.util.ArrayList;
046: import java.util.Arrays;
047: import java.util.ResourceBundle;
048:
049: import java.io.*;
050: import javax.swing.*;
051: import org.enhydra.dods.xslt.*;
052: import org.enhydra.kelp.common.AbstractEchoBuilder;
053:
054: //
055: public class Generator extends AbstractEchoBuilder {
056:
057: static ResourceBundle res = ResourceBundle
058: .getBundle("org.enhydra.kelp.common.Res"); // nores
059: private Component owner = null;
060: private boolean doneDialog = false;
061: private CoreDodsTool coreDodsTool = null;
062:
063: public Generator(WriteListener listener) {
064: super (listener);
065: }
066:
067: protected void buildImpl() throws ToolException {
068:
069: Exception ex = null;
070:
071: if (getProject().getDomlFilePath().equals("")) {
072: refreshProgress(100, "");
073: JOptionPane.showMessageDialog(getOwner(),
074: "A filed, denoted by 'Doml file', has to be set.");
075: return;
076: }
077:
078: try {
079: refreshProgress(1, res.getString("Dods_starting"));
080: echo(res.getString("Dods_starting"));
081: if (isFresh()) {
082: buildDods();
083: }
084: refreshProgress(100, "");
085: echo("--- Dods Generator finished --- ");
086:
087: } catch (Exception e) {
088: ex = e;
089: echo(ex);
090: }
091: }
092:
093: public void setOwner(Component c) {
094: owner = c;
095: }
096:
097: public Component getOwner() {
098: return owner;
099: }
100:
101: private String getEnhydraPath() {
102: return getProject().getEnhydraPath();
103: }
104:
105: private String 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 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: }
|