]> SALOME platform Git repositories - tools/siman.git/commitdiff
Salome HOME
Fix for mantis #0022067: Drop-down list of the type of imported document not conform...
authorrkv <rkv@opencascade.com>
Mon, 14 Jan 2013 08:01:07 +0000 (08:01 +0000)
committerrkv <rkv@opencascade.com>
Mon, 14 Jan 2013 08:01:07 +0000 (08:01 +0000)
Workspace/Siman/WebContent/study/importDocument.jsp
Workspace/Siman/src/org/splat/simer/ApplicationSettings.java
Workspace/Siman/src/org/splat/simer/ImportDocumentAction.java

index f3106226033b3c54585dd2bbea5bde3f4eb7ff66..957a23bcc5b9d0641e9358f76775709a1861cab8 100644 (file)
 <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
-    pageEncoding="ISO-8859-1"
-%>
-<%@
-    taglib prefix="s" uri="/struts-tags"
-%>
-<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
-<html>
-
-  <head>
-    <link href=<s:url value="/skin/default.css"/> rel="stylesheet" type="text/css">
-    <script language="JavaScript">
-
-    function initialize () {
-//  ----------------------
-      bring.documentName.focus();
-    }
-    </script>
-  </head>
-  <body onLoad="initialize()">
+       pageEncoding="ISO-8859-1"%>
+<%@ taglib prefix="s" uri="/struts-tags"%>
+<script>
+$(document).ready(function () {
+    $("#bring #documentName").focus();
+});
+</script>
 
 <!-- Import dialog
      =============================================================================================================================
   -->
-      <div id=article-box>
-        <div id=section><s:text name="title.import"/></div>
-        <div id=article-body class=text>
-          <table width=100% cellpadding=0 cellspacing=0 border=0 class=text>
-            <tr height=25 valign=middle>
-              <td>
-                <s:text name="message.upload">
-                  <s:param><s:property value="%{fileName}"/></s:param>
-                </s:text>
-              </td>
-            </tr>
-            <tr height=1 bgcolor=#AAAAAA><td></td></tr>
-          </table>
+<div id=article-box>
+<div id=section><s:text name="title.import" /></div>
+<div id=article-body class=text>
+<table width=100% cellpadding=0 cellspacing=0 border=0 class=text>
+       <tr height=25 valign=middle>
+               <td><s:text name="message.upload">
+                       <s:param>
+                               <s:property value="%{fileName}" />
+                       </s:param>
+               </s:text></td>
+       </tr>
+       <tr height=1 bgcolor=#AAAAAA>
+               <td></td>
+       </tr>
+</table>
 
-          <form name="bring" action="valid-import" method="post">
-          <s:hidden name="fileName"      value="%{fileName}" />
-          <s:hidden name="reference"     value="%{reference}" />
-          <s:hidden name="documentTitle" value="%{documentName}" />
-          <s:hidden name="defaultDocumentType"  value="%{documentType}" />
-          <s:hidden name="defaultDocumentState" value="%{documentState}" />
-          <s:hidden name="version"       value="%{version}" />
-          <s:hidden name="documentDate"  value="%{documentDate}" />
-          <table cellpadding=0 cellspacing=0 border=0 class=text>
-            <tr height=15><td></td></tr>
-            <tr>
-              <td align=right><s:text name="field.documentype"/>&nbsp;&nbsp;</td>
-              <td align=left>&nbsp;<s:text name="field.documentitle"/></td>
-            </tr>
-            <tr>
-              <td>
-                <s:set var="type"      value="defaultDocumentType.index"/>
-                <s:set var="selectype" value="%{'onChange=submit()'}"/>
-                <s:if test="%{documentType != 0}">
-                  <s:set var="selectype" value="%{'disabled'}"/>
-                </s:if>
-                <select name="documentType" <s:property value="%{#selectype}"/>>
-                  <option value="-1"><s:text name="menu.select"/></option>
-                  <option value="0">&nbsp;<s:text name="menu.newdoctype"/></option>
-                  <optgroup label="&nbsp;<s:text name="label.doctypes"/>">
-                    <s:iterator value="documentTypes">
-                      <s:if test="%{index == #type}">
-                        <option selected value="<s:property value="index"/>">&nbsp;<s:text name="type.document.%{name}"/></option>
-                      </s:if><s:else>
-                        <option value="<s:property value="index"/>">&nbsp;<s:text name="type.document.%{name}"/></option>
-                      </s:else>
-                    </s:iterator>
-                  </optgroup>
-                </select>&nbsp;
-              </td>
-              <td>
-                <s:set var="setname" value="%{''}"/>
-                <s:if test="%{reference != null}">
-                  <s:set var="setname" value="%{'disabled'}"/>
-                </s:if>
-                <input type="text" name="documentName" size="60" value="<s:property value="documentName"/>" <s:property value="%{#setname}"/> />
-              </td>
-            </tr>
-            <s:if test="defaultDocumentUses.size > 0">
-              <tr><td align=right><s:text name="label.uses"/>:</td></tr>
-              <s:iterator value="defaultDocumentUses">
-              <tr>
-                <td align=right><input type="checkbox" name="uses" value="<s:property value="index"/>" checked></td>
-                <td><s:property value="title"/></td>
-              </tr>
-              </s:iterator>
-            </s:if>
-            <tr height=10><td></td></tr>
-            <tr>
-              <td align=right>
-                <input type="submit" name="cancel" value="<s:text name="button.cancel"/>"/>&nbsp;
-              </td>
-              <td align=left>
-                <input type="submit" name="save" value="<s:text name="button.import"/>"/>
-                <select name="documentState" <s:property value="%{#setname}"/>>
-                  <s:if test="documentState == 'EXTERN'">
-                    <option value="inWORK"><s:text name="label.inWORK"/></option>
-                    <option value="inDRAFT"><s:text name="label.inDRAFT"/></option>
-                    <option value="EXTERN" selected><s:text  name="label.EXTERN"/></option>
-                  </s:if>
-                  <s:elseif test="documentState == 'inDRAFT'">
-                    <option value="inWORK"><s:text name="label.inWORK"/></option>
-                    <option value="inDRAFT" selected><s:text name="label.inDRAFT"/></option>
-                    <option value="EXTERN"><s:text  name="label.EXTERN"/></option>
-                  </s:elseif>
-                  <s:else>
-                    <option value="inWORK" selected><s:text name="label.inWORK"/></option>
-                    <option value="inDRAFT"><s:text name="label.inDRAFT"/></option>
-                    <option value="EXTERN"><s:text  name="label.EXTERN"/></option>
-                  </s:else>
-                </select>
-              </td>
-            </tr>
-          </table>
-          </form>
-        </div>
-      </div>
-  </body>
-</html>
\ No newline at end of file
+<form name="bring" id="bring" action="valid-import" method="post">
+<s:hidden name="fileName" value="%{fileName}" /> <s:hidden
+       name="reference" value="%{reference}" /> <s:hidden
+       name="documentTitle" value="%{documentName}" /> <s:hidden
+       name="defaultDocumentType" value="%{documentType}" /> <s:hidden
+       name="defaultDocumentState" value="%{documentState}" /> <s:hidden
+       name="version" value="%{version}" /> <s:hidden name="documentDate"
+       value="%{documentDate}" />
+<table cellpadding=0 cellspacing=0 border=0 class=text>
+       <tr height=15>
+               <td></td>
+       </tr>
+       <tr>
+               <td align=right><s:text name="field.documentype" />&nbsp;&nbsp;</td>
+               <td align=left>&nbsp;<s:text name="field.documentitle" /></td>
+       </tr>
+       <tr>
+               <td>
+               <s:select theme="simple" name="documentType" list="documentTypes"
+                       listKey="index" listValue="%{getText('type.document.' + getName())}" />
+               &nbsp;</td>
+               <td><s:set var="setname" value="%{''}" /> <s:if
+                       test="%{reference != null}">
+                       <s:set var="setname" value="%{'disabled'}" />
+               </s:if> <input type="text" name="documentName" id="documentName" size="60"
+                       value="<s:property value="documentName"/>"
+                       <s:property value="%{#setname}"/> /></td>
+       </tr>
+       <s:if test="defaultDocumentUses.size > 0">
+               <tr>
+                       <td align=right><s:text name="label.uses" />:</td>
+               </tr>
+               <s:iterator value="defaultDocumentUses">
+                       <tr>
+                               <td align=right><input type="checkbox" name="uses"
+                                       value="<s:property value="index"/>" checked></td>
+                               <td><s:property value="title" /></td>
+                       </tr>
+               </s:iterator>
+       </s:if>
+       <tr height=10>
+               <td></td>
+       </tr>
+       <tr>
+               <td align=right><input type="submit" name="cancel"
+                       value="<s:text name="button.cancel"/>" />&nbsp;</td>
+               <td align=left><input type="submit" name="save"
+                       value="<s:text name="button.import"/>" /> <select
+                       name="documentState" <s:property value="%{#setname}"/>>
+                       <s:if test="documentState == 'EXTERN'">
+                               <option value="inWORK"><s:text name="label.inWORK" /></option>
+                               <option value="inDRAFT"><s:text name="label.inDRAFT" /></option>
+                               <option value="EXTERN" selected><s:text name="label.EXTERN" /></option>
+                       </s:if>
+                       <s:elseif test="documentState == 'inDRAFT'">
+                               <option value="inWORK"><s:text name="label.inWORK" /></option>
+                               <option value="inDRAFT" selected><s:text
+                                       name="label.inDRAFT" /></option>
+                               <option value="EXTERN"><s:text name="label.EXTERN" /></option>
+                       </s:elseif>
+                       <s:else>
+                               <option value="inWORK" selected><s:text name="label.inWORK" /></option>
+                               <option value="inDRAFT"><s:text name="label.inDRAFT" /></option>
+                               <option value="EXTERN"><s:text name="label.EXTERN" /></option>
+                       </s:else>
+               </select></td>
+       </tr>
+</table>
+</form>
+</div>
+</div>
index 7f9e3084c4292caf9841a0f511f1da9c1452bb41..d2bbd28cc1032bfd6bf1ec2f613ba229e5a19c00 100644 (file)
@@ -394,59 +394,59 @@ public class ApplicationSettings {
                /**
                 * Accept the document.
                 */
-               accept, 
+               accept,
                /**
                 * Approve the document.
                 */
-               approve, 
+               approve,
                /**
                 * Promote the document.
                 */
-               promote, 
+               promote,
                /**
                 * Demote the docuemnt.
                 */
-               demote, 
+               demote,
                /**
                 * Undo the last operation.
                 */
-               undo, 
+               undo,
                /**
                 * Rename the document.
                 */
-               rename, 
+               rename,
                /**
                 * Attach a file to the document.
                 */
-               attach, 
+               attach,
                /**
                 * Edit the document.
                 */
-               edit, 
+               edit,
                /**
                 * script
                 */
-               script, 
+               script,
                /**
                 * Version the document.
                 */
-               version, 
+               version,
                /**
                 * replace
                 */
-               replace, 
+               replace,
                /**
                 * export
                 */
-               export, 
+               export,
                /**
                 * Remove the document.
                 */
-               remove, 
+               remove,
                /**
                 * purge
                 */
-               purge, 
+               purge,
                /**
                 * Mark the study as reference.
                 */
@@ -459,9 +459,9 @@ public class ApplicationSettings {
 
                private EditableStudyPopup() {
                        super();
-                       addItem(MNU_MARK_AS_REFERENCE, new PopupItem(MNU_NAME_MARK_AS_REFERENCE)
-                                       .action(ACT_NOT_YET_IMPLEMENTED).confirmation(
-                                                       "message.markasreference.study"));
+                       addItem(MNU_MARK_AS_REFERENCE, new PopupItem(
+                                       MNU_NAME_MARK_AS_REFERENCE).action(ACT_NOT_YET_IMPLEMENTED)
+                                       .confirmation("message.markasreference.study"));
                        addItem(MNU_PUBLISH, new PopupItem(MNU_NAME_PUBLISH).icon(
                                        "image.publish.png").action("edit-study?action=publish")
                                        .confirmation("message.publish.study"));
@@ -484,8 +484,9 @@ public class ApplicationSettings {
                                        "message.delete.study"));
                }
 
-               /** 
+               /**
                 * {@inheritDoc}
+                * 
                 * @see org.splat.wapp.ContextualMenu#isEnabled(java.lang.String)
                 */
                @Override
@@ -1095,6 +1096,15 @@ public class ApplicationSettings {
                return convertmap.get(format + type.getName()); // May be null;
        }
 
+       /**
+        * Get default document type for the given format on the given study step.
+        * 
+        * @param step
+        *            the study step
+        * @param format
+        *            the file format
+        * @return default document type or null if not defined in the configuration
+        */
        public DocumentType getDefaultDocumentType(final Step step,
                        final String format) {
                return getProjectSettings().getDefaultDocumentType(step.getStep(),
index c5db79ea52bcb711d4ad135e718d108fbc8d4ddf..faf4dfe9cf42146190b7c34253e4d36f6cb3652c 100644 (file)
@@ -93,8 +93,9 @@ public class ImportDocumentAction extends UploadBaseNextAction {
                } else {
                        setToolProperty(Constants.NONE);
                }
-               initializationFullScreenContext(Constants.STUDY_MENU, Constants.STUDY_MENU,
-                               Constants.FALSE, getToolProperty(), Constants.STUDY_MENU);
+               initializationFullScreenContext(Constants.STUDY_MENU,
+                               Constants.STUDY_MENU, Constants.FALSE, getToolProperty(),
+                               Constants.STUDY_MENU);
 
                User user = getConnectedUser();
                File updir = getRepositoryService().getDownloadDirectory(user);
@@ -105,7 +106,11 @@ public class ImportDocumentAction extends UploadBaseNextAction {
                mystudy = getOpenStudy();
                Step step = mystudy.getSelectedStep();
                _documentTypes = getStepService().getValidDocumentTypes(step);
+               // Set the document type by default
                deftype = getApplicationSettings().getDefaultDocumentType(step, filext);
+               if (deftype != null) {
+                       setDefaultDocumentType(Long.toString(deftype.getIndex()));
+               }
                defuses = new ArrayList<Document>();
                state = ProgressState.inWORK;
 
@@ -241,8 +246,9 @@ public class ImportDocumentAction extends UploadBaseNextAction {
        private void setError(final String errorCode) {
                setErrorCode(errorCode);
 
-               initializationFullScreenContext(Constants.STUDY_MENU, Constants.STUDY_MENU,
-                               Constants.FALSE, Constants.NONE, Constants.STUDY_MENU);
+               initializationFullScreenContext(Constants.STUDY_MENU,
+                               Constants.STUDY_MENU, Constants.FALSE, Constants.NONE,
+                               Constants.STUDY_MENU);
        }
 
        /**
@@ -261,8 +267,9 @@ public class ImportDocumentAction extends UploadBaseNextAction {
                if (_documentType == 0) {
                        setErrorCode("message.error.import.type");
 
-                       initializationFullScreenContext(Constants.STUDY_MENU, Constants.STUDY_MENU,
-                                       Constants.TRUE, Constants.NONE, Constants.STUDY_MENU);
+                       initializationFullScreenContext(Constants.STUDY_MENU,
+                                       Constants.STUDY_MENU, Constants.TRUE, Constants.NONE,
+                                       Constants.STUDY_MENU);
 
                        return ERROR;
                }
@@ -288,8 +295,9 @@ public class ImportDocumentAction extends UploadBaseNextAction {
                                }
                        }
                        if (LOG.isDebugEnabled()) {
-                               LOG.debug("Document to be imported uses documents with following ids:");
-                               for (Long usesId: uses) {
+                               LOG
+                                               .debug("Document to be imported uses documents with following ids:");
+                               for (Long usesId : uses) {
                                        LOG.debug("#" + usesId);
                                }
                        }
@@ -318,8 +326,9 @@ public class ImportDocumentAction extends UploadBaseNextAction {
                        setErrorCode("message.error.internal");
                }
 
-               initializationFullScreenContext(Constants.STUDY_MENU, Constants.STUDY_MENU,
-                               Constants.TRUE, Constants.NONE, Constants.STUDY_MENU);
+               initializationFullScreenContext(Constants.STUDY_MENU,
+                               Constants.STUDY_MENU, Constants.TRUE, Constants.NONE,
+                               Constants.STUDY_MENU);
 
                return ERROR;
        }