mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-05 23:35:48 +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:
|
* Contributors:
|
||||||
* Martin Oberhuber (Wind River) - Added Javadoc.
|
* 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;
|
package org.eclipse.rse.core.model;
|
||||||
|
@ -31,7 +32,7 @@ import java.util.Map;
|
||||||
* The key <code>"description"</code> is reserved for internal
|
* The key <code>"description"</code> is reserved for internal
|
||||||
* use, to store the description of the Property set.
|
* 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.
|
* The key used to store the description of the Property Set.
|
||||||
* This is no longer used and should not be referenced except for
|
* This is no longer used and should not be referenced except for
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Martin Oberhuber (Wind River) - Added Javadoc.
|
* 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;
|
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 since the underlying {@link java.util.HashMap} is
|
||||||
* not thread-safe.
|
* 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 _name;
|
||||||
private String _label = null;
|
private String _label = null;
|
||||||
|
@ -204,4 +205,5 @@ public class PropertySet extends RSEPersistableObject implements IPropertySet, I
|
||||||
public void update(Observable o, Object arg) {
|
public void update(Observable o, Object arg) {
|
||||||
setDirty(true);
|
setDirty(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
* Martin Oberhuber (Wind River) - [184095] Replace systemTypeName by IRSESystemType
|
* Martin Oberhuber (Wind River) - [184095] Replace systemTypeName by IRSESystemType
|
||||||
* Kevin Doyle (IBM) - [163883] Multiple filter strings are disabled
|
* Kevin Doyle (IBM) - [163883] Multiple filter strings are disabled
|
||||||
* Kevin Doyle (IBM) - [197199] Renaming a Profile doesn't cause a save
|
* 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;
|
package org.eclipse.rse.internal.persistence.dom;
|
||||||
|
@ -182,6 +183,10 @@ public class RSEDOMExporter implements IRSEDOMExporter {
|
||||||
|
|
||||||
}
|
}
|
||||||
result[i] = propertySetNode;
|
result[i] = propertySetNode;
|
||||||
|
// persist nested property sets of property set
|
||||||
|
if (set instanceof IRSEModelObject){
|
||||||
|
createPropertySetNodes(propertySetNode, (IRSEModelObject)set, clean);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
* Martin Oberhuber (Wind River) - [175680] Deprecate obsolete ISystemRegistry methods
|
* Martin Oberhuber (Wind River) - [175680] Deprecate obsolete ISystemRegistry methods
|
||||||
* Kevin Doyle (IBM) - [163883] Multiple filter strings are disabled
|
* Kevin Doyle (IBM) - [163883] Multiple filter strings are disabled
|
||||||
* Martin Oberhuber (Wind River) - [202416] Protect against NPEs when importing DOM
|
* 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;
|
package org.eclipse.rse.internal.persistence.dom;
|
||||||
|
@ -505,16 +506,24 @@ public class RSEDOMImporter {
|
||||||
}
|
}
|
||||||
// properties are now stored as children, get those next
|
// properties are now stored as children, get those next
|
||||||
RSEDOMNode[] children = propertySetNode.getChildren();
|
RSEDOMNode[] children = propertySetNode.getChildren();
|
||||||
for (int i = 0; i < children.length; i++) {
|
for (int i = 0; i < children.length; i++) {
|
||||||
RSEDOMNode child = children[i];
|
RSEDOMNode child = children[i];
|
||||||
String propertyName = child.getName();
|
|
||||||
String propertyValue = getAttributeValue(child, IRSEDOMConstants.ATTRIBUTE_VALUE);
|
// is this a property set or a property?
|
||||||
String propertyTypeName = getAttributeValue(child, IRSEDOMConstants.ATTRIBUTE_TYPE);
|
String type = child.getType();
|
||||||
IPropertyType propertyType = PropertyType.fromString(propertyTypeName);
|
if (set instanceof IRSEModelObject && type.equals(IRSEDOMConstants.TYPE_PROPERTY_SET)){
|
||||||
if (IPropertySet.DESCRIPTION_KEY.equals(propertyName)) { // any descriptions found as properties should be set directly
|
restorePropertySet((IRSEModelObject)set, child);
|
||||||
set.setDescription(propertyValue);
|
}
|
||||||
} else {
|
else {
|
||||||
set.addProperty(propertyName, propertyValue, propertyType);
|
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;
|
return set;
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
* Martin Oberhuber (Wind River) - [184095] Replace systemTypeName by IRSESystemType
|
* Martin Oberhuber (Wind River) - [184095] Replace systemTypeName by IRSESystemType
|
||||||
* Martin Oberhuber (Wind River) - [177523] Unify singleton getter methods
|
* Martin Oberhuber (Wind River) - [177523] Unify singleton getter methods
|
||||||
* Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry
|
* 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;
|
package org.eclipse.rse.tests.persistence;
|
||||||
|
@ -135,6 +136,13 @@ public class PersistenceTest extends RSECoreTestCase {
|
||||||
bogusProperties.addProperty("bp1", "1");
|
bogusProperties.addProperty("bp1", "1");
|
||||||
bogusProperties.addProperty("bp2", "2");
|
bogusProperties.addProperty("bp2", "2");
|
||||||
bogus.addPropertySet(bogusProperties);
|
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();
|
bogus.commit();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -157,6 +165,11 @@ public class PersistenceTest extends RSECoreTestCase {
|
||||||
assertEquals("1", bogusProperties.getProperty("bp1").getValue());
|
assertEquals("1", bogusProperties.getProperty("bp1").getValue());
|
||||||
assertEquals("2", bogusProperties.getProperty("bp2").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 {
|
try {
|
||||||
registry.deleteSystemProfile(bogus);
|
registry.deleteSystemProfile(bogus);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue