diff --git a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/model/IPropertySet.java b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/model/IPropertySet.java index b2e1e37d77c..fd596da03e9 100644 --- a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/model/IPropertySet.java +++ b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/model/IPropertySet.java @@ -13,6 +13,7 @@ * * Contributors: * Martin Oberhuber (Wind River) - Added Javadoc. + * David McKnight (IBM) - [217715] [api] RSE property sets should support nested property sets *******************************************************************************/ package org.eclipse.rse.core.model; @@ -31,7 +32,7 @@ import java.util.Map; * The key "description" is reserved for internal * use, to store the description of the Property set. */ -public interface IPropertySet { +public interface IPropertySet extends IPropertySetContainer { /** * The key used to store the description of the Property Set. * This is no longer used and should not be referenced except for diff --git a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/model/PropertySet.java b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/model/PropertySet.java index 6dba0224a74..dea4ff809eb 100644 --- a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/model/PropertySet.java +++ b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/model/PropertySet.java @@ -13,6 +13,7 @@ * * Contributors: * Martin Oberhuber (Wind River) - Added Javadoc. + * David McKnight (IBM) - [217715] [api] RSE property sets should support nested property sets *******************************************************************************/ package org.eclipse.rse.core.model; @@ -30,7 +31,7 @@ import java.util.Set; * Not thread-safe since the underlying {@link java.util.HashMap} is * not thread-safe. */ -public class PropertySet extends RSEPersistableObject implements IPropertySet, ILabeledObject, Observer { +public class PropertySet extends RSEModelObject implements IPropertySet, IRSEModelObject, ILabeledObject, Observer { private String _name; private String _label = null; @@ -204,4 +205,5 @@ public class PropertySet extends RSEPersistableObject implements IPropertySet, I public void update(Observable o, Object arg) { setDirty(true); } + } diff --git a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/internal/persistence/dom/RSEDOMExporter.java b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/internal/persistence/dom/RSEDOMExporter.java index 826dda9f6a0..9b456f8f88d 100644 --- a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/internal/persistence/dom/RSEDOMExporter.java +++ b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/internal/persistence/dom/RSEDOMExporter.java @@ -15,6 +15,7 @@ * Martin Oberhuber (Wind River) - [184095] Replace systemTypeName by IRSESystemType * Kevin Doyle (IBM) - [163883] Multiple filter strings are disabled * Kevin Doyle (IBM) - [197199] Renaming a Profile doesn't cause a save + * David McKnight (IBM) - [217715] [api] RSE property sets should support nested property sets ********************************************************************************/ package org.eclipse.rse.internal.persistence.dom; @@ -182,6 +183,10 @@ public class RSEDOMExporter implements IRSEDOMExporter { } result[i] = propertySetNode; + // persist nested property sets of property set + if (set instanceof IRSEModelObject){ + createPropertySetNodes(propertySetNode, (IRSEModelObject)set, clean); + } } return result; } diff --git a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/internal/persistence/dom/RSEDOMImporter.java b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/internal/persistence/dom/RSEDOMImporter.java index 6c7b6f9aed8..74a5bb89396 100644 --- a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/internal/persistence/dom/RSEDOMImporter.java +++ b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/internal/persistence/dom/RSEDOMImporter.java @@ -16,6 +16,7 @@ * Martin Oberhuber (Wind River) - [175680] Deprecate obsolete ISystemRegistry methods * Kevin Doyle (IBM) - [163883] Multiple filter strings are disabled * Martin Oberhuber (Wind River) - [202416] Protect against NPEs when importing DOM + * David McKnight (IBM) - [217715] [api] RSE property sets should support nested property sets ********************************************************************************/ package org.eclipse.rse.internal.persistence.dom; @@ -505,16 +506,24 @@ public class RSEDOMImporter { } // properties are now stored as children, get those next RSEDOMNode[] children = propertySetNode.getChildren(); - for (int i = 0; i < children.length; i++) { + for (int i = 0; i < children.length; i++) { RSEDOMNode child = children[i]; - String propertyName = child.getName(); - String propertyValue = getAttributeValue(child, IRSEDOMConstants.ATTRIBUTE_VALUE); - String propertyTypeName = getAttributeValue(child, IRSEDOMConstants.ATTRIBUTE_TYPE); - IPropertyType propertyType = PropertyType.fromString(propertyTypeName); - if (IPropertySet.DESCRIPTION_KEY.equals(propertyName)) { // any descriptions found as properties should be set directly - set.setDescription(propertyValue); - } else { - set.addProperty(propertyName, propertyValue, propertyType); + + // is this a property set or a property? + String type = child.getType(); + if (set instanceof IRSEModelObject && type.equals(IRSEDOMConstants.TYPE_PROPERTY_SET)){ + restorePropertySet((IRSEModelObject)set, child); + } + else { + String propertyName = child.getName(); + String propertyValue = getAttributeValue(child, IRSEDOMConstants.ATTRIBUTE_VALUE); + String propertyTypeName = getAttributeValue(child, IRSEDOMConstants.ATTRIBUTE_TYPE); + IPropertyType propertyType = PropertyType.fromString(propertyTypeName); + if (IPropertySet.DESCRIPTION_KEY.equals(propertyName)) { // any descriptions found as properties should be set directly + set.setDescription(propertyValue); + } else { + set.addProperty(propertyName, propertyValue, propertyType); + } } } return set; diff --git a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/persistence/PersistenceTest.java b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/persistence/PersistenceTest.java index fa6e0b70b9a..4d25e2de449 100644 --- a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/persistence/PersistenceTest.java +++ b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/persistence/PersistenceTest.java @@ -9,6 +9,7 @@ * Martin Oberhuber (Wind River) - [184095] Replace systemTypeName by IRSESystemType * Martin Oberhuber (Wind River) - [177523] Unify singleton getter methods * Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry + * David McKnight (IBM) - [217715] [api] RSE property sets should support nested property sets ********************************************************************************/ package org.eclipse.rse.tests.persistence; @@ -135,6 +136,13 @@ public class PersistenceTest extends RSECoreTestCase { bogusProperties.addProperty("bp1", "1"); bogusProperties.addProperty("bp2", "2"); bogus.addPropertySet(bogusProperties); + + // nested property set + IPropertySet bogusNestedProperties = new PropertySet("bogus_nested_properties"); + bogusNestedProperties.addProperty("bnpa", "a"); + bogusNestedProperties.addProperty("bnpb", "b"); + bogusProperties.addPropertySet(bogusNestedProperties); + bogus.commit(); /* @@ -157,6 +165,11 @@ public class PersistenceTest extends RSECoreTestCase { assertEquals("1", bogusProperties.getProperty("bp1").getValue()); assertEquals("2", bogusProperties.getProperty("bp2").getValue()); + bogusNestedProperties = bogusProperties.getPropertySet("bogus_nested_properties"); + assertNotNull(bogusNestedProperties); + assertEquals("a", bogusNestedProperties.getProperty("bnpa").getValue()); + assertEquals("b", bogusNestedProperties.getProperty("bnpb").getValue()); + try { registry.deleteSystemProfile(bogus); } catch (Exception e) {