Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 577d2f95928a441baed6f81594f13ff36f298730 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
/*******************************************************************************
 * Copyright (c) 2000, 2009 IBM Corporation and others.
 *
 * This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License 2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.team.ui.synchronize;

import org.eclipse.compare.CompareConfiguration;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IExecutableExtension;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.preference.PreferencePage;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.team.core.TeamException;
import org.eclipse.ui.IMemento;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.part.IPageBookViewPage;

/**
 * A synchronize participant is a visual component that can be displayed within any
 * control (e.g. view, editor, dialog).  Typically a participant is used to show changes between
 * local resources and variant states of those resources and allows the user to perform actions
 * to manipulate the changes.
 * <p>
 * This class does not mandate how the synchronization state is displayed, but instead provides
 * the accessors that clients would use to create a visual instance of the this participant.
 * </p><p>
 * A participant can display multiple instances of its synchronization state to the user via the creation
 * of a page {@link #createPage(ISynchronizePageConfiguration)} and
 * clients can decide where to display the page. For example, the synchronize view is an example
 * of a client that displays a participant in a view. However, you can imagine that a client may
 * also want to display this state in a wizard or dialog instead.
 * </p><p>
 * When a participant is registered with the {@link ISynchronizeManager} it will automatically display
 * in the <i>Synchronize View</i> and if the participant extension point
 * enabled <code>synchronizeWizards</code> it will also appear in the global synchronize action
 * toolbar.
 * <p>
 * A participant is added to the workbench as follows:</p>
 * <ul>
 * <li>A <code>synchronizeParticipant</code> extension is contributed to
 * the team registry. This extension defines the participant id, name, icon, type, and
 * participant class.
 * <li>A user via a wizard provided by the <code>synchronizeWizards</code> extension point
 * or client code, creates a participant instance and registers it with the
 * synchronize manager. It then appears in the synchronize view.
 * <li>A synchronization can be persistent and thus re-initialized at startup.
 * <li>A pinned participant will only be removed from the synchronize manager if it is un-pinned.
 * </ul>
 * <p>
 * Once a participant is added to the synchronize manager its lifecycle will be managed. On shutdown if
 * the participant is persistable, the participant will be asked to persist state via
 * the <code>saveState()</code> method. At startup the <code>init()</code> method is called
 * with a handle to the state that was saved. The dispose method is called when the participant is
 * removed from the manager and at shutdown.
 * </p>
 * @see ISynchronizeView
 * @see ISynchronizeManager
 * @see AbstractSynchronizeParticipant
 * @since 3.0
 * @noimplement Clients are not intended to implement this interface. Instead,
 *              subclass {@link AbstractSynchronizeParticipant}.
 */
public interface ISynchronizeParticipant extends IExecutableExtension, IAdaptable {

	/**
	 * A property constant that can be used to indicate that the content of this participant
	 * has changed. This is a general event that can be used to indicate to the user that there
	 * is a change in state for the participant. In general, the values associated with the event do not have
	 * any meaning.
	 *
	 * @see #addPropertyChangeListener(IPropertyChangeListener)
	 */
	public static final String P_CONTENT = "org.eclipse.team.ui.content"; //$NON-NLS-1$

	/**
	 * Returns the unique id that identified the <i>type</i> of this
	 * synchronize participant. The synchronize manager supports registering
	 * several instances of the same participant type.
	 *
	 * @return the unique id that identified the <i>type</i> of this
	 * synchronize participant.
	 */
	public String getId();

	/**
	 * Returns the instance id that identified the unique instance of this
	 * participant. The synchronize manager supports registering
	 * several instances of the same participant type and this id is used
	 * to differentiate between them.
	 *
	 * @return  the instance id that identified the unique instance of this
	 * participant or <code>null</code> if this participant doesn't support
	 * multiple instances.
	 */
	public String getSecondaryId();

	/**
	 * Returns the name of this synchronize participant. This name is displayed to the user.
	 *
	 * @return the name of this synchronize participant
	 */
	public String getName();

	/**
	 * Returns an image descriptor for this synchronize participant, or <code>null</code>
	 * if none.
	 *
	 * @return an image descriptor for this synchronize participant, or <code>null</code>
	 * if none
	 */
	public ImageDescriptor getImageDescriptor();

	/**
	 * Returns if this participant is pinned. Pinned participants will only be removed from the
	 * synchronize manager until they are un-pinned.
	 *
	 * @return <code>true</code> if this participant is pinned and <code>false</code>
	 * otherwise.
	 */
	public boolean isPinned();

	/**
	 * Sets whether this participant is pinned.
	 *
	 * @param pinned sets if the participant is pinned.
	 */
	public void setPinned(boolean pinned);

	/**
	 * Creates the configuration for the participant page. The configuration controls the
	 * options for displaying the participant. The configuration used to initialize the page
	 * when {@link #createPage(ISynchronizePageConfiguration)} is called and as such
	 * can be used to pre-configure visual properties of the displayed page.
	 *
	 * @return the configuration for the participant page.
	 */
	public ISynchronizePageConfiguration createPageConfiguration();

	/**
	 * Creates and returns a new page for this synchronize participant. The
	 * page is displayed using the parameters from the configuration. For example,
	 * the configuration defines the context in which the page is shown, via the
	 * {@link ISynchronizePageSite}.
	 *
	 * @param configuration used to initialize the page
	 * @return a page book view page representation of this synchronize
	 * participant
	 */
	public IPageBookViewPage createPage(ISynchronizePageConfiguration configuration);

	/**
	 * Runs the participants action. Typically this would be some action to refresh the synchronization
	 * state of the participant. This action is run from the global synchronize drop-down.
	 *
	 * @param part the part in which the action is run or <code>null</code> if the action
	 * is not being run in a workbench part.
	 */
	public void run(IWorkbenchPart part);

	/**
	 * Initializes this participant with the given participant state.
	 * A memento is passed to the participant which contains a snapshot
	 * of the participants state from a previous session.
	 * <p>
	 * This method is automatically called by the team plugin shortly after
	 * participant construction. It marks the start of the views
	 * lifecycle. Clients must not call this method.
	 * </p>
	 * @param secondaryId the secondayId of this participant instance or <code>null</code>
	 * if this participant doesn't support multiple instances.
	 * @param memento the participant state or <code>null</code> if there
	 * is no previous saved state
	 * @exception PartInitException if this participant was not initialized
	 * successfully
	 */
	public void init(String secondaryId, IMemento memento) throws PartInitException;

	/**
	 * Disposes of this synchronize participant and is called to free the
	 * resources associated with a participant. When a participant is added
	 * to the {@link ISynchronizeManager} this method is called when the
	 * manager is shutdown or the participant is removed from the manager.
	 * <p>
	 * Within this method a participant may release any resources, fonts, images, etc.
	 * held by this part.  It is also very important to remove all listeners.
	 * </p><p>
	 * Clients should not call this method (the synchronize manager calls this
	 * method at appropriate times).
	 * </p>
	 */
	public void dispose();

	/**
	 * Saves the participants object state within the memento. This state
	 * will be available when the participant is restored via <code>init</code>.
	 * <p>
	 * This method can be called multiple times during the lifetime of the
	 * participant object.
	 * </p>
	 * @param memento a memento to receive the object state
	 */
	public void saveState(IMemento memento);

	/**
	 * Adds a listener for changes to properties of this synchronize
	 * participant. Has no effect if an identical listener is already
	 * registered.
	 * <p>
	 * The changes supported by the synchronize view are as follows:
	 * </p>
	 * <ul>
	 * <li><code>IBasicPropertyConstants.P_TEXT</code>- indicates the name
	 * of a synchronize participant has changed</li>
	 * <li><code>IBasicPropertyConstants.P_IMAGE</code>- indicates the
	 * image of a synchronize participant has changed</li>
	 * </ul>
	 * <p>
	 * Clients may define additional properties as required.
	 * </p>
	 * @param listener a property change listener
	 */
	public void addPropertyChangeListener(IPropertyChangeListener listener);

	/**
	 * Removes the given property listener from this synchronize participant.
	 * Has no effect if an identical listener is not already registered.
	 *
	 * @param listener a property listener
	 */
	public void removePropertyChangeListener(IPropertyChangeListener listener);

	/**
	 * Prepare the given element and compare configuration for use with a compare editor
	 * input.
	 * @param element the sync model element whose contents are about to be displayed to the user
	 * 		in a compare editor or compare dialog
	 * @param configuration the compare configuration that will be used to configure the compare editor or dialog
	 * @param monitor a progress monitor that can be used if contacting a server to prepare the element and configuration
	 * @throws TeamException if an error occurred that should prevent the display of the compare editor containing
	 * 		the element
	 *
	 * @since 3.1
	 */
	public void prepareCompareInput(
	        ISynchronizeModelElement element,
	        CompareConfiguration configuration,
	        IProgressMonitor monitor)
				throws TeamException;

    /**
     * Return the list of preference pages that are associated with this participant
     * @return the list of preference pages that are associated with this participant
     * @since 3.1
     */
    public PreferencePage[] getPreferencePages();

	/**
	 * Returns the help context id of this participant.
	 *
	 * @return the help context id of this participant
	 * @since 3.5
	 */
	public String getHelpContextId();
}

Back to the top