Home | History | Annotate | Download | only in afe
      1 package autotest.afe;
      2 
      3 import autotest.common.ui.ExtendedListBox;
      4 import autotest.common.ui.SimplifiedList;
      5 
      6 import com.google.gwt.event.dom.client.HasClickHandlers;
      7 import com.google.gwt.user.client.ui.Button;
      8 import com.google.gwt.user.client.ui.CheckBox;
      9 import com.google.gwt.user.client.ui.Composite;
     10 import com.google.gwt.user.client.ui.HasText;
     11 import com.google.gwt.user.client.ui.HasValue;
     12 import com.google.gwt.user.client.ui.HorizontalPanel;
     13 import com.google.gwt.user.client.ui.Label;
     14 import com.google.gwt.user.client.ui.Panel;
     15 import com.google.gwt.user.client.ui.SimplePanel;
     16 import com.google.gwt.user.client.ui.TabPanel;
     17 import com.google.gwt.user.client.ui.TextArea;
     18 import com.google.gwt.user.client.ui.TextBox;
     19 import com.google.gwt.user.client.ui.VerticalPanel;
     20 import com.google.gwt.user.client.ui.Widget;
     21 
     22 public class HostSelectorDisplay extends Composite implements HostSelector.Display {
     23     private Label hostSelectorTitle = new Label("Select Hosts for Running Tests:");
     24     private TextArea hostnameInput = new TextArea();
     25     private Button addByHostnameButton = new Button();
     26     private CheckBox allowOneTimeHostsBox = new CheckBox();
     27     private ExtendedListBox labelList = new ExtendedListBox();
     28     private TextBox labelNumberInput = new TextBox();
     29     private Button addByLabelButton = new Button();
     30     private Panel availableTablePanel, selectedTablePanel;
     31     private TabPanel tabPanel = new TabPanel();
     32 
     33     private boolean haveTables = false;
     34 
     35     public HostSelectorDisplay() {
     36         // Set title label style
     37         hostSelectorTitle.setStyleName("field-name");
     38 
     39         // available host table
     40         availableTablePanel = new SimplePanel();
     41         tabPanel.add(availableTablePanel, "By browsing hosts");
     42 
     43         // choose by hostname
     44         Panel hostnamePanel = new VerticalPanel();
     45         hostnamePanel.add(new Label("Enter hostnames, separated by commas or spaces"));
     46         hostnamePanel.add(hostnameInput);
     47         hostnameInput.setSize("100%", "10em");
     48         addByHostnameButton.setText("Select hosts");
     49         allowOneTimeHostsBox.setText("Allow hosts not in Autotest");
     50         Panel lowerPanel = new HorizontalPanel();
     51         lowerPanel.add(addByHostnameButton);
     52         lowerPanel.add(allowOneTimeHostsBox);
     53         hostnamePanel.add(lowerPanel);
     54         tabPanel.add(hostnamePanel, "By specifying hostnames");
     55 
     56         // add metahosts
     57         Panel labelPanel = new VerticalPanel();
     58         Panel labelTop = new HorizontalPanel();
     59         labelTop.add(new Label("Run on any hosts with label"));
     60         labelTop.add(labelList);
     61         labelPanel.add(labelTop);
     62         Panel labelBottom = new HorizontalPanel();
     63         labelBottom.add(new Label("Number of hosts:"));
     64         labelBottom.add(labelNumberInput);
     65         labelNumberInput.setVisibleLength(4);
     66         addByLabelButton.setText("Add hosts");
     67         labelBottom.add(addByLabelButton);
     68         labelPanel.add(labelBottom);
     69         tabPanel.add(labelPanel, "By specifying host labels");
     70 
     71         tabPanel.selectTab(0);
     72 
     73         // the tabbed selector is displayed alongside the list of selected hosts
     74         selectedTablePanel = new VerticalPanel();
     75         selectedTablePanel.addStyleName("data-table");
     76         Label selectedTitle = new Label("Selected hosts:");
     77         selectedTitle.addStyleName("field-name");
     78         selectedTablePanel.add(selectedTitle);
     79         Panel outerPanel = new VerticalPanel();
     80         outerPanel.add(hostSelectorTitle);
     81         outerPanel.add(tabPanel);
     82         outerPanel.add(selectedTablePanel);
     83         outerPanel.addStyleName("panel-boundedwidth");
     84         outerPanel.addStyleName("data-table-outlined-gray");
     85         initWidget(outerPanel);
     86     }
     87 
     88     @Override
     89     public void addTables(Widget availableTable, Widget selectedTable) {
     90         assert !haveTables;
     91         availableTablePanel.add(availableTable);
     92         selectedTablePanel.add(selectedTable);
     93         haveTables = true;
     94     }
     95 
     96     @Override
     97     public HasClickHandlers getAddByHostnameButton() {
     98         return addByHostnameButton;
     99     }
    100 
    101     @Override
    102     public HasValue<Boolean> getAllowOneTimeHostsField() {
    103         return allowOneTimeHostsBox;
    104     }
    105 
    106     @Override
    107     public HasClickHandlers getAddByLabelButton() {
    108         return addByLabelButton;
    109     }
    110 
    111     @Override
    112     public HasText getHostnameField() {
    113         return hostnameInput;
    114     }
    115 
    116     @Override
    117     public SimplifiedList getLabelList() {
    118         return labelList;
    119     }
    120 
    121     @Override
    122     public HasText getLabelNumberField() {
    123         return labelNumberInput;
    124     }
    125 }
    126