Class ResourceUIUtil
java.lang.Object
org.eclipse.emf.compare.rcp.ui.internal.util.ResourceUIUtil
This class will be used to provide various utilities aimed at NotLoadedFragment manipulation.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
ID of the graph of EMF resources used by EMFCompare to compute the logical model. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic IMergeViewerItem
addNewContainerForNotLoadedFragmentMatches
(Collection<IMergeViewerItem> items, IMergeViewer.MergeViewerSide side, Comparison comparison, AdapterFactory adapterFactory) Adds a new parent container to the given list of IMergeViewerItems if needed and returns it.static boolean
Check if the given list of TreeNodes contains at least two nodes that have NotLoadedFragmentMatch for data.static IMergeViewerItem
createItemForNotLoadedFragmentMatch
(Match match, IMergeViewer.MergeViewerSide side, Comparison comparison, AdapterFactory adapterFactory) Constructs aNotLoadedFragmentMatch
from the givenMatch
and then return theIMergeViewerItem
corresponding to this NotLoadedFragmentMatch.static Collection<Match>
getChildrenMatchWithNotLoadedParent
(Comparison comparison, Match match, IMergeViewer.MergeViewerSide side) Filters, from the root matches of the given comparison, those who will children matches of the given match if all fragments of the whole models involved in comparison had been loaded, for the given side of the comparison.static ResourceSet
getDataResourceSet
(Match match) Get the Resource's ResourceSet of the data associated to the given Match.static ResourceSet
getDataResourceSet
(Match match, IMergeViewer.MergeViewerSide side) Get the Resource's ResourceSet of the data associated to the given Match, and for the given side of the comparison.static URI
getDataURI
(Match match) Get the Resource's URI of the data associated to the given Matchstatic URI
getDataURI
(Match match, IMergeViewer.MergeViewerSide side) Get the Resource's URI of the data associated to the given Match, and for the given side of the comparison. .static Collection<URI>
getDataURIs
(Collection<Match> matches, IMergeViewer.MergeViewerSide side) Get the Resource's URIs of the data associated to the given list of Matches.static EObject
getEObjectParent
(ResourceSet rs, URI uri) Get the first loaded EObject parent of the given resource (represented by its URI) contained in the given ResourceSet.static Collection<Match>
Get from the given list ofIMergeViewerItem
s, the NotLoadedFragmentMatchs.static Resource
getParent
(ResourceSet rs, URI uri) Get the parent of the given resource (represented by its URI) contained in the given ResourceSet.static URI
getParentResourceURI
(ResourceSet rs, URI uri) Get the first loaded parent resource URI of the given resource (represented by its URI) contained in the given ResourceSet.static String
Get the resource's name associated with the data of the given NotLoadedFragmentMatch.static IGraphView<URI>
Get the graph of resources' URI for the models involved in the current comparison.static URI
getRootResourceURI
(URI uri) Get the root resource of the whole model that contains the given fragment (represented by its uri).static TreeNode
getTreeNode
(Collection<TreeNode> nodes, Match match) Search from the given list of TreeNodes (and recursively on its children), the one that is associated to the given Match.static TreeNode
getTreeNodeFromURI
(Collection<TreeNode> nodes, URI uri) Get from the given list of TreeNodes, the one that has its data's resource's URI (TreeNode -> Match -> EObject -> Resource -> URI) corresponding to the given URI.static boolean
isChildOf
(URI uri, Collection<URI> uris) Check if the given URI is a child (directly or not) of one of the given list of URIs.static boolean
isFirstLevelFragment
(URI uri) Check if the given URI corresponds to a fragment of model that is at the first level of the model, in other words a fragment that is directly under a root resource.static boolean
isFragment
(URI uri) Check if the given URI correspond to a fragment of model.static boolean
isFragment
(Match rootMatch, IMergeViewer.MergeViewerSide side) Check if the given match is a root match of its comparison model and is a fragment.static boolean
isRootResource
(URI uri) Check if the given URI correspond to the root resource of a model.
-
Field Details
-
RESOURCES_GRAPH_ID
ID of the graph of EMF resources used by EMFCompare to compute the logical model.- See Also:
-
-
Constructor Details
-
ResourceUIUtil
public ResourceUIUtil()
-
-
Method Details
-
getResourcesURIGraph
Get the graph of resources' URI for the models involved in the current comparison.- Returns:
- the graph if it exists,
null
otherwise.
-
isRootResource
Check if the given URI correspond to the root resource of a model. In this case a root resource is a piece of a whole model that is not a fragment of the model.- Parameters:
uri
- the given URI.- Returns:
true
if the given URI is root resource of a model,false
otherwise.
-
isFragment
Check if the given URI correspond to a fragment of model. In this case a fragment is a piece of a whole model that is not the root resource of the model.- Parameters:
uri
- the given URI.- Returns:
true
if the given URI is a fragment of a model,false
otherwise.
-
isFragment
Check if the given match is a root match of its comparison model and is a fragment. In this case a fragment is a piece of a whole model that is not the root resource of the model.- Parameters:
rootMatch
- the given match.side
- the side for which we want to know if it is a fragment or not.- Returns:
true
if the given match is a root match of its comparison model and is a fragment,false
otherwise.
-
isFirstLevelFragment
Check if the given URI corresponds to a fragment of model that is at the first level of the model, in other words a fragment that is directly under a root resource. In this case a fragment is a piece of a whole model that is not the root resource of the model.If the given fragment (represented by the given URI) has several parents, this method will return
false
.- Parameters:
uri
- the given URI.- Returns:
true
if the given URI is a fragment of a model,false
otherwise.
-
getRootResourceURI
Get the root resource of the whole model that contains the given fragment (represented by its uri).If at some point of the process a fragment has several parents, this method will return
null
.- Parameters:
uri
- the given URI.- Returns:
- the root resource of the whole model that contains the given fragment if found,
null
otherwise.
-
getParentResourceURI
Get the first loaded parent resource URI of the given resource (represented by its URI) contained in the given ResourceSet.If at some point of the process the current resource (represented by its URI) has several parents, this method will return
null
.- Parameters:
rs
- the ResourceSet in which the first loaded parent must be found.uri
- the URI of the resource for which we want to get its first loaded parent.- Returns:
- the URI of the first loaded resource parent if found,
null
otherwise.
-
getParent
Get the parent of the given resource (represented by its URI) contained in the given ResourceSet.If the given resource (represented by its URI) has several parents, this method will return
null
.- Parameters:
rs
- the ResourceSet in which the parent must be found.uri
- the URI of the resource for which we want to get its parent.- Returns:
- the parent of the given resource (represented by its URI) if found,
null
otherwise.
-
getEObjectParent
Get the first loaded EObject parent of the given resource (represented by its URI) contained in the given ResourceSet.If at some point of the process the current resource (represented by its URI) has several parents, this method will return
null
.- Parameters:
rs
- the ResourceSet in which the first loaded parent must be found.uri
- the URI of the resource for which we want to get its first loaded parent.- Returns:
- the first loaded EObject parent of the given resource (represented by its URI) if found,
null
otherwise.
-
getTreeNode
Search from the given list of TreeNodes (and recursively on its children), the one that is associated to the given Match.- Parameters:
nodes
- the given list of TreeNodes.match
- the given Match.- Returns:
- the TreeNode that is associated to the given Match.
-
getTreeNodeFromURI
Get from the given list of TreeNodes, the one that has its data's resource's URI (TreeNode -> Match -> EObject -> Resource -> URI) corresponding to the given URI.- Parameters:
nodes
- the given list of TreeNodes.uri
- the given URI.- Returns:
- the TreeNode that has its data's resource's URI corresponding to the given URI, or null if no one match.
-
getDataURI
Get the Resource's URI of the data associated to the given Match- Parameters:
match
- the given Match.- Returns:
- the Resource's URI of the data associated to the given Match.
-
getDataURIs
public static Collection<URI> getDataURIs(Collection<Match> matches, IMergeViewer.MergeViewerSide side) Get the Resource's URIs of the data associated to the given list of Matches.- Parameters:
matches
- the given list of Matches.side
- the given side of the comparison.- Returns:
- the Resource's URIs of the data associated to the given list of Matches.
-
getDataURI
Get the Resource's URI of the data associated to the given Match, and for the given side of the comparison. .- Parameters:
match
- the given Match.side
- the given side of the comparison.- Returns:
- the Resource's URI of the data associated to the given Match.
-
getDataResourceSet
Get the Resource's ResourceSet of the data associated to the given Match.- Parameters:
match
- the given Match.- Returns:
- the Resource's ResourceSet of the data associated to the given Match.
-
getDataResourceSet
Get the Resource's ResourceSet of the data associated to the given Match, and for the given side of the comparison.- Parameters:
match
- the given Match.side
- the given side of the comparison.- Returns:
- the Resource's ResourceSet of the data associated to the given Match.
-
containsNotLoadedFragmentNodes
Check if the given list of TreeNodes contains at least two nodes that have NotLoadedFragmentMatch for data.- Parameters:
nodes
- the given list of TreeNodes.- Returns:
true
if the given list of TreeNodes contains at least two nodes that have NotLoadedFragmentMatch for data, false otherwise.
-
getNotLoadedFragmentMatches
Get from the given list ofIMergeViewerItem
s, the NotLoadedFragmentMatchs.- Parameters:
items
- the given list of IMergeViewerItems.- Returns:
- a list of Match.
-
getResourceName
Get the resource's name associated with the data of the given NotLoadedFragmentMatch. If it is a NotLoadedFragmentMatch containing others NotLoadedFragmentMatch, then it returns an empty string.- Parameters:
match
- the given NotLoadedFragmentMatch.- Returns:
- the resource's name associated with the data of the given NotLoadedFragmentMatch.
-
getChildrenMatchWithNotLoadedParent
public static Collection<Match> getChildrenMatchWithNotLoadedParent(Comparison comparison, Match match, IMergeViewer.MergeViewerSide side) Filters, from the root matches of the given comparison, those who will children matches of the given match if all fragments of the whole models involved in comparison had been loaded, for the given side of the comparison.- Parameters:
comparison
- the given comparison, cannot benull
.match
- the given match, can benull
.side
- the given side of the comparison.- Returns:
- a list of Matches.
-
isChildOf
Check if the given URI is a child (directly or not) of one of the given list of URIs.- Parameters:
uri
- the given URI.uris
- the given list of URIs.- Returns:
- true if the given URI is a child (directly or not) of one of the given list of URIs, false otherwise.
-
createItemForNotLoadedFragmentMatch
public static IMergeViewerItem createItemForNotLoadedFragmentMatch(Match match, IMergeViewer.MergeViewerSide side, Comparison comparison, AdapterFactory adapterFactory) Constructs aNotLoadedFragmentMatch
from the givenMatch
and then return theIMergeViewerItem
corresponding to this NotLoadedFragmentMatch.- Parameters:
match
- the given Match.side
- the side of the Match.comparison
- the comparison object that contains the Match.adapterFactory
- the adapter factory used to create the merge viewer item.- Returns:
- an IMergeViewerItem.
-
addNewContainerForNotLoadedFragmentMatches
public static IMergeViewerItem addNewContainerForNotLoadedFragmentMatches(Collection<IMergeViewerItem> items, IMergeViewer.MergeViewerSide side, Comparison comparison, AdapterFactory adapterFactory) Adds a new parent container to the given list of IMergeViewerItems if needed and returns it. If the given items don't need a new parent, return null.- Parameters:
items
- the given IMergeViewerItems.side
- the side of the Match.comparison
- the comparison object that contains the Match.adapterFactory
- the adapter factory used to create the merge viewer item.- Returns:
- an IMergeViewerItem, or null.
-