KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > team > ui > mapping > ISynchronizationCompareAdapter


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
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  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.team.ui.mapping;
12
13 import org.eclipse.compare.structuremergeviewer.ICompareInput;
14 import org.eclipse.core.resources.mapping.ResourceMapping;
15 import org.eclipse.core.runtime.CoreException;
16 import org.eclipse.core.runtime.IProgressMonitor;
17 import org.eclipse.jface.resource.ImageDescriptor;
18 import org.eclipse.team.core.mapping.ISynchronizationContext;
19 import org.eclipse.ui.IMemento;
20
21 /**
22  * The compare adapter provides compare support for the model objects
23  * associated with a model provider.
24  * <p>
25  * Clients should not implement this interface but should subclass {@link SynchronizationCompareAdapter}
26  * instead.
27  *
28  * @since 3.2
29  */

30 public interface ISynchronizationCompareAdapter {
31     
32     /**
33      * Return whether their is a compare input associated with the given object.
34      * In other words, return <code>true</code> if {@link #asCompareInput(ISynchronizationContext, Object) }
35      * would return a value and <code>false</code> if it would return <code>null</code>.
36      * @param context the synchronization context
37      * @param object the object.
38      * @return whether their is a compare input associated with the given object
39      */

40     boolean hasCompareInput(ISynchronizationContext context, Object JavaDoc object);
41     
42     /**
43      * Return a compare input for the given model object. Creation of the input
44      * should be fast. Synchronization information calculations that are longer
45      * running should be performed in the
46      * {@link ISynchronizationCompareInput#prepareInput(org.eclipse.compare.CompareConfiguration, IProgressMonitor)}
47      * method. Clients should call this method once per context before obtaining
48      * any compare inputs from the adapter. A <code>null</code> should be
49      * returned if the model object is in-sync or otherwise cannot be compared.
50      * <p>
51      * Model providers can choose to return an instance of {@link ISynchronizationCompareInput}
52      * if they wish to tailor the compare editor used to show the compare input
53      * of provide an {@link SaveableComparison} in order to have more control
54      * over the save lifecycle during a merge.
55      *
56      * @param context the synchronization context
57      * @param o the model object
58      * @return a compare input or <code>null</code> if the model object is
59      * in-sync or otherwise cannot be compared.
60      */

61     ICompareInput asCompareInput(ISynchronizationContext context, Object JavaDoc o);
62     
63     /**
64      * Get the name associated with the model object of the given mapping.
65      * This name should be suitable for display to the user.
66      * @param mapping the mapping
67      * @return the name of the mapping's model object
68      */

69     public String JavaDoc getName(ResourceMapping mapping);
70     
71     /**
72      * Get the path associated with the model object
73      * of the given mapping.
74      * This path should be suitable for display to the user.
75      * @param mapping the mapping
76      * @return the path of the model object of the mapping
77      */

78     public String JavaDoc getPathString(ResourceMapping mapping);
79     
80     /**
81      * Return an image descriptor that can be displayed as an icon for the
82      * model object of the given resource mapping.
83      * @param mapping the mapping
84      * @return an image descriptor that can be displayed as an icon for the
85      * model object of the given resource mapping
86      * @since 3.3
87      */

88     public ImageDescriptor getImageDescriptor(ResourceMapping mapping);
89     
90     /**
91      * Save the given resource mappings from this adapters
92      * model provider into the given memento in a form
93      * that can be restored at a future time.
94      * @param mappings the resource mappings to save
95      * @param memento the memento where the mappings should be saved
96      */

97     public void save(ResourceMapping[] mappings, IMemento memento);
98     
99     /**
100      * Restore the previously saved resource mappings.
101      * @param memento a memento
102      * @return the mappings restored from the given memento
103      */

104     public ResourceMapping[] restore(IMemento memento);
105
106     /**
107      * Return the synchronization state of the resource mapping with respect to
108      * the given team state provider. This method is invoked from instances of
109      * {@link ITeamStateProvider} when the synchronization state description for
110      * an element is requested. This method can return -1 to indicate that the state
111      * calculation should be performed using the resources that the element maps to.
112      *
113      * @param provider
114      * the team state provider
115      * @param mapping
116      * the element
117      * @param stateMask
118      * the state mask that indicates which state flags are desired
119      * @param monitor
120      * a progress monitor
121      * @return the synchronization state of the element or -1 if the calculation
122      * of the state should be done using the resources of the mapping.
123      * @throws CoreException
124      *
125      * @since 3.3
126      */

127     public int getSynchronizationState(ITeamStateProvider provider, ResourceMapping mapping, int stateMask, IProgressMonitor monitor) throws CoreException;
128     
129 }
130
Popular Tags