Author: mes
Date: 2009-07-27 17:03:07 -0700 (Mon, 27 Jul 2009)
New Revision: 17586
Added:
cytoscape3/trunk/application/src/main/java/cytoscape/CytoscapeShutdown.java
cytoscape3/trunk/application/src/main/java/cytoscape/events/CytoscapeShutdownEvent.java
cytoscape3/trunk/application/src/main/java/cytoscape/events/CytoscapeShutdownListener.java
cytoscape3/trunk/application/src/main/java/cytoscape/internal/CyVersion.java
cytoscape3/trunk/application/src/main/java/cytoscape/internal/SessionShutdownHandler.java
cytoscape3/trunk/application/src/main/java/cytoscape/internal/ShutdownHandler.java
Removed:
cytoscape3/trunk/application/src/main/java/cytoscape/CyMain.java
Modified:
cytoscape3/trunk/application/src/main/java/cytoscape/Cytoscape.java
cytoscape3/trunk/application/src/main/java/cytoscape/CytoscapeVersion.java
cytoscape3/trunk/application/src/main/java/cytoscape/internal/actions/DeleteAction.java
cytoscape3/trunk/application/src/main/java/cytoscape/internal/actions/ExitAction.java
cytoscape3/trunk/application/src/main/java/cytoscape/internal/view/CytoPanelImp.java
cytoscape3/trunk/application/src/main/java/cytoscape/internal/view/CytoscapeDesktop.java
cytoscape3/trunk/application/src/main/resources/META-INF/spring/bundle-context-osgi.xml
cytoscape3/trunk/application/src/main/resources/META-INF/spring/bundle-context.xml
cytoscape3/trunk/application/src/main/resources/cytoscape.props
Log:
refactored version and moved shutdown from Cytoscape.java to a service
Deleted: cytoscape3/trunk/application/src/main/java/cytoscape/CyMain.java
===================================================================
--- cytoscape3/trunk/application/src/main/java/cytoscape/CyMain.java
2009-07-27 22:09:00 UTC (rev 17585)
+++ cytoscape3/trunk/application/src/main/java/cytoscape/CyMain.java
2009-07-28 00:03:07 UTC (rev 17586)
@@ -1,421 +0,0 @@
-/*
- File: CyMain.java
-
- Copyright (c) 2006, The Cytoscape Consortium (www.cytoscape.org)
-
- The Cytoscape Consortium is:
- - Institute for Systems Biology
- - University of California San Diego
- - Memorial Sloan-Kettering Cancer Center
- - Institut Pasteur
- - Agilent Technologies
-
- This library is free software; you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as published
- by the Free Software Foundation; either version 2.1 of the License, or
- any later version.
-
- This library is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF
- MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. The software and
- documentation provided hereunder is on an "as is" basis, and the
- Institute for Systems Biology and the Whitehead Institute
- have no obligations to provide maintenance, support,
- updates, enhancements or modifications. In no event shall the
- Institute for Systems Biology and the Whitehead Institute
- be liable to any party for direct, indirect, special,
- incidental or consequential damages, including lost profits, arising
- out of the use of this software and its documentation, even if the
- Institute for Systems Biology and the Whitehead Institute
- have been advised of the possibility of such damage. See
- the GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with this library; if not, write to the Free Software Foundation,
- Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- */
-package cytoscape;
-
-
-import cytoscape.util.FileUtil;
-import cytoscape.view.CySwingApplication;
-import org.apache.commons.cli.*;
-import org.cytoscape.session.CyNetworkManager;
-
-
-import javax.swing.*;
-
-import java.awt.*;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Properties;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * This is the main startup class for Cytoscape.
- *
- * <p>
- * Look and Feel is modified for jgoodies 2.1.4 by Kei Ono
- * </p>
- */
-public class CyMain {
- protected String[] args;
- protected Properties props;
- protected String[] graphFiles;
- protected String[] plugins;
- protected Properties vizmapProps;
-
- protected static String sessionFile;
-
- protected String[] nodeAttrFiles;
- protected String[] edgeAttrFiles;
- protected String[] expressionFiles;
- protected org.apache.commons.cli.Options options;
- protected CytoscapeVersion ver;
- protected FileUtil fileUtil;
-
- protected static void setupLookAndFeel() {
-// try {
-// if (LookUtils.IS_OS_WINDOWS) {
-// /*
-// * For Windows: just use platform default look
& feel.
-// */
-// UIManager
-//
.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
-// } else if (LookUtils.IS_OS_MAC) {
-// /*
-// * For Mac: move menue bar to OS X default bar
(next to Apple
-// * icon)
-// */
-//
System.setProperty("apple.laf.useScreenMenuBar", "true");
-// } else {
-// /*
-// * For Unix platforms, use JGoodies Looks
-// */
-// final Properties props = System.getProperties();
-// String JVMVersion =
props.getProperty("java.version");
-// System.out.println("JVM Version = " +
JVMVersion);
-// if (JVMVersion.startsWith("1.6")) {
-// System.out.println("SE6 found. Use
Nimbus...");
-// UIManager
-//
.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
-// }
-// }
-// } catch (Exception e) {
-// System.err.println("Can't set look & feel:" + e);
-// }
- }
-
-
- /**
- * Creates a new CyMain object.
- *
- * @param args
- * DOCUMENT ME!
- *
- * @throws Exception
- * DOCUMENT ME!
- */
- public CyMain(CySwingApplication desk, CyNetworkManager netmgr,
- CytoscapeVersion ver, FileUtil fileUtil) throws
Exception {
- this(new String[] {}, desk, netmgr, ver, fileUtil);
- }
-
- public CyMain(String[] args, CySwingApplication desk,
- CyNetworkManager netmgr, CytoscapeVersion ver, FileUtil
fileUtil)
- throws Exception {
- System.out.println("CyMain constructor");
- this.ver = ver;
- this.fileUtil = fileUtil;
-
- if (System.getProperty("os.name").startsWith("Mac")) {
- /*
- * By kono 4/2/2007 Fix Application name for Mac.
- */
- final String version = ver.getVersion();
- System.setProperty(
-
"com.apple.mrj.application.apple.menu.about.name", version);
- System.setProperty("apple.awt.brushMetalRounded",
"true");
- System.setProperty("apple.awt.antialiasing", "on");
- System.setProperty("apple.awt.rendering",
"VALUE_RENDER_SPEED");
- }
-
- props = null;
- graphFiles = null;
- plugins = null;
- vizmapProps = null;
- sessionFile = null;
- nodeAttrFiles = null;
- edgeAttrFiles = null;
- expressionFiles = null;
- this.args = args;
- options = new org.apache.commons.cli.Options();
-
- parseCommandLine(args);
-
- Cytoscape.setDesktop(desk);
- Cytoscape.setNetworkManager(netmgr);
- }
-
- protected void parseCommandLine(String[] args) {
- // create the options
- options.addOption("h", "help", false, "Print this message.");
- options.addOption("v", "version", false, "Print the version
number.");
- // commented out until we actually support doing anything in
headless
- // mode
- // options.addOption("H", "headless", false,
- // "Run in headless (no gui) mode.");
-
options.addOption(OptionBuilder.withLongOpt("session").withDescription(
- "Load a cytoscape session (.cys)
file.").withValueSeparator(
- '\0').withArgName("file").hasArg() // only
allow one session!!!
- .create("s"));
-
-
options.addOption(OptionBuilder.withLongOpt("network").withDescription(
- "Load a network file (any
format).").withValueSeparator('\0')
- .withArgName("file").hasArgs().create("N"));
-
- options
- .addOption(OptionBuilder
- .withLongOpt("edge-attrs")
- .withDescription(
- "Load an edge
attributes file (edge attribute format).")
-
.withValueSeparator('\0').withArgName("file").hasArgs()
- .create("e"));
- options.addOption(OptionBuilder.withLongOpt("node-attrs")
- .withDescription(
- "Load a node attributes file
(node attribute format).")
-
.withValueSeparator('\0').withArgName("file").hasArgs().create(
- "n"));
-
options.addOption(OptionBuilder.withLongOpt("matrix").withDescription(
- "Load a node attribute matrix file (table).")
-
.withValueSeparator('\0').withArgName("file").hasArgs().create(
- "m"));
-
- options
- .addOption(OptionBuilder
- .withLongOpt("plugin")
- .withDescription(
- "Load a plugin
jar file, directory of jar files, plugin class name, or plugin jar URL.")
-
.withValueSeparator('\0').withArgName("file").hasArgs()
- .create("p"));
-
- options
- .addOption(OptionBuilder
- .withLongOpt("props")
- .withDescription(
- "Load cytoscape
properties file (Java properties format) or individual property: -P
name=value.")
-
.withValueSeparator('\0').withArgName("file").hasArgs()
- .create("P"));
-
options.addOption(OptionBuilder.withLongOpt("vizmap").withDescription(
- "Load vizmap properties file (Java properties
format).")
-
.withValueSeparator('\0').withArgName("file").hasArgs().create(
- "V"));
-
- // try to parse the cmd line
- CommandLineParser parser = new PosixParser();
- CommandLine line = null;
-
- try {
- line = parser.parse(options, args);
- } catch (ParseException e) {
- System.err
- .println("Parsing command line failed:
" + e.getMessage());
- printHelp();
- System.exit(1);
- }
-
- // Read any argument containing ".cys" as session file.
- // Allows session files to be passed in via MIME type settings.
- // This imprecise method is overwritten by -s option, if
specified.
- for (String freeArg : args) {
- if (freeArg.contains(".cys")) {
- sessionFile = freeArg;
- }
- }
-
- // use what is found on the command line to set values
- if (line.hasOption("h")) {
- printHelp();
- System.exit(0);
- }
-
- if (line.hasOption("v")) {
- System.out.println(ver.getVersion());
- System.exit(0);
- }
-
- if (line.hasOption("P"))
- props = createProperties(line.getOptionValues("P"));
- else
- props = createProperties(new String[0]);
-
- if (line.hasOption("N"))
- graphFiles = line.getOptionValues("N");
-
- if (line.hasOption("p"))
- plugins = line.getOptionValues("p");
-
- if (line.hasOption("V"))
- vizmapProps =
createProperties(line.getOptionValues("V"));
- else
- vizmapProps = createProperties(new String[0]);
-
- if (line.hasOption("s"))
- sessionFile = line.getOptionValue("s");
-
- if (line.hasOption("n"))
- nodeAttrFiles = line.getOptionValues("n");
-
- if (line.hasOption("e"))
- edgeAttrFiles = line.getOptionValues("e");
-
- if (line.hasOption("m"))
- expressionFiles = line.getOptionValues("m");
- }
-
-
- protected void printHelp() {
- HelpFormatter formatter = new HelpFormatter();
- formatter.printHelp("java -Xmx512M -jar cytoscape.jar
[OPTIONS]",
- options);
- }
-
- /**
- * DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- */
- public Properties getProps() {
- return props;
- }
-
- /**
- * DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- */
- public Properties getVizProps() {
- return vizmapProps;
- }
-
- private Properties createProperties(String[] potentialProps) {
- // for ( String asdf: potentialProps)
- // System.out.println("prop: '" + asdf + "'");
- Properties props = new Properties();
- Properties argProps = new Properties();
-
- Matcher propPattern = Pattern.compile("^((\\w+\\.*)+)\\=(.+)$")
- .matcher("");
-
- for (int i = 0; i < potentialProps.length; i++) {
- propPattern.reset(potentialProps[i]);
-
- // check to see if the string is a key value pair
- if (propPattern.matches()) {
- argProps
-
.setProperty(propPattern.group(1), propPattern.group(3));
-
- // otherwise assume it's a file/url
- } else {
- try {
- InputStream in =
fileUtil.getInputStream(potentialProps[i]);
-
- if (in != null)
- props.load(in);
- else
- System.out.println("Couldn't
load property: "
- +
potentialProps[i]);
- } catch (IOException e) {
- System.out.println("Couldn't load
property: "
- + potentialProps[i]);
- e.printStackTrace();
- }
- }
- }
-
- // Transfer argument properties into the full properties.
- // We do this so that anything specified on the command line
- // overrides anything specified in a file.
- props.putAll(argProps);
-
- return props;
- }
-
- /**
- * DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- */
- public List<String> getGraphFiles() {
- return createList(graphFiles);
- }
-
- /**
- * DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- */
- public List<String> getEdgeAttributeFiles() {
- return createList(edgeAttrFiles);
- }
-
- /**
- * DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- */
- public List<String> getNodeAttributeFiles() {
- return createList(nodeAttrFiles);
- }
-
- /**
- * DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- */
- public List<String> getExpressionFiles() {
- return createList(expressionFiles);
- }
-
- /**
- * DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- */
- public List<String> getPlugins() {
- return createList(plugins);
- }
-
- /**
- * DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- */
- public String getSessionFile() {
- return sessionFile;
- }
-
- /**
- * DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- */
- public String[] getArgs() {
- return args;
- }
-
- private List<String> createList(String[] vals) {
- if (vals == null)
- return new ArrayList<String>();
-
- ArrayList<String> a = new ArrayList<String>(vals.length);
-
- for (int i = 0; i < vals.length; i++)
- a.add(i, vals[i]);
-
- return a;
- }
-}
Modified: cytoscape3/trunk/application/src/main/java/cytoscape/Cytoscape.java
===================================================================
--- cytoscape3/trunk/application/src/main/java/cytoscape/Cytoscape.java
2009-07-27 22:09:00 UTC (rev 17585)
+++ cytoscape3/trunk/application/src/main/java/cytoscape/Cytoscape.java
2009-07-28 00:03:07 UTC (rev 17586)
@@ -149,66 +149,8 @@
// Test
protected static Object pcs2 = new Object();
protected static PropertyChangeSupport newPcs = new
PropertyChangeSupport(pcs2);
- protected static CySwingApplication defaultDesktop;
- private static CyNetworkManager netmgr;
-
- /**
- * Shuts down Cytoscape, after giving plugins time to react.
- *
- * @param returnVal
- * The return value. Zero indicates success, non-zero
otherwise.
- */
- public static void exit(int returnVal) {
- // prompt the user about saving modified files before
quitting
- if (confirmQuit()) {
- try {
- firePropertyChange(CYTOSCAPE_EXIT,
null, "now");
- } catch (Exception e) {
- System.out.println("Errors on close,
closed anyways.");
- }
-
- System.out.println("Cytoscape Exiting....");
-
- System.exit(returnVal);
- } else {
- return;
- }
- }
-
- /**
- * Prompt the user about saving modified files before quitting.
- */
- private static boolean confirmQuit() {
- final String msg = "Do you want to save your session?";
- int networkCount = netmgr.getNetworkSet().size();
-
- // If there is no network, just quit.
- if (networkCount == 0) {
- return true;
- }
-
- //
- // Confirm user to save current session or not.
- //
- Object[] options = { "Yes, save and quit", "No, just quit",
"Cancel" };
- int n =
JOptionPane.showOptionDialog(defaultDesktop.getJFrame(), msg,
- "Save Networks Before
Quitting?",
- JOptionPane.YES_NO_OPTION,
-
JOptionPane.QUESTION_MESSAGE, null, options, options[0]);
-
- if (n == JOptionPane.NO_OPTION) {
- return true;
- } else if (n == JOptionPane.YES_OPTION) {
- // TODO
- System.out.println("NOT implemented");
- return true;
- } else {
- return false; // default if dialog box is closed
- }
- }
-
// --------------------//
// Root Graph Methods
// --------------------//
@@ -234,25 +176,7 @@
return newPcs;
}
-
/**
- * Don't use this!.
- * TODO resolve how the desktop is accessed.
- */
- public static void setDesktop(CySwingApplication desk ) {
- if ( desk != null )
- defaultDesktop = desk;
- }
-
- /**
- * Don't use this!.
- */
- static void setNetworkManager(CyNetworkManager nm) {
- if ( nm != null )
- netmgr = nm;
- }
-
- /**
* DOCUMENT ME!
*
* @param property_type DOCUMENT ME!
Added:
cytoscape3/trunk/application/src/main/java/cytoscape/CytoscapeShutdown.java
===================================================================
--- cytoscape3/trunk/application/src/main/java/cytoscape/CytoscapeShutdown.java
(rev 0)
+++ cytoscape3/trunk/application/src/main/java/cytoscape/CytoscapeShutdown.java
2009-07-28 00:03:07 UTC (rev 17586)
@@ -0,0 +1,47 @@
+
+/*
+ File: CytoscapeShutdown.java
+
+ Copyright (c) 2006, The Cytoscape Consortium (www.cytoscape.org)
+
+ The Cytoscape Consortium is:
+ - Institute for Systems Biology
+ - University of California San Diego
+ - Memorial Sloan-Kettering Cancer Center
+ - Institut Pasteur
+ - Agilent Technologies
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation; either version 2.1 of the License, or
+ any later version.
+
+ This library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF
+ MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. The software and
+ documentation provided hereunder is on an "as is" basis, and the
+ Institute for Systems Biology and the Whitehead Institute
+ have no obligations to provide maintenance, support,
+ updates, enhancements or modifications. In no event shall the
+ Institute for Systems Biology and the Whitehead Institute
+ be liable to any party for direct, indirect, special,
+ incidental or consequential damages, including lost profits, arising
+ out of the use of this software and its documentation, even if the
+ Institute for Systems Biology and the Whitehead Institute
+ have been advised of the possibility of such damage. See
+ the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this library; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+package cytoscape;
+
+/**
+ * A service that will shutdown Cytoscape cleanly. Will fire a
+ * CytoscapeShutdownEvent such that all CytoscapeShutdownListener will be
+ * notified before actually shutting down.
+ */
+public interface CytoscapeShutdown {
+ void exit(int retVal);
+}
Modified:
cytoscape3/trunk/application/src/main/java/cytoscape/CytoscapeVersion.java
===================================================================
--- cytoscape3/trunk/application/src/main/java/cytoscape/CytoscapeVersion.java
2009-07-27 22:09:00 UTC (rev 17585)
+++ cytoscape3/trunk/application/src/main/java/cytoscape/CytoscapeVersion.java
2009-07-28 00:03:07 UTC (rev 17586)
@@ -1,98 +1,78 @@
/*
- * File: CytoscapeVersion.java Copyright (c) 2006, The Cytoscape Consortium
- * (www.cytoscape.org) The Cytoscape Consortium is: - Institute for Systems
- * Biology - University of California San Diego - Memorial Sloan-Kettering
- * Cancer Center - Institut Pasteur - Agilent Technologies This library is free
- * software; you can redistribute it and/or modify it under the terms of the
GNU
- * Lesser General Public License as published by the Free Software Foundation;
- * either version 2.1 of the License, or any later version. This library is
- * distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY,
- * WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR A
- * PARTICULAR PURPOSE. The software and documentation provided hereunder is on
- * an "as is" basis, and the Institute for Systems Biology and the Whitehead
- * Institute have no obligations to provide maintenance, support, updates,
- * enhancements or modifications. In no event shall the Institute for Systems
- * Biology and the Whitehead Institute be liable to any party for direct,
- * indirect, special, incidental or consequential damages, including lost
- * profits, arising out of the use of this software and its documentation, even
- * if the Institute for Systems Biology and the Whitehead Institute have been
- * advised of the possibility of such damage. See the GNU Lesser General Public
- * License for more details. You should have received a copy of the GNU Lesser
- * General Public License along with this library; if not, write to the Free
- * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- * USA.
- */
-package cytoscape;
+ File: CytoscapeVersion.java
-import java.util.Properties;
+ Copyright (c) 2006, The Cytoscape Consortium (www.cytoscape.org)
-/**
- * Identify the version of cytoscape.
- */
-public class CytoscapeVersion {
- public String version;
+ The Cytoscape Consortium is:
+ - Institute for Systems Biology
+ - University of California San Diego
+ - Memorial Sloan-Kettering Cancer Center
+ - Institut Pasteur
+ - Agilent Technologies
- private String majorMinorVersion;
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation; either version 2.1 of the License, or
+ any later version.
- private String bugFixVersion = "0";
+ This library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF
+ MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. The software and
+ documentation provided hereunder is on an "as is" basis, and the
+ Institute for Systems Biology and the Whitehead Institute
+ have no obligations to provide maintenance, support,
+ updates, enhancements or modifications. In no event shall the
+ Institute for Systems Biology and the Whitehead Institute
+ be liable to any party for direct, indirect, special,
+ incidental or consequential damages, including lost profits, arising
+ out of the use of this software and its documentation, even if the
+ Institute for Systems Biology and the Whitehead Institute
+ have been advised of the possibility of such damage. See
+ the GNU Lesser General Public License for more details.
+ You should have received a copy of the GNU Lesser General Public License
+ along with this library; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+package cytoscape;
- public CytoscapeVersion(Properties props) {
- version = props.getProperty("cytoscape.version.number");
- String[] vers = version.split("\\.");
- majorMinorVersion = vers[0] + "." + vers[1];
- if (vers.length == 3) {
- bugFixVersion = vers[2];
- }
- }
-
+public interface CytoscapeVersion {
+
/**
- * Returns the string 'Cytoscape Version ' and the version number Do
not use
- * to just get a version.
- *
- * @return DOCUMENT ME!
+ * The full version as a string, for example "3.2.5". Should
+ * not include any other text or name.
*/
- public String getVersion() {
- return "Cytoscape Version " + version;
- }
+ public String getVersion();
/**
- * @return See getVersion()
+ * The first of the three numbers defining the version of the
+ * software, meaning "3" if the version is "3.2.5". This number
+ * changes only for comprehensive software changes and while APIs
+ * may be similar between versions, they are not guaranteed to be
+ * compatible.
*/
- public String toString() {
- return getVersion();
- }
+ public int getMajorVersion();
+
/**
- * This method gets the major and minor version for Cytsocape ignoring
- * the bug fix version number. Example: If Cytoscape is currently at
2.4.6
- * this method will return 2.4
- *
- * @return The major and minor version numbers of the currently running
- * Cytoscape.
+ * The second of the three numbers defining the version of the
+ * software, meaning "2" if the version is "3.2.5". This number
+ * changes as new functionality or a new API is added to the software.
+ * Minor version APIs are guaranteed to be backwards compatibile for
+ * all previous versions within the major version (i.e. version 3.2
+ * will be completely compatible with all 3.1.x, and 3.0.x code).
*/
- public String getMajorVersion() {
- return majorMinorVersion;
- }
+ public int getMinorVersion();
+
/**
- * This method gets the bug fix version for Cytsocape.
- * Example: If Cytoscape is currently at 2.4.6 this method will return 6
- * If there is no bug fix version the default is 0
- *
- * @return Just the bug fix version
+ * The third of the three numbers defining the version of the
+ * software, meaning "5" if the version is "3.2.5". This number
+ * changes as bug fixes are made and no new features or APIs should be
+ * added. Bug fix version APIs are guaranteed to be backwards
+ * compatibile for all previous versions within the major version
+ * (i.e. version 3.2.5 will be completely compatible with all 3.x
+ * versions of the code).
*/
- public String getBugFixVersion() {
- return bugFixVersion;
- }
-
- /**
- *
- * @return Full version number for currently running Cytoscape.
- * Ex. 2.4.6
- */
- public String getFullVersion() {
- return version;
- }
-
+ public int getBugFixVersion();
}
Added:
cytoscape3/trunk/application/src/main/java/cytoscape/events/CytoscapeShutdownEvent.java
===================================================================
---
cytoscape3/trunk/application/src/main/java/cytoscape/events/CytoscapeShutdownEvent.java
(rev 0)
+++
cytoscape3/trunk/application/src/main/java/cytoscape/events/CytoscapeShutdownEvent.java
2009-07-28 00:03:07 UTC (rev 17586)
@@ -0,0 +1,18 @@
+
+package cytoscape.events;
+
+import org.cytoscape.event.CyEvent;
+
+/**
+ * An event fired immediately before Cytoscape will be shutdown.
+ */
+public interface CytoscapeShutdownEvent extends CyEvent<Object> {
+
+ /**
+ * A callback to the firing class that allows a listener to
+ * abort the shutdown. This can cause conflicts if abused.
+ * @param why A user comprehensible message describing why the shutdown
+ * was aborted.
+ */
+ void abortShutdown(String why);
+}
Added:
cytoscape3/trunk/application/src/main/java/cytoscape/events/CytoscapeShutdownListener.java
===================================================================
---
cytoscape3/trunk/application/src/main/java/cytoscape/events/CytoscapeShutdownListener.java
(rev 0)
+++
cytoscape3/trunk/application/src/main/java/cytoscape/events/CytoscapeShutdownListener.java
2009-07-28 00:03:07 UTC (rev 17586)
@@ -0,0 +1,11 @@
+
+package cytoscape.events;
+
+import org.cytoscape.event.CyListener;
+
+/**
+ *
+ */
+public interface CytoscapeShutdownListener extends CyListener {
+ public void handleEvent(CytoscapeShutdownEvent e);
+}
Added:
cytoscape3/trunk/application/src/main/java/cytoscape/internal/CyVersion.java
===================================================================
---
cytoscape3/trunk/application/src/main/java/cytoscape/internal/CyVersion.java
(rev 0)
+++
cytoscape3/trunk/application/src/main/java/cytoscape/internal/CyVersion.java
2009-07-28 00:03:07 UTC (rev 17586)
@@ -0,0 +1,91 @@
+/*
+ File: CytoscapeVersion.java
+
+ Copyright (c) 2006, The Cytoscape Consortium (www.cytoscape.org)
+
+ The Cytoscape Consortium is:
+ - Institute for Systems Biology
+ - University of California San Diego
+ - Memorial Sloan-Kettering Cancer Center
+ - Institut Pasteur
+ - Agilent Technologies
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation; either version 2.1 of the License, or
+ any later version.
+
+ This library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF
+ MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. The software and
+ documentation provided hereunder is on an "as is" basis, and the
+ Institute for Systems Biology and the Whitehead Institute
+ have no obligations to provide maintenance, support,
+ updates, enhancements or modifications. In no event shall the
+ Institute for Systems Biology and the Whitehead Institute
+ be liable to any party for direct, indirect, special,
+ incidental or consequential damages, including lost profits, arising
+ out of the use of this software and its documentation, even if the
+ Institute for Systems Biology and the Whitehead Institute
+ have been advised of the possibility of such damage. See
+ the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this library; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+package cytoscape.internal;
+
+import java.util.Properties;
+import cytoscape.CytoscapeVersion;
+
+/**
+ * Identify the version of cytoscape.
+ */
+public class CyVersion implements CytoscapeVersion {
+
+ private final int major;
+ private final int minor;
+ private final int bugfix;
+ private final String version;
+
+ public CyVersion(Properties props) {
+ version = props.getProperty("cytoscape.version.number");
+
+ if ( !version.matches("^\\d+\\.\\d+\\.\\d+$") )
+ throw new IllegalArgumentException("Malformed version
number: must be of the form X.Y.Z where X,Y, and Z are positive integers.");
+
+ final String[] vers = version.split("\\.");
+ major = Integer.parseInt(vers[0]);
+ minor = Integer.parseInt(vers[1]);
+ bugfix = Integer.parseInt(vers[2]);
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public String getVersion() {
+ return version;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public int getMajorVersion() {
+ return major;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public int getMinorVersion() {
+ return minor;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public int getBugFixVersion() {
+ return bugfix;
+ }
+}
Added:
cytoscape3/trunk/application/src/main/java/cytoscape/internal/SessionShutdownHandler.java
===================================================================
---
cytoscape3/trunk/application/src/main/java/cytoscape/internal/SessionShutdownHandler.java
(rev 0)
+++
cytoscape3/trunk/application/src/main/java/cytoscape/internal/SessionShutdownHandler.java
2009-07-28 00:03:07 UTC (rev 17586)
@@ -0,0 +1,89 @@
+
+/*
+ File: SessionShutdownHandler.java
+
+ Copyright (c) 2006, The Cytoscape Consortium (www.cytoscape.org)
+
+ The Cytoscape Consortium is:
+ - Institute for Systems Biology
+ - University of California San Diego
+ - Memorial Sloan-Kettering Cancer Center
+ - Institut Pasteur
+ - Agilent Technologies
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation; either version 2.1 of the License, or
+ any later version.
+
+ This library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF
+ MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. The software and
+ documentation provided hereunder is on an "as is" basis, and the
+ Institute for Systems Biology and the Whitehead Institute
+ have no obligations to provide maintenance, support,
+ updates, enhancements or modifications. In no event shall the
+ Institute for Systems Biology and the Whitehead Institute
+ be liable to any party for direct, indirect, special,
+ incidental or consequential damages, including lost profits, arising
+ out of the use of this software and its documentation, even if the
+ Institute for Systems Biology and the Whitehead Institute
+ have been advised of the possibility of such damage. See
+ the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this library; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+
+package cytoscape.internal;
+
+
+//import org.cytoscape.session.CySessionManager;
+import org.cytoscape.session.CyNetworkManager;
+
+import cytoscape.events.CytoscapeShutdownListener;
+import cytoscape.events.CytoscapeShutdownEvent;
+import cytoscape.view.CySwingApplication;
+
+import javax.swing.JOptionPane;
+
+public class SessionShutdownHandler implements CytoscapeShutdownListener {
+
+// private CySessionManager session;
+ private CySwingApplication desktop;
+ private CyNetworkManager netmgr;
+
+ public SessionShutdownHandler(/*CySessionManager session,*/
CySwingApplication desktop, CyNetworkManager netmgr) {
+ //this.session = session;
+ this.desktop = desktop;
+ this.netmgr = netmgr;
+ }
+
+ public void handleEvent(CytoscapeShutdownEvent e) {
+
+ // If there are no networks, just quit.
+ if (netmgr.getNetworkSet().size() == 0)
+ return;
+
+ // Ask user whether to save current session or not.
+ final String msg = "Do you want to save your session?";
+ final String header = "Save Networks Before Quitting?";
+ final Object[] options = { "Yes, save and quit", "No, just
quit", "Cancel" };
+ final int n = JOptionPane.showOptionDialog(desktop.getJFrame(),
msg, header,
+ JOptionPane.YES_NO_OPTION,
+
JOptionPane.QUESTION_MESSAGE,
+
null, options, options[0]);
+
+ if (n == JOptionPane.NO_OPTION) {
+ return;
+ } else if (n == JOptionPane.YES_OPTION) {
+ // TODO
+ System.out.println("SESSION SAVING NOT IMPLEMENTED
!!!!");
+ return;
+ } else {
+ e.abortShutdown("User canceled the shutdown request.");
+ return;
+ }
+ }
+}
Added:
cytoscape3/trunk/application/src/main/java/cytoscape/internal/ShutdownHandler.java
===================================================================
---
cytoscape3/trunk/application/src/main/java/cytoscape/internal/ShutdownHandler.java
(rev 0)
+++
cytoscape3/trunk/application/src/main/java/cytoscape/internal/ShutdownHandler.java
2009-07-28 00:03:07 UTC (rev 17586)
@@ -0,0 +1,74 @@
+
+/*
+ File: ShutdownHandler.java
+
+ Copyright (c) 2006, The Cytoscape Consortium (www.cytoscape.org)
+
+ The Cytoscape Consortium is:
+ - Institute for Systems Biology
+ - University of California San Diego
+ - Memorial Sloan-Kettering Cancer Center
+ - Institut Pasteur
+ - Agilent Technologies
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation; either version 2.1 of the License, or
+ any later version.
+
+ This library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF
+ MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. The software and
+ documentation provided hereunder is on an "as is" basis, and the
+ Institute for Systems Biology and the Whitehead Institute
+ have no obligations to provide maintenance, support,
+ updates, enhancements or modifications. In no event shall the
+ Institute for Systems Biology and the Whitehead Institute
+ be liable to any party for direct, indirect, special,
+ incidental or consequential damages, including lost profits, arising
+ out of the use of this software and its documentation, even if the
+ Institute for Systems Biology and the Whitehead Institute
+ have been advised of the possibility of such damage. See
+ the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this library; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+
+package cytoscape.internal;
+
+import cytoscape.events.CytoscapeShutdownEvent;
+import cytoscape.events.CytoscapeShutdownListener;
+import cytoscape.CytoscapeShutdown;
+import org.cytoscape.event.CyEventHelper;
+
+/**
+ *
+ */
+public class ShutdownHandler implements CytoscapeShutdown {
+
+ private final CyEventHelper eh;
+ private boolean actuallyShutdown;
+
+ public ShutdownHandler(CyEventHelper eh) {
+ this.eh = eh;
+ }
+
+ public void exit(int retVal) {
+ actuallyShutdown = true;
+ eh.fireSynchronousEvent( new CytoscapeShutdownEvent() {
+ public Object getSource() { return
ShutdownHandler.this; }
+ public void abortShutdown(String why) {
+ System.out.println("SHUTDOWN ABORTED: "
+ why);
+ actuallyShutdown = false;
+ }
+ }, CytoscapeShutdownListener.class );
+
+ // TODO figure out a way to do a clean shutdown of the OSGi
container.
+ if ( actuallyShutdown )
+ System.exit(retVal);
+ else
+ System.out.println("NOT shutting down, per listener
instruction.");
+ }
+}
Modified:
cytoscape3/trunk/application/src/main/java/cytoscape/internal/actions/DeleteAction.java
===================================================================
---
cytoscape3/trunk/application/src/main/java/cytoscape/internal/actions/DeleteAction.java
2009-07-27 22:09:00 UTC (rev 17585)
+++
cytoscape3/trunk/application/src/main/java/cytoscape/internal/actions/DeleteAction.java
2009-07-28 00:03:07 UTC (rev 17586)
@@ -149,7 +149,7 @@
for ( CyEdge ed : edges )
cyNet.removeEdge(ed);
- Cytoscape.firePropertyChange(Cytoscape.NETWORK_MODIFIED, null,
cyNet);
+ //Cytoscape.firePropertyChange(Cytoscape.NETWORK_MODIFIED,
null, cyNet);
}
public void menuSelected(MenuEvent me) {
Modified:
cytoscape3/trunk/application/src/main/java/cytoscape/internal/actions/ExitAction.java
===================================================================
---
cytoscape3/trunk/application/src/main/java/cytoscape/internal/actions/ExitAction.java
2009-07-27 22:09:00 UTC (rev 17585)
+++
cytoscape3/trunk/application/src/main/java/cytoscape/internal/actions/ExitAction.java
2009-07-28 00:03:07 UTC (rev 17586)
@@ -41,7 +41,7 @@
package cytoscape.internal.actions;
import org.cytoscape.session.CyNetworkManager;
-import cytoscape.Cytoscape;
+import cytoscape.CytoscapeShutdown;
import cytoscape.util.CytoscapeAction;
import java.awt.event.ActionEvent;
@@ -53,12 +53,14 @@
public class ExitAction extends CytoscapeAction {
private final static long serialVersionUID = 1202339869460858L;
protected int returnVal;
+ private final CytoscapeShutdown shutdown;
/**
* Creates a new ExitAction object.
*/
- public ExitAction(CyNetworkManager netmgr) {
+ public ExitAction(CyNetworkManager netmgr, CytoscapeShutdown shutdown) {
super("Quit",netmgr);
+ this.shutdown = shutdown;
setPreferredMenu("File");
setAcceleratorCombo(java.awt.event.KeyEvent.VK_Q,
ActionEvent.CTRL_MASK);
}
@@ -69,6 +71,6 @@
* @param e DOCUMENT ME!
*/
public void actionPerformed(ActionEvent e) {
- Cytoscape.exit(returnVal);
+ shutdown.exit(returnVal);
}
}
Modified:
cytoscape3/trunk/application/src/main/java/cytoscape/internal/view/CytoPanelImp.java
===================================================================
---
cytoscape3/trunk/application/src/main/java/cytoscape/internal/view/CytoPanelImp.java
2009-07-27 22:09:00 UTC (rev 17585)
+++
cytoscape3/trunk/application/src/main/java/cytoscape/internal/view/CytoPanelImp.java
2009-07-28 00:03:07 UTC (rev 17586)
@@ -742,7 +742,8 @@
if (cytoPanelContainer == null) {
System.out.println("CytoPanel::DockCytoPanel()
-"
+ "cytoPanelContainer
reference has not been set!");
- Cytoscape.exit(1);
+ // TODO Is this possibly right?
+ //Cytoscape.exit(1);
}
cytoPanelContainer.insertCytoPanel(this,
compassDirection);
Modified:
cytoscape3/trunk/application/src/main/java/cytoscape/internal/view/CytoscapeDesktop.java
===================================================================
---
cytoscape3/trunk/application/src/main/java/cytoscape/internal/view/CytoscapeDesktop.java
2009-07-27 22:09:00 UTC (rev 17585)
+++
cytoscape3/trunk/application/src/main/java/cytoscape/internal/view/CytoscapeDesktop.java
2009-07-28 00:03:07 UTC (rev 17586)
@@ -55,8 +55,7 @@
import javax.swing.WindowConstants;
import javax.swing.border.EmptyBorder;
-import cytoscape.Cytoscape;
-import cytoscape.CytoscapeVersion;
+import cytoscape.CytoscapeShutdown;
import org.cytoscape.session.CyNetworkManager;
import cytoscape.view.CytoPanel;
@@ -111,20 +110,19 @@
// Status Bar
protected CytoStatusBarImpl statusBar;
protected JPanel main_panel;
+ private final CytoscapeShutdown shutdown;
- private CytoscapeVersion version;
-
/**
* Creates a new CytoscapeDesktop object.
*/
- public CytoscapeDesktop(CyMenus cyMenus, NetworkViewManager
networkViewManager, NetworkPanel networkPanel , CytoscapeVersion version,
CytoStatusBarImpl statusBar) {
+ public CytoscapeDesktop(CyMenus cyMenus, NetworkViewManager
networkViewManager, NetworkPanel networkPanel , CytoStatusBarImpl statusBar,
CytoscapeShutdown shut) {
super("Cytoscape Desktop (New Session)");
this.cyMenus = cyMenus;
this.networkViewManager = networkViewManager;
this.networkPanel = networkPanel;
- this.version = version;
this.statusBar = statusBar;
+ this.shutdown = shut;
setIconImage(Toolkit.getDefaultToolkit().getImage(getClass().getResource(SMALL_ICON)));
@@ -144,13 +142,13 @@
initStatusBar(main_panel);
setJMenuBar(cyMenus.getMenuBar().getJMenuBar());
- //don't automatically close window. Let
Cytoscape.exit(returnVal)
- //handle this, based upon user confirmation.
+ //don't automatically close window. Let shutdown.exit(returnVal)
+ //handle this
setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent we) {
- Cytoscape.exit(0);
+ shutdown.exit(0);
}
});
Modified:
cytoscape3/trunk/application/src/main/resources/META-INF/spring/bundle-context-osgi.xml
===================================================================
---
cytoscape3/trunk/application/src/main/resources/META-INF/spring/bundle-context-osgi.xml
2009-07-27 22:09:00 UTC (rev 17585)
+++
cytoscape3/trunk/application/src/main/resources/META-INF/spring/bundle-context-osgi.xml
2009-07-28 00:03:07 UTC (rev 17586)
@@ -9,7 +9,6 @@
<osgi:reference id="cyNetworkManagerServiceRef"
interface="org.cytoscape.session.CyNetworkManager" />
<osgi:reference id="cyNetworkNamingServiceRef"
interface="org.cytoscape.session.CyNetworkNaming" />
-
<osgi:reference id="streamUtilServiceRef"
interface="org.cytoscape.io.util.StreamUtil" />
<osgi:reference id="taskManagerServiceRef"
interface="org.cytoscape.work.TaskManager" />
@@ -337,4 +336,13 @@
<osgi:service id="selectRegisterListenerService"
ref="selectRegisterListener"
interface="org.cytoscape.session.events.NetworkViewAddedListener" />
+
+ <osgi:service id="sessionShutdownHandlerService"
ref="sessionShutdownHandler"
+ interface="cytoscape.events.CytoscapeShutdownListener" />
+
+ <osgi:service id="cytoscapeShutdownService" ref="cytoscapeShutdown"
+ interface="cytoscape.CytoscapeShutdown" />
+
+ <osgi:service id="cytoscapeVersionService" ref="cytoscapeVersion"
+ interface="cytoscape.CytoscapeVersion" />
</beans>
Modified:
cytoscape3/trunk/application/src/main/resources/META-INF/spring/bundle-context.xml
===================================================================
---
cytoscape3/trunk/application/src/main/resources/META-INF/spring/bundle-context.xml
2009-07-27 22:09:00 UTC (rev 17585)
+++
cytoscape3/trunk/application/src/main/resources/META-INF/spring/bundle-context.xml
2009-07-28 00:03:07 UTC (rev 17586)
@@ -29,10 +29,16 @@
</bean>
<!-- Cytoscape Version -->
- <bean name="cytoscapeVersion" class="cytoscape.CytoscapeVersion">
+ <bean name="cytoscapeVersion" class="cytoscape.internal.CyVersion">
<constructor-arg ref="cytoscapeProperties" />
</bean>
+ <!-- shutdown support -->
+ <bean name="cytoscapeShutdown"
class="cytoscape.internal.ShutdownHandler">
+ <constructor-arg ref="cyEventHelperServiceRef" />
+ </bean>
+
+
<!-- Various Utilities -->
<bean name="proxyHandler"
class="cytoscape.internal.util.ProxyHandlerImpl">
<constructor-arg ref="cytoscapeProperties" />
@@ -61,7 +67,6 @@
<constructor-arg ref="cyOperatingContext" />
<constructor-arg ref="cyEventHelperServiceRef" />
</bean>
-
<bean name="bookmarkDialogFactory"
class="cytoscape.internal.dialogs.BookmarkDialogFactoryImpl">
<constructor-arg ref="bookmarkServiceRef" />
<constructor-arg ref="bookmarksUtilServiceRef" />
@@ -103,17 +108,24 @@
<constructor-arg ref="cytoscapeMenus" />
<constructor-arg ref="networkViewManager" />
<constructor-arg ref="networkPanel" />
- <constructor-arg ref="cytoscapeVersion" />
<constructor-arg ref="cytoStatusBarImpl" />
+ <constructor-arg ref="cytoscapeShutdown" />
</bean>
- <!-- cyMain. Currently working as a builder for application. -->
+ <!-- cyMain. Currently working as a builder for application.
<bean name="cyMain" class="cytoscape.CyMain">
<constructor-arg ref="cytoscapeDesktop" />
<constructor-arg ref="cyNetworkManagerServiceRef" />
<constructor-arg ref="cytoscapeVersion" />
<constructor-arg ref="fileUtil" />
</bean>
+ -->
+
+ <!-- session support -->
+ <bean id="sessionShutdownHandler"
class="cytoscape.internal.SessionShutdownHandler">
+ <constructor-arg ref="cytoscapeDesktop" />
+ <constructor-arg ref="cyNetworkManagerServiceRef" />
+ </bean>
<!--
<bean id="printAction" class="cytoscape.internal.actions.PrintAction">
@@ -124,6 +136,7 @@
-->
<bean id="exitAction" class="cytoscape.internal.actions.ExitAction">
<constructor-arg ref="cyNetworkManagerServiceRef" />
+ <constructor-arg ref="cytoscapeShutdown" />
</bean>
<bean id="undoAction" class="cytoscape.internal.actions.UndoAction">
<constructor-arg ref="undoSupportServiceRef" />
Modified: cytoscape3/trunk/application/src/main/resources/cytoscape.props
===================================================================
--- cytoscape3/trunk/application/src/main/resources/cytoscape.props
2009-07-27 22:09:00 UTC (rev 17585)
+++ cytoscape3/trunk/application/src/main/resources/cytoscape.props
2009-07-28 00:03:07 UTC (rev 17586)
@@ -15,7 +15,7 @@
proxy.server=
proxy.server.port=
proxy.server.type=
-cytoscape.version.number=2.7
+cytoscape.version.number=3.0.0
exportTextAsShape=true
vizmapper.cntMapperUpperLimit=2000
undo.limit=10
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"cytoscape-cvs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/cytoscape-cvs?hl=en
-~----------~----~----~----~------~----~------~--~---