org.mftech.dawn.runtime.client.synchronization
Class ResourceHelper

java.lang.Object
  extended by org.mftech.dawn.runtime.client.synchronization.ResourceHelper

public class ResourceHelper
extends java.lang.Object


Field Summary
static java.lang.String gmfResourceWithEMF_0Objects
           
static java.lang.String gmfResourceWithEMF_0ObjectsTEST
           
 
Constructor Summary
ResourceHelper()
           
 
Method Summary
static void addElementToContainer(org.eclipse.emf.ecore.EObject element, org.eclipse.emf.ecore.EObject container, org.eclipse.emf.ecore.EStructuralFeature containingFeature)
           
static void addViewToResource(org.eclipse.emf.ecore.xmi.XMLResource projectResource, org.eclipse.gmf.runtime.notation.View view)
          This method add a view to the resource and copies all xmid ids.
static boolean areSameObjects(org.eclipse.emf.ecore.EObject oldNode, org.eclipse.emf.ecore.EObject newNode)
          compares two eObjects by there xmi-id whether the are equal or not
static void changeViewInResource(org.eclipse.emf.ecore.EObject leftObject, org.eclipse.gmf.runtime.notation.View rightObject)
          changes the leftObject to the values of rightObject leftObject=rightObject
static void copyXmiId(org.eclipse.emf.ecore.EObject oldElement, org.eclipse.emf.ecore.EObject newElement)
          copies the XMI-id from oldElement to new Element
static void copyXmiIds(org.eclipse.emf.ecore.EObject oldObject, org.eclipse.emf.ecore.EObject newObject)
          This method provides deep copying of all childrens xmi ids from oldObject to newObject
static org.eclipse.emf.ecore.EObject createCopy(org.eclipse.emf.ecore.EObject v)
           
static org.eclipse.emf.ecore.EObject createCopyAndInsert(org.eclipse.emf.ecore.EObject oldObject, org.eclipse.emf.ecore.EObject newParent)
          creates a deep Copy and also copies xmi ids This method can be used if the copy should be insertet into newParent
static org.eclipse.emf.ecore.resource.Resource createEmptyResource(org.eclipse.emf.ecore.resource.ResourceSet rsSet, java.lang.String pluginId)
           
static void deleteViewInResource(org.eclipse.emf.ecore.xmi.XMLResource projectResource, org.eclipse.emf.ecore.EObject e)
           
static org.eclipse.gef.EditPart findEditPart(org.eclipse.gmf.runtime.notation.View view, org.eclipse.gmf.runtime.diagram.ui.resources.editor.parts.DiagramDocumentEditor dawnDiagramEditor)
          finds EditPart from a View
static org.eclipse.gef.EditPart findEditPart(org.eclipse.gmf.runtime.notation.View view, org.eclipse.gef.EditPartViewer viewer)
           
static org.eclipse.gef.EditPart findEditPartByXMIId(org.eclipse.gmf.runtime.notation.View view, org.eclipse.gmf.runtime.diagram.ui.resources.editor.parts.DiagramDocumentEditor dawnDiagramEditor)
           
static org.eclipse.gmf.runtime.notation.Diagram getDiagramFromResource(org.eclipse.emf.ecore.resource.Resource res)
          returns the diagram from the resource if no diagram can be found it returns null.
static java.lang.String getLocationFromResource(org.eclipse.emf.ecore.resource.Resource r)
           
static org.eclipse.emf.ecore.EObject getSameEObjectFromOtherResource(org.eclipse.emf.ecore.EObject e, org.eclipse.emf.ecore.xmi.XMLResource resource)
          returns the same Object in the other resource.
static java.lang.String getXmiId(org.eclipse.emf.ecore.EObject eObject)
           
static java.lang.String getXmiId(org.eclipse.emf.ecore.EObject eObject, org.eclipse.emf.ecore.resource.Resource xmiResource)
           
static boolean isObjectInResource(org.eclipse.emf.ecore.resource.Resource res, org.eclipse.emf.ecore.EObject element)
          checks if an element with element's id exists in the give resource
static org.eclipse.emf.ecore.resource.Resource loadFromFile(java.lang.String file, org.eclipse.emf.ecore.resource.ResourceSet rsSet)
           
static org.eclipse.emf.ecore.resource.Resource loadFromXML(java.lang.String xml, org.eclipse.emf.ecore.resource.ResourceSet rsSet)
           
static org.eclipse.emf.ecore.resource.Resource loadResourceFromFileString(java.lang.String filePath, org.eclipse.emf.ecore.resource.ResourceSet rsSet)
           
static boolean objectsHaveChanged(java.lang.Object serverO, java.lang.Object clientO)
          finds changed objects
static void printEObject(org.eclipse.emf.ecore.EObject o, int level)
           
static void printEObjectFull(org.eclipse.emf.ecore.EObject o, int level)
           
static void printEObjectFullSysout(org.eclipse.emf.ecore.EObject o, int level)
           
static void printResource(org.eclipse.emf.ecore.resource.Resource r)
           
static void printResourceSysout(org.eclipse.emf.ecore.resource.Resource r)
           
static java.lang.String readFromFile(java.lang.String filePath)
           
static java.lang.String resourceToString(org.eclipse.emf.ecore.resource.Resource res)
           
static java.lang.String saveToXML(org.eclipse.emf.ecore.xmi.XMLResource resource)
           
static void setXmiId(org.eclipse.emf.ecore.EObject eObject, java.lang.String id)
           
static void setXmiId(org.eclipse.emf.ecore.EObject v, org.eclipse.emf.ecore.xmi.XMLResource oldResource)
          sets the objects id in the old resource to the new resource
static void updateElement(org.eclipse.emf.ecore.EObject oldElement, org.eclipse.emf.ecore.EObject newElement)
          Deprecated. 
static void updateEObject(org.eclipse.emf.ecore.EObject leftObject, org.eclipse.emf.ecore.EObject rightObject)
           
static void updateReference(org.eclipse.emf.ecore.EObject leftParent, org.eclipse.emf.ecore.EObject rightParent, org.eclipse.emf.ecore.EReference reference)
           
static void writeToFile(java.lang.String path, java.lang.String xml)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

gmfResourceWithEMF_0Objects

public static java.lang.String gmfResourceWithEMF_0Objects

gmfResourceWithEMF_0ObjectsTEST

public static java.lang.String gmfResourceWithEMF_0ObjectsTEST
Constructor Detail

ResourceHelper

public ResourceHelper()
Method Detail

getXmiId

public static java.lang.String getXmiId(org.eclipse.emf.ecore.EObject eObject)

getXmiId

public static java.lang.String getXmiId(org.eclipse.emf.ecore.EObject eObject,
                                        org.eclipse.emf.ecore.resource.Resource xmiResource)

setXmiId

public static void setXmiId(org.eclipse.emf.ecore.EObject eObject,
                            java.lang.String id)

resourceToString

public static java.lang.String resourceToString(org.eclipse.emf.ecore.resource.Resource res)

loadFromFile

public static org.eclipse.emf.ecore.resource.Resource loadFromFile(java.lang.String file,
                                                                   org.eclipse.emf.ecore.resource.ResourceSet rsSet)

writeToFile

public static void writeToFile(java.lang.String path,
                               java.lang.String xml)
                        throws java.io.IOException
Throws:
java.io.IOException

saveToXML

public static java.lang.String saveToXML(org.eclipse.emf.ecore.xmi.XMLResource resource)
                                  throws java.io.IOException
Throws:
java.io.IOException

loadFromXML

public static org.eclipse.emf.ecore.resource.Resource loadFromXML(java.lang.String xml,
                                                                  org.eclipse.emf.ecore.resource.ResourceSet rsSet)
                                                           throws java.io.IOException
Throws:
java.io.IOException

getDiagramFromResource

public static org.eclipse.gmf.runtime.notation.Diagram getDiagramFromResource(org.eclipse.emf.ecore.resource.Resource res)
returns the diagram from the resource if no diagram can be found it returns null.

Parameters:
res -
Returns:

areSameObjects

public static boolean areSameObjects(org.eclipse.emf.ecore.EObject oldNode,
                                     org.eclipse.emf.ecore.EObject newNode)
compares two eObjects by there xmi-id whether the are equal or not

Parameters:
oldNode -
newNode -
Returns:
true if xmi-id equal, else otherwise

getSameEObjectFromOtherResource

public static org.eclipse.emf.ecore.EObject getSameEObjectFromOtherResource(org.eclipse.emf.ecore.EObject e,
                                                                            org.eclipse.emf.ecore.xmi.XMLResource resource)
returns the same Object in the other resource. The Object is identified by the xmi ID

Parameters:
e -
resource -
Returns:

objectsHaveChanged

public static boolean objectsHaveChanged(java.lang.Object serverO,
                                         java.lang.Object clientO)
finds changed objects

Parameters:
serverO -
clientO -
Returns:

loadResourceFromFileString

public static org.eclipse.emf.ecore.resource.Resource loadResourceFromFileString(java.lang.String filePath,
                                                                                 org.eclipse.emf.ecore.resource.ResourceSet rsSet)
                                                                          throws java.io.IOException
Throws:
java.io.IOException

readFromFile

public static java.lang.String readFromFile(java.lang.String filePath)
                                     throws java.io.IOException
Throws:
java.io.IOException

copyXmiId

public static void copyXmiId(org.eclipse.emf.ecore.EObject oldElement,
                             org.eclipse.emf.ecore.EObject newElement)
copies the XMI-id from oldElement to new Element

Parameters:
newElement -
oldElement -

setXmiId

public static void setXmiId(org.eclipse.emf.ecore.EObject v,
                            org.eclipse.emf.ecore.xmi.XMLResource oldResource)
sets the objects id in the old resource to the new resource

Parameters:
v -
oldResource -

createCopyAndInsert

public static org.eclipse.emf.ecore.EObject createCopyAndInsert(org.eclipse.emf.ecore.EObject oldObject,
                                                                org.eclipse.emf.ecore.EObject newParent)
creates a deep Copy and also copies xmi ids This method can be used if the copy should be insertet into newParent

Parameters:
oldObject -
newParent -
Returns:

createCopy

public static org.eclipse.emf.ecore.EObject createCopy(org.eclipse.emf.ecore.EObject v)

copyXmiIds

public static void copyXmiIds(org.eclipse.emf.ecore.EObject oldObject,
                              org.eclipse.emf.ecore.EObject newObject)
This method provides deep copying of all childrens xmi ids from oldObject to newObject

Parameters:
oldObject -
newObject -

updateElement

@Deprecated
public static void updateElement(org.eclipse.emf.ecore.EObject oldElement,
                                            org.eclipse.emf.ecore.EObject newElement)
Deprecated. 

this Method copies the values from one Element to the other curretnly only for attributes and not for references

Parameters:
element -
element2 -

createEmptyResource

public static org.eclipse.emf.ecore.resource.Resource createEmptyResource(org.eclipse.emf.ecore.resource.ResourceSet rsSet,
                                                                          java.lang.String pluginId)
                                                                   throws java.io.IOException
Throws:
java.io.IOException

addViewToResource

public static void addViewToResource(org.eclipse.emf.ecore.xmi.XMLResource projectResource,
                                     org.eclipse.gmf.runtime.notation.View view)
This method add a view to the resource and copies all xmid ids. In the end the new resource will contain an exact copy of the given view.

Parameters:
projectResource -
view -

changeViewInResource

public static void changeViewInResource(org.eclipse.emf.ecore.EObject leftObject,
                                        org.eclipse.gmf.runtime.notation.View rightObject)
changes the leftObject to the values of rightObject leftObject=rightObject

Parameters:
leftObject -
newObject -

updateEObject

public static void updateEObject(org.eclipse.emf.ecore.EObject leftObject,
                                 org.eclipse.emf.ecore.EObject rightObject)
                          throws EClassIncompatibleException
Parameters:
leftObject -
rightObject -
Throws:
EClassIncompatibleException

updateReference

public static void updateReference(org.eclipse.emf.ecore.EObject leftParent,
                                   org.eclipse.emf.ecore.EObject rightParent,
                                   org.eclipse.emf.ecore.EReference reference)
                            throws EClassIncompatibleException
Throws:
EClassIncompatibleException

deleteViewInResource

public static void deleteViewInResource(org.eclipse.emf.ecore.xmi.XMLResource projectResource,
                                        org.eclipse.emf.ecore.EObject e)

addElementToContainer

public static void addElementToContainer(org.eclipse.emf.ecore.EObject element,
                                         org.eclipse.emf.ecore.EObject container,
                                         org.eclipse.emf.ecore.EStructuralFeature containingFeature)

isObjectInResource

public static boolean isObjectInResource(org.eclipse.emf.ecore.resource.Resource res,
                                         org.eclipse.emf.ecore.EObject element)
checks if an element with element's id exists in the give resource

Parameters:
res -
element -
Returns:

printResource

public static void printResource(org.eclipse.emf.ecore.resource.Resource r)

printResourceSysout

public static void printResourceSysout(org.eclipse.emf.ecore.resource.Resource r)

printEObject

public static void printEObject(org.eclipse.emf.ecore.EObject o,
                                int level)

printEObjectFull

public static void printEObjectFull(org.eclipse.emf.ecore.EObject o,
                                    int level)

printEObjectFullSysout

public static void printEObjectFullSysout(org.eclipse.emf.ecore.EObject o,
                                          int level)

getLocationFromResource

public static java.lang.String getLocationFromResource(org.eclipse.emf.ecore.resource.Resource r)
                                                throws java.net.MalformedURLException,
                                                       java.io.IOException
Throws:
java.net.MalformedURLException
java.io.IOException

findEditPart

public static org.eclipse.gef.EditPart findEditPart(org.eclipse.gmf.runtime.notation.View view,
                                                    org.eclipse.gmf.runtime.diagram.ui.resources.editor.parts.DiagramDocumentEditor dawnDiagramEditor)
finds EditPart from a View

Parameters:
view -
dawnDiagramEditor -
Returns:

findEditPart

public static org.eclipse.gef.EditPart findEditPart(org.eclipse.gmf.runtime.notation.View view,
                                                    org.eclipse.gef.EditPartViewer viewer)

findEditPartByXMIId

public static org.eclipse.gef.EditPart findEditPartByXMIId(org.eclipse.gmf.runtime.notation.View view,
                                                           org.eclipse.gmf.runtime.diagram.ui.resources.editor.parts.DiagramDocumentEditor dawnDiagramEditor)
Parameters:
view -
dawnDiagramEditor -
Returns: