1 23 package org.enhydra.kelp.common.dods; 24 25 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 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 43 import java.awt.Component ; 45 import java.io.File ; 46 import java.util.ArrayList ; 47 import java.util.Arrays ; 48 import java.util.ResourceBundle ; 49 50 import java.io.*; 51 import javax.swing.*; 52 import org.enhydra.dods.xslt.*; 53 import org.enhydra.kelp.common.AbstractEchoBuilder; 54 55 public class Generator extends AbstractEchoBuilder { 57 58 static ResourceBundle res = 59 ResourceBundle.getBundle("org.enhydra.kelp.common.Res"); private Component 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 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 e) { 88 ex = e; 89 echo(ex); 90 } 91 } 92 93 public void setOwner(Component c) { 94 owner = c; 95 } 96 97 public Component getOwner() { 98 return owner; 99 } 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 } 157 | Popular Tags |