summaryrefslogtreecommitdiff
path: root/NET/worlds/console/WebControl.java
blob: 588c453fcb72cb613ea64263b17358fa5ff20cea (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
package NET.worlds.console;

public class WebControl extends RenderCanvasOverlay {
   private final int ID_GO_BACK = 32768;
   private final int ID_GO_FORWARD = 32769;
   private final int ID_VIEW_STOP = 32770;
   private final int ID_VIEW_REFRESH = 32771;
   private final int ID_GO_HOME = 32772;
   private final int ID_EXIT = 32773;
   private WebControlImp imp = null;

   public WebControl(RenderCanvas pCanvas, boolean hasToolbar) throws NoWebControlException {
      super(pCanvas);

      try {
         this.imp = WebControlFactory.createWebControlImp(this.getNativeWindowHandle(), hasToolbar, false);
      } catch (NoWebControlException var4) {
         super.detach();
         throw var4;
      }
   }

   public WebControl(RenderCanvas pCanvas, int xPer, int yPer, boolean hasToolbar, boolean isFixedSize, boolean isBanner) throws NoWebControlException {
      super(pCanvas, xPer, yPer, isFixedSize, !isBanner);
      this.imp = WebControlFactory.createWebControlImp(this.getNativeWindowHandle(), hasToolbar, isBanner);
   }

   public boolean setURL(String pURL) {
      if (this.imp == null) {
         System.out.println("Null implementation in WebControl.setURL");
         return false;
      } else {
         return this.imp.setURL(pURL);
      }
   }

   public boolean setURL(String pURL, String pPostData) {
      if (this.imp == null) {
         System.out.println("Null implementation in WebControl.setURL");
         return false;
      } else {
         return pPostData != null && !pPostData.equals("") ? this.imp.setURL(pURL, pPostData) : this.imp.setURL(pURL);
      }
   }

   @Override
   protected void handleCommand(int commandID) {
      if (this.imp == null) {
         System.out.println("Now this should be impossible. Null imp in WebControl.handleCommand.");
      } else {
         switch (commandID) {
            case 32768:
               this.imp.goBack();
               break;
            case 32769:
               this.imp.goForward();
               break;
            case 32770:
               this.imp.stop();
               break;
            case 32771:
               this.imp.refresh();
               break;
            case 32772:
               this.imp.home();
               break;
            case 32773:
               this.detach();
         }
      }
   }

   @Override
   void detach() {
      if (this.imp != null) {
         this.imp.detach();
      }

      super.detach();
   }

   @Override
   void canvasResized(int parentX, int parentY) {
      super.canvasResized(parentX, parentY);
      if (this.imp == null) {
         System.out.println("Null imp in WebControl.canvasResized");
      } else {
         this.imp.resize(parentX, parentY, this.getXPercent(), this.getYPercent());
      }
   }
}