|
|||||||||||||||||||
| 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 | |||||||||||||||
| Wizard.java | 0% | 0% | 0% | 0% |
|
||||||||||||||
| 1 |
package baseCode.gui;
|
|
| 2 |
|
|
| 3 |
import java.awt.BorderLayout;
|
|
| 4 |
import java.awt.Dimension;
|
|
| 5 |
import java.awt.FlowLayout;
|
|
| 6 |
import java.awt.Point;
|
|
| 7 |
import java.awt.event.ActionEvent;
|
|
| 8 |
import java.util.Vector;
|
|
| 9 |
|
|
| 10 |
import javax.swing.BorderFactory;
|
|
| 11 |
import javax.swing.JButton;
|
|
| 12 |
import javax.swing.JDialog;
|
|
| 13 |
import javax.swing.JFrame;
|
|
| 14 |
import javax.swing.JLabel;
|
|
| 15 |
import javax.swing.JPanel;
|
|
| 16 |
import javax.swing.SwingConstants;
|
|
| 17 |
|
|
| 18 |
import baseCode.util.StatusViewer;
|
|
| 19 |
|
|
| 20 |
/**
|
|
| 21 |
*
|
|
| 22 |
*
|
|
| 23 |
*
|
|
| 24 |
* <hr>
|
|
| 25 |
* <p>Copyright (c) 2004-2005 Columbia University
|
|
| 26 |
* @author pavlidis
|
|
| 27 |
* @author Homin Lee
|
|
| 28 |
* @version $Id: Wizard.java,v 1.10 2005/03/21 18:01:03 pavlidis Exp $
|
|
| 29 |
*/
|
|
| 30 |
public abstract class Wizard extends JDialog { |
|
| 31 |
protected JPanel mainPanel;
|
|
| 32 |
protected FlowLayout flowlayout1 = new FlowLayout(); |
|
| 33 |
protected JPanel BottomPanel = new JPanel(); |
|
| 34 |
protected JPanel BottomPanelWrap = new JPanel(); |
|
| 35 |
protected JLabel jLabelStatus = new JLabel(); |
|
| 36 |
protected JPanel jPanelStatus = new JPanel(); |
|
| 37 |
|
|
| 38 |
protected JButton nextButton = new JButton(); |
|
| 39 |
protected JButton backButton = new JButton(); |
|
| 40 |
protected JButton cancelButton = new JButton(); |
|
| 41 |
protected JButton finishButton = new JButton(); |
|
| 42 |
|
|
| 43 |
Vector steps = new Vector();
|
|
| 44 |
protected JFrame callingframe;
|
|
| 45 |
private StatusViewer statusMessenger;
|
|
| 46 |
|
|
| 47 | 0 |
public Wizard( JFrame callingframe, int width, int height ) { |
| 48 |
//enableEvents(AWTEvent.WINDOW_EVENT_MASK);
|
|
| 49 | 0 |
this.callingframe = callingframe;
|
| 50 | 0 |
setModal( true );
|
| 51 | 0 |
jbInit( width, height ); |
| 52 |
} |
|
| 53 |
|
|
| 54 |
//Component initialization
|
|
| 55 | 0 |
private void jbInit( int width, int height ) { |
| 56 | 0 |
setResizable( true );
|
| 57 | 0 |
mainPanel = ( JPanel ) this.getContentPane();
|
| 58 | 0 |
mainPanel.setPreferredSize( new Dimension( width, height ) );
|
| 59 | 0 |
mainPanel.setLayout( new BorderLayout() );
|
| 60 |
|
|
| 61 |
// holds the buttons and the status bar.
|
|
| 62 | 0 |
BottomPanelWrap.setLayout( new BorderLayout() );
|
| 63 |
|
|
| 64 |
//bottom buttons/////////////////////////////////////////////////////////
|
|
| 65 | 0 |
BottomPanel.setPreferredSize( new Dimension( width, 40 ) );
|
| 66 | 0 |
nextButton.setText( "Next >" );
|
| 67 | 0 |
nextButton |
| 68 |
.addActionListener( new Wizard_nextButton_actionAdapter( this ) ); |
|
| 69 | 0 |
nextButton.setMnemonic( 'n' ); |
| 70 | 0 |
backButton.setText( "< Back" );
|
| 71 | 0 |
backButton |
| 72 |
.addActionListener( new Wizard_backButton_actionAdapter( this ) ); |
|
| 73 | 0 |
backButton.setEnabled( false );
|
| 74 | 0 |
backButton.setMnemonic( 'b' ); |
| 75 | 0 |
cancelButton.setText( "Cancel" );
|
| 76 | 0 |
cancelButton.addActionListener( new Wizard_cancelButton_actionAdapter(
|
| 77 |
this ) );
|
|
| 78 | 0 |
cancelButton.setMnemonic( 'c' ); |
| 79 | 0 |
finishButton.setText( "Finish" );
|
| 80 | 0 |
finishButton.setMnemonic( 'f' ); |
| 81 | 0 |
finishButton.addActionListener( new Wizard_finishButton_actionAdapter(
|
| 82 |
this ) );
|
|
| 83 | 0 |
BottomPanel.add( cancelButton, null );
|
| 84 | 0 |
BottomPanel.add( backButton, null );
|
| 85 | 0 |
BottomPanel.add( nextButton, null );
|
| 86 | 0 |
BottomPanel.add( finishButton, null );
|
| 87 |
|
|
| 88 |
// status bar
|
|
| 89 | 0 |
jPanelStatus.setBorder( BorderFactory.createEtchedBorder() ); |
| 90 | 0 |
jLabelStatus.setFont( new java.awt.Font( "Dialog", 0, 11 ) ); |
| 91 | 0 |
jLabelStatus.setPreferredSize( new Dimension( width - 40, 19 ) );
|
| 92 | 0 |
jLabelStatus.setHorizontalAlignment( SwingConstants.LEFT ); |
| 93 | 0 |
jPanelStatus.add( jLabelStatus, null );
|
| 94 | 0 |
statusMessenger = new StatusJlabel( jLabelStatus );
|
| 95 |
|
|
| 96 | 0 |
BottomPanelWrap.add( BottomPanel, BorderLayout.NORTH ); |
| 97 | 0 |
BottomPanelWrap.add( jPanelStatus, BorderLayout.SOUTH ); |
| 98 |
|
|
| 99 | 0 |
mainPanel.add( BottomPanelWrap, BorderLayout.SOUTH ); |
| 100 |
|
|
| 101 |
} |
|
| 102 |
|
|
| 103 |
/**
|
|
| 104 |
* Print a message to the status bar.
|
|
| 105 |
*
|
|
| 106 |
* @param a
|
|
| 107 |
*/
|
|
| 108 | 0 |
public void showStatus( String a ) { |
| 109 | 0 |
statusMessenger.setStatus( a ); |
| 110 |
} |
|
| 111 |
|
|
| 112 |
/**
|
|
| 113 |
* Print an error message to the status bar.
|
|
| 114 |
*
|
|
| 115 |
* @param a
|
|
| 116 |
*/
|
|
| 117 | 0 |
public void showError( String a ) { |
| 118 | 0 |
statusMessenger.setError( a ); |
| 119 |
} |
|
| 120 |
|
|
| 121 |
/**
|
|
| 122 |
* Make the status bar empty.
|
|
| 123 |
*/
|
|
| 124 | 0 |
public void clearStatus() { |
| 125 | 0 |
statusMessenger.setStatus( "" );
|
| 126 |
} |
|
| 127 |
|
|
| 128 | 0 |
protected void addStep( int step, WizardStep panel ) { |
| 129 | 0 |
steps.add( step - 1, panel ); |
| 130 | 0 |
if ( step == 1 )
|
| 131 | 0 |
mainPanel.add( ( JPanel ) steps.get( 0 ), BorderLayout.CENTER ); |
| 132 |
} |
|
| 133 |
|
|
| 134 | 0 |
public void showWizard() { |
| 135 | 0 |
Dimension dlgSize = getPreferredSize(); |
| 136 | 0 |
Dimension frmSize = callingframe.getSize(); |
| 137 | 0 |
Point loc = callingframe.getLocation(); |
| 138 | 0 |
setLocation( ( frmSize.width - dlgSize.width ) / 2 + loc.x, |
| 139 |
( frmSize.height - dlgSize.height ) / 2 + loc.y ); |
|
| 140 | 0 |
pack(); |
| 141 | 0 |
nextButton.requestFocusInWindow(); |
| 142 | 0 |
show(); |
| 143 |
} |
|
| 144 |
|
|
| 145 |
/**
|
|
| 146 |
* Define what happens when the 'next' button is pressed
|
|
| 147 |
*
|
|
| 148 |
* @param e
|
|
| 149 |
*/
|
|
| 150 |
protected abstract void nextButton_actionPerformed( ActionEvent e ); |
|
| 151 |
|
|
| 152 |
/**
|
|
| 153 |
* Define what happens when the 'back' button is pressed
|
|
| 154 |
*
|
|
| 155 |
* @param e
|
|
| 156 |
*/
|
|
| 157 |
protected abstract void backButton_actionPerformed( ActionEvent e ); |
|
| 158 |
|
|
| 159 |
/**
|
|
| 160 |
* Define what happens when the 'cancel' button is pressed.
|
|
| 161 |
*
|
|
| 162 |
* @param e
|
|
| 163 |
*/
|
|
| 164 |
protected abstract void cancelButton_actionPerformed( ActionEvent e ); |
|
| 165 |
|
|
| 166 |
/**
|
|
| 167 |
* Define what happens when the 'finish' button is pressed.
|
|
| 168 |
*
|
|
| 169 |
* @param e
|
|
| 170 |
*/
|
|
| 171 |
protected abstract void finishButton_actionPerformed( ActionEvent e ); |
|
| 172 |
|
|
| 173 |
/**
|
|
| 174 |
* Disable the "finish" button, indicating the user has some steps to do yet.
|
|
| 175 |
*/
|
|
| 176 | 0 |
public void setFinishDisabled() { |
| 177 | 0 |
this.finishButton.setEnabled( false ); |
| 178 |
} |
|
| 179 |
|
|
| 180 |
/**
|
|
| 181 |
* Enable the "finish" button, indicating the user can get out of the wizard at this stage.
|
|
| 182 |
*/
|
|
| 183 | 0 |
public void setFinishEnabled() { |
| 184 | 0 |
this.finishButton.setEnabled( true ); |
| 185 |
} |
|
| 186 |
} |
|
| 187 |
|
|
| 188 |
class Wizard_nextButton_actionAdapter implements java.awt.event.ActionListener { |
|
| 189 |
Wizard adaptee; |
|
| 190 |
|
|
| 191 | 0 |
Wizard_nextButton_actionAdapter( Wizard adaptee ) {
|
| 192 | 0 |
this.adaptee = adaptee;
|
| 193 |
} |
|
| 194 |
|
|
| 195 | 0 |
public void actionPerformed( ActionEvent e ) { |
| 196 | 0 |
adaptee.nextButton_actionPerformed( e ); |
| 197 |
} |
|
| 198 |
} |
|
| 199 |
|
|
| 200 |
class Wizard_backButton_actionAdapter implements java.awt.event.ActionListener { |
|
| 201 |
Wizard adaptee; |
|
| 202 |
|
|
| 203 | 0 |
Wizard_backButton_actionAdapter( Wizard adaptee ) {
|
| 204 | 0 |
this.adaptee = adaptee;
|
| 205 |
} |
|
| 206 |
|
|
| 207 | 0 |
public void actionPerformed( ActionEvent e ) { |
| 208 | 0 |
adaptee.backButton_actionPerformed( e ); |
| 209 |
} |
|
| 210 |
} |
|
| 211 |
|
|
| 212 |
class Wizard_cancelButton_actionAdapter implements |
|
| 213 |
java.awt.event.ActionListener {
|
|
| 214 |
Wizard adaptee; |
|
| 215 |
|
|
| 216 | 0 |
Wizard_cancelButton_actionAdapter( Wizard adaptee ) {
|
| 217 | 0 |
this.adaptee = adaptee;
|
| 218 |
} |
|
| 219 |
|
|
| 220 | 0 |
public void actionPerformed( ActionEvent e ) { |
| 221 | 0 |
adaptee.cancelButton_actionPerformed( e ); |
| 222 |
} |
|
| 223 |
} |
|
| 224 |
|
|
| 225 |
class Wizard_finishButton_actionAdapter implements |
|
| 226 |
java.awt.event.ActionListener {
|
|
| 227 |
Wizard adaptee; |
|
| 228 |
|
|
| 229 | 0 |
Wizard_finishButton_actionAdapter( Wizard adaptee ) {
|
| 230 | 0 |
this.adaptee = adaptee;
|
| 231 |
} |
|
| 232 |
|
|
| 233 | 0 |
public void actionPerformed( ActionEvent e ) { |
| 234 | 0 |
adaptee.finishButton_actionPerformed( e ); |
| 235 |
} |
|
| 236 |
} |
|
| 237 |
|
|
| 238 |
|
|
||||||||||