-// $Id$
/**
* Copyright (C) 2015 EDIT
* European Distributed Institute of Taxonomy
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.viewers.TreeNode;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.commands.ICommandService;
+import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache;
import eu.etaxonomy.taxeditor.model.MessagingUtils;
+import eu.etaxonomy.taxeditor.store.CdmStore;
/**
* Scans eu.etaxonomy.taxeditor.store.cdmViewer extension point.
Map<Command, String> commandViewerNameMap = new HashMap<Command, String>();
if(input!=null){
+ //for generic UuidAndTitleCache objects try to load the object
+ if (input instanceof UuidAndTitleCache){
+ UuidAndTitleCache uuidAndTitleCache = (UuidAndTitleCache)input;
+ input = CdmStore.getCommonService().find(uuidAndTitleCache.getType(), uuidAndTitleCache.getUuid());
+ }
+ //for tree nodes get the value resp. the object of the node
+ else if (input instanceof TreeNode){
+ TreeNode treeNode = (TreeNode)input;
+ input = treeNode.getValue();
+ }
+
+
IExtensionRegistry reg = Platform.getExtensionRegistry();
IConfigurationElement[] extensions = reg
.getConfigurationElementsFor("eu.etaxonomy.taxeditor.store.cdmViewer"); //$NON-NLS-1$
String viewerName = configElement.getAttribute("viewerName"); //$NON-NLS-1$
Class<?> selectionClass = Class.forName(configElement.getAttribute("selection")); //$NON-NLS-1$
if(selectionClass.isAssignableFrom(input.getClass())){
- ICommandService commandService = (ICommandService)PlatformUI.getWorkbench().getService(ICommandService.class);
+ ICommandService commandService = PlatformUI.getWorkbench().getService(ICommandService.class);
Command command = commandService.getCommand(commandId);
- //TODO: maybe pass the command directly instead of just the command id
if(command.isEnabled()){
commandViewerNameMap.put(command, viewerName);
}