Salome HOME
Refactoring continues: UserService is created instead of UserDirectory. Database...
[tools/siman.git] / Workspace / Siman / WebContent / smesh / index.jsp
1 <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
2     pageEncoding="ISO-8859-1"
3 %>
4 <%@ page import="java.util.ResourceBundle"%>
5 <%@ page import="org.hibernate.Session"%>
6 <%@ page import="org.hibernate.Transaction"%>
7 <%@ page import="org.splat.dal.dao.som.Database"%>
8 <%@ page import="org.splat.dal.bo.som.Scenario"%>
9 <%@ page import="org.splat.dal.bo.som.Publication"%>
10 <%@ page import="org.splat.dal.bo.som.Document"%>
11 <%@ page import="org.splat.som.ApplicationRights"%>
12 <%@ page import="org.splat.simer.OpenStudy"%>
13 <%@ page import="org.splat.simer.StudyMenu"%>
14 <%@
15     taglib prefix="s" uri="/struts-tags"
16 %>
17 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
18
19 <!-- Initialization
20      =============================================================================================================================
21   -->
22 <%
23         String            path   = request.getParameter("open");
24     OpenStudy         simer  = (OpenStudy)session.getAttribute("study.open");
25     ApplicationRights rights = (ApplicationRights)session.getAttribute("user.rights");
26     String            name;
27     boolean           ishared;
28
29     Session      connex  = Database.getCurSession();
30     Transaction  transax = connex.beginTransaction();
31
32     if (path == null) {
33 //    Check-out from the tool-bar, looking for the scenario from the selected menu item
34       StudyMenu  menu  = simer.getMenu();
35       String[]   item  = menu.getSelection().split("\\x2E");
36       Scenario[] scene = simer.getStudyObject().getScenarii();
37       int  j = Integer.valueOf(item[0]);
38       int  i;
39       for (i=0; i<scene.length; i++) {
40         if (scene[i].getIndex() == j) break;
41       }
42     //TODO: RKV: scene[i].checkout(rights.getUser());
43
44       name    =  ResourceBundle.getBundle("som").getString("type.document.model") + "1";
45       ishared = false;
46     }
47     else {
48 //    Check-out from a Geometry document, looking for the scenario from the corresponding publication
49       simer.selectDocument(path);
50
51       Publication edited   = simer.getSelectedDocument();
52       Document    selecdoc = edited.value();
53       Scenario    owner    = (Scenario)edited.getOwner();   // In the GEOM context, the ProjectElement is necessarilly a Scenario
54
55     //TODO: RKV: owner.checkout(rights.getUser());
56
57       name    =  selecdoc.getTitle();
58       ishared = simer.getStudyObject().shares(selecdoc) || selecdoc.isVersioned();
59     }
60     transax.commit();
61 %>
62 <html>
63   <head>
64     <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
65     <title><%=name%></title>
66     <script language="JavaScript">
67
68     function saveAs () {
69 //  ------------------
70       var answer = window.showModalDialog("saveAs.jsp", window, "dialogHeight:115px; dialogWidth:400px; scroll:no; help:no; status:no");
71       if (answer != null) {
72         parse = answer.split(";");
73         window.location = "valid-save?documentType=5&fileName=Maillage1.med&documentName=" + parse[0] + "&documentState=" + parse[1];
74       }
75       return false;
76     }
77
78     function versionAs () {
79 //  ---------------------
80       var answer = window.showModalDialog("versionAs.jsp", window, "dialogHeight:80px; dialogWidth:600px; scroll:no; help:no; status:no");
81         if (answer != null) {
82           parse  = answer.split("&");
83           action = parse[0].split("=");
84
85           if (action[0] == "version") {
86             if (parse.length > 1) {
87               window.location = "valid-version?fileName=Maillage1.med&documentState=" + action[1] + "&" + parse[1];
88             } else {
89               window.location = "valid-version?fileName=Maillage1.med&documentState=" + action[1];
90             }
91           }
92         }
93         return false;
94     }
95
96     function updateAs () {
97 //  ------------------
98       var answer = window.showModalDialog("updateAs.jsp", window, "dialogHeight:155px; dialogWidth:600px; scroll:no; help:no; status:no");
99       if (answer != null) {
100         parse  = answer.split("&");
101         action = parse[0].split("=");
102
103         if (action[0] == "update") {
104           window.location = "valid-update?fileName=Maillage1.med";
105         } else
106         if (action[0] == "version") {
107           if (parse.length > 1) {
108             window.location = "valid-version?fileName=Maillage1.med&documentState=" + action[1] + "&" + parse[1];
109           } else {
110             window.location = "valid-version?fileName=Maillage1.med&documentState=" + action[1];
111           }
112         }
113       }
114       return false;
115     }
116     </script>
117   </head>
118
119   <body background="window.png">
120     <table width=100% border=0 cellspacing=0 cellpadding=0>
121       <tr height=20><td width=73></td></tr>
122       <tr height=24>
123         <td></td>
124         <td>
125 <%  if (path == null) {
126 %>        <a href="javascript:void(0)" onClick="saveAs()"><img src="<s:url value="/skin/image.hold.gif"/>" width="24" height="24" border="none"/></a>
127 <%  } else if (ishared) {
128 %>        <a href="javascript:void(0)" onClick="versionAs()"><img src="<s:url value="/skin/image.hold.gif"/>" width="24" height="24" border="none"/></a>
129 <%  } else {
130 %>        <a href="javascript:void(0)" onClick="updateAs()"><img src="<s:url value="/skin/image.hold.gif"/>" width="24" height="24" border="none"/></a>
131 <%  }
132 %>      </td>
133       </tr>
134     </table>
135   </body>
136 </html>