org.jupe.uml2model
Class UML2ModelRoot

java.lang.Object
  extended by org.jupe.uml2model.UML2ModelRoot

public class UML2ModelRoot
extends java.lang.Object

Author:
carlos, Michael Pradel

Field Summary
static java.lang.String PRIMITIVE_TYPES_PACKAGE
          The name of the package where the primitives types are stored.
static java.lang.String UNRESOLVED_TYPES_PACKAGE
          The name of the package where unresolved types are temporary stored.
 
Constructor Summary
UML2ModelRoot(JupeProject project)
           
 
Method Summary
 void addToIDHash(org.eclipse.uml2.uml.Element element)
          Checks if the element is already in the ID hash table (see IDFromElement) and adds it with a new ID if not.
 java.util.List<ITypeContentProposal> completeInPrimitiveTypes(java.lang.String contents)
          Searches for possible resolution of the given String to the type name of a primitive type.
 java.util.List<ITypeContentProposal> completeInUML2(java.lang.String contents)
          Completes the given String to a type name found in the UML2 model.
 java.util.List<ITypeContentProposal> completeInUnresolvedTypes(java.lang.String contents)
          Searches for possible auto-completion resolution of the given String to a type name that is in the package for unresolved types right now.
 java.lang.String getAbsoluteName(org.eclipse.uml2.uml.NamedElement element)
          Convenience method to call getAbsoluteName(NamedElement, boolean) with the second parameter set to true.
 java.lang.String getAbsoluteName(org.eclipse.uml2.uml.NamedElement element, boolean noHiddenPackages)
          Builds the absolute name for an given UML2 element.
 org.eclipse.uml2.uml.Element getElement(java.lang.String id)
          Get the UML2 element that corresponds to a certain ID (see IDFromElement).
 java.lang.String getID(org.eclipse.uml2.uml.Element element)
          Get the unique ID of a UML2 element (see IDFromElement).
 org.eclipse.uml2.uml.Model getUML2Model()
           
 void registerTypeName(java.lang.String absoluteName)
          Signal to the UML model that a type with a certain type name exists.
 void repopulateHashTable(org.eclipse.emf.ecore.xmi.XMLResource xml)
          Reads the XML file that contains the UML2 model and fills the hash table that contains each UML2 element and its corresponding unique ID (see IDFromElement).
 org.eclipse.uml2.uml.Classifier resolveType(java.lang.String absoluteName)
           
 void setUML2Model(org.eclipse.uml2.uml.Model newModel)
           
 void setUpHiddenPackages()
          Creates two hidden packages: One for primitive types (e.g. int, boolean) which are loaded from the UML2 library, and another one for temporary unresolved types.
 void setXmiIDs(org.eclipse.emf.ecore.xmi.XMLResource xml)
          Writes the unique IDs of UML2 elements that are stored in IDFromElement and elementFromID at runtime into the XML file that contains the UML2 model.
 void unregisterTypeName(java.lang.String absoluteName)
          Signal to the UML model that a type with a certain name doesn't exist anymore.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PRIMITIVE_TYPES_PACKAGE

public static final java.lang.String PRIMITIVE_TYPES_PACKAGE
The name of the package where the primitives types are stored.

See Also:
Constant Field Values

UNRESOLVED_TYPES_PACKAGE

public static final java.lang.String UNRESOLVED_TYPES_PACKAGE
The name of the package where unresolved types are temporary stored. The package should not include other packages, but included types' names should be the (so far known) absolute name, e.g. "org.foo.Bar".

A type is called unresolved here, if it doesn't exist in the rest of the UML2 model or in the source. E.g. unresolved types can be created when the user sets some type reference in a diagram to a type he will create later.

See Also:
Constant Field Values
Constructor Detail

UML2ModelRoot

public UML2ModelRoot(JupeProject project)
Method Detail

setUpHiddenPackages

public void setUpHiddenPackages()
Creates two hidden packages: One for primitive types (e.g. int, boolean) which are loaded from the UML2 library, and another one for temporary unresolved types.


getUML2Model

public org.eclipse.uml2.uml.Model getUML2Model()

setUML2Model

public void setUML2Model(org.eclipse.uml2.uml.Model newModel)

addToIDHash

public void addToIDHash(org.eclipse.uml2.uml.Element element)
Checks if the element is already in the ID hash table (see IDFromElement) and adds it with a new ID if not.

Parameters:
element - The UML2 element to add to the ID hash table.

getID

public java.lang.String getID(org.eclipse.uml2.uml.Element element)
Get the unique ID of a UML2 element (see IDFromElement).

Parameters:
element - A UML2 element.
Returns:
The unique ID of the element.

getElement

public org.eclipse.uml2.uml.Element getElement(java.lang.String id)
Get the UML2 element that corresponds to a certain ID (see IDFromElement).

Parameters:
id - An ID for a UML2 element.
Returns:
The UML2 element for the given ID.

getAbsoluteName

public java.lang.String getAbsoluteName(org.eclipse.uml2.uml.NamedElement element,
                                        boolean noHiddenPackages)
Builds the absolute name for an given UML2 element.

Parameters:
element - An UML2 element.
noHiddenPackages - When true, elements in the hidden packages won't be resolved, but return their simple name.
Returns:
The absolute name, or the simple name if the element is in the hidden packages and noHiddenPackage is true.

getAbsoluteName

public java.lang.String getAbsoluteName(org.eclipse.uml2.uml.NamedElement element)
Convenience method to call getAbsoluteName(NamedElement, boolean) with the second parameter set to true.

Parameters:
element -
Returns:
See Also:
getAbsoluteName(NamedElement, boolean)

setXmiIDs

public void setXmiIDs(org.eclipse.emf.ecore.xmi.XMLResource xml)
Writes the unique IDs of UML2 elements that are stored in IDFromElement and elementFromID at runtime into the XML file that contains the UML2 model.

This method should be called while saving the UML2 model.

Parameters:
xml - The resource containing the UML2 model.

repopulateHashTable

public void repopulateHashTable(org.eclipse.emf.ecore.xmi.XMLResource xml)
Reads the XML file that contains the UML2 model and fills the hash table that contains each UML2 element and its corresponding unique ID (see IDFromElement).

This method should be called while laoding the UML2 model.

Parameters:
xml - The resource containing the UML2 model.

completeInUnresolvedTypes

public java.util.List<ITypeContentProposal> completeInUnresolvedTypes(java.lang.String contents)
Searches for possible auto-completion resolution of the given String to a type name that is in the package for unresolved types right now.

Parameters:
contents - The beginning of a type name.
Returns:
List of proposals (absolute names) found in the package for unresolved types that match the given String.

completeInPrimitiveTypes

public java.util.List<ITypeContentProposal> completeInPrimitiveTypes(java.lang.String contents)
Searches for possible resolution of the given String to the type name of a primitive type.

Parameters:
contents - The beginning of a type name.
Returns:
List of proposal found in the package for primitive types that match the given String.

completeInUML2

public java.util.List<ITypeContentProposal> completeInUML2(java.lang.String contents)
Completes the given String to a type name found in the UML2 model. The search will not be performed in the hidden packages.

Parameters:
contents - The beginning of a type name.
Returns:
List of proposals that match the given String.

resolveType

public org.eclipse.uml2.uml.Classifier resolveType(java.lang.String absoluteName)

registerTypeName

public void registerTypeName(java.lang.String absoluteName)
Signal to the UML model that a type with a certain type name exists. That method should be called each time when a type is created, moved or renamed (also its underlying packages).

The method checks whether the new type allows resolution of a type that is marked as unresolved, and adds the type name to a internal hash table.

Parameters:
absoluteName - The absolute name of the type.

unregisterTypeName

public void unregisterTypeName(java.lang.String absoluteName)
Signal to the UML model that a type with a certain name doesn't exist anymore.

The method will remove the type from a internal hash table.

Parameters:
absoluteName - The absolute name of the type.