fix #6418: set actual monitor to null and argument is final
authorKatja Luther <k.luther@bgbm.org>
Tue, 30 May 2017 11:42:47 +0000 (13:42 +0200)
committerKatja Luther <k.luther@bgbm.org>
Tue, 30 May 2017 11:43:38 +0000 (13:43 +0200)
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/referencingobjects/ReferencingObjectsView.java

index 510d01d4986c4b1a6069c44b3baa2982f12993d5..b595c38892fa00c600fd55b74f27507b467267f7 100644 (file)
@@ -20,7 +20,10 @@ import org.apache.log4j.Logger;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.IJobChangeEvent;
+import org.eclipse.core.runtime.jobs.IJobChangeListener;
 import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.core.runtime.jobs.JobChangeAdapter;
 import org.eclipse.jface.action.MenuManager;
 import org.eclipse.jface.viewers.CellEditor;
 import org.eclipse.jface.viewers.ICellModifier;
@@ -38,6 +41,7 @@ import org.eclipse.swt.widgets.Control;
 import org.eclipse.swt.widgets.Display;
 import org.eclipse.swt.widgets.Menu;
 import org.eclipse.swt.widgets.Table;
+import org.eclipse.ui.IActionBars;
 import org.eclipse.ui.IWorkbenchPart;
 import org.springframework.remoting.RemoteAccessException;
 
@@ -77,6 +81,7 @@ import eu.etaxonomy.cdm.model.taxon.TaxonBase;
 import eu.etaxonomy.cdm.model.taxon.TaxonNode;
 import eu.etaxonomy.taxeditor.model.DescriptionHelper;
 import eu.etaxonomy.taxeditor.session.ICdmEntitySession;
+import eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled;
 import eu.etaxonomy.taxeditor.store.CdmStore;
 import eu.etaxonomy.taxeditor.view.AbstractCdmViewPart;
 
@@ -95,7 +100,7 @@ public class ReferencingObjectsView extends AbstractCdmViewPart {
 
        private String referencedObjectTitleCache;
        private ConversationHolder conversation;
-       private final ICdmEntitySession cdmEntitySession;
+       //private final ICdmEntitySession cdmEntitySession;
        private UUID actualUuid;
        List<CdmBase> referencingObjects = null;
        Set<CdmBase> referencingObjectsSet = null;
@@ -103,7 +108,9 @@ public class ReferencingObjectsView extends AbstractCdmViewPart {
        private Job currentJob = null;
 
        public ReferencingObjectsView() {
-           cdmEntitySession = CdmStore.getCurrentSessionManager().bindNullSession();
+         // cdmEntitySession = CdmStore.getCurrentSessionManager().getNullSession();
+           
+               //cdmEntitySession = CdmStore.getCurrentSessionManager().bindNullSession();
        }
 
        /** {@inheritDoc} */
@@ -116,6 +123,7 @@ public class ReferencingObjectsView extends AbstractCdmViewPart {
                createColumns(viewer);
                viewer.setContentProvider(new ReferencingObjectsContentProvider());
                viewer.setLabelProvider(new ReferencingObjectsLabelProvider());
+               
                viewer.setCellModifier(new ICellModifier() {
             @Override
             public void modify(Object element, String property, Object value) {
@@ -182,7 +190,7 @@ public class ReferencingObjectsView extends AbstractCdmViewPart {
 
        @Override
        public void setFocus() {
-           cdmEntitySession.bind();
+          // cdmEntitySession.bind();
        }
 
        public void updateReferencingObjects(final UUID entityUUID, final Class objectClass) {
@@ -202,10 +210,10 @@ public class ReferencingObjectsView extends AbstractCdmViewPart {
                }
 
            }
-               currentJob = new Job("Update Referencing Objects " + entityUUID) {
+               currentJob = new Job("Update Referencing Objects") {
 
                        @Override
-                       protected IStatus run(IProgressMonitor monitor) {
+                       protected IStatus run(final IProgressMonitor monitor) {
                                monitor.beginTask("Calculating referencing objects", 100);
                                actualUuid = entityUUID;
 
@@ -221,8 +229,8 @@ public class ReferencingObjectsView extends AbstractCdmViewPart {
                                }
                                actualMonitor = monitor;
                                if (entityUUID != null){
-                                   ICdmEntitySession previousCdmEntitySession = CdmStore.getCurrentSessionManager().getActiveSession();
-                       cdmEntitySession.bind();
+//                                 ICdmEntitySession previousCdmEntitySession = CdmStore.getCurrentSessionManager().getActiveSession();
+//                     cdmEntitySession.bind();
                        referencingObjectsSet = getReferencingObjects(entityUUID, objectClass);
 
                        if(monitor.isCanceled()) {
@@ -241,23 +249,25 @@ public class ReferencingObjectsView extends AbstractCdmViewPart {
                        }
 
                        if(monitor.isCanceled()) {
-                           if(previousCdmEntitySession != null) {
-                               previousCdmEntitySession.bind();
-                           }
+//                         if(previousCdmEntitySession != null) {
+//                             previousCdmEntitySession.bind();
+//                         }
 
                            return Status.CANCEL_STATUS;
                        }
                        monitor.worked(80);
-                    updateView();
-
-                       if(previousCdmEntitySession != null) {
-                           previousCdmEntitySession.bind();
-                       }
+                    
+                       updateView();
+//                     if(previousCdmEntitySession != null) {
+//                         previousCdmEntitySession.bind();
+//                     }else{
+//                             CdmStore.getCurrentSessionManager().bind(null); 
+//                     }
                       // actualUuid = entityUUID;
                                }
                                monitor.done();
-
-
+                               actualMonitor = null;
+                               
                                return Status.OK_STATUS;
 
 
@@ -266,20 +276,6 @@ public class ReferencingObjectsView extends AbstractCdmViewPart {
                currentJob.setUser(true);
 
                currentJob.schedule();
-//             final IJobChangeListener listener;
-//             listener =  new JobChangeAdapter() {
-//            @Override
-//            public void done(IJobChangeEvent event) {
-//                System.err.println("Job is done" + entityUUID);
-//                //event.getJob().cancel();
-//            }
-//
-//        };
-//        currentJob.addJobChangeListener(listener);
-
-
-
-
        }
 
        private Set<CdmBase> getReferencingObjects(UUID entity, Class objectClass) {
@@ -391,6 +387,7 @@ public class ReferencingObjectsView extends AbstractCdmViewPart {
            Display.getDefault().asyncExec(new Runnable() {
             @Override
             public void run() {
+               
                        if (viewer != null && !viewer.getControl().isDisposed()){
                                try{
                                        viewer.setInput(referencingObjects);
@@ -399,7 +396,6 @@ public class ReferencingObjectsView extends AbstractCdmViewPart {
 
                                        //enable/disable table
                                        viewer.getControl().setEnabled(referencingObjects!=null);
-
                                }catch(Exception e){
                                    e.printStackTrace();
                                    logger.debug(e.getStackTrace());
@@ -416,11 +412,12 @@ public class ReferencingObjectsView extends AbstractCdmViewPart {
            Display.getDefault().asyncExec(new Runnable() {
             @Override
             public void run() {
-                   if (referencedObjectTitleCache != null){
+               if (referencedObjectTitleCache != null){
                     setContentDescription(description);
                 } else {
                     setContentDescription(description);
                 }
+                   
             }
 
          });
@@ -487,7 +484,7 @@ public class ReferencingObjectsView extends AbstractCdmViewPart {
                conversation.close();
                selectionService.removePostSelectionListener(this);
                selectionService.removeSelectionListener(this);
-               cdmEntitySession.dispose();
+               //cdmEntitySession.dispose();
                super.dispose();
 
        }