1 29 38 39 package org.planetamessenger.mos.forms; 40 41 import org.planetamessenger.mos.engine.*; 42 import org.planetamessenger.mos.ui.*; 43 44 45 public class JMOSProfileManagerDlg extends javax.swing.JDialog implements javax.swing.event.TreeSelectionListener { 46 47 private JProfileTree profileTree; 48 private javax.swing.JButton cancelBtn; 49 private javax.swing.JButton okBtn; 50 private javax.swing.JButton removeProfileBtn; 51 private javax.swing.JButton selectProfileBtn; 52 private javax.swing.JButton newProfileBtn; 53 private javax.swing.JButton changeLookAndFeelBtn; 54 private javax.swing.JLabel profileLabel; 55 private javax.swing.JScrollPane profileTreePane; 56 57 58 59 64 public JMOSProfileManagerDlg( java.awt.Frame parent, boolean modal ) { 65 66 super( parent, modal ); 67 68 initComponents(); 69 } 70 71 76 void windowRefresh() { 77 78 javax.swing.SwingUtilities.updateComponentTreeUI( this ); 79 } 80 81 85 private void initComponents() { 86 87 java.awt.GridBagConstraints constraints = new java.awt.GridBagConstraints (); 88 89 90 profileLabel = new javax.swing.JLabel (); 91 profileTree = new JProfileTree( JSharedObjects.getLanguageManager().getStringEx( "PROFILES" ) ); 92 newProfileBtn = new javax.swing.JButton (); 93 selectProfileBtn = new javax.swing.JButton (); 94 removeProfileBtn = new javax.swing.JButton (); 95 okBtn = new javax.swing.JButton (); 96 cancelBtn = new javax.swing.JButton (); 97 changeLookAndFeelBtn = new javax.swing.JButton (); 98 profileTreePane = new javax.swing.JScrollPane ( profileTree ); 99 100 getContentPane().setLayout( new java.awt.GridBagLayout () ); 101 102 setTitle( JSharedObjects.getLanguageManager().getStringEx( "PROFILE_MANAGER" ) ); 103 setName( "JMOSProfileManagerDlg" ); 104 105 addWindowListener( new java.awt.event.WindowAdapter () { 106 107 public void windowClosing( java.awt.event.WindowEvent evt ) { 108 closeDialog( evt ); 109 } 110 } ); 111 112 constraints.gridx = 0; 113 constraints.gridy = 0; 114 constraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 115 constraints.gridheight = 1; 116 constraints.weightx = 1.0; 117 constraints.weighty = 0.0; 118 constraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 119 constraints.insets = new java.awt.Insets ( 2, 2, 2, 2 ); 120 121 profileLabel.setFont( JSystemFonts.FONT ); 122 profileLabel.setText( JSharedObjects.getLanguageManager().getStringEx( "SELECTED_A_PROFILE" ) ); 123 getContentPane().add( profileLabel, constraints ); 124 125 constraints.gridy++; 126 constraints.gridwidth = java.awt.GridBagConstraints.RELATIVE; 127 constraints.gridheight = 9; constraints.fill = java.awt.GridBagConstraints.BOTH; 129 constraints.weightx = 1.0; 130 constraints.weighty = 1.0; 131 132 profileTree.addTreeSelectionListener( this ); 133 getContentPane().add( profileTreePane, constraints ); 134 135 constraints.gridx++; 136 constraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 137 constraints.gridheight = 1; 138 constraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 139 constraints.weightx = 0.0; 140 constraints.weighty = 1.0; 141 142 newProfileBtn.setFont( JSystemFonts.FONT ); 143 newProfileBtn.setText( JSharedObjects.getLanguageManager().getStringEx( "NEW_PROFILE" ) ); 144 newProfileBtn.setName("newProfileBtn"); 145 newProfileBtn.setIcon( JSharedObjects.getResources().getIcon( JResources.NEW_ICON ) ); 146 getContentPane().add( newProfileBtn, constraints ); 147 148 constraints.gridy = java.awt.GridBagConstraints.RELATIVE; 149 150 changeLookAndFeelBtn.setEnabled( false ); 151 changeLookAndFeelBtn.setFont( JSystemFonts.FONT ); 152 changeLookAndFeelBtn.setIcon( JSharedObjects.getResources().getIcon( JResources.RELOAD_ICON ) ); 154 changeLookAndFeelBtn.setText( JSharedObjects.getLanguageManager().getStringEx( "CHANGE_LOOK_AND_FEEL" ) ); 155 getContentPane().add( changeLookAndFeelBtn, constraints ); 156 157 selectProfileBtn.setEnabled( false ); 158 selectProfileBtn.setFont( JSystemFonts.FONT ); 159 selectProfileBtn.setIcon( JSharedObjects.getResources().getIcon( JResources.APPLY_BUTTON_ICON ) ); 160 selectProfileBtn.setText( JSharedObjects.getLanguageManager().getStringEx( "ACTIVATE_PROFILE" ) ); 161 getContentPane().add( selectProfileBtn, constraints ); 162 163 removeProfileBtn.setEnabled( false ); 164 removeProfileBtn.setFont( JSystemFonts.FONT ); 165 removeProfileBtn.setIcon( JSharedObjects.getResources().getIcon( JResources.REMOVE_FILE_ICON ) ); 166 removeProfileBtn.setText( JSharedObjects.getLanguageManager().getStringEx( "REMOVE_PROFILE" ) ); 167 getContentPane().add( removeProfileBtn, constraints ); 168 169 okBtn.setFont( JSystemFonts.FONT ); 170 okBtn.setText( JSharedObjects.getLanguageManager().getStringEx( "OK" ) ); 171 okBtn.setIcon( JSharedObjects.getResources().getIcon( JResources.OK_BUTTON_ICON ) ); 172 getContentPane().add( okBtn, constraints ); 173 174 cancelBtn.setFont( JSystemFonts.FONT ); 175 cancelBtn.setText( JSharedObjects.getLanguageManager().getStringEx( "CANCEL" ) ); 176 cancelBtn.setIcon( JSharedObjects.getResources().getIcon( JResources.CLOSE_BUTTON_ICON ) ); 177 getContentPane().add( cancelBtn, constraints ); 178 179 setSize( JSharedObjects.getConfiguration().getProfileWindowSize() ); 180 setLocation( JSharedObjects.getConfiguration().getProfileWindowLocation() ); 181 setResizable( true ); 182 184 changeLookAndFeelBtn.addActionListener( new java.awt.event.ActionListener () { 186 187 public void actionPerformed( java.awt.event.ActionEvent evt ) { 188 189 changeLookAndFeelButtonActionPerformed( evt ); 190 } 191 } ); 192 193 newProfileBtn.addActionListener( new java.awt.event.ActionListener () { 195 196 public void actionPerformed( java.awt.event.ActionEvent evt ) { 197 198 newProfileButtonActionPerformed( evt ); 199 } 200 } ); 201 202 removeProfileBtn.addActionListener( new java.awt.event.ActionListener () { 204 205 public void actionPerformed( java.awt.event.ActionEvent evt ) { 206 207 removeProfileButtonActionPerformed( evt ); 208 } 209 } ); 210 211 selectProfileBtn.addActionListener( new java.awt.event.ActionListener () { 213 214 public void actionPerformed( java.awt.event.ActionEvent evt ) { 215 216 selectProfileButtonActionPerformed( evt ); 217 } 218 } ); 219 220 okBtn.addActionListener( new java.awt.event.ActionListener () { 222 223 public void actionPerformed( java.awt.event.ActionEvent evt ) { 224 225 okButtonActionPerformed( evt ); 226 } 227 } ); 228 229 cancelBtn.addActionListener( new java.awt.event.ActionListener () { 231 232 public void actionPerformed( java.awt.event.ActionEvent evt ) { 233 234 cancelButtonActionPerformed( evt ); 235 } 236 } ); 237 } 238 239 243 private void changeLookAndFeelButtonActionPerformed( java.awt.event.ActionEvent evt ) { 244 245 System.err.println( "JMOSProfileManagerDlg.changeLookAndFeelButtonActionPerformed() - Triggered" ); 246 247 javax.swing.tree.TreePath selectedPath = profileTree.getSelectionPath(); 248 249 if( selectedPath != null ) 250 profileTree.startEditingAtPath( selectedPath ); 251 } 252 253 258 private void newProfileButtonActionPerformed( java.awt.event.ActionEvent evt ) { 259 260 System.err.println( "JMOSProfileManagerDlg.newProfileButtonActionPerformed() - Triggered" ); 261 262 profileTree.addProfile( JSharedObjects.getLanguageManager().getStringEx( "NEW_PROFILE" ) ); 263 } 264 265 270 private void removeProfileButtonActionPerformed( java.awt.event.ActionEvent evt ) { 271 272 System.err.println( "JMOSProfileManagerDlg.removeProfileButtonActionPerformed() - Triggered" ); 273 274 JProfileTreeItem selectedProfile = profileTree.getSelectedItem(); 275 276 if( selectedProfile != null ) { 277 if( selectedProfile.getItemType() == JProfileTreeItem.TYPE_PROFILE ) { 278 profileTree.removeSelectedItem(); 279 return; 280 } 281 } 282 283 javax.swing.JOptionPane.showMessageDialog( this, JSharedObjects.getLanguageManager().getStringEx( "PLEASE_SELECT_PROFILE_WARNING" ), JSharedObjects.getLanguageManager().getStringEx( "INFORMATION" ), javax.swing.JOptionPane.INFORMATION_MESSAGE ); 284 } 285 286 291 private void selectProfileButtonActionPerformed( java.awt.event.ActionEvent evt ) { 292 293 System.err.println( "JMOSProfileManagerDlg.selectProfileButtonActionPerformed() - Triggered" ); 294 295 JProfileTreeItem selectedProfile = profileTree.getSelectedItem(); 296 297 298 if( selectedProfile != null ) { 299 if( selectedProfile.getItemType() == JProfileTreeItem.TYPE_PROFILE ) { 300 profileTree.setDefaultProfile(); 301 302 if( JSharedObjects.getProfileManager().getDefaultProfile() != JSharedObjects.getProfileManager().getProfileId() ) 304 javax.swing.JOptionPane.showMessageDialog( this, JSharedObjects.getLanguageManager().getStringEx( "PROFILE_ACTIVATION_WARNING" ), JSharedObjects.getLanguageManager().getStringEx( "INFORMATION" ), javax.swing.JOptionPane.INFORMATION_MESSAGE ); 305 306 selectProfileBtn.setEnabled( false ); 307 308 return; 309 } 310 } 311 312 javax.swing.JOptionPane.showMessageDialog( this, JSharedObjects.getLanguageManager().getStringEx( "PLEASE_SELECT_PROFILE_WARNING" ), JSharedObjects.getLanguageManager().getStringEx( "INFORMATION" ), javax.swing.JOptionPane.INFORMATION_MESSAGE ); 313 } 314 315 320 private void okButtonActionPerformed( java.awt.event.ActionEvent evt ) { 321 322 JSharedObjects.getConfiguration().setProfileWindowProperties( this.getLocation(), this.getSize() ); 323 closeDialog( null ); 324 } 325 326 331 private void cancelButtonActionPerformed( java.awt.event.ActionEvent evt ) { 332 333 JSharedObjects.getConfiguration().setProfileWindowProperties( this.getLocation(), this.getSize() ); 334 JSharedObjects.getLookAndFeelManager().loadDefaultLookAndFeel(); 335 closeDialog( null ); 336 } 337 338 343 private void closeDialog( java.awt.event.WindowEvent evt ) { 344 345 setVisible( false ); 346 dispose(); 347 } 348 349 356 public void valueChanged( javax.swing.event.TreeSelectionEvent treeSelectionEvent ) { 357 358 javax.swing.tree.TreePath path = treeSelectionEvent.getPath(); 359 int nPathCount = path.getPathCount(); 360 JProfileMutableTreeNode node = ( JProfileMutableTreeNode ) path.getPathComponent( nPathCount - 1 ); 361 JProfileTreeItem item = ( JProfileTreeItem ) node.getUserObject(); 362 363 364 switch( item.getItemType() ) { 365 366 case JProfileTreeItem.TYPE_PLUGIN : { 367 removeProfileBtn.setEnabled( false ); 368 selectProfileBtn.setEnabled( false ); 369 changeLookAndFeelBtn.setEnabled( false ); 370 } break; 371 372 case JProfileTreeItem.TYPE_PROFILE : { 373 removeProfileBtn.setEnabled( true ); 374 375 if( item.getProfileId() == JSharedObjects.getProfileManager().getDefaultProfile() ) 376 selectProfileBtn.setEnabled( false ); 377 else 378 selectProfileBtn.setEnabled( true ); 379 380 changeLookAndFeelBtn.setEnabled( false ); 381 } break; 382 383 case JProfileTreeItem.TYPE_LOOKNFEEL : { 384 removeProfileBtn.setEnabled( false ); 385 selectProfileBtn.setEnabled( false ); 386 changeLookAndFeelBtn.setEnabled( true ); 387 } break; 388 389 default : { 390 removeProfileBtn.setEnabled( false ); 391 selectProfileBtn.setEnabled( false ); 392 changeLookAndFeelBtn.setEnabled( false ); 393 } break; 394 } 395 } 396 } 397 | Popular Tags |