]> SALOME platform Git repositories - tools/siman.git/blobdiff - Workspace/Siman/src/org/splat/simer/ImportDocumentAction.java
Salome HOME
Update uses list functionality
[tools/siman.git] / Workspace / Siman / src / org / splat / simer / ImportDocumentAction.java
index 697f2b7d3a40b7490a05beedc8fc9630f42481b2..ed307e2ce165b5d59030d58c0df6e3de9a8c0312 100644 (file)
@@ -59,6 +59,21 @@ public class ImportDocumentAction extends BaseUploadDocumentAction {
         */
        private DocumentTypeService _documentTypeService;
 
+       /**
+        * Update uses documents list if chosen new type of import document.
+        * @return SUCCESS
+        */
+       public final  String updateUsesList() {
+               _mystudy = getOpenStudy();
+               _defuses = new ArrayList<Document>();
+               _deftype = getDocumentTypeService().selectType(
+                               (int) _documentType);
+               if (_deftype != null) {
+                       setupDefaultUses(_deftype);
+               }
+               return SUCCESS;
+       }
+
        /**
         * Initialize the operation.
         * 
@@ -212,9 +227,7 @@ public class ImportDocumentAction extends BaseUploadDocumentAction {
                initializationScreenContext(Constants.STUDY_MENU, Constants.STUDY_MENU,
                                Constants.TRUE);
 
-               if (_action == ToDo.cancel) {
-                       res = "cancel";
-               } else if (_documentType == 0) {
+               if (_documentType == 0) {
                        setErrorCode("message.error.import.type");
 
                        initializationFullScreenContext(Constants.STUDY_MENU,
@@ -224,6 +237,7 @@ public class ImportDocumentAction extends BaseUploadDocumentAction {
                        try {
                                // Getting user inputs
                                _mystudy = getOpenStudy();
+                               _mystudy.updateCurrentStep(); //update current step 
                                User user = getConnectedUser();
                                Step step = _mystudy.getSelectedStep();
                                Date aDate = null;
@@ -265,7 +279,12 @@ public class ImportDocumentAction extends BaseUploadDocumentAction {
                                //
                                // if (send != null) send.converts(addoc); // Asynchronous process
 
-                               _mystudy.add(addoc); // Updates the presentation
+                               if (uses.isEmpty()) {
+                                       _mystudy.add(addoc); // Updates the presentation
+                               } else {
+                                       // Re-opening (refreshing) the currently open study
+                                       refreshStudy();
+                               }
                                res = SUCCESS;
                        } catch (FileNotFoundException error) {
                                LOG.error("Reason:", error);
@@ -442,4 +461,4 @@ public class ImportDocumentAction extends BaseUploadDocumentAction {
        public List<Boolean> getReviewable() {
                return _reviewable;
        }
-}
\ No newline at end of file
+}