From: <ba...@us...> - 2008-10-22 16:09:47
|
Revision: 2172 http://obo.svn.sourceforge.net/obo/?rev=2172&view=rev Author: balhoff Date: 2008-10-22 16:09:42 +0000 (Wed, 22 Oct 2008) Log Message: ----------- Added preliminary window informing user that ontologies are being downloaded. Also added splash screen to Mac version (only works when running in Java 1.6). Modified Paths: -------------- phenex/trunk/.classpath phenex/trunk/build.xml phenex/trunk/src/org/phenoscape/main/PhenexStartupTask.java phenex/trunk/src/org/phenoscape/model/PhenoscapeController.java Added Paths: ----------- phenex/trunk/lib/swing-worker-1.2.jar phenex/trunk/src/org/phenoscape/swing/BlockingProgressDialog.java Modified: phenex/trunk/.classpath =================================================================== --- phenex/trunk/.classpath 2008-10-17 21:20:05 UTC (rev 2171) +++ phenex/trunk/.classpath 2008-10-22 16:09:42 UTC (rev 2172) @@ -84,5 +84,6 @@ <classpathentry kind="lib" path="lib/jpl.jar"/> <classpathentry kind="lib" path="lib/arq.jar"/> <classpathentry kind="lib" path="lib/commons-lang-2.4.jar"/> + <classpathentry kind="lib" path="lib/swing-worker-1.2.jar"/> <classpathentry kind="output" path="bin"/> </classpath> Modified: phenex/trunk/build.xml =================================================================== --- phenex/trunk/build.xml 2008-10-17 21:20:05 UTC (rev 2171) +++ phenex/trunk/build.xml 2008-10-22 16:09:42 UTC (rev 2172) @@ -205,7 +205,7 @@ <fileset file="log4j.xml"/> <manifest> <attribute name="Main-Class" value="${main-class}"/> - <attribute name="SplashScreen-Image" value="org/phenoscape/view/images/Seal-of-Phenex-medium.png"/> + <!-- <attribute name="SplashScreen-Image" value="org/phenoscape/view/images/Seal-of-Phenex-medium.png"/> --> </manifest> </jar> </target> @@ -217,11 +217,10 @@ <taskdef name="jarbundler" classname="net.sourceforge.jarbundler.JarBundler" classpath="${build-lib}/jarbundler-2.0.0.jar"/> <!-- Create a self-contained double-clickable app bundle for Mac OS X in "dist/Phenex.app" --> <target name="dist-mac" depends="jar, dist-init"> - <jarbundler dir="${dist}" name="Phenex" mainclass="${main-class}" jvmversion="1.5+" vmoptions="-Xmx1024M" version="${phenex.version}" build="${phenex.build}" icon="launchers/macosx/Seal-of-Phenex.icns"> + <jarbundler dir="${dist}" name="Phenex" mainclass="${main-class}" jvmversion="1.5+" vmoptions="-Xmx1024M" version="${phenex.version}" build="${phenex.build}" icon="launchers/macosx/Seal-of-Phenex.icns" splashfile="$JAVAROOT/Seal-of-Phenex-medium.png"> <jarfileset file="${jarfile}"/> <jarfileset dir="${lib}"/> - <!-- splashfile="$JAVAROOT/phenote_logo.jpg" temp from jarbundler--> - <!--<javafilelist dir="images" files="phenote_logo.jpg"/>--> + <javafilelist dir="src/org/phenoscape/view/images" files="Seal-of-Phenex-medium.png"/> <javaproperty name="apple.laf.useScreenMenuBar" value="true"/> <javaproperty name="phenex.version" value="${phenex.version}"/> <javaproperty name="phenex.build" value="${phenex.build}"/> Added: phenex/trunk/lib/swing-worker-1.2.jar =================================================================== (Binary files differ) Property changes on: phenex/trunk/lib/swing-worker-1.2.jar ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Modified: phenex/trunk/src/org/phenoscape/main/PhenexStartupTask.java =================================================================== --- phenex/trunk/src/org/phenoscape/main/PhenexStartupTask.java 2008-10-17 21:20:05 UTC (rev 2171) +++ phenex/trunk/src/org/phenoscape/main/PhenexStartupTask.java 2008-10-22 16:09:42 UTC (rev 2172) @@ -4,6 +4,7 @@ import java.io.File; import java.util.ArrayList; import java.util.Collection; +import java.util.concurrent.ExecutionException; import javax.swing.AbstractAction; import javax.swing.Action; @@ -20,9 +21,12 @@ import org.bbop.framework.GUITask; import org.bbop.framework.dock.LayoutDriver; import org.bbop.framework.dock.idw.IDWDriver; +import org.jdesktop.swingworker.SwingWorker; import org.oboedit.gui.tasks.DefaultGUIStartupTask; import org.phenoscape.app.CrossPlatform; +import org.phenoscape.model.OntologyController; import org.phenoscape.model.PhenoscapeController; +import org.phenoscape.swing.BlockingProgressDialog; import org.phenoscape.swing.WindowSizePrefsSaver; import org.phenoscape.view.CharacterMatrixComponentFactory; import org.phenoscape.view.CharacterTableComponentFactory; @@ -99,7 +103,28 @@ @Override protected void configureSystem() { super.configureSystem(); - this.controller = new PhenoscapeController(); + final SwingWorker<OntologyController, Void> ontologyLoader = new SwingWorker<OntologyController, Void>() { + @Override + protected OntologyController doInBackground() { + return new OntologyController(); + } + }; + // you would expect that displaying the progress dialog would make the splash screen go away, but it doesn't + this.flashJFrameToMakeSplashScreenGoAway(); + final BlockingProgressDialog<OntologyController, Void> dialog = new BlockingProgressDialog<OntologyController, Void>(ontologyLoader, "Phenex is checking for ontology updates. It may take some time to download and configure ontologies."); + dialog.setTitle("Launching " + this.getAppName()); + dialog.setSize(400, 150); + dialog.setLocationRelativeTo(null); + dialog.run(); + try { + this.controller = new PhenoscapeController(ontologyLoader.get()); + } catch (InterruptedException e) { + log().fatal("Failed to create ontology controller", e); + GUIManager.exit(1); + } catch (ExecutionException e) { + log().fatal("Failed to create ontology controller", e); + GUIManager.exit(1); + } this.controller.setAppName(this.getAppName()); } @@ -188,6 +213,12 @@ // hopefully none of these tasks are needed for operations in Phenex return new ArrayList<GUITask>(); } + + private void flashJFrameToMakeSplashScreenGoAway() { + final JFrame frame = new JFrame(); + frame.setVisible(true); + frame.setVisible(false); + } private Logger log() { return Logger.getLogger(this.getClass()); Modified: phenex/trunk/src/org/phenoscape/model/PhenoscapeController.java =================================================================== --- phenex/trunk/src/org/phenoscape/model/PhenoscapeController.java 2008-10-17 21:20:05 UTC (rev 2171) +++ phenex/trunk/src/org/phenoscape/model/PhenoscapeController.java 2008-10-22 16:09:42 UTC (rev 2172) @@ -32,7 +32,7 @@ public class PhenoscapeController extends DocumentController { - private final OntologyController ontologyController = new OntologyController(); + private final OntologyController ontologyController; private final DataSet dataSet = new DataSet(); private final SortedList<Character> sortedCharacters; private final EventSelectionModel<Character> charactersSelectionModel; @@ -49,8 +49,9 @@ private String appName; private final List<NewDataListener> newDataListeners = new ArrayList<NewDataListener>(); - public PhenoscapeController() { + public PhenoscapeController(OntologyController ontologyController) { super(); + this.ontologyController = ontologyController; this.sortedCharacters = new SortedList<Character>(this.dataSet.getCharacters(), new EverythingEqualComparator<Character>()); this.charactersSelectionModel = new EventSelectionModel<Character>(this.sortedCharacters); new ListSelectionMaintainer<Character>(this.sortedCharacters, this.charactersSelectionModel); Added: phenex/trunk/src/org/phenoscape/swing/BlockingProgressDialog.java =================================================================== --- phenex/trunk/src/org/phenoscape/swing/BlockingProgressDialog.java (rev 0) +++ phenex/trunk/src/org/phenoscape/swing/BlockingProgressDialog.java 2008-10-22 16:09:42 UTC (rev 2172) @@ -0,0 +1,76 @@ +package org.phenoscape.swing; + +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Insets; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; + +import javax.swing.JDialog; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JProgressBar; + +import org.jdesktop.swingworker.SwingWorker; + +/** + * A modal dialog which displays a message and an indeterminate progress bar + * while a executing a SwingWorker object. The dialog closes and returns when the SwingWorker + * finishes executing. + * + * @author Jim Balhoff + */ +public class BlockingProgressDialog<T, V> extends JDialog { + + private final SwingWorker<T, V> worker; + private String message; + + public BlockingProgressDialog(SwingWorker<T, V> worker, String message) { + super(new JFrame(), true); + this.worker = worker; + this.message = message; + this.worker.addPropertyChangeListener(new WorkerListener()); + this.initializeInterface(); + } + + /** + * Display the dialog and execute the SwingWorker. Returns when the + * SwingWorker completes execution. + */ + public void run() { + this.worker.execute(); + this.setVisible(true); + } + + private void initializeInterface() { + this.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); + this.setResizable(false); + this.setLayout(new GridBagLayout()); + // surrounding with html tags makes the JLable wrap its text + final JLabel label = new JLabel("<HTML>" + this.message + "</HTML>"); + final GridBagConstraints labelConstraints = new GridBagConstraints(); + labelConstraints.insets = new Insets(11, 11, 11, 11); + labelConstraints.fill = GridBagConstraints.BOTH; + labelConstraints.weightx = 1.0; + labelConstraints.weighty = 1.0; + this.add(label, labelConstraints); + final GridBagConstraints progressConstraints = new GridBagConstraints(); + progressConstraints.gridy = 1; + progressConstraints.fill = GridBagConstraints.HORIZONTAL; + progressConstraints.insets = new Insets(11, 11, 11, 11); + final JProgressBar progress = new JProgressBar(); + progress.setIndeterminate(true); + this.add(progress, progressConstraints); + } + + private class WorkerListener implements PropertyChangeListener { + + public void propertyChange(PropertyChangeEvent evt) { + if ("state".equals(evt.getPropertyName()) && worker.getState().equals(SwingWorker.StateValue.DONE)) { + BlockingProgressDialog.this.setVisible(false); + } + } + + } + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |