diff options
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.releng.preferences/src/org')
12 files changed, 3095 insertions, 0 deletions
diff --git a/plugins/org.eclipse.emf.cdo.releng.preferences/src/org/eclipse/emf/cdo/releng/preferences/PreferenceNode.java b/plugins/org.eclipse.emf.cdo.releng.preferences/src/org/eclipse/emf/cdo/releng/preferences/PreferenceNode.java new file mode 100644 index 0000000000..35c5597b3c --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.releng.preferences/src/org/eclipse/emf/cdo/releng/preferences/PreferenceNode.java @@ -0,0 +1,152 @@ +/** + */ +package org.eclipse.emf.cdo.releng.preferences; + +import org.eclipse.emf.common.util.EList; + +import org.eclipse.emf.ecore.EObject; + +/** + * <!-- begin-user-doc --> + * A representation of the model object '<em><b>Preference Node</b></em>'. + * <!-- end-user-doc --> + * + * <p> + * The following features are supported: + * <ul> + * <li>{@link org.eclipse.emf.cdo.releng.preferences.PreferenceNode#getChildren <em>Children</em>}</li> + * <li>{@link org.eclipse.emf.cdo.releng.preferences.PreferenceNode#getParent <em>Parent</em>}</li> + * <li>{@link org.eclipse.emf.cdo.releng.preferences.PreferenceNode#getProperties <em>Properties</em>}</li> + * <li>{@link org.eclipse.emf.cdo.releng.preferences.PreferenceNode#getName <em>Name</em>}</li> + * <li>{@link org.eclipse.emf.cdo.releng.preferences.PreferenceNode#getLocation <em>Location</em>}</li> + * </ul> + * </p> + * + * @see org.eclipse.emf.cdo.releng.preferences.PreferencesPackage#getPreferenceNode() + * @model + * @generated + */ +public interface PreferenceNode extends EObject +{ + /** + * Returns the value of the '<em><b>Children</b></em>' containment reference list. + * The list contents are of type {@link org.eclipse.emf.cdo.releng.preferences.PreferenceNode}. + * It is bidirectional and its opposite is '{@link org.eclipse.emf.cdo.releng.preferences.PreferenceNode#getParent <em>Parent</em>}'. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Children</em>' containment reference list isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Children</em>' containment reference list. + * @see org.eclipse.emf.cdo.releng.preferences.PreferencesPackage#getPreferenceNode_Children() + * @see org.eclipse.emf.cdo.releng.preferences.PreferenceNode#getParent + * @model opposite="parent" containment="true" keys="name" + * @generated + */ + EList<PreferenceNode> getChildren(); + + /** + * Returns the value of the '<em><b>Parent</b></em>' container reference. + * It is bidirectional and its opposite is '{@link org.eclipse.emf.cdo.releng.preferences.PreferenceNode#getChildren <em>Children</em>}'. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Parent</em>' container reference isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Parent</em>' container reference. + * @see #setParent(PreferenceNode) + * @see org.eclipse.emf.cdo.releng.preferences.PreferencesPackage#getPreferenceNode_Parent() + * @see org.eclipse.emf.cdo.releng.preferences.PreferenceNode#getChildren + * @model opposite="children" transient="false" + * @generated + */ + PreferenceNode getParent(); + + /** + * Sets the value of the '{@link org.eclipse.emf.cdo.releng.preferences.PreferenceNode#getParent <em>Parent</em>}' container reference. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @param value the new value of the '<em>Parent</em>' container reference. + * @see #getParent() + * @generated + */ + void setParent(PreferenceNode value); + + /** + * Returns the value of the '<em><b>Properties</b></em>' containment reference list. + * The list contents are of type {@link org.eclipse.emf.cdo.releng.preferences.Property}. + * It is bidirectional and its opposite is '{@link org.eclipse.emf.cdo.releng.preferences.Property#getParent <em>Parent</em>}'. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Properties</em>' containment reference list isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Properties</em>' containment reference list. + * @see org.eclipse.emf.cdo.releng.preferences.PreferencesPackage#getPreferenceNode_Properties() + * @see org.eclipse.emf.cdo.releng.preferences.Property#getParent + * @model opposite="parent" containment="true" keys="name" + * @generated + */ + EList<Property> getProperties(); + + /** + * Returns the value of the '<em><b>Name</b></em>' attribute. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Name</em>' attribute isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Name</em>' attribute. + * @see #setName(String) + * @see org.eclipse.emf.cdo.releng.preferences.PreferencesPackage#getPreferenceNode_Name() + * @model required="true" + * @generated + */ + String getName(); + + /** + * Sets the value of the '{@link org.eclipse.emf.cdo.releng.preferences.PreferenceNode#getName <em>Name</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @param value the new value of the '<em>Name</em>' attribute. + * @see #getName() + * @generated + */ + void setName(String value); + + /** + * Returns the value of the '<em><b>Location</b></em>' attribute. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Location</em>' attribute isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Location</em>' attribute. + * @see org.eclipse.emf.cdo.releng.preferences.PreferencesPackage#getPreferenceNode_Location() + * @model transient="true" changeable="false" volatile="true" derived="true" + * @generated + */ + String getLocation(); + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @model + * @generated + */ + PreferenceNode getNode(String name); + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @model + * @generated + */ + Property getProperty(String name); + +} // PreferenceNode diff --git a/plugins/org.eclipse.emf.cdo.releng.preferences/src/org/eclipse/emf/cdo/releng/preferences/PreferencesFactory.java b/plugins/org.eclipse.emf.cdo.releng.preferences/src/org/eclipse/emf/cdo/releng/preferences/PreferencesFactory.java new file mode 100644 index 0000000000..427a8cb217 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.releng.preferences/src/org/eclipse/emf/cdo/releng/preferences/PreferencesFactory.java @@ -0,0 +1,52 @@ +/** + */ +package org.eclipse.emf.cdo.releng.preferences; + +import org.eclipse.emf.ecore.EFactory; + +/** + * <!-- begin-user-doc --> + * The <b>Factory</b> for the model. + * It provides a create method for each non-abstract class of the model. + * <!-- end-user-doc --> + * @see org.eclipse.emf.cdo.releng.preferences.PreferencesPackage + * @generated + */ +public interface PreferencesFactory extends EFactory +{ + /** + * The singleton instance of the factory. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + PreferencesFactory eINSTANCE = org.eclipse.emf.cdo.releng.preferences.impl.PreferencesFactoryImpl.init(); + + /** + * Returns a new object of class '<em>Preference Node</em>'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return a new object of class '<em>Preference Node</em>'. + * @generated + */ + PreferenceNode createPreferenceNode(); + + /** + * Returns a new object of class '<em>Property</em>'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return a new object of class '<em>Property</em>'. + * @generated + */ + Property createProperty(); + + /** + * Returns the package supported by this factory. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the package supported by this factory. + * @generated + */ + PreferencesPackage getPreferencesPackage(); + +} //PreferencesFactory diff --git a/plugins/org.eclipse.emf.cdo.releng.preferences/src/org/eclipse/emf/cdo/releng/preferences/PreferencesPackage.java b/plugins/org.eclipse.emf.cdo.releng.preferences/src/org/eclipse/emf/cdo/releng/preferences/PreferencesPackage.java new file mode 100644 index 0000000000..d8b8bf4ece --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.releng.preferences/src/org/eclipse/emf/cdo/releng/preferences/PreferencesPackage.java @@ -0,0 +1,495 @@ +/** + */ +package org.eclipse.emf.cdo.releng.preferences; + +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EDataType; +import org.eclipse.emf.ecore.EOperation; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.EReference; + +/** + * <!-- begin-user-doc --> + * The <b>Package</b> for the model. + * It contains accessors for the meta objects to represent + * <ul> + * <li>each class,</li> + * <li>each feature of each class,</li> + * <li>each operation of each class,</li> + * <li>each enum,</li> + * <li>and each data type</li> + * </ul> + * <!-- end-user-doc --> + * @see org.eclipse.emf.cdo.releng.preferences.PreferencesFactory + * @model kind="package" + * @generated + */ +public interface PreferencesPackage extends EPackage +{ + /** + * The package name. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + String eNAME = "preferences"; + + /** + * The package namespace URI. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + String eNS_URI = "http://www.eclipse.org/CDO/releng/preferences/1.0"; + + /** + * The package namespace name. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + String eNS_PREFIX = "preferences"; + + /** + * The singleton instance of the package. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + PreferencesPackage eINSTANCE = org.eclipse.emf.cdo.releng.preferences.impl.PreferencesPackageImpl.init(); + + /** + * The meta object id for the '{@link org.eclipse.emf.cdo.releng.preferences.impl.PreferenceNodeImpl <em>Preference Node</em>}' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see org.eclipse.emf.cdo.releng.preferences.impl.PreferenceNodeImpl + * @see org.eclipse.emf.cdo.releng.preferences.impl.PreferencesPackageImpl#getPreferenceNode() + * @generated + */ + int PREFERENCE_NODE = 0; + + /** + * The feature id for the '<em><b>Children</b></em>' containment reference list. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int PREFERENCE_NODE__CHILDREN = 0; + + /** + * The feature id for the '<em><b>Parent</b></em>' container reference. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int PREFERENCE_NODE__PARENT = 1; + + /** + * The feature id for the '<em><b>Properties</b></em>' containment reference list. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int PREFERENCE_NODE__PROPERTIES = 2; + + /** + * The feature id for the '<em><b>Name</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int PREFERENCE_NODE__NAME = 3; + + /** + * The feature id for the '<em><b>Location</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int PREFERENCE_NODE__LOCATION = 4; + + /** + * The number of structural features of the '<em>Preference Node</em>' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int PREFERENCE_NODE_FEATURE_COUNT = 5; + + /** + * The operation id for the '<em>Get Node</em>' operation. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int PREFERENCE_NODE___GET_NODE__STRING = 0; + + /** + * The operation id for the '<em>Get Property</em>' operation. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int PREFERENCE_NODE___GET_PROPERTY__STRING = 1; + + /** + * The number of operations of the '<em>Preference Node</em>' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int PREFERENCE_NODE_OPERATION_COUNT = 2; + + /** + * The meta object id for the '{@link org.eclipse.emf.cdo.releng.preferences.impl.PropertyImpl <em>Property</em>}' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see org.eclipse.emf.cdo.releng.preferences.impl.PropertyImpl + * @see org.eclipse.emf.cdo.releng.preferences.impl.PreferencesPackageImpl#getProperty() + * @generated + */ + int PROPERTY = 1; + + /** + * The feature id for the '<em><b>Name</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int PROPERTY__NAME = 0; + + /** + * The feature id for the '<em><b>Parent</b></em>' container reference. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int PROPERTY__PARENT = 1; + + /** + * The feature id for the '<em><b>Value</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int PROPERTY__VALUE = 2; + + /** + * The number of structural features of the '<em>Property</em>' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int PROPERTY_FEATURE_COUNT = 3; + + /** + * The number of operations of the '<em>Property</em>' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int PROPERTY_OPERATION_COUNT = 0; + + + /** + * The meta object id for the '<em>Escaped String</em>' data type. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see java.lang.String + * @see org.eclipse.emf.cdo.releng.preferences.impl.PreferencesPackageImpl#getEscapedString() + * @generated + */ + int ESCAPED_STRING = 2; + + + /** + * Returns the meta object for class '{@link org.eclipse.emf.cdo.releng.preferences.PreferenceNode <em>Preference Node</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for class '<em>Preference Node</em>'. + * @see org.eclipse.emf.cdo.releng.preferences.PreferenceNode + * @generated + */ + EClass getPreferenceNode(); + + /** + * Returns the meta object for the containment reference list '{@link org.eclipse.emf.cdo.releng.preferences.PreferenceNode#getChildren <em>Children</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the containment reference list '<em>Children</em>'. + * @see org.eclipse.emf.cdo.releng.preferences.PreferenceNode#getChildren() + * @see #getPreferenceNode() + * @generated + */ + EReference getPreferenceNode_Children(); + + /** + * Returns the meta object for the container reference '{@link org.eclipse.emf.cdo.releng.preferences.PreferenceNode#getParent <em>Parent</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the container reference '<em>Parent</em>'. + * @see org.eclipse.emf.cdo.releng.preferences.PreferenceNode#getParent() + * @see #getPreferenceNode() + * @generated + */ + EReference getPreferenceNode_Parent(); + + /** + * Returns the meta object for the containment reference list '{@link org.eclipse.emf.cdo.releng.preferences.PreferenceNode#getProperties <em>Properties</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the containment reference list '<em>Properties</em>'. + * @see org.eclipse.emf.cdo.releng.preferences.PreferenceNode#getProperties() + * @see #getPreferenceNode() + * @generated + */ + EReference getPreferenceNode_Properties(); + + /** + * Returns the meta object for the attribute '{@link org.eclipse.emf.cdo.releng.preferences.PreferenceNode#getName <em>Name</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the attribute '<em>Name</em>'. + * @see org.eclipse.emf.cdo.releng.preferences.PreferenceNode#getName() + * @see #getPreferenceNode() + * @generated + */ + EAttribute getPreferenceNode_Name(); + + /** + * Returns the meta object for the attribute '{@link org.eclipse.emf.cdo.releng.preferences.PreferenceNode#getLocation <em>Location</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the attribute '<em>Location</em>'. + * @see org.eclipse.emf.cdo.releng.preferences.PreferenceNode#getLocation() + * @see #getPreferenceNode() + * @generated + */ + EAttribute getPreferenceNode_Location(); + + /** + * Returns the meta object for the '{@link org.eclipse.emf.cdo.releng.preferences.PreferenceNode#getNode(java.lang.String) <em>Get Node</em>}' operation. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the '<em>Get Node</em>' operation. + * @see org.eclipse.emf.cdo.releng.preferences.PreferenceNode#getNode(java.lang.String) + * @generated + */ + EOperation getPreferenceNode__GetNode__String(); + + /** + * Returns the meta object for the '{@link org.eclipse.emf.cdo.releng.preferences.PreferenceNode#getProperty(java.lang.String) <em>Get Property</em>}' operation. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the '<em>Get Property</em>' operation. + * @see org.eclipse.emf.cdo.releng.preferences.PreferenceNode#getProperty(java.lang.String) + * @generated + */ + EOperation getPreferenceNode__GetProperty__String(); + + /** + * Returns the meta object for class '{@link org.eclipse.emf.cdo.releng.preferences.Property <em>Property</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for class '<em>Property</em>'. + * @see org.eclipse.emf.cdo.releng.preferences.Property + * @generated + */ + EClass getProperty(); + + /** + * Returns the meta object for the attribute '{@link org.eclipse.emf.cdo.releng.preferences.Property#getName <em>Name</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the attribute '<em>Name</em>'. + * @see org.eclipse.emf.cdo.releng.preferences.Property#getName() + * @see #getProperty() + * @generated + */ + EAttribute getProperty_Name(); + + /** + * Returns the meta object for the container reference '{@link org.eclipse.emf.cdo.releng.preferences.Property#getParent <em>Parent</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the container reference '<em>Parent</em>'. + * @see org.eclipse.emf.cdo.releng.preferences.Property#getParent() + * @see #getProperty() + * @generated + */ + EReference getProperty_Parent(); + + /** + * Returns the meta object for the attribute '{@link org.eclipse.emf.cdo.releng.preferences.Property#getValue <em>Value</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the attribute '<em>Value</em>'. + * @see org.eclipse.emf.cdo.releng.preferences.Property#getValue() + * @see #getProperty() + * @generated + */ + EAttribute getProperty_Value(); + + /** + * Returns the meta object for data type '{@link java.lang.String <em>Escaped String</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for data type '<em>Escaped String</em>'. + * @see java.lang.String + * @model instanceClass="java.lang.String" + * @generated + */ + EDataType getEscapedString(); + + /** + * Returns the factory that creates the instances of the model. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the factory that creates the instances of the model. + * @generated + */ + PreferencesFactory getPreferencesFactory(); + + /** + * <!-- begin-user-doc --> + * Defines literals for the meta objects that represent + * <ul> + * <li>each class,</li> + * <li>each feature of each class,</li> + * <li>each operation of each class,</li> + * <li>each enum,</li> + * <li>and each data type</li> + * </ul> + * <!-- end-user-doc --> + * @generated + */ + interface Literals + { + /** + * The meta object literal for the '{@link org.eclipse.emf.cdo.releng.preferences.impl.PreferenceNodeImpl <em>Preference Node</em>}' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see org.eclipse.emf.cdo.releng.preferences.impl.PreferenceNodeImpl + * @see org.eclipse.emf.cdo.releng.preferences.impl.PreferencesPackageImpl#getPreferenceNode() + * @generated + */ + EClass PREFERENCE_NODE = eINSTANCE.getPreferenceNode(); + + /** + * The meta object literal for the '<em><b>Children</b></em>' containment reference list feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + EReference PREFERENCE_NODE__CHILDREN = eINSTANCE.getPreferenceNode_Children(); + + /** + * The meta object literal for the '<em><b>Parent</b></em>' container reference feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + EReference PREFERENCE_NODE__PARENT = eINSTANCE.getPreferenceNode_Parent(); + + /** + * The meta object literal for the '<em><b>Properties</b></em>' containment reference list feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + EReference PREFERENCE_NODE__PROPERTIES = eINSTANCE.getPreferenceNode_Properties(); + + /** + * The meta object literal for the '<em><b>Name</b></em>' attribute feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + EAttribute PREFERENCE_NODE__NAME = eINSTANCE.getPreferenceNode_Name(); + + /** + * The meta object literal for the '<em><b>Location</b></em>' attribute feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + EAttribute PREFERENCE_NODE__LOCATION = eINSTANCE.getPreferenceNode_Location(); + + /** + * The meta object literal for the '<em><b>Get Node</b></em>' operation. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + EOperation PREFERENCE_NODE___GET_NODE__STRING = eINSTANCE.getPreferenceNode__GetNode__String(); + + /** + * The meta object literal for the '<em><b>Get Property</b></em>' operation. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + EOperation PREFERENCE_NODE___GET_PROPERTY__STRING = eINSTANCE.getPreferenceNode__GetProperty__String(); + + /** + * The meta object literal for the '{@link org.eclipse.emf.cdo.releng.preferences.impl.PropertyImpl <em>Property</em>}' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see org.eclipse.emf.cdo.releng.preferences.impl.PropertyImpl + * @see org.eclipse.emf.cdo.releng.preferences.impl.PreferencesPackageImpl#getProperty() + * @generated + */ + EClass PROPERTY = eINSTANCE.getProperty(); + + /** + * The meta object literal for the '<em><b>Name</b></em>' attribute feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + EAttribute PROPERTY__NAME = eINSTANCE.getProperty_Name(); + + /** + * The meta object literal for the '<em><b>Parent</b></em>' container reference feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + EReference PROPERTY__PARENT = eINSTANCE.getProperty_Parent(); + + /** + * The meta object literal for the '<em><b>Value</b></em>' attribute feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + EAttribute PROPERTY__VALUE = eINSTANCE.getProperty_Value(); + + /** + * The meta object literal for the '<em>Escaped String</em>' data type. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see java.lang.String + * @see org.eclipse.emf.cdo.releng.preferences.impl.PreferencesPackageImpl#getEscapedString() + * @generated + */ + EDataType ESCAPED_STRING = eINSTANCE.getEscapedString(); + + } + +} //PreferencesPackage diff --git a/plugins/org.eclipse.emf.cdo.releng.preferences/src/org/eclipse/emf/cdo/releng/preferences/Property.java b/plugins/org.eclipse.emf.cdo.releng.preferences/src/org/eclipse/emf/cdo/releng/preferences/Property.java new file mode 100644 index 0000000000..2df74423c5 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.releng.preferences/src/org/eclipse/emf/cdo/releng/preferences/Property.java @@ -0,0 +1,107 @@ +/** + */ +package org.eclipse.emf.cdo.releng.preferences; + +import org.eclipse.emf.ecore.EObject; + +/** + * <!-- begin-user-doc --> + * A representation of the model object '<em><b>Property</b></em>'. + * <!-- end-user-doc --> + * + * <p> + * The following features are supported: + * <ul> + * <li>{@link org.eclipse.emf.cdo.releng.preferences.Property#getName <em>Name</em>}</li> + * <li>{@link org.eclipse.emf.cdo.releng.preferences.Property#getParent <em>Parent</em>}</li> + * <li>{@link org.eclipse.emf.cdo.releng.preferences.Property#getValue <em>Value</em>}</li> + * </ul> + * </p> + * + * @see org.eclipse.emf.cdo.releng.preferences.PreferencesPackage#getProperty() + * @model + * @generated + */ +public interface Property extends EObject +{ + /** + * Returns the value of the '<em><b>Name</b></em>' attribute. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Name</em>' attribute isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Name</em>' attribute. + * @see #setName(String) + * @see org.eclipse.emf.cdo.releng.preferences.PreferencesPackage#getProperty_Name() + * @model required="true" + * @generated + */ + String getName(); + + /** + * Sets the value of the '{@link org.eclipse.emf.cdo.releng.preferences.Property#getName <em>Name</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @param value the new value of the '<em>Name</em>' attribute. + * @see #getName() + * @generated + */ + void setName(String value); + + /** + * Returns the value of the '<em><b>Parent</b></em>' container reference. + * It is bidirectional and its opposite is '{@link org.eclipse.emf.cdo.releng.preferences.PreferenceNode#getProperties <em>Properties</em>}'. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Parent</em>' container reference isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Parent</em>' container reference. + * @see #setParent(PreferenceNode) + * @see org.eclipse.emf.cdo.releng.preferences.PreferencesPackage#getProperty_Parent() + * @see org.eclipse.emf.cdo.releng.preferences.PreferenceNode#getProperties + * @model opposite="properties" transient="false" + * @generated + */ + PreferenceNode getParent(); + + /** + * Sets the value of the '{@link org.eclipse.emf.cdo.releng.preferences.Property#getParent <em>Parent</em>}' container reference. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @param value the new value of the '<em>Parent</em>' container reference. + * @see #getParent() + * @generated + */ + void setParent(PreferenceNode value); + + /** + * Returns the value of the '<em><b>Value</b></em>' attribute. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Value</em>' attribute isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Value</em>' attribute. + * @see #setValue(String) + * @see org.eclipse.emf.cdo.releng.preferences.PreferencesPackage#getProperty_Value() + * @model dataType="org.eclipse.emf.cdo.releng.preferences.EscapedString" + * @generated + */ + String getValue(); + + /** + * Sets the value of the '{@link org.eclipse.emf.cdo.releng.preferences.Property#getValue <em>Value</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @param value the new value of the '<em>Value</em>' attribute. + * @see #getValue() + * @generated + */ + void setValue(String value); + +} // Property diff --git a/plugins/org.eclipse.emf.cdo.releng.preferences/src/org/eclipse/emf/cdo/releng/preferences/impl/PreferenceNodeImpl.java b/plugins/org.eclipse.emf.cdo.releng.preferences/src/org/eclipse/emf/cdo/releng/preferences/impl/PreferenceNodeImpl.java new file mode 100644 index 0000000000..92abb11f66 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.releng.preferences/src/org/eclipse/emf/cdo/releng/preferences/impl/PreferenceNodeImpl.java @@ -0,0 +1,543 @@ +/** + */ +package org.eclipse.emf.cdo.releng.preferences.impl; + +import org.eclipse.emf.cdo.releng.preferences.PreferenceNode; +import org.eclipse.emf.cdo.releng.preferences.PreferencesPackage; +import org.eclipse.emf.cdo.releng.preferences.Property; +import org.eclipse.emf.cdo.releng.preferences.util.PreferencesUtil; + +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.notify.NotificationChain; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.ecore.InternalEObject; +import org.eclipse.emf.ecore.impl.ENotificationImpl; +import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; +import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList; +import org.eclipse.emf.ecore.util.EcoreUtil; +import org.eclipse.emf.ecore.util.InternalEList; + +import org.eclipse.core.runtime.IPath; + +import org.osgi.service.prefs.BackingStoreException; +import org.osgi.service.prefs.Preferences; + +import java.lang.reflect.InvocationTargetException; +import java.util.Collection; + +/** + * <!-- begin-user-doc --> + * An implementation of the model object '<em><b>Preference Node</b></em>'. + * <!-- end-user-doc --> + * <p> + * The following features are implemented: + * <ul> + * <li>{@link org.eclipse.emf.cdo.releng.preferences.impl.PreferenceNodeImpl#getChildren <em>Children</em>}</li> + * <li>{@link org.eclipse.emf.cdo.releng.preferences.impl.PreferenceNodeImpl#getParent <em>Parent</em>}</li> + * <li>{@link org.eclipse.emf.cdo.releng.preferences.impl.PreferenceNodeImpl#getProperties <em>Properties</em>}</li> + * <li>{@link org.eclipse.emf.cdo.releng.preferences.impl.PreferenceNodeImpl#getName <em>Name</em>}</li> + * <li>{@link org.eclipse.emf.cdo.releng.preferences.impl.PreferenceNodeImpl#getLocation <em>Location</em>}</li> + * </ul> + * </p> + * + * @generated + */ +public class PreferenceNodeImpl extends MinimalEObjectImpl.Container implements PreferenceNode +{ + /** + * The cached value of the '{@link #getChildren() <em>Children</em>}' containment reference list. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getChildren() + * @generated + * @ordered + */ + protected EList<PreferenceNode> children; + + /** + * The cached value of the '{@link #getProperties() <em>Properties</em>}' containment reference list. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getProperties() + * @generated + * @ordered + */ + protected EList<Property> properties; + + /** + * The default value of the '{@link #getName() <em>Name</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getName() + * @generated + * @ordered + */ + protected static final String NAME_EDEFAULT = null; + + /** + * The cached value of the '{@link #getName() <em>Name</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getName() + * @generated + * @ordered + */ + protected String name = NAME_EDEFAULT; + + /** + * The default value of the '{@link #getLocation() <em>Location</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getLocation() + * @generated + * @ordered + */ + protected static final String LOCATION_EDEFAULT = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected PreferenceNodeImpl() + { + super(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + protected EClass eStaticClass() + { + return PreferencesPackage.Literals.PREFERENCE_NODE; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EList<PreferenceNode> getChildren() + { + if (children == null) + { + children = new EObjectContainmentWithInverseEList<PreferenceNode>(PreferenceNode.class, this, + PreferencesPackage.PREFERENCE_NODE__CHILDREN, PreferencesPackage.PREFERENCE_NODE__PARENT); + } + return children; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public PreferenceNode getParent() + { + if (eContainerFeatureID() != PreferencesPackage.PREFERENCE_NODE__PARENT) + { + return null; + } + return (PreferenceNode)eInternalContainer(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public NotificationChain basicSetParent(PreferenceNode newParent, NotificationChain msgs) + { + msgs = eBasicSetContainer((InternalEObject)newParent, PreferencesPackage.PREFERENCE_NODE__PARENT, msgs); + return msgs; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void setParent(PreferenceNode newParent) + { + if (newParent != eInternalContainer() || eContainerFeatureID() != PreferencesPackage.PREFERENCE_NODE__PARENT + && newParent != null) + { + if (EcoreUtil.isAncestor(this, newParent)) + { + throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); + } + NotificationChain msgs = null; + if (eInternalContainer() != null) + { + msgs = eBasicRemoveFromContainer(msgs); + } + if (newParent != null) + { + msgs = ((InternalEObject)newParent).eInverseAdd(this, PreferencesPackage.PREFERENCE_NODE__CHILDREN, + PreferenceNode.class, msgs); + } + msgs = basicSetParent(newParent, msgs); + if (msgs != null) + { + msgs.dispatch(); + } + } + else if (eNotificationRequired()) + { + eNotify(new ENotificationImpl(this, Notification.SET, PreferencesPackage.PREFERENCE_NODE__PARENT, newParent, + newParent)); + } + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EList<Property> getProperties() + { + if (properties == null) + { + properties = new EObjectContainmentWithInverseEList<Property>(Property.class, this, + PreferencesPackage.PREFERENCE_NODE__PROPERTIES, PreferencesPackage.PROPERTY__PARENT); + } + return properties; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public String getName() + { + return name; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void setName(String newName) + { + String oldName = name; + name = newName; + if (eNotificationRequired()) + { + eNotify(new ENotificationImpl(this, Notification.SET, PreferencesPackage.PREFERENCE_NODE__NAME, oldName, name)); + } + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public String getLocation() + { + try + { + Preferences preferences = PreferencesUtil.getPreferences(this, false); + IPath path = PreferencesUtil.getLocation(preferences); + return path == null ? null : path.toString(); + } + catch (BackingStoreException ex) + { + // Ignore + return null; + } + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public PreferenceNode getNode(String name) + { + for (PreferenceNode node : getChildren()) + { + if (name.equals(node.getName())) + { + return node; + } + } + return null; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public Property getProperty(String name) + { + for (Property property : getProperties()) + { + if (name.equals(property.getName())) + { + return property; + } + } + return null; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @SuppressWarnings("unchecked") + @Override + public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) + { + switch (featureID) + { + case PreferencesPackage.PREFERENCE_NODE__CHILDREN: + return ((InternalEList<InternalEObject>)(InternalEList<?>)getChildren()).basicAdd(otherEnd, msgs); + case PreferencesPackage.PREFERENCE_NODE__PARENT: + if (eInternalContainer() != null) + { + msgs = eBasicRemoveFromContainer(msgs); + } + return basicSetParent((PreferenceNode)otherEnd, msgs); + case PreferencesPackage.PREFERENCE_NODE__PROPERTIES: + return ((InternalEList<InternalEObject>)(InternalEList<?>)getProperties()).basicAdd(otherEnd, msgs); + } + return super.eInverseAdd(otherEnd, featureID, msgs); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) + { + switch (featureID) + { + case PreferencesPackage.PREFERENCE_NODE__CHILDREN: + return ((InternalEList<?>)getChildren()).basicRemove(otherEnd, msgs); + case PreferencesPackage.PREFERENCE_NODE__PARENT: + return basicSetParent(null, msgs); + case PreferencesPackage.PREFERENCE_NODE__PROPERTIES: + return ((InternalEList<?>)getProperties()).basicRemove(otherEnd, msgs); + } + return super.eInverseRemove(otherEnd, featureID, msgs); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) + { + switch (eContainerFeatureID()) + { + case PreferencesPackage.PREFERENCE_NODE__PARENT: + return eInternalContainer().eInverseRemove(this, PreferencesPackage.PREFERENCE_NODE__CHILDREN, + PreferenceNode.class, msgs); + } + return super.eBasicRemoveFromContainerFeature(msgs); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) + { + switch (featureID) + { + case PreferencesPackage.PREFERENCE_NODE__CHILDREN: + return getChildren(); + case PreferencesPackage.PREFERENCE_NODE__PARENT: + return getParent(); + case PreferencesPackage.PREFERENCE_NODE__PROPERTIES: + return getProperties(); + case PreferencesPackage.PREFERENCE_NODE__NAME: + return getName(); + case PreferencesPackage.PREFERENCE_NODE__LOCATION: + return getLocation(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @SuppressWarnings("unchecked") + @Override + public void eSet(int featureID, Object newValue) + { + switch (featureID) + { + case PreferencesPackage.PREFERENCE_NODE__CHILDREN: + getChildren().clear(); + getChildren().addAll((Collection<? extends PreferenceNode>)newValue); + return; + case PreferencesPackage.PREFERENCE_NODE__PARENT: + setParent((PreferenceNode)newValue); + return; + case PreferencesPackage.PREFERENCE_NODE__PROPERTIES: + getProperties().clear(); + getProperties().addAll((Collection<? extends Property>)newValue); + return; + case PreferencesPackage.PREFERENCE_NODE__NAME: + setName((String)newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + public void eUnset(int featureID) + { + switch (featureID) + { + case PreferencesPackage.PREFERENCE_NODE__CHILDREN: + getChildren().clear(); + return; + case PreferencesPackage.PREFERENCE_NODE__PARENT: + setParent((PreferenceNode)null); + return; + case PreferencesPackage.PREFERENCE_NODE__PROPERTIES: + getProperties().clear(); + return; + case PreferencesPackage.PREFERENCE_NODE__NAME: + setName(NAME_EDEFAULT); + return; + } + super.eUnset(featureID); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + public boolean eIsSet(int featureID) + { + switch (featureID) + { + case PreferencesPackage.PREFERENCE_NODE__CHILDREN: + return children != null && !children.isEmpty(); + case PreferencesPackage.PREFERENCE_NODE__PARENT: + return getParent() != null; + case PreferencesPackage.PREFERENCE_NODE__PROPERTIES: + return properties != null && !properties.isEmpty(); + case PreferencesPackage.PREFERENCE_NODE__NAME: + return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name); + case PreferencesPackage.PREFERENCE_NODE__LOCATION: + return LOCATION_EDEFAULT == null ? getLocation() != null : !LOCATION_EDEFAULT.equals(getLocation()); + } + return super.eIsSet(featureID); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + public Object eInvoke(int operationID, EList<?> arguments) throws InvocationTargetException + { + switch (operationID) + { + case PreferencesPackage.PREFERENCE_NODE___GET_NODE__STRING: + return getNode((String)arguments.get(0)); + case PreferencesPackage.PREFERENCE_NODE___GET_PROPERTY__STRING: + return getProperty((String)arguments.get(0)); + } + return super.eInvoke(operationID, arguments); + } + + @Override + public String eURIFragmentSegment(EStructuralFeature eStructuralFeature, EObject eObject) + { + if (eStructuralFeature == PreferencesPackage.Literals.PREFERENCE_NODE__CHILDREN) + { + PreferenceNode child = (PreferenceNode)eObject; + String name = child.getName(); + if (name != null) + { + String encodedName = URI.encodeSegment(name, false); + if (encodedName.startsWith("@")) + { + encodedName = "%40" + encodedName.substring(1); + } + return encodedName; + } + } + + if (eStructuralFeature == PreferencesPackage.Literals.PREFERENCE_NODE__PROPERTIES) + { + Property property = (Property)eObject; + String name = property.getName(); + if (name != null) + { + return "^" + URI.encodeSegment(name, false); + } + } + + return super.eURIFragmentSegment(eStructuralFeature, eObject); + } + + @Override + public EObject eObjectForURIFragmentSegment(String uriFragmentSegment) + { + if (uriFragmentSegment.startsWith("^")) + { + String preferenceNodeName = URI.decode(uriFragmentSegment.substring(1)); + return getProperty(preferenceNodeName); + } + if (!uriFragmentSegment.startsWith("@")) + { + String preferenceNodeName = URI.decode(uriFragmentSegment); + return getNode(preferenceNodeName); + } + return super.eObjectForURIFragmentSegment(uriFragmentSegment); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + public String toString() + { + if (eIsProxy()) + { + return super.toString(); + } + + StringBuffer result = new StringBuffer(super.toString()); + result.append(" (name: "); + result.append(name); + result.append(')'); + return result.toString(); + } + +} // PreferenceNodeImpl diff --git a/plugins/org.eclipse.emf.cdo.releng.preferences/src/org/eclipse/emf/cdo/releng/preferences/impl/PreferencesFactoryImpl.java b/plugins/org.eclipse.emf.cdo.releng.preferences/src/org/eclipse/emf/cdo/releng/preferences/impl/PreferencesFactoryImpl.java new file mode 100644 index 0000000000..73af81b8a4 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.releng.preferences/src/org/eclipse/emf/cdo/releng/preferences/impl/PreferencesFactoryImpl.java @@ -0,0 +1,246 @@ +/** + */ +package org.eclipse.emf.cdo.releng.preferences.impl; + +import org.eclipse.emf.cdo.releng.preferences.PreferenceNode; +import org.eclipse.emf.cdo.releng.preferences.PreferencesFactory; +import org.eclipse.emf.cdo.releng.preferences.PreferencesPackage; +import org.eclipse.emf.cdo.releng.preferences.Property; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EDataType; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.impl.EFactoryImpl; +import org.eclipse.emf.ecore.plugin.EcorePlugin; + +/** + * <!-- begin-user-doc --> + * An implementation of the model <b>Factory</b>. + * <!-- end-user-doc --> + * @generated + */ +public class PreferencesFactoryImpl extends EFactoryImpl implements PreferencesFactory +{ + /** + * Creates the default factory implementation. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static PreferencesFactory init() + { + try + { + PreferencesFactory thePreferencesFactory = (PreferencesFactory)EPackage.Registry.INSTANCE.getEFactory(PreferencesPackage.eNS_URI); + if (thePreferencesFactory != null) + { + return thePreferencesFactory; + } + } + catch (Exception exception) + { + EcorePlugin.INSTANCE.log(exception); + } + return new PreferencesFactoryImpl(); + } + + /** + * Creates an instance of the factory. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public PreferencesFactoryImpl() + { + super(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + public EObject create(EClass eClass) + { + switch (eClass.getClassifierID()) + { + case PreferencesPackage.PREFERENCE_NODE: return createPreferenceNode(); + case PreferencesPackage.PROPERTY: return createProperty(); + default: + throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier"); + } + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + public Object createFromString(EDataType eDataType, String initialValue) + { + switch (eDataType.getClassifierID()) + { + case PreferencesPackage.ESCAPED_STRING: + return createEscapedStringFromString(eDataType, initialValue); + default: + throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier"); + } + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + public String convertToString(EDataType eDataType, Object instanceValue) + { + switch (eDataType.getClassifierID()) + { + case PreferencesPackage.ESCAPED_STRING: + return convertEscapedStringToString(eDataType, instanceValue); + default: + throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier"); + } + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public PreferenceNode createPreferenceNode() + { + PreferenceNodeImpl preferenceNode = new PreferenceNodeImpl(); + return preferenceNode; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public Property createProperty() + { + PropertyImpl property = new PropertyImpl(); + return property; + } + + private static final String[] ESCAPES = { "\\000", "\\001", "\\002", "\\003", "\\004", "\\005", "\\006", "\\007", + "\\010", "\\t", "\\n", "\\013", "\\014", "\\r", "\\016", "\\017", "\\020", "\\021", "\\022", "\\023", "\\024", + "\\025", "\\026", "\\027", "\\030", "\\031", "\\032", "\\033", "\\034", "\\035", "\\036", "\\037" }; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public String createEscapedStringFromString(EDataType eDataType, String initialValue) + { + if (initialValue == null) + { + return null; + } + + StringBuilder result = new StringBuilder(); + for (int i = 0, length = initialValue.length(); i < length; ++i) + { + char c = initialValue.charAt(i); + if (c == '\\') + { + if (++i < length) + { + c = initialValue.charAt(i); + if (c == 't') + { + result.append('\t'); + continue; + } + else if (c == 'r') + { + result.append('\r'); + continue; + } + else if (c == 'n') + { + result.append('\n'); + continue; + } + else if (c == '\\') + { + result.append('\\'); + continue; + } + else if (i + 2 < length && c >= '0' && c <= '7' && initialValue.charAt(i + 1) >= '0' + && initialValue.charAt(i + 1) <= '7' && initialValue.charAt(i + 2) >= '0' + && initialValue.charAt(i + 2) <= '7') + { + result.append((char)Integer.parseInt(initialValue.substring(i, i + 3), 8)); + i += 2; + continue; + } + } + } + result.append(c); + } + return result.toString(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public String convertEscapedStringToString(EDataType eDataType, Object instanceValue) + { + if (instanceValue == null) + { + return null; + } + + String initialValue = instanceValue.toString(); + StringBuilder result = new StringBuilder(); + for (int i = 0, length = initialValue.length(); i < length; ++i) + { + char c = initialValue.charAt(i); + if (c < ESCAPES.length) + { + result.append(ESCAPES[c]); + } + else if (c == '\\') + { + result.append("\\\\"); + } + else + { + result.append(c); + } + } + return result.toString(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public PreferencesPackage getPreferencesPackage() + { + return (PreferencesPackage)getEPackage(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @deprecated + * @generated + */ + @Deprecated + public static PreferencesPackage getPackage() + { + return PreferencesPackage.eINSTANCE; + } + +} // PreferencesFactoryImpl diff --git a/plugins/org.eclipse.emf.cdo.releng.preferences/src/org/eclipse/emf/cdo/releng/preferences/impl/PreferencesPackageImpl.java b/plugins/org.eclipse.emf.cdo.releng.preferences/src/org/eclipse/emf/cdo/releng/preferences/impl/PreferencesPackageImpl.java new file mode 100644 index 0000000000..dcc7b03510 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.releng.preferences/src/org/eclipse/emf/cdo/releng/preferences/impl/PreferencesPackageImpl.java @@ -0,0 +1,347 @@ +/** + */ +package org.eclipse.emf.cdo.releng.preferences.impl; + +import org.eclipse.emf.cdo.releng.preferences.PreferenceNode; +import org.eclipse.emf.cdo.releng.preferences.PreferencesFactory; +import org.eclipse.emf.cdo.releng.preferences.PreferencesPackage; +import org.eclipse.emf.cdo.releng.preferences.Property; + +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EDataType; +import org.eclipse.emf.ecore.EOperation; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.EReference; + +import org.eclipse.emf.ecore.impl.EPackageImpl; + +/** + * <!-- begin-user-doc --> + * An implementation of the model <b>Package</b>. + * <!-- end-user-doc --> + * @generated + */ +public class PreferencesPackageImpl extends EPackageImpl implements PreferencesPackage +{ + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EClass preferenceNodeEClass = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EClass propertyEClass = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EDataType escapedStringEDataType = null; + + /** + * Creates an instance of the model <b>Package</b>, registered with + * {@link org.eclipse.emf.ecore.EPackage.Registry EPackage.Registry} by the package + * package URI value. + * <p>Note: the correct way to create the package is via the static + * factory method {@link #init init()}, which also performs + * initialization of the package, or returns the registered package, + * if one already exists. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see org.eclipse.emf.ecore.EPackage.Registry + * @see org.eclipse.emf.cdo.releng.preferences.PreferencesPackage#eNS_URI + * @see #init() + * @generated + */ + private PreferencesPackageImpl() + { + super(eNS_URI, PreferencesFactory.eINSTANCE); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private static boolean isInited = false; + + /** + * Creates, registers, and initializes the <b>Package</b> for this model, and for any others upon which it depends. + * + * <p>This method is used to initialize {@link PreferencesPackage#eINSTANCE} when that field is accessed. + * Clients should not invoke it directly. Instead, they should simply access that field to obtain the package. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #eNS_URI + * @see #createPackageContents() + * @see #initializePackageContents() + * @generated + */ + public static PreferencesPackage init() + { + if (isInited) return (PreferencesPackage)EPackage.Registry.INSTANCE.getEPackage(PreferencesPackage.eNS_URI); + + // Obtain or create and register package + PreferencesPackageImpl thePreferencesPackage = (PreferencesPackageImpl)(EPackage.Registry.INSTANCE.get(eNS_URI) instanceof PreferencesPackageImpl ? EPackage.Registry.INSTANCE.get(eNS_URI) : new PreferencesPackageImpl()); + + isInited = true; + + // Create package meta-data objects + thePreferencesPackage.createPackageContents(); + + // Initialize created meta-data + thePreferencesPackage.initializePackageContents(); + + // Mark meta-data to indicate it can't be changed + thePreferencesPackage.freeze(); + + + // Update the registry and return the package + EPackage.Registry.INSTANCE.put(PreferencesPackage.eNS_URI, thePreferencesPackage); + return thePreferencesPackage; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EClass getPreferenceNode() + { + return preferenceNodeEClass; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EReference getPreferenceNode_Children() + { + return (EReference)preferenceNodeEClass.getEStructuralFeatures().get(0); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EReference getPreferenceNode_Parent() + { + return (EReference)preferenceNodeEClass.getEStructuralFeatures().get(1); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EReference getPreferenceNode_Properties() + { + return (EReference)preferenceNodeEClass.getEStructuralFeatures().get(2); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EAttribute getPreferenceNode_Name() + { + return (EAttribute)preferenceNodeEClass.getEStructuralFeatures().get(3); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EAttribute getPreferenceNode_Location() + { + return (EAttribute)preferenceNodeEClass.getEStructuralFeatures().get(4); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EOperation getPreferenceNode__GetNode__String() + { + return preferenceNodeEClass.getEOperations().get(0); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EOperation getPreferenceNode__GetProperty__String() + { + return preferenceNodeEClass.getEOperations().get(1); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EClass getProperty() + { + return propertyEClass; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EAttribute getProperty_Name() + { + return (EAttribute)propertyEClass.getEStructuralFeatures().get(0); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EReference getProperty_Parent() + { + return (EReference)propertyEClass.getEStructuralFeatures().get(1); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EAttribute getProperty_Value() + { + return (EAttribute)propertyEClass.getEStructuralFeatures().get(2); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EDataType getEscapedString() + { + return escapedStringEDataType; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public PreferencesFactory getPreferencesFactory() + { + return (PreferencesFactory)getEFactoryInstance(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private boolean isCreated = false; + + /** + * Creates the meta-model objects for the package. This method is + * guarded to have no affect on any invocation but its first. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void createPackageContents() + { + if (isCreated) return; + isCreated = true; + + // Create classes and their features + preferenceNodeEClass = createEClass(PREFERENCE_NODE); + createEReference(preferenceNodeEClass, PREFERENCE_NODE__CHILDREN); + createEReference(preferenceNodeEClass, PREFERENCE_NODE__PARENT); + createEReference(preferenceNodeEClass, PREFERENCE_NODE__PROPERTIES); + createEAttribute(preferenceNodeEClass, PREFERENCE_NODE__NAME); + createEAttribute(preferenceNodeEClass, PREFERENCE_NODE__LOCATION); + createEOperation(preferenceNodeEClass, PREFERENCE_NODE___GET_NODE__STRING); + createEOperation(preferenceNodeEClass, PREFERENCE_NODE___GET_PROPERTY__STRING); + + propertyEClass = createEClass(PROPERTY); + createEAttribute(propertyEClass, PROPERTY__NAME); + createEReference(propertyEClass, PROPERTY__PARENT); + createEAttribute(propertyEClass, PROPERTY__VALUE); + + // Create data types + escapedStringEDataType = createEDataType(ESCAPED_STRING); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private boolean isInitialized = false; + + /** + * Complete the initialization of the package and its meta-model. This + * method is guarded to have no affect on any invocation but its first. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void initializePackageContents() + { + if (isInitialized) return; + isInitialized = true; + + // Initialize package + setName(eNAME); + setNsPrefix(eNS_PREFIX); + setNsURI(eNS_URI); + + // Create type parameters + + // Set bounds for type parameters + + // Add supertypes to classes + + // Initialize classes, features, and operations; add parameters + initEClass(preferenceNodeEClass, PreferenceNode.class, "PreferenceNode", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEReference(getPreferenceNode_Children(), this.getPreferenceNode(), this.getPreferenceNode_Parent(), "children", null, 0, -1, PreferenceNode.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + getPreferenceNode_Children().getEKeys().add(this.getPreferenceNode_Name()); + initEReference(getPreferenceNode_Parent(), this.getPreferenceNode(), this.getPreferenceNode_Children(), "parent", null, 0, 1, PreferenceNode.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEReference(getPreferenceNode_Properties(), this.getProperty(), this.getProperty_Parent(), "properties", null, 0, -1, PreferenceNode.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + getPreferenceNode_Properties().getEKeys().add(this.getProperty_Name()); + initEAttribute(getPreferenceNode_Name(), ecorePackage.getEString(), "name", null, 1, 1, PreferenceNode.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getPreferenceNode_Location(), ecorePackage.getEString(), "location", null, 0, 1, PreferenceNode.class, IS_TRANSIENT, IS_VOLATILE, !IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, IS_DERIVED, IS_ORDERED); + + EOperation op = initEOperation(getPreferenceNode__GetNode__String(), this.getPreferenceNode(), "getNode", 0, 1, IS_UNIQUE, IS_ORDERED); + addEParameter(op, ecorePackage.getEString(), "name", 0, 1, IS_UNIQUE, IS_ORDERED); + + op = initEOperation(getPreferenceNode__GetProperty__String(), this.getProperty(), "getProperty", 0, 1, IS_UNIQUE, IS_ORDERED); + addEParameter(op, ecorePackage.getEString(), "name", 0, 1, IS_UNIQUE, IS_ORDERED); + + initEClass(propertyEClass, Property.class, "Property", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEAttribute(getProperty_Name(), ecorePackage.getEString(), "name", null, 1, 1, Property.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEReference(getProperty_Parent(), this.getPreferenceNode(), this.getPreferenceNode_Properties(), "parent", null, 0, 1, Property.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getProperty_Value(), this.getEscapedString(), "value", null, 0, 1, Property.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + // Initialize data types + initEDataType(escapedStringEDataType, String.class, "EscapedString", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS); + + // Create resource + createResource(eNS_URI); + } + +} //PreferencesPackageImpl diff --git a/plugins/org.eclipse.emf.cdo.releng.preferences/src/org/eclipse/emf/cdo/releng/preferences/impl/PreferencesURIHandlerImpl.java b/plugins/org.eclipse.emf.cdo.releng.preferences/src/org/eclipse/emf/cdo/releng/preferences/impl/PreferencesURIHandlerImpl.java new file mode 100644 index 0000000000..dc98b11f88 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.releng.preferences/src/org/eclipse/emf/cdo/releng/preferences/impl/PreferencesURIHandlerImpl.java @@ -0,0 +1,174 @@ +/* + * Copyright (c) 2013 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + */ +package org.eclipse.emf.cdo.releng.preferences.impl; + +import org.eclipse.emf.cdo.releng.preferences.PreferenceNode; +import org.eclipse.emf.cdo.releng.preferences.util.PreferencesUtil; + +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.resource.URIConverter; +import org.eclipse.emf.ecore.resource.impl.URIHandlerImpl; + +import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.preferences.IEclipsePreferences; + +import org.osgi.service.prefs.BackingStoreException; +import org.osgi.service.prefs.Preferences; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.Collections; +import java.util.Map; + +/** + * @author Eike Stepper + */ +public class PreferencesURIHandlerImpl extends URIHandlerImpl +{ + private static final IEclipsePreferences ROOT = Platform.getPreferencesService().getRootNode(); + + @Override + public boolean canHandle(URI uri) + { + return "preference".equals(uri.scheme()); + } + + protected static class PreferenceAccessor + { + private final Preferences preferences; + + private final String key; + + public PreferenceAccessor(URI uri) + { + Preferences node = ROOT; + for (String name : uri.trimSegments(1).segments()) + { + node = node.node(name); + } + key = uri.lastSegment(); + preferences = node; + } + + public String get() + { + return preferences.get(key, null); + + } + + public void put(String value) throws IOException + { + preferences.put(key, value); + flush(); + } + + public void remove() throws IOException + { + preferences.remove(key); + flush(); + } + + private void flush() throws IOException + { + try + { + preferences.flush(); + } + catch (BackingStoreException ex) + { + throw new IOException(ex); + } + } + } + + @Override + public InputStream createInputStream(URI uri, final Map<?, ?> options) throws IOException + { + if (uri.segmentCount() == 1) + { + class PreferencesInput extends InputStream implements URIConverter.Loadable + { + private PreferenceNode preferencesNode = PreferencesUtil.getRootPreferenceNode(Boolean.TRUE.equals(options + .get(PreferencesUtil.OPTION_SYNCHRONIZED_PREFERENCES))); + + private InputStream in; + + public void loadResource(Resource resource) throws IOException + { + resource.getContents().add(preferencesNode); + } + + @Override + public int read() throws IOException + { + if (in == null) + { + ByteArrayOutputStream out = new ByteArrayOutputStream(); + preferencesNode.eResource().save(out, null); + in = new ByteArrayInputStream(out.toByteArray()); + } + return in.read(); + } + } + + return new PreferencesInput(); + } + URI preferencePath = uri.trimSegments(1); + String value = new PreferenceAccessor(preferencePath).get(); + if (value == null) + { + throw new IOException("No preference value available for " + preferencePath); + } + return new URIConverter.ReadableInputStream(value); + } + + @Override + public OutputStream createOutputStream(URI uri, Map<?, ?> options) throws IOException + { + final PreferenceAccessor accessor = new PreferenceAccessor(uri.trimSegments(1)); + return new ByteArrayOutputStream() + { + @Override + public void close() throws IOException + { + accessor.put(new String(toByteArray(), "UTF-8")); + } + }; + } + + @Override + public void delete(URI uri, Map<?, ?> options) throws IOException + { + new PreferenceAccessor(uri.trimSegments(1)).remove(); + } + + @Override + public boolean exists(URI uri, Map<?, ?> options) + { + return new PreferenceAccessor(uri.trimSegments(1)).get() != null; + } + + @Override + public Map<String, ?> getAttributes(URI uri, Map<?, ?> options) + { + return Collections.emptyMap(); + } + + @Override + public void setAttributes(URI uri, Map<String, ?> attributes, Map<?, ?> options) throws IOException + { + // Do nothing. + } +} diff --git a/plugins/org.eclipse.emf.cdo.releng.preferences/src/org/eclipse/emf/cdo/releng/preferences/impl/PropertyImpl.java b/plugins/org.eclipse.emf.cdo.releng.preferences/src/org/eclipse/emf/cdo/releng/preferences/impl/PropertyImpl.java new file mode 100644 index 0000000000..8319e1e9b7 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.releng.preferences/src/org/eclipse/emf/cdo/releng/preferences/impl/PropertyImpl.java @@ -0,0 +1,344 @@ +/** + */ +package org.eclipse.emf.cdo.releng.preferences.impl; + +import org.eclipse.emf.cdo.releng.preferences.PreferenceNode; +import org.eclipse.emf.cdo.releng.preferences.PreferencesPackage; +import org.eclipse.emf.cdo.releng.preferences.Property; + +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.notify.NotificationChain; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.InternalEObject; + +import org.eclipse.emf.ecore.impl.ENotificationImpl; +import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; + +import org.eclipse.emf.ecore.util.EcoreUtil; + +/** + * <!-- begin-user-doc --> + * An implementation of the model object '<em><b>Property</b></em>'. + * <!-- end-user-doc --> + * <p> + * The following features are implemented: + * <ul> + * <li>{@link org.eclipse.emf.cdo.releng.preferences.impl.PropertyImpl#getName <em>Name</em>}</li> + * <li>{@link org.eclipse.emf.cdo.releng.preferences.impl.PropertyImpl#getParent <em>Parent</em>}</li> + * <li>{@link org.eclipse.emf.cdo.releng.preferences.impl.PropertyImpl#getValue <em>Value</em>}</li> + * </ul> + * </p> + * + * @generated + */ +public class PropertyImpl extends MinimalEObjectImpl.Container implements Property +{ + /** + * The default value of the '{@link #getName() <em>Name</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getName() + * @generated + * @ordered + */ + protected static final String NAME_EDEFAULT = null; + + /** + * The cached value of the '{@link #getName() <em>Name</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getName() + * @generated + * @ordered + */ + protected String name = NAME_EDEFAULT; + + /** + * The default value of the '{@link #getValue() <em>Value</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getValue() + * @generated + * @ordered + */ + protected static final String VALUE_EDEFAULT = null; + + /** + * The cached value of the '{@link #getValue() <em>Value</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getValue() + * @generated + * @ordered + */ + protected String value = VALUE_EDEFAULT; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected PropertyImpl() + { + super(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + protected EClass eStaticClass() + { + return PreferencesPackage.Literals.PROPERTY; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public String getName() + { + return name; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void setName(String newName) + { + String oldName = name; + name = newName; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, PreferencesPackage.PROPERTY__NAME, oldName, name)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public PreferenceNode getParent() + { + if (eContainerFeatureID() != PreferencesPackage.PROPERTY__PARENT) return null; + return (PreferenceNode)eInternalContainer(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public NotificationChain basicSetParent(PreferenceNode newParent, NotificationChain msgs) + { + msgs = eBasicSetContainer((InternalEObject)newParent, PreferencesPackage.PROPERTY__PARENT, msgs); + return msgs; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void setParent(PreferenceNode newParent) + { + if (newParent != eInternalContainer() || (eContainerFeatureID() != PreferencesPackage.PROPERTY__PARENT && newParent != null)) + { + if (EcoreUtil.isAncestor(this, newParent)) + throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); + NotificationChain msgs = null; + if (eInternalContainer() != null) + msgs = eBasicRemoveFromContainer(msgs); + if (newParent != null) + msgs = ((InternalEObject)newParent).eInverseAdd(this, PreferencesPackage.PREFERENCE_NODE__PROPERTIES, PreferenceNode.class, msgs); + msgs = basicSetParent(newParent, msgs); + if (msgs != null) msgs.dispatch(); + } + else if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, PreferencesPackage.PROPERTY__PARENT, newParent, newParent)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public String getValue() + { + return value; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void setValue(String newValue) + { + String oldValue = value; + value = newValue; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, PreferencesPackage.PROPERTY__VALUE, oldValue, value)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) + { + switch (featureID) + { + case PreferencesPackage.PROPERTY__PARENT: + if (eInternalContainer() != null) + msgs = eBasicRemoveFromContainer(msgs); + return basicSetParent((PreferenceNode)otherEnd, msgs); + } + return super.eInverseAdd(otherEnd, featureID, msgs); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) + { + switch (featureID) + { + case PreferencesPackage.PROPERTY__PARENT: + return basicSetParent(null, msgs); + } + return super.eInverseRemove(otherEnd, featureID, msgs); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) + { + switch (eContainerFeatureID()) + { + case PreferencesPackage.PROPERTY__PARENT: + return eInternalContainer().eInverseRemove(this, PreferencesPackage.PREFERENCE_NODE__PROPERTIES, PreferenceNode.class, msgs); + } + return super.eBasicRemoveFromContainerFeature(msgs); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) + { + switch (featureID) + { + case PreferencesPackage.PROPERTY__NAME: + return getName(); + case PreferencesPackage.PROPERTY__PARENT: + return getParent(); + case PreferencesPackage.PROPERTY__VALUE: + return getValue(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + public void eSet(int featureID, Object newValue) + { + switch (featureID) + { + case PreferencesPackage.PROPERTY__NAME: + setName((String)newValue); + return; + case PreferencesPackage.PROPERTY__PARENT: + setParent((PreferenceNode)newValue); + return; + case PreferencesPackage.PROPERTY__VALUE: + setValue((String)newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + public void eUnset(int featureID) + { + switch (featureID) + { + case PreferencesPackage.PROPERTY__NAME: + setName(NAME_EDEFAULT); + return; + case PreferencesPackage.PROPERTY__PARENT: + setParent((PreferenceNode)null); + return; + case PreferencesPackage.PROPERTY__VALUE: + setValue(VALUE_EDEFAULT); + return; + } + super.eUnset(featureID); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + public boolean eIsSet(int featureID) + { + switch (featureID) + { + case PreferencesPackage.PROPERTY__NAME: + return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name); + case PreferencesPackage.PROPERTY__PARENT: + return getParent() != null; + case PreferencesPackage.PROPERTY__VALUE: + return VALUE_EDEFAULT == null ? value != null : !VALUE_EDEFAULT.equals(value); + } + return super.eIsSet(featureID); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + public String toString() + { + if (eIsProxy()) return super.toString(); + + StringBuffer result = new StringBuffer(super.toString()); + result.append(" (name: "); + result.append(name); + result.append(", value: "); + result.append(value); + result.append(')'); + return result.toString(); + } + +} //PropertyImpl diff --git a/plugins/org.eclipse.emf.cdo.releng.preferences/src/org/eclipse/emf/cdo/releng/preferences/util/PreferencesAdapterFactory.java b/plugins/org.eclipse.emf.cdo.releng.preferences/src/org/eclipse/emf/cdo/releng/preferences/util/PreferencesAdapterFactory.java new file mode 100644 index 0000000000..41057ad260 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.releng.preferences/src/org/eclipse/emf/cdo/releng/preferences/util/PreferencesAdapterFactory.java @@ -0,0 +1,152 @@ +/** + */ +package org.eclipse.emf.cdo.releng.preferences.util; + +import org.eclipse.emf.cdo.releng.preferences.*; + +import org.eclipse.emf.common.notify.Adapter; +import org.eclipse.emf.common.notify.Notifier; + +import org.eclipse.emf.common.notify.impl.AdapterFactoryImpl; + +import org.eclipse.emf.ecore.EObject; + +/** + * <!-- begin-user-doc --> + * The <b>Adapter Factory</b> for the model. + * It provides an adapter <code>createXXX</code> method for each class of the model. + * <!-- end-user-doc --> + * @see org.eclipse.emf.cdo.releng.preferences.PreferencesPackage + * @generated + */ +public class PreferencesAdapterFactory extends AdapterFactoryImpl +{ + /** + * The cached model package. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected static PreferencesPackage modelPackage; + + /** + * Creates an instance of the adapter factory. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public PreferencesAdapterFactory() + { + if (modelPackage == null) + { + modelPackage = PreferencesPackage.eINSTANCE; + } + } + + /** + * Returns whether this factory is applicable for the type of the object. + * <!-- begin-user-doc --> + * This implementation returns <code>true</code> if the object is either the model's package or is an instance object of the model. + * <!-- end-user-doc --> + * @return whether this factory is applicable for the type of the object. + * @generated + */ + @Override + public boolean isFactoryForType(Object object) + { + if (object == modelPackage) + { + return true; + } + if (object instanceof EObject) + { + return ((EObject)object).eClass().getEPackage() == modelPackage; + } + return false; + } + + /** + * The switch that delegates to the <code>createXXX</code> methods. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected PreferencesSwitch<Adapter> modelSwitch = + new PreferencesSwitch<Adapter>() + { + @Override + public Adapter casePreferenceNode(PreferenceNode object) + { + return createPreferenceNodeAdapter(); + } + @Override + public Adapter caseProperty(Property object) + { + return createPropertyAdapter(); + } + @Override + public Adapter defaultCase(EObject object) + { + return createEObjectAdapter(); + } + }; + + /** + * Creates an adapter for the <code>target</code>. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @param target the object to adapt. + * @return the adapter for the <code>target</code>. + * @generated + */ + @Override + public Adapter createAdapter(Notifier target) + { + return modelSwitch.doSwitch((EObject)target); + } + + + /** + * Creates a new adapter for an object of class '{@link org.eclipse.emf.cdo.releng.preferences.PreferenceNode <em>Preference Node</em>}'. + * <!-- begin-user-doc --> + * This default implementation returns null so that we can easily ignore cases; + * it's useful to ignore a case when inheritance will catch all the cases anyway. + * <!-- end-user-doc --> + * @return the new adapter. + * @see org.eclipse.emf.cdo.releng.preferences.PreferenceNode + * @generated + */ + public Adapter createPreferenceNodeAdapter() + { + return null; + } + + /** + * Creates a new adapter for an object of class '{@link org.eclipse.emf.cdo.releng.preferences.Property <em>Property</em>}'. + * <!-- begin-user-doc --> + * This default implementation returns null so that we can easily ignore cases; + * it's useful to ignore a case when inheritance will catch all the cases anyway. + * <!-- end-user-doc --> + * @return the new adapter. + * @see org.eclipse.emf.cdo.releng.preferences.Property + * @generated + */ + public Adapter createPropertyAdapter() + { + return null; + } + + /** + * Creates a new adapter for the default case. + * <!-- begin-user-doc --> + * This default implementation returns null. + * <!-- end-user-doc --> + * @return the new adapter. + * @generated + */ + public Adapter createEObjectAdapter() + { + return null; + } + +} //PreferencesAdapterFactory diff --git a/plugins/org.eclipse.emf.cdo.releng.preferences/src/org/eclipse/emf/cdo/releng/preferences/util/PreferencesSwitch.java b/plugins/org.eclipse.emf.cdo.releng.preferences/src/org/eclipse/emf/cdo/releng/preferences/util/PreferencesSwitch.java new file mode 100644 index 0000000000..c4de14a7f7 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.releng.preferences/src/org/eclipse/emf/cdo/releng/preferences/util/PreferencesSwitch.java @@ -0,0 +1,142 @@ +/** + */ +package org.eclipse.emf.cdo.releng.preferences.util; + +import org.eclipse.emf.cdo.releng.preferences.*; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EPackage; + +import org.eclipse.emf.ecore.util.Switch; + +/** + * <!-- begin-user-doc --> + * The <b>Switch</b> for the model's inheritance hierarchy. + * It supports the call {@link #doSwitch(EObject) doSwitch(object)} + * to invoke the <code>caseXXX</code> method for each class of the model, + * starting with the actual class of the object + * and proceeding up the inheritance hierarchy + * until a non-null result is returned, + * which is the result of the switch. + * <!-- end-user-doc --> + * @see org.eclipse.emf.cdo.releng.preferences.PreferencesPackage + * @generated + */ +public class PreferencesSwitch<T> extends Switch<T> +{ + /** + * The cached model package + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected static PreferencesPackage modelPackage; + + /** + * Creates an instance of the switch. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public PreferencesSwitch() + { + if (modelPackage == null) + { + modelPackage = PreferencesPackage.eINSTANCE; + } + } + + /** + * Checks whether this is a switch for the given package. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @parameter ePackage the package in question. + * @return whether this is a switch for the given package. + * @generated + */ + @Override + protected boolean isSwitchFor(EPackage ePackage) + { + return ePackage == modelPackage; + } + + /** + * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the first non-null result returned by a <code>caseXXX</code> call. + * @generated + */ + @Override + protected T doSwitch(int classifierID, EObject theEObject) + { + switch (classifierID) + { + case PreferencesPackage.PREFERENCE_NODE: + { + PreferenceNode preferenceNode = (PreferenceNode)theEObject; + T result = casePreferenceNode(preferenceNode); + if (result == null) result = defaultCase(theEObject); + return result; + } + case PreferencesPackage.PROPERTY: + { + Property property = (Property)theEObject; + T result = caseProperty(property); + if (result == null) result = defaultCase(theEObject); + return result; + } + default: return defaultCase(theEObject); + } + } + + /** + * Returns the result of interpreting the object as an instance of '<em>Preference Node</em>'. + * <!-- begin-user-doc --> + * This implementation returns null; + * returning a non-null result will terminate the switch. + * <!-- end-user-doc --> + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of '<em>Preference Node</em>'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T casePreferenceNode(PreferenceNode object) + { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of '<em>Property</em>'. + * <!-- begin-user-doc --> + * This implementation returns null; + * returning a non-null result will terminate the switch. + * <!-- end-user-doc --> + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of '<em>Property</em>'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseProperty(Property object) + { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of '<em>EObject</em>'. + * <!-- begin-user-doc --> + * This implementation returns null; + * returning a non-null result will terminate the switch, but this is the last case anyway. + * <!-- end-user-doc --> + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of '<em>EObject</em>'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) + * @generated + */ + @Override + public T defaultCase(EObject object) + { + return null; + } + +} //PreferencesSwitch diff --git a/plugins/org.eclipse.emf.cdo.releng.preferences/src/org/eclipse/emf/cdo/releng/preferences/util/PreferencesUtil.java b/plugins/org.eclipse.emf.cdo.releng.preferences/src/org/eclipse/emf/cdo/releng/preferences/util/PreferencesUtil.java new file mode 100644 index 0000000000..f0b0510d4f --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.releng.preferences/src/org/eclipse/emf/cdo/releng/preferences/util/PreferencesUtil.java @@ -0,0 +1,341 @@ +/* + * Copyright (c) 2004-2013 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + */ +package org.eclipse.emf.cdo.releng.preferences.util; + +import org.eclipse.emf.cdo.releng.preferences.PreferenceNode; +import org.eclipse.emf.cdo.releng.preferences.PreferencesFactory; +import org.eclipse.emf.cdo.releng.preferences.Property; + +import org.eclipse.emf.common.notify.Notifier; +import org.eclipse.emf.common.notify.impl.AdapterImpl; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; + +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.preferences.IEclipsePreferences; +import org.eclipse.core.runtime.preferences.IEclipsePreferences.NodeChangeEvent; +import org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent; + +import org.osgi.service.prefs.BackingStoreException; +import org.osgi.service.prefs.Preferences; + +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +/** + * @author Eike Stepper + */ +public final class PreferencesUtil +{ + /** + * A resource load option to load an instance using {@link #getRootPreferenceNode(boolean) PreferencesUtil.getRootPreferenceNode(true)}. + * The resource must be {@link Resource#unload() unloaded}, to avoid dangling listeners. + */ + public static final String OPTION_SYNCHRONIZED_PREFERENCES = "SYNCHRONIZED_PREFERENCES"; + + private static final IEclipsePreferences ROOT = Platform.getPreferencesService().getRootNode(); + + public static final URI ROOT_PREFERENCE_NODE_URI = URI.createURI("preference:/"); + + private static class PreferencesAdapter extends AdapterImpl implements IEclipsePreferences.INodeChangeListener, + IEclipsePreferences.IPreferenceChangeListener + { + protected IEclipsePreferences preferences; + + public PreferencesAdapter(IEclipsePreferences preferences) + { + this.preferences = preferences; + + preferences.addNodeChangeListener(this); + preferences.addPreferenceChangeListener(this); + } + + @Override + public boolean isAdapterForType(Object type) + { + return type == PreferencesAdapter.class; + } + + public void preferenceChange(PreferenceChangeEvent event) + { + PreferenceNode preferenceNode = (PreferenceNode)target; + String name = event.getKey(); + Object value = event.getNewValue(); + EList<Property> properties = preferenceNode.getProperties(); + for (int i = 0, size = properties.size(); i < size; ++i) + { + Property property = properties.get(i); + int comparison = property.getName().compareTo(name); + if (comparison == 0) + { + if (value == null) + { + properties.remove(i); + } + else + { + property.setValue(value.toString()); + } + return; + } + else if (comparison > 0) + { + if (value != null) + { + property = PreferencesFactory.eINSTANCE.createProperty(); + property.setName(name); + property.setValue(value.toString()); + properties.add(i, property); + } + return; + } + } + Property property = PreferencesFactory.eINSTANCE.createProperty(); + property.setName(name); + property.setValue(value.toString()); + properties.add(property); + } + + public void added(NodeChangeEvent event) + { + PreferenceNode preferenceNode = (PreferenceNode)target; + Preferences childNode = event.getChild(); + PreferenceNode childPreferenceNode = PreferencesFactory.eINSTANCE.createPreferenceNode(); + String name = childNode.name(); + childPreferenceNode.setName(name); + traverse(childPreferenceNode, childNode, true); + EList<PreferenceNode> children = preferenceNode.getChildren(); + for (int i = 0, size = children.size(); i < size; ++i) + { + PreferenceNode otherChildPreferenceNode = children.get(i); + if (otherChildPreferenceNode.getName().compareTo(name) >= 0) + { + children.add(i, childPreferenceNode); + return; + } + } + children.add(childPreferenceNode); + } + + public void removed(NodeChangeEvent event) + { + PreferenceNode preferenceNode = (PreferenceNode)target; + Preferences childNode = event.getChild(); + String name = childNode.name(); + EList<PreferenceNode> children = preferenceNode.getChildren(); + for (int i = 0, size = children.size(); i < size; ++i) + { + PreferenceNode childPreferenceNode = children.get(i); + if (childPreferenceNode.getName().equals(name)) + { + children.remove(i); + return; + } + } + } + + @Override + public void unsetTarget(Notifier oldTarget) + { + super.unsetTarget(oldTarget); + + preferences.removeNodeChangeListener(this); + preferences.removePreferenceChangeListener(this); + } + } + + public static PreferenceNode getRootPreferenceNode() + { + return getRootPreferenceNode(false); + } + + public static PreferenceNode getRootPreferenceNode(boolean isSynchronized) + { + ResourceSet resourceSet = new ResourceSetImpl(); + Resource resource = resourceSet.createResource(ROOT_PREFERENCE_NODE_URI.appendSegment("*.preferences")); + PreferenceNode root = PreferencesFactory.eINSTANCE.createPreferenceNode(); + traverse(root, ROOT, isSynchronized); + resource.getContents().add(root); + + return root; + } + + private static void traverse(PreferenceNode preferenceNode, Preferences node, boolean isSynchronized) + { + try + { + if (isSynchronized && node instanceof IEclipsePreferences) + { + preferenceNode.eAdapters().add(new PreferencesAdapter((IEclipsePreferences)node)); + } + + preferenceNode.setName(node.name()); + + EList<PreferenceNode> children = preferenceNode.getChildren(); + String[] childrenNames = node.childrenNames(); + Arrays.sort(childrenNames); + for (String name : childrenNames) + { + Preferences childNode = node.node(name); + PreferenceNode childPreferenceNode = PreferencesFactory.eINSTANCE.createPreferenceNode(); + traverse(childPreferenceNode, childNode, isSynchronized); + children.add(childPreferenceNode); + } + EList<Property> properties = preferenceNode.getProperties(); + String[] keys = node.keys(); + Arrays.sort(keys); + for (String name : keys) + { + Property property = PreferencesFactory.eINSTANCE.createProperty(); + property.setName(name); + property.setValue(node.get(name, null)); + properties.add(property); + } + } + catch (BackingStoreException ex) + { + // Ignore + } + } + + public static Preferences getPreferences(PreferenceNode preferenceNode, boolean demandCreate) + throws BackingStoreException + { + if (preferenceNode == null) + { + return ROOT; + } + + Preferences parentPreferences = getPreferences(preferenceNode.getParent(), demandCreate); + if (parentPreferences != null) + { + String name = preferenceNode.getName(); + if (demandCreate || parentPreferences.nodeExists(name)) + { + return parentPreferences.node(name); + } + } + return null; + } + + public static IPath getLocation(Preferences preferences) + { + if (preferences == null) + { + return null; + } + + try + { + Method getLocationMethod = preferences.getClass().getDeclaredMethod("getLocation"); + getLocationMethod.setAccessible(true); + IPath location = (IPath)getLocationMethod.invoke(preferences); + return location; + } + catch (Exception ex) + { + // Ignore + } + + return null; + } + + private static List<PreferenceNode> getPath(PreferenceNode preferenceNode) + { + List<PreferenceNode> path = new ArrayList<PreferenceNode>(); + while (preferenceNode != null) + { + path.add(preferenceNode); + preferenceNode = preferenceNode.getParent(); + } + Collections.reverse(path); + return path; + } + + public static PreferenceNode getAncestor(PreferenceNode preferenceNode) + { + List<PreferenceNode> path = getPath(preferenceNode); + int size = path.size(); + if (size > 1) + { + PreferenceNode root = path.get(0); + if ("".equals(root.getName())) + { + PreferenceNode base = path.get(1); + String name = base.getName(); + int start = 2; + if ("project".equals(name)) + { + name = "instance"; + PreferenceNode result = root.getNode(name); + for (int i = ++start; result != null && i < size; ++i) + { + result = result.getNode(path.get(i).getName()); + } + if (result != null) + { + return result; + } + } + + if ("instance".equals(name)) + { + name = "default"; + PreferenceNode result = root.getNode(name); + for (int i = start; result != null && i < size; ++i) + { + result = result.getNode(path.get(i).getName()); + } + if (result != null) + { + return result; + } + } + + if ("default".equals(name)) + { + name = "configuration"; + PreferenceNode result = root.getNode(name); + for (int i = start; result != null && i < size; ++i) + { + result = result.getNode(path.get(i).getName()); + } + if (result != null) + { + return result; + } + } + + if ("configuration".equals(name)) + { + name = "bundle_defaults"; + PreferenceNode result = root.getNode(name); + for (int i = start; result != null && i < size; ++i) + { + result = result.getNode(path.get(i).getName()); + } + if (result != null) + { + return result; + } + } + } + } + return null; + } +} |