org.eclipse.emf.compare.rcp.ui.internal.util

## Class ResourceUIUtil

- java.lang.Object
- - org.eclipse.emf.compare.rcp.ui.internal.util.ResourceUIUtil

    public class ResourceUIUtil
    extends Object

This class will be used to provide various utilities aimed at NotLoadedFragment manipulation.

### Field Summary

Fields
`static String` `RESOURCES_GRAPH_ID` ID of the graph of EMF resources used by EMFCompare to compute the logical model.

### Constructor Summary

Constructors
Constructor and Description
`ResourceUIUtil()`

### Method Summary

All Methods Static Methods Concrete Methods
`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.
`static boolean` `containsNotLoadedFragmentNodes(Collection<TreeNode> nodes)` 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 a `NotLoadedFragmentMatch` from the given `Match` and then return the `IMergeViewerItem` 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 Match
`static 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>` `getNotLoadedFragmentMatches(Collection<IMergeViewerItem> items)` Get from the given list of `IMergeViewerItem`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` `getResourceName(NotLoadedFragmentMatch match)` Get the resource's name associated with the data of the given NotLoadedFragmentMatch.
`static IGraphView<URI>` `getResourcesURIGraph()` 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(Match rootMatch, IMergeViewer.MergeViewerSide side)` Check if the given match is a root match of its comparison model and is a fragment.
`static boolean` `isFragment(URI uri)` Check if the given URI correspond to a fragment of model.
`static boolean` `isRootResource(URI uri)` Check if the given URI correspond to the root resource of a model.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### RESOURCES_GRAPH_ID

    public static final String RESOURCES_GRAPH_ID

ID of the graph of EMF resources used by EMFCompare to compute the logical model.

See Also:
  Constant Field Values

### Constructor Detail

#### ResourceUIUtil

    public ResourceUIUtil()

### Method Detail

#### getResourcesURIGraph

    public static IGraphView<URI> getResourcesURIGraph()

Get the graph of resources' URI for the models involved in the current comparison.

Returns:
  the graph if it exists, `null` otherwise.

#### isRootResource

    public static boolean isRootResource(URI uri)

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

    public static boolean isFragment(URI uri)

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

    public 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. 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

    public 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. 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

    public static URI getRootResourceURI(URI uri)

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

    public 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.

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

    public static Resource getParent(ResourceSet rs,
                                     URI uri)

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

    public 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.

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

    public 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.

Parameters:
  `nodes` - the given list of TreeNodes.
  `match` - the given Match.
Returns:
  the TreeNode that is associated to the given Match.

#### getTreeNodeFromURI

    public 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.

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

    public static URI getDataURI(Match match)

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

    public static 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. .

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

    public static ResourceSet getDataResourceSet(Match match)

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

    public 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.

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

    public static boolean containsNotLoadedFragmentNodes(Collection<TreeNode> nodes)

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

    public static Collection<Match> getNotLoadedFragmentMatches(Collection<IMergeViewerItem> items)

Get from the given list of `IMergeViewerItem`s, the NotLoadedFragmentMatchs.

Parameters:
  `items` - the given list of IMergeViewerItems.
Returns:
  a list of Match.

#### getResourceName

    public static String getResourceName(NotLoadedFragmentMatch match)

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 be `null`.
  `match` - the given match, can be `null`.
  `side` - the given side of the comparison.
Returns:
  a list of Matches.

#### isChildOf

    public 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.

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 a `NotLoadedFragmentMatch` from the given `Match` and then return the `IMergeViewerItem` 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.