Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 231cff2734bdae221a1dc4377e11e34176f58f28 (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 Eastadl Allocation Table
	 */
	public static final String TABLE_ALLOCATION_TYPE = "EAST-ADLFunctionAllocationTable"; //$NON-NLS-1$

	/**
	 *
	 * 
	 *
	 * @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);

	}

}

Back to the top