home *** CD-ROM | disk | FTP | other *** search
/ Popular Software (Premium Edition) / mycd.iso / INTERNET / NETSCAP4.06 / CP32E406.EXE / nav40.z / ifc11.jar / netscape / constructor / ViewProxy.class (.txt) < prev   
Encoding:
Java Class File  |  1998-08-13  |  5.1 KB  |  155 lines

  1. package netscape.constructor;
  2.  
  3. import netscape.application.Application;
  4. import netscape.application.Color;
  5. import netscape.application.Font;
  6. import netscape.application.Graphics;
  7. import netscape.application.LineBorder;
  8. import netscape.application.Target;
  9. import netscape.application.View;
  10. import netscape.util.ClassInfo;
  11. import netscape.util.Codable;
  12. import netscape.util.CodingException;
  13. import netscape.util.Decoder;
  14. import netscape.util.Encoder;
  15. import netscape.util.Vector;
  16.  
  17. public class ViewProxy extends View implements Target, Codable {
  18.    String viewClassName;
  19.    String[] commands;
  20.    String shortName;
  21.    private View _replacingView;
  22.    public static final String CLASS_NAME_KEY = "viewClassName";
  23.    public static final String COMMANDS_KEY = "commands";
  24.    public static final String VIEWPROXY_CLASS_NAME = "netscape.constructor.ViewProxy";
  25.  
  26.    public ViewProxy() {
  27.       this(0, 0, 0, 0);
  28.    }
  29.  
  30.    public ViewProxy(int var1, int var2, int var3, int var4) {
  31.       super(var1, var2, var3, var4);
  32.       this.commands = new String[0];
  33.       this.setViewClassName("netscape.constructor.ViewProxy");
  34.    }
  35.  
  36.    public void setViewClassName(String var1) {
  37.       this.viewClassName = var1;
  38.       if (this.viewClassName == null || "".equals(this.viewClassName)) {
  39.          this.viewClassName = "netscape.constructor.ViewProxy";
  40.       }
  41.  
  42.       int var2 = this.viewClassName.lastIndexOf(46);
  43.       if (var2 != -1) {
  44.          this.shortName = this.viewClassName.substring(var2 + 1);
  45.       } else {
  46.          this.shortName = this.viewClassName;
  47.       }
  48.    }
  49.  
  50.    public String viewClassName() {
  51.       return this.viewClassName;
  52.    }
  53.  
  54.    public void setCommands(String[] var1) {
  55.       if (var1 != null) {
  56.          this.commands = var1;
  57.       } else {
  58.          this.commands = new String[0];
  59.       }
  60.    }
  61.  
  62.    public String[] commands() {
  63.       return this.commands;
  64.    }
  65.  
  66.    public void drawView(Graphics var1) {
  67.       var1.setColor(Color.gray);
  68.       var1.fillRect(((View)this).localBounds());
  69.       var1.setColor(Color.white);
  70.       var1.setFont(Font.defaultFont());
  71.       var1.drawStringInRect(this.shortName, ((View)this).localBounds(), 1);
  72.       LineBorder.blackLine().drawInRect(var1, ((View)this).localBounds());
  73.    }
  74.  
  75.    public boolean isTransparent() {
  76.       return false;
  77.    }
  78.  
  79.    public void performCommand(String var1, Object var2) {
  80.    }
  81.  
  82.    public void describeClassInfo(ClassInfo var1) {
  83.       super.describeClassInfo(var1);
  84.       var1.addClass("netscape.constructor.ViewProxy", 1);
  85.       var1.addField("viewClassName", (byte)16);
  86.       var1.addField("commands", (byte)17);
  87.    }
  88.  
  89.    public void encode(Encoder var1) throws CodingException {
  90.       super.encode(var1);
  91.       var1.encodeString("viewClassName", this.viewClassName);
  92.       var1.encodeStringArray("commands", this.commands, 0, this.commands.length);
  93.    }
  94.  
  95.    public void decode(Decoder var1) throws CodingException {
  96.       super.decode(var1);
  97.       this.setViewClassName(var1.decodeString("viewClassName"));
  98.       this.setCommands(var1.decodeStringArray("commands"));
  99.       if (!(Application.application() instanceof Constructor) || !((Constructor)Application.application()).inConstructionMode() && !"netscape.constructor.ViewProxy".equals(this.viewClassName)) {
  100.          try {
  101.             Application var3 = Application.application();
  102.             Class var2;
  103.             if (var3 != null) {
  104.                var2 = var3.classForName(this.viewClassName);
  105.             } else {
  106.                var2 = Class.forName(this.viewClassName);
  107.             }
  108.  
  109.             if (var2 != null) {
  110.                Object var4 = var2.newInstance();
  111.                if (!(var4 instanceof View)) {
  112.                   System.err.println("CustomView: " + this + " decode error: " + this.viewClassName + " is not a View subclass.");
  113.                   return;
  114.                }
  115.  
  116.                this._replacingView = (View)var4;
  117.                var1.replaceObject(this._replacingView);
  118.                return;
  119.             }
  120.          } catch (InstantiationException var5) {
  121.             return;
  122.          } catch (ClassNotFoundException var6) {
  123.             return;
  124.          } catch (IllegalAccessException var7) {
  125.          }
  126.  
  127.       }
  128.    }
  129.  
  130.    public void finishDecoding() throws CodingException {
  131.       super.finishDecoding();
  132.       if (this._replacingView != null) {
  133.          this.setAttributesToReplacingView(this._replacingView);
  134.       }
  135.  
  136.       this._replacingView = null;
  137.    }
  138.  
  139.    public void setAttributesToReplacingView(View var1) {
  140.       Vector var2 = ((View)this).subviews();
  141.       var1.setBounds(super.bounds);
  142.       var1.setHorizResizeInstruction(((View)this).horizResizeInstruction());
  143.       var1.setVertResizeInstruction(((View)this).vertResizeInstruction());
  144.       var1.setBuffered(((View)this).isBuffered());
  145.       if (var2 != null) {
  146.          int var4 = var2.count();
  147.  
  148.          for(int var3 = 0; var3 < var4; ++var3) {
  149.             var1.addSubview((View)var2.elementAt(var3));
  150.          }
  151.       }
  152.  
  153.    }
  154. }
  155.