1 package devisor2.grid.GUI.dialogs; 2 3 4 import java.awt.*; 5 import java.awt.event.*; 6 import javax.swing.*; 7 import devisor2.grid.GUI.framework.*; 8 import devisor2.grid.options.*; 9 10 11 /** 12 * This class defines our basic info dialog with version information, 13 * developers, revision history etc. It is linked to the GUI via the 14 * MainMenu's About... entry. <br> 15 * <br> 16 * This is a regular dialog, so it is used just like every other dialog as 17 * well, if you want to know more, take a look at the technical paper 18 * which explains dialogs to be found in the /manual/specs directory of 19 * your DeViSoRGriD 2 installation. <br> 20 * In this class, the version number is managed! 21 * 22 * @author Dominik Goeddeke 23 * @version 1.0 (quite finished) 24 */ 25 public class InfoDialog extends JDialog 26 { 27 28 public static final int version_level1 = 2; 29 public static final int version_level2 = 1; 30 public static final int version_level3 = 0; 31 32 public static final String release_date = "October 17th, 2003"; 33 34 /** 35 * the info dialog is displayed via two static methods of this class 36 * (see below), this class variable just references the instance 37 * which is ready for display 38 */ 39 private static InfoDialog infodialog; 40 41 /** 42 * the MainFrame object of this dialog. important because the dialog is 43 * centered on it 44 */ 45 private MainFrame parent; 46 47 /** 48 * the ControlCenter reference 49 */ 50 private ControlCenter cc; 51 52 53 /** 54 * creates a new instance of the dialog 55 * @param JFrame parent the parent frame the dialog is centered on 56 */ InfoDialog(MainFrame parent)57 public InfoDialog (MainFrame parent) 58 { 59 super (parent, true); 60 this.parent = parent; 61 cc = ControlCenter.getMyself (); 62 layoutGui (); 63 setLocationRelativeTo (parent); 64 setDefaultCloseOperation (DO_NOTHING_ON_CLOSE); 65 setResizable (false); 66 pack (); 67 } 68 69 /** 70 * creates the gui (nothing spectacular here) 71 */ layoutGui()72 private void layoutGui () 73 { 74 // the basics 75 setTitle ((String)cc.rb.getObject ((String)"GUI_dialogs_InfoDialog_frametitle")); 76 JPanel panel = new JPanel (); 77 panel.setLayout (new BorderLayout ()); 78 panel.add (Box.createRigidArea (new Dimension(20,20)), BorderLayout.WEST); 79 panel.add (Box.createRigidArea (new Dimension(20,20)), BorderLayout.EAST); 80 // north we have the logo 81 JLabel logo = new JLabel (new ImageIcon(cc.op.get(Options.general_devisorhome)+"images/devisorlogo.gif")); 82 panel.add (logo, BorderLayout.NORTH); 83 // in the middle some text 84 JPanel center = new JPanel (); 85 GridBagLayout layout = new GridBagLayout (); 86 GridBagConstraints constraints = new GridBagConstraints (); 87 JLabel label; 88 center.setLayout (layout); 89 constraints.fill = GridBagConstraints.HORIZONTAL; 90 constraints.weightx = 1.0; 91 // programm info 92 JPanel about = new JPanel (); 93 about.setLayout (new BoxLayout (about, BoxLayout.Y_AXIS)); 94 about.setBorder (BorderFactory.createTitledBorder ((String)cc.rb.getObject("GUI_dialogs_InfoDialog_about"))); 95 label = new JLabel ((String)cc.rb.getObject("GUI_dialogs_InfoDialog_abouttext1")); 96 label.setAlignmentX (Component.CENTER_ALIGNMENT); 97 about.add (label); 98 label = new JLabel ((String)cc.rb.getObject("GUI_dialogs_InfoDialog_abouttext2")); 99 label.setAlignmentX (Component.CENTER_ALIGNMENT); 100 about.add (label); 101 label = new JLabel ((String)cc.rb.getObject("GUI_dialogs_InfoDialog_abouttext3")); 102 label.setAlignmentX (Component.CENTER_ALIGNMENT); 103 about.add (label); 104 label = new JLabel ((String)cc.rb.getObject("GUI_dialogs_InfoDialog_abouttext4")); 105 label.setAlignmentX (Component.CENTER_ALIGNMENT); 106 about.add (label); 107 constraints.gridy = 0; 108 layout.setConstraints(about, constraints); 109 center.add (about); 110 // version info 111 JPanel version = new JPanel (); 112 version.setLayout (new BoxLayout (version, BoxLayout.Y_AXIS)); 113 version.setBorder (BorderFactory.createTitledBorder ((String)cc.rb.getObject("GUI_dialogs_InfoDialog_version"))); 114 label = new JLabel (version_level1+"."+version_level2+"."+version_level3); 115 label.setAlignmentX (Component.CENTER_ALIGNMENT); 116 version.add (label); 117 label = new JLabel (release_date); 118 label.setAlignmentX (Component.CENTER_ALIGNMENT); 119 version.add (label); 120 constraints.gridy = 1; 121 layout.setConstraints(version, constraints); 122 center.add (version); 123 // developers info 124 JPanel dev = new JPanel (); 125 dev.setLayout (new BoxLayout (dev, BoxLayout.Y_AXIS)); 126 dev.setBorder (BorderFactory.createTitledBorder ((String)cc.rb.getObject("GUI_dialogs_InfoDialog_developers"))); 127 label = new JLabel ("Christian Becker"); 128 label.setAlignmentX (Component.CENTER_ALIGNMENT); 129 dev.add (label); 130 label = new JLabel ("Dominik G�ddeke"); 131 label.setAlignmentX (Component.CENTER_ALIGNMENT); 132 dev.add (label); 133 label = new JLabel ("Patrick Otto"); 134 label.setAlignmentX (Component.CENTER_ALIGNMENT); 135 dev.add (label); 136 dev.add (new JLabel (" ")); 137 label = new JLabel ("Institute of Numerics and Applied Mathematics"); 138 label.setAlignmentX (Component.CENTER_ALIGNMENT); 139 dev.add (label); 140 label = new JLabel ("University of Dortmund, Germany"); 141 label.setAlignmentX (Component.CENTER_ALIGNMENT); 142 dev.add (label); 143 constraints.gridy = 2; 144 layout.setConstraints(dev, constraints); 145 center.add (dev); 146 // contact info 147 JPanel contact = new JPanel (); 148 contact.setLayout (new BoxLayout (contact, BoxLayout.Y_AXIS)); 149 contact.setBorder (BorderFactory.createTitledBorder ((String)cc.rb.getObject("GUI_dialogs_InfoDialog_contact"))); 150 label = new JLabel ((String)cc.rb.getObject("GUI_dialogs_InfoDialog_contact_text1")); 151 label.setAlignmentX (Component.CENTER_ALIGNMENT); 152 contact.add (label); 153 label = new JLabel ((String)cc.rb.getObject("GUI_dialogs_InfoDialog_contact_text2")); 154 label.setAlignmentX (Component.CENTER_ALIGNMENT); 155 contact.add (label); 156 label = new JLabel ("http://www.featflow.de"); 157 label.setAlignmentX (Component.CENTER_ALIGNMENT); 158 contact.add (label); 159 label = new JLabel ((String)cc.rb.getObject("GUI_dialogs_InfoDialog_contact_text3")); 160 label.setAlignmentX (Component.CENTER_ALIGNMENT); 161 contact.add (label); 162 label = new JLabel ("devisor@featflow.de"); 163 label.setAlignmentX (Component.CENTER_ALIGNMENT); 164 contact.add (label); 165 constraints.gridy = 3; 166 layout.setConstraints(contact, constraints); 167 center.add (contact); 168 panel.add (center, BorderLayout.CENTER); 169 // a button goes south 170 JButton button = new JButton ("OK"); 171 button.addActionListener (new ActionListener () { 172 public void actionPerformed (ActionEvent e) { 173 dispose (); 174 } 175 }); 176 button.setAlignmentX(Component.CENTER_ALIGNMENT); 177 button.setSize (150, 40); 178 panel.add (button, BorderLayout.SOUTH); 179 getRootPane().setDefaultButton (button); 180 getContentPane().add(panel); 181 setResizable (false); 182 } 183 184 /** 185 * this is one of the two important methods in this class. 186 * it instantiates a new dialog object and sets up its gui 187 */ initialize(MainFrame parent)188 public static void initialize(MainFrame parent) { 189 infodialog = new InfoDialog (parent); 190 } 191 192 /** 193 * if initialize() has been called before (i.e. the dialog has been 194 * instanciated), this method just lets the dialog pop up modally on the 195 * screen. 196 */ showDialog()197 public static void showDialog() { 198 if (infodialog != null) 199 { 200 infodialog.setLocationRelativeTo (infodialog.parent); 201 infodialog.setVisible(true); 202 } 203 else 204 { 205 System.err.println("InfoDialog requires you to call initialize " 206 + "before calling showDialog."); 207 } 208 } 209 210 } 211