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