Skip to main content
summaryrefslogtreecommitdiffstats
blob: 002e1baf51aa4f1df45253bba3729c79b88424b6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/*******************************************************************************
 * Copyright (c) 20011 Boeing.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     Boeing - initial API and implementation
 *******************************************************************************/
package org.eclipse.osee.ats.view.web;

import org.eclipse.osee.display.view.web.OseeFooter;
import org.eclipse.osee.vaadin.widgets.AccountMenuBar;
import org.eclipse.osee.vaadin.widgets.HasViews;
import org.eclipse.osee.vaadin.widgets.Navigator;
import org.eclipse.osee.vaadin.widgets.Navigator.View;
import org.eclipse.osee.vaadin.widgets.Navigator.ViewChangeListener;
import com.vaadin.ui.Alignment;
import com.vaadin.ui.Component;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.MenuBar;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;

/**
 * @author Shawn F. Cook
 */
@SuppressWarnings("serial")
public class AtsWindowFactory {

   public Window createNavigatableWindow(HasViews provider, AtsNavigator navigator) {

      VerticalLayout layout = new VerticalLayout();
      final Window w = new Window("OSEE", layout);

      w.addComponent(createNavigationBar(navigator, provider));
      w.addComponent(navigator);
      w.addComponent(createFooter());

      layout.setMargin(false);
      layout.setSpacing(true);
      layout.setSizeFull();
      layout.setExpandRatio(navigator, 1.0f);

      navigator.addListener(new ViewChangeListener() {
         @Override
         public void navigatorViewChange(View previous, View current) {
            Window mainWindow = w.getApplication().getMainWindow();
            mainWindow.setCaption("OSEE - " + current.getClass().getSimpleName());
            mainWindow.showNotification("Navigated to " + current.getClass().getName());
         }
      });
      return w;
   }

   private Component createFooter() {
      return new OseeFooter();
   }

   private Component createNavigationBar(final Navigator navigator, HasViews provider) {
      HorizontalLayout layout = new HorizontalLayout();

      MenuBar menu = new MenuBar();
      layout.addComponent(menu);

      menu.setWidth("100%");
      layout.setWidth("100%");
      for (final Class<?> viewClass : provider.getViews()) {
         navigator.addView(viewClass.getSimpleName(), viewClass);
         //         menu.addItem(viewClass.getSimpleName(), new MenuBar.Command() {
         //
         //            @Override
         //            public void menuSelected(MenuBar.MenuItem selectedItem) {
         //               navigator.navigateTo(viewClass);
         //            }
         //         });
      }

      MenuBar menuBar = new AccountMenuBar();
      layout.addComponent(menuBar);

      layout.setComponentAlignment(menu, Alignment.BOTTOM_LEFT);
      layout.setComponentAlignment(menuBar, Alignment.BOTTOM_RIGHT);
      layout.setExpandRatio(menu, 1.0f);
      return layout;
   }
}

Back to the top