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
|
/*******************************************************************************
* Copyright (c) 2011 Boeing.
* All rightsimport com.vaadin.Application;
import com.vaadin.service.ApplicationContext.TransactionListener;
he 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.components;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import org.eclipse.osee.display.api.components.AttributeComponent;
import org.eclipse.osee.display.api.data.WebArtifact;
import org.eclipse.osee.display.view.web.CssConstants;
import com.vaadin.ui.Alignment;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.VerticalLayout;
/**
* @author Shawn F. Cook
*/
@SuppressWarnings("serial")
public class OseeAttributeComponent extends VerticalLayout implements AttributeComponent {
private WebArtifact artifact;
private void createLayout() {
removeAllComponents();
if (artifact != null) {
final HorizontalLayout attributesLayout = new HorizontalLayout();
final OseeShowHideButton showHideButton = new OseeShowHideButton("Attributes");
showHideButton.addListener(new OseeShowHideButton.ClickListener() {
@Override
public void buttonClick(OseeShowHideButton.ClickEvent event) {
attributesLayout.setVisible(showHideButton.isStateShow());
}
});
attributesLayout.setVisible(showHideButton.isStateShow());
Map<String, String> attributes = new HashMap<String, String>();
attributes.put("Category", artifact.getAttr_Category());
attributes.put("Developmental Assurance Level", artifact.getAttr_DevAssurLevel());
attributes.put("Imported Paragraph Number", artifact.getAttr_ImpoParaNum());
attributes.put("Partition", artifact.getAttr_Partition());
attributes.put("Qualification Method", artifact.getAttr_QualMethod());
attributes.put("Subsystem", artifact.getAttr_Subsystm());
attributes.put("Technical Performance Parameter", artifact.getAttr_TechPerfParam());
Set<Entry<String, String>> set = attributes.entrySet();
VerticalLayout attrLabelsLayout = new VerticalLayout();
VerticalLayout attrValuesLayout = new VerticalLayout();
for (Entry<String, String> entry : set) {
Label attrLabel = new Label(String.format("%s:", entry.getKey()));
Label attrValue = new Label(entry.getValue());
attrLabel.setStyleName(CssConstants.OSEE_ATTRIBUTELABEL);
attrValue.setStyleName(CssConstants.OSEE_ATTRIBUTEVALUE);
attrLabelsLayout.addComponent(attrLabel);
attrValuesLayout.addComponent(attrValue);
attrLabelsLayout.setComponentAlignment(attrLabel, Alignment.MIDDLE_RIGHT);
attrValuesLayout.setComponentAlignment(attrValue, Alignment.MIDDLE_LEFT);
}
Label spacer = new Label("");
spacer.setWidth(15, UNITS_PIXELS);
attributesLayout.addComponent(attrLabelsLayout);
attributesLayout.addComponent(spacer);
attributesLayout.addComponent(attrValuesLayout);
addComponent(showHideButton);
addComponent(attributesLayout);
setExpandRatio(attributesLayout, 1.0f);
}
}
@Override
public void clearAll() {
this.artifact = null;
createLayout();
}
@Override
public void setErrorMessage(String message) {
}
@Override
public void addAttribute(String type, String value) {
}
}
|