Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 9f5feb40253d1fc0e6b1f2bb2f54082ac1b91cc6 (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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
/*******************************************************************************
 * Copyright (c) 2007, 2019 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.tools.api.command;

import java.util.Collection;
import java.util.Set;

import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.sirius.diagram.DDiagram;
import org.eclipse.sirius.diagram.DDiagramElement;
import org.eclipse.sirius.diagram.DDiagramElementContainer;
import org.eclipse.sirius.diagram.DEdge;
import org.eclipse.sirius.diagram.DNode;
import org.eclipse.sirius.diagram.DragAndDropTarget;
import org.eclipse.sirius.diagram.EdgeTarget;
import org.eclipse.sirius.diagram.description.DiagramDescription;
import org.eclipse.sirius.diagram.description.tool.BehaviorTool;
import org.eclipse.sirius.diagram.description.tool.ContainerCreationDescription;
import org.eclipse.sirius.diagram.description.tool.ContainerDropDescription;
import org.eclipse.sirius.diagram.description.tool.DirectEditLabel;
import org.eclipse.sirius.diagram.description.tool.DoubleClickDescription;
import org.eclipse.sirius.diagram.description.tool.EdgeCreationDescription;
import org.eclipse.sirius.diagram.description.tool.NodeCreationDescription;
import org.eclipse.sirius.diagram.description.tool.ReconnectEdgeDescription;
import org.eclipse.sirius.tools.api.command.DCommand;
import org.eclipse.sirius.tools.api.command.ICommandFactory;
import org.eclipse.sirius.tools.api.ui.IExternalJavaAction;
import org.eclipse.sirius.viewpoint.DRefreshable;
import org.eclipse.sirius.viewpoint.DRepresentationElement;
import org.eclipse.sirius.viewpoint.DSemanticDecorator;
import org.eclipse.sirius.viewpoint.description.tool.ExternalJavaAction;
import org.eclipse.sirius.viewpoint.description.tool.OperationAction;
import org.eclipse.sirius.viewpoint.description.tool.PaneBasedSelectionWizardDescription;
import org.eclipse.sirius.viewpoint.description.tool.PasteDescription;
import org.eclipse.sirius.viewpoint.description.tool.SelectionWizardDescription;
import org.eclipse.sirius.viewpoint.description.tool.ToolDescription;
import org.eclipse.sirius.viewpoint.description.validation.ValidationFix;

/**
 * The command factory for diagram dialect.
 * 
 * @author mchauvin
 * @since 0.9.0
 */
public interface IDiagramCommandFactory extends ICommandFactory {
    /**
     * Create a command that executes the operation of a {@link BehaviorTool}.
     * <p>
     * The operations of a {@link BehaviorTool} are executed on the <code>rootObject</code> parameter. If the
     * <code>executeFromRootContainer</code> is <code>true</code> the operations are executed on the root container of
     * <code>rootObject</code>.
     * </p>
     * <p>
     * Finally, if the <code>deepProcess</code> parameter is <code>true</code>, the operations are executing on all
     * children (with a deep path) according to the {@link BehaviorTool#getDomainClass()} and the
     * {@link BehaviorTool#getPrecondition()}.
     * </p>
     * 
     * @param rootObject
     *            the selected object.
     * @param tool
     *            the behavior.
     * @param executeFromRootContainer
     *            if <code>true</code> the tool is applied on the root container of <code>rootObject</code>.
     * @param deepProcess
     *            if <code>true</code>
     * @return return the command that executes a behavior.
     */
    Command buildLaunchRuleCommandFromTool(DSemanticDecorator rootObject, BehaviorTool tool, boolean executeFromRootContainer, boolean deepProcess);

    /**
     * Create a command that creates a node.
     * 
     * @param container
     *            container element in which the command should put the created node.
     * @param tool
     *            {@link NodeCreationDescription} used to build the command.
     * @return a command able to create the node and putting it in the container, corresponding to the
     *         {@link NodeCreationDescription}.
     */
    Command buildCreateNodeCommandFromTool(DDiagramElementContainer container, NodeCreationDescription tool);

    /**
     * Create a command that creates a node.
     * 
     * @param node
     *            the node container in which the command should put the created node.
     * @param tool
     * 
     *            the {@link NodeCreationDescription} used to build the command.
     * @return a command able to create the node and putting it around the node, corresponding to the
     *         {@link NodeCreationDescription}.
     */
    Command buildCreateNodeCommandFromTool(DNode node, NodeCreationDescription tool);

    /**
     * Create a command that create a node and put it in the viewpoint.
     * 
     * @param diagram
     *            the viewpoint in which the command should put the created node.
     * @param tool
     *            the {@link NodeCreationDescription} used to build the command.
     * @return a command able to create the node and putting it into the viewpoint, corresponding to the
     *         {@link NodeCreationDescription}.
     */
    Command buildCreateNodeCommandFromTool(DDiagram diagram, NodeCreationDescription tool);

    /**
     * Create a command that is able to execute the operations of a
     * {@link org.eclipse.sirius.viewpoint.description.tool.SelectionWizardDescription} .
     * 
     * @param tool
     *            the tool, it must be a
     *            {@link org.eclipse.sirius.viewpoint.description.tool.SelectionWizardDescription} .
     * @param dContainer
     *            the clicked designer container.
     * @param selectedElement
     *            the selected element.
     * @return a command that is able to execute the operations of
     *         {@link org.eclipse.sirius.viewpoint.description.tool.SelectionWizardDescription} .
     */
    Command buildSelectionWizardCommandFromTool(SelectionWizardDescription tool, DSemanticDecorator dContainer, Collection<EObject> selectedElement);

    /**
     * Create a command that is able to execute the operations of a
     * {@link org.eclipse.sirius.viewpoint.description.tool.PaneBasedSelectionWizardDescription} .
     * 
     * @param tool
     *            the tool, it must be a
     *            {@link org.eclipse.sirius.viewpoint.description.tool.PaneBasedSelectionWizardDescription} .
     * @param dContainer
     *            the clicked designer container.
     * @param selectedElement
     *            the selected element.
     * @return a command that is able to execute the operations of
     *         {@link org.eclipse.sirius.viewpoint.description.tool.PaneBasedSelectionWizardDescription} .
     */
    Command buildPaneBasedSelectionWizardCommandFromTool(PaneBasedSelectionWizardDescription tool, DSemanticDecorator dContainer, Collection<EObject> selectedElement);

    /**
     * Create a command that is able to execute the operations of a
     * {@link org.eclipse.sirius.description.tool.JavaActionMenuItem}.
     * 
     * @param tool
     *            the tool, it must be a {@link org.eclipse.sirius.description.tool.JavaActionMenuItem} , the action to
     *            launch.
     * @param selectedViews
     *            the clicked designer container.
     * @param javaAction
     *            the java action to execute.
     * @return a command that is able to execute the operations of
     *         {@link org.eclipse.sirius.description.tool.JavaActionMenuItem} .
     */
    Command buildJavaActionFromTool(ExternalJavaAction tool, Collection<DSemanticDecorator> selectedViews, IExternalJavaAction javaAction);

    /**
     * Create a command that is able to execute the operations of a
     * {@link org.eclipse.sirius.description.tool.OperationMenuItem}.
     * 
     * @param tool
     *            the tool, it must be a {@link org.eclipse.sirius.description.tool.OperationMenuItem} , the operation
     *            to launch.
     * @param selectedViews
     *            the clicked designer container.
     * 
     * @return a command that is able to execute the operations of
     *         {@link org.eclipse.sirius.description.tool.OperationMenuItem}.
     */
    Command buildOperationActionFromTool(OperationAction tool, Collection<DSemanticDecorator> selectedViews);

    /**
     * Build an edge creation command from a tool description.
     * 
     * @param source
     *            the source node of the connection.
     * @param target
     *            the target node of the connection.
     * @param tool
     *            the tool that describes how to create the new edge.
     * @return a command able to create the edge.
     */
    Command buildCreateEdgeCommandFromTool(EdgeTarget source, EdgeTarget target, EdgeCreationDescription tool);

    /**
     * Create a reconnection command.
     * 
     * @param tool
     *            the description of the reconnection.
     * @param edge
     *            the edge to reconnect.
     * @param source
     *            the source node.
     * @param target
     *            the target node.
     * @return the reconnection command.
     */
    Command buildReconnectEdgeCommandFromTool(ReconnectEdgeDescription tool, DEdge edge, EdgeTarget source, EdgeTarget target);

    /**
     * Create a command able to drop a node into a container.
     * 
     * @param dContainer
     *            the target designer container.
     * @param element
     *            the node to drop.
     * @param tool
     *            the tool that describes the operation.
     * @return a command able to drop a node into a container.
     */
    Command buildDropInContainerCommandFromTool(DragAndDropTarget dContainer, DDiagramElement element, ContainerDropDescription tool);

    /**
     * Create a command able to drop a node into a container.
     * 
     * @param dContainer
     *            the target designer container.
     * @param droppedElement
     *            the element to drop
     * 
     * @param tool
     *            the tool that describes the operation.
     * @return a command able to drop a node into a container.
     */
    Command buildDropInContainerCommandFromTool(DragAndDropTarget dContainer, EObject droppedElement, ContainerDropDescription tool);

    /**
     * Create a command able to paste a semantic element into a container.
     * 
     * @param dContainer
     *            the target designer container.
     * @param element
     *            the node targeting the semantic element to paste.
     * @param tool
     *            the tool that describes the operation.
     * @return a command able to paste a semantic element into a container.
     */
    Command buildPasteCommandFromTool(DSemanticDecorator dContainer, DSemanticDecorator element, PasteDescription tool);

    /**
     * Create a command able to paste a semantic element into a container.
     * 
     * @param dContainer
     *            the target designer container.
     * @param copiedElement
     *            the element to drop
     * 
     * @param tool
     *            the tool that describes the operation.
     * @return a command able to drop a node into a container.
     */
    Command buildPasteCommandFromTool(DSemanticDecorator dContainer, EObject copiedElement, PasteDescription tool);

    /**
     * Create a command able to execute an action when double clicking on an element.
     * 
     * @param dDiagramElement
     *            the element that can be double clicked.
     * 
     * @param tool
     *            the tool that describes the operation.
     * @return a command able to execute a defined action when double clicking on dDiagramElement.
     */
    Command buildDoubleClickOnElementCommandFromTool(DDiagramElement dDiagramElement, DoubleClickDescription tool);

    /**
     * Create a command that creates a container.
     * 
     * @param diagram
     *            the diagram that owns the container.
     * @param tool
     *            The tool that describes the container creation.
     * @return the command that creates the container.
     */
    Command buildCreateContainerCommandFromTool(DDiagram diagram, ContainerCreationDescription tool);

    /**
     * Create a command that is able to create a container into the specified container.
     * 
     * @param nodeContainer
     *            the parent container.
     * @param tool
     *            the tool that describes how to create the new container.
     * @return a command that is able to create a container into the specified container.
     */
    Command buildCreateContainerCommandFromTool(DDiagramElementContainer nodeContainer, ContainerCreationDescription tool);

    /**
     * Create a command to delete a viewpoint.
     * 
     * @param vp
     *            the viewpoint to delete.
     * @return the command.
     */
    Command buildDeleteDiagram(DDiagram vp);

    /**
     * Create a command to delete a viewpoint element from the diagram.
     * 
     * @param element
     *            element to delete.
     * @return a command that delete the DDiagramElement without deleting the semantic one.
     */
    Command buildDeleteFromDiagramCommand(DDiagramElement element);

    /**
     * Returns a command that can delete the specified element.
     * 
     * @param element
     *            the element to delete.
     * @return a command that can delete the specified element.
     */
    Command buildDeleteDiagramElement(DDiagramElement element);

    /**
     * Build a direct edit label command using the corresponding tool description.
     * 
     * @param repElement
     *            : the element on which the label should be changed.
     * @param directEditTool
     *            : the tool description.
     * @param newValue
     *            : the new label value
     * @return : a command which prepare the model request interpreter and set the new label.
     */
    Command buildDirectEditLabelFromTool(DRepresentationElement repElement, DirectEditLabel directEditTool, String newValue);

    /**
     * Build a command that is able to refresh a refreshable element.
     * 
     * @param refreshableElement
     *            the element to refresh.
     * @return a command that is able to refresh a refreshable element.
     */
    Command buildRefreshCommand(DRefreshable refreshableElement);

    /**
     * Build a command that is able to hide many elements.
     * 
     * @param elementsToHide
     *            the elements to hide.
     * @return a command that is able to hide many elements.
     */
    Command buildHideCommand(Set<EObject> elementsToHide);

    /**
     * Build a command that is able to hide label of many elements.
     * 
     * @param elementsToHide
     *            the elements to hide.
     * @return a command that is able to hide label of many elements.
     */
    Command buildHideLabelCommand(Set<EObject> elementsToHide);

    /**
     * Build a command that is able to reveal one diagram element.
     * 
     * @param diagramElement
     *            the diagram element to reveal.
     * @return a command that is able to reveal one diagram element.
     */
    Command buildRevealCommand(DDiagramElement diagramElement);

    /**
     * Build a command that is able to reveal label of one diagram element.
     * 
     * @param diagramElement
     *            the diagram element for which you want to reveal the label.
     * @return a command that is able to reveal the label of one diagram element.
     */
    Command buildRevealLabelCommand(DDiagramElement diagramElement);

    /**
     * Build a command that is able to reveal all elements of a diagram.
     * 
     * @param diagram
     *            the diagram.
     * @return a command that is able to reveal all elements of a diagram.
     */
    Command buildRevealElementsCommand(DDiagram diagram);

    /**
     * Build a command that is able to reveal all elements of a diagram.
     * 
     * @param elementsToReveal
     *            the diagram elements to reveal.
     * @return a command that is able to reveal all elements of a diagram.
     */
    Command buildRevealElementsCommand(Set<DDiagramElement> elementsToReveal);

    /**
     * Create a command that is able to create a diagram.
     * 
     * @param description
     *            the tool that describes how to create the diagram.
     * @param semanticElement
     *            the element from which the diagram will be created.
     * @param monitor
     *            a {@link IProgressMonitor} to show progression of {@link DDiagram} creation
     * @return a command that is able to create a diagram.
     */
    DCommand buildCreateDiagramFromDescription(DiagramDescription description, EObject semanticElement, IProgressMonitor monitor);

    /**
     * Create a command to execute a quick fix .
     * 
     * @param fix
     *            quick fix description.
     * @param fixTarget
     *            Target to execute fix on.
     * @param diagram
     *            the current diagram
     * @return an executable command.
     */
    Command buildQuickFixOperation(ValidationFix fix, EObject fixTarget, DDiagram diagram);

    /**
     * Create a command to execute a generic {@link ToolDescription}.
     * 
     * @param containerView
     *            the view the tool has been invoked on.
     * @param toolDesc
     *            the description of the tool.
     * @return a command which executes the behavior specified in the tool in the context of the view.
     */
    Command buildGenericToolCommandFromTool(EObject containerView, ToolDescription toolDesc);

    /**
     * Create a command that shifts nodes to insert or remove vertical blank space in a diagram.
     * 
     * @param diagram
     *            the diagram in which insert blank space
     * @param startX
     *            the initial location in pixel to insert blank space
     * @param spaceToInsert
     *            the number of pixels to insert
     * 
     * @return a command able to insert blank space (move all elements).
     */
    Command buildInsertVerticalBlankSpaceCommand(DDiagram diagram, int startX, int spaceToInsert);
}

Back to the top