1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package olr.presentation;
18
19 import org.w3c.dom.html.HTMLTableCellElement;
20
21 import com.lutris.appserver.server.httpPresentation.HttpPresentationException;
22
23 /***
24 * @version $Id: Header.java,v 1.6 2004/08/02 18:52:31 roku Exp $
25 */
26 public class Header extends ExtendedHttpPresentation {
27 /***
28 * Initializes an instance of this class.
29 */
30 public Header() {
31 }
32
33 public boolean loggedInUserRequired() {
34 return false;
35 }
36
37 public String handleDefault() throws HttpPresentationException {
38 return showPage();
39 }
40
41 public String handleSave() throws HttpPresentationException {
42 try {
43 getSessionData().setChanged(false);
44 getSessionData().getCourseViewers().save();
45 } catch (Exception e) {
46 showPage(e.getMessage());
47 }
48 return showPage();
49 }
50
51 public String showPage() {
52 return showPage(null);
53 }
54
55 public String showPage(String errorMsg) {
56 HeaderHTML page = new HeaderHTML();
57 if (errorMsg != null)
58 page.getElementErrorText().getFirstChild().setNodeValue(errorMsg);
59 HTMLTableCellElement importButton = page.getElementImport();
60 HTMLTableCellElement deleteButton = page.getElementDelete();
61 HTMLTableCellElement saveButton = page.getElementSave();
62 HTMLTableCellElement menuButton = page.getElementMenu();
63 HTMLTableCellElement logoutButton = page.getElementLogout();
64 if (getUser() == null)
65 logoutButton.getParentNode().removeChild(logoutButton);
66 if (!getSessionData().isStarted()) {
67 saveButton.getParentNode().removeChild(saveButton);
68 menuButton.getParentNode().removeChild(menuButton);
69 deleteButton.getParentNode().removeChild(deleteButton);
70 importButton.getParentNode().removeChild(importButton);
71 } else if (!getSessionData().isAuthor()) {
72 saveButton.getParentNode().removeChild(saveButton);
73 deleteButton.getParentNode().removeChild(deleteButton);
74 importButton.getParentNode().removeChild(importButton);
75 }
76 return page.toDocument();
77 }
78 }