Skip to main content
summaryrefslogtreecommitdiffstats
blob: dbee0c77cf085ef42ee02aa7317ad0f4bdf5aa4b (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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
/*******************************************************************************
 * Copyright (c) 2011 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.display.view.web.search;

import org.eclipse.osee.display.api.components.ArtifactHeaderComponent;
import org.eclipse.osee.display.api.data.ViewArtifact;
import org.eclipse.osee.display.api.search.SearchPresenter;
import org.eclipse.osee.display.view.web.components.OseeArtifactNameLinkComponent;
import org.eclipse.osee.display.view.web.components.OseeAttributeComponent;
import org.eclipse.osee.display.view.web.components.OseeBreadcrumbComponent;
import org.eclipse.osee.display.view.web.components.OseeRelationsComponent;
import org.eclipse.osee.display.view.web.components.OseeSearchHeaderComponent;
import org.eclipse.osee.vaadin.widgets.Navigator;
import com.vaadin.Application;
import com.vaadin.ui.Alignment;
import com.vaadin.ui.CustomComponent;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.Panel;
import com.vaadin.ui.VerticalLayout;

/**
 * @author Shawn F. Cook
 */
@SuppressWarnings("serial")
public class OseeArtifactView extends CustomComponent implements Navigator.View, ArtifactHeaderComponent {

   protected SearchPresenter searchPresenter = null;
   protected OseeSearchHeaderComponent searchHeader;
   protected OseeRelationsComponent relationsComp = new OseeRelationsComponent();
   protected OseeAttributeComponent attributeComp = new OseeAttributeComponent();
   private final OseeBreadcrumbComponent breadcrumbComp = new OseeBreadcrumbComponent(null);
   private ViewArtifact artifact;

   @Override
   public void attach() {
      //TODO: remove?
   }

   protected void createLayout() {
      setSizeFull();

      Label spacer = new Label();
      spacer.setHeight(5, UNITS_PIXELS);

      HorizontalLayout leftMarginAndBody = new HorizontalLayout();
      leftMarginAndBody.setSizeFull();
      Label leftMarginSpace = new Label("");
      leftMarginSpace.setWidth(80, UNITS_PIXELS);
      leftMarginAndBody.addComponent(leftMarginSpace);

      if (artifact != null) {
         VerticalLayout artNameVertLayout = new VerticalLayout();
         artNameVertLayout.setSizeFull();

         breadcrumbComp.setArtifact(artifact);
         artNameVertLayout.addComponent(breadcrumbComp);

         OseeArtifactNameLinkComponent artifactName = new OseeArtifactNameLinkComponent(artifact);
         artifactName.setSizeUndefined();
         Label spacer1 = new Label();
         spacer1.setWidth(10, UNITS_PIXELS);
         spacer1.setHeight(null);
         Label artifactType = new Label(String.format("[%s]", artifact.getArtifactType()), Label.CONTENT_XHTML);
         artifactType.setSizeUndefined();
         HorizontalLayout artNameAndTypeLayout = new HorizontalLayout();
         artNameAndTypeLayout.setSizeUndefined();
         artNameAndTypeLayout.addComponent(artifactName);
         artNameAndTypeLayout.addComponent(spacer1);
         artNameAndTypeLayout.addComponent(artifactType);
         artNameAndTypeLayout.setComponentAlignment(artifactType, Alignment.BOTTOM_CENTER);
         artNameVertLayout.addComponent(artNameAndTypeLayout);

         VerticalLayout artRelSpacer = new VerticalLayout();
         artRelSpacer.setHeight(15, UNITS_PIXELS);
         artNameVertLayout.addComponent(artRelSpacer);

         VerticalLayout bodyVertLayout = new VerticalLayout();
         bodyVertLayout.setMargin(true);
         bodyVertLayout.setSizeFull();
         bodyVertLayout.addComponent(relationsComp);

         VerticalLayout relAttrSpacer = new VerticalLayout();
         relAttrSpacer.setHeight(15, UNITS_PIXELS);
         bodyVertLayout.addComponent(relAttrSpacer);

         bodyVertLayout.addComponent(attributeComp);

         VerticalLayout bottomSpacer = new VerticalLayout();
         bodyVertLayout.addComponent(bottomSpacer);
         bodyVertLayout.setExpandRatio(bottomSpacer, 1.0f);

         Panel mainLayoutPanel = new Panel();
         mainLayoutPanel.setScrollable(true);
         mainLayoutPanel.getContent().setSizeUndefined();
         mainLayoutPanel.setContent(bodyVertLayout);
         mainLayoutPanel.setSizeFull();

         artNameVertLayout.addComponent(mainLayoutPanel);
         artNameVertLayout.setExpandRatio(mainLayoutPanel, 1.0f);
         leftMarginAndBody.addComponent(artNameVertLayout);
         leftMarginAndBody.setExpandRatio(artNameVertLayout, 1.0f);
      }

      final VerticalLayout vertLayout = new VerticalLayout();
      vertLayout.addComponent(searchHeader);
      vertLayout.addComponent(spacer);
      vertLayout.setComponentAlignment(searchHeader, Alignment.TOP_LEFT);
      searchHeader.setWidth(100, UNITS_PERCENTAGE);
      searchHeader.setHeight(null);
      vertLayout.addComponent(leftMarginAndBody);
      vertLayout.setExpandRatio(leftMarginAndBody, 1.0f);

      vertLayout.setSizeFull();
      setCompositionRoot(vertLayout);
   }

   @Override
   public void init(Navigator navigator, Application application) {
      //Do nothing.
   }

   @Override
   public String getWarningForNavigatingFrom() {
      return null;
   }

   @Override
   public void clearAll() {
      this.artifact = null;
      createLayout();
   }

   @Override
   public void setArtifact(ViewArtifact artifact) {
      this.artifact = artifact;
      createLayout();
   }

   @Override
   public void setErrorMessage(String message) {
      //TODO:
   }

   @Override
   public void navigateTo(String requestedDataId) {
      if (searchHeader != null) {
         searchHeader.createLayout();
      }
      createLayout();
   }
}

Back to the top