From: Patrick Plitzner Date: Thu, 18 Aug 2016 13:10:55 +0000 (+0200) Subject: fix #5988 Add Checklist Editor to generic "Open in..." menu X-Git-Tag: 4.3.0^2~68 X-Git-Url: https://dev.e-taxonomy.eu/gitweb/taxeditor.git/commitdiff_plain/1b6fc97e1609b5ec875018ec41af92649649074b?hp=a56c8dc53e6c4f827a1b06798c8b8e5ae2f122df fix #5988 Add Checklist Editor to generic "Open in..." menu --- diff --git a/eu.etaxonomy.taxeditor.editor/OSGI-INF/l10n/plugin.properties b/eu.etaxonomy.taxeditor.editor/OSGI-INF/l10n/plugin.properties index e3f0fba1c..ef403bd00 100644 --- a/eu.etaxonomy.taxeditor.editor/OSGI-INF/l10n/plugin.properties +++ b/eu.etaxonomy.taxeditor.editor/OSGI-INF/l10n/plugin.properties @@ -184,3 +184,4 @@ command.name.TOGGLE_LINK_WITH_TAXON_SELECTION = Toggle link with taxon selection viewCommandMapping.viewerName.NAME_EDITOR = Name Editor viewCommandMapping.viewerName.SPECIMEN_EDITOR = Derivative Editor +viewCommandMapping.viewerName.CHECKLIST_EDITOR = Checklist Editor \ No newline at end of file diff --git a/eu.etaxonomy.taxeditor.editor/OSGI-INF/l10n/plugin_de.properties b/eu.etaxonomy.taxeditor.editor/OSGI-INF/l10n/plugin_de.properties index 8c3d36882..ace0d93b8 100644 --- a/eu.etaxonomy.taxeditor.editor/OSGI-INF/l10n/plugin_de.properties +++ b/eu.etaxonomy.taxeditor.editor/OSGI-INF/l10n/plugin_de.properties @@ -182,4 +182,5 @@ command.name.REMOVE_SINGLE_READ = Entferne Single-Read von Sequenz command.name.TOGGLE_LINK_WITH_TAXON_SELECTION = De-/Aktiviere Verknüpfung mit Taxonauswahl viewCommandMapping.viewerName.NAME_EDITOR = Namenseditor -viewCommandMapping.viewerName.SPECIMEN_EDITOR = Specimen-Editor \ No newline at end of file +viewCommandMapping.viewerName.SPECIMEN_EDITOR = Specimen-Editor +viewCommandMapping.viewerName.CHECKLIST_EDITOR = Checklisten-Editor \ No newline at end of file diff --git a/eu.etaxonomy.taxeditor.editor/plugin.xml b/eu.etaxonomy.taxeditor.editor/plugin.xml index ff2957452..0bb691ff2 100644 --- a/eu.etaxonomy.taxeditor.editor/plugin.xml +++ b/eu.etaxonomy.taxeditor.editor/plugin.xml @@ -1231,10 +1231,6 @@ - - @@ -1305,6 +1301,25 @@ + + + + + + + + + + + + + + + + + + diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/OpenChecklistEditorHandler.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/OpenChecklistEditorHandler.java index cc2bbf047..0b16c16c8 100644 --- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/OpenChecklistEditorHandler.java +++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/OpenChecklistEditorHandler.java @@ -1,65 +1,58 @@ package eu.etaxonomy.taxeditor.editor.handler; -import org.apache.log4j.Logger; -import org.eclipse.core.commands.AbstractHandler; +import java.util.UUID; + import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.ui.PartInitException; -import org.eclipse.ui.handlers.HandlerUtil; +import eu.etaxonomy.cdm.api.service.IClassificationService; +import eu.etaxonomy.cdm.api.service.ITaxonNodeService; import eu.etaxonomy.cdm.model.taxon.Classification; +import eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode; import eu.etaxonomy.cdm.model.taxon.TaxonNode; import eu.etaxonomy.taxeditor.editor.EditorUtil; import eu.etaxonomy.taxeditor.editor.view.checklist.ChecklistEditorInput; -import eu.etaxonomy.taxeditor.model.AbstractUtility; +import eu.etaxonomy.taxeditor.handler.defaultHandler.DefaultOpenHandlerBase; import eu.etaxonomy.taxeditor.model.MessagingUtils; import eu.etaxonomy.taxeditor.preference.IPreferenceKeys; import eu.etaxonomy.taxeditor.preference.PreferencesUtil; +import eu.etaxonomy.taxeditor.store.CdmStore; -public class OpenChecklistEditorHandler extends AbstractHandler { +public class OpenChecklistEditorHandler extends DefaultOpenHandlerBase { - private static final Logger logger = Logger.getLogger(OpenChecklistEditorHandler.class); + @Override + protected ITaxonTreeNode getEntity(UUID uuid) { + ITaxonTreeNode taxonTreeNode = CdmStore.getService(ITaxonNodeService.class).load(uuid); + if(taxonTreeNode==null){ + taxonTreeNode = CdmStore.getService(IClassificationService.class).load(uuid); + } + return taxonTreeNode; + } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands. - * ExecutionEvent) - */ - @Override - public Object execute(ExecutionEvent event) throws ExecutionException { - boolean isChecklistEditorActivated = PreferencesUtil.getPreferenceStore().getBoolean( - IPreferenceKeys.DISTRIBUTION_AREA_PREFRENCES_ACTIVE); - if (isChecklistEditorActivated) { - ISelection currentSelection = HandlerUtil.getCurrentSelection(event); - if (currentSelection instanceof IStructuredSelection) { - Object selectedElement = ((IStructuredSelection) currentSelection).getFirstElement(); - if (selectedElement instanceof Classification) { - ChecklistEditorInput input = new ChecklistEditorInput(((Classification) selectedElement)); - try { - EditorUtil.open(input); - } catch (PartInitException e) { - MessagingUtils.error(OpenChecklistEditorHandler.class, "Could not open ChecklistView", e); - } catch (NullPointerException npe) { - MessagingUtils.messageDialog("Failed to open Editor", OpenChecklistEditorHandler.class, - "Could not open ChecklistView. The hierarchy is corrupted!", npe); - } - } else if (selectedElement instanceof TaxonNode) { - ChecklistEditorInput input = new ChecklistEditorInput(((TaxonNode) selectedElement)); - try { - EditorUtil.open(input); - } catch (PartInitException e) { - MessagingUtils.error(OpenChecklistEditorHandler.class, "Could not open ChecklistView", e); - } catch (NullPointerException npe) { - MessagingUtils.messageDialog("Failed to open Editor", OpenChecklistEditorHandler.class, - "Could not open ChecklistView. The hierarchy is corrupted!", npe); - } - } - } - } - return null; - } + @Override + protected void open(ExecutionEvent event, ITaxonTreeNode entity) { + if (PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.DISTRIBUTION_AREA_PREFRENCES_ACTIVE)) { + if (entity instanceof Classification) { + ChecklistEditorInput input = new ChecklistEditorInput(((Classification) entity)); + try { + EditorUtil.open(input); + } catch (PartInitException e) { + MessagingUtils.error(OpenChecklistEditorHandler.class, "Could not open ChecklistView", e); + } catch (NullPointerException npe) { + MessagingUtils.messageDialog("Failed to open Editor", OpenChecklistEditorHandler.class, + "Could not open ChecklistView. The hierarchy is corrupted!", npe); + } + } else if (entity instanceof TaxonNode) { + ChecklistEditorInput input = new ChecklistEditorInput((TaxonNode) entity); + try { + EditorUtil.open(input); + } catch (PartInitException e) { + MessagingUtils.error(OpenChecklistEditorHandler.class, "Could not open ChecklistView", e); + } catch (NullPointerException npe) { + MessagingUtils.messageDialog("Failed to open Editor", OpenChecklistEditorHandler.class, + "Could not open ChecklistView. The hierarchy is corrupted!", npe); + } + } + } + } } diff --git a/eu.etaxonomy.taxeditor.navigation/OSGI-INF/l10n/bundle.properties b/eu.etaxonomy.taxeditor.navigation/OSGI-INF/l10n/bundle.properties index e6582f7fd..1bb4af14f 100644 --- a/eu.etaxonomy.taxeditor.navigation/OSGI-INF/l10n/bundle.properties +++ b/eu.etaxonomy.taxeditor.navigation/OSGI-INF/l10n/bundle.properties @@ -8,7 +8,6 @@ command.label.1 = Edit menu.label = New command.label.2 = Taxon command.label.3 = Classification -command.label.4 = Open in Checklist Editor command.label.5 = Edit command.label.6 = Change accepted taxon to synonym command.label.7 = Move taxon (with child taxa) diff --git a/eu.etaxonomy.taxeditor.navigation/OSGI-INF/l10n/bundle_de.properties b/eu.etaxonomy.taxeditor.navigation/OSGI-INF/l10n/bundle_de.properties index a561d9e43..f78b7e12d 100644 --- a/eu.etaxonomy.taxeditor.navigation/OSGI-INF/l10n/bundle_de.properties +++ b/eu.etaxonomy.taxeditor.navigation/OSGI-INF/l10n/bundle_de.properties @@ -8,7 +8,6 @@ command.label.1 = Bearbeiten menu.label = Neu command.label.2 = Taxon command.label.3 = Klassifikation -command.label.4 = \u00D6ffne im Checklisten Editor command.label.5 = Bearbeiten command.label.6 = Akzeptiertes Taxon zum Synonym umwandeln command.label.7 = Verschiebe Taxon (mit Kindern) diff --git a/eu.etaxonomy.taxeditor.navigation/plugin.xml b/eu.etaxonomy.taxeditor.navigation/plugin.xml index 2173e1efe..4960a059f 100644 --- a/eu.etaxonomy.taxeditor.navigation/plugin.xml +++ b/eu.etaxonomy.taxeditor.navigation/plugin.xml @@ -134,28 +134,6 @@ - - - - - - - - - - - - - -