home *** CD-ROM | disk | FTP | other *** search
- package netscape.constructor;
-
- import netscape.application.Application;
- import netscape.application.Color;
- import netscape.application.Font;
- import netscape.application.Graphics;
- import netscape.application.LineBorder;
- import netscape.application.Target;
- import netscape.application.View;
- 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 ViewProxy extends View implements Target, Codable {
- String viewClassName;
- String[] commands;
- String shortName;
- private View _replacingView;
- public static final String CLASS_NAME_KEY = "viewClassName";
- public static final String COMMANDS_KEY = "commands";
- public static final String VIEWPROXY_CLASS_NAME = "netscape.constructor.ViewProxy";
-
- public ViewProxy() {
- this(0, 0, 0, 0);
- }
-
- public ViewProxy(int var1, int var2, int var3, int var4) {
- super(var1, var2, var3, var4);
- this.commands = new String[0];
- this.setViewClassName("netscape.constructor.ViewProxy");
- }
-
- public void setViewClassName(String var1) {
- this.viewClassName = var1;
- if (this.viewClassName == null || "".equals(this.viewClassName)) {
- this.viewClassName = "netscape.constructor.ViewProxy";
- }
-
- int var2 = this.viewClassName.lastIndexOf(46);
- if (var2 != -1) {
- this.shortName = this.viewClassName.substring(var2 + 1);
- } else {
- this.shortName = this.viewClassName;
- }
- }
-
- public String viewClassName() {
- return this.viewClassName;
- }
-
- public void setCommands(String[] var1) {
- if (var1 != null) {
- this.commands = var1;
- } else {
- this.commands = new String[0];
- }
- }
-
- public String[] commands() {
- return this.commands;
- }
-
- public void drawView(Graphics var1) {
- var1.setColor(Color.gray);
- var1.fillRect(((View)this).localBounds());
- var1.setColor(Color.white);
- var1.setFont(Font.defaultFont());
- var1.drawStringInRect(this.shortName, ((View)this).localBounds(), 1);
- LineBorder.blackLine().drawInRect(var1, ((View)this).localBounds());
- }
-
- public boolean isTransparent() {
- return false;
- }
-
- public void performCommand(String var1, Object var2) {
- }
-
- public void describeClassInfo(ClassInfo var1) {
- super.describeClassInfo(var1);
- var1.addClass("netscape.constructor.ViewProxy", 1);
- var1.addField("viewClassName", (byte)16);
- var1.addField("commands", (byte)17);
- }
-
- public void encode(Encoder var1) throws CodingException {
- super.encode(var1);
- var1.encodeString("viewClassName", this.viewClassName);
- var1.encodeStringArray("commands", this.commands, 0, this.commands.length);
- }
-
- public void decode(Decoder var1) throws CodingException {
- super.decode(var1);
- this.setViewClassName(var1.decodeString("viewClassName"));
- this.setCommands(var1.decodeStringArray("commands"));
- if (!(Application.application() instanceof Constructor) || !((Constructor)Application.application()).inConstructionMode() && !"netscape.constructor.ViewProxy".equals(this.viewClassName)) {
- try {
- Application var3 = Application.application();
- Class var2;
- if (var3 != null) {
- var2 = var3.classForName(this.viewClassName);
- } else {
- var2 = Class.forName(this.viewClassName);
- }
-
- if (var2 != null) {
- Object var4 = var2.newInstance();
- if (!(var4 instanceof View)) {
- System.err.println("CustomView: " + this + " decode error: " + this.viewClassName + " is not a View subclass.");
- return;
- }
-
- this._replacingView = (View)var4;
- var1.replaceObject(this._replacingView);
- return;
- }
- } catch (InstantiationException var5) {
- return;
- } catch (ClassNotFoundException var6) {
- return;
- } catch (IllegalAccessException var7) {
- }
-
- }
- }
-
- public void finishDecoding() throws CodingException {
- super.finishDecoding();
- if (this._replacingView != null) {
- this.setAttributesToReplacingView(this._replacingView);
- }
-
- this._replacingView = null;
- }
-
- public void setAttributesToReplacingView(View var1) {
- Vector var2 = ((View)this).subviews();
- var1.setBounds(super.bounds);
- var1.setHorizResizeInstruction(((View)this).horizResizeInstruction());
- var1.setVertResizeInstruction(((View)this).vertResizeInstruction());
- var1.setBuffered(((View)this).isBuffered());
- if (var2 != null) {
- int var4 = var2.count();
-
- for(int var3 = 0; var3 < var4; ++var3) {
- var1.addSubview((View)var2.elementAt(var3));
- }
- }
-
- }
- }
-