home *** CD-ROM | disk | FTP | other *** search
/ Computer Shopper 139 / dpcs0999.iso / Web / CFserver / data1.cab / Java / CFJava.cab / CFJavaRuntime.cab / netscape / constructor / ViewProxy.class (.txt) < prev   
Encoding:
Java Class File  |  1998-10-01  |  5.2 KB  |  148 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.             Class var2 = Class.forName(this.viewClassName);
  102.             if (var2 != null) {
  103.                Object var3 = var2.newInstance();
  104.                if (!(var3 instanceof View)) {
  105.                   System.err.println("CustomView: " + this + " decode error: " + this.viewClassName + " is not a View subclass.");
  106.                   return;
  107.                }
  108.  
  109.                this._replacingView = (View)var3;
  110.                var1.replaceObject(this._replacingView);
  111.                return;
  112.             }
  113.          } catch (InstantiationException var4) {
  114.             return;
  115.          } catch (ClassNotFoundException var5) {
  116.             return;
  117.          } catch (IllegalAccessException var6) {
  118.          }
  119.  
  120.       }
  121.    }
  122.  
  123.    public void finishDecoding() throws CodingException {
  124.       super.finishDecoding();
  125.       if (this._replacingView != null) {
  126.          this.setAttributesToReplacingView(this._replacingView);
  127.       }
  128.  
  129.       this._replacingView = null;
  130.    }
  131.  
  132.    public void setAttributesToReplacingView(View var1) {
  133.       Vector var2 = ((View)this).subviews();
  134.       var1.setBounds(super.bounds);
  135.       var1.setHorizResizeInstruction(((View)this).horizResizeInstruction());
  136.       var1.setVertResizeInstruction(((View)this).vertResizeInstruction());
  137.       var1.setBuffered(((View)this).isBuffered());
  138.       if (var2 != null) {
  139.          int var4 = var2.count();
  140.  
  141.          for(int var3 = 0; var3 < var4; ++var3) {
  142.             var1.addSubview((View)var2.elementAt(var3));
  143.          }
  144.       }
  145.  
  146.    }
  147. }
  148.