had to rename the packages to make them compliant with buckminster
[taxeditor.git] / taxeditor-editor / src / main / java / eu / etaxonomy / taxeditor / editor / key / polytomous / PolytomousKeyEditor.java
diff --git a/taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/polytomous/PolytomousKeyEditor.java b/taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/polytomous/PolytomousKeyEditor.java
deleted file mode 100644 (file)
index cd145fc..0000000
+++ /dev/null
@@ -1,156 +0,0 @@
-/**
- * 
- */
-package eu.etaxonomy.taxeditor.editor.key.polytomous;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jface.viewers.IBaseLabelProvider;
-import org.eclipse.jface.viewers.IContentProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.zest.core.viewers.IGraphContentProvider;
-
-import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
-import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
-import eu.etaxonomy.cdm.model.description.PolytomousKey;
-import eu.etaxonomy.cdm.model.description.PolytomousKeyNode;
-import eu.etaxonomy.taxeditor.editor.key.AbstractKeyEditor;
-import eu.etaxonomy.taxeditor.store.CdmStore;
-
-/**
- * @author n.hoffmann
- *
- */
-public class PolytomousKeyEditor extends AbstractKeyEditor<PolytomousKey> {
-       
-       private class PolytomousKeyRelationship {
-               private Object destination;
-               private Object source;
-
-               PolytomousKeyRelationship(Object source, Object destination){
-                       this.source = HibernateProxyHelper.deproxy(source);
-                       this.destination = HibernateProxyHelper.deproxy(destination);
-               }
-       }
-       
-       private class ContentProvider implements IGraphContentProvider{
-               
-               private List<PolytomousKeyRelationship> relations;
-               
-               @Override
-               public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
-                       
-               }
-               
-               @Override
-               public void dispose() {
-                       
-               }
-               
-               @Override
-               public Object[] getElements(Object inputElement) {
-                       relations = new ArrayList<PolytomousKeyRelationship>();
-                       
-                       if(inputElement instanceof PolytomousKey){      
-                               getTreeRecursively(relations, inputElement);
-                       }
-                       return relations.toArray();
-               }
-               
-               private void getTreeRecursively(List<PolytomousKeyRelationship> relations, Object parent){
-                       List<PolytomousKeyNode> children;
-                       
-                       if(parent instanceof PolytomousKeyNode){
-                               children = ((PolytomousKeyNode) parent).getChildren();
-                       }else if(parent instanceof PolytomousKey){
-                               children = ((PolytomousKey) parent).getRoot().getChildren();
-                       }else{
-                               throw new RuntimeException("Parent element has to be PolytomousKeyNode or PolytomousKey, but was: " + parent.getClass());
-                       }
-                       
-                       for(PolytomousKeyNode childNode : children){
-                               relations.add(new PolytomousKeyRelationship(parent, childNode));
-                               getTreeRecursively(relations, childNode);
-                       }
-               }
-               
-
-               @Override
-               public Object getSource(Object rel) {
-                       return ((PolytomousKeyRelationship) rel).source;
-               }
-
-               @Override
-               public Object getDestination(Object rel) {
-                       return ((PolytomousKeyRelationship) rel).destination;
-               }
-               
-       };
-       
-       private class PolytomousKeyLabelProvider extends LabelProvider{
-               @Override
-               public String getText(Object element) {
-                       if(element instanceof PolytomousKey){
-                               return ((PolytomousKey) element).getTitleCache();
-                       }else if(element instanceof PolytomousKeyNode){
-                               PolytomousKeyNode keyNode = (PolytomousKeyNode) element;
-                               
-                               if(keyNode.isLeaf()){
-                                       if(keyNode.getTaxon() != null){
-                                               return keyNode.getTaxon().getName().getTitleCache();
-                                       }
-                                       return "leaf but no taxon";
-                               }
-                               
-                               if(keyNode.getNodeNumber() != null){
-                                       return keyNode.getNodeNumber().toString();
-                               }else{
-                                       return "No node number set";
-                               }
-                       }else if(element instanceof PolytomousKeyRelationship){
-                               PolytomousKeyRelationship relationship = (PolytomousKeyRelationship) element;
-                               if(relationship.source instanceof PolytomousKeyNode){
-                                       PolytomousKeyNode sourceNode = (PolytomousKeyNode) relationship.source;
-                                       if(sourceNode.getQuestion() != null && sourceNode.getQuestion().getLabelText(CdmStore.getDefaultLanguage()) != null){
-                                               return sourceNode.getQuestion().getLabelText(CdmStore.getDefaultLanguage());
-                                       }
-                               }
-                       }
-                       return "";
-               }
-       };
-       
-       public static final String ID = "eu.etaxonomy.taxeditor.editor.key.polytomous";
-       
-       /**
-        * 
-        */
-       public PolytomousKeyEditor() {
-               super();
-       }
-       
-
-       @Override
-       public ConversationHolder getConversationHolder() {
-               return ((PolytomousKeyEditorInput) getEditorInput()).getConversationHolder();
-       }
-
-       @Override
-       public PolytomousKey getKey() {
-               return ((PolytomousKeyEditorInput) getEditorInput()).getKey();
-       }
-
-
-       @Override
-       protected IBaseLabelProvider getLabelProvider() {
-               return new PolytomousKeyLabelProvider();
-       }
-
-
-       @Override
-       protected IContentProvider getContentProvider() {
-               return new ContentProvider();
-       }       
-}