]> SALOME platform Git repositories - tools/siman.git/blobdiff - Workspace/Siman/src/org/splat/simer/EditDocumentAction.java
Salome HOME
Fix of document popup menu refreshing after document import, delete and version....
[tools/siman.git] / Workspace / Siman / src / org / splat / simer / EditDocumentAction.java
index 66689767a7936babbcbe23fb5c0edbc7c17fa88e..ab8b2fb04ae396775f7079bbf81b388fb99b0c89 100644 (file)
@@ -53,12 +53,15 @@ public class EditDocumentAction extends DisplayStudyStepAction {
         * Operations enumeration.
         */
        private enum Execute {
+               /**
+                * Possible document operations.
+                */
                renameDocument, accept, promote, demote, review, invalidate, approve, disapprove
        };
 
-       // ==============================================================================================================================
+       // =========================================================================
        // Action methods
-       // ==============================================================================================================================
+       // =========================================================================
 
        /**
         * Open a study.
@@ -111,7 +114,8 @@ public class EditDocumentAction extends DisplayStudyStepAction {
                                getPublicationService().approve(doc,
                                                Calendar.getInstance().getTime());
                                _openStudy.update(doc);
-                               _openStudy.getMenu().refreshSelectedItem(); // Updates the menu icon, in case of other documents in approved state
+                               // Update the menu icon, in case of other documents in approved state
+                               _openStudy.getMenu().refreshSelectedItem();
                        }
                        res = SUCCESS;
                } catch (RuntimeException saverror) {
@@ -175,10 +179,10 @@ public class EditDocumentAction extends DisplayStudyStepAction {
                        Step step = _openStudy.getSelectedStep();
                        Publication edited = step.getDocument(Long.valueOf(_index));
                        Date modifTime = Calendar.getInstance().getTime();
-                       
+
                        // Replace the document source file
                        getPublicationService().replace(edited, upfile, modifTime);
-                       
+
                        _openStudy.update(edited);
                        res = SUCCESS;
                } catch (Exception error) {
@@ -202,25 +206,22 @@ public class EditDocumentAction extends DisplayStudyStepAction {
                setMenu();
                _openStudy = getOpenStudy();
                Step step = _openStudy.getSelectedStep();
-               Publication doctag = step.getDocument(Long.valueOf(_index));
-               Long prevVersion = 0L;
-               if (doctag.value().getPreviousVersion() != null) {
-                       prevVersion = doctag.value().getPreviousVersion().getIndex();
-               }
 
                if (getStepService().removeDocument(step, Long.valueOf(_index))) { // Updates the data structure
-                       _openStudy.remove(doctag); // Updates the presentation
-                       // The previous version must be republished if any
-                       if (prevVersion > 0) {
-                               _openStudy.add(step.getDocument(prevVersion));
+                       // Re-opening (refreshing) the currently open study
+                       if (_selection == null) { // Opening a study just newed
+                               _selection = _openStudy.getSelection(); // Default selection
                        }
+                       _openStudy = open(getStudyService().selectStudy(
+                                       _openStudy.getIndex())); // Closes the previously open study
+                       _openStudy.setSelection(_selection);
                }
                return SUCCESS;
        }
 
-       // ==============================================================================================================================
+       // =========================================================================
        // Getters and setters
-       // ==============================================================================================================================
+       // =========================================================================
 
        /**
         * Set the document title.