KickJava   Java API By Example, From Geeks To Geeks.

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


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 package org.enhydra.kelp.forte.services;
24 //
25
import org.openide.TopManager;
26 import org.openide.compiler.CompilerType;
27 import org.openide.cookies.CompilerCookie;
28 import org.openide.loaders.CompilerSupport;
29 import org.openide.loaders.DataObject;
30 import org.openide.loaders.MultiDataObject.Entry;
31
32 /**
33  *
34  * @author rees0234
35  * @version
36  */

37 public class XMLCCompilerSupport extends CompilerSupport {
38     private Entry sourceEntry;
39
40     /**
41      * Creates new XMLCCompilerSupport
42      */

43     protected XMLCCompilerSupport(Entry entry, Class JavaDoc cookie) {
44         super(entry, cookie);
45         sourceEntry = entry;
46     }
47
48     protected final Entry getSourceEntry() {
49         return sourceEntry;
50     }
51
52     /**
53      * @return default CompilerType for XMLCDOs
54      */

55     protected CompilerType defaultCompilerType() {
56
57         // return getOpts().getCompiler();
58
return (CompilerType) TopManager.getDefault().getServices().find(XMLCCompilerType.class);
59     }
60
61     /**
62      * getter for JavaSettings
63      */

64
65     /*
66      * private static JavaSettings getOpts() {
67      * if (opts == null) {
68      * opts = (JavaSettings) JavaSettings.findObject(JavaSettings.class, true);
69      * }
70      * return opts;
71      * }
72      */

73
74     /**
75      * Determines whether the source was successfully compiled. It uses
76      * the configured CompilerType for determining what files should it look
77      * after.
78      */

79
80     public boolean isUpToDate() {
81
82         // quick: modified dataobjects cannot be up to date.
83
DataObject d = getSourceEntry().getDataObject();
84
85         if (d.isModified()) {
86             return false;
87         }
88         CompilerCookie ccookie =
89             (CompilerCookie) d.getCookie(CompilerCookie.Compile.class);
90
91         if (ccookie == null) {
92             return false;
93         }
94         org.openide.compiler.CompilerJob j =
95             new org.openide.compiler.CompilerJob(org.openide.compiler.Compiler.DEPTH_ONE);
96
97         return j.isUpToDate();
98     }
99
100     /**
101      * Compile cookie support.
102      * Note that as a special case, when {@link Compiler#DEPTH_ONE} is requested,
103      * a {@link CompilerCookie.Build} will actually be sent to the compiler manager,
104      * rather than a {@link CompilerCookie.Compile}, on the assumption that the user
105      * wished to force (re-)compilation of the single data object.
106      */

107
108     public static class Compile extends XMLCCompilerSupport
109         implements CompilerCookie.Compile {
110
111         /**
112          * New support for given entry. The file is taken from the
113          * entry and is updated if the entry moves or renames itself.
114          * @param entry entry to create instance from
115          */

116         public Compile(Entry entry) {
117             super(entry, CompilerCookie.Compile.class);
118         }
119     }
120
121     /**
122      * Build cookie support.
123      */

124     public static class Build extends XMLCCompilerSupport
125         implements CompilerCookie.Build {
126
127         /**
128          * New support for given entry. The file is taken from the
129          * entry and is updated if the entry moves or renames itself.
130          * @param entry entry to create instance from
131          */

132         public Build(Entry entry) {
133             super(entry, CompilerCookie.Build.class);
134         }
135
136     }
137
138     /**
139      * Clean cookie support.
140      */

141     public static class Clean extends XMLCCompilerSupport
142         implements CompilerCookie.Clean {
143
144         /**
145          * New support for given entry. The file is taken from the
146          * entry and is updated if the entry moves or renames itself.
147          * @param entry entry to create instance from
148          */

149         public Clean(Entry entry) {
150             super(entry, CompilerCookie.Clean.class);
151         }
152
153     }
154 }
155
Popular Tags