home *** CD-ROM | disk | FTP | other *** search
/ Computer Shopper 139 / dpcs0999.iso / Web / CFserver / data1.cab / Java / CFJava.cab / CFJavaRuntime.cab / netscape / constructor / Plan.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-10-01  |  15.8 KB  |  826 lines

  1. package netscape.constructor;
  2.  
  3. import java.io.BufferedInputStream;
  4. import java.io.BufferedOutputStream;
  5. import java.io.FileInputStream;
  6. import java.io.FileOutputStream;
  7. import java.io.IOException;
  8. import java.io.InputStream;
  9. import java.io.OutputStream;
  10. import java.net.URL;
  11. import netscape.application.Application;
  12. import netscape.application.Color;
  13. import netscape.application.ExtendedTarget;
  14. import netscape.application.ExternalWindow;
  15. import netscape.application.InternalWindow;
  16. import netscape.application.Rect;
  17. import netscape.application.RootView;
  18. import netscape.application.Size;
  19. import netscape.application.Target;
  20. import netscape.application.View;
  21. import netscape.util.Archive;
  22. import netscape.util.Archiver;
  23. import netscape.util.ClassInfo;
  24. import netscape.util.Codable;
  25. import netscape.util.CodingException;
  26. import netscape.util.Decoder;
  27. import netscape.util.DeserializationException;
  28. import netscape.util.Encoder;
  29. import netscape.util.Enumeration;
  30. import netscape.util.Hashtable;
  31. import netscape.util.Unarchiver;
  32. import netscape.util.Vector;
  33.  
  34. public class Plan implements ExtendedTarget, Codable, Cloneable {
  35.    Archive archiveData;
  36.    TargetProxyManager targetProxyManager;
  37.    Hashtable nameToComponent;
  38.    Hashtable objectToBounds;
  39.    Vector rootComponents;
  40.    Vector components;
  41.    int versionNumber;
  42.    Size documentSize;
  43.    String planURL;
  44.    int archiveFormat;
  45.    boolean validArchive;
  46.    boolean validObjects;
  47.    Color backgroundColor;
  48.    public static final int UNKNOWN_TYPE = 0;
  49.    public static final int ASCII_TYPE = 1;
  50.    public static final int BINARY_TYPE = 2;
  51.    public static final String ASCII_FILE_EXTENSION = "plana";
  52.    public static final String BINARY_FILE_EXTENSION = "planb";
  53.    public static final String NAME_TO_COMPONENT_KEY = "nameToComponent";
  54.    public static final String OBJECT_TO_BOUNDS_KEY = "objectToBounds";
  55.    public static final String ROOT_COMPONENTS_KEY = "rootComponents";
  56.    public static final String ALL_COMPONENTS_KEY = "allComponents";
  57.    public static final String VERSION_NUMBER_KEY = "versionNumber";
  58.    public static final String DOCUMENT_SIZE_KEY = "documentSize";
  59.    public static final String BACKGROUND_COLOR_KEY = "backgroundColor";
  60.    public static final int CURRENT_VERSION_NUMBER = 2;
  61.  
  62.    public static Plan createPlan(String var0) {
  63.       Plan var1;
  64.       try {
  65.          var1 = new Plan(var0);
  66.       } catch (IOException var2) {
  67.          var1 = null;
  68.       }
  69.  
  70.       return var1;
  71.    }
  72.  
  73.    public static Plan createPlan(String var0, Hashtable var1) {
  74.       Plan var2;
  75.       try {
  76.          var2 = new Plan(var0, var1);
  77.       } catch (IOException var3) {
  78.          var2 = null;
  79.       }
  80.  
  81.       return var2;
  82.    }
  83.  
  84.    public static Plan createPlan(String var0, Target var1) {
  85.       Plan var2;
  86.       try {
  87.          var2 = new Plan(var0, var1);
  88.       } catch (IOException var3) {
  89.          var2 = null;
  90.       }
  91.  
  92.       return var2;
  93.    }
  94.  
  95.    public static Plan createPlan(InputStream var0, int var1) {
  96.       Plan var2;
  97.       try {
  98.          var2 = new Plan(var0, var1);
  99.       } catch (IOException var3) {
  100.          var2 = null;
  101.       }
  102.  
  103.       return var2;
  104.    }
  105.  
  106.    public Plan() {
  107.       this.archiveData = null;
  108.       this.targetProxyManager = null;
  109.       this.nameToComponent = null;
  110.       this.objectToBounds = null;
  111.       this.rootComponents = null;
  112.       this.components = null;
  113.       this.documentSize = null;
  114.       this.validArchive = false;
  115.       this.validObjects = false;
  116.       this.planURL = null;
  117.       this.versionNumber = 2;
  118.       this.archiveFormat = 0;
  119.       this.backgroundColor = Color.lightGray;
  120.    }
  121.  
  122.    public Plan(String var1) throws IOException {
  123.       this.validArchive = false;
  124.       this.validObjects = false;
  125.       if (var1 != null && var1.length() >= 1) {
  126.          InputStream var2 = this.streamFromURL(var1);
  127.          this.initFrom(var2, this.archiveFormat);
  128.          this.planURL = new String(var1);
  129.          if (this.validArchive) {
  130.             this.unarchiveObjects();
  131.          }
  132.  
  133.       }
  134.    }
  135.  
  136.    public Plan(String var1, Hashtable var2) throws IOException {
  137.       this.validArchive = false;
  138.       this.validObjects = false;
  139.       if (var1 != null && var1.length() >= 1) {
  140.          InputStream var3 = this.streamFromURL(var1);
  141.          this.initFrom(var3, this.archiveFormat);
  142.          this.planURL = new String(var1);
  143.          if (this.validArchive) {
  144.             this.unarchiveObjects(var2);
  145.          }
  146.  
  147.       }
  148.    }
  149.  
  150.    public Plan(String var1, Target var2) throws IOException {
  151.       this.validArchive = false;
  152.       this.validObjects = false;
  153.       if (var1 != null && var1.length() >= 1) {
  154.          InputStream var3 = this.streamFromURL(var1);
  155.          this.initFrom(var3, this.archiveFormat);
  156.          this.planURL = new String(var1);
  157.          if (this.validArchive) {
  158.             this.unarchiveObjects(var2);
  159.          }
  160.  
  161.       }
  162.    }
  163.  
  164.    public Plan(InputStream var1, int var2) throws IOException {
  165.       this.initFrom(var1, var2);
  166.    }
  167.  
  168.    protected void initFrom(InputStream var1, int var2) throws IOException {
  169.       this.archiveFormat = var2;
  170.       this.validArchive = false;
  171.       this.validObjects = false;
  172.       this.planURL = null;
  173.       this.versionNumber = 2;
  174.       if (var1 != null) {
  175.          this.archiveData = this.archiveFromStream(var1, var2);
  176.          if (this.archiveData != null) {
  177.             this.validArchive = true;
  178.          }
  179.  
  180.       }
  181.    }
  182.  
  183.    public void releaseObjects() {
  184.       this.targetProxyManager = null;
  185.       this.nameToComponent = null;
  186.       this.objectToBounds = null;
  187.       this.rootComponents = null;
  188.       this.components = null;
  189.       this.documentSize = null;
  190.       this.validObjects = false;
  191.    }
  192.  
  193.    public boolean unarchiveObjects(Hashtable var1) {
  194.       this.validObjects = false;
  195.       if (!this.validArchive) {
  196.          return this.validObjects;
  197.       } else {
  198.          this.validObjects = this.unarchiveFrom(this.archiveData, var1);
  199.          if (this.validObjects) {
  200.             this.finishUnarchiving();
  201.          }
  202.  
  203.          return this.validObjects;
  204.       }
  205.    }
  206.  
  207.    public boolean unarchiveObjects(Target var1) {
  208.       Hashtable var2 = new Hashtable(1);
  209.       var2.put("__nEdEtCoDe", var1);
  210.       return this.unarchiveObjects(var2);
  211.    }
  212.  
  213.    public boolean unarchiveObjects() {
  214.       return this.unarchiveObjects((Hashtable)null);
  215.    }
  216.  
  217.    protected void finishUnarchiving() {
  218.       int var1 = this.rootComponents().count();
  219.  
  220.       while(true) {
  221.          --var1;
  222.          if (var1 < 0) {
  223.             return;
  224.          }
  225.  
  226.          if (this.rootComponents().elementAt(var1) instanceof Script) {
  227.             Script var2 = (Script)this.rootComponents().elementAt(var1);
  228.             if (var2.isUsingLiveConnect()) {
  229.                var2.setNamedObjects(this.nameToComponent());
  230.             }
  231.          }
  232.       }
  233.    }
  234.  
  235.    public TargetProxyManager targetProxyManager() {
  236.       if (this.targetProxyManager == null) {
  237.          this.targetProxyManager = new TargetProxyManager();
  238.       }
  239.  
  240.       return this.targetProxyManager;
  241.    }
  242.  
  243.    public void setTargetProxyManager(TargetProxyManager var1) {
  244.       this.targetProxyManager = var1;
  245.    }
  246.  
  247.    public Hashtable nameToComponent() {
  248.       if (this.nameToComponent == null) {
  249.          this.nameToComponent = new Hashtable();
  250.       }
  251.  
  252.       return this.nameToComponent;
  253.    }
  254.  
  255.    public void setNameToComponent(Hashtable var1) {
  256.       this.nameToComponent = (Hashtable)var1.clone();
  257.    }
  258.  
  259.    public Object componentNamed(String var1) {
  260.       return this.nameToComponent().get(var1);
  261.    }
  262.  
  263.    public Hashtable objectToBounds() {
  264.       if (this.objectToBounds == null) {
  265.          this.objectToBounds = new Hashtable();
  266.       }
  267.  
  268.       return this.objectToBounds;
  269.    }
  270.  
  271.    public void setObjectToBounds(Hashtable var1) {
  272.       this.objectToBounds = var1;
  273.    }
  274.  
  275.    public Vector rootComponents() {
  276.       if (this.rootComponents == null) {
  277.          this.rootComponents = new Vector();
  278.       }
  279.  
  280.       return this.rootComponents;
  281.    }
  282.  
  283.    public void setRootComponents(Vector var1) {
  284.       this.rootComponents = var1;
  285.    }
  286.  
  287.    public Vector components() {
  288.       if (this.components == null) {
  289.          this.components = new Vector();
  290.       }
  291.  
  292.       return this.components;
  293.    }
  294.  
  295.    public void setComponents(Vector var1) {
  296.       this.components = var1;
  297.    }
  298.  
  299.    public int versionNumber() {
  300.       return this.versionNumber;
  301.    }
  302.  
  303.    public void setVersionNumber(int var1) {
  304.       this.versionNumber = var1;
  305.    }
  306.  
  307.    public Size size() {
  308.       if (this.documentSize == null) {
  309.          this.documentSize = new Size(0, 0);
  310.       }
  311.  
  312.       return this.documentSize;
  313.    }
  314.  
  315.    public void setSize(Size var1) {
  316.       this.documentSize = var1;
  317.    }
  318.  
  319.    public void setSize(int var1, int var2) {
  320.       this.documentSize = new Size(var1, var2);
  321.    }
  322.  
  323.    public String url() {
  324.       return this.planURL;
  325.    }
  326.  
  327.    public void setURL(String var1) {
  328.       this.planURL = var1;
  329.    }
  330.  
  331.    public int archiveFormat() {
  332.       return this.archiveFormat;
  333.    }
  334.  
  335.    public void setArchiveFormat(int var1) {
  336.       this.archiveFormat = var1;
  337.    }
  338.  
  339.    public void setValidArchive(boolean var1) {
  340.       this.validArchive = var1;
  341.    }
  342.  
  343.    public boolean isValidArchive() {
  344.       return this.validArchive;
  345.    }
  346.  
  347.    public void setValidObjects(boolean var1) {
  348.       this.validObjects = var1;
  349.    }
  350.  
  351.    public boolean hasValidObjects() {
  352.       return this.validObjects;
  353.    }
  354.  
  355.    public Archive archiveData() {
  356.       return this.archiveData;
  357.    }
  358.  
  359.    public void setArchiveData(Archive var1) {
  360.       this.archiveData = var1;
  361.    }
  362.  
  363.    public Color backgroundColor() {
  364.       return this.backgroundColor;
  365.    }
  366.  
  367.    public void setBackgroundColor(Color var1) {
  368.       this.backgroundColor = var1;
  369.    }
  370.  
  371.    public boolean save() {
  372.       boolean var2 = false;
  373.       if (this.planURL != null && !this.planURL.equals("") && (this.archiveFormat == 1 || this.archiveFormat == 2)) {
  374.          try {
  375.             BufferedOutputStream var1 = new BufferedOutputStream(new FileOutputStream(this.planURL));
  376.             var2 = this.saveToStream(var1, this.archiveFormat);
  377.             ((OutputStream)var1).close();
  378.             return var2;
  379.          } catch (IOException var4) {
  380.             ((Throwable)var4).printStackTrace(System.err);
  381.             return var2;
  382.          }
  383.       } else {
  384.          return var2;
  385.       }
  386.    }
  387.  
  388.    public boolean saveToStream(OutputStream var1, int var2) {
  389.       if (var1 == null) {
  390.          return false;
  391.       } else if (var2 != 1 && var2 != 2) {
  392.          return false;
  393.       } else {
  394.          Archive var3 = new Archive();
  395.  
  396.          try {
  397.             this.archiveTo(var3);
  398.             if (var2 == 1) {
  399.                var3.writeASCII(var1, true);
  400.             } else {
  401.                var3.write(var1);
  402.             }
  403.  
  404.             return true;
  405.          } catch (IOException var5) {
  406.             ((Throwable)var5).printStackTrace(System.err);
  407.             return false;
  408.          } catch (CodingException var6) {
  409.             ((Throwable)var6).printStackTrace(System.err);
  410.             return false;
  411.          }
  412.       }
  413.    }
  414.  
  415.    protected int archiveFormatOf(String var1) {
  416.       if (var1 != null && var1.length() >= 1) {
  417.          if (var1.endsWith("planb")) {
  418.             return 2;
  419.          } else {
  420.             return var1.endsWith("plana") ? 1 : 0;
  421.          }
  422.       } else {
  423.          return 0;
  424.       }
  425.    }
  426.  
  427.    protected InputStream streamFromURL(String var1) throws IOException {
  428.       BufferedInputStream var2 = null;
  429.       boolean var5 = false;
  430.       boolean var6 = false;
  431.       boolean var7 = false;
  432.       boolean var8 = false;
  433.       String var9 = var1;
  434.       if (var1 != null && var1.length() != 0) {
  435.          int var3 = this.archiveFormatOf(var1);
  436.          if (var3 == 1) {
  437.             var6 = true;
  438.          } else if (var3 == 2) {
  439.             var7 = true;
  440.          } else {
  441.             var8 = true;
  442.          }
  443.  
  444.          do {
  445.             var5 = false;
  446.  
  447.             try {
  448.                URL var15 = new URL(var1);
  449.                var2 = new BufferedInputStream(var15.openStream());
  450.             } catch (IOException var13) {
  451.                try {
  452.                   URL var14 = new URL(Application.application().codeBase(), var1);
  453.                   var2 = new BufferedInputStream(var14.openStream());
  454.                } catch (IOException var12) {
  455.                   try {
  456.                      Object var4 = null;
  457.                      var2 = new BufferedInputStream(new FileInputStream(var1));
  458.                   } catch (IOException var11) {
  459.                      if (!var7 && var8) {
  460.                         var1 = var9 + "." + "planb";
  461.                         var7 = true;
  462.                         var5 = true;
  463.                         var3 = 2;
  464.                      } else {
  465.                         if (var6 || !var8) {
  466.                            throw var11;
  467.                         }
  468.  
  469.                         var1 = var9 + "." + "plana";
  470.                         var6 = true;
  471.                         var5 = true;
  472.                         var3 = 1;
  473.                      }
  474.                   }
  475.                }
  476.             }
  477.          } while(var5);
  478.  
  479.          if (var2 != null) {
  480.             this.setArchiveFormat(var3);
  481.          }
  482.  
  483.          return var2;
  484.       } else {
  485.          return null;
  486.       }
  487.    }
  488.  
  489.    protected Archive archiveFromStream(InputStream var1, int var2) throws IOException {
  490.       if (var1 != null && (var2 == 1 || var2 == 2)) {
  491.          Archive var3 = new Archive();
  492.  
  493.          try {
  494.             if (var2 == 1) {
  495.                var3.readASCII(var1);
  496.             } else {
  497.                if (var2 != 2) {
  498.                   return null;
  499.                }
  500.  
  501.                var3.read(var1);
  502.             }
  503.  
  504.             return var3;
  505.          } catch (IOException var5) {
  506.             throw var5;
  507.          } catch (CodingException var6) {
  508.             ((Throwable)var6).printStackTrace(System.err);
  509.             return null;
  510.          } catch (DeserializationException var7) {
  511.             ((Throwable)var7).printStackTrace(System.err);
  512.             return null;
  513.          }
  514.       } else {
  515.          return null;
  516.       }
  517.    }
  518.  
  519.    protected boolean unarchiveFrom(Archive var1, Hashtable var2) {
  520.       if (var1 == null) {
  521.          return false;
  522.       } else {
  523.          Hashtable var5;
  524.          try {
  525.             int[] var4 = var1.rootIdentifiers();
  526.             Unarchiver var3 = new Unarchiver(var1);
  527.             if (var4.length > 1) {
  528.                this.targetProxyManager = (TargetProxyManager)var3.unarchiveIdentifier(var4[1]);
  529.                this.targetProxyManager.setTargets(var2);
  530.             }
  531.  
  532.             var5 = (Hashtable)var3.unarchiveIdentifier(var4[0]);
  533.          } catch (CodingException var7) {
  534.             ((Throwable)var7).printStackTrace(System.err);
  535.             return false;
  536.          }
  537.  
  538.          this.decodeDocumentInformation(var5);
  539.          return true;
  540.       }
  541.    }
  542.  
  543.    protected void decodeDocumentInformation(Hashtable var1) {
  544.       Integer var2 = (Integer)var1.get("versionNumber");
  545.       if (var2 != null) {
  546.          this.versionNumber = var2;
  547.       } else {
  548.          this.versionNumber = 0;
  549.       }
  550.  
  551.       if (this.versionNumber != 2) {
  552.          this.decodeBETADocumentInformation(var1);
  553.       } else {
  554.          this.nameToComponent = (Hashtable)var1.get("nameToComponent");
  555.          this.rootComponents = (Vector)var1.get("rootComponents");
  556.          this.components = (Vector)var1.get("allComponents");
  557.          this.documentSize = (Size)var1.get("documentSize");
  558.          this.objectToBounds = (Hashtable)var1.get("objectToBounds");
  559.          this.backgroundColor = (Color)var1.get("backgroundColor");
  560.       }
  561.    }
  562.  
  563.    protected void decodeBETADocumentInformation(Hashtable var1) {
  564.       String var2 = "components";
  565.       String var3 = "namedComponents";
  566.       String var4 = "documentSize";
  567.       String var5 = "nonViewBounds";
  568.       String var6 = "documentVersion";
  569.       String var7 = "builderComponents";
  570.       Vector var11 = (Vector)var1.get(var2);
  571.       if (var11 == null) {
  572.          System.err.println("Unsupported Plan file format. Could not find " + var2 + " in Hashtable: " + var1);
  573.       } else {
  574.          Integer var12 = (Integer)var1.get(var6);
  575.          if (var12 != null) {
  576.             this.versionNumber = var12;
  577.          } else {
  578.             this.versionNumber = 0;
  579.          }
  580.  
  581.          System.err.println("Upgrading plan file " + this.url() + " from version: " + this.versionNumber + " to: " + 2 + ".");
  582.          this.versionNumber = 2;
  583.          this.rootComponents = (Vector)var1.get(var2);
  584.          this.components = (Vector)var1.get(var7);
  585.          this.documentSize = (Size)var1.get(var4);
  586.          this.objectToBounds = (Hashtable)var1.get(var5);
  587.          this.backgroundColor = Color.lightGray;
  588.          Hashtable var10 = (Hashtable)var1.get(var3);
  589.          if (var10 != null) {
  590.             this.nameToComponent().clear();
  591.             Enumeration var8 = var10.keys();
  592.  
  593.             while(var8.hasMoreElements()) {
  594.                Object var9 = var8.nextElement();
  595.                this.nameToComponent().put((String)var10.get(var9), var9);
  596.             }
  597.          }
  598.  
  599.       }
  600.    }
  601.  
  602.    public void archiveObjectsToArchiveData() {
  603.       this.archiveData = new Archive();
  604.       this.archiveTo(this.archiveData);
  605.    }
  606.  
  607.    protected void archiveTo(Archive var1) {
  608.       Archiver var2 = new Archiver(var1);
  609.       Hashtable var3 = new Hashtable();
  610.       this.encodeDocumentInformation(var3);
  611.  
  612.       try {
  613.          var2.archiveRootObject(var3);
  614.          var2.archiveRootObject(this.targetProxyManager());
  615.       } catch (CodingException var5) {
  616.          ((Throwable)var5).printStackTrace();
  617.       }
  618.    }
  619.  
  620.    protected void encodeDocumentInformation(Hashtable var1) {
  621.       if (this.nameToComponent != null) {
  622.          var1.put("nameToComponent", this.nameToComponent);
  623.       } else {
  624.          var1.put("nameToComponent", new Hashtable());
  625.       }
  626.  
  627.       if (this.objectToBounds != null) {
  628.          var1.put("objectToBounds", this.objectToBounds);
  629.       } else {
  630.          var1.put("objectToBounds", new Hashtable());
  631.       }
  632.  
  633.       if (this.rootComponents != null) {
  634.          var1.put("rootComponents", this.rootComponents);
  635.       } else {
  636.          var1.put("rootComponents", new Vector(0));
  637.       }
  638.  
  639.       if (this.components != null) {
  640.          var1.put("allComponents", this.components);
  641.       } else {
  642.          var1.put("allComponents", new Vector(0));
  643.       }
  644.  
  645.       var1.put("versionNumber", new Integer(this.versionNumber));
  646.       if (this.documentSize != null) {
  647.          var1.put("documentSize", this.documentSize);
  648.       } else {
  649.          var1.put("documentSize", new Size(0, 0));
  650.       }
  651.  
  652.       if (this.backgroundColor != null) {
  653.          var1.put("backgroundColor", this.backgroundColor);
  654.       } else {
  655.          var1.put("backgroundColor", Color.lightGray);
  656.       }
  657.    }
  658.  
  659.    public void performCommand(String var1, Object var2) {
  660.    }
  661.  
  662.    public boolean canPerformCommand(String var1) {
  663.       return false;
  664.    }
  665.  
  666.    public void describeClassInfo(ClassInfo var1) {
  667.       var1.addClass("netscape.constructor.Plan", 2);
  668.       var1.addField("nameToComponent", (byte)18);
  669.       var1.addField("objectToBounds", (byte)18);
  670.       var1.addField("rootComponents", (byte)18);
  671.       var1.addField("allComponents", (byte)18);
  672.       var1.addField("versionNumber", (byte)18);
  673.       var1.addField("documentSize", (byte)18);
  674.       var1.addField("backgroundColor", (byte)18);
  675.    }
  676.  
  677.    public void encode(Encoder var1) throws CodingException {
  678.       var1.encodeObject("nameToComponent", this.nameToComponent);
  679.       var1.encodeObject("objectToBounds", this.objectToBounds);
  680.       var1.encodeObject("rootComponents", this.rootComponents);
  681.       var1.encodeObject("allComponents", this.components);
  682.       var1.encodeObject("versionNumber", new Integer(this.versionNumber));
  683.       var1.encodeObject("documentSize", this.documentSize);
  684.       var1.encodeObject("backgroundColor", this.backgroundColor);
  685.    }
  686.  
  687.    public void decode(Decoder var1) throws CodingException {
  688.       this.nameToComponent = (Hashtable)var1.decodeObject("nameToComponent");
  689.       this.objectToBounds = (Hashtable)var1.decodeObject("objectToBounds");
  690.       this.rootComponents = (Vector)var1.decodeObject("rootComponents");
  691.       this.components = (Vector)var1.decodeObject("allComponents");
  692.       Integer var2 = (Integer)var1.decodeObject("versionNumber");
  693.       if (var2 != null) {
  694.          this.versionNumber = var2;
  695.       } else {
  696.          this.versionNumber = 0;
  697.       }
  698.  
  699.       this.documentSize = (Size)var1.decodeObject("documentSize");
  700.       this.backgroundColor = (Color)var1.decodeObject("backgroundColor");
  701.    }
  702.  
  703.    public void finishDecoding() throws CodingException {
  704.    }
  705.  
  706.    public Object clone() {
  707.       Plan var1 = null;
  708.  
  709.       try {
  710.          var1 = (Plan)super.clone();
  711.       } catch (CloneNotSupportedException var5) {
  712.          System.err.println(var5);
  713.          ((Throwable)var5).printStackTrace();
  714.       }
  715.  
  716.       Hashtable var3 = new Hashtable(1);
  717.       var3.put("__nEdEtCoDeNonReplacing", new Object());
  718.       var1.targetProxyManager = null;
  719.       var1.nameToComponent = null;
  720.       var1.objectToBounds = null;
  721.       var1.rootComponents = null;
  722.       var1.components = null;
  723.       var1.documentSize = null;
  724.       var1.backgroundColor = null;
  725.       Archive var2 = new Archive();
  726.       this.archiveTo(var2);
  727.       var1.unarchiveFrom(var2, var3);
  728.       return var1;
  729.    }
  730.  
  731.    public Rect boundingRect() {
  732.       Rect var2 = null;
  733.       int var1 = this.rootComponents().count();
  734.  
  735.       while(true) {
  736.          --var1;
  737.          if (var1 < 0) {
  738.             if (var2 == null) {
  739.                return new Rect(0, 0, 0, 0);
  740.             }
  741.  
  742.             return var2;
  743.          }
  744.  
  745.          Object var3 = this.rootComponents().elementAt(var1);
  746.          if (var3 instanceof View && this.constructorComponentWasView(var3) && !(var3 instanceof InternalWindow)) {
  747.             if (var2 == null) {
  748.                var2 = new Rect(((View)var3).bounds);
  749.             } else {
  750.                var2.unionWith(((View)var3).bounds);
  751.             }
  752.          }
  753.       }
  754.    }
  755.  
  756.    public void sizeToFit() {
  757.       Rect var1 = this.boundingRect();
  758.       this.moveBy(-var1.x, -var1.y);
  759.       this.setSize(new Size(var1.width, var1.height));
  760.    }
  761.  
  762.    public void moveBy(int var1, int var2) {
  763.       int var3 = this.rootComponents().count();
  764.  
  765.       while(true) {
  766.          --var3;
  767.          if (var3 < 0) {
  768.             return;
  769.          }
  770.  
  771.          Object var4 = this.rootComponents().elementAt(var3);
  772.          if (var4 instanceof View && this.constructorComponentWasView(var4)) {
  773.             ((View)var4).moveBy(var1, var2);
  774.          }
  775.       }
  776.    }
  777.  
  778.    public void addContentsToView(View var1) {
  779.       int var3 = this.rootComponents().count();
  780.  
  781.       for(int var2 = 0; var2 < var3; ++var2) {
  782.          Object var4 = this.rootComponents().elementAt(var2);
  783.          if (var4 instanceof InternalWindow && this.constructorComponentWasView(var4)) {
  784.             InternalWindow var5 = (InternalWindow)var4;
  785.             if (var1 instanceof RootView) {
  786.                var5.setRootView((RootView)var1);
  787.                if (var5.onscreenAtStartup()) {
  788.                   var5.show();
  789.                }
  790.             }
  791.          } else if ((this.constructorComponentWasView(var4) || !(var4 instanceof View)) && var4 instanceof View) {
  792.             var1.addSubview((View)var4);
  793.          }
  794.       }
  795.  
  796.    }
  797.  
  798.    protected boolean constructorComponentWasView(Object var1) {
  799.       return !this.objectToBounds.containsKey(var1);
  800.    }
  801.  
  802.    public View viewWithContents() {
  803.       View var1 = new View(0, 0, this.size().width, this.size().height);
  804.       this.addContentsToView(var1);
  805.       return var1;
  806.    }
  807.  
  808.    public InternalWindow internalWindowWithContents() {
  809.       InternalWindow var1 = new InternalWindow();
  810.       Size var2 = var1.windowSizeForContentSize(this.size().width, this.size().height);
  811.       var1.setBounds(0, 0, var2.width, var2.height);
  812.       var1.contentView().setBackgroundColor(this.backgroundColor());
  813.       this.addContentsToView(var1.contentView());
  814.       return var1;
  815.    }
  816.  
  817.    public ExternalWindow externalWindowWithContents() {
  818.       ExternalWindow var1 = new ExternalWindow();
  819.       Size var2 = var1.windowSizeForContentSize(this.size().width, this.size().height);
  820.       var1.setBounds(0, 0, var2.width, var2.height);
  821.       var1.rootView().setColor(this.backgroundColor());
  822.       this.addContentsToView(var1.rootView());
  823.       return var1;
  824.    }
  825. }
  826.