Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 046ebb85a220b4253459aea59177287e3ed75e94 (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
/*******************************************************************************
 * Copyright (c) 2013 Atos
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     Arthur Daussy - initial implementation
 *******************************************************************************/
package org.eclipse.papyrus.team.collaborative.controlmode.control;

import org.eclipse.gmf.runtime.common.core.command.ICommand;
import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
import org.eclipse.papyrus.infra.services.controlmode.ControlModeRequest;
import org.eclipse.papyrus.infra.services.controlmode.participants.IControlCommandParticipant;
import org.eclipse.papyrus.infra.services.controlmode.participants.IUncontrolCommandParticipant;
import org.eclipse.papyrus.team.collaborative.controlmode.commands.AddFileToCollabSVN;
import org.eclipse.papyrus.team.collaborative.controlmode.commands.SaveCommand;
import org.eclipse.papyrus.team.collaborative.core.utils.CollabUtils;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.ISaveablePart;
import org.eclipse.ui.PlatformUI;


/**
 * The Class SVNControlModeParticipant.
 * This {@link IControlCommandParticipant} provide mean to automatically integrate file generated after a control into a SVN repository
 * WARNING: The {@link IUncontrolCommandParticipant} is not implemented yet
 */
public class SVNControlModeParticipant implements IControlCommandParticipant, IUncontrolCommandParticipant {

	/**
	 * Instantiates a new sVN control mode participant.
	 */
	public SVNControlModeParticipant() {
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.papyrus.controlmode.interfaces.IControlModeParticipant#getID()
	 */
	@Override
	public String getID() {
		return "org.eclipse.papyrus.team.collaborative.core.integration.papyrus.control.SVNControlModeParticipant";
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.papyrus.controlmode.interfaces.IControlModeParticipant#getPriority()
	 */
	@Override
	public int getPriority() {
		return 10000;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.papyrus.controlmode.interfaces.IUncontrolCommandParticipant#provideUnControlCommand(org.eclipse.papyrus.controlmode.request.
	 * ControlModeRequest)
	 */
	@Override
	public boolean provideUnControlCommand(ControlModeRequest request) {
		return CollabUtils.isCollab(request.getTargetObject());
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.papyrus.controlmode.interfaces.IUncontrolCommandParticipant#getPreUncontrolCommand(org.eclipse.papyrus.controlmode.request.
	 * ControlModeRequest)
	 */
	@Override
	public ICommand getPreUncontrolCommand(ControlModeRequest request) {
		// TODO Auto-generated method stub
		return null;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.papyrus.controlmode.interfaces.IUncontrolCommandParticipant#getPostUncontrolCommand(org.eclipse.papyrus.controlmode.request.
	 * ControlModeRequest)
	 */
	@Override
	public ICommand getPostUncontrolCommand(ControlModeRequest request) {
		// TODO Auto-generated method stub
		return null;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.papyrus.controlmode.interfaces.IControlCommandParticipant#provideControlCommand(org.eclipse.papyrus.controlmode.request.
	 * ControlModeRequest)
	 */
	@Override
	public boolean provideControlCommand(ControlModeRequest request) {
		return CollabUtils.isCollab(request.getTargetObject());
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.papyrus.controlmode.interfaces.IControlCommandParticipant#getPreControlCommand(org.eclipse.papyrus.controlmode.request.
	 * ControlModeRequest)
	 */
	@Override
	public ICommand getPreControlCommand(ControlModeRequest request) {
		return null;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.papyrus.controlmode.interfaces.IControlCommandParticipant#getPostControlCommand(org.eclipse.papyrus.controlmode.request.
	 * ControlModeRequest)
	 */
	@Override
	public ICommand getPostControlCommand(ControlModeRequest request) {
		CompositeTransactionalCommand cc = new CompositeTransactionalCommand(request.getEditingDomain(), "Share file to SVN with need lock");
		IEditorPart editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
		if (editor instanceof ISaveablePart) {
			cc.compose(new SaveCommand(request.getEditingDomain(), editor));
			cc.compose(new AddFileToCollabSVN(request.getEditingDomain(), request));
		}
		return cc;
	}

}

Back to the top