Manage selected filters in ContentMergeViewer parts.
[EMFCompare2.git] / plugins / org.eclipse.emf.compare.rcp.ui / src / org / eclipse / emf / compare / rcp / ui / internal / mergeviewer / item / IMergeViewerItem.java
blobfedc9c422dd9c8818d356a3760c8d59021659b1e
1 /*******************************************************************************
2 * Copyright (c) 2012 Obeo.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors:
9 * Obeo - initial API and implementation
10 *******************************************************************************/
11 package org.eclipse.emf.compare.rcp.ui.internal.mergeviewer.item;
13 import com.google.common.base.Predicate;
15 import java.util.Collection;
17 import org.eclipse.emf.common.notify.Adapter;
18 import org.eclipse.emf.compare.Diff;
19 import org.eclipse.emf.compare.rcp.ui.internal.mergeviewer.IMergeViewer.MergeViewerSide;
20 import org.eclipse.emf.compare.rcp.ui.internal.structuremergeviewer.filters.IDifferenceFilter;
22 /**
23 * @author <a href="mailto:mikael.barbero@obeo.fr">Mikael Barbero</a>
25 public interface IMergeViewerItem extends Adapter {
27 Diff getDiff();
29 Object getLeft();
31 Object getRight();
33 Object getAncestor();
35 Object getSideValue(MergeViewerSide side);
37 MergeViewerSide getSide();
39 boolean isInsertionPoint();
41 /**
42 * Returns the parent of this element. If the object is the root of a hierarchy <code>null</code> is
43 * returned.
45 * @return the parent of this element, or <code>null</code> if the element has no parent
47 Container getParent();
49 public static final Predicate<IMergeViewerItem> IS_INSERTION_POINT = new Predicate<IMergeViewerItem>() {
50 public boolean apply(IMergeViewerItem item) {
51 return item.isInsertionPoint();
55 interface Container extends IMergeViewerItem {
56 /**
57 * Returns whether this container has at least one child. In some cases this methods avoids having to
58 * call the potential more costly <code>getChildren</code> method.
60 * @param selectedFilters
61 * the active filters.
62 * @return <code>true</code> if this container has at least one child
64 boolean hasChildren(Collection<IDifferenceFilter> selectedFilters);
66 /**
67 * Returns the children of this container. If this container has no children an empty array is
68 * returned (not <code>null</code>).
70 * @param selectedFilters
71 * the active filters.
72 * @return the children of this container as an array
74 IMergeViewerItem[] getChildren(Collection<IDifferenceFilter> selectedFilters);