home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 2004 May / DPPCPRO0504.ISO / May / Seatools / SeaTools.iso / tools / en / webhelp / webhelp.jar / XMLConsumer / SecondaryDialog.class (.txt) < prev    next >
Encoding:
Java Class File  |  2002-04-17  |  4.6 KB  |  190 lines

  1. package XMLConsumer;
  2.  
  3. import hhapplet.BsscFontFixPatch;
  4. import hhapplet.IActionSink;
  5. import hhapplet.ResourceLib;
  6. import hhapplet.URLFileHandler;
  7. import java.awt.BorderLayout;
  8. import java.awt.Button;
  9. import java.awt.Color;
  10. import java.awt.Component;
  11. import java.awt.Container;
  12. import java.awt.Dimension;
  13. import java.awt.Event;
  14. import java.awt.Font;
  15. import java.awt.Frame;
  16. import java.awt.Label;
  17. import java.awt.List;
  18. import java.awt.Panel;
  19. import java.awt.Point;
  20. import java.awt.Toolkit;
  21. import java.awt.Window;
  22. import java.net.MalformedURLException;
  23. import java.net.URL;
  24. import java.util.Vector;
  25.  
  26. public class SecondaryDialog extends Frame {
  27.    private Button m_btnDisplay = null;
  28.    private Button m_btnCancel = null;
  29.    private List m_list = null;
  30.    private IActionSink m_accepter;
  31.    private Vector m_vEntries;
  32.    private URL m_baseURL;
  33.    private String m_target;
  34.    private boolean m_bIsIE3 = false;
  35.    private Point m_pntPosition;
  36.  
  37.    public boolean gotFocus(Event var1, Object var2) {
  38.       if (var1.target == this) {
  39.          this.m_list.requestFocus();
  40.          return true;
  41.       } else {
  42.          return super.gotFocus(var1, var2);
  43.       }
  44.    }
  45.  
  46.    public void showTopic() {
  47.       ((Component)this).setBackground(new Color(192, 192, 192));
  48.       if (!System.getProperty("os.name").startsWith("Windows") && !System.getProperty("os.name").startsWith("Mac OS")) {
  49.          this.show();
  50.       }
  51.  
  52.       short var1 = 300;
  53.       short var2 = 240;
  54.       Dimension var3 = Toolkit.getDefaultToolkit().getScreenSize();
  55.       int var4 = var3.width / 2 - var1 / 2;
  56.       int var5 = var3.height / 2 - var2 / 2;
  57.       if (!System.getProperty("os.name").startsWith("Windows") && !System.getProperty("os.name").startsWith("Mac OS")) {
  58.          ((Component)this).reshape(var4, var5, var1, var2);
  59.       } else {
  60.          ((Component)this).resize(var1, var2);
  61.       }
  62.  
  63.       this.m_pntPosition = new Point(var4, var5);
  64.       if (System.getProperty("java.vendor").startsWith("Microsoft") && System.getProperty("java.version").startsWith("1.0")) {
  65.          this.m_bIsIE3 = true;
  66.       }
  67.  
  68.       int var6 = BsscFontFixPatch.GetFontSize();
  69.       this.m_list.setFont(new Font(BsscFontFixPatch.GetFontName(), 0, var6));
  70.  
  71.       for(int var7 = 0; var7 < this.m_vEntries.size(); ++var7) {
  72.          this.m_list.addItem(((Topic)this.m_vEntries.elementAt(var7)).getName());
  73.       }
  74.  
  75.       this.m_list.select(0);
  76.       Panel var8 = new Panel();
  77.       ((Container)var8).add(this.m_btnDisplay);
  78.       ((Container)var8).add(this.m_btnCancel);
  79.       ((Container)this).setLayout(new BorderLayout(5, 5));
  80.       this.m_list.setBackground(Color.white);
  81.       ((Container)this).add("North", new Label("   " + ResourceLib.GetRes("RelateTopicListPrompt")));
  82.       ((Container)this).add("Center", this.m_list);
  83.       ((Container)this).add("South", var8);
  84.       if (!System.getProperty("os.name").startsWith("Windows") && !System.getProperty("os.name").startsWith("Mac OS")) {
  85.          ((Window)this).toFront();
  86.       } else {
  87.          ((Component)this).reshape(var4, var5, var1, var2);
  88.          ((Component)this).move(var4, var5);
  89.          ((Frame)this).setResizable(false);
  90.          this.show();
  91.       }
  92.    }
  93.  
  94.    public SecondaryDialog(IActionSink var1, URL var2, String var3, Vector var4) {
  95.       super(ResourceLib.GetRes("TopicsFound"));
  96.       this.m_accepter = var1;
  97.       this.m_vEntries = var4;
  98.       this.m_baseURL = var2;
  99.       this.m_btnDisplay = new Button(ResourceLib.GetRes("Display"));
  100.       this.m_btnCancel = new Button(ResourceLib.GetRes("Cancel"));
  101.       this.m_list = new List();
  102.       this.m_target = var3;
  103.    }
  104.  
  105.    public List getList() {
  106.       return this.m_list;
  107.    }
  108.  
  109.    protected void gotoSelectedIndex() {
  110.       int var1 = this.m_list.getSelectedIndex();
  111.       if (var1 != -1) {
  112.          try {
  113.             Topic var2 = (Topic)this.m_vEntries.elementAt(var1);
  114.             URL var3 = URLFileHandler.makeURL(this.m_baseURL, var2.getURL(), (String)null);
  115.             String var4 = var3.toString();
  116.             if (var4.indexOf("file:/\\\\") == 0) {
  117.                var4 = "file://" + var4.substring(8);
  118.                var3 = new URL(var4);
  119.             }
  120.  
  121.             Vector var5 = new Vector();
  122.             var5.addElement(var3.toString());
  123.             var5.addElement(this.m_target);
  124.             this.m_accepter.accept(var5);
  125.          } catch (MalformedURLException var6) {
  126.             ((Throwable)var6).printStackTrace();
  127.          }
  128.  
  129.          this.closeDialog();
  130.          ((Frame)this).dispose();
  131.       }
  132.  
  133.    }
  134.  
  135.    public void show() {
  136.       if (this.m_bIsIE3) {
  137.          Dimension var1 = ((Component)this).size();
  138.          ((Component)this).reshape(this.m_pntPosition.x, this.m_pntPosition.y, var1.width, var1.height);
  139.          super.show();
  140.          ((Component)this).reshape(this.m_pntPosition.x, this.m_pntPosition.y, var1.width, var1.height);
  141.       } else {
  142.          super.show();
  143.       }
  144.  
  145.       this.m_list.requestFocus();
  146.    }
  147.  
  148.    public boolean action(Event var1, Object var2) {
  149.       if (var1.target != this.m_btnDisplay && var1.target != this.m_list) {
  150.          if (var1.target == this.m_btnCancel) {
  151.             this.closeDialog();
  152.             return true;
  153.          } else {
  154.             return false;
  155.          }
  156.       } else {
  157.          this.gotoSelectedIndex();
  158.          return true;
  159.       }
  160.    }
  161.  
  162.    public void closeDialog() {
  163.       ((Frame)this).dispose();
  164.    }
  165.  
  166.    public boolean handleEvent(Event var1) {
  167.       if (!System.getProperty("java.version").startsWith("1.1.5") || !System.getProperty("java.vendor").startsWith("Netscape") || var1.id != 401 || var1.key != 10 || var1.target != this.m_btnDisplay && var1.target != this.m_btnCancel) {
  168.          if (var1.id == 201) {
  169.             this.closeDialog();
  170.             ((Frame)this).dispose();
  171.          } else {
  172.             if (var1.target == this.m_list && var1.key == 10 && var1.id == 401) {
  173.                this.gotoSelectedIndex();
  174.                return true;
  175.             }
  176.  
  177.             if (var1.key == 27 && var1.id == 402) {
  178.                this.closeDialog();
  179.                ((Frame)this).dispose();
  180.             }
  181.          }
  182.  
  183.          return super.handleEvent(var1);
  184.       } else {
  185.          this.action(var1, var1.target);
  186.          return true;
  187.       }
  188.    }
  189. }
  190.