001: /*****************************************************************************
002: * NULLWriter.java
003: * ****************************************************************************/package org.openlaszlo.compiler;
004:
005: import org.openlaszlo.sc.ScriptCompiler;
006: import org.openlaszlo.server.LPS;
007: import org.openlaszlo.utils.ChainedException;
008: import org.openlaszlo.utils.FileUtils;
009: import org.openlaszlo.utils.ListFormat;
010: import org.openlaszlo.compiler.CompilationEnvironment;
011: import org.openlaszlo.compiler.ObjectWriter.ImportResourceError;
012: import org.openlaszlo.compiler.ObjectWriter.Resource;
013:
014: import org.openlaszlo.iv.flash.api.FlashDef;
015:
016: import org.openlaszlo.media.*;
017:
018: import java.io.*;
019: import java.util.*;
020: import java.lang.Math;
021: import java.lang.Character;
022:
023: import org.jdom.Element;
024:
025: // jgen 1.4
026: import java.awt.geom.Rectangle2D;
027:
028: import org.apache.log4j.*;
029:
030: /**
031: * This ObjectWriter is just for gathering compilation warnings from
032: * the tag compiler. It has stubbed out all calls to the script
033: * compiler or media compilers.
034: *
035: * Properties documented in Compiler.getProperties.
036: */
037: class NullWriter extends DHTMLWriter {
038:
039: // Accumulate script here, to pass to script compiler
040: protected PrintWriter scriptWriter = null;
041: protected StringWriter scriptBuffer = null;
042:
043: /** Logger */
044: protected static Logger mLogger = org.apache.log4j.Logger
045: .getLogger(NullWriter.class);
046:
047: NullWriter(Properties props, OutputStream stream,
048: CompilerMediaCache cache, boolean importLibrary,
049: CompilationEnvironment env) {
050:
051: super (props, stream, cache, importLibrary, env);
052:
053: scriptBuffer = new StringWriter();
054: scriptWriter = new PrintWriter(scriptBuffer);
055:
056: }
057:
058: /**
059: * Sets the canvas for the app
060: *
061: * @param canvas
062: *
063: */
064: void setCanvas(Canvas canvas, String canvasConstructor) {
065: scriptWriter.println(canvasConstructor);
066: }
067:
068: void setCanvasDefaults(Canvas canvas, CompilerMediaCache mc) {
069: };
070:
071: public int addScript(String script) {
072: scriptWriter.println(script);
073: return script.length();
074: }
075:
076: public void importPreloadResource(File fileName, String name)
077: throws ImportResourceError {
078: }
079:
080: public void importPreloadResource(String fileName, String name)
081: throws ImportResourceError {
082: }
083:
084: /** Import a multiframe resource into the current movie. Using a
085: * name that already exists clobbers the old resource (for now).
086: */
087: public void importPreloadResource(List sources, String name,
088: File parent) throws ImportResourceError {
089: }
090:
091: /** Import a resource file into the current movie.
092: * Using a name that already exists clobbers the
093: * old resource (for now).
094: *
095: * @param fileName file name of the resource
096: * @param name name of the MovieClip/Sprite
097: * @throws CompilationError
098: */
099: public void importResource(String fileName, String name)
100: throws ImportResourceError {
101: importResource(new File(fileName), name);
102: }
103:
104: public void importResource(File inputFile, String name)
105: throws ImportResourceError {
106: }
107:
108: public void importResource(List sources, String sResourceName,
109: File parent) {
110: writeResourceLibraryDescriptor(sources, sResourceName, parent);
111: }
112:
113: /* Write resource descriptor library */
114: public void writeResourceLibraryDescriptor(List sources,
115: String sResourceName, File parent) {
116: }
117:
118: public void close() throws IOException {
119: }
120:
121: public void openSnippet(String url) throws IOException {
122: this .liburl = url;
123: }
124:
125: public void closeSnippet() throws IOException {
126: }
127:
128: /* [todo 2006-02-09 hqm] These methods are to be compatible with
129: SWF font machinery -- this should get factored away someday so that the FontCompiler
130: doesn't try to do anything with <font> tags in DHTML, (except maybe make aliases for them?)
131: */
132: FontManager getFontManager() {
133: // mEnv.warn("DHTML runtime doesn't support FontManager API");
134: return null;
135: }
136:
137: public boolean isDeviceFont(String face) {
138: return true;
139: }
140:
141: public void setDeviceFont(String face) {
142: }
143:
144: public void setFontManager(FontManager fm) {
145: }
146:
147: public void importFontStyle(String fileName, String face,
148: String style, CompilationEnvironment env)
149: throws FileNotFoundException, CompilationError {
150: env.warn("DHTMLWriter does not support importing fonts");
151: }
152:
153: void addPreloaderScript(String script) {
154: };
155:
156: void addPreloader(CompilationEnvironment env) {
157: };
158:
159: public void importBaseLibrary(String library,
160: CompilationEnvironment env) {
161: env.warn("DHTMLWriter does not implement importBaseLibrary");
162: }
163:
164: public String importClickResource(File file)
165: throws ImportResourceError {
166: mEnv.warn("clickregion not implemented by DHTMLWriter");
167: return ("DHTMLWriter clickregions not implemented");
168: }
169:
170: protected Resource getResource(String fileName, String name,
171: boolean stop) throws ImportResourceError {
172: return null;
173: }
174:
175: }
|