blob: b57f69dcd2a16970f23435077964b1fc4b5bd6a2 (
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
|
/**
*
*/
package org.eclipse.papyrus.eastadl.nattable.allocation.config.handler;
import org.eclipse.emf.common.command.Command;
import org.eclipse.gmf.runtime.emf.type.core.IElementType;
import org.eclipse.papyrus.eastadl.nattable.menu.handlers.FunctionAllocationHandler;
import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager;
import org.eclipse.papyrus.infra.nattable.utils.INattableModelManagerUtils;
public class CreateFunctionAllocationHandler extends FunctionAllocationHandler {
/**
* the id used for the Papyrus SysML Allocation Table
*/
public static final String TABLE_ALLOCATION_TYPE = "EAST-ADLFunctionAllocationTable"; //$NON-NLS-1$
/**
*
* @see org.eclipse.papyrus.sysml.nattable.menu.handlers.AbstractSysmlNattableCreateCommandHandler#setEnabled(java.lang.Object)
*
* @param evaluationContext
*/
@Override
public void setEnabled(Object evaluationContext) {
Command command = getCommand();
boolean isEnabled = command.canExecute();
INattableModelManager tableManager = INattableModelManagerUtils.getTableManagerFromWorkbenchPart(getActiveWorkbenchPart());
isEnabled = isEnabled && tableManager.getTable().getTableConfiguration().getType().equals(TABLE_ALLOCATION_TYPE);
if(isEnabled) {
IElementType newElementType = getElementTypeToCreate();
String id = newElementType.getId();
isEnabled = tableManager.canCreateRowElement(id);
}
setBaseEnabled(isEnabled);
}
}
|