blob: 6814eee1aff355eba4b38a4049af765ef78c7606 (
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
|
/*******************************************************************************
* Copyright (c) 2015 THALES GLOBAL SERVICES.
* 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.internal.edit.commands;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.draw2d.geometry.PointList;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.gmf.runtime.common.core.command.CommandResult;
import org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionEditPart;
import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand;
import org.eclipse.sirius.diagram.ui.provider.Messages;
/**
* This class allows to update edge label Node position.
*
* @author <a href="mailto:laurent.redor@obeo.fr">Laurent Redor</a>
*/
public class SetLabelsOffsetCommmand extends AbstractTransactionalCommand {
/** Operation to delegate the job concerning the labels. */
private SetLabelsOffsetOperation setLabelsOperation;
/**
* Default constructor.
*
* @param editingDomain
* the editing domain through which model changes are made
*/
public SetLabelsOffsetCommmand(TransactionalEditingDomain editingDomain) {
super(editingDomain, Messages.SetLabelsOffsetCommmand_label, null);
setLabelsOperation = new SetLabelsOffsetOperation();
}
/**
* Method to set the newPointList.
*
* @param newPointList
* The new points list
*/
public void setNewPointList(PointList newPointList) {
setLabelsOperation.setNewPointList(newPointList);
}
@Override
protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
setLabelsOperation.updateGMFLabelsOffset();
return CommandResult.newOKCommandResult();
}
/**
* Set labels to update according to a connectionEditPart (all labels of
* this connection will be update). <BR>
* This method must be called after having called the
* {@link #setNewPointList(PointList)} method.
*
* @param connectionEditPart
* The connection from which to get the potential three labels to
* update
*/
public void setLabelsToUpdate(ConnectionEditPart connectionEditPart) {
setLabelsOperation.setLabelsToUpdate(connectionEditPart);
}
/**
* Set labels to update according to a connectionEditPart (all labels of
* this connection will be update). This method must be used if the edge
* figure is updated (through feedback) during the move. Indeed, in this
* case, we can not use the figure to retrieve the old points.<BR>
* This method must be called after having called the
* {@link #setNewPointList(PointList)} method.
*
* @param connectionEditPart
* The connection from which to get the potential three labels to
* update
* @param originalPoints
* The points of the edge before the move.
*/
public void setLabelsToUpdate(ConnectionEditPart connectionEditPart, PointList originalPoints) {
setLabelsOperation.setLabelsToUpdate(connectionEditPart, originalPoints);
}
}
|