Author: ruschein
Date: 2011-04-04 15:38:05 -0700 (Mon, 04 Apr 2011)
New Revision: 24665
Added:
core3/swing-application-impl/trunk/src/main/java/org/cytoscape/internal/shutdown/
core3/swing-application-impl/trunk/src/main/java/org/cytoscape/internal/shutdown/ConfigDirPropertyWriter.java
Modified:
core3/swing-application-impl/trunk/pom.xml
core3/swing-application-impl/trunk/src/main/resources/META-INF/spring/bundle-context-osgi.xml
core3/swing-application-impl/trunk/src/main/resources/META-INF/spring/bundle-context.xml
Log:
Work in progress.
Modified: core3/swing-application-impl/trunk/pom.xml
===================================================================
--- core3/swing-application-impl/trunk/pom.xml 2011-04-04 22:25:10 UTC (rev
24664)
+++ core3/swing-application-impl/trunk/pom.xml 2011-04-04 22:38:05 UTC (rev
24665)
@@ -83,6 +83,21 @@
<dependencies>
<dependency>
<groupId>org.cytoscape</groupId>
+ <artifactId>work-api</artifactId>
+ <version>3.0.0-alpha3-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.cytoscape</groupId>
+ <artifactId>io-api</artifactId>
+ <version>3.0.0-alpha3-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.cytoscape</groupId>
+ <artifactId>property-api</artifactId>
+ <version>3.0.0-alpha4-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.cytoscape</groupId>
<artifactId>swing-application-api</artifactId>
<version>3.0.0-alpha2-SNAPSHOT</version>
</dependency>
Added:
core3/swing-application-impl/trunk/src/main/java/org/cytoscape/internal/shutdown/ConfigDirPropertyWriter.java
===================================================================
---
core3/swing-application-impl/trunk/src/main/java/org/cytoscape/internal/shutdown/ConfigDirPropertyWriter.java
(rev 0)
+++
core3/swing-application-impl/trunk/src/main/java/org/cytoscape/internal/shutdown/ConfigDirPropertyWriter.java
2011-04-04 22:38:05 UTC (rev 24665)
@@ -0,0 +1,84 @@
+package org.cytoscape.internal.shutdown;
+
+
+import java.io.File;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.cytoscape.application.swing.events.CytoscapeShutdownEvent;
+import org.cytoscape.application.swing.events.CytoscapeShutdownListener;
+import org.cytoscape.property.CyProperty;
+import org.cytoscape.io.CyFileFilter;
+import org.cytoscape.io.write.CyPropertyWriterFactory;
+import org.cytoscape.io.write.CyPropertyWriterManager;
+import org.cytoscape.io.write.CyWriter;
+import org.cytoscape.work.SequentialTaskFactory;
+
+
+public class ConfigDirPropertyWriter implements CytoscapeShutdownListener {
+ private final CyPropertyWriterManager propertyWriterManager;
+ private final Map<CyProperty, Map> configDirProperties;
+ private final Set<CyPropertyWriterFactory> propertyWriterFactories;
+ private final SequentialTaskFactory sequentialTaskFactory;
+
+ ConfigDirPropertyWriter(final CyPropertyWriterManager
propertyWriterManager)
+ {
+ this.propertyWriterManager = propertyWriterManager;
+ configDirProperties = new HashMap<CyProperty, Map>();
+ propertyWriterFactories = new
HashSet<CyPropertyWriterFactory>();
+ sequentialTaskFactory = new SequentialTaskFactory();
+ }
+
+ public void handleEvent(final CytoscapeShutdownEvent event) {
+ for (final Map.Entry<CyProperty, Map> keyAndValue :
configDirProperties.entrySet()) {
+ final String propertyName =
(String)keyAndValue.getValue().get("cyPropertyName");
+ final String outputFileName =
+ System.getProperty("user.home") + "/" +
CyProperty.DEFAULT_CONFIG_DIR
+ + "/" + propertyName + ".props";
+ final File outputFile = new File(outputFileName);
+ boolean foundCorrectFileFiler = false;
+ for (final CyPropertyWriterFactory
propertyWriterFactory : propertyWriterFactories) {
+ final CyFileFilter fileFilter =
propertyWriterFactory.getCyFileFilter();
+System.err.println("+++++++++++++ trying "+fileFilter);
+ try {
+ final CyWriter writer =
+
propertyWriterManager.getWriter(keyAndValue.getKey(), fileFilter,
+
outputFile);
+ sequentialTaskFactory.addTask(writer);
+ foundCorrectFileFiler = true;
+System.err.println("+++++++++++++ SUCCESS!");
+ break;
+ } catch (final Exception e) {
+ }
+ }
+ if (!foundCorrectFileFiler)
+ System.err.println("+++ Failed create a
CyWriter for \""
+ + outputFileName + "\"!");
+ }
+ }
+
+ public void addCyProperty(final CyProperty newCyProperty, final Map
properties) {
+ if (newCyProperty.getSavePolicy() ==
CyProperty.SavePolicy.CONFIG_DIR)
+ configDirProperties.put(newCyProperty, properties);
+ }
+
+ public void removeCyProperty(final CyProperty oldCyProperty, final Map
properties) {
+ if (oldCyProperty.getSavePolicy() ==
CyProperty.SavePolicy.CONFIG_DIR)
+ configDirProperties.remove(oldCyProperty);
+
+ }
+
+ public void addCyPropertyFileWriterFactory(final
CyPropertyWriterFactory newCyPropertyWriterFactory,
+ final Map properties)
+ {
+ propertyWriterFactories.add(newCyPropertyWriterFactory);
+ }
+
+ public void removeCyPropertyFileWriterFactory(final
CyPropertyWriterFactory oldCyPropertyWriterFactory,
+ final Map properties)
+ {
+ propertyWriterFactories.remove(oldCyPropertyWriterFactory);
+ }
+}
\ No newline at end of file
Modified:
core3/swing-application-impl/trunk/src/main/resources/META-INF/spring/bundle-context-osgi.xml
===================================================================
---
core3/swing-application-impl/trunk/src/main/resources/META-INF/spring/bundle-context-osgi.xml
2011-04-04 22:25:10 UTC (rev 24664)
+++
core3/swing-application-impl/trunk/src/main/resources/META-INF/spring/bundle-context-osgi.xml
2011-04-04 22:38:05 UTC (rev 24665)
@@ -7,6 +7,9 @@
<!-- Import OSGi services -->
+ <osgi:reference id="streamUtilServiceRef"
+ interface="org.cytoscape.io.util.StreamUtil" />
+
<osgi:reference id="cytoscapePropertiesServiceRef"
interface="org.cytoscape.property.CyProperty"
filter="(cyPropertyName=coreSettings)" />
@@ -14,6 +17,9 @@
<osgi:reference id="cyApplicationManagerServiceRef"
interface="org.cytoscape.session.CyApplicationManager" />
+ <osgi:reference id="propertyWriterManagerRef"
+ interface="org.cytoscape.io.write.CyPropertyWriterManager" />
+
<osgi:reference id="cyNetworkViewManagerServiceRef"
interface="org.cytoscape.view.model.CyNetworkViewManager" />
@@ -328,4 +334,19 @@
<value>org.cytoscape.session.events.SetCurrentNetworkViewListener</value>
</osgi:interfaces>
</osgi:service>
+
+ <osgi:service id="configDirPropertyWriterService"
ref="configDirPropertyWriter"
+
interface="org.cytoscape.application.swing.events.CytoscapeShutdownListener" />
+
+ <osgi:set id="propertySet"
interface="org.cytoscape.property.CyProperty"
+ cardinality="0..N">
+ <osgi:listener bind-method="addCyProperty"
unbind-method="removeCyProperty"
+ ref="configDirPropertyWriter" />
+ </osgi:set>
+
+ <osgi:set id="propertyFileFilterSet"
interface="org.cytoscape.io.write.CyPropertyWriterFactory"
+ cardinality="0..N">
+ <osgi:listener bind-method="addCyPropertyFileWriterFactory"
unbind-method="removeCyPropertyFileWriterFactory"
+ ref="configDirPropertyWriter" />
+ </osgi:set>
</beans>
Modified:
core3/swing-application-impl/trunk/src/main/resources/META-INF/spring/bundle-context.xml
===================================================================
---
core3/swing-application-impl/trunk/src/main/resources/META-INF/spring/bundle-context.xml
2011-04-04 22:25:10 UTC (rev 24664)
+++
core3/swing-application-impl/trunk/src/main/resources/META-INF/spring/bundle-context.xml
2011-04-04 22:38:05 UTC (rev 24665)
@@ -32,8 +32,10 @@
<bean name="cytoscapeShutdown"
class="org.cytoscape.internal.ShutdownHandler">
<constructor-arg ref="cyEventHelperServiceRef" />
</bean>
+ <bean name="configDirPropertyWriter"
class="org.cytoscape.internal.shutdown.ConfigDirPropertyWriter">
+ <constructor-arg ref="propertyWriterManagerRef" />
+ </bean>
-
<!-- Various Utilities -->
<bean name="cyOperatingContext"
class="org.cytoscape.internal.CyOperatingContextImpl">
--
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.