Fixes a problem where multiple polytomous key editors could not be opened
authorn.hoffmann <n.hoffmann@localhost>
Thu, 5 May 2011 12:54:30 +0000 (12:54 +0000)
committern.hoffmann <n.hoffmann@localhost>
Thu, 5 May 2011 12:54:30 +0000 (12:54 +0000)
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/AbstractIdentificationEditorInput.java
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/key/polytomous/PolytomousKeyViewPart.java
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/key/polytomous/handler/EditHandler.java

index ff1e6960f692be32886c2bcb8fa43726e810c62b..4bf11c90dff393d6db4ec30929588e7f2533bfbf 100644 (file)
@@ -98,5 +98,15 @@ public abstract class AbstractIdentificationEditorInput<T extends IIdentificatio
        @Override
        public void update(CdmDataChangeMap changeEvents) {
        }
+       
+       /* (non-Javadoc)
+        * @see java.lang.Object#equals(java.lang.Object)
+        */
+       @Override
+       public boolean equals(Object obj) {
+               // TODO Auto-generated method stub
+               boolean result = super.equals(obj);
+               return result;
+       }
 
 }
index 4909068443a423c6b545ad12dc69dc8758b3602b..342819f2358c9012a5838511537fdaa3dece1e6c 100644 (file)
@@ -130,7 +130,7 @@ public class PolytomousKeyViewPart extends ViewPart implements
                text_filter.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
                text_filter.addModifyListener(new FilterModifyListener());
                
-               viewer = new ListViewer(container, SWT.H_SCROLL | SWT.V_SCROLL);
+               viewer = new ListViewer(container, SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI);
                viewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
                
                viewer.setContentProvider(new PolytomousKeyContentProvider());
index 2e8bfce1840b8ea63ef6ea1dc0e2376ee7d276b3..6a514cc66b7ca49d52f3df6c65f4adf1869e03d3 100644 (file)
@@ -13,12 +13,17 @@ package eu.etaxonomy.taxeditor.navigation.key.polytomous.handler;
 import org.eclipse.core.commands.AbstractHandler;
 import org.eclipse.core.commands.ExecutionEvent;
 import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
 import org.eclipse.jface.viewers.ISelection;
 import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.ui.handlers.HandlerUtil;
+import org.eclipse.swt.widgets.Display;
 
 import eu.etaxonomy.cdm.model.description.PolytomousKey;
 import eu.etaxonomy.taxeditor.navigation.NavigationUtil;
+import eu.etaxonomy.taxeditor.navigation.key.polytomous.PolytomousKeyViewPart;
 
 /**
  * @author n.hoffmann
@@ -32,14 +37,40 @@ public class EditHandler extends AbstractHandler {
         */
        @Override
        public Object execute(ExecutionEvent event) throws ExecutionException {
-               ISelection selection = HandlerUtil.getCurrentSelection(event);
+               PolytomousKeyViewPart view = (PolytomousKeyViewPart) NavigationUtil.getView(PolytomousKeyViewPart.ID, false);
                
+               ISelection selection = view.getSite().getSelectionProvider().getSelection(); 
                if(selection instanceof StructuredSelection){
                        final StructuredSelection structuredSelection = (StructuredSelection) selection;
                
-                       if(structuredSelection.size() == 1 && structuredSelection.getFirstElement() instanceof PolytomousKey){
-                               NavigationUtil.openEditor((PolytomousKey) structuredSelection.getFirstElement());
-                       }
+                       Job job = new Job("Opening Polytomous Keys"){
+
+                               @Override
+                               protected IStatus run(IProgressMonitor monitor) {
+                                       monitor.beginTask("Opening Polytomous Keys", structuredSelection.size());
+                                       
+                                       for(final Object selectedObject : structuredSelection.toArray()){
+                                               if(selectedObject instanceof PolytomousKey){
+                                                       
+                                                       Display.getDefault().asyncExec(new Runnable(){
+
+                                                               @Override
+                                                               public void run() {
+                                                                       NavigationUtil.openEditor((PolytomousKey) selectedObject);
+                                                               }
+                                                               
+                                                       });
+                                                       monitor.worked(1);
+                                               }
+                                       }
+                                       monitor.done();
+                                       return Status.OK_STATUS;
+                               }
+                               
+                       };
+                       
+                       job.setPriority(Job.SHORT);
+                       job.schedule();                 
                        
                }
                return null;