blob: 3cc1e5a740e896affc7e67ceb269250bdcccbf2e (
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
|
/*******************************************************************************
* Copyright (c) 2010, 2015 THALES GLOBAL SERVICES 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:
* Obeo - initial API and implementation
*******************************************************************************/
package org.eclipse.sirius.diagram.ui.tools.internal.commands;
import java.util.Collection;
import org.eclipse.emf.transaction.RecordingCommand;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.sirius.diagram.DDiagram;
import org.eclipse.sirius.diagram.business.api.helper.concern.ConcernService;
import org.eclipse.sirius.diagram.description.tool.BehaviorTool;
import org.eclipse.sirius.diagram.ui.provider.Messages;
/**
* Specific command to update activated behaviors.
*
* @author mporhel
*/
public final class DeactivateBehaviorToolsCommand extends RecordingCommand {
private final Collection<BehaviorTool> oldElements;
private final DDiagram diagram;
/**
* Constructor.
*
* @param domain
* the editing domain.
* @param oldElements
* elements to remove
* @param dDiagram
* the current diagram.
*/
public DeactivateBehaviorToolsCommand(TransactionalEditingDomain domain, DDiagram dDiagram, Collection<BehaviorTool> oldElements) {
super(domain, Messages.DeactivateBehaviorToolsCommand_label);
this.diagram = dDiagram;
this.oldElements = oldElements;
}
/**
* {@inheritDoc}
*/
@Override
protected void doExecute() {
if (diagram == null || oldElements == null) {
return;
}
for (BehaviorTool tool : oldElements) {
diagram.getActivateBehaviors().remove(tool);
}
ConcernService.resetCurrentConcern(diagram);
}
}
|