Clover coverage report - baseCode - 0.2.5 Coverage timestamp: Tue Apr 12 2005 11:31:58 EDT FRAMES NO FRAMES |
file stats: | LOC: | 292 |  | Methods: | 24
| NCLOC: | 173 |  | Classes: | 7
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
AppDialog.java | 0% | 0% | 0% | 0% |

1 |  |
     package baseCode.gui;
2 |  |
3 |  |
     import java.awt.BorderLayout;
4 |  |
     import java.awt.Color;
5 |  |
     import java.awt.Container;
6 |  |
     import java.awt.Dimension;
7 |  |
     import java.awt.Point;
8 |  |
     import java.awt.event.ActionEvent;
9 |  |
     import java.awt.event.MouseEvent;
10 |  |
     import java.awt.event.MouseListener;
11 |  |
     import java.io.IOException;
12 |  |
13 |  |
     import javax.swing.JButton;
14 |  |
     import javax.swing.JDialog;
15 |  |
     import javax.swing.JEditorPane;
16 |  |
     import javax.swing.JFrame;
17 |  |
     import javax.swing.JLabel;
18 |  |
     import javax.swing.JPanel;
19 |  |
     import javax.swing.event.HyperlinkEvent;
20 |  |
     import javax.swing.event.HyperlinkListener;
21 |  |
22 |  |
     import baseCode.util.BrowserLauncher;
23 |  |
24 |  |
     /**
25 |  |
      * <p>
26 |  |
      * Title:
27 |  |
      * </p>
28 |  |
      * <p>
29 |  |
      * Description:
30 |  |
      * </p>
31 |  |
      * <p>
32 |  |
      * Copyright: Copyright (c) 2003
33 |  |
      * </p>
34 |  |
      * <p>
35 |  |
      * Company:
36 |  |
      * </p>
37 |  |
      *
38 |  |
      * @author Homin Lee
39 |  |
      * @version $Id: AppDialog.java,v 1.7 2004/07/27 03:18:58 pavlidis Exp $
40 |  |
      */
41 |  |
42 |  |
     public abstract class AppDialog extends JDialog {
43 |  |
        /**
44 |  |
         * <hr>
45 |  |
         * <p>
46 |  |
         * Copyright (c) 2004 Columbia University
47 |  |
         *
48 |  |
         * @author pavlidis
49 |  |
         * @version $Id: AppDialog.java,v 1.7 2004/07/27 03:18:58 pavlidis Exp $
50 |  |
         */
51 |  |
52 |  |
        JPanel mainPanel;
53 |  |
        BorderLayout borderLayout1 = new BorderLayout();
54 |  |
        JPanel contentPanel = new JPanel();
55 |  |
        JPanel bottomPanel = new JPanel();
56 |  |
        protected JButton actionButton = new JButton();
57 |  |
        protected JButton cancelButton = new JButton();
58 |  |
        protected JButton helpButton = new JButton();
59 |  |
60 |  |
        protected Container callingframe;
61 |  |
62 | 0 |
        public AppDialog() {
63 |  |
64 |  |
        }
65 |  |
66 | 0 |
        public AppDialog( JFrame callingframe, int width, int height ) {
67 | 0 |
           this.callingframe = callingframe;
68 | 0 |
           setModal( true );
69 | 0 |
           jbInit( width, height );
70 |  |
        }
71 |  |
72 | 0 |
        private void jbInit( int width, int height ) {
73 | 0 |
           setResizable( true );
74 | 0 |
           mainPanel = ( JPanel ) this.getContentPane();
75 | 0 |
           mainPanel.setPreferredSize( new Dimension( width, height ) );
76 | 0 |
           mainPanel.setLayout( borderLayout1 );
77 |  |
78 | 0 |
           contentPanel.setPreferredSize( new Dimension( width, height - 40 ) );
79 | 0 |
           BorderLayout borderLayout4 = new BorderLayout();
80 | 0 |
           contentPanel.setLayout( borderLayout4 );
81 |  |
82 | 0 |
           bottomPanel.setPreferredSize( new Dimension( width, 40 ) );
83 | 0 |
           cancelButton.setText( "Cancel" );
84 | 0 |
           cancelButton.setMnemonic( 'c' );
85 | 0 |
           cancelButton.addActionListener( new AppDialog_cancelButton_actionAdapter(
86 |  |
                 this ) );
87 | 0 |
           actionButton.addActionListener( new AppDialog_actionButton_actionAdapter(
88 |  |
                 this ) );
89 |  |
90 | 0 |
           helpButton.addActionListener( new AppDialog_helpButton_actionAdapter(
91 |  |
                 this ) );
92 | 0 |
           helpButton.setText( "Help" );
93 |  |
94 | 0 |
           bottomPanel.add( helpButton, null );
95 | 0 |
           bottomPanel.add( cancelButton, null );
96 | 0 |
           bottomPanel.add( actionButton, null );
97 | 0 |
           mainPanel.add( contentPanel, BorderLayout.CENTER );
98 | 0 |
           mainPanel.add( bottomPanel, BorderLayout.SOUTH );
99 |  |
        }
100 |  |
101 | 0 |
        public void showDialog() {
102 | 0 |
           Dimension dlgSize = getPreferredSize();
103 | 0 |
           Dimension frmSize = callingframe.getSize();
104 | 0 |
           Point loc = callingframe.getLocation();
105 | 0 |
           setLocation( ( frmSize.width - dlgSize.width ) / 2 + loc.x,
106 |  |
                 ( frmSize.height - dlgSize.height ) / 2 + loc.y );
107 | 0 |
           pack();
108 | 0 |
           actionButton.requestFocusInWindow();
109 | 0 |
           show();
110 |  |
        }
111 |  |
112 |  |
        // helper to respond to links.
113 |  |
        class LinkFollower implements HyperlinkListener {
114 |  |
115 |  |
           /*
116 |  |
            * (non-Javadoc)
117 |  |
            *
118 |  |
            * @see javax.swing.event.HyperlinkListener#hyperlinkUpdate(javax.swing.event.HyperlinkEvent)
119 |  |
            */
120 | 0 |
           public void hyperlinkUpdate( HyperlinkEvent e ) {
121 | 0 |
              if ( e.getEventType() == HyperlinkEvent.EventType.ACTIVATED ) {
122 | 0 |
                 try {
123 | 0 |
                    BrowserLauncher.openURL( e.getURL().toExternalForm() );
124 |  |
                 } catch ( IOException e1 ) {
125 | 0 |
                    GuiUtil.error( "Could not open link" );
126 |  |
                 }
127 |  |
              }
128 |  |
           }
129 |  |
        }
130 |  |
131 |  |
        // Slightly specialized editor pane.
132 |  |
        class HelpEditorPane extends JEditorPane {
133 |  |
134 | 0 |
           HelpEditorPane( String text ) {
135 | 0 |
              super();
136 | 0 |
              this.setEditable( false );
137 | 0 |
              this.setContentType( "text/html" );
138 | 0 |
              this.setText( text );
139 | 0 |
              this.addHyperlinkListener( new LinkFollower() );
140 |  |
           }
141 |  |
142 |  |
        }
143 |  |
144 |  |
        // @todo why using spaces for layout?
145 | 0 |
        protected void addHelp( String text ) {
146 |  |
147 | 0 |
           HelpEditorPane helpArea = null;
148 |  |
149 | 0 |
           helpArea = new HelpEditorPane( text );
150 | 0 |
           JLabel jLabel1 = new JLabel( "      " );
151 | 0 |
           JLabel jLabel2 = new JLabel( " " );
152 | 0 |
           JLabel jLabel3 = new JLabel( " " );
153 | 0 |
           JLabel jLabel4 = new JLabel( "      " );
154 | 0 |
           BorderLayout borderLayout2 = new BorderLayout();
155 | 0 |
           JPanel labelPanel = new JPanel();
156 | 0 |
           labelPanel.setBackground( Color.WHITE );
157 | 0 |
           labelPanel.setLayout( borderLayout2 );
158 | 0 |
           labelPanel.add( helpArea, BorderLayout.CENTER );
159 | 0 |
           labelPanel.add( jLabel1, BorderLayout.WEST );
160 | 0 |
           labelPanel.add( jLabel2, BorderLayout.NORTH );
161 | 0 |
           labelPanel.add( jLabel3, BorderLayout.SOUTH );
162 | 0 |
           labelPanel.add( jLabel4, BorderLayout.EAST );
163 | 0 |
           contentPanel.add( labelPanel, BorderLayout.NORTH );
164 |  |
165 | 0 |
           helpArea.addMouseListener( new AppDialog_mouselistener_actionAdapter(
166 |  |
                 this ) );
167 |  |
168 |  |
        }
169 |  |
170 | 0 |
        protected void addMain( JPanel panel ) {
171 | 0 |
           contentPanel.add( panel, BorderLayout.CENTER );
172 |  |
        }
173 |  |
174 | 0 |
        protected void setActionButtonText( String val ) {
175 | 0 |
           actionButton.setText( val );
176 |  |
        }
177 |  |
178 | 0 |
        protected void setCancelButtonText( String val ) {
179 | 0 |
           cancelButton.setText( val );
180 |  |
        }
181 |  |
182 | 0 |
        protected void setHelpButtonText( String val ) {
183 | 0 |
           helpButton.setText( val );
184 |  |
        }
185 |  |
186 |  |
        protected abstract void cancelButton_actionPerformed( ActionEvent e );
187 |  |
188 |  |
        protected abstract void actionButton_actionPerformed( ActionEvent e );
189 |  |
190 |  |
        protected abstract void helpButton_actionPerformed( ActionEvent e );
191 |  |
192 |  |
        /**
193 |  |
         * @param e
194 |  |
         */
195 | 0 |
        public void mouseButton_actionPerformed( MouseEvent e ) {
196 |  |
           // TODO Auto-generated method stub
197 |  |
        }
198 |  |
199 |  |
     }
200 |  |
201 |  |
     class AppDialog_helpButton_actionAdapter implements
202 |  |
           java.awt.event.ActionListener {
203 |  |
        AppDialog adaptee;
204 |  |
205 | 0 |
        AppDialog_helpButton_actionAdapter( AppDialog adaptee ) {
206 | 0 |
           this.adaptee = adaptee;
207 |  |
        }
208 |  |
209 | 0 |
        public void actionPerformed( ActionEvent e ) {
210 | 0 |
           adaptee.helpButton_actionPerformed( e );
211 |  |
        }
212 |  |
     }
213 |  |
214 |  |
     class AppDialog_cancelButton_actionAdapter implements
215 |  |
           java.awt.event.ActionListener {
216 |  |
        AppDialog adaptee;
217 |  |
218 | 0 |
        AppDialog_cancelButton_actionAdapter( AppDialog adaptee ) {
219 | 0 |
           this.adaptee = adaptee;
220 |  |
        }
221 |  |
222 | 0 |
        public void actionPerformed( ActionEvent e ) {
223 | 0 |
           adaptee.cancelButton_actionPerformed( e );
224 |  |
        }
225 |  |
     }
226 |  |
227 |  |
     class AppDialog_actionButton_actionAdapter implements
228 |  |
           java.awt.event.ActionListener {
229 |  |
        AppDialog adaptee;
230 |  |
231 | 0 |
        AppDialog_actionButton_actionAdapter( AppDialog adaptee ) {
232 | 0 |
           this.adaptee = adaptee;
233 |  |
        }
234 |  |
235 | 0 |
        public void actionPerformed( ActionEvent e ) {
236 | 0 |
           adaptee.actionButton_actionPerformed( e );
237 |  |
        }
238 |  |
     }
239 |  |
240 |  |
     class AppDialog_mouselistener_actionAdapter implements MouseListener {
241 |  |
242 |  |
        AppDialog adaptee;
243 |  |
244 |  |
        /**
245 |  |
         * @param adaptee
246 |  |
         */
247 | 0 |
        public AppDialog_mouselistener_actionAdapter( AppDialog adaptee ) {
248 | 0 |
           this.adaptee = adaptee;
249 |  |
        }
250 |  |
251 |  |
        /*
252 |  |
         * (non-Javadoc)
253 |  |
         *
254 |  |
         * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
255 |  |
         */
256 | 0 |
        public void mouseClicked( MouseEvent e ) {
257 | 0 |
           adaptee.mouseButton_actionPerformed( e );
258 |  |
        }
259 |  |
260 |  |
        /*
261 |  |
         * (non-Javadoc)
262 |  |
         *
263 |  |
         * @see java.awt.event.MouseListener#mouseEntered(java.awt.event.MouseEvent)
264 |  |
         */
265 | 0 |
        public void mouseEntered( MouseEvent e ) {
266 |  |
        }
267 |  |
268 |  |
        /*
269 |  |
         * (non-Javadoc)
270 |  |
         *
271 |  |
         * @see java.awt.event.MouseListener#mouseExited(java.awt.event.MouseEvent)
272 |  |
         */
273 | 0 |
        public void mouseExited( MouseEvent e ) {
274 |  |
        }
275 |  |
276 |  |
        /*
277 |  |
         * (non-Javadoc)
278 |  |
         *
279 |  |
         * @see java.awt.event.MouseListener#mousePressed(java.awt.event.MouseEvent)
280 |  |
         */
281 | 0 |
        public void mousePressed( MouseEvent e ) {
282 |  |
        }
283 |  |
284 |  |
        /*
285 |  |
         * (non-Javadoc)
286 |  |
         *
287 |  |
         * @see java.awt.event.MouseListener#mouseReleased(java.awt.event.MouseEvent)
288 |  |
         */
289 | 0 |
        public void mouseReleased( MouseEvent e ) {
290 |  |
        }
291 |  |
292 |  |
     }