taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/dnd/NameEditorDragSourceEffect.java -text
taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/dnd/NameEditorDropTargetEffect.java -text
taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/dnd/NameEditorDropTargetListener.java -text
-taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/handler/AbstractDynamicConceptRelationMenu.java -text
taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/handler/ChangeAcceptedTaxonToSynonymHandler.java -text
-taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/handler/ChangeConceptRelationshipTypeHandler.java -text
-taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/handler/ChangeConceptRelationshipTypeMenu.java -text
taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/handler/ChangeSynonymToAcceptedTaxonHandler.java -text
taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/handler/ChangeToConceptRelationHandler.java -text
-taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/handler/ChangeToConceptRelationMenu.java -text
taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/handler/ChangeToMisapplicationHandler.java -text
taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/handler/ChangeToSynonymHandler.java -text
-taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/handler/CreateConceptRelationHandler.java -text
-taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/handler/CreateConceptRelationMenu.java -text
taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/handler/CreateHeterotypicSynonymHandler.java -text
taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/handler/CreateHomotypicSynonymHandler.java -text
taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/handler/CreateMisapplicationHandler.java -text
taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/ChangeSynonymToConceptOperation.java -text
taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/ChangeSynonymToHomotypicalGroupBasionymOperation.java -text
taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/ChangeSynonymToMisapplicationOperation.java -text
-taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/CreateConceptRelationOperation.java -text
taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/CreateNameRelationOperation.java -text
taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/CreateSynonymInExistingHomotypicalGroupOperation.java -text
taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/CreateSynonymInNewGroupOperation.java -text
-taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/DeleteConceptRelationOperation.java -text
taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/DeleteMisapplicationOperation.java -text
taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/DeleteNameRelationOperation.java -text
taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/DeleteSynonymOperation.java -text
taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/AbstractCdmDataViewer.java -text
taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/AbstractCdmEditorViewPart.java -text
taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/AbstractSplitableViewPart.java -text
+taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/concept/ConceptContentProvider.java -text
+taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/concept/ConceptLabelProvider.java -text
+taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/concept/ConceptViewPart.java -text
+taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/concept/ConceptViewerSorter.java -text
+taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/concept/handler/AbstractDynamicConceptRelationMenu.java -text
+taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/concept/handler/ChangeConceptRelationshipTypeHandler.java -text
+taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/concept/handler/ChangeConceptRelationshipTypeMenu.java -text
+taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/concept/handler/ChangeToConceptRelationMenu.java -text
+taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/concept/handler/CreateConceptRelationHandler.java -text
+taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/concept/handler/CreateConceptRelationMenu.java -text
+taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/concept/handler/DeleteConceptRelationHandler.java -text
+taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/concept/handler/OpenRelatedConceptHandler.java -text
+taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/concept/operation/CreateConceptRelationOperation.java -text
+taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/concept/operation/DeleteConceptRelationOperation.java -text
taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/DescriptiveContentProvider.java -text
taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/DescriptiveLabelProvider.java -text
taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/DescriptiveViewPart.java -text
name="Media"
restorable="true">
</view>
+ <view
+ class="eu.etaxonomy.taxeditor.editor.view.concept.ConceptViewPart"
+ id="eu.etaxonomy.taxeditor.editor.view.concept"
+ name="Concept Relations"
+ restorable="true">
+ </view>
</extension>
<extension
point="org.eclipse.ui.elementFactories">
value="eu.etaxonomy.taxeditor.editor.view.media">
</parameter>
</command>
+ <command
+ commandId="org.eclipse.ui.views.showView"
+ label="Concept"
+ style="push">
+ <parameter
+ name="org.eclipse.ui.views.showView.viewId"
+ value="eu.etaxonomy.taxeditor.editor.view.concept">
+ </parameter>
+ </command>
</menuContribution>
</extension>
<extension
</not>
</visibleWhen>
</command>
- <menu
- label="Concept Relation">
- <visibleWhen>
- <not>
- <or>
- <reference
- definitionId="isAcceptedTaxon">
- </reference>
- <reference
- definitionId="isConceptRelation">
- </reference>
- </or>
- </not>
- </visibleWhen>
- <dynamic
- class="eu.etaxonomy.taxeditor.editor.name.handler.ChangeToConceptRelationMenu"
- id="eu.etaxonomy.taxeditor.editor.dynamicConceptRelationMenu">
- </dynamic>
- </menu>
<command
commandId="eu.etaxonomy.taxeditor.editor.name.changeToMisapplication"
label="Misapplication"
</reference>
</visibleWhen>
<dynamic
- class="eu.etaxonomy.taxeditor.editor.name.handler.ChangeConceptRelationshipTypeMenu"
+ class="eu.etaxonomy.taxeditor.editor.view.concept.handler.ChangeConceptRelationshipTypeMenu"
id="eu.etaxonomy.taxeditor.editor.dynamicConceptRelationMenu">
</dynamic>
</menu>
id="eu.etaxonomy.taxeditor.editor.name.createSynonymInHomotypicalGroup"
name="Create Synonym In Homotypical Group">
</command>
- <command
- defaultHandler="eu.etaxonomy.taxeditor.editor.name.handler.CreateConceptRelationHandler"
- id="eu.etaxonomy.taxeditor.editor.name.createConceptRelation"
- name="Create Concept Relation">
- </command>
<command
defaultHandler="eu.etaxonomy.taxeditor.editor.name.handler.CreateMisapplicationHandler"
id="eu.etaxonomy.taxeditor.editor.name.createMisapplication"
name="Change To Misapplication">
</command>
<command
- defaultHandler="eu.etaxonomy.taxeditor.editor.name.handler.ChangeConceptRelationshipTypeHandler"
+ defaultHandler="eu.etaxonomy.taxeditor.editor.view.concept.handler.ChangeConceptRelationshipTypeHandler"
id="eu.etaxonomy.taxeditor.editor.name.changeConceptRelationshipType"
name="Change Concept Relationship Type">
</command>
</activeWhen>
</handler>
</extension>
+ <extension
+ point="org.eclipse.ui.menus">
+ <menuContribution
+ allPopups="false"
+ locationURI="popup:eu.etaxonomy.taxeditor.editor.view.concept">
+ <menu
+ label="New">
+ <dynamic
+ class="eu.etaxonomy.taxeditor.editor.view.concept.handler.CreateConceptRelationMenu"
+ id="eu.etaxonomy.taxeditor.editor.view.concept.menus.new">
+ </dynamic>
+ </menu>
+ <command
+ commandId="eu.etaxonomy.taxeditor.editor.view.concept.command.open"
+ label="Open Related Concept"
+ style="push">
+ </command>
+ <separator
+ name="eu.etaxonomy.taxeditor.editor.view.concept.menu.separator1"
+ visible="true">
+ </separator>
+ <command
+ commandId="org.eclipse.ui.edit.delete"
+ label="Delete"
+ style="push">
+ </command>
+ </menuContribution>
+ </extension>
+ <extension
+ point="org.eclipse.ui.commands">
+ <command
+ defaultHandler="eu.etaxonomy.taxeditor.editor.view.concept.handler.CreateConceptRelationHandler"
+ id="eu.etaxonomy.taxeditor.editor.name.createConceptRelation"
+ name="Create Concept Relation">
+ </command>
+ <command
+ defaultHandler="eu.etaxonomy.taxeditor.editor.view.concept.handler.OpenRelatedConceptHandler"
+ id="eu.etaxonomy.taxeditor.editor.view.concept.command.open"
+ name="Open Related Concept">
+ </command>
+ </extension>
+ <extension
+ point="org.eclipse.ui.handlers">
+ <handler
+ class="eu.etaxonomy.taxeditor.editor.view.concept.handler.DeleteConceptRelationHandler"
+ commandId="org.eclipse.ui.edit.delete">
+ </handler>
+ </extension>
</plugin>
import eu.etaxonomy.taxeditor.editor.EditorUtil;
import eu.etaxonomy.taxeditor.editor.Page;
import eu.etaxonomy.taxeditor.editor.name.TaxonNameEditor;
-import eu.etaxonomy.taxeditor.editor.name.operation.CreateConceptRelationOperation;
+import eu.etaxonomy.taxeditor.editor.view.concept.operation.CreateConceptRelationOperation;
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
import eu.etaxonomy.taxeditor.parser.ParseHandler;
import eu.etaxonomy.taxeditor.editor.EditorUtil;
import eu.etaxonomy.taxeditor.editor.Page;
import eu.etaxonomy.taxeditor.editor.name.TaxonNameEditor;
-import eu.etaxonomy.taxeditor.editor.name.operation.DeleteConceptRelationOperation;
import eu.etaxonomy.taxeditor.editor.name.operation.DeleteMisapplicationOperation;
import eu.etaxonomy.taxeditor.editor.name.operation.DeleteSynonymOperation;
+import eu.etaxonomy.taxeditor.editor.view.concept.operation.DeleteConceptRelationOperation;
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
/**
operation = new DeleteMisapplicationOperation(commandName, editor.getUndoContext(), editor
.getTaxon(), (Taxon) selectedElement, editor);
}
- // concept relation
- else if(selectedElement instanceof Taxon && ((Taxon) selectedElement).isRelatedConcept()){
- operation = new DeleteConceptRelationOperation(commandName, editor.getUndoContext(), editor.getTaxon(), (Taxon) selectedElement, editor);
- }
else {
throw new IllegalArgumentException("Element has to be Synonym, Misapplication or Concept");
}
+++ /dev/null
-/**
-* Copyright (C) 2007 EDIT
-* European Distributed Institute of Taxonomy
-* http://www.e-taxonomy.eu
-*
-* The contents of this file are subject to the Mozilla Public License Version 1.1
-* See LICENSE.TXT at the top of this package for the full license terms.
-*/
-
-package eu.etaxonomy.taxeditor.editor.name.operation;
-
-import java.util.Set;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.commands.operations.IUndoContext;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-
-import eu.etaxonomy.cdm.model.reference.Reference;
-import eu.etaxonomy.cdm.model.taxon.Taxon;
-import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;
-import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
-import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
-import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
-import eu.etaxonomy.taxeditor.store.StoreUtil;
-
-/**
- * Deletes a relation between two taxa.
- *
- * TODO we assume that there is only one kind of relation between two taxa.
- * If there are more, this operation breaks
- *
- * @author p.ciardelli
- * @author n.hoffmann
- * @created 29.01.2009
- * @version 1.0
- */
-public class DeleteConceptRelationOperation extends AbstractPostOperation {
-
- private Taxon relatedTaxon;
- private TaxonRelationshipType relationshipType;
- private Reference<?> citation;
- private String microcitation;
- private TaxonRelationship taxonRelationship;
-
- /**
- * <p>Constructor for DeleteConceptRelationOperation.</p>
- *
- * @param label a {@link java.lang.String} object.
- * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
- * @param taxon a {@link eu.etaxonomy.cdm.model.taxon.Taxon} object.
- * @param relatedTaxon a {@link eu.etaxonomy.cdm.model.taxon.Taxon} object.
- * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
- */
- public DeleteConceptRelationOperation(String label,
- IUndoContext undoContext, Taxon taxon, Taxon relatedTaxon,
- IPostOperationEnabled postOperationEnabled) {
- super(label, undoContext, taxon, postOperationEnabled);
-
- this.relatedTaxon = relatedTaxon;
-
- Set<TaxonRelationship> taxonRelationships = taxon.getTaxonRelations(relatedTaxon);
-
- if(taxonRelationships.size() > 1){
- StoreUtil.warningDialog("Multiple relations between taxa", this, "There are multiple relations between the " +
- "accepted and the related taxon. This case is not handled by the software yet");
- return;
- }
-
- taxonRelationship = taxonRelationships.iterator().next();
-
- relationshipType = taxonRelationship.getType();
-
- citation = taxonRelationship.getCitation();
- microcitation = taxonRelationship.getCitationMicroReference();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
- */
- /** {@inheritDoc} */
- @Override
- public IStatus execute(IProgressMonitor monitor, IAdaptable info)
- throws ExecutionException {
-
- // Find relation, save citation information
- for (TaxonRelationship relationship : taxon.getTaxonRelations()) {
- if (relationship.getType().equals(relationshipType)
- && relationship.getFromTaxon().equals(relatedTaxon)) {
- citation = relationship.getCitation();
- microcitation = relationship.getCitationMicroReference();
- taxonRelationship = relationship;
- }
- }
- monitor.worked(20);
-
- // Remove relation from taxon
- taxon.removeTaxonRelation(taxonRelationship);
- monitor.worked(40);
-
- return postExecute(taxon);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
- */
- /** {@inheritDoc} */
- @Override
- public IStatus redo(IProgressMonitor monitor, IAdaptable info)
- throws ExecutionException {
- return execute(monitor, info);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
- */
- /** {@inheritDoc} */
- @Override
- public IStatus undo(IProgressMonitor monitor, IAdaptable info)
- throws ExecutionException {
-
-// relatedTaxon.addTaxonRelation(relationship); // don't do nothin'
- taxon.addTaxonRelation(relatedTaxon, relationshipType, citation, microcitation);
-
- return postExecute(relatedTaxon);
- }
-}
--- /dev/null
+// $Id$
+/**
+* Copyright (C) 2007 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+
+package eu.etaxonomy.taxeditor.editor.view.concept;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+
+import eu.etaxonomy.cdm.model.taxon.Taxon;
+import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;
+import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
+import eu.etaxonomy.taxeditor.editor.TaxonEditorInput;
+
+/**
+ * @author n.hoffmann
+ * @created Jan 24, 2011
+ * @version 1.0
+ */
+public class ConceptContentProvider implements IStructuredContentProvider {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.IContentProvider#dispose()
+ */
+ @Override
+ public void dispose() {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
+ */
+ @Override
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
+ */
+ @Override
+ public Object[] getElements(Object inputElement) {
+ if(inputElement instanceof TaxonEditorInput){
+ Taxon taxon = ((TaxonEditorInput) inputElement).getTaxon();
+
+ Set<TaxonRelationship> filteredTaxonRelations = new HashSet<TaxonRelationship>();
+
+ for (TaxonRelationship relationship : taxon.getTaxonRelations()) {
+ if (! relationship.getType().equals(TaxonRelationshipType.MISAPPLIED_NAME_FOR()) ||
+ relationship.getType().equals(TaxonRelationshipType.TAXONOMICALLY_INCLUDED_IN())) {
+ filteredTaxonRelations.add(relationship);
+ }
+ }
+
+ return filteredTaxonRelations.toArray();
+ }
+ return new Object[0];
+ }
+
+}
--- /dev/null
+// $Id$
+/**
+* Copyright (C) 2007 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+
+package eu.etaxonomy.taxeditor.editor.view.concept;
+
+import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.StyledString;
+import org.eclipse.swt.graphics.Image;
+
+import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;
+import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
+import eu.etaxonomy.taxeditor.model.ImageResources;
+
+/**
+ * @author n.hoffmann
+ * @created Jan 24, 2011
+ * @version 1.0
+ */
+public class ConceptLabelProvider extends LabelProvider implements IStyledLabelProvider {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object)
+ */
+ @Override
+ public Image getImage(Object element) {
+ if(element instanceof TaxonRelationship){
+ TaxonRelationshipType type = ((TaxonRelationship) element).getType();
+
+ return getTaxonRelationshipImage(type);
+ }
+ return super.getImage(element);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ColumnLabelProvider#getText(java.lang.Object)
+ */
+ @Override
+ public String getText(Object element) {
+ if(element instanceof TaxonRelationship){
+ TaxonRelationship relationship = (TaxonRelationship) element;
+
+ return String.format("%s %s %s", relationship.getFromTaxon(), relationship.getType().getLabel(), relationship.getToTaxon());
+ }
+
+ return "";
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider#getStyledText(java.lang.Object)
+ */
+ @Override
+ public StyledString getStyledText(Object element) {
+ return new StyledString(getText(element), StyledString.QUALIFIER_STYLER);
+ }
+
+ /**
+ * @param type
+ * @return
+ */
+ public Image getTaxonRelationshipImage(TaxonRelationshipType type) {
+
+ return ImageResources.getImage(ImageResources.CONCEPT_ICON);
+ }
+}
--- /dev/null
+// $Id$
+/**
+* Copyright (C) 2007 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+
+package eu.etaxonomy.taxeditor.editor.view.concept;
+
+import org.eclipse.jface.action.GroupMarker;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ListViewer;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbenchActionConstants;
+import org.eclipse.ui.IWorkbenchPart;
+
+import eu.etaxonomy.taxeditor.bulkeditor.BulkEditor;
+import eu.etaxonomy.taxeditor.editor.EditorUtil;
+import eu.etaxonomy.taxeditor.editor.MultiPageTaxonEditor;
+import eu.etaxonomy.taxeditor.editor.key.AbstractKeyEditor;
+import eu.etaxonomy.taxeditor.editor.view.AbstractCdmEditorViewPart;
+
+/**
+ * @author n.hoffmann
+ * @created Jan 24, 2011
+ * @version 1.0
+ */
+public class ConceptViewPart extends AbstractCdmEditorViewPart {
+
+ public static final String ID = "eu.etaxonomy.taxeditor.editor.view.concept";
+
+ private ListViewer viewer;
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.ISelectionListener#selectionChanged(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection)
+ */
+ @Override
+ public void selectionChanged(IWorkbenchPart part, ISelection selection) {
+ if(EditorUtil.getActiveEditor() == null){
+ showEmptyPage();
+ return;
+ }
+
+ if(part instanceof BulkEditor){
+ showEmptyPage();
+ return;
+ }
+
+ if(part instanceof AbstractKeyEditor){
+ showEmptyPage();
+ return;
+ }
+
+ if(part instanceof MultiPageTaxonEditor){
+ if(! part.equals(this.part)){
+ IEditorInput input = ((IEditorPart) part).getEditorInput();
+ showViewer(part, new StructuredSelection(input));
+ }
+ showViewer();
+ }
+
+ }
+
+ /* (non-Javadoc)
+ * @see eu.etaxonomy.taxeditor.operation.IPostOperationEnabled#onComplete()
+ */
+ @Override
+ public boolean onComplete() {
+ return true;
+ }
+
+ /* (non-Javadoc)
+ * @see eu.etaxonomy.taxeditor.model.AbstractCdmViewPart#getViewer()
+ */
+ @Override
+ public Viewer getViewer() {
+ return viewer;
+ }
+
+ /* (non-Javadoc)
+ * @see eu.etaxonomy.taxeditor.model.AbstractCdmViewPart#createViewer(org.eclipse.swt.widgets.Composite)
+ */
+ @Override
+ public void createViewer(Composite parent) {
+ viewer = new ListViewer(parent);
+
+ viewer.setContentProvider(new ConceptContentProvider());
+ viewer.setLabelProvider(new ConceptLabelProvider());
+
+
+ viewer.setSorter(new ConceptViewerSorter());
+
+ createMenu();
+
+ createToolbar();
+ }
+
+ private void createMenu(){
+ MenuManager menuManager = new MenuManager();
+ menuManager.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
+
+ getSite().registerContextMenu(menuManager, viewer);
+
+ Control control = viewer.getControl();
+ Menu menu = menuManager.createContextMenu(control);
+
+ control.setMenu(menu);
+ }
+
+ private void createToolbar() {
+ IToolBarManager toolBarManager = getViewSite().getActionBars().getToolBarManager();
+// toolBarManager.add();
+// toolBarManager.add();
+ }
+
+
+ /* (non-Javadoc)
+ * @see eu.etaxonomy.taxeditor.editor.view.AbstractCdmEditorViewPart#changed(java.lang.Object)
+ */
+ @Override
+ public void changed(Object object) {
+ getViewer().refresh();
+ super.changed(object);
+ }
+}
--- /dev/null
+// $Id$
+/**
+* Copyright (C) 2007 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+
+package eu.etaxonomy.taxeditor.editor.view.concept;
+
+import org.eclipse.jface.viewers.ViewerSorter;
+
+/**
+ * @author n.hoffmann
+ * @created Jan 24, 2011
+ * @version 1.0
+ */
+public class ConceptViewerSorter extends ViewerSorter {
+
+}
/**
*
*/
-package eu.etaxonomy.taxeditor.editor.name.handler;
+package eu.etaxonomy.taxeditor.editor.view.concept.handler;
import java.util.Arrays;
import java.util.List;
* See LICENSE.TXT at the top of this package for the full license terms.
*/
-package eu.etaxonomy.taxeditor.editor.name.handler;
+package eu.etaxonomy.taxeditor.editor.view.concept.handler;
import org.apache.log4j.Logger;
import org.eclipse.core.commands.AbstractHandler;
* See LICENSE.TXT at the top of this package for the full license terms.
*/
-package eu.etaxonomy.taxeditor.editor.name.handler;
+package eu.etaxonomy.taxeditor.editor.view.concept.handler;
+
/**
* See LICENSE.TXT at the top of this package for the full license terms.
*/
-package eu.etaxonomy.taxeditor.editor.name.handler;
+package eu.etaxonomy.taxeditor.editor.view.concept.handler;
+
/**
* See LICENSE.TXT at the top of this package for the full license terms.
*/
-package eu.etaxonomy.taxeditor.editor.name.handler;
+package eu.etaxonomy.taxeditor.editor.view.concept.handler;
import org.apache.log4j.Logger;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.commands.common.NotDefinedException;
import org.eclipse.swt.widgets.Event;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.handlers.HandlerUtil;
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
import eu.etaxonomy.cdm.model.taxon.Taxon;
+import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;
import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
+import eu.etaxonomy.taxeditor.dialogs.filteredSelection.TaxonBaseSelectionDialog;
import eu.etaxonomy.taxeditor.editor.EditorUtil;
import eu.etaxonomy.taxeditor.editor.Page;
import eu.etaxonomy.taxeditor.editor.name.TaxonNameEditor;
-import eu.etaxonomy.taxeditor.editor.name.operation.CreateConceptRelationOperation;
+import eu.etaxonomy.taxeditor.editor.view.concept.operation.CreateConceptRelationOperation;
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
+import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
import eu.etaxonomy.taxeditor.parser.ParseHandler;
/**
TaxonNameEditor editor = (TaxonNameEditor) EditorUtil.getActiveEditorPage(
Page.NAME);
- TaxonNameBase conceptName = ParseHandler.createEmptyName();
- Taxon concept = Taxon.NewInstance(conceptName, null);
-
+ Taxon relatedConcept = TaxonBaseSelectionDialog.selectTaxon(HandlerUtil.getActiveShell(event), editor.getConversationHolder());
+
TaxonRelationshipType type = (TaxonRelationshipType) ((Event)event.getTrigger()).data;
- AbstractPostOperation operation;
+ IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
+ IPostOperationEnabled postOperationEnabled = (activePart instanceof IPostOperationEnabled) ? (IPostOperationEnabled) activePart : null;
+
try {
- operation = new CreateConceptRelationOperation(event.getCommand().getName(),
- editor.getUndoContext(), editor.getTaxon(), concept, type, editor);
+ AbstractPostOperation operation = new CreateConceptRelationOperation(event.getCommand().getName(),
+ editor.getUndoContext(), editor.getTaxon(), relatedConcept, type, postOperationEnabled);
EditorUtil.executeOperation(operation);
} catch (NotDefinedException e) {
logger.warn("Command name not set");
* See LICENSE.TXT at the top of this package for the full license terms.
*/
-package eu.etaxonomy.taxeditor.editor.name.handler;
+package eu.etaxonomy.taxeditor.editor.view.concept.handler;
+
/**
--- /dev/null
+// $Id$
+/**
+* Copyright (C) 2007 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+
+package eu.etaxonomy.taxeditor.editor.view.concept.handler;
+
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.commands.common.NotDefinedException;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;
+import eu.etaxonomy.taxeditor.editor.EditorUtil;
+import eu.etaxonomy.taxeditor.editor.Page;
+import eu.etaxonomy.taxeditor.editor.name.TaxonNameEditor;
+import eu.etaxonomy.taxeditor.editor.view.concept.operation.DeleteConceptRelationOperation;
+import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
+import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
+
+/**
+ * @author n.hoffmann
+ * @created Jan 25, 2011
+ * @version 1.0
+ */
+public class DeleteConceptRelationHandler extends AbstractHandler {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+ */
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ TaxonNameEditor editor = (TaxonNameEditor) EditorUtil.getActiveEditorPage(
+ Page.NAME);
+
+ ISelection selection = HandlerUtil.getActiveMenuSelection(event);
+
+ Set<TaxonRelationship> relations = new HashSet<TaxonRelationship>();
+
+ if(selection instanceof IStructuredSelection){
+ IStructuredSelection structuredSelection = (IStructuredSelection) selection;
+ Iterator iterator = structuredSelection.iterator();
+
+ while (iterator.hasNext()){
+ Object element = iterator.next();
+ if(element instanceof TaxonRelationship){
+ relations.add((TaxonRelationship) element);
+ }
+ }
+ }
+
+ IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
+ IPostOperationEnabled postOperationEnabled = (activePart instanceof IPostOperationEnabled) ? (IPostOperationEnabled) activePart : null;
+
+ try {
+ AbstractPostOperation operation = new DeleteConceptRelationOperation(event.getCommand().getName(),
+ editor.getUndoContext(), editor.getTaxon(), relations, postOperationEnabled);
+ EditorUtil.executeOperation(operation);
+ } catch (NotDefinedException e) {
+ EditorUtil.warn(getClass(), "Command name not set");
+ }
+
+ return null;
+ }
+}
--- /dev/null
+// $Id$
+/**
+* Copyright (C) 2007 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+
+package eu.etaxonomy.taxeditor.editor.view.concept.handler;
+
+import java.util.Iterator;
+
+import org.eclipse.core.commands.AbstractHandler;
+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.model.taxon.Taxon;
+import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;
+import eu.etaxonomy.taxeditor.editor.EditorUtil;
+import eu.etaxonomy.taxeditor.editor.MultiPageTaxonEditor;
+
+/**
+ * @author n.hoffmann
+ * @created Jan 25, 2011
+ * @version 1.0
+ */
+public class OpenRelatedConceptHandler extends AbstractHandler {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+ */
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ MultiPageTaxonEditor editor = EditorUtil.getActiveMultiPageTaxonEditor();
+
+ ISelection selection = HandlerUtil.getActiveMenuSelection(event);
+
+ if(selection instanceof IStructuredSelection){
+ IStructuredSelection structuredSelection = (IStructuredSelection) selection;
+ Iterator iterator = structuredSelection.iterator();
+
+ while (iterator.hasNext()){
+ Object element = iterator.next();
+ if(element instanceof TaxonRelationship){
+ Taxon relatedTaxon = getRelatedTaxon((TaxonRelationship) element, editor.getTaxon());
+
+ try {
+ EditorUtil.openTaxonBase(relatedTaxon.getUuid());
+ } catch (PartInitException e) {
+ EditorUtil.errorDialog("Could not open taxon", getClass(),
+ String.format("Could not open the taxon: %s" ,relatedTaxon), e);
+ }
+ }
+ }
+ }
+
+ return null;
+ }
+
+
+ private Taxon getRelatedTaxon(TaxonRelationship relationship, Taxon taxon){
+ if (relationship.getFromTaxon().equals(taxon)){
+ return relationship.getToTaxon();
+ }
+ else if(relationship.getToTaxon().equals(taxon)){
+ return relationship.getFromTaxon();
+ }
+ else{
+ return null;
+ }
+ }
+}
* See LICENSE.TXT at the top of this package for the full license terms.
*/
-package eu.etaxonomy.taxeditor.editor.name.operation;
+package eu.etaxonomy.taxeditor.editor.view.concept.operation;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.commands.operations.IUndoContext;
--- /dev/null
+/**
+* Copyright (C) 2007 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+
+package eu.etaxonomy.taxeditor.editor.view.concept.operation;
+
+import java.util.Set;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.commands.operations.IUndoContext;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+
+import eu.etaxonomy.cdm.model.taxon.Taxon;
+import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;
+import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
+import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
+
+/**
+ * Deletes given relations between two taxa.
+ *
+ * @author p.ciardelli
+ * @author n.hoffmann
+ * @created 29.01.2009
+ * @version 1.0
+ */
+public class DeleteConceptRelationOperation extends AbstractPostOperation {
+
+ private Set<TaxonRelationship> taxonRelationships;
+
+
+ /**
+ * @param name
+ * @param undoContext
+ * @param relation
+ * @param postOperationEnabled
+ */
+ public DeleteConceptRelationOperation(String label,
+ IUndoContext undoContext, Taxon taxon, Set<TaxonRelationship> relations,
+ IPostOperationEnabled postOperationEnabled) {
+ super(label, undoContext, taxon, postOperationEnabled);
+
+ taxonRelationships = relations;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
+ */
+ /** {@inheritDoc} */
+ @Override
+ public IStatus execute(IProgressMonitor monitor, IAdaptable info)
+ throws ExecutionException {
+
+ monitor.worked(20);
+
+ // Remove relation from taxon
+ for(TaxonRelationship relationship : taxonRelationships){
+ taxon.removeTaxonRelation(relationship);
+ monitor.worked(10);
+ }
+ monitor.worked(10);
+
+ return postExecute(taxon);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
+ */
+ /** {@inheritDoc} */
+ @Override
+ public IStatus redo(IProgressMonitor monitor, IAdaptable info)
+ throws ExecutionException {
+ return execute(monitor, info);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
+ */
+ /** {@inheritDoc} */
+ @Override
+ public IStatus undo(IProgressMonitor monitor, IAdaptable info)
+ throws ExecutionException {
+
+ for(TaxonRelationship relationship : taxonRelationships){
+ taxon.addTaxonRelation(relationship);
+ monitor.worked(10);
+ }
+
+ return postExecute(taxon);
+ }
+}
import eu.etaxonomy.cdm.model.taxon.Taxon;
import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;
import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
-import eu.etaxonomy.taxeditor.editor.name.operation.CreateConceptRelationOperation;
+import eu.etaxonomy.taxeditor.editor.view.concept.operation.CreateConceptRelationOperation;
import eu.etaxonomy.taxeditor.store.operations.AbstractTaxeditorOperationTest;
/**
}
/**
- * Test method for {@link eu.etaxonomy.taxeditor.editor.name.operation.CreateConceptRelationOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
+ * Test method for {@link eu.etaxonomy.taxeditor.editor.view.concept.operation.CreateConceptRelationOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
* @throws ExecutionException
*/
@Test
}
/**
- * Test method for {@link eu.etaxonomy.taxeditor.editor.name.operation.CreateConceptRelationOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
+ * Test method for {@link eu.etaxonomy.taxeditor.editor.view.concept.operation.CreateConceptRelationOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
* @throws ExecutionException
*/
@Test
}
/**
- * Test method for {@link eu.etaxonomy.taxeditor.editor.name.operation.CreateConceptRelationOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
+ * Test method for {@link eu.etaxonomy.taxeditor.editor.view.concept.operation.CreateConceptRelationOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
* @throws ExecutionException
*/
@Test
import eu.etaxonomy.cdm.model.common.ICdmBase;
import eu.etaxonomy.cdm.model.taxon.Taxon;
import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
-import eu.etaxonomy.taxeditor.editor.name.operation.DeleteConceptRelationOperation;
import eu.etaxonomy.taxeditor.store.operations.AbstractTaxeditorOperationTest;
/**
Assert.assertTrue(taxon.getTaxonRelations().size() > 0);
- operation = new DeleteConceptRelationOperation("", undoContext, taxon, relatedTaxon, postOperation);
+// operation = new DeleteConceptRelationOperation("", undoContext, taxon, relatedTaxon, postOperation);
}
/**
- * Test method for {@link eu.etaxonomy.taxeditor.editor.name.operation.DeleteConceptRelationOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
+ * Test method for {@link eu.etaxonomy.taxeditor.editor.view.concept.operation.DeleteConceptRelationOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
* @throws ExecutionException
*/
@Test
}
/**
- * Test method for {@link eu.etaxonomy.taxeditor.editor.name.operation.DeleteConceptRelationOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
+ * Test method for {@link eu.etaxonomy.taxeditor.editor.view.concept.operation.DeleteConceptRelationOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
* @throws ExecutionException
*/
@Test
}
/**
- * Test method for {@link eu.etaxonomy.taxeditor.editor.name.operation.DeleteConceptRelationOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
+ * Test method for {@link eu.etaxonomy.taxeditor.editor.view.concept.operation.DeleteConceptRelationOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
* @throws ExecutionException
*/
@Test
import org.eclipse.jface.resource.ImageRegistry;
import org.eclipse.swt.graphics.Image;
+import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
import eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin;
/**