]> SALOME platform Git repositories - tools/siman.git/commitdiff
Salome HOME
Fix of document popup menu refreshing after document import, delete and version....
authorrkv <rkv@opencascade.com>
Thu, 18 Apr 2013 13:09:52 +0000 (13:09 +0000)
committerrkv <rkv@opencascade.com>
Thu, 18 Apr 2013 13:09:52 +0000 (13:09 +0000)
Workspace/Siman-Common/src/org/splat/service/PublicationServiceImpl.java
Workspace/Siman-Common/src/org/splat/service/StepServiceImpl.java
Workspace/Siman-Common/src/org/splat/som/DocumentRights.java
Workspace/Siman/src/org/splat/simer/BaseUploadDocumentAction.java
Workspace/Siman/src/org/splat/simer/EditDocumentAction.java
Workspace/Siman/src/org/splat/simer/ImportDocumentAction.java
Workspace/Siman/src/org/splat/simer/VersionDocumentAction.java

index a901160ce2db1139905cd1dd7e48963c42cf04af..dd01f84b6133acfc24185fd0ddbfe01841d38269 100644 (file)
@@ -304,9 +304,7 @@ public class PublicationServiceImpl implements PublicationService {
                                compatible.add(docusedby[i]);
                        }
                }
-               List<Publication> relist = current.getRelations(UsedByRelation.class);
-               for (Iterator<Publication> i = relist.iterator(); i.hasNext();) {
-                       Publication using = i.next();
+               for (Publication using : current.getRelations(UsedByRelation.class)) {
                        if (!compatible.contains(using.getIndex())) {
                                outdate(using);
                        }
index 6e8e04a718ded14a8d9a5d356fa5c2bf2f0a857b..29d53c0468181c367d2c03809dbddf55f6166595 100644 (file)
@@ -501,6 +501,7 @@ public class StepServiceImpl implements StepService {
                        // Republish the previous version if any to avoid it becoming an orphan
                        Document prevVersion = torem.value().getPreviousVersion();
                        if (prevVersion != null) {
+                               prevVersion.setHistory(prevVersion.getHistory() - 1);
                                add(aStep, new Publication(prevVersion, aStep.getOwner()));
                                getProjectElementDAO().merge(aStep.getOwner());
                        }
index 571b419e1a34e8791a28a3cda9393ad1c1dacbb1..ab19e9c5ecff06d2499eaa41621616e098575b46 100644 (file)
@@ -300,7 +300,8 @@ public class DocumentRights {
                        return false;
                }
 
-               List<Publication> using = _operand.getRelations(UsedByRelation.class);
+               List<Relation> using = _operand.value().getRelations(
+                               UsedByRelation.class);
                return using.isEmpty();
        }
 
index c54d9503f3f58461b4d610ef4a0a5e8431a5185b..008b7903d693ceb0bc280bb75c251a89ce690d49 100644 (file)
@@ -250,7 +250,7 @@ public class BaseUploadDocumentAction extends AbstractUploadNextAction {
        // ==============================================================================================================================
        // Getters and setters
        // ==============================================================================================================================
-       
+
        public DocumentType getDefaultDocumentType() {
                return _deftype;
        }
@@ -287,13 +287,13 @@ public class BaseUploadDocumentAction extends AbstractUploadNextAction {
                this._state = ProgressState.valueOf(state);
        }
 
-       // ==============================================================================================================================
+       // =========================================================================
        // Protected services
-       // ==============================================================================================================================
-       
+       // =========================================================================
+
        protected void setupDefaultUses(final DocumentType type) {
                Set<DocumentType> uses = type.getDefaultUses();
-       
+
                for (Iterator<DocumentType> i = uses.iterator(); i.hasNext();) {
                        DocumentType usetype = i.next();
                        List<Document> usedoc = _mystudy.collectInvolvedDocuments(usetype);
@@ -308,7 +308,7 @@ public class BaseUploadDocumentAction extends AbstractUploadNextAction {
        public void setUses(final String list) {
                this._docuses = list;
        }
-       
+
        public String getWriteAccess() {
                Boolean res = (_mystudy != null);
                if (res) {
@@ -316,4 +316,14 @@ public class BaseUploadDocumentAction extends AbstractUploadNextAction {
                }
                return res.toString();
        }
+
+       /**
+        * Refresh the study representation according to the current database content.
+        */
+       public void refreshStudy() {
+               // Update of the open study
+               String selection = _mystudy.getSelection();
+               _mystudy = open(getStudyService().selectStudy(_mystudy.getIndex())); // Updates the study
+               _mystudy.setSelection(selection); // Rebuilds the presentation
+       }
 }
\ No newline at end of file
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.
index 748a0f7b7b4b155f45fb0455f1035f205f998ff2..70b76234b13b363c7d32adeedb291d9a1a2b69ef 100644 (file)
@@ -269,10 +269,7 @@ public class ImportDocumentAction extends BaseUploadDocumentAction {
                                        _mystudy.add(addoc); // Updates the presentation
                                } else {
                                        // Re-opening (refreshing) the currently open study
-                                       String selection = _mystudy.getSelection();
-                                       _mystudy = open(getStudyService().selectStudy(
-                                                       _mystudy.getIndex())); // Updates the study
-                                       _mystudy.setSelection(selection);
+                                       refreshStudy();
                                }
                                res = SUCCESS;
                        } catch (FileNotFoundException error) {
index 90fe6d9ccdb7fd71f72be758c2e1720f9ef0299c..5c41b269c4e91e2b1ad41ddc5657573e76a8f276 100644 (file)
@@ -79,7 +79,7 @@ public class VersionDocumentAction extends BaseUploadDocumentAction {
                                setupDefaultUses(_deftype);
                        }
                        // Add additional documents used by the current version
-                       for (Relation usesRel: doc.getRelations(UsesRelation.class)) {
+                       for (Relation usesRel : doc.getRelations(UsesRelation.class)) {
                                Document used = (Document) usesRel.getTo();
                                if (!_defuses.contains(used)) {
                                        _defuses.add(used);
@@ -93,19 +93,20 @@ public class VersionDocumentAction extends BaseUploadDocumentAction {
                        _usedby.addAll(tag.getRelations(UsedByRelation.class));
 
                        // Initialize applicable states list
-                       if(tag.value().getProgressState() == ProgressState.EXTERN) {
+                       if (tag.value().getProgressState() == ProgressState.EXTERN) {
                                _documentStates.add(ProgressState.EXTERN);
                        } else {
-                       _documentStates.add(ProgressState.inWORK);
-                       if (_deftype != null) {
-                               // Check if the validation cycle of the document type can has a review state
-                               ValidationCycle cycle = getStudyService().getValidationCycleOf(
-                                               _mystudy.getMystudy(), _deftype);
-                               if ((cycle != null) && cycle.enables(ValidationStep.REVIEW)) {
-                                       _documentStates.add(ProgressState.inDRAFT);
+                               _documentStates.add(ProgressState.inWORK);
+                               if (_deftype != null) {
+                                       // Check if the validation cycle of the document type can has a review state
+                                       ValidationCycle cycle = getStudyService()
+                                                       .getValidationCycleOf(_mystudy.getMystudy(),
+                                                                       _deftype);
+                                       if ((cycle != null) && cycle.enables(ValidationStep.REVIEW)) {
+                                               _documentStates.add(ProgressState.inDRAFT);
+                                       }
                                }
                        }
-                       }
                } else {
                        if (!(Constants.NONE.equals(getToolProperty()))) {
                                initializationFullScreenContext(Constants.STUDY_MENU,
@@ -203,8 +204,7 @@ public class VersionDocumentAction extends BaseUploadDocumentAction {
                                                _state, aDate, listDocuses, _docusedby);
 
                                // Update of the open study
-                               _mystudy.setSelection(_mystudy.getSelection()); // Rebuilds the presentation
-                               // TODO: Look is an optimization is possible (for example by updating the presentation of versioned document)
+                               refreshStudy();
 
                                res = SUCCESS;
                        } catch (FileNotFoundException error) {