Skip to content

Package: DiffMergeModelContext

DiffMergeModelContext

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2011-2014 EclipseSource Muenchen GmbH and others.
3: *
4: * All rights reserved. This program and the accompanying materials
5: * are made available under the terms of the Eclipse Public License 2.0
6: * which accompanies this distribution, and is available at
7: * https://www.eclipse.org/legal/epl-2.0/
8: *
9: * SPDX-License-Identifier: EPL-2.0
10: *
11: * Contributors:
12: * Eugen Neufeld - initial API and implementation
13: ******************************************************************************/
14: package org.eclipse.emf.ecp.diffmerge.spi.context;
15:
16: import java.util.Set;
17:
18: import org.eclipse.emf.ecore.EObject;
19: import org.eclipse.emf.ecp.view.spi.context.ViewModelContext;
20: import org.eclipse.emf.ecp.view.spi.model.VControl;
21: import org.eclipse.emf.ecp.view.spi.model.VDomainModelReference;
22:
23: /**
24: * The {@link DiffMergeModelContext} extends the {@link ViewModelContext} and allows to retrieve two origin objects.
25: *
26: * @see ViewModelContext
27: * @author Eugen Neufeld
28: */
29: public interface DiffMergeModelContext extends ViewModelContext {
30:
31:         /**
32:          * Gets the left model.
33:          *
34:          * @return the left model
35:          */
36:         EObject getLeftModel();
37:
38:         /**
39:          * Gets the right model.
40:          *
41:          * @return the right model
42:          */
43:         EObject getRightModel();
44:
45:         /**
46:          * Checks whether a control has a diff.
47:          *
48:          * @param control the {@link VControl} to check
49:          * @return true if there is a difference
50:          */
51:         boolean hasDiff(VControl control);
52:
53:         /**
54:          * Returns a pair containing the left and right control for the diff.
55:          *
56:          * @param control the control to get the pair for
57:          * @return a pair or null if no diff exists for the provided control
58:          */
59:         ControlPair getPairWithDiff(VControl control);
60:
61:         /**
62:          * Returns the total number of differences.
63:          *
64:          * @return the total number of differences
65:          */
66:         int getTotalNumberOfDiffs();
67:
68:         /**
69:          * Returns the diff index of a control. If the control does not have a diff the index will be -1.
70:          *
71:          * @param control the {@link VControl} to get the index for
72:          * @return the index of the control
73:          */
74:         int getIndexOf(VControl control);
75:
76:         /**
77:          * Returns the control based on the diff index. If the index is less then 0 and greater or equals the total number
78:          * of diff, then a {@link IllegalArgumentException} will be thrown.
79:          *
80:          * @param diffIndex the diff index to get the control for
81:          * @return the {@link VControl}
82:          * @throws IllegalArgumentException thrown if the index is invalid
83:          */
84:         VControl getControl(int diffIndex) throws IllegalArgumentException;
85:
86:         /**
87:          * Returns true if the control already was merged or doesn't have a difference at all.
88:          *
89:          * @param vControl the {@link VControl} to check
90:          * @return true if is merged
91:          */
92:         boolean isControlMerged(VControl vControl);
93:
94:         /**
95:          * Mark a control as merged.
96:          *
97:          * @param vControl the {@link VControl} to be merged
98:          * @param merged true if control is merged, false otherwise
99:          */
100:         void markControl(VControl vControl, boolean merged);
101:
102:         /**
103:          * Returns the set of domainModelReferences which are merged.
104:          *
105:          * @return the set of merged {@link VDomainModelReference VDomainModelReferences}
106:          */
107:         Set<VDomainModelReference> getMergedDomainObjects();
108: }