blob: c89a86e0c8c97e34b682658d9426ec8c4df8fb6f (
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
|
package org.eclipse.papyrus.eastadl.nattable.menu.handlers;
import org.eclipse.emf.common.command.Command;
import org.eclipse.papyrus.eastadl.service.types.handlers.AbstractEastadlCreateCommandHandler;
import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager;
import org.eclipse.papyrus.infra.nattable.utils.INattableModelManagerUtils;
import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
import org.eclipse.papyrus.uml.nattable.menu.util.TableMenuUtils;
import org.eclipse.papyrus.uml.service.types.utils.ICommandContext;
public abstract class AbstractEastadlNattableCreateCommandHandler extends
AbstractEastadlCreateCommandHandler {
/**
* <pre>
*
* Build the create command for an element creation in the selected container.
* The create command is given by the {@link IElementEditService} of selected
* element.
*
* @return the composite creation command for current selection
*
* </pre>
*/
protected Command buildCommand() {
Command createCmd = super.buildCommand();
return TableMenuUtils.buildNattableCreationCommand(createCmd,
this.createRequest);
}
/**
* Obtain the context of the active table editor.
*
* @see org.eclipse.papyrus.uml.service.types.handlers.AbstractCommandHandler#getCommandContext()
*
* @return
*/
protected ICommandContext getCommandContext() {
return TableMenuUtils.getTableCommandContext(INattableModelManagerUtils
.getTableManagerFromWorkbenchPart(getActiveWorkbenchPart()));
}
/**
* Verify if this handler is currently active and the command can execute.
* Additionally, verify if this table can add this type of element.
*
* @see org.eclipse.papyrus.uml.service.types.handlers.AbstractCreateCommandHandler#setEnabled(java.lang.Object)
*
* @param evaluationContext
*/
public void setEnabled(Object evaluationContext) {
INattableModelManager tableManager = INattableModelManagerUtils
.getTableManagerFromWorkbenchPart(getActiveWorkbenchPart());
boolean isEnabled = tableManager
.canCreateRowElement(getElementTypeToCreate().getId());
if (isEnabled) {
// we test the enable of the super implementation
super.setEnabled(evaluationContext);
isEnabled = super.isEnabled();
}
setBaseEnabled(isEnabled);
}
}
|