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 query.ContainerPalette;
014: import query.QueryPalette;
015: import components.SchemaTreeWindow;
016: import components.TaxonomyTreeWindow;
017: import graphical.DragListView;
018: import soif.CSID;
019: import soif.Schema;
020: import soif.SchemaGetter;
021: import soif.Taxonomy;
022: import soif.TaxonomyGetter;
023: import util.ReportError;
024:
025: import netscape.application.Application;
026: import netscape.application.Button;
027: import netscape.application.Color;
028: import netscape.application.ExternalWindow;
029: import netscape.application.InternalWindow;
030: import netscape.application.Menu;
031: import netscape.application.MenuItem;
032: import netscape.application.MenuView;
033: import netscape.application.Size;
034: import netscape.application.Target;
035: import netscape.application.View;
036:
037: public class QueryEdit extends Application implements Target {
038: private QueryPalette queryPalette;
039: private ContainerPalette containerPalette;
040: private Schema schema;
041: private Taxonomy taxonomy;
042:
043: private Menu menu;
044: private MenuView menuView;
045: private MenuItem fileMenuItem;
046:
047: private SchemaGetter sg;
048: private TaxonomyGetter tg;
049: private String testSchema;
050: private String testTaxonomy;
051:
052: private static ExternalWindow externalWindow;
053:
054: public void init() {
055: super .init();
056:
057: Header.showVersion(Messages.TITLE_QUERYEDIT, true, true);
058:
059: boolean valid = true;
060:
061: mainRootView().setColor(graphical.Header.DESKTOPCOLOR);
062:
063: String CGILocation = Header.parameterMacro(this , "CGILocation");
064: String CGITarget = Header.parameterMacro(this , "CGITarget");
065: String CGISchemaRead = Header.parameterMacro(this ,
066: "CGISchemaRead");
067: String CGITaxRead = Header.parameterMacro(this , "CGITaxRead");
068:
069: CSID csid = Header.parameterCSIDMacro(this );
070:
071: if ((CGILocation == null) || (CGITarget == null)
072: || (CGITaxRead == null) || (CGISchemaRead == null)
073: || (csid.isValid() == false)) {
074: valid = false;
075: }
076:
077: // SGP: needs work v
078:
079: testSchema = parameterNamed("testSchema");
080: if (testSchema != null) {
081: valid = true;
082: }
083:
084: testTaxonomy = parameterNamed("testTaxonomy");
085: if (testTaxonomy != null) {
086: valid = true;
087: }
088:
089: if (externalWindow != null) {
090: testSchema = "testSchema";
091: testTaxonomy = "testTaxonomy";
092: valid = true;
093: }
094:
095: if (valid) {
096: if (testSchema == null) {
097: sg = new SchemaGetter(CGILocation, CGITarget
098: + CGISchemaRead, csid);
099: sg.start();
100: } else {
101: ReportError.reportError(ReportError.WARNING,
102: ReportError.ADMIN, "QueryEdit", "init",
103: Messages.USETESTSCHEMA);
104: schema = Instrument.testSchema();
105: sg = null;
106: }
107:
108: if (testTaxonomy == null) {
109: tg = new TaxonomyGetter(CGILocation, CGITarget
110: + CGITaxRead, csid);
111: tg.start();
112: } else {
113: ReportError.reportError(ReportError.WARNING,
114: ReportError.ADMIN, "QueryEdit", "init",
115: Messages.USETESTTAXONOMY);
116: taxonomy = Instrument.testTaxonomy();
117: tg = null;
118: }
119: }
120:
121: containerPalette = new ContainerPalette(3, 4);
122: containerPalette.show();
123: queryPalette = new QueryPalette(13, 14);
124: queryPalette.show();
125:
126: menu = new Menu();
127: fileMenuItem = menu.addItemWithSubmenu("File");
128: fileMenuItem.submenu().addItem(Messages.CMD_NEWTAXWIND,
129: Messages.CMD_NEWTAXWIND, this );
130: fileMenuItem.submenu().addItem(Messages.CMD_NEWSCHWIND,
131: Messages.CMD_NEWSCHWIND, this );
132: fileMenuItem.submenu().addSeparator();
133: fileMenuItem.submenu().addItem(Messages.CMD_SEARCH,
134: Messages.CMD_SEARCH, this );
135: externalWindow.setMenu(menu);
136: menuView = new MenuView(menu);
137: menuView.sizeToMinSize();
138: externalWindow.setMenuView(menuView);
139:
140: Header.showVersion(Messages.TITLE_QUERYEDIT, false, true);
141: }
142:
143: public void performCommand(String command, Object arg) {
144: if (Messages.CMD_NEWSCHWIND.equals(command)) {
145: if ((sg != null) && (schema == null)) {
146: sg.waitFor();
147: schema = sg.getSchema();
148: }
149:
150: SchemaTreeWindow schemaTreeWindow = new SchemaTreeWindow(0,
151: 0, graphical.Header.IWINDWIDTH,
152: graphical.Header.IWINDHEIGHT, schema, false, false,
153: false);
154: schemaTreeWindow.setRootView(externalWindow.rootView()); // SGP ??
155: schemaTreeWindow.show();
156: } else if (Messages.CMD_NEWTAXWIND.equals(command)) {
157: if ((tg != null) && (taxonomy == null)) {
158: tg.waitFor();
159: taxonomy = tg.getTaxonomy();
160: }
161:
162: TaxonomyTreeWindow taxonomyTreeWindow = new TaxonomyTreeWindow(
163: 0, 0, graphical.Header.IWINDWIDTH,
164: graphical.Header.IWINDHEIGHT, taxonomy, false,
165: false, null);
166: taxonomyTreeWindow.setRootView(externalWindow.rootView()); // SGP ??
167: taxonomyTreeWindow.show();
168: }
169: }
170:
171: // SGP: revise
172: public static void main(String args[]) {
173: QueryEdit app;
174: Size size;
175:
176: app = new QueryEdit();
177: externalWindow = new ExternalWindow();
178: app.setMainRootView(externalWindow.rootView());
179: size = externalWindow.windowSizeForContentSize(470, 290);
180: externalWindow.sizeTo(size.width, size.height);
181: externalWindow.show();
182:
183: app.run();
184: System.exit(0);
185: }
186: /*
187: */
188: }
|