AT: commiting latest changes to the Palm Use data extension and merger
authora.theys <a.theys@localhost>
Thu, 1 Mar 2012 10:12:22 +0000 (10:12 +0000)
committera.theys <a.theys@localhost>
Thu, 1 Mar 2012 10:12:22 +0000 (10:12 +0000)
1  2 
eu.etaxonomy.taxeditor.editor/META-INF/MANIFEST.MF
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/uses/UsesViewPart.java
eu.etaxonomy.taxeditor.store/META-INF/MANIFEST.MF
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/combo/TermComboElement.java

index cfe3bb91097ebd4ee39eb04ff904844363aa7e63,0000000000000000000000000000000000000000..a98e3e27e3bf017a43fcd842c7f6f0fd540609a0
mode 100644,000000..100644
--- /dev/null
@@@ -1,254 -1,0 +1,277 @@@
-       public void changed(Object object) {\r
-               for(FeatureNodeContainerTree containerTree : featureNodeContainerCache.values()){\r
-                       containerTree.buildTree();\r
-               }\r
-               viewer.refresh();\r
-               \r
-               /*if(object instanceof DescriptionElementBase){\r
-                       DescriptionElementBase descriptionElement = (DescriptionElementBase) object;\r
-                       DescriptionBase description = descriptionElement.getInDescription();\r
-                       FeatureNodeContainerTree containerTree = featureNodeContainerCache.get(description);\r
-                       \r
-                       FeatureNodeContainer featureNodeContainer = containerTree.getFeatureNodeContainerForDescriptionElement(descriptionElement);\r
-                       viewer.expandToLevel(featureNodeContainer, 1);\r
-                       \r
-               }*/\r
 +package eu.etaxonomy.taxeditor.editor.view.uses;\r
 +\r
 +import java.util.HashMap;\r
 +import java.util.Map;\r
 +\r
 +import org.eclipse.jface.action.Action;\r
 +import org.eclipse.jface.action.GroupMarker;\r
 +import org.eclipse.jface.action.IToolBarManager;\r
 +import org.eclipse.jface.action.MenuManager;\r
 +import org.eclipse.jface.resource.ImageDescriptor;\r
 +import org.eclipse.jface.viewers.ISelection;\r
 +import org.eclipse.jface.viewers.StructuredSelection;\r
 +import org.eclipse.jface.viewers.TreeViewer;\r
 +import org.eclipse.jface.viewers.Viewer;\r
 +import org.eclipse.swt.SWT;\r
 +import org.eclipse.swt.dnd.DND;\r
 +import org.eclipse.swt.dnd.Transfer;\r
 +import org.eclipse.swt.graphics.ImageData;\r
 +import org.eclipse.swt.widgets.Composite;\r
 +import org.eclipse.swt.widgets.Control;\r
 +import org.eclipse.swt.widgets.Menu;\r
 +import org.eclipse.swt.widgets.Tree;\r
++import org.eclipse.ui.IEditorInput;\r
 +import org.eclipse.ui.IEditorPart;\r
 +import org.eclipse.ui.IWorkbenchActionConstants;\r
 +import org.eclipse.ui.IWorkbenchPart;\r
 +\r
 +import eu.etaxonomy.cdm.model.common.CdmBase;\r
 +import eu.etaxonomy.cdm.model.description.DescriptionBase;\r
 +import eu.etaxonomy.cdm.model.description.DescriptionElementBase;\r
 +import eu.etaxonomy.cdm.model.description.TaxonDescription;\r
 +import eu.etaxonomy.cdm.api.service.IDescriptionService;\r
 +import eu.etaxonomy.taxeditor.bulkeditor.BulkEditor;\r
 +import eu.etaxonomy.taxeditor.editor.EditorUtil;\r
 +import eu.etaxonomy.taxeditor.editor.MultiPageTaxonEditor;\r
 +import eu.etaxonomy.taxeditor.editor.TaxonEditorInput;\r
++import eu.etaxonomy.taxeditor.editor.definedterm.DefinedTermEditor;\r
 +import eu.etaxonomy.taxeditor.editor.key.AbstractGraphKeyEditor;\r
 +import eu.etaxonomy.taxeditor.editor.view.descriptive.DescriptionElementDragListener;\r
 +import eu.etaxonomy.taxeditor.editor.view.descriptive.DescriptionElementDropAdapter;\r
 +import eu.etaxonomy.taxeditor.editor.view.descriptive.DescriptionElementTransfer;\r
 +import eu.etaxonomy.taxeditor.editor.view.descriptive.DescriptiveViewerSorter;\r
 +import eu.etaxonomy.taxeditor.model.FeatureNodeContainer;\r
 +import eu.etaxonomy.taxeditor.model.FeatureNodeContainerTree;\r
 +import eu.etaxonomy.taxeditor.model.IPartContentHasDetails;\r
 +import eu.etaxonomy.taxeditor.model.IPartContentHasSupplementalData;\r
 +import eu.etaxonomy.taxeditor.model.ImageResources;\r
 +import eu.etaxonomy.taxeditor.view.AbstractCdmEditorViewPart;\r
 +\r
 +\r
 +\r
 +public class UsesViewPart extends AbstractCdmEditorViewPart implements IPartContentHasDetails, IPartContentHasSupplementalData {\r
 +      \r
 +      public static final String ID = "eu.etaxonomy.taxeditor.editor.view.uses";\r
 +      private TreeViewer viewer;\r
 +      private Map<TaxonDescription, FeatureNodeContainerTree> featureNodeContainerCache = new HashMap<TaxonDescription, FeatureNodeContainerTree>();\r
 +      private ToggleDescriptionAction showAllElementsAction;\r
 +      private ToggleDescriptionAction hideAllElementsAction;\r
 +\r
 +      private int dndOperations = DND.DROP_COPY | DND.DROP_MOVE;\r
 +      \r
 +      /** {@inheritDoc} */\r
 +      @Override\r
 +      public void createViewer(Composite parent) {\r
 +              \r
 +              viewer = new TreeViewer(new Tree(parent, SWT.MULTI | SWT.H_SCROLL\r
 +                              | SWT.V_SCROLL | SWT.FULL_SELECTION));\r
 +                              \r
 +              viewer.setContentProvider(new UsesContentProvider(featureNodeContainerCache));          \r
 +              \r
 +              //viewer.setInput(descService.listTaxonDescriptions(Taxon, null, null, null, null, null, null));\r
 +              \r
 +              viewer.setLabelProvider(new UsesLabelProvider());\r
 +              \r
 +              //viewer.setSorter(new DescriptiveViewerSorter());\r
 +              \r
 +              viewer.setAutoExpandLevel(2);\r
 +              \r
 +              \r
 +              \r
 +              Transfer[] transfers = new Transfer[] { DescriptionElementTransfer.getInstance() };\r
 +              /*viewer.addDragSupport(dndOperations, transfers, new DescriptionElementDragListener(\r
 +                              this));\r
 +              viewer.addDropSupport(dndOperations, transfers,\r
 +                              new DescriptionElementDropAdapter(viewer));*/\r
 +                                              \r
 +              // Propagate selection from viewer\r
 +              getSite().setSelectionProvider(viewer);\r
 +              \r
 +              showAllElementsAction = new ToggleDescriptionAction(false);             \r
 +              hideAllElementsAction = new ToggleDescriptionAction(true);\r
 +              \r
 +              // Add context menu to tree\r
 +              createMenu();\r
 +              \r
 +              createToolbar();\r
 +              \r
 +              // set initial input\r
 +//            if(getEditor() != null){\r
 +//                    viewer.setInput(getEditor().getEditorInput());\r
 +//            }\r
 +      }\r
 +      \r
++\r
++      /* (non-Javadoc)\r
++       * @see eu.etaxonomy.taxeditor.model.AbstractCdmViewPart#getInitialSelection()\r
++       */\r
++      /** {@inheritDoc} */\r
++      @Override\r
++      protected ISelection getInitialSelection() {\r
++              if(getEditor() != null){\r
++                      return new StructuredSelection(getEditor().getEditorInput());\r
++              }       \r
++              \r
++              return super.getInitialSelection();\r
++      }\r
++      \r
 +      private void createToolbar() {\r
 +              IToolBarManager toolBarManager = getViewSite().getActionBars().getToolBarManager();\r
 +              toolBarManager.add(showAllElementsAction);\r
 +              toolBarManager.add(hideAllElementsAction);\r
 +      }\r
 +      \r
++      \r
 +      private void createMenu(){\r
 +              MenuManager menuManager = new MenuManager();\r
 +              menuManager.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));\r
 +              \r
 +              getSite().registerContextMenu(menuManager, viewer);\r
 +\r
 +              // FIXME for some reason this is not working\r
 +              menuManager.add(showAllElementsAction);\r
 +              menuManager.add(hideAllElementsAction);\r
 +                              \r
 +              Control control = viewer.getControl();\r
 +              Menu menu = menuManager.createContextMenu(control);\r
 +              \r
 +              control.setMenu(menu);  \r
 +      }\r
 +      \r
-               if(object != null){\r
-                       StructuredSelection selection = new StructuredSelection(object);\r
-                       viewer.setSelection(selection, true);\r
-               }\r
\r
-               super.changed(object);\r
-       }\r
-       \r
-       \r
-       /* (non-Javadoc)\r
-        * @see eu.etaxonomy.taxeditor.model.AbstractCdmViewPart#getInitialSelection()\r
-        */\r
-       /** {@inheritDoc} */\r
-       @Override\r
-       protected ISelection getInitialSelection() {\r
-               if(getEditor() != null){\r
-                       return new StructuredSelection(getEditor().getEditorInput());\r
-               }       \r
-               \r
-               return super.getInitialSelection();\r
-       }\r
-       \r
-       /** {@inheritDoc} */\r
-       @Override\r
-       public boolean postOperation(CdmBase objectAffectedByOperation) {\r
-               return super.postOperation(objectAffectedByOperation);\r
-       }\r
 +\r
-                               TaxonEditorInput input = (TaxonEditorInput)((IEditorPart) part).getEditorInput();\r
 +      \r
 +      @Override\r
 +      public void selectionChanged(IWorkbenchPart part, ISelection selection) {\r
 +              if(EditorUtil.getActiveEditor() == null){\r
 +                      showEmptyPage();\r
 +                      return;\r
 +              }\r
 +              \r
 +              if(part instanceof BulkEditor){\r
 +                      showEmptyPage();\r
 +                      return;\r
 +              }\r
 +              \r
 +              if(part instanceof AbstractGraphKeyEditor){\r
 +                      showEmptyPage();\r
 +                      return;\r
 +              }\r
 +              \r
++              if(part instanceof DefinedTermEditor){\r
++                      showEmptyPage();\r
++                      return;\r
++              }\r
++              \r
 +              if(part instanceof MultiPageTaxonEditor){\r
 +                      if(! part.equals(this.part)){\r
-       @Override\r
-       public boolean onComplete() {\r
-               return false;\r
-       }\r
++                              //TaxonEditorInput input = (TaxonEditorInput)((IEditorPart) part).getEditorInput();\r
++                              IEditorInput input = ((IEditorPart) part).getEditorInput();\r
 +                              featureNodeContainerCache.clear();\r
 +                              //showViewer(part, new StructuredSelection(CdmStore.getService(IDescriptionService.class).listTaxonDescriptions(input.getTaxonNode().getTaxon(), null, null, null, null, null, null)));\r
 +                              showViewer(part, new StructuredSelection(input));\r
 +                      }\r
 +                      showViewer();\r
 +              }\r
 +              \r
 +      }\r
 +\r
-       @Override\r
-       public Viewer getViewer() {\r
-               return viewer;\r
-       }\r
++\r
 +\r
 +      /*@Override\r
 +      public void showViewer(IWorkbenchPart part, IStructuredSelection selection) {\r
 +              this.part = part;               \r
 +      \r
 +              Object element = selection.getFirstElement();\r
 +              \r
 +              getViewer().setInput(descService.listTaxonDescriptions((Taxon) element, null, null, null, null, null, null));\r
 +              \r
 +              showViewer();   \r
 +      }*/\r
 +      \r
++      \r
 +      \r
 +      private class ToggleDescriptionAction extends Action{\r
 +              private boolean expanded;\r
 +              \r
 +              public ToggleDescriptionAction(boolean expand){\r
 +                      super(null, Action.AS_PUSH_BUTTON);\r
 +                      expanded = expand;\r
 +                      setImageAndTooltip();\r
 +              }\r
 +              \r
 +              private void setImageAndTooltip(){\r
 +                      setImageDescriptor(new ImageDescriptor() {\r
 +                              @Override\r
 +                              public ImageData getImageData() {\r
 +                                      setText(expanded ? "Collapse All" : "Expand All");\r
 +                                      String resource = expanded ? ImageResources.COLLAPSE_ALL : ImageResources.EXPAND_ALL;\r
 +                                      return ImageResources.getImage(resource).getImageData();\r
 +                              }\r
 +                      });\r
 +                      \r
 +                      String toolTipText = expanded ? "Collapse all" : "Show all descriptive data";\r
 +                      setToolTipText(toolTipText);\r
 +              }\r
 +              \r
 +              @Override\r
 +              public void run() {\r
 +                      if(expanded){\r
 +                              viewer.collapseAll();\r
 +                      }else{\r
 +                              viewer.expandAll();\r
 +                      }\r
 +                      setImageAndTooltip();\r
 +              }\r
 +      }\r
++      \r
++      /** {@inheritDoc} */\r
++      @Override\r
++      public boolean postOperation(CdmBase objectAffectedByOperation) {\r
++              viewer.refresh();\r
++              return super.postOperation(objectAffectedByOperation);\r
++      }\r
++      \r
++      /** {@inheritDoc} */\r
++      @Override\r
++      public void changed(Object object) {\r
++              for(FeatureNodeContainerTree containerTree : featureNodeContainerCache.values()){\r
++                      containerTree.buildTree();\r
++              }\r
++              viewer.refresh();\r
++              \r
++              if(object instanceof DescriptionElementBase){\r
++                      DescriptionElementBase descriptionElement = (DescriptionElementBase) object;\r
++                      DescriptionBase description = descriptionElement.getInDescription();\r
++                      FeatureNodeContainerTree containerTree = featureNodeContainerCache.get(description);\r
++                      \r
++                      FeatureNodeContainer featureNodeContainer = containerTree.getFeatureNodeContainerForDescriptionElement(descriptionElement);\r
++                      viewer.expandToLevel(featureNodeContainer, 1);\r
++                      \r
++              }\r
++\r
++              if(object != null){\r
++                      StructuredSelection selection = new StructuredSelection(object);\r
++                      viewer.setSelection(selection, true);\r
++              }\r
++\r
++              super.changed(object);\r
++      }\r
++      \r
 +\r
++      /** {@inheritDoc} */\r
++      @Override\r
++      public Viewer getViewer() {\r
++              return viewer;\r
++      }\r
 +      \r
++      /**\r
++       * <p>onComplete</p>\r
++       *\r
++       * @return a boolean.\r
++       */\r
++      @Override\r
++      public boolean onComplete() {\r
++              return false;\r
++      }\r
 +\r
 +}\r
index 8c5fba40a769d5fac4e06072e863664a1fb79516,08f00c59fa08dfad5251dd228b9651c5fe96bae4..17e8eb8e8c7aa2c648ded5fd011eb26c6ca9cd6f
@@@ -189,9 -191,9 +191,9 @@@ public class TermComboElement<T extend
                        if (label == null) {
                                if (term.getTitleCache() != null) {
                                        label = term.getTitleCache();
--                                      StoreUtil.error(getClass(),
++                                      StoreUtil.warn(getClass(),
                                                        "Term does not have a representation: " + term
--                                                                      + ", " + term.getUuid(), null);
++                                                                      + ", " + term.getUuid());
                                } else {
                                        label = "Unknown";
                                        StoreUtil.error(getClass(),