Clover coverage report - brownies library - 1.0-beta-1 Coverage timestamp: 月 8 16 2004 17:14:42 GMT+09:00 FRAMES NO FRAMES |
file stats: | LOC: | 149 |  | Methods: | 10
| NCLOC: | 78 |  | Classes: | 1
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover
Source file | Conditionals | Statements | Methods | TOTAL
ContentDialog.java | 0% | 0% | 0% | 0% |

1 |  |
     /*
2 |  |
      * joey and its relative products are published under the terms
3 |  |
      * of the Apache Software License.
4 |  |
      *
5 |  |
      * Created on 2004/07/11 21:11:11
6 |  |
      */
7 |  |
     package org.asyrinx.brownie.swing.content;
8 |  |
9 |  |
     import java.awt.Component;
10 |  |
     import java.awt.Container;
11 |  |
     import java.awt.Dialog;
12 |  |
     import java.awt.Frame;
13 |  |
     import java.awt.HeadlessException;
14 |  |
     import java.awt.Window;
15 |  |
16 |  |
     import javax.swing.JDialog;
17 |  |
     import javax.swing.JPanel;
18 |  |
     import javax.swing.SwingUtilities;
19 |  |
20 |  |
     import org.asyrinx.brownie.swing.GuiRuntimeException;
21 |  |
22 |  |
     /**
23 |  |
      * @author akima
24 |  |
      */
25 |  |
     public class ContentDialog extends JDialog {
26 |  |
27 |  |
         protected final Component content;
28 |  |
29 |  |
         /**
30 |  |
          *
31 |  |
          * @param content
32 |  |
          * @param owner
33 |  |
          * @param title
34 |  |
          * @param modal
35 |  |
          * @throws HeadlessException
36 |  |
          */
37 | 0 |
         public ContentDialog(Component content, Dialog owner, String title,
38 |  |
                 boolean modal) throws HeadlessException {
39 | 0 |
             super(owner, title, modal);
40 | 0 |
             this.content = content;
41 | 0 |
             intiPane();
42 |  |
         }
43 |  |
44 |  |
         /**
45 |  |
          * @param content
46 |  |
          * @param owner
47 |  |
          * @param title
48 |  |
          * @param modal
49 |  |
          * @throws java.awt.HeadlessException
50 |  |
          */
51 | 0 |
         public ContentDialog(Component content, Frame owner, String title,
52 |  |
                 boolean modal) throws HeadlessException {
53 | 0 |
             super(owner, title, modal);
54 | 0 |
             this.content = content;
55 | 0 |
             intiPane();
56 |  |
         }
57 |  |
58 |  |
         /**
59 |  |
          *
60 |  |
          * @param content
61 |  |
          * @param owner
62 |  |
          * @param title
63 |  |
          * @param modal
64 |  |
          * @return
65 |  |
          */
66 | 0 |
         public static ContentDialog create(Component content, Component owner,
67 |  |
                 String title, boolean modal) {
68 | 0 |
             if (owner instanceof Frame) {
69 | 0 |
                 return new ContentDialog(content, (Frame) owner, title, modal);
70 | 0 |
             } else if (owner instanceof Dialog) {
71 | 0 |
                 return new ContentDialog(content, (Dialog) owner, title, modal);
72 |  |
             } else {
73 | 0 |
                 final Window window = SwingUtilities.getWindowAncestor(owner);
74 | 0 |
                 if (window instanceof Frame) {
75 | 0 |
                     return new ContentDialog(content, (Frame) window, title, modal);
76 | 0 |
                 } else if (window instanceof Dialog) {
77 | 0 |
                     return new ContentDialog(content, (Dialog) window, title, modal);
78 |  |
                 } else {
79 | 0 |
                     throw new GuiRuntimeException(
80 |  |
                             "owner and its window don't extended Frame or Dialog.");
81 |  |
                 }
82 |  |
             }
83 |  |
         }
84 |  |
85 | 0 |
         protected void intiPane() {
86 | 0 |
             if (content instanceof Container) {
87 | 0 |
                 this.setContentPane((Container) content);
88 |  |
             } else {
89 | 0 |
                 final JPanel panel = new JPanel();
90 | 0 |
                 panel.add(content);
91 | 0 |
                 this.setContentPane(panel);
92 |  |
             }
93 |  |
         }
94 |  |
95 |  |
         /*
96 |  |
          * (non-Javadoc)
97 |  |
          *
98 |  |
          * @see java.awt.Dialog#show()
99 |  |
          */
100 | 0 |
         public void show() {
101 | 0 |
             invokeBeforeShow();
102 | 0 |
             super.show();
103 | 0 |
             invokeAfterShow();
104 |  |
         }
105 |  |
106 |  |
         /**
107 |  |
          *
108 |  |
          */
109 | 0 |
         protected void invokeBeforeShow() {
110 | 0 |
             if (content instanceof WindowContent)
111 | 0 |
                 ((WindowContent) content).beforeShow();
112 |  |
         }
113 |  |
114 |  |
         /**
115 |  |
          *
116 |  |
          */
117 | 0 |
         protected void invokeAfterShow() {
118 | 0 |
             if (content instanceof WindowContent)
119 | 0 |
                 ((WindowContent) content).afterShow();
120 |  |
         }
121 |  |
122 |  |
         /*
123 |  |
          * (non-Javadoc)
124 |  |
          *
125 |  |
          * @see java.awt.Dialog#hide()
126 |  |
          */
127 | 0 |
         public void hide() {
128 | 0 |
             invokeBeforeHide();
129 | 0 |
             super.hide();
130 | 0 |
             invokeAfterHide();
131 |  |
         }
132 |  |
133 |  |
         /**
134 |  |
          *
135 |  |
          */
136 | 0 |
         protected void invokeBeforeHide() {
137 | 0 |
             if (content instanceof WindowContent)
138 | 0 |
                 ((WindowContent) content).beforeHide();
139 |  |
         }
140 |  |
141 |  |
         /**
142 |  |
          *
143 |  |
          */
144 | 0 |
         protected void invokeAfterHide() {
145 | 0 |
             if (content instanceof WindowContent)
146 | 0 |
                 ((WindowContent) content).afterHide();
147 |  |
         }
148 |  |
149 |  |
     }