Author: clopes
Date: 2012-01-10 12:47:14 -0800 (Tue, 10 Jan 2012)
New Revision: 27967
Modified:
core3/api/trunk/property-api/src/main/java/org/cytoscape/property/AbstractConfigDirPropsReader.java
core3/api/trunk/property-api/src/main/java/org/cytoscape/property/CyProperty.java
core3/api/trunk/property-api/src/main/java/org/cytoscape/property/SimpleCyProperty.java
core3/api/trunk/property-api/src/test/java/org/cytoscape/property/AbstractConfigDirPropsReaderTest.java
core3/api/trunk/property-api/src/test/java/org/cytoscape/property/SimpleCyPropertyTest.java
core3/api/trunk/session-api/src/main/java/org/cytoscape/session/CySession.java
core3/api/trunk/session-api/src/test/java/org/cytoscape/session/CySessionTest.java
core3/api/trunk/session-api/src/test/java/org/cytoscape/session/events/SessionLoadedEventTest.java
core3/impl/trunk/core-task-impl/src/test/java/org/cytoscape/task/internal/proxysettings/ProxySettingTaskTest.java
core3/impl/trunk/core-task-impl/src/test/java/org/cytoscape/task/internal/proxysettings/ProxySettingsTaskFactoryTest.java
core3/impl/trunk/ding-impl/performance-debug/src/main/java/org/cytoscape/ding/internal/PerfTest.java
core3/impl/trunk/filter-impl/src/main/java/org/cytoscape/filter/internal/CyActivator.java
core3/impl/trunk/filter-impl/src/main/java/org/cytoscape/filter/internal/read/filter/FilterReader.java
core3/impl/trunk/io-impl/impl/src/main/java/org/cytoscape/io/internal/read/session/AbstractSessionReader.java
core3/impl/trunk/io-impl/impl/src/main/java/org/cytoscape/io/internal/read/session/Cy2SessionReaderImpl.java
core3/impl/trunk/io-impl/impl/src/main/java/org/cytoscape/io/internal/read/session/Cy3SessionReaderImpl.java
core3/impl/trunk/io-impl/impl/src/main/java/org/cytoscape/io/internal/write/session/SessionWriterImpl.java
core3/impl/trunk/io-impl/impl/src/test/java/org/cytoscape/io/internal/read/AbstractNetworkViewReaderTester.java
core3/impl/trunk/io-impl/impl/src/test/java/org/cytoscape/io/internal/read/gml/GMLFileFilterTest.java
core3/impl/trunk/io-impl/impl/src/test/java/org/cytoscape/io/internal/read/session/SessionFileFilterTest.java
core3/impl/trunk/io-impl/performance/src/main/java/org/cytoscape/io/read/sif/PerfTest.java
core3/impl/trunk/linkout-impl/src/main/java/org/cytoscape/linkout/internal/CyActivator.java
core3/impl/trunk/linkout-impl/src/main/java/org/cytoscape/linkout/internal/PropsReader.java
core3/impl/trunk/property-impl/src/main/java/org/cytoscape/property/internal/CyActivator.java
core3/impl/trunk/property-impl/src/main/java/org/cytoscape/property/internal/PropsReader.java
core3/impl/trunk/property-impl/src/main/java/org/cytoscape/property/internal/bookmark/BookmarkReader.java
core3/impl/trunk/session-impl/src/main/java/org/cytoscape/session/internal/CySessionManagerImpl.java
core3/impl/trunk/swing-application-impl/src/main/java/org/cytoscape/internal/actions/PreferenceAction.java
Log:
Fixes #564 : Add "name" property to the CyProperty interface
Modified:
core3/api/trunk/property-api/src/main/java/org/cytoscape/property/AbstractConfigDirPropsReader.java
===================================================================
---
core3/api/trunk/property-api/src/main/java/org/cytoscape/property/AbstractConfigDirPropsReader.java
2012-01-10 20:25:23 UTC (rev 27966)
+++
core3/api/trunk/property-api/src/main/java/org/cytoscape/property/AbstractConfigDirPropsReader.java
2012-01-10 20:47:14 UTC (rev 27967)
@@ -30,18 +30,16 @@
public abstract class AbstractConfigDirPropsReader implements
CyProperty<Properties> {
private static final Logger logger =
LoggerFactory.getLogger(AbstractConfigDirPropsReader.class);
- /**
- * The Properties object created for this class.
- */
+ /** The name of this CyProperty. */
+ protected final String name;
+ /** The Properties object created for this class. */
protected final Properties props;
-
- /**
- * The SavePolicy of this CyProperty.
- */
+ /** The SavePolicy of this CyProperty. */
protected final SavePolicy savePolicy;
/**
* Creates a new AbstractConfigDirPropsReader object.
+ * @param name The name of this CyProperty.
* @param propFileName The name of the java.util.Properties file to
read.
* @param savePolicy The save policy for this CyProperty. This value
MUST be
* either {@link CyProperty.SavePolicy.CONFIG_DIR} or
@@ -50,7 +48,10 @@
* If you'd like to use a different SavePolicy, then consider using
* {@link SimpleCyProperty} instead.
*/
- public AbstractConfigDirPropsReader(String propFileName, SavePolicy
savePolicy) {
+ public AbstractConfigDirPropsReader(final String name, final String
propFileName, final SavePolicy savePolicy) {
+ if ( name == null )
+ throw new NullPointerException("name cannot be null");
+
if ( propFileName == null )
throw new NullPointerException("propFileName cannot be
null");
@@ -61,6 +62,7 @@
savePolicy !=
CyProperty.SavePolicy.SESSION_FILE_AND_CONFIG_DIR )
throw new IllegalArgumentException("Save policy must
be either CONFIG_DIR or SESSION_FILE_AND_CONFIG_DIR");
+ this.name = name;
this.savePolicy = savePolicy;
this.props = new Properties();
@@ -116,6 +118,12 @@
/** {@inheritDoc} */
@Override
+ public String getName() {
+ return name;
+ }
+
+ /** {@inheritDoc} */
+ @Override
public CyProperty.SavePolicy getSavePolicy() {
return savePolicy;
}
Modified:
core3/api/trunk/property-api/src/main/java/org/cytoscape/property/CyProperty.java
===================================================================
---
core3/api/trunk/property-api/src/main/java/org/cytoscape/property/CyProperty.java
2012-01-10 20:25:23 UTC (rev 27966)
+++
core3/api/trunk/property-api/src/main/java/org/cytoscape/property/CyProperty.java
2012-01-10 20:47:14 UTC (rev 27967)
@@ -53,9 +53,15 @@
* system properties ({@link System#getProperties()}).
*/
String DEFAULT_PROPS_CONFIG_DIR = ".cytoscape";
-
+
/**
- * Return a property object
+ * Returns the name of the CyProperty.
+ * @return The name of the CyProperty.
+ */
+ String getName();
+
+ /**
+ * Return a property object.
* @return A property object of type P.
*/
P getProperties();
Modified:
core3/api/trunk/property-api/src/main/java/org/cytoscape/property/SimpleCyProperty.java
===================================================================
---
core3/api/trunk/property-api/src/main/java/org/cytoscape/property/SimpleCyProperty.java
2012-01-10 20:25:23 UTC (rev 27966)
+++
core3/api/trunk/property-api/src/main/java/org/cytoscape/property/SimpleCyProperty.java
2012-01-10 20:47:14 UTC (rev 27967)
@@ -1,6 +1,5 @@
package org.cytoscape.property;
-
import java.util.Properties;
@@ -11,11 +10,10 @@
*/
public final class SimpleCyProperty implements CyProperty<Properties> {
- /**
- * Core Cytoscape Property (Cytoscape System Property)
- */
- public static final String CORE_PROPRERTY_NAME = "cytoscape3.props";
+ /** Core Cytoscape Property (Cytoscape System Property) */
+ public static final String CORE_PROPRERTY_NAME = "cytoscape 3";
+ private final String name;
private final Properties properties;
private final CyProperty.SavePolicy savePolicy;
@@ -26,26 +24,33 @@
* should encapsulate. Throws NullPointerException if Properties is
null.
* @param savePolicy the {@link CyProperty.SavePolicy} of this
CyProperty object.
*/
- public SimpleCyProperty(final Properties properties, final
CyProperty.SavePolicy savePolicy) {
+ public SimpleCyProperty(final String name, final Properties properties,
final CyProperty.SavePolicy savePolicy) {
+ if (name == null)
+ throw new NullPointerException("\"name\" parameter is
null!");
if (properties == null)
throw new NullPointerException("\"properties\"
parameter is null!");
if (savePolicy == null)
throw new NullPointerException("\"savePolicy\"
parameter is null!");
+ this.name = name;
this.properties = properties;
this.savePolicy = savePolicy;
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ /** {@inheritDoc} */
+ @Override
public Properties getProperties() {
return properties;
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
+ @Override
public CyProperty.SavePolicy getSavePolicy() {
return savePolicy;
}
Modified:
core3/api/trunk/property-api/src/test/java/org/cytoscape/property/AbstractConfigDirPropsReaderTest.java
===================================================================
---
core3/api/trunk/property-api/src/test/java/org/cytoscape/property/AbstractConfigDirPropsReaderTest.java
2012-01-10 20:25:23 UTC (rev 27966)
+++
core3/api/trunk/property-api/src/test/java/org/cytoscape/property/AbstractConfigDirPropsReaderTest.java
2012-01-10 20:47:14 UTC (rev 27967)
@@ -1,49 +1,62 @@
package org.cytoscape.property;
+import static org.cytoscape.property.CyProperty.SavePolicy.*;
import static org.junit.Assert.*;
-import java.util.Properties;
+
import org.junit.Test;
public class AbstractConfigDirPropsReaderTest {
private class BasicConfigDirPropsReader extends
AbstractConfigDirPropsReader {
- BasicConfigDirPropsReader(String s, SavePolicy sp) {
- super(s,sp);
+ BasicConfigDirPropsReader(String name, String fileName,
SavePolicy sp) {
+ super(name, fileName, sp);
}
}
@Test(expected=IllegalArgumentException.class)
public void testBadSavePolicy() throws Exception {
- BasicConfigDirPropsReader p = new
BasicConfigDirPropsReader("homer",CyProperty.SavePolicy.DO_NOT_SAVE);
+ BasicConfigDirPropsReader p = new
BasicConfigDirPropsReader("Homer","homer.props",DO_NOT_SAVE);
}
@Test(expected=IllegalArgumentException.class)
public void testBadSavePolicy2() throws Exception {
- BasicConfigDirPropsReader p = new
BasicConfigDirPropsReader("homer",CyProperty.SavePolicy.SESSION_FILE);
+ BasicConfigDirPropsReader p = new
BasicConfigDirPropsReader("Homer","homer.props",SESSION_FILE);
}
@Test(expected=NullPointerException.class)
- public void testNullSavePol() throws Exception {
- BasicConfigDirPropsReader p = new
BasicConfigDirPropsReader("homer",null);
+ public void testNullName() throws Exception {
+ BasicConfigDirPropsReader p = new
BasicConfigDirPropsReader(null,"homer.props",null);
+
}
@Test(expected=NullPointerException.class)
public void testNullPropName() throws Exception {
- BasicConfigDirPropsReader p = new
BasicConfigDirPropsReader(null,CyProperty.SavePolicy.CONFIG_DIR);
+ BasicConfigDirPropsReader p = new
BasicConfigDirPropsReader("Test",null,CONFIG_DIR);
}
+
+ @Test(expected=NullPointerException.class)
+ public void testNullSavePol() throws Exception {
+ BasicConfigDirPropsReader p = new
BasicConfigDirPropsReader("Homer","homer.props",null);
+ }
@Test
public void testGetDefaultProp(){
- BasicConfigDirPropsReader p = new
BasicConfigDirPropsReader("test.props",CyProperty.SavePolicy.CONFIG_DIR);
+ BasicConfigDirPropsReader p = new
BasicConfigDirPropsReader("Test","test.props",CONFIG_DIR);
assertEquals("marge",
p.getProperties().getProperty("homer").toString() );
}
+
+ @Test
+ public void testGetName(){
+ BasicConfigDirPropsReader p = new
BasicConfigDirPropsReader("Test","test.props",CONFIG_DIR);
+ assertEquals("Test", p.getName());
+ }
@Test
public void testGetSavePolicy(){
- BasicConfigDirPropsReader p = new
BasicConfigDirPropsReader("test.props",CyProperty.SavePolicy.CONFIG_DIR);
- assertEquals(CyProperty.SavePolicy.CONFIG_DIR,
p.getSavePolicy());
+ BasicConfigDirPropsReader p = new
BasicConfigDirPropsReader("Test","test.props",CONFIG_DIR);
+ assertEquals(CONFIG_DIR, p.getSavePolicy());
}
// no tests for reading config dir since we don't want to pollute the
actual config dir with anything
Modified:
core3/api/trunk/property-api/src/test/java/org/cytoscape/property/SimpleCyPropertyTest.java
===================================================================
---
core3/api/trunk/property-api/src/test/java/org/cytoscape/property/SimpleCyPropertyTest.java
2012-01-10 20:25:23 UTC (rev 27966)
+++
core3/api/trunk/property-api/src/test/java/org/cytoscape/property/SimpleCyPropertyTest.java
2012-01-10 20:47:14 UTC (rev 27967)
@@ -9,27 +9,31 @@
public class SimpleCyPropertyTest {
@Test(expected=NullPointerException.class)
+ public void testNullName() throws Exception {
+ SimpleCyProperty p = new SimpleCyProperty(null, new
Properties(), CyProperty.SavePolicy.DO_NOT_SAVE);
+ }
+
+ @Test(expected=NullPointerException.class)
public void testNullProp() throws Exception {
- SimpleCyProperty p = new SimpleCyProperty(null,
CyProperty.SavePolicy.DO_NOT_SAVE);
+ SimpleCyProperty p = new SimpleCyProperty("test", null,
CyProperty.SavePolicy.DO_NOT_SAVE);
}
@Test(expected=NullPointerException.class)
public void testNullSavePol() throws Exception {
- Properties props = new Properties();
- SimpleCyProperty p = new SimpleCyProperty(props, null);
+ SimpleCyProperty p = new SimpleCyProperty("test", new
Properties(), null);
}
-
+
@Test
public void testGetProp(){
Properties props = new Properties();
- SimpleCyProperty p = new SimpleCyProperty(props,
CyProperty.SavePolicy.DO_NOT_SAVE);
+ SimpleCyProperty p = new SimpleCyProperty("test", props,
CyProperty.SavePolicy.DO_NOT_SAVE);
assertTrue(p.getProperties() != null);
}
@Test
public void testGetSavePol(){
Properties props = new Properties();
- SimpleCyProperty p = new SimpleCyProperty(props,
CyProperty.SavePolicy.DO_NOT_SAVE);
+ SimpleCyProperty p = new SimpleCyProperty("test", props,
CyProperty.SavePolicy.DO_NOT_SAVE);
assertTrue(p.getSavePolicy() ==
CyProperty.SavePolicy.DO_NOT_SAVE);
}
}
Modified:
core3/api/trunk/session-api/src/main/java/org/cytoscape/session/CySession.java
===================================================================
---
core3/api/trunk/session-api/src/main/java/org/cytoscape/session/CySession.java
2012-01-10 20:25:23 UTC (rev 27966)
+++
core3/api/trunk/session-api/src/main/java/org/cytoscape/session/CySession.java
2012-01-10 20:47:14 UTC (rev 27967)
@@ -37,6 +37,7 @@
import org.cytoscape.model.CyNetwork;
import org.cytoscape.model.CyTableMetadata;
+import org.cytoscape.property.CyProperty;
import org.cytoscape.property.bookmark.Bookmarks;
import org.cytoscape.property.session.Cysession;
import org.cytoscape.view.model.CyNetworkView;
@@ -68,7 +69,7 @@
private final Set<CyNetworkView> netViews;
private final Set<CyTableMetadata> tables;
private final Map<CyNetworkView,String> vsMap;
- private final Map<String, Properties> properties;
+ private final Set<CyProperty<Properties>> properties;
private final Set<VisualStyle> visualStyles;
private final Map<String, List<File>> appFiles;
private final Bookmarks bookmarks;
@@ -98,7 +99,7 @@
vsMap = b.vsMap;
if ( b.properties == null )
- properties = new HashMap<String, Properties>();
+ properties = new HashSet<CyProperty<Properties>>();
else
properties = b.properties;
@@ -134,7 +135,7 @@
private Set<CyNetworkView> netViews;
private Set<CyTableMetadata> tables;
private Map<CyNetworkView,String> vsMap;
- private Map<String, Properties> properties;
+ private Set<CyProperty<Properties>> properties;
private Set<VisualStyle> visualStyles;
private Map<String, List<File>> appFiles;
private Bookmarks bookmarks;
@@ -203,11 +204,11 @@
/**
* Returns an instance of Builder that has at least been
configured
* with the specified properties.
- * @param p A map of session related Property objects by
property name.
+ * @param p A set of session related {@link CyProperty} objects.
* @return An instance of Builder that has at least been
configured
* with the specified properties.
*/
- public Builder properties(final Map<String, Properties> p) {
+ public Builder properties(final Set<CyProperty<Properties>> p) {
properties = p;
return this;
}
@@ -291,11 +292,11 @@
public Map<CyNetworkView,String> getViewVisualStyleMap() { return vsMap; }
/**
- * Returns a map of session related properties defined for this session.
- * @return A map of session related Property objects by property name.
+ * Returns a set of {@link CyProperty} objects defined for this session.
+ * @return A set of session related {@link CyProperty} objects.
* defined for this session.
*/
- public Map<String, Properties> getProperties() { return properties; }
+ public Set<CyProperty<Properties>> getProperties() { return properties; }
/**
* Returns a set containing all VisualStyles defined for this session.
Modified:
core3/api/trunk/session-api/src/test/java/org/cytoscape/session/CySessionTest.java
===================================================================
---
core3/api/trunk/session-api/src/test/java/org/cytoscape/session/CySessionTest.java
2012-01-10 20:25:23 UTC (rev 27966)
+++
core3/api/trunk/session-api/src/test/java/org/cytoscape/session/CySessionTest.java
2012-01-10 20:47:14 UTC (rev 27967)
@@ -16,6 +16,8 @@
import org.cytoscape.model.CyTable;
import org.cytoscape.model.CyTableMetadata;
+import org.cytoscape.property.CyProperty;
+import org.cytoscape.property.SimpleCyProperty;
import org.cytoscape.property.bookmark.Bookmarks;
import org.cytoscape.property.session.Cysession;
import org.cytoscape.view.model.CyNetworkView;
@@ -267,23 +269,31 @@
}
- private void checkProps(Map<String, Properties> map) {
- assertNotNull(map);
- Properties p = map.get("Session");
- assertNotNull(p);
+ private void checkProps(Set<CyProperty<Properties>> set) {
+ assertNotNull(set);
+ assertEquals(1,set.size());
+
+ CyProperty<Properties> cyProps = set.toArray(new
CyProperty[set.size()])[0];
+ assertNotNull(cyProps);
+ assertEquals("test",cyProps.getName());
+
assertEquals(CyProperty.SavePolicy.SESSION_FILE,cyProps.getSavePolicy());
+
+ Properties p = cyProps.getProperties();
assertEquals(2,p.size());
assertEquals("value1",p.getProperty("key1"));
assertEquals("value2",p.getProperty("key2"));
}
- private Map<String, Properties> getFakeProps() {
- Map<String, Properties> map = new HashMap<String, Properties>();
+ private Set<CyProperty<Properties>> getFakeProps() {
+ Set<CyProperty<Properties>> set = new
HashSet<CyProperty<Properties>>();
Properties p = new Properties();
p.setProperty("key1","value1");
p.setProperty("key2","value2");
- map.put("Session", p);
- return map;
+ CyProperty<Properties> cyProps = new SimpleCyProperty("test",
p, CyProperty.SavePolicy.SESSION_FILE);
+ set.add(cyProps);
+
+ return set;
}
}
Modified:
core3/api/trunk/session-api/src/test/java/org/cytoscape/session/events/SessionLoadedEventTest.java
===================================================================
---
core3/api/trunk/session-api/src/test/java/org/cytoscape/session/events/SessionLoadedEventTest.java
2012-01-10 20:25:23 UTC (rev 27966)
+++
core3/api/trunk/session-api/src/test/java/org/cytoscape/session/events/SessionLoadedEventTest.java
2012-01-10 20:47:14 UTC (rev 27967)
@@ -10,6 +10,7 @@
import java.util.Set;
import org.cytoscape.model.CyTableMetadata;
+import org.cytoscape.property.CyProperty;
import org.cytoscape.property.bookmark.Bookmarks;
import org.cytoscape.property.session.Cysession;
import org.cytoscape.session.CySession;
@@ -29,7 +30,7 @@
private CySession session;
@Mock
- private Map<String, Properties> props;
+ private Set<CyProperty<Properties>> props;
@Mock
private Bookmarks bkmarks;
Modified:
core3/impl/trunk/core-task-impl/src/test/java/org/cytoscape/task/internal/proxysettings/ProxySettingTaskTest.java
===================================================================
---
core3/impl/trunk/core-task-impl/src/test/java/org/cytoscape/task/internal/proxysettings/ProxySettingTaskTest.java
2012-01-10 20:25:23 UTC (rev 27966)
+++
core3/impl/trunk/core-task-impl/src/test/java/org/cytoscape/task/internal/proxysettings/ProxySettingTaskTest.java
2012-01-10 20:47:14 UTC (rev 27967)
@@ -27,7 +27,7 @@
@Test
public void testRun() throws Exception {
Properties properties = new Properties();
- final CyProperty<Properties> proxyProperties = new
SimpleCyProperty(properties , SavePolicy.DO_NOT_SAVE);
+ final CyProperty<Properties> proxyProperties = new
SimpleCyProperty("Test", properties, SavePolicy.DO_NOT_SAVE);
final ProxySettingsTask2 t = new
ProxySettingsTask2(proxyProperties, streamUtil);
final String type = "http";
Modified:
core3/impl/trunk/core-task-impl/src/test/java/org/cytoscape/task/internal/proxysettings/ProxySettingsTaskFactoryTest.java
===================================================================
---
core3/impl/trunk/core-task-impl/src/test/java/org/cytoscape/task/internal/proxysettings/ProxySettingsTaskFactoryTest.java
2012-01-10 20:25:23 UTC (rev 27966)
+++
core3/impl/trunk/core-task-impl/src/test/java/org/cytoscape/task/internal/proxysettings/ProxySettingsTaskFactoryTest.java
2012-01-10 20:47:14 UTC (rev 27967)
@@ -21,7 +21,7 @@
StreamUtil streamUtil = mock(StreamUtil.class);
Properties properties = new Properties();
- final CyProperty<Properties> proxyProperties = new
SimpleCyProperty(properties , SavePolicy.DO_NOT_SAVE);
+ final CyProperty<Properties> proxyProperties = new
SimpleCyProperty("Test", properties, SavePolicy.DO_NOT_SAVE);
ProxySettingsTaskFactory factory = new
ProxySettingsTaskFactory(proxyProperties, streamUtil);
TaskIterator ti = factory.createTaskIterator();
Modified:
core3/impl/trunk/ding-impl/performance-debug/src/main/java/org/cytoscape/ding/internal/PerfTest.java
===================================================================
---
core3/impl/trunk/ding-impl/performance-debug/src/main/java/org/cytoscape/ding/internal/PerfTest.java
2012-01-10 20:25:23 UTC (rev 27966)
+++
core3/impl/trunk/ding-impl/performance-debug/src/main/java/org/cytoscape/ding/internal/PerfTest.java
2012-01-10 20:47:14 UTC (rev 27967)
@@ -1,7 +1,7 @@
package org.cytoscape.ding.internal;
-
+import static org.cytoscape.property.CyProperty.SavePolicy.DO_NOT_SAVE;
import static org.mockito.Mockito.mock;
import java.awt.Color;
@@ -37,7 +37,6 @@
public class PerfTest {
-
public static void main(String[] args) {
PerfTest pt = new PerfTest();
//pt.runTestLoop();
@@ -63,7 +62,7 @@
viewFactory = nvts.getNetworkViewFactory();
Properties properties = new Properties();
- CyProperty<Properties> cyProperties = new
SimpleCyProperty(properties, CyProperty.SavePolicy.DO_NOT_SAVE);
+ CyProperty<Properties> cyProperties = new
SimpleCyProperty("Test",properties, DO_NOT_SAVE);
readUtil = new ReadUtils(new StreamUtilImpl(cyProperties));
}
@@ -143,7 +142,7 @@
private CyLayoutAlgorithmManager getLayouts() {
Properties p = new Properties();
- CyProperty<Properties> props = new
SimpleCyProperty(p,CyProperty.SavePolicy.DO_NOT_SAVE);
+ CyProperty<Properties> props = new
SimpleCyProperty("Test",p,DO_NOT_SAVE);
CyLayoutsImpl cyLayouts = new CyLayoutsImpl(props);
CyLayoutAlgorithm gridNodeLayout = new
GridNodeLayout(mock(UndoSupport.class));
cyLayouts.addLayout(gridNodeLayout,p);
Modified:
core3/impl/trunk/filter-impl/src/main/java/org/cytoscape/filter/internal/CyActivator.java
===================================================================
---
core3/impl/trunk/filter-impl/src/main/java/org/cytoscape/filter/internal/CyActivator.java
2012-01-10 20:25:23 UTC (rev 27966)
+++
core3/impl/trunk/filter-impl/src/main/java/org/cytoscape/filter/internal/CyActivator.java
2012-01-10 20:47:14 UTC (rev 27967)
@@ -67,7 +67,7 @@
//
BasicCyFileFilter filterFilter = new BasicCyFileFilter(new
String[]{"filters"}, new String[]{"text/plain"}, "Filters
file",DataCategory.PROPERTIES, streamUtil);
- FilterReader filterReader = new FilterReader("props.filters");
+ FilterReader filterReader = new FilterReader("filters",
"props.filters");
FilterWriterFactoryImpl filterWriter = new
FilterWriterFactoryImpl(filterFilter);
ServicesUtil.filterReader = filterReader;
Modified:
core3/impl/trunk/filter-impl/src/main/java/org/cytoscape/filter/internal/read/filter/FilterReader.java
===================================================================
---
core3/impl/trunk/filter-impl/src/main/java/org/cytoscape/filter/internal/read/filter/FilterReader.java
2012-01-10 20:25:23 UTC (rev 27966)
+++
core3/impl/trunk/filter-impl/src/main/java/org/cytoscape/filter/internal/read/filter/FilterReader.java
2012-01-10 20:47:14 UTC (rev 27967)
@@ -26,6 +26,7 @@
// This is in the resource file (jar)
private static final String DEF_PROP_FILE_NAME =
"default_filters.props";
+ private String name;
private Vector<CompositeFilter> FilterVect;
public static String cyConfigVerDir;
@@ -33,12 +34,14 @@
/**
* Creates a new BookmarkReader object.
*/
- public FilterReader(String resourceLocation) {
-
+ public FilterReader(String name, String resourceLocation) {
+ if ( name == null )
+ throw new NullPointerException("name is null");
+
if ( resourceLocation == null )
throw new NullPointerException("resource Location is
null");
- InputStream is = null;
+ this.name = name;
this.FilterVect = new Vector<CompositeFilter>();
// Load global filtrers if any
@@ -47,12 +50,12 @@
ServicesUtil.cytoscapeVersionService.getMinorVersion()).getAbsolutePath();
final File globalFilterFile = new File(cyConfigVerDir +
File.separator + resourceLocation);
- if (globalFilterFile.exists()){
- try
- {
+ InputStream is = null;
+
+ if (globalFilterFile.exists()) {
+ try {
is = new FileInputStream(globalFilterFile);
- }
- catch (Exception e){
+ } catch (Exception e){
e.printStackTrace();
}
}
@@ -93,19 +96,21 @@
// System.out.println("\n\n\tFilterReader
this.FilterVect.size()="+this.FilterVect.size()+ "\n");
}
-
@Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
public Vector<CompositeFilter> getProperties() {
return this.FilterVect;
}
-
@Override
public CyProperty.SavePolicy getSavePolicy() {
return CyProperty.SavePolicy.SESSION_FILE_AND_CONFIG_DIR;
}
-
@Override
public void handleEvent(SessionLoadedEvent e) {
// TODO
Modified:
core3/impl/trunk/io-impl/impl/src/main/java/org/cytoscape/io/internal/read/session/AbstractSessionReader.java
===================================================================
---
core3/impl/trunk/io-impl/impl/src/main/java/org/cytoscape/io/internal/read/session/AbstractSessionReader.java
2012-01-10 20:25:23 UTC (rev 27966)
+++
core3/impl/trunk/io-impl/impl/src/main/java/org/cytoscape/io/internal/read/session/AbstractSessionReader.java
2012-01-10 20:47:14 UTC (rev 27967)
@@ -46,6 +46,7 @@
import org.cytoscape.io.read.CySessionReader;
import org.cytoscape.model.CyNetwork;
import org.cytoscape.model.CyTableMetadata;
+import org.cytoscape.property.CyProperty;
import org.cytoscape.property.bookmark.Bookmarks;
import org.cytoscape.property.session.Cysession;
import org.cytoscape.session.CySession;
@@ -67,7 +68,7 @@
protected Cysession cysession;
protected Bookmarks bookmarks;
- protected Map<String, Properties> propertiesMap = new HashMap<String,
Properties>();
+ protected Set<CyProperty<Properties>> properties = new
HashSet<CyProperty<Properties>>();
protected final Set<CyNetwork> networks = new
LinkedHashSet<CyNetwork>();
protected final Set<CyNetworkView> networkViews = new
LinkedHashSet<CyNetworkView>();
protected final Set<VisualStyle> visualStyles = new
HashSet<VisualStyle>();
@@ -108,7 +109,7 @@
@Override
public CySession getSession() {
CySession ret = new
CySession.Builder().networks(networks).networkViews(networkViews)
-
.viewVisualStyleMap(visualStyleMap).properties(propertiesMap).visualStyles(visualStyles)
+
.viewVisualStyleMap(visualStyleMap).properties(properties).visualStyles(visualStyles)
.bookmarks(bookmarks).cysession(cysession).appFileListMap(appFileListMap).tables(tableMetadata)
.build();
Modified:
core3/impl/trunk/io-impl/impl/src/main/java/org/cytoscape/io/internal/read/session/Cy2SessionReaderImpl.java
===================================================================
---
core3/impl/trunk/io-impl/impl/src/main/java/org/cytoscape/io/internal/read/session/Cy2SessionReaderImpl.java
2012-01-10 20:25:23 UTC (rev 27966)
+++
core3/impl/trunk/io-impl/impl/src/main/java/org/cytoscape/io/internal/read/session/Cy2SessionReaderImpl.java
2012-01-10 20:47:14 UTC (rev 27967)
@@ -72,6 +72,8 @@
import org.cytoscape.model.CyRow;
import org.cytoscape.model.subnetwork.CyRootNetwork;
import org.cytoscape.model.subnetwork.CyRootNetworkManager;
+import org.cytoscape.property.CyProperty;
+import org.cytoscape.property.SimpleCyProperty;
import org.cytoscape.property.bookmark.Bookmarks;
import org.cytoscape.property.session.Child;
import org.cytoscape.property.session.Cysession;
@@ -288,7 +290,7 @@
if
(row.getTable().getColumn(CY2_PARENT_NETWORK_COLUMN) == null)
row.getTable().createColumn(CY2_PARENT_NETWORK_COLUMN, Long.class, false);
-
+
row.set(CY2_PARENT_NETWORK_COLUMN,
parent.getSUID());
}
@@ -377,10 +379,10 @@
newProps.put(key, value);
}
}
-
- if (newProps.size() > 0) {
- propertiesMap.put("session", newProps); //
TODO: choose a better name
- }
+
+ CyProperty<Properties> cyProps = new
SimpleCyProperty("session", newProps,
+ CyProperty.SavePolicy.SESSION_FILE);
+ properties.add(cyProps);
}
}
@@ -397,8 +399,9 @@
}
private void processNetworks() throws Exception {
- if (cysession == null) return;
-
+ if (cysession == null)
+ return;
+
// Network attributes and visual styles
if (cysession.getNetworkTree() != null) {
for (final Network net :
cysession.getNetworkTree().getNetwork()) {
@@ -406,12 +409,12 @@
// so let's ignore a network with that name.
if (net.getId().equals(NETWORK_ROOT))
continue;
-
+
final String netName = net.getId();
// Set attribute values that are saved in the
cysession.xml
final CyNetwork cyNet = getNetwork(netName);
-
+
if (cyNet != null) {
// From Cytoscape 3.0, the selection
and hidden attributes are stored inside CyTables.
if (net.getSelectedNodes() != null)
@@ -431,7 +434,7 @@
if (view != null) {
String vsName = net.getVisualStyle();
-
+
if (vsName != null)
visualStyleMap.put(view,
vsName);
}
@@ -530,7 +533,7 @@
if (n != null)
net.getRow(n, tableName).set(attrName, true);
- else
+ else
logger.error("Cannot restore boolean node attr
\"" + name + "\": node not found.");
}
}
@@ -543,7 +546,7 @@
// create an id map
Map<String, CyEdge> edgeMap = new HashMap<String, CyEdge>();
- for (CyEdge e : net.getEdgeList()){
+ for (CyEdge e : net.getEdgeList()) {
CyRow row = net.getRow(e);
String name = row.get(CyNetwork.NAME, String.class);
@@ -562,7 +565,7 @@
if (e != null)
net.getRow(e, tableName).set(attrName, true);
- else
+ else
logger.error("Cannot restore boolean edge attr
\"" + name + "\": node not found.");
}
}
Modified:
core3/impl/trunk/io-impl/impl/src/main/java/org/cytoscape/io/internal/read/session/Cy3SessionReaderImpl.java
===================================================================
---
core3/impl/trunk/io-impl/impl/src/main/java/org/cytoscape/io/internal/read/session/Cy3SessionReaderImpl.java
2012-01-10 20:25:23 UTC (rev 27966)
+++
core3/impl/trunk/io-impl/impl/src/main/java/org/cytoscape/io/internal/read/session/Cy3SessionReaderImpl.java
2012-01-10 20:47:14 UTC (rev 27967)
@@ -80,6 +80,8 @@
import org.cytoscape.model.CyTable;
import org.cytoscape.model.CyTableEntry;
import org.cytoscape.model.CyTableMetadata;
+import org.cytoscape.property.CyProperty;
+import org.cytoscape.property.SimpleCyProperty;
import org.cytoscape.property.bookmark.Bookmarks;
import org.cytoscape.property.session.Cysession;
import org.cytoscape.view.model.CyNetworkView;
@@ -372,15 +374,20 @@
reader.run(taskMonitor);
Properties props = (Properties) reader.getProperty();
- if (props != null && props.size() > 0) {
+ if (props != null) {
Matcher matcher = PROPERTIES_PATTERN.matcher(entryName);
if (matcher.matches()) {
String propsName = matcher.group(2);
- if (propsName != null)
- propertiesMap.put(propsName, props);
+ if (propsName != null) {
+ CyProperty<Properties> cyProps = new
SimpleCyProperty(propsName, props,
+
CyProperty.SavePolicy.SESSION_FILE);
+ properties.add(cyProps);
+ }
}
+ } else {
+ logger.error("Cannot extract CyProperty name from: " +
entryName);
}
}
Modified:
core3/impl/trunk/io-impl/impl/src/main/java/org/cytoscape/io/internal/write/session/SessionWriterImpl.java
===================================================================
---
core3/impl/trunk/io-impl/impl/src/main/java/org/cytoscape/io/internal/write/session/SessionWriterImpl.java
2012-01-10 20:25:23 UTC (rev 27966)
+++
core3/impl/trunk/io-impl/impl/src/main/java/org/cytoscape/io/internal/write/session/SessionWriterImpl.java
2012-01-10 20:47:14 UTC (rev 27967)
@@ -60,7 +60,6 @@
import java.util.HashSet;
import java.util.List;
import java.util.Map;
-import java.util.Map.Entry;
import java.util.Properties;
import java.util.Set;
import java.util.zip.ZipEntry;
@@ -83,6 +82,7 @@
import org.cytoscape.model.VirtualColumnInfo;
import org.cytoscape.model.subnetwork.CyRootNetwork;
import org.cytoscape.model.subnetwork.CyRootNetworkManager;
+import org.cytoscape.property.CyProperty;
import org.cytoscape.property.session.Cysession;
import org.cytoscape.session.CySession;
import org.cytoscape.view.model.CyNetworkView;
@@ -114,7 +114,6 @@
// Name of CySession file.
private static final String VIZMAP_FILE = "session_vizmap.xml";
- private static final String CYPROP_FILE = "session_cytoscape.props";
private final String cysessionDocId;
private final String sessionDir;
@@ -286,9 +285,9 @@
* Writes the cytoscape.props file to the session zip.
*/
private void zipProperties() throws Exception {
- for (Entry<String, Properties> entry :
session.getProperties().entrySet()) {
- String fileName = entry.getKey() + PROPERTIES_EXT;
- Properties props = entry.getValue();
+ for (CyProperty<Properties> cyProps : session.getProperties()) {
+ String fileName = cyProps.getName() + PROPERTIES_EXT;
+ Properties props = cyProps.getProperties();
zos.putNextEntry(new ZipEntry(sessionDir +
PROPERTIES_FOLDER + fileName) );
Modified:
core3/impl/trunk/io-impl/impl/src/test/java/org/cytoscape/io/internal/read/AbstractNetworkViewReaderTester.java
===================================================================
---
core3/impl/trunk/io-impl/impl/src/test/java/org/cytoscape/io/internal/read/AbstractNetworkViewReaderTester.java
2012-01-10 20:25:23 UTC (rev 27966)
+++
core3/impl/trunk/io-impl/impl/src/test/java/org/cytoscape/io/internal/read/AbstractNetworkViewReaderTester.java
2012-01-10 20:47:14 UTC (rev 27967)
@@ -60,7 +60,7 @@
netFactory = nts.getNetworkFactory();
properties = new Properties();
- CyProperty<Properties> cyProperties = new
SimpleCyProperty(properties, SavePolicy.DO_NOT_SAVE);
+ CyProperty<Properties> cyProperties = new
SimpleCyProperty("Test", properties, SavePolicy.DO_NOT_SAVE);
NetworkViewTestSupport nvts = new NetworkViewTestSupport();
setViewThreshold(DEF_THRESHOLD);
Modified:
core3/impl/trunk/io-impl/impl/src/test/java/org/cytoscape/io/internal/read/gml/GMLFileFilterTest.java
===================================================================
---
core3/impl/trunk/io-impl/impl/src/test/java/org/cytoscape/io/internal/read/gml/GMLFileFilterTest.java
2012-01-10 20:25:23 UTC (rev 27966)
+++
core3/impl/trunk/io-impl/impl/src/test/java/org/cytoscape/io/internal/read/gml/GMLFileFilterTest.java
2012-01-10 20:47:14 UTC (rev 27967)
@@ -28,7 +28,7 @@
String description = "GML";
Properties properties = new Properties();
- CyProperty<Properties> cyProperties = new
SimpleCyProperty(properties, SavePolicy.DO_NOT_SAVE);
+ CyProperty<Properties> cyProperties = new
SimpleCyProperty("test", properties, SavePolicy.DO_NOT_SAVE);
filter = new GMLFileFilter(extensions, contentTypes,
description , DataCategory.NETWORK, new StreamUtilImpl(cyProperties));
}
Modified:
core3/impl/trunk/io-impl/impl/src/test/java/org/cytoscape/io/internal/read/session/SessionFileFilterTest.java
===================================================================
---
core3/impl/trunk/io-impl/impl/src/test/java/org/cytoscape/io/internal/read/session/SessionFileFilterTest.java
2012-01-10 20:25:23 UTC (rev 27966)
+++
core3/impl/trunk/io-impl/impl/src/test/java/org/cytoscape/io/internal/read/session/SessionFileFilterTest.java
2012-01-10 20:47:14 UTC (rev 27967)
@@ -26,7 +26,7 @@
contentTypes = new HashSet<String>();
Properties properties = new Properties();
- CyProperty<Properties> cyProperties = new
SimpleCyProperty(properties, SavePolicy.DO_NOT_SAVE);
+ CyProperty<Properties> cyProperties = new
SimpleCyProperty("test", properties, SavePolicy.DO_NOT_SAVE);
streamUtil = new StreamUtilImpl(cyProperties);
}
Modified:
core3/impl/trunk/io-impl/performance/src/main/java/org/cytoscape/io/read/sif/PerfTest.java
===================================================================
---
core3/impl/trunk/io-impl/performance/src/main/java/org/cytoscape/io/read/sif/PerfTest.java
2012-01-10 20:25:23 UTC (rev 27966)
+++
core3/impl/trunk/io-impl/performance/src/main/java/org/cytoscape/io/read/sif/PerfTest.java
2012-01-10 20:47:14 UTC (rev 27967)
@@ -1,7 +1,7 @@
package org.cytoscape.io.read.sif;
-
+import static org.cytoscape.property.CyProperty.SavePolicy.DO_NOT_SAVE;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -32,7 +32,6 @@
public class PerfTest {
-
public static void main(String[] args) {
new PerfTest().runTestLoop();
}
@@ -60,7 +59,7 @@
netFactory = nts.getNetworkFactory();
properties = new Properties();
- CyProperty<Properties> cyProperties = new
SimpleCyProperty(properties, CyProperty.SavePolicy.DO_NOT_SAVE);
+ CyProperty<Properties> cyProperties = new
SimpleCyProperty("Test", properties, DO_NOT_SAVE);
NetworkViewTestSupport nvts = new NetworkViewTestSupport();
setViewThreshold(DEF_THRESHOLD);
Modified:
core3/impl/trunk/linkout-impl/src/main/java/org/cytoscape/linkout/internal/CyActivator.java
===================================================================
---
core3/impl/trunk/linkout-impl/src/main/java/org/cytoscape/linkout/internal/CyActivator.java
2012-01-10 20:25:23 UTC (rev 27966)
+++
core3/impl/trunk/linkout-impl/src/main/java/org/cytoscape/linkout/internal/CyActivator.java
2012-01-10 20:47:14 UTC (rev 27967)
@@ -28,7 +28,7 @@
OpenBrowser openBrowserServiceRef =
getService(bc,OpenBrowser.class);
CyServiceRegistrar cyServiceRegistrarServiceRef =
getService(bc,CyServiceRegistrar.class);
CyApplicationConfiguration cyApplicationConfigurationServiceRef
= getService(bc,CyApplicationConfiguration.class);
- PropsReader linkoutProps = new
PropsReader("linkout.props",CyProperty.SavePolicy.CONFIG_DIR);
+ PropsReader linkoutProps = new
PropsReader("linkout","linkout.props",CyProperty.SavePolicy.CONFIG_DIR);
LinkOut linkout = new
LinkOut(linkoutProps,cyServiceRegistrarServiceRef,openBrowserServiceRef,cyApplicationConfigurationServiceRef);
Modified:
core3/impl/trunk/linkout-impl/src/main/java/org/cytoscape/linkout/internal/PropsReader.java
===================================================================
---
core3/impl/trunk/linkout-impl/src/main/java/org/cytoscape/linkout/internal/PropsReader.java
2012-01-10 20:25:23 UTC (rev 27966)
+++
core3/impl/trunk/linkout-impl/src/main/java/org/cytoscape/linkout/internal/PropsReader.java
2012-01-10 20:47:14 UTC (rev 27967)
@@ -1,12 +1,11 @@
-
package org.cytoscape.linkout.internal;
import org.cytoscape.property.AbstractConfigDirPropsReader;
-import org.cytoscape.property.CyProperty;
public class PropsReader extends AbstractConfigDirPropsReader {
- PropsReader(String s, SavePolicy sp) {
- super(s,sp);
+
+ PropsReader(String name, String fileName, SavePolicy sp) {
+ super(name, fileName, sp);
}
}
Modified:
core3/impl/trunk/property-impl/src/main/java/org/cytoscape/property/internal/CyActivator.java
===================================================================
---
core3/impl/trunk/property-impl/src/main/java/org/cytoscape/property/internal/CyActivator.java
2012-01-10 20:25:23 UTC (rev 27966)
+++
core3/impl/trunk/property-impl/src/main/java/org/cytoscape/property/internal/CyActivator.java
2012-01-10 20:47:14 UTC (rev 27967)
@@ -5,6 +5,7 @@
import org.cytoscape.property.internal.PropsReader;
import org.cytoscape.property.internal.bookmark.BookmarkReader;
import org.cytoscape.property.CyProperty;
+import org.cytoscape.property.SimpleCyProperty;
import org.cytoscape.session.events.SessionLoadedListener;
import org.cytoscape.property.bookmark.BookmarksUtil;
import org.osgi.framework.BundleContext;
@@ -19,7 +20,7 @@
public void start(BundleContext bc) {
- BookmarkReader bookmarksReader = new
BookmarkReader("bookmarks.xml");
+ BookmarkReader bookmarksReader = new
BookmarkReader("bookmarks","bookmarks.xml");
BookmarksUtilImpl bookmarksUtil = new BookmarksUtilImpl();
Properties bookmarksReaderProps = new Properties();
@@ -32,7 +33,7 @@
bookmarksUtilProps.setProperty("serviceType","property.util");
registerService(bc,bookmarksUtil,BookmarksUtil.class,
bookmarksUtilProps);
- PropsReader cyApplicationCoreProperty = new
PropsReader("cytoscape3.props");
+ PropsReader cyApplicationCoreProperty = new
PropsReader(SimpleCyProperty.CORE_PROPRERTY_NAME,"cytoscape3.props");
Properties cyApplicationCorePropertyProps = new Properties();
cyApplicationCorePropertyProps.setProperty("cyPropertyName","cytoscape3.props");
cyApplicationCorePropertyProps.setProperty("serviceType","property");
Modified:
core3/impl/trunk/property-impl/src/main/java/org/cytoscape/property/internal/PropsReader.java
===================================================================
---
core3/impl/trunk/property-impl/src/main/java/org/cytoscape/property/internal/PropsReader.java
2012-01-10 20:25:23 UTC (rev 27966)
+++
core3/impl/trunk/property-impl/src/main/java/org/cytoscape/property/internal/PropsReader.java
2012-01-10 20:47:14 UTC (rev 27967)
@@ -1,53 +1,20 @@
package org.cytoscape.property.internal;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.util.Properties;
-
-import org.cytoscape.property.CyProperty;
import org.cytoscape.property.AbstractConfigDirPropsReader;
-import org.cytoscape.session.CySession;
-import org.cytoscape.session.events.SessionLoadedEvent;
-import org.cytoscape.session.events.SessionLoadedListener;
-import static org.cytoscape.application.CyApplicationConfiguration.*;
+import org.cytoscape.property.CyProperty;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class PropsReader extends AbstractConfigDirPropsReader
- implements SessionLoadedListener {
+public class PropsReader extends AbstractConfigDirPropsReader {
private static final Logger logger =
LoggerFactory.getLogger(PropsReader.class);
/**
* Creates a new PropsReader object.
*/
- public PropsReader(String propsName) {
- super(propsName,CyProperty.SavePolicy.CONFIG_DIR);
+ public PropsReader(String name, String fileName) {
+ super(name, fileName, CyProperty.SavePolicy.CONFIG_DIR);
}
-
- @Override
- public void handleEvent(SessionLoadedEvent e) {
- // TODO: should not worry about session related props, since
the save policy is CONFIG_DIR (?)
-// logger.debug("Updating Properties from loaded session...");
-//
-// Properties newProps = null;
-// CySession sess = e.getLoadedSession();
-//
-// if (sess != null)
-// newProps = sess.getProperties();
-// 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();
-// }
-//
-// props.clear();
-// props.putAll(newProps);
- }
}
Modified:
core3/impl/trunk/property-impl/src/main/java/org/cytoscape/property/internal/bookmark/BookmarkReader.java
===================================================================
---
core3/impl/trunk/property-impl/src/main/java/org/cytoscape/property/internal/bookmark/BookmarkReader.java
2012-01-10 20:25:23 UTC (rev 27966)
+++
core3/impl/trunk/property-impl/src/main/java/org/cytoscape/property/internal/bookmark/BookmarkReader.java
2012-01-10 20:47:14 UTC (rev 27967)
@@ -20,25 +20,28 @@
private static final String BOOKMARK_PACKAGE =
Bookmarks.class.getPackage().getName();
private static final Logger logger =
LoggerFactory.getLogger(BookmarkReader.class);
+ private String name;
private Bookmarks bookmarks;
/**
* Creates a new BookmarkReader object.
*/
- public BookmarkReader(String resourceLocation) {
+ public BookmarkReader(final String name, final String resourceLocation)
{
+ if ( name == null )
+ throw new NullPointerException("name is null");
+ if ( resourceLocation == null )
+ throw new NullPointerException("resourceLocation is
null");
+
InputStream is = null;
try {
- if ( resourceLocation == null )
- throw new
NullPointerException("resourceLocation is null");
-
is =
this.getClass().getClassLoader().getResourceAsStream(resourceLocation);
if (is == null)
throw new IllegalArgumentException("Failed to
open resource: " + resourceLocation);
- final JAXBContext jaxbContext =
JAXBContext.newInstance(BOOKMARK_PACKAGE,getClass().getClassLoader());
+ final JAXBContext jaxbContext =
JAXBContext.newInstance(BOOKMARK_PACKAGE, getClass().getClassLoader());
final Unmarshaller unmarshaller =
jaxbContext.createUnmarshaller();
@@ -55,6 +58,11 @@
}
@Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
public Bookmarks getProperties() {
return bookmarks;
}
Modified:
core3/impl/trunk/session-impl/src/main/java/org/cytoscape/session/internal/CySessionManagerImpl.java
===================================================================
---
core3/impl/trunk/session-impl/src/main/java/org/cytoscape/session/internal/CySessionManagerImpl.java
2012-01-10 20:25:23 UTC (rev 27966)
+++
core3/impl/trunk/session-impl/src/main/java/org/cytoscape/session/internal/CySessionManagerImpl.java
2012-01-10 20:47:14 UTC (rev 27967)
@@ -57,7 +57,6 @@
import org.cytoscape.model.subnetwork.CyRootNetwork;
import org.cytoscape.model.subnetwork.CyRootNetworkManager;
import org.cytoscape.property.CyProperty;
-import org.cytoscape.property.SimpleCyProperty;
import org.cytoscape.property.bookmark.Bookmarks;
import org.cytoscape.property.session.Cysession;
import org.cytoscape.property.session.Desktop;
@@ -94,7 +93,7 @@
private final CyRootNetworkManager rootNetMgr;
private final CyServiceRegistrar registrar;
- private final Map<CyProperty<?>, Map<String, String>> sessionProperties;
+ private final Set<CyProperty<?>> sessionProperties;
private static final Logger logger =
LoggerFactory.getLogger(CySessionManagerImpl.class);
@@ -114,7 +113,7 @@
this.nvMgr = nvMgr;
this.rootNetMgr = rootNetMgr;
this.registrar = registrar;
- sessionProperties = new HashMap<CyProperty<?>, Map<String,
String>>();
+ this.sessionProperties = new HashSet<CyProperty<?>>();
}
@Override
@@ -147,7 +146,7 @@
Map<String, List<File>> appMap =
savingEvent.getAppFileListMap();
Set<CyTable> tables = tblMgr.getAllTables(true);
Set<VisualStyle> styles = vmMgr.getAllVisualStyles();
- Map<String, Properties> props = getProperties();
+ Set<CyProperty<Properties>> props = getProperties();
Bookmarks bkmarks = getBookmarks();
Set<CyTableMetadata> metadata = buildMetadata(tables, networks);
@@ -249,7 +248,7 @@
// Cysession info
Cysession cysess = new CysessionFactory(netMgr, nvMgr,
vmMgr).createDefaultCysession();
- Map<String, Properties> props = getProperties();
+ Set<CyProperty<Properties>> props = getProperties();
Bookmarks bkmarks = getBookmarks();
sess = new
CySession.Builder().properties(props).bookmarks(bkmarks).cysession(cysess).visualStyles(styles)
@@ -289,7 +288,7 @@
CyProperty.SavePolicy sp = newCyProperty.getSavePolicy();
if (sp == CyProperty.SavePolicy.SESSION_FILE || sp ==
CyProperty.SavePolicy.SESSION_FILE_AND_CONFIG_DIR)
- sessionProperties.put(newCyProperty, properties);
+ sessionProperties.add(newCyProperty);
}
public void removeCyProperty(final CyProperty<?> oldCyProperty, final
Map<String, String> properties) {
@@ -302,7 +301,7 @@
private Bookmarks getBookmarks() {
Bookmarks bookmarks = null;
- for (CyProperty<?> cyProps : sessionProperties.keySet()) {
+ for (CyProperty<?> cyProps : sessionProperties) {
if (cyProps.getProperties() instanceof Bookmarks) {
bookmarks = (Bookmarks) cyProps.getProperties();
break;
@@ -312,33 +311,25 @@
return bookmarks;
}
- /**
- * @return Map of session Properties by property name.
- */
- private Map<String/*property name*/, Properties> getProperties() {
- Map<String, Properties> map = new HashMap<String, Properties>();
+ @SuppressWarnings("unchecked")
+ private Set<CyProperty<Properties>> getProperties() {
+ Set<CyProperty<Properties>> set = new
HashSet<CyProperty<Properties>>();
- for (Entry<CyProperty<?>, Map<String, String>> entry :
sessionProperties.entrySet()) {
- CyProperty<?> cyProps = entry.getKey();
- Map<String, String> metadata = entry.getValue();
-
+ for (CyProperty<?> cyProps : sessionProperties) {
if (cyProps.getProperties() instanceof Properties) {
- map.put(metadata.get("cyPropertyName"),
(Properties) cyProps.getProperties());
+ set.add((CyProperty<Properties>) cyProps);
}
}
- return map;
+ return set;
}
private void restoreProperties(CySession sess) {
- final Map<String, Properties> sessionPropsMap =
sess.getProperties();
+ final Set<CyProperty<Properties>> set = sess.getProperties();
- for (Entry<String, Properties> entry :
sessionPropsMap.entrySet()) {
- final Properties props = entry.getValue();
- CyProperty<Properties> cyProps = new
SimpleCyProperty(props, CyProperty.SavePolicy.SESSION_FILE);
-
+ for (CyProperty<Properties> cyProps : set) {
final Properties serviceProps = new Properties();
- serviceProps.setProperty("cyPropertyName",
entry.getKey());
+ serviceProps.setProperty("cyPropertyName",
cyProps.getName());
serviceProps.setProperty("serviceType", "property");
registrar.registerAllServices(cyProps, serviceProps);
@@ -438,9 +429,9 @@
tblMgr.reset();
// Unregister session properties
- final Set<CyProperty<?>> cyPropsSet = new
HashSet<CyProperty<?>>(sessionProperties.keySet());
+ final Set<CyProperty<?>> cyPropsClone = new
HashSet<CyProperty<?>>(sessionProperties);
- for (CyProperty<?> cyProps : cyPropsSet) {
+ for (CyProperty<?> cyProps : cyPropsClone) {
if
(cyProps.getSavePolicy().equals(CyProperty.SavePolicy.SESSION_FILE)) {
registrar.unregisterAllServices(cyProps);
}
Modified:
core3/impl/trunk/swing-application-impl/src/main/java/org/cytoscape/internal/actions/PreferenceAction.java
===================================================================
---
core3/impl/trunk/swing-application-impl/src/main/java/org/cytoscape/internal/actions/PreferenceAction.java
2012-01-10 20:25:23 UTC (rev 27966)
+++
core3/impl/trunk/swing-application-impl/src/main/java/org/cytoscape/internal/actions/PreferenceAction.java
2012-01-10 20:47:14 UTC (rev 27967)
@@ -81,43 +81,32 @@
setMenuGravity(10.0f);
}
- /**
- * DOCUMENT ME!
- *
- * @param e DOCUMENT ME!
- */
+ @Override
public void actionPerformed(ActionEvent e) {
preferencesDialog =
pdf.getPreferencesDialog(desktop.getJFrame(), propMap, bookmarkMap, bkUtil);
preferencesDialog.setVisible(true);
}
- //
public void addCyProperty(CyProperty<?> p, Dictionary d){
-
- String propertyName = (String) d.get("cyPropertyName");
-
+ String propertyName = p.getName();
Object obj = p.getProperties();
if (obj instanceof Properties){
propMap.put(propertyName, (Properties)obj);
- }
- else if (obj instanceof Bookmarks){
+ } else if (obj instanceof Bookmarks){
bookmarkMap.put(propertyName, (Bookmarks)obj);
- }
- else {
+ } else {
System.out.println("PreferenceAction: Do not know what
kind of properties it is!");
}
}
public void removeCyProperty(CyProperty<?> p, Dictionary d){
-
String propertyName = (String) d.get("cyPropertyName");
-
Object obj = p.getProperties();
+
if (obj instanceof Properties){
propMap.remove(propertyName);
- }
- else if (obj instanceof Bookmarks){
+ } else if (obj instanceof Bookmarks){
bookmarkMap.remove(propertyName);
}
}
--
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.