View Javadoc

1   /*
2    *  Copyright 2004 University of Hannover
3    *
4    *  Licensed under the Apache License, Version 2.0 (the "License");
5    *  you may not use this file except in compliance with the License.
6    *  You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   *  Unless required by applicable law or agreed to in writing, software
11   *  distributed under the License is distributed on an "AS IS" BASIS,
12   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *  See the License for the specific language governing permissions and
14   *  limitations under the License.
15   */
16  
17  package olr.presentation;
18  
19  import olr.viewer.CourseViewer;
20  import olr.viewer.CourseViewers;
21  
22  import org.w3c.dom.Node;
23  import org.w3c.dom.html.HTMLAnchorElement;
24  import org.w3c.dom.html.HTMLTableCellElement;
25  
26  import com.lutris.appserver.server.httpPresentation.HttpPresentationException;
27  
28  /***
29   * @version $Id: StructureHeader.java,v 1.6 2004/08/02 18:55:06 roku Exp $
30   */
31  public class StructureHeader extends ExtendedHttpPresentation {
32      /***
33       * Initializes an instance of this class.
34       */
35      public StructureHeader() {
36      }
37  
38      public boolean loggedInUserRequired() {
39          return true;
40      }
41  
42      public String handleDefault() throws HttpPresentationException {
43          return showPage();
44      }
45  
46      public String showPage() {
47          StructureHeaderHTML page = new StructureHeaderHTML();
48          try {
49              HTMLTableCellElement schema = page.getElementSchema();
50              HTMLTableCellElement schemaNoLink = page.getElementSchemaNoLink();
51              HTMLTableCellElement space = page.getElementSpace();
52              HTMLAnchorElement schemaLink = page.getElementSchemaLink();
53              Node parent = schema.getParentNode();
54              CourseViewers viewers = getSessionData().getCourseViewers();
55              for (int i = 0; i < viewers.getCount(); i++) {
56                  CourseViewer courseViewer = viewers.getViewerAt(i);
57                  if (courseViewer.equals(viewers.getActiveViewer())) {
58                      page.setTextSchemaTitle(courseViewer.getTitle());
59                      parent.appendChild(schemaNoLink.cloneNode(true));
60                  } else {
61                      page.setTextSchemaLink(courseViewer.getTitle());
62                      schemaLink.setHref("StructureFrame.po?event=chooseSchema&nr=".concat(String
63                              .valueOf(String.valueOf(i))));
64                      parent.appendChild(schema.cloneNode(true));
65                  }
66                  parent.appendChild(space.cloneNode(true));
67              }
68  
69              parent.removeChild(schema);
70              parent.removeChild(schemaNoLink);
71              parent.removeChild(space);
72          } catch (Exception e) {
73              e.printStackTrace();
74          }
75          return page.toDocument();
76      }
77  }