Skip to main content
summaryrefslogtreecommitdiffstats
blob: 0e35709df84078264fdd6bf324ebc96bd2139b9c (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
/*******************************************************************************
 * 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.view.web.AbstractCommonView;
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 com.vaadin.Application;
import com.vaadin.ui.Alignment;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.Panel;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;
import com.vaadin.ui.Window.Notification;

/**
 * @author Shawn F. Cook
 */
@SuppressWarnings("serial")
public abstract class OseeArtifactView extends AbstractCommonView implements ArtifactHeaderComponent {

   protected final OseeRelationsComponent relationsComp = new OseeRelationsComponent();
   protected final OseeAttributeComponent attributeComp = new OseeAttributeComponent();
   private final OseeBreadcrumbComponent breadcrumbComp = new OseeBreadcrumbComponent(null);
   private final OseeArtifactNameLinkComponent artifactName = new OseeArtifactNameLinkComponent();
   private final Label artifactType = new Label("", Label.CONTENT_XHTML);
   private ViewArtifact artifact;
   private final int LEFTMARGIN_WIDTH = 5;

   @Override
   protected void createLayout() {
      setSizeFull();

      getSearchHeader().setWidth(100, UNITS_PERCENTAGE);
      getSearchHeader().setHeight(null);

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

      HorizontalLayout hLayout_LeftMargAndBody = new HorizontalLayout();
      hLayout_LeftMargAndBody.setSizeFull();
      Label leftMarginSpace = new Label("");
      leftMarginSpace.setWidth(LEFTMARGIN_WIDTH, UNITS_PIXELS);
      hLayout_LeftMargAndBody.addComponent(leftMarginSpace);

      VerticalLayout vLayout_OutBody = new VerticalLayout();
      vLayout_OutBody.setSizeFull();

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

      artifactName.setSizeUndefined();

      Label spacer1 = new Label();
      spacer1.setWidth(10, UNITS_PIXELS);
      spacer1.setHeight(null);

      artifactType.setSizeUndefined();

      HorizontalLayout hLayout_ArtNameAndType = new HorizontalLayout();
      hLayout_ArtNameAndType.setSizeUndefined();

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

      VerticalLayout vLayout_Body = new VerticalLayout();
      vLayout_Body.setMargin(false, false, false, true);
      vLayout_Body.setSizeFull();

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

      VerticalLayout bottomSpacer = new VerticalLayout();

      Panel panel_Body = new Panel();
      panel_Body.setScrollable(true);
      panel_Body.getContent().setSizeUndefined();
      panel_Body.setSizeFull();

      hLayout_ArtNameAndType.addComponent(artifactName);
      hLayout_ArtNameAndType.addComponent(spacer1);
      hLayout_ArtNameAndType.addComponent(artifactType);

      vLayout_Body.addComponent(vSpacer);
      vLayout_Body.addComponent(hLayout_ArtNameAndType);
      vLayout_Body.addComponent(artRelSpacer);
      vLayout_Body.addComponent(relationsComp);
      vLayout_Body.addComponent(relAttrSpacer);
      vLayout_Body.addComponent(attributeComp);
      vLayout_Body.addComponent(bottomSpacer);

      panel_Body.setContent(vLayout_Body);

      vLayout_OutBody.addComponent(breadcrumbComp);
      vLayout_OutBody.addComponent(panel_Body);

      hLayout_LeftMargAndBody.addComponent(vLayout_OutBody);

      addComponent(getSearchHeader());
      addComponent(spacer);
      addComponent(hLayout_LeftMargAndBody);

      hLayout_ArtNameAndType.setComponentAlignment(artifactType, Alignment.BOTTOM_CENTER);
      vLayout_Body.setExpandRatio(bottomSpacer, 1.0f);
      vLayout_OutBody.setExpandRatio(panel_Body, 1.0f);
      hLayout_LeftMargAndBody.setExpandRatio(vLayout_OutBody, 1.0f);
      setComponentAlignment(getSearchHeader(), Alignment.TOP_LEFT);
      setExpandRatio(hLayout_LeftMargAndBody, 1.0f);
   }

   private void updateLayout() {
      if (artifact != null) {
         breadcrumbComp.setArtifact(artifact);
         artifactType.setCaption(String.format("[%s]", artifact.getArtifactType()));
         artifactName.setArtifact(artifact);
      }
   }

   @Override
   public void clearAll() {
      artifact = null;
      updateLayout();
   }

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

   @Override
   public void setErrorMessage(String message) {
      Application app = this.getApplication();
      if (app != null) {
         Window mainWindow = app.getMainWindow();
         if (mainWindow != null) {
            mainWindow.showNotification(message, Notification.TYPE_ERROR_MESSAGE);
         } else {
            System.out.println("OseeArtifactView.setErrorMessage - ERROR: Application.getMainWindow() returns null value.");
         }
      } else {
         System.out.println("OseeArtifactView.setErrorMessage - ERROR: getApplication() returns null value.");
      }
   }
}

Back to the top