Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 4938c3ed423293490b2c18a5e5d0864f81c62bbd (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
/*******************************************************************************
 * Copyright (c) 2006 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.internal.ccvs.ui.mappings;

import org.eclipse.core.resources.mapping.ResourceMapping;
import org.eclipse.team.core.mapping.provider.SynchronizationContext;
import org.eclipse.team.core.subscribers.Subscriber;
import org.eclipse.team.core.subscribers.SubscriberScopeManager;
import org.eclipse.team.internal.ccvs.core.CVSMergeSubscriber;
import org.eclipse.team.internal.ccvs.ui.CVSUIMessages;
import org.eclipse.team.ui.synchronize.ModelSynchronizeParticipant;
import org.eclipse.ui.IWorkbenchPart;

public class ModelMergeOperation extends AbstractModelMergeOperation {

	private final Subscriber subscriber;
	private final boolean attempAutomerge;
	
	/**
	 * Create a merge operation for the given subscriber. The merge operation will cancel the subscriber
	 * when it is no longer needed.
	 * @param part the part
	 * @param mappings the mappings
	 * @param subscriber the subscriber
	 * @param attempAutomerge 
	 */
	public ModelMergeOperation(IWorkbenchPart part, ResourceMapping[] mappings, final CVSMergeSubscriber subscriber, boolean attempAutomerge) {
		super(part, new SubscriberScopeManager(subscriber.getName(), mappings, subscriber, true){
			public void dispose() {
				subscriber.cancel();
				super.dispose();
			}
		}, true);
		this.subscriber = subscriber;
		this.attempAutomerge = attempAutomerge;
	}

	/* (non-Javadoc)
	 * @see org.eclipse.team.ui.operations.ModelParticipantMergeOperation#createMergeContext()
	 */
	protected SynchronizationContext createMergeContext() {
		return MergeSubscriberContext.createContext(getScopeManager(), subscriber);
	}
	
	/* (non-Javadoc)
	 * @see org.eclipse.team.ui.TeamOperation#getJobName()
	 */
	protected String getJobName() {
		return CVSUIMessages.MergeUpdateAction_jobName;
	}
	
	/* (non-Javadoc)
	 * @see org.eclipse.team.internal.ccvs.ui.mappings.AbstractModelMergeOperation#createParticipant()
	 */
	protected ModelSynchronizeParticipant createParticipant() {
		setOwnsManager(false);
		return new ModelMergeParticipant((MergeSubscriberContext)createMergeContext());
	}
	
	protected boolean isPreviewInDialog() {
		return false;
	}
	
	public boolean isPreviewRequested() {
		return !attempAutomerge;
	}

}

Back to the top