KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > kelp > forte > services > XMLCCompilerType


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  * Lisa Reese
21  *
22  */

23
24 package org.enhydra.kelp.forte.services;
25
26 import java.io.File JavaDoc;
27 import java.io.IOException JavaDoc;
28 import java.util.Map JavaDoc;
29
30 import org.openide.compiler.ExternalCompilerType;
31 import org.openide.compiler.CompilerType;
32 import org.openide.compiler.Compiler;
33 import org.openide.compiler.*;
34 import org.openide.cookies.CompilerCookie;
35 import org.openide.execution.NbProcessDescriptor;
36 import org.openide.loaders.DataObject;
37 import org.openide.util.HelpCtx;
38 import org.openide.util.NbBundle;
39
40 /** Runs an external process to "compile" a type of file.
41  *
42  * @author rees0234
43  */

44 public class XMLCCompilerType extends ExternalCompilerType {
45
46 //these are all of our xmlc settings:
47
static final long serialVersionUID = -2979099777437824015L;
48 // private String workingDir; // nores
49
// private boolean autoPackage; // nores
50
// private String libs; // nores
51
// private String outDir; // nores
52
// private String customName; // nores
53
// private String classNameType; // nores
54
// private String optionFile; // nores
55
// private String xmlcParameters; // nores
56
// public final static String NAME_SELECTED = "enhydra.selected"; // nores
57
// private String staticResource; // nores
58

59 // public final static String VALUE_ENHYDRA = "Enhydra"; // nores
60

61     // directory names
62
// public final static String[] DEFAULT_CONTENT = {
63
// "css", "gif", "jpg", "js", "jsp", "wbmp"
64
// }; // nores
65

66     //
67
// public final String XMLC_DOC_TYPES =
68
// "enhydra.xmlc.docTypes"; // nores
69
// private boolean build; // nores
70
// private boolean printDOM; // nores
71
// private boolean printParse; // nores
72
// private boolean printDoc; // nores
73
// private boolean verboseMode; // nores
74
// private boolean printAccessor; // nores
75
// private String outputToFilename; // nores
76
// private String mapFromFolder; // nores
77
// private String mapToPackage; // nores
78
// public final String XMLC_MAP_PACKAGE_LENGTH =
79
// "enhydra.xmlc.map.package.length"; // nores
80
// private int mapScope;
81
/*
82     static final ExternalCompiler.ErrorExpression[] ERROR_EXPRS = {
83     // See docs for this class for how to construct them.
84         new ExternalCompiler.ErrorExpression (NbBundle.getMessage (XMLCCompilerCompilerType.class, "LBL_error_exp_1"),
85                           "(some|reg|exp|here)",
86                           1, 2, 3, 4),
87     // maybe some more choices as well
88     };
89     */

90
91     private static final NbProcessDescriptor DEFAULT = new NbProcessDescriptor (
92                 // PROCESS NAME:
93
// This need not be Javac, of course:
94
"{" + ExternalCompilerGroup.Format.TAG_JAVAHOME + "}{" + ExternalCompilerGroup.Format.TAG_SEPARATOR +
95         "}bin{" + ExternalCompilerGroup.Format.TAG_SEPARATOR + "}javac",
96                 // LIST OF ARGUMENTS INCLUDING OPTIONS:
97
// And you need not specify a classpath if that does not apply to your situation:
98
"-cp {" + ExternalCompilerGroup.Format.TAG_REPOSITORY + "}" +
99                 "{" + ExternalCompilerGroup.Format.TAG_PATHSEPARATOR + "}" + "{" + ExternalCompilerGroup.Format.TAG_CLASSPATH + "}" +
100                 "{" + ExternalCompilerGroup.Format.TAG_PATHSEPARATOR + "}" + "{" + ExternalCompilerGroup.Format.TAG_LIBRARY + "}" +
101                 "{" + ExternalCompilerGroup.Format.TAG_PATHSEPARATOR + "}" + "{" + ExternalCompilerGroup.Format.TAG_BOOTCLASSPATH + "} " +
102                 // You can modify the default format however you like, and insert or remove tags like so:
103
// "-myoption {" + XMLCCompilerCompilerGroup.Format.TAG_MYOPTIONVAL + "} " +
104
// List of file names will go here:
105
"{" + ExternalCompilerGroup.Format.TAG_FILES + '}',
106                 // DESCRIPTION FOR USER OF HOW TO MODIFY THE ARGUMENTS:
107
NbBundle.getMessage (XMLCCompilerType.class, "MSG_format_hint")
108             );
109
110     // The default value for an unconfigured compiler.
111
private String JavaDoc valueOfMyOption = "someDefaultValue";
112
113     public XMLCCompilerType()
114 {
115         // Override the default process choice made in ExternalCompilerType:
116
setExternalCompiler (DEFAULT);
117         /*
118         // Install a default error expression, out of the default list presented to the user:
119         setErrorExpression (ERROR_EXPRS[0]);
120         */

121     }
122
123     public String JavaDoc getValueOfMyOption () {
124         return valueOfMyOption;
125     }
126
127     public synchronized void setValueOfMyOption (String JavaDoc nue) {
128         String JavaDoc old = valueOfMyOption;
129         valueOfMyOption = nue;
130         firePropertyChange ("valueOfMyOption", old, nue);
131     }
132
133 /* public boolean getBuild()
134     {
135         return build;
136     }
137
138     public void setBuild(boolean build)
139     {
140         this.build = build;
141     }
142
143     public boolean getPrintDOM()
144     {
145         return printDOM;
146     }
147
148     public void setPrintDOM(boolean printDOM)
149     {
150         this.printDOM = printDOM;
151     }*/

152
153     /*
154     public HelpCtx getHelpCtx () {
155         return new HelpCtx (XMLCCompilerType.class);
156     }
157     */

158
159     public void prepareJob (CompilerJob job, Class JavaDoc type, DataObject obj) {
160         Compiler JavaDoc cleaner;
161         if (type.equals (CompilerCookie.Clean.class) ||
162                 type.equals (CompilerCookie.Build.class)) {
163                     cleaner = new XMLCCleanCompiler (obj.getPrimaryFile ());
164             job.add (cleaner);
165         } else {
166             cleaner = null;
167         }
168         if (type.equals (CompilerCookie.Compile.class) ||
169                 type.equals (CompilerCookie.Build.class)) {
170                     Compiler JavaDoc compiler = new XMLCCompiler
171                                 (false, obj.getPrimaryFile (), getExternalCompiler (), getErrorExpression (), getValueOfMyOption ());
172             job.add (compiler);
173             if (cleaner != null) compiler.dependsOn (cleaner);
174         } else if (cleaner == null) {
175             // do not do anything--unrecognized compilation type
176
}
177     }
178
179 }
180
Popular Tags