1 package autotest.tko;
2 
3 import autotest.common.ui.DoubleListSelector;
4 import autotest.common.ui.ExtendedListBox;
5 import autotest.common.ui.MultiListSelectPresenter;
6 import autotest.common.ui.SimplifiedList;
7 import autotest.common.ui.ToggleControl;
8 import autotest.common.ui.ToggleLink;
9 import autotest.common.ui.MultiListSelectPresenter.DoubleListDisplay;
10 import autotest.common.ui.MultiListSelectPresenter.ToggleDisplay;
11 
12 import com.google.gwt.user.client.ui.Composite;
13 import com.google.gwt.user.client.ui.HasText;
14 import com.google.gwt.user.client.ui.Panel;
15 import com.google.gwt.user.client.ui.StackPanel;
16 import com.google.gwt.user.client.ui.TextArea;
17 import com.google.gwt.user.client.ui.VerticalPanel;
18 
19 public class SpreadsheetHeaderSelectorView extends Composite
20                                            implements MultiListSelectPresenter.ToggleDisplay,
21                                                       SpreadsheetHeaderSelect.Display {
22     protected final static String SWITCH_TO_SINGLE = "Switch to single";
23     protected final static String SWITCH_TO_MULTIPLE = "Switch to multiple";
24     static final String CANCEL_FIXED_VALUES = "Don't use fixed values";
25     static final String USE_FIXED_VALUES = "Fixed values...";
26 
27     private ToggleLink fixedValuesToggle = new ToggleLink(USE_FIXED_VALUES, CANCEL_FIXED_VALUES);
28     private TextArea fixedValues = new TextArea();
29     private ExtendedListBox listBox = new ExtendedListBox();
30     private DoubleListSelector doubleListDisplay = new DoubleListSelector();
31     private StackPanel stack = new StackPanel();
32     private ToggleLink multipleSelectToggle = new ToggleLink(SWITCH_TO_MULTIPLE, SWITCH_TO_SINGLE);
33 
SpreadsheetHeaderSelectorView()34     public SpreadsheetHeaderSelectorView() {
35         Panel singleHeaderOptions = new VerticalPanel();
36         singleHeaderOptions.add(listBox);
37 
38         stack.add(singleHeaderOptions);
39         stack.add(doubleListDisplay);
40 
41         Panel fixedValuePanel = new VerticalPanel();
42         fixedValuePanel.add(fixedValuesToggle);
43         fixedValuePanel.add(fixedValues);
44 
45         Panel panel = new VerticalPanel();
46         panel.add(stack);
47         panel.add(fixedValuePanel);
48         panel.add(multipleSelectToggle);
49         initWidget(panel);
50 
51         fixedValues.setVisible(false);
52         fixedValues.addStyleName("fixed-headers-input");
53     }
54 
55     @Override
getFixedValuesInput()56     public HasText getFixedValuesInput() {
57         return fixedValues;
58     }
59 
60     @Override
getFixedValuesToggle()61     public ToggleLink getFixedValuesToggle() {
62         return fixedValuesToggle;
63     }
64 
65     @Override
setFixedValuesVisible(boolean visible)66     public void setFixedValuesVisible(boolean visible) {
67         fixedValues.setVisible(visible);
68     }
69 
70     @Override
getDoubleListDisplay()71     public DoubleListDisplay getDoubleListDisplay() {
72         return doubleListDisplay;
73     }
74 
75     @Override
getToggleDisplay()76     public ToggleDisplay getToggleDisplay() {
77         return this;
78     }
79 
80     @Override
getSingleSelector()81     public SimplifiedList getSingleSelector() {
82         return listBox;
83     }
84 
85     @Override
getToggleMultipleLink()86     public ToggleControl getToggleMultipleLink() {
87         return multipleSelectToggle;
88     }
89 
90     @Override
setDoubleListVisible(boolean doubleListVisible)91     public void setDoubleListVisible(boolean doubleListVisible) {
92         stack.showStack(doubleListVisible ? 1 : 0);
93     }
94 }
95