Author: kono
Date: 2011-08-18 13:14:15 -0700 (Thu, 18 Aug 2011)
New Revision: 26603

Added:
   
core3/impl/trunk/application-impl/src/main/java/org/cytoscape/application/internal/CyApplicationCoreProperty.java
Modified:
   
core3/api/trunk/property-api/src/main/java/org/cytoscape/property/BasicCyProperty.java
   core3/impl/trunk/application-impl/pom.xml
   
core3/impl/trunk/application-impl/src/main/resources/META-INF/spring/bundle-context-osgi.xml
   
core3/impl/trunk/application-impl/src/main/resources/META-INF/spring/bundle-context.xml
   
core3/impl/trunk/core-task-impl/src/main/resources/META-INF/spring/bundle-context-osgi.xml
   
core3/impl/trunk/ding-impl/ding-customgraphics-manager-impl/src/main/resources/META-INF/spring/bundle-context-osgi.xml
   
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/resources/META-INF/spring/bundle-context-osgi.xml
   
core3/impl/trunk/io-impl/src/main/java/org/cytoscape/io/internal/write/CyNetworkViewWriterManagerImpl.java
   
core3/impl/trunk/io-impl/src/main/java/org/cytoscape/io/internal/write/PropertyWriterManagerImpl.java
   
core3/impl/trunk/io-impl/src/main/java/org/cytoscape/io/internal/write/properties/PropertiesWriterFactoryImpl.java
   
core3/impl/trunk/io-impl/src/main/java/org/cytoscape/io/internal/write/properties/PropertiesWriterImpl.java
   
core3/impl/trunk/io-impl/src/main/resources/META-INF/spring/bundle-context-osgi.xml
   
core3/impl/trunk/io-impl/src/main/resources/META-INF/spring/bundle-context.xml
   
core3/impl/trunk/layout-impl/src/main/resources/META-INF/spring/bundle-context-osgi.xml
   
core3/impl/trunk/plugin-impl/src/main/resources/META-INF/spring/bundle-context-osgi.xml
   
core3/impl/trunk/swing-application-impl/src/main/java/org/cytoscape/internal/dialogs/PreferencesDialogImpl.java
   
core3/impl/trunk/swing-application-impl/src/main/java/org/cytoscape/internal/shutdown/ConfigDirPropertyWriter.java
   
core3/impl/trunk/swing-application-impl/src/main/java/org/cytoscape/internal/shutdown/PropertyWriter.java
   
core3/impl/trunk/swing-application-impl/src/main/resources/META-INF/spring/bundle-context-osgi.xml
   
core3/impl/trunk/table-import-impl/src/main/resources/META-INF/spring/bundle-context-osgi.xml
   
core3/impl/trunk/work-swing-impl/it/src/test/java/org/cytoscape/work/ServiceConfigurationTest.java
Log:
refs #357 Old "coreSettings" property had been replaced by cytoscape.props 
application-wide CyProperty.  However, one of them cannot be removed.  We need 
to figure out why.

Modified: 
core3/api/trunk/property-api/src/main/java/org/cytoscape/property/BasicCyProperty.java
===================================================================
--- 
core3/api/trunk/property-api/src/main/java/org/cytoscape/property/BasicCyProperty.java
      2011-08-18 18:29:03 UTC (rev 26602)
+++ 
core3/api/trunk/property-api/src/main/java/org/cytoscape/property/BasicCyProperty.java
      2011-08-18 20:14:15 UTC (rev 26603)
@@ -9,6 +9,12 @@
  * general purpose use. 
  */
 public final class BasicCyProperty implements CyProperty<Properties> {
+       
+       /**
+        * Core Cytoscape Property (Cytoscpae System Property)
+        */
+       public static final String CORE_PROPRERTY_NAME = "cytoscape.props";
+       
        private final Properties properties;
        private final CyProperty.SavePolicy savePolicy;
 

Modified: core3/impl/trunk/application-impl/pom.xml
===================================================================
--- core3/impl/trunk/application-impl/pom.xml   2011-08-18 18:29:03 UTC (rev 
26602)
+++ core3/impl/trunk/application-impl/pom.xml   2011-08-18 20:14:15 UTC (rev 
26603)
@@ -82,5 +82,9 @@
                        <groupId>org.cytoscape</groupId>
                        <artifactId>property-api</artifactId>
                </dependency>
+               <dependency>
+                       <groupId>org.cytoscape</groupId>
+                       <artifactId>session-api</artifactId>
+               </dependency>
        </dependencies>
 </project>

Added: 
core3/impl/trunk/application-impl/src/main/java/org/cytoscape/application/internal/CyApplicationCoreProperty.java
===================================================================
--- 
core3/impl/trunk/application-impl/src/main/java/org/cytoscape/application/internal/CyApplicationCoreProperty.java
                           (rev 0)
+++ 
core3/impl/trunk/application-impl/src/main/java/org/cytoscape/application/internal/CyApplicationCoreProperty.java
   2011-08-18 20:14:15 UTC (rev 26603)
@@ -0,0 +1,100 @@
+package org.cytoscape.application.internal;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+
+import org.cytoscape.application.CyApplicationConfiguration;
+import org.cytoscape.property.CyProperty;
+import org.cytoscape.session.CySession;
+import org.cytoscape.session.events.SessionLoadedEvent;
+import org.cytoscape.session.events.SessionLoadedListener;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class CyApplicationCoreProperty implements CyProperty<Properties>, 
SessionLoadedListener {
+       private static final Logger logger = 
LoggerFactory.getLogger(CyApplicationCoreProperty.class);
+
+       // This is in the resource file (jar)
+       private static final String DEF_PROP_FILE_NAME = "cytoscape.props";
+
+       private Properties props;
+
+       /**
+        * Creates a new PropsReader object.
+        * 
+        */
+       public CyApplicationCoreProperty(final CyApplicationConfiguration 
config) {
+               InputStream is = null;
+
+               final File propFile = new File(config.getSettingLocation(), 
"cytoscape.props");
+
+               try {
+                       
+                       if (propFile.exists()) {
+                               is = new FileInputStream(propFile);
+                               props = new Properties();
+                               props.load(is);
+                               logger.info("PropFile is: " + 
propFile.getAbsolutePath());
+                       } else {
+                               logger.warn("Could not read properties from 
config directry - trying to load default properties.");
+                               is = 
this.getClass().getClassLoader().getResourceAsStream(DEF_PROP_FILE_NAME);
+                               props = new Properties();
+                               try {
+                                       props.load(is);
+                               } catch (IOException e1) {
+                                       logger.warn("Could not read core 
property.  Use empty one.", e1);
+                               }
+                       }
+               } catch (Exception e) {
+                       logger.warn("Could not read properties from config 
directry - trying to load default properties.", e);
+                       is = 
this.getClass().getClassLoader().getResourceAsStream(DEF_PROP_FILE_NAME);
+                       props = new Properties();
+                       try {
+                               props.load(is);
+                       } catch (IOException e1) {
+                               logger.warn("Could not read core property.  Use 
empty one.", e1);
+                       }
+               } finally {
+                       if (is != null) {
+                               try {
+                                       is.close();
+                               } catch (IOException ioe) {
+                               }
+                               is = null;
+                       }
+               }
+       }
+
+       @Override
+       public CyProperty.SavePolicy getSavePolicy() {
+               return CyProperty.SavePolicy.SESSION_FILE_AND_CONFIG_DIR;
+       }
+
+       @Override
+       public Properties getProperties() {
+               return props;
+       }
+
+       @Override
+       public void handleEvent(SessionLoadedEvent e) {
+               logger.debug("Updating Properties from loaded session...");
+
+               Properties newProps = null;
+               CySession sess = e.getLoadedSession();
+
+               if (sess != null)
+                       newProps = sess.getCytoscapeProperties();
+               else
+                       logger.warn("Loaded session is null.");
+
+               if (newProps == null) {
+                       logger.warn("Could not get new properties from loaded 
session - using empty properties.");
+                       newProps = new Properties();
+               }
+
+               this.props = newProps;
+       }
+}

Modified: 
core3/impl/trunk/application-impl/src/main/resources/META-INF/spring/bundle-context-osgi.xml
===================================================================
--- 
core3/impl/trunk/application-impl/src/main/resources/META-INF/spring/bundle-context-osgi.xml
        2011-08-18 18:29:03 UTC (rev 26602)
+++ 
core3/impl/trunk/application-impl/src/main/resources/META-INF/spring/bundle-context-osgi.xml
        2011-08-18 20:14:15 UTC (rev 26603)
@@ -13,19 +13,23 @@
                        
<value>org.cytoscape.model.events.NetworkAboutToBeDestroyedListener</value>
                        
<value>org.cytoscape.view.model.events.NetworkViewAboutToBeDestroyedListener</value>
                </osgi:interfaces>
-       </osgi:service>
+       </osgi:service> 
 
-       <osgi:service id="cytoscapeShutdownService" ref="cytoscapeShutdown" 
auto-export="interfaces" />
-       <osgi:service id="cytoscapeVersionService" ref="cytoscapeVersion" 
auto-export="interfaces" />
-       <osgi:service id="cyApplicationConfigurationService" 
ref="cyApplicationConfiguration" auto-export="interfaces" />
-
        <osgi:reference id="cyEventHelperServiceRef" 
interface="org.cytoscape.event.CyEventHelper" />
        <osgi:reference id="cyNetworkManagerServiceRef"
                interface="org.cytoscape.model.CyNetworkManager" />
        <osgi:reference id="cyNetworkViewManagerServiceRef"
                interface="org.cytoscape.view.model.CyNetworkViewManager" />
 
-       <osgi:reference id="cytoscapePropertiesServiceRef"
-               interface="org.cytoscape.property.CyProperty" 
filter="(cyPropertyName=coreSettings)" />
+       <osgi:service id="cytoscapeShutdownService" ref="cytoscapeShutdown" 
auto-export="interfaces" />
+       <osgi:service id="cytoscapeVersionService" ref="cytoscapeVersion" 
auto-export="interfaces" />
+       <osgi:service id="cyApplicationConfigurationService" 
ref="cyApplicationConfiguration" auto-export="interfaces" />
+       
+       <osgi:service id="cyApplicationCorePropertyService" 
ref="cyApplicationCoreProperty" auto-export="interfaces" >
+               <osgi:service-properties>
+                       <entry key="serviceType" value="property" />
+                       <entry key="cyPropertyName" value="cytoscape.props" />
+               </osgi:service-properties>
+       </osgi:service>
 
 </beans>

Modified: 
core3/impl/trunk/application-impl/src/main/resources/META-INF/spring/bundle-context.xml
===================================================================
--- 
core3/impl/trunk/application-impl/src/main/resources/META-INF/spring/bundle-context.xml
     2011-08-18 18:29:03 UTC (rev 26602)
+++ 
core3/impl/trunk/application-impl/src/main/resources/META-INF/spring/bundle-context.xml
     2011-08-18 20:14:15 UTC (rev 26603)
@@ -31,8 +31,8 @@
        </bean>
 
        <!-- Cytoscape Version -->
-       <bean name="cytoscapeVersion" 
class="org.cytoscape.application.internal.CyVersion">
-               <constructor-arg ref="cytoscapePropertiesServiceRef" />
+       <bean name="cytoscapeVersion" 
class="org.cytoscape.application.internal.CyVersion" 
depends-on="cyApplicationCoreProperty">
+               <constructor-arg ref="cyApplicationCoreProperty" />
        </bean>
        
        <!-- shutdown support -->
@@ -42,4 +42,7 @@
        
        <bean id="cyApplicationConfiguration" 
class="org.cytoscape.application.internal.CyApplicationConfigurationImpl" />
 
+       <bean id="cyApplicationCoreProperty" 
class="org.cytoscape.application.internal.CyApplicationCoreProperty">
+               <constructor-arg ref="cyApplicationConfiguration" />
+       </bean>
 </beans>

Modified: 
core3/impl/trunk/core-task-impl/src/main/resources/META-INF/spring/bundle-context-osgi.xml
===================================================================
--- 
core3/impl/trunk/core-task-impl/src/main/resources/META-INF/spring/bundle-context-osgi.xml
  2011-08-18 18:29:03 UTC (rev 26602)
+++ 
core3/impl/trunk/core-task-impl/src/main/resources/META-INF/spring/bundle-context-osgi.xml
  2011-08-18 20:14:15 UTC (rev 26603)
@@ -72,7 +72,7 @@
                interface="org.cytoscape.session.CySessionManager" />
 
        <osgi:reference id="cyPropertyServiceRef" 
interface="org.cytoscape.property.CyProperty"
-               filter="(cyPropertyName=coreSettings)" />
+               filter="(cyPropertyName=cytoscape.props)" />
 
        <osgi:reference id="cyTableManagerServiceRef" 
interface="org.cytoscape.model.CyTableManager" />
 

Modified: 
core3/impl/trunk/ding-impl/ding-customgraphics-manager-impl/src/main/resources/META-INF/spring/bundle-context-osgi.xml
===================================================================
--- 
core3/impl/trunk/ding-impl/ding-customgraphics-manager-impl/src/main/resources/META-INF/spring/bundle-context-osgi.xml
      2011-08-18 18:29:03 UTC (rev 26602)
+++ 
core3/impl/trunk/ding-impl/ding-customgraphics-manager-impl/src/main/resources/META-INF/spring/bundle-context-osgi.xml
      2011-08-18 20:14:15 UTC (rev 26603)
@@ -8,7 +8,7 @@
        <osgi:reference id="guiTaskManagerServiceRef" 
interface="org.cytoscape.work.swing.GUITaskManager" />
                
        <osgi:reference id="coreCyPropertyServiceRef"
-               interface="org.cytoscape.property.CyProperty"  
filter="(cyPropertyName=coreSettings)"/>
+               interface="org.cytoscape.property.CyProperty"  
filter="(cyPropertyName=cytoscape.props)"/>
                
        <osgi:reference id="cyApplicationManagerServiceRef" 
interface="org.cytoscape.application.CyApplicationManager" />
        

Modified: 
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/resources/META-INF/spring/bundle-context-osgi.xml
===================================================================
--- 
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/resources/META-INF/spring/bundle-context-osgi.xml
        2011-08-18 18:29:03 UTC (rev 26602)
+++ 
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/resources/META-INF/spring/bundle-context-osgi.xml
        2011-08-18 20:14:15 UTC (rev 26603)
@@ -134,7 +134,7 @@
 
 
        <osgi:reference id="cyPropertyServiceRef" 
interface="org.cytoscape.property.CyProperty"
-               filter="(cyPropertyName=coreSettings)" />
+               filter="(cyPropertyName=cytoscape.props)" />
                
        <osgi:service id="showGraphicsDetailTaskFactoryService" 
ref="showGraphicsDetailTaskFactory" auto-export="interfaces">
                <osgi:service-properties>

Modified: 
core3/impl/trunk/io-impl/src/main/java/org/cytoscape/io/internal/write/CyNetworkViewWriterManagerImpl.java
===================================================================
--- 
core3/impl/trunk/io-impl/src/main/java/org/cytoscape/io/internal/write/CyNetworkViewWriterManagerImpl.java
  2011-08-18 18:29:03 UTC (rev 26602)
+++ 
core3/impl/trunk/io-impl/src/main/java/org/cytoscape/io/internal/write/CyNetworkViewWriterManagerImpl.java
  2011-08-18 20:14:15 UTC (rev 26603)
@@ -13,7 +13,7 @@
 
 public class CyNetworkViewWriterManagerImpl extends 
AbstractWriterManager<CyNetworkViewWriterFactory> implements 
CyNetworkViewWriterManager {
        public CyNetworkViewWriterManagerImpl() {
-               super(DataCategory.NETWORK);
+               super(DataCategory.NETWORK);            
        }
 
        @Override

Modified: 
core3/impl/trunk/io-impl/src/main/java/org/cytoscape/io/internal/write/PropertyWriterManagerImpl.java
===================================================================
--- 
core3/impl/trunk/io-impl/src/main/java/org/cytoscape/io/internal/write/PropertyWriterManagerImpl.java
       2011-08-18 18:29:03 UTC (rev 26602)
+++ 
core3/impl/trunk/io-impl/src/main/java/org/cytoscape/io/internal/write/PropertyWriterManagerImpl.java
       2011-08-18 20:14:15 UTC (rev 26603)
@@ -16,7 +16,7 @@
        implements CyPropertyWriterManager
 {
        public PropertyWriterManagerImpl() {
-               super(DataCategory.PROPERTIES);
+               super(DataCategory.PROPERTIES);         
        }
 
        public CyWriter getWriter(Object property, CyFileFilter filter, File 
outFile) throws Exception {

Modified: 
core3/impl/trunk/io-impl/src/main/java/org/cytoscape/io/internal/write/properties/PropertiesWriterFactoryImpl.java
===================================================================
--- 
core3/impl/trunk/io-impl/src/main/java/org/cytoscape/io/internal/write/properties/PropertiesWriterFactoryImpl.java
  2011-08-18 18:29:03 UTC (rev 26602)
+++ 
core3/impl/trunk/io-impl/src/main/java/org/cytoscape/io/internal/write/properties/PropertiesWriterFactoryImpl.java
  2011-08-18 20:14:15 UTC (rev 26603)
@@ -1,9 +1,8 @@
 package org.cytoscape.io.internal.write.properties;
 
-import java.io.OutputStream;
 import org.cytoscape.io.CyFileFilter;
-import org.cytoscape.io.write.CyWriter;
 import org.cytoscape.io.internal.write.AbstractPropertyWriterFactory;
+import org.cytoscape.io.write.CyWriter;
 
 public class PropertiesWriterFactoryImpl extends AbstractPropertyWriterFactory 
{
        

Modified: 
core3/impl/trunk/io-impl/src/main/java/org/cytoscape/io/internal/write/properties/PropertiesWriterImpl.java
===================================================================
--- 
core3/impl/trunk/io-impl/src/main/java/org/cytoscape/io/internal/write/properties/PropertiesWriterImpl.java
 2011-08-18 18:29:03 UTC (rev 26602)
+++ 
core3/impl/trunk/io-impl/src/main/java/org/cytoscape/io/internal/write/properties/PropertiesWriterImpl.java
 2011-08-18 20:14:15 UTC (rev 26603)
@@ -28,23 +28,19 @@
 package org.cytoscape.io.internal.write.properties;
 
 
-import java.util.Properties;
 import java.io.OutputStream;
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.Marshaller;
+import java.util.Properties;
 
 import org.cytoscape.io.write.CyWriter;
-import org.cytoscape.property.CyProperty;
-import org.cytoscape.work.TaskMonitor;
 import org.cytoscape.work.AbstractTask;
+import org.cytoscape.work.TaskMonitor;
 
 
 public class PropertiesWriterImpl extends AbstractTask implements CyWriter {
        private final OutputStream outputStream;
        private final Properties properties;
 
-       public PropertiesWriterImpl(final OutputStream outputStream, Object 
props) {
+       public PropertiesWriterImpl(final OutputStream outputStream, final 
Object props) {
                this.outputStream = outputStream;
                if (props instanceof Properties)
                        properties = (Properties)props;
@@ -54,6 +50,7 @@
 
        @Override
        public void run(TaskMonitor taskMonitor) throws Exception {
-               properties.store(outputStream,"Written by: Cytoscape's 
PropertiesWriterImpl");
+               properties.store(outputStream, "Written by: Cytoscape's 
PropertiesWriterImpl");
+               this.outputStream.close();              
        }
 }

Modified: 
core3/impl/trunk/io-impl/src/main/resources/META-INF/spring/bundle-context-osgi.xml
===================================================================
--- 
core3/impl/trunk/io-impl/src/main/resources/META-INF/spring/bundle-context-osgi.xml
 2011-08-18 18:29:03 UTC (rev 26602)
+++ 
core3/impl/trunk/io-impl/src/main/resources/META-INF/spring/bundle-context-osgi.xml
 2011-08-18 20:14:15 UTC (rev 26603)
@@ -24,7 +24,7 @@
                interface="org.cytoscape.model.CyTableFactory" />
 
        <osgi:reference id="cyPropertyServiceRef" 
interface="org.cytoscape.property.CyProperty"
-               filter="(cyPropertyName=coreSettings)" />
+               filter="(cyPropertyName=cytoscape.props)" />
 
        <osgi:reference id="cyApplicationManagerServiceRef"
                interface="org.cytoscape.application.CyApplicationManager" />

Modified: 
core3/impl/trunk/io-impl/src/main/resources/META-INF/spring/bundle-context.xml
===================================================================
--- 
core3/impl/trunk/io-impl/src/main/resources/META-INF/spring/bundle-context.xml  
    2011-08-18 18:29:03 UTC (rev 26602)
+++ 
core3/impl/trunk/io-impl/src/main/resources/META-INF/spring/bundle-context.xml  
    2011-08-18 20:14:15 UTC (rev 26603)
@@ -12,7 +12,7 @@
            http://www.springframework.org/schema/context/spring-context-2.5.xsd
            http://www.springframework.org/schema/lang 
http://www.springframework.org/schema/lang/spring-lang-2.5.xsd
             http://www.springframework.org/schema/osgi 
http://www.springframework.org/schema/osgi/spring-osgi-1.0.xsd";
-       default-lazy-init="true">
+       default-lazy-init="false">
 
        <context:annotation-config />
 

Modified: 
core3/impl/trunk/layout-impl/src/main/resources/META-INF/spring/bundle-context-osgi.xml
===================================================================
--- 
core3/impl/trunk/layout-impl/src/main/resources/META-INF/spring/bundle-context-osgi.xml
     2011-08-18 18:29:03 UTC (rev 26602)
+++ 
core3/impl/trunk/layout-impl/src/main/resources/META-INF/spring/bundle-context-osgi.xml
     2011-08-18 20:14:15 UTC (rev 26603)
@@ -26,7 +26,7 @@
        </osgi:reference>
 
        <osgi:reference id="cyPropertyServiceRef" 
interface="org.cytoscape.property.CyProperty"
-               filter="(cyPropertyName=coreSettings)" />
+               filter="(cyPropertyName=cytoscape.props)" />
 
 
 </beans>

Modified: 
core3/impl/trunk/plugin-impl/src/main/resources/META-INF/spring/bundle-context-osgi.xml
===================================================================
--- 
core3/impl/trunk/plugin-impl/src/main/resources/META-INF/spring/bundle-context-osgi.xml
     2011-08-18 18:29:03 UTC (rev 26602)
+++ 
core3/impl/trunk/plugin-impl/src/main/resources/META-INF/spring/bundle-context-osgi.xml
     2011-08-18 20:14:15 UTC (rev 26603)
@@ -49,7 +49,7 @@
 
        <osgi:reference id="cyPropertyRef"
                interface="org.cytoscape.property.CyProperty"
-               filter="(cyPropertyName=coreSettings)">
+               filter="(cyPropertyName=cytoscape.props)">
        </osgi:reference>
 
        <osgi:reference id="cyPropertyReaderManagerRef"

Modified: 
core3/impl/trunk/swing-application-impl/src/main/java/org/cytoscape/internal/dialogs/PreferencesDialogImpl.java
===================================================================
--- 
core3/impl/trunk/swing-application-impl/src/main/java/org/cytoscape/internal/dialogs/PreferencesDialogImpl.java
     2011-08-18 18:29:03 UTC (rev 26602)
+++ 
core3/impl/trunk/swing-application-impl/src/main/java/org/cytoscape/internal/dialogs/PreferencesDialogImpl.java
     2011-08-18 20:14:15 UTC (rev 26603)
@@ -72,6 +72,7 @@
 import org.cytoscape.event.CyEventHelper;
 
 import org.cytoscape.internal.CyOperatingContextImpl;
+import org.cytoscape.property.BasicCyProperty;
 import org.cytoscape.property.CyProperty;
 import org.cytoscape.property.bookmark.Bookmarks;
 import org.cytoscape.property.bookmark.BookmarksUtil;
@@ -148,7 +149,7 @@
 
                this.cmbPropCategories.setModel(cmbModel);
                
-               String key = "coreSettings";
+               String key = BasicCyProperty.CORE_PROPRERTY_NAME;
                
                int index =0;
                for (int i=0; i<keys.length; i++){

Modified: 
core3/impl/trunk/swing-application-impl/src/main/java/org/cytoscape/internal/shutdown/ConfigDirPropertyWriter.java
===================================================================
--- 
core3/impl/trunk/swing-application-impl/src/main/java/org/cytoscape/internal/shutdown/ConfigDirPropertyWriter.java
  2011-08-18 18:29:03 UTC (rev 26602)
+++ 
core3/impl/trunk/swing-application-impl/src/main/java/org/cytoscape/internal/shutdown/ConfigDirPropertyWriter.java
  2011-08-18 20:14:15 UTC (rev 26603)
@@ -3,17 +3,14 @@
 
 import java.io.File;
 import java.util.HashMap;
-import java.util.HashSet;
 import java.util.Map;
-import java.util.Set;
 
 import org.cytoscape.application.CyApplicationConfiguration;
 import org.cytoscape.application.events.CytoscapeShutdownEvent;
 import org.cytoscape.application.events.CytoscapeShutdownListener;
-import org.cytoscape.property.CyProperty;
 import org.cytoscape.io.CyFileFilter;
 import org.cytoscape.io.write.CyPropertyWriterManager;
-import org.cytoscape.io.write.CyWriter;
+import org.cytoscape.property.CyProperty;
 import org.cytoscape.work.TaskManager;
 
 
@@ -33,6 +30,7 @@
        }
 
        public void handleEvent(final CytoscapeShutdownEvent event) {
+               
                CyFileFilter matchingFileFilter = null;
                for (final CyFileFilter fileFilter : 
propertyWriterManager.getAvailableWriterFilters()) {
                        if (fileFilter.getExtensions().contains("props")) {
@@ -42,20 +40,29 @@
                }
                if (matchingFileFilter == null)
                        throw new IllegalStateException("could not find a 
properties CyFileFilter!");
-
+               
                for (final Map.Entry<CyProperty, Map> keyAndValue : 
configDirProperties.entrySet()) {
-                       final String propertyName = 
(String)keyAndValue.getValue().get("cyPropertyName");                           
    
-                       final File outputFile = new 
File(config.getSettingLocation(), propertyName + ".props");
+                       final String propertyName = 
(String)keyAndValue.getValue().get("cyPropertyName");
+                       final String propertyFileName;
+                       if(propertyName.endsWith(".props"))
+                               propertyFileName = propertyName;
+                       else
+                               propertyFileName = propertyName + ".props";
+                       
+                       
+                       final File outputFile = new 
File(config.getSettingLocation(), propertyFileName);
+                       
                        final PropertyWriterFactory taskFactory =
                                new 
PropertyWriterFactory(propertyWriterManager, keyAndValue.getKey(),
                                                          matchingFileFilter, 
outputFile);
                        taskManager.execute(taskFactory);
                }
+               
        }
 
        public void addCyProperty(final CyProperty newCyProperty, final Map 
properties) {
                if (newCyProperty.getSavePolicy() == 
CyProperty.SavePolicy.CONFIG_DIR
-                   || newCyProperty.getSavePolicy() == 
CyProperty.SavePolicy.SESSION_FILE_AND_CONFIG_DIR)
+                               || newCyProperty.getSavePolicy() == 
CyProperty.SavePolicy.SESSION_FILE_AND_CONFIG_DIR)
                        configDirProperties.put(newCyProperty, properties);
        }
 

Modified: 
core3/impl/trunk/swing-application-impl/src/main/java/org/cytoscape/internal/shutdown/PropertyWriter.java
===================================================================
--- 
core3/impl/trunk/swing-application-impl/src/main/java/org/cytoscape/internal/shutdown/PropertyWriter.java
   2011-08-18 18:29:03 UTC (rev 26602)
+++ 
core3/impl/trunk/swing-application-impl/src/main/java/org/cytoscape/internal/shutdown/PropertyWriter.java
   2011-08-18 20:14:15 UTC (rev 26603)
@@ -15,7 +15,8 @@
  * the specified image file using the specified RenderingEngine.
  */
 public final class PropertyWriter extends 
AbstractCyWriter<CyPropertyWriterManager> {
-       private final CyProperty property;
+       
+       private final CyProperty<?> property;
        private final String fileFilterDescription;
 
        /**
@@ -25,7 +26,7 @@
         * @param outputFile     Where to write the serialised data to.
         */
        public PropertyWriter(final CyPropertyWriterManager writerManager,
-                             final CyFileFilter fileFilter, final CyProperty 
property,
+                             final CyFileFilter fileFilter, final 
CyProperty<?> property,
                              final File outputFile)
        {
                super(writerManager);

Modified: 
core3/impl/trunk/swing-application-impl/src/main/resources/META-INF/spring/bundle-context-osgi.xml
===================================================================
--- 
core3/impl/trunk/swing-application-impl/src/main/resources/META-INF/spring/bundle-context-osgi.xml
  2011-08-18 18:29:03 UTC (rev 26602)
+++ 
core3/impl/trunk/swing-application-impl/src/main/resources/META-INF/spring/bundle-context-osgi.xml
  2011-08-18 20:14:15 UTC (rev 26603)
@@ -15,7 +15,7 @@
        <osgi:reference id="recentlyOpenedTrackerServiceRef" 
interface="org.cytoscape.io.util.RecentlyOpenedTracker" />
 
        <osgi:reference id="cytoscapePropertiesServiceRef"
-               interface="org.cytoscape.property.CyProperty" 
filter="(cyPropertyName=coreSettings)" />
+               interface="org.cytoscape.property.CyProperty" 
filter="(cyPropertyName=cytoscape.props)" />
 
        <osgi:reference id="cyApplicationManagerServiceRef"
                interface="org.cytoscape.application.CyApplicationManager" />

Modified: 
core3/impl/trunk/table-import-impl/src/main/resources/META-INF/spring/bundle-context-osgi.xml
===================================================================
--- 
core3/impl/trunk/table-import-impl/src/main/resources/META-INF/spring/bundle-context-osgi.xml
       2011-08-18 18:29:03 UTC (rev 26602)
+++ 
core3/impl/trunk/table-import-impl/src/main/resources/META-INF/spring/bundle-context-osgi.xml
       2011-08-18 20:14:15 UTC (rev 26603)
@@ -28,7 +28,7 @@
  
        <osgi:reference id="cytoscapePropertiesServiceRef" 
                interface="org.cytoscape.property.CyProperty"
-               filter="(cyPropertyName=coreSettings)" />
+               filter="(cyPropertyName=cytoscape.props)" />
 
        <osgi:reference id="fileUtilService" 
interface="org.cytoscape.util.swing.FileUtil" />
        <osgi:reference id="openBrowserService" 
interface="org.cytoscape.util.swing.OpenBrowser" />             

Modified: 
core3/impl/trunk/work-swing-impl/it/src/test/java/org/cytoscape/work/ServiceConfigurationTest.java
===================================================================
--- 
core3/impl/trunk/work-swing-impl/it/src/test/java/org/cytoscape/work/ServiceConfigurationTest.java
  2011-08-18 18:29:03 UTC (rev 26602)
+++ 
core3/impl/trunk/work-swing-impl/it/src/test/java/org/cytoscape/work/ServiceConfigurationTest.java
  2011-08-18 20:14:15 UTC (rev 26603)
@@ -25,7 +25,7 @@
        @Before
        public void setup() {
                Properties coreP = new Properties();
-               coreP.setProperty("cyPropertyName","coreSettings");
+               coreP.setProperty("cyPropertyName","cytoscape.props");
 
                Properties p = new Properties();
                p.setProperty("cyPropertyName","bookmarks");

-- 
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.

Reply via email to