mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-03 14:25:37 +02:00
[217715] [api] RSE property sets should support nested property sets
This commit is contained in:
parent
f52890cf85
commit
891be3307b
5 changed files with 41 additions and 11 deletions
|
@ -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 <code>"description"</code> 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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Add table
Reference in a new issue