[jsword-svn] bibledesktop/java/main/org/crosswire/bibledesktop/desktop s

jswordcvs at crosswire.org jswordcvs at crosswire.org
Sat Jun 11 07:26:36 MST 2005


Update of /cvs/jsword/bibledesktop/java/main/org/crosswire/bibledesktop/desktop
In directory www.crosswire.org:/tmp/cvs-serv21146/java/main/org/crosswire/bibledesktop/desktop

Modified Files:
	Desktop.java 
Log Message:
Made the startup experience a bit nicer.

Index: Desktop.java
===================================================================
RCS file: /cvs/jsword/bibledesktop/java/main/org/crosswire/bibledesktop/desktop/Desktop.java,v
retrieving revision 1.45
retrieving revision 1.46
diff -C2 -d -r1.45 -r1.46
*** Desktop.java	17 May 2005 00:44:31 -0000	1.45
--- Desktop.java	11 Jun 2005 14:26:34 -0000	1.46
***************
*** 48,51 ****
--- 48,52 ----
  import javax.swing.JPopupMenu;
  import javax.swing.JSplitPane;
+ import javax.swing.SwingUtilities;
  import javax.swing.WindowConstants;
  
***************
*** 127,131 ****
                      LookAndFeelUtil.initialize();
  
!                     Desktop desktop = new Desktop();
  
                      // change the size and location before showing the application.
--- 128,134 ----
                      LookAndFeelUtil.initialize();
  
!                     final Splash splash = new Splash();
! 
!                     final Desktop desktop = new Desktop();
  
                      // change the size and location before showing the application.
***************
*** 133,140 ****
                      GuiUtil.centerWindow(desktop);
  
!                     // Don't use pack.
!                     // It uses preferred dimensions, which are not used here.
!                     desktop.toFront();
!                     desktop.setVisible(true);
                  }
              };
--- 136,151 ----
                      GuiUtil.centerWindow(desktop);
  
!                     // Now bring up the app and offer to install books if the user has none.
!                     SwingUtilities.invokeLater(new Runnable()
!                         {
!                             public void run()
!                             {
!                                 splash.close();
!                                 desktop.setVisible(true);
!                                 desktop.establishPreferredSize();
!                                 desktop.pack();
!                                 desktop.checkForBooks();
!                             }
!                         });
                  }
              };
***************
*** 161,184 ****
          Project project = Project.instance();
  
          // Load the configuration.
!         // This has to be done before any gui components are created are created.
          // This includes code that is invoked by it.
          generateConfig();
  
-         // Listen for book changes so that the Options can be kept current
-         BooksListener cbl = new BooksListener()
-         {
-             public void bookAdded(BooksEvent ev)
-             {
-                 generateConfig();
-             }
- 
-             public void bookRemoved(BooksEvent ev)
-             {
-                 generateConfig();
-             }
-         };
-         Books.installed().addBooksListener(cbl);
- 
          // Make this be the root frame of optiondialogs
          JOptionPane.setRootFrame(this);
--- 172,186 ----
          Project project = Project.instance();
  
+         // Splash screen
+         URL predicturl = project.getWritablePropertiesURL(SPLASH_PROPS);
+         Job startJob = JobManager.createJob(Msg.STARTUP_TITLE.toString(), predicturl, true);
+ 
          // Load the configuration.
!         // This has to be done before any gui components are created.
!         // (Other than the splash)
          // This includes code that is invoked by it.
+         startJob.setProgress(Msg.STARTUP_CONFIG.toString());
          generateConfig();
  
          // Make this be the root frame of optiondialogs
          JOptionPane.setRootFrame(this);
***************
*** 187,230 ****
          Reporter.grabAWTExecptions(true);
  
-         // Splash screen
-         URL predicturl = project.getWritablePropertiesURL(SPLASH_PROPS);
-         Splash splash = new Splash();
-         Job startJob = JobManager.createJob(Msg.STARTUP_TITLE.toString(), predicturl, true);
-         splash.pack();
- 
          // Create the Desktop Actions
          actions = new DesktopActions(this);
  
-         startJob.setProgress(Msg.STARTUP_CONFIG.toString());
- 
          startJob.setProgress(Msg.STARTUP_GENERATE.toString());
          createComponents();
  
          // GUI setup
          debug();
          init();
  
!         // This is technically overkill, but it does hide the reference pane if
!         // there are no reference works
!         refreshBooks();
! 
!         // Configuration
!         startJob.setProgress(Msg.STARTUP_GENERAL_CONFIG.toString());
! 
!         startJob.done();
!         splash.close();
! 
!         // News users probably wont have any Bibles installedso we give them a
!         // hand getting to the installation diallog.
!         List bibles = Books.installed().getBooks(BookFilters.getBibles());
!         if (bibles.size() == 0)
          {
!             int reply = JOptionPane.showConfirmDialog(this, Msg.NO_BIBLES_MESSAGE, Msg.NO_BIBLES_TITLE.toString(), JOptionPane.OK_CANCEL_OPTION,
!                             JOptionPane.QUESTION_MESSAGE);
!             if (reply == JOptionPane.OK_OPTION)
              {
!                 actions.doBooks();
              }
!         }
      }
  
--- 189,220 ----
          Reporter.grabAWTExecptions(true);
  
          // Create the Desktop Actions
          actions = new DesktopActions(this);
  
          startJob.setProgress(Msg.STARTUP_GENERATE.toString());
          createComponents();
  
+         // Configuration
+         startJob.setProgress(Msg.STARTUP_GENERAL_CONFIG.toString());
          // GUI setup
          debug();
          init();
  
!         // Listen for book changes so that the Options can be kept current
!         BooksListener cbl = new BooksListener()
          {
!             public void bookAdded(BooksEvent ev)
              {
!                 generateConfig();
              }
! 
!             public void bookRemoved(BooksEvent ev)
!             {
!                 generateConfig();
!             }
!         };
!         Books.installed().addBooksListener(cbl);
! 
!         startJob.done();
      }
  
***************
*** 428,431 ****
--- 418,432 ----
          setTitle(Msg.getApplicationTitle());
      }
+     
+     /**
+      * Get the size of the content panel and make that the preferred size.
+      */
+     public void establishPreferredSize()
+     {
+         JComponent contentPane = (JComponent) getContentPane();
+         contentPane.setPreferredSize(contentPane.getSize());
+         
+         log.warn("The size of the contentpane is: " + contentPane.getSize()); //$NON-NLS-1$
+     }
  
      /**
***************
*** 700,703 ****
--- 701,720 ----
      }
  
+     public void checkForBooks()
+     {
+         // News users probably wont have any Bibles installed so we give them a
+         // hand getting to the installation dialog.
+         List bibles = Books.installed().getBooks(BookFilters.getBibles());
+         if (bibles.size() == 0)
+         {
+             int reply = JOptionPane.showConfirmDialog(this, Msg.NO_BIBLES_MESSAGE, Msg.NO_BIBLES_TITLE.toString(), JOptionPane.OK_CANCEL_OPTION,
+                             JOptionPane.QUESTION_MESSAGE);
+             if (reply == JOptionPane.OK_OPTION)
+             {
+                 actions.doBooks();
+             }
+         }
+     }
+ 
      /**
       * @param maxHeight The maxHeight to set.



More information about the jsword-svn mailing list