Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 8b738501ae16660756b9bb61834d4363c7166493 (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
/*******************************************************************************
 * Copyright (c) 2005 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.subscriber;

import org.eclipse.compare.structuremergeviewer.IDiffElement;
import org.eclipse.team.core.synchronize.*;
import org.eclipse.team.core.synchronize.FastSyncInfoFilter.SyncInfoDirectionFilter;
import org.eclipse.team.internal.ccvs.ui.wizards.GenerateDiffFileWizard;
import org.eclipse.team.internal.ui.synchronize.SyncInfoModelElement;
import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration;
import org.eclipse.team.ui.synchronize.SynchronizeModelOperation;

public class CreatePatchAction extends CVSParticipantAction {

	protected CreatePatchAction(ISynchronizePageConfiguration configuration) {
		super(configuration);
	}

	@Override
	protected SynchronizeModelOperation getSubscriberOperation(ISynchronizePageConfiguration configuration, IDiffElement[] elements) {
		return null;
	}
	
	@Override
	protected FastSyncInfoFilter getSyncInfoFilter() {
		return new SyncInfoDirectionFilter(new int[] {SyncInfo.CONFLICTING, SyncInfo.OUTGOING});
	}

	@Override
	public void runOperation() {
		final SyncInfoSet set = getSyncInfoSet();
		GenerateDiffFileWizard.run(getConfiguration().getSite().getPart(), set.getResources(), false);
	}
	
	/*
	 * Return the selected SyncInfo for which this action is enabled.
	 * 
	 * @return the selected SyncInfo for which this action is enabled.
	 */
	private SyncInfoSet getSyncInfoSet() {
		IDiffElement [] elements= getFilteredDiffElements();
		SyncInfoSet filtered = new SyncInfoSet();
		for (int i = 0; i < elements.length; i++) {
			IDiffElement e = elements[i];
			if (e instanceof SyncInfoModelElement) {
				filtered.add(((SyncInfoModelElement)e).getSyncInfo());
			}
		}
		return filtered;
	}
	
	@Override
	protected String getBundleKeyPrefix() {
		return "GenerateDiffFileAction."; //$NON-NLS-1$
	}
}

Back to the top