home *** CD-ROM | disk | FTP | other *** search
- package netscape.constructor;
-
- import java.io.FileInputStream;
- import java.io.IOException;
- import netscape.application.ExternalWindow;
- import netscape.application.InternalWindow;
- import netscape.application.Target;
- import netscape.application.Window;
- import netscape.util.ClassInfo;
- import netscape.util.Codable;
- import netscape.util.CodingException;
- import netscape.util.Decoder;
- import netscape.util.Encoder;
- import netscape.util.Vector;
-
- public class PlanLoader implements Target, Codable {
- String url;
- boolean isRelativeURL;
- boolean asExternalWindow;
- Plan plan;
- static boolean rememberWindows;
- static Vector windowVector;
- public static final String CREATE_PLAN = "Load Plan";
- static final String HIDE_WINDOWS = "Hide Windows";
- static final String SHOW_WINDOWS = "Show Windows";
- static final String URL_KEY = "Plan URL";
- static final String IS_RELATIVE_KEY = "URL is relative to codebase";
- static final String LOAD_INTO_EXTERNAL_WINDOW = "Use External Window";
-
- public PlanLoader() {
- this.url = null;
- this.plan = null;
- this.isRelativeURL = false;
- this.asExternalWindow = true;
- }
-
- public PlanLoader(String var1) {
- this(var1, false);
- }
-
- public PlanLoader(String var1, boolean var2) {
- this.url = var1;
- this.plan = null;
- this.isRelativeURL = var2;
- this.asExternalWindow = true;
- }
-
- public void setPlan(Plan var1) {
- this.plan = var1;
- }
-
- public Plan plan() {
- return this.plan;
- }
-
- public void setPlanURL(String var1) {
- this.url = var1;
- }
-
- public String planURL() {
- return this.url;
- }
-
- public String fullURL() {
- return this.planURL();
- }
-
- public void setRelativeURL(boolean var1) {
- this.isRelativeURL = var1;
- }
-
- public boolean isRelativeURL() {
- return this.isRelativeURL;
- }
-
- public void performCommand(String var1, Object var2) {
- if ("Load Plan".equals(var1)) {
- this.createPlan();
- } else if ("Hide Windows".equals(var1)) {
- hideWindows();
- } else {
- if ("Show Windows".equals(var1)) {
- showWindows();
- }
-
- }
- }
-
- public boolean loadInExternalWindow() {
- return this.asExternalWindow;
- }
-
- public void setLoadInExternalWindow(boolean var1) {
- this.asExternalWindow = var1;
- }
-
- public void loadPlan() {
- if (this.plan() != null) {
- this.plan.unarchiveObjects();
- } else if (this.planURL() != null && this.planURL().length() >= 1) {
- try {
- FileInputStream var2 = new FileInputStream(this.fullURL());
- this.plan = new Plan();
- int var1 = this.plan.archiveFormatOf(this.fullURL());
- this.plan.initFrom(var2, var1);
- this.plan.unarchiveObjects();
- } catch (IOException var4) {
- try {
- this.plan = new Plan(this.fullURL());
- } catch (IOException var3) {
- System.err.println("PlanLoader could not load plan file: \"" + this.fullURL() + "\"");
- }
- }
- }
- }
-
- public InternalWindow putPlanInInternalWindow() {
- this.loadPlan();
- if (this.plan() == null) {
- return null;
- } else {
- InternalWindow var1 = this.plan().internalWindowWithContents();
- var1.setCloseable(true);
- if (rememberWindows()) {
- windowVector().addElement(var1);
- }
-
- return var1;
- }
- }
-
- public ExternalWindow putPlanInExternalWindow() {
- this.loadPlan();
- if (this.plan() == null) {
- return null;
- } else {
- ExternalWindow var1 = this.plan().externalWindowWithContents();
- if (rememberWindows()) {
- windowVector().addElement(var1);
- }
-
- return var1;
- }
- }
-
- public void createPlan() {
- if (this.asExternalWindow) {
- ExternalWindow var1 = this.putPlanInExternalWindow();
- if (var1 != null) {
- var1.show();
- }
- } else {
- InternalWindow var2 = this.putPlanInInternalWindow();
- if (var2 != null) {
- var2.show();
- }
- }
-
- if (this.plan() != null) {
- this.plan().releaseObjects();
- }
-
- }
-
- public void describeClassInfo(ClassInfo var1) {
- var1.addClass("netscape.constructor.PlanLoader", 1);
- var1.addField("Plan URL", (byte)16);
- var1.addField("URL is relative to codebase", (byte)0);
- var1.addField("Use External Window", (byte)0);
- }
-
- public void encode(Encoder var1) throws CodingException {
- var1.encodeString("Plan URL", this.url);
- var1.encodeBoolean("URL is relative to codebase", this.isRelativeURL);
- var1.encodeBoolean("Use External Window", this.asExternalWindow);
- }
-
- public void decode(Decoder var1) throws CodingException {
- this.url = var1.decodeString("Plan URL");
- this.isRelativeURL = var1.decodeBoolean("URL is relative to codebase");
- this.asExternalWindow = var1.decodeBoolean("Use External Window");
- }
-
- public void finishDecoding() throws CodingException {
- }
-
- public static void setRememberWindows(boolean var0) {
- rememberWindows = var0;
- }
-
- public static boolean rememberWindows() {
- return rememberWindows;
- }
-
- public static Vector windowVector() {
- if (windowVector == null) {
- windowVector = new Vector();
- }
-
- return windowVector;
- }
-
- public static void hideWindows() {
- int var0 = windowVector().count();
- if (var0 >= 1) {
- while(true) {
- --var0;
- if (var0 < 0) {
- windowVector.removeAllElements();
- return;
- }
-
- if (windowVector().elementAt(var0) instanceof ExternalWindow) {
- ((ExternalWindow)windowVector().elementAt(var0)).dispose();
- } else if (windowVector().elementAt(var0) instanceof InternalWindow) {
- ((InternalWindow)windowVector().elementAt(var0)).hide();
- }
- }
- }
- }
-
- public static void showWindows() {
- int var0 = windowVector().count();
- if (var0 >= 1) {
- while(true) {
- --var0;
- if (var0 < 0) {
- return;
- }
-
- ((Window)windowVector().elementAt(var0)).show();
- }
- }
- }
- }
-