001: /*
002: * CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF
003: * NETSCAPE COMMUNICATIONS CORPORATION
004: *
005: * Copyright (c) 1996 Netscape Communications Corporation.
006: * All Rights Reserved.
007: * Use of this Source Code is subject to the terms of the applicable
008: * license agreement from Netscape Communications Corporation.
009: */
010:
011: package applications;
012:
013: import components.RDEditorWindow;
014:
015: import graphical.WindowTiler;
016: import soif.CSID;
017: import soif.Schema;
018: import soif.SchemaGetter;
019: import soif.Taxonomy;
020: import soif.TaxonomyGetter;
021: import util.ReportError;
022:
023: import netscape.application.Alert;
024: import netscape.application.Application;
025: import netscape.application.Bitmap;
026: import netscape.application.ExternalWindow;
027: import netscape.application.RootView;
028: import netscape.application.Size;
029: import netscape.application.Window;
030: import netscape.application.WindowOwner;
031:
032: public class RDEdit extends Application implements WindowOwner {
033: public ExternalWindow externalWindow;
034:
035: private WindowTiler windowTiler;
036:
037: private RDEditorWindow editorWindow;
038:
039: private String UIId;
040:
041: private boolean testMode = false;
042:
043: private SchemaGetter sg;
044: private TaxonomyGetter tg;
045: private String testSchema;
046: private String testTaxonomy;
047: private String testSearch;
048:
049: private Schema schema;
050: private Taxonomy taxonomy;
051:
052: private CSID csid;
053: private CSID dbcsid;
054: private String CGILocation;
055: private String CGITarget;
056: private String CGIDBLocation;
057:
058: private Bitmap bm;
059:
060: private boolean standAlone = false;
061:
062: public void init() {
063: super .init();
064:
065: UIId = Header.parameterMacro(this , "UIId");
066:
067: Header.showVersion(UIId, true, true);
068: boolean valid = true;
069:
070: externalWindow = new ExternalWindow();
071: setMainRootView(externalWindow.rootView());
072: mainRootView().setColor(graphical.Header.DESKTOPCOLOR);
073: externalWindow.setTitle(UIId);
074: externalWindow.setOwner(this ); // To intercept close
075:
076: // Create window tiler
077: windowTiler = new WindowTiler();
078:
079: // Minimize bitmap
080: bm = new Bitmap(components.Header.minCompass,
081: components.Header.minCompassSize.width,
082: components.Header.minCompassSize.height);
083:
084: CGILocation = Header.parameterMacro(this , "CGILocation");
085: CGITarget = Header.parameterMacro(this , "CGITarget");
086: String CGITaxRead = Header.parameterMacro(this , "CGITaxRead");
087: String CGITaxWrite = Header.parameterMacro(this , "CGITaxWrite");
088: String CGISchemaRead = Header.parameterMacro(this ,
089: "CGISchemaRead");
090: CGIDBLocation = Header.parameterMacro(this , "CGIDBLocation");
091: csid = Header.parameterCSIDMacro(this );
092: dbcsid = Header.parameterDBCSIDMacro(this );
093:
094: if ((CGILocation == null) || (CGITarget == null)
095: || (CGITaxRead == null) || (CGITaxWrite == null)
096: || (CGISchemaRead == null) || (csid.isValid() == false)
097: || (dbcsid.isValid() == false)) {
098: valid = false;
099: }
100:
101: testSchema = parameterNamed("testSchema");
102: testTaxonomy = parameterNamed("testTaxonomy");
103: testSearch = parameterNamed("testSearch");
104:
105: if (standAlone) {
106: testSchema = "testSchema";
107: testTaxonomy = "testTaxonomy";
108: testSearch = "testSearch";
109: valid = true;
110: }
111:
112: if (testSearch != null) {
113: testMode = true;
114: }
115:
116: if ((testSchema != null) && (testTaxonomy != null)) {
117: valid = true;
118: }
119:
120: if (valid) {
121: if (testSchema == null) {
122: sg = new SchemaGetter(CGILocation, CGITarget
123: + CGISchemaRead, csid);
124: sg.start();
125: } else {
126: ReportError.reportError(ReportError.WARNING,
127: ReportError.ADMIN, "RDEdit", "init",
128: Messages.USETESTSCHEMA);
129: schema = Instrument.testSchema();
130: sg = null;
131: }
132:
133: if (testTaxonomy == null) {
134: tg = new TaxonomyGetter(CGILocation, CGITarget
135: + CGITaxRead, csid);
136: tg.start();
137: } else {
138: ReportError.reportError(ReportError.WARNING,
139: ReportError.ADMIN, "RDEdit", "init",
140: Messages.USETESTTAXONOMY);
141: taxonomy = Instrument.testTaxonomy();
142: tg = null;
143: }
144:
145: if ((schema == null) && (sg != null)) {
146: sg.waitFor();
147: schema = sg.getSchema();
148: }
149:
150: if ((taxonomy == null) && (tg != null)) {
151: tg.waitFor();
152: taxonomy = tg.getTaxonomy();
153: }
154:
155: editorWindow = new RDEditorWindow(externalWindow,
156: windowTiler, graphical.Header.WINDOWHGAP,
157: graphical.Header.WINDOWVGAP,
158: graphical.Header.IWINDWIDTH,
159: graphical.Header.IWINDHEIGHT, testMode, true,
160: schema, taxonomy, CGIDBLocation, CGILocation,
161: dbcsid, csid);
162: editorWindow.setMinimize(bm,
163: components.Messages.LBL_RDEDIT, externalWindow,
164: windowTiler);
165: windowTiler.addWindow(editorWindow); // Tile window (set position)
166: editorWindow.show();
167:
168: Header.EWSizer(externalWindow, editorWindow);
169: externalWindow.show();
170: }
171:
172: Header.showVersion(UIId, false, true);
173: }
174:
175: public static void main(String args[]) {
176: RDEdit app;
177: app = new RDEdit();
178: app.standAlone = true;
179: app.run();
180: System.exit(0);
181: }
182:
183: /**
184: * WindowOwner interface. Used to intercept close on application window
185: * and check for unsaved changes.
186: */
187:
188: public void windowDidHide(Window window) {
189: /*
190: * Removed this, it causes a crash if the applet is closed and
191: * then the user clicks on the disable button in the admin window
192:
193: stopRunning();
194:
195: */
196: }
197:
198: public boolean windowWillHide(Window window) {
199: return editorWindow.closeRequest(); // Check for unsaved changes
200: }
201:
202: public void windowDidBecomeMain(Window window) {
203: }
204:
205: public void windowDidResignMain(Window window) {
206: }
207:
208: public void windowDidShow(Window window) {
209: }
210:
211: public boolean windowWillShow(Window window) {
212: return true;
213: }
214:
215: public void windowWillSizeBy(Window window, Size size) {
216: }
217: }
|