import java.util.Set;
import java.util.UUID;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.commands.NotEnabledException;
-import org.eclipse.core.commands.NotHandledException;
-import org.eclipse.core.commands.common.NotDefinedException;
import org.eclipse.core.commands.operations.IUndoContext;
import org.eclipse.core.commands.operations.UndoContext;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.ui.IEditorReference;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.handlers.IHandlerService;
import org.eclipse.ui.navigator.CommonViewer;
import eu.etaxonomy.cdm.model.common.ICdmBase;
public class NavigationUtil extends AbstractUtility{
private static IUndoContext defaultUndoContext;
- /**
- * <p>executeEditHandler</p>
- */
- public static void executeEditHandler(){
-
- String commandId = "eu.etaxonomy.taxeditor.navigation.command.update.editSelection";
-
- IHandlerService handlerService = (IHandlerService) AbstractUtility.getService(IHandlerService.class);
- try {
- handlerService.executeCommand(commandId, null);
- } catch (ExecutionException e) {
- MessagingUtils.error(NavigationUtil.class, e);
- } catch (NotDefinedException e) {
- MessagingUtils.error(NavigationUtil.class, e);
- } catch (NotEnabledException e) {
- MessagingUtils.error(NavigationUtil.class, e);
- } catch (NotHandledException e) {
- MessagingUtils.error(NavigationUtil.class, e);
- }
- }
-
/**
* <p>openEditor</p>
*
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.TreePath;
import org.eclipse.ui.IMemento;
import org.eclipse.ui.IViewSite;
import eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled;
import eu.etaxonomy.taxeditor.store.CdmStore;
import eu.etaxonomy.taxeditor.store.LoginManager;
+import eu.etaxonomy.taxeditor.view.CdmViewerChooser;
/**
* Taxonomic tree implementation using Common Navigator Framework.
/** {@inheritDoc} */
@Override
- protected void handleDoubleClick(DoubleClickEvent anEvent) {
- NavigationUtil.executeEditHandler();
+ protected void handleDoubleClick(DoubleClickEvent event) {
+ if(event.getSelection() instanceof IStructuredSelection){
+ Object selectedObject = ((IStructuredSelection) event.getSelection()).getFirstElement();
+ CdmViewerChooser chooser = new CdmViewerChooser(getSite().getShell());
+ chooser.chooseViewer(selectedObject);
+ }
// If the double click is passed up to the super-class it will
// expand/collapse trees.
// We do not want that
import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.DoubleClickEvent;
import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
+import eu.etaxonomy.cdm.api.service.ITaxonService;
import eu.etaxonomy.cdm.api.service.config.IFindTaxaAndNamesConfigurator;
import eu.etaxonomy.cdm.model.common.IdentifiableEntity;
+import eu.etaxonomy.cdm.model.taxon.Synonym;
+import eu.etaxonomy.cdm.model.taxon.Taxon;
+import eu.etaxonomy.cdm.model.taxon.TaxonBase;
import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache;
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
import eu.etaxonomy.cdm.persistence.query.MatchMode;
import eu.etaxonomy.taxeditor.model.AbstractUtility;
import eu.etaxonomy.taxeditor.model.ContextListenerAdapter;
import eu.etaxonomy.taxeditor.model.IContextListener;
-import eu.etaxonomy.taxeditor.navigation.NavigationUtil;
import eu.etaxonomy.taxeditor.navigation.search.SearchBar.SearchOption;
import eu.etaxonomy.taxeditor.store.CdmStore;
+import eu.etaxonomy.taxeditor.view.CdmViewerChooser;
/**
* <p>SearchResultView class.</p>
resultViewer.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
- NavigationUtil.executeEditHandler();
+ if(event.getSelection() instanceof IStructuredSelection){
+ Object selectedObject = ((IStructuredSelection) event.getSelection()).getFirstElement();
+ if (selectedObject instanceof UuidAndTitleCache){
+ Class type = ((UuidAndTitleCache) selectedObject).getType();
+ if(type == Taxon.class || type == Synonym.class){
+ TaxonBase taxonBase = CdmStore.getService(ITaxonService.class).load(((UuidAndTitleCache) selectedObject).getUuid());
+ CdmViewerChooser chooser = new CdmViewerChooser(getSite().getShell());
+ chooser.chooseViewer(taxonBase);
+ }
+ }
+ }
}
});
import java.util.HashMap;
import java.util.Map;
+import org.eclipse.core.commands.Command;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.Platform;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.commands.ICommandService;
import eu.etaxonomy.taxeditor.model.MessagingUtils;
String viewerName = configElement.getAttribute("viewerName"); //$NON-NLS-1$
Class<?> selectionClass = Class.forName(configElement.getAttribute("selection")); //$NON-NLS-1$
if(selectionClass.isAssignableFrom(input.getClass())){
- commandViewerNameMap.put(commandId, viewerName);
+ ICommandService commandService = (ICommandService)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(commandId, viewerName);
+ }
}
} catch (ClassNotFoundException e) {
MessagingUtils.error(CdmViewerChooser.class, "Could not initalize selection class element of cdmViewer extension", e); //$NON-NLS-1$