View Javadoc

1   package org.catacomb.druid.gui.base;
2   
3   import org.catacomb.druid.event.ClosureListener;
4   import org.catacomb.druid.swing.DFrame;
5   import org.catacomb.interlish.structure.ActionRelay;
6   import org.catacomb.interlish.structure.ActionSource;
7   import org.catacomb.report.E;
8   
9   
10  import java.awt.Color;
11  import java.awt.Cursor;
12  import java.awt.Point;
13  
14  
15  public class DruFrame implements ActionSource, ClosureListener  {
16      static final long serialVersionUID = 1001;
17  
18      DruPanel druPanel;
19  
20      String id;
21  
22      ActionRelay actionRelay;
23  
24      boolean donePack;
25  
26      boolean hideOnClose;
27  
28      DFrame dFrame;
29  
30      Color backgroundColor;
31  
32  
33      public DruFrame(String s) {
34          dFrame = new DFrame(s);
35          dFrame.setClosureListener(this);
36          donePack = false;
37          hideOnClose = false;
38      }
39  
40      public DFrame getGUIPeer() {
41          return dFrame;
42      }
43  
44  
45      public void setPreferredSize(int w, int h) {
46          dFrame.setPreferredSize(w, h);
47      }
48  
49      public String toString() {
50          return "DruFrame " + id;
51      }
52  
53      public void pack() {
54          donePack = true;
55          dFrame.pack();
56      }
57  
58      public void packIfNecessary() {
59          if (!donePack) {
60              pack();
61          }
62      }
63  
64  
65  
66      public void setID(String s) {
67          id = s;
68      }
69  
70  
71      public String getID() {
72          return id;
73      }
74  
75  
76      public void setCloseActionHide() {
77          hideOnClose = true;
78      }
79  
80  
81      public void requestClose() {
82          if (hideOnClose) {
83              dFrame.setVisible(false);
84  
85          } else if (actionRelay == null) {
86              E.error("no action connector for this frame " + id);
87              dFrame.setVisible(true);
88  
89          } else {
90              actionRelay.action("requestClose");
91          }
92      }
93  
94  
95      public void closed() {
96          System.out.println("frame closed");
97      }
98  
99  
100 
101     public void setActionRelay(ActionRelay ar) {
102         actionRelay = ar;
103     }
104 
105 
106 
107     public void setDruMenuBar(DruMenuBar amb) {
108         dFrame.setJMenuBar(amb.getGUIPeer());
109     }
110 
111 
112     public void setDruPanel(DruPanel axp) {
113         druPanel = axp;
114         if (backgroundColor != null) {
115             druPanel.setFallbackBackgroundColor(backgroundColor);
116         }
117         dFrame.getContentPane().add("Center", axp.getGUIPeer());
118     }
119 
120 
121     public void setVisible(boolean b) {
122         dFrame.setVisible(b);
123     }
124 
125 
126     public void dispose() {
127         dFrame.dispose();
128     }
129 
130 
131     public void setBackgroundColor(Color bg) {
132         backgroundColor = bg;
133         dFrame.setBg(bg);
134     }
135 
136 
137     public void setTitle(String s) {
138         dFrame.setTitle(s);
139     }
140 
141 
142     public int[] getIntArraySize() {
143         return dFrame.getIntArraySize();
144     }
145 
146     public int[] getLocation() {
147         Point p = dFrame.getLocation();
148         int[] ret = {(int)(p.getX()), (int)(p.getY())};
149         return ret;
150     }
151 
152     public void setLocation(int x, int y) {
153         dFrame.setLocation(x, y);
154     }
155 
156     public void toFront() {
157         dFrame.toFront();
158 
159     }
160 
161     public void waitCursor() {
162         dFrame.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
163     }
164 
165     public void normalCursor() {
166         dFrame.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
167     }
168 
169     public Object getContent() {
170         return dFrame.getContentPane();
171     }
172 
173 
174 
175 }