package eu.etaxonomy.taxeditor.handler.defaultHandler;
+import java.util.UUID;
+
import javax.inject.Named;
import org.eclipse.e4.core.di.annotations.CanExecute;
import org.eclipse.e4.ui.services.IServiceConstants;
import org.eclipse.e4.ui.workbench.modeling.EPartService;
import org.eclipse.e4.ui.workbench.modeling.EPartService.PartState;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import eu.etaxonomy.cdm.model.common.CdmBase;
+import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache;
import eu.etaxonomy.taxeditor.bulkeditor.AppModelId;
+import eu.etaxonomy.taxeditor.editor.IReferencingObjectsView;
public class OpenReferencingObjectsViewHandler {
+ Object selectedObject;
@Execute
public void execute(EPartService partService) {
MPart part = partService.createPart(AppModelId.PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_BULKEDITOR_REFERENCINGOBJECTS_E4_REFERENCINGOBJECTSVIEWE4);
part = partService.showPart(part, PartState.ACTIVATE);
+ IReferencingObjectsView view = (IReferencingObjectsView)part.getObject();
+ UUID uuid = null;
+ Class clazz = null;
+
+ if (selectedObject instanceof IStructuredSelection){
+ selectedObject = ((IStructuredSelection)selectedObject).getFirstElement();
+ }
+ if (selectedObject instanceof CdmBase){
+ uuid = ((CdmBase)selectedObject).getUuid();
+ clazz = selectedObject.getClass();
+ } else if (selectedObject instanceof UuidAndTitleCache){
+ uuid = ((UuidAndTitleCache)selectedObject).getUuid();
+ clazz = ((UuidAndTitleCache)selectedObject).getType();
+ }
+ if (uuid != null && clazz != null){
+ view.updateReferencingObjects(uuid, clazz);
+ }
+
+
+
}
@CanExecute
boolean canExecute = false;
MPart part = partService.findPart(AppModelId.PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_BULKEDITOR_REFERENCINGOBJECTS_E4_REFERENCINGOBJECTSVIEWE4);
canExecute = !part.equals(activePart);
+
+
+ if (canExecute){
+ String commandId = menuItem.getCommand().getElementId();
+ selectedObject = menuItem.getTransientData().get(commandId+".uuid");
+ if (selectedObject instanceof IStructuredSelection){
+ canExecute = ((IStructuredSelection)selectedObject).size() == 1;
+ }
+ }
menuItem.setVisible(canExecute);
return canExecute;
}