To facilitate profile selection in the Create Job view, we need to add a
new widget type. Currently, all widgets are assumed to be checkboxes.
Extend the createWidget API to take a type.

0 means checkbox
1 means listbox (technically as written any non-zero value means this)

This should probably be turned into a well-defined enum eventually.

Signed-off-by: Nishanth Aravamudan <[email protected]>
---
 .../client/src/autotest/afe/JobDetailView.java     |    4 +-
 frontend/client/src/autotest/afe/TestSelector.java |    6 ++--
 .../afe/create/CreateJobViewPresenter.java         |    1 +
 .../src/autotest/common/table/DataTable.java       |   23 +++++++++++++------
 frontend/client/src/autotest/tko/TableView.java    |    2 +-
 5 files changed, 23 insertions(+), 13 deletions(-)

diff --git a/frontend/client/src/autotest/afe/JobDetailView.java 
b/frontend/client/src/autotest/afe/JobDetailView.java
index e2b9ada..b1e1f34 100644
--- a/frontend/client/src/autotest/afe/JobDetailView.java
+++ b/frontend/client/src/autotest/afe/JobDetailView.java
@@ -436,9 +436,9 @@ public class JobDetailView extends DetailView implements 
TableWidgetFactory, Tab
         this.jobId = newJobId;
     }
 
-    public Widget createWidget(int row, int cell, JSONObject hostQueueEntry) {
+    public Widget createWidget(int row, int cell, JSONObject hostQueueEntry, 
int type) {
         if (cell == 0) {
-            return selectionManager.createWidget(row, cell, hostQueueEntry);
+            return selectionManager.createWidget(row, cell, hostQueueEntry, 
type);
         }
 
         String executionSubdir = 
Utils.jsonToString(hostQueueEntry.get("execution_subdir"));
diff --git a/frontend/client/src/autotest/afe/TestSelector.java 
b/frontend/client/src/autotest/afe/TestSelector.java
index 6bdcdf1..cc74ba6 100644
--- a/frontend/client/src/autotest/afe/TestSelector.java
+++ b/frontend/client/src/autotest/afe/TestSelector.java
@@ -53,7 +53,7 @@ public class TestSelector extends Composite implements 
DataTableListener, Change
     // ad-hoc interface
     public static interface ISelectionManager {
         public void deselectAll();
-        public Widget createWidget(int row, int cell, JSONObject rowObject);
+        public Widget createWidget(int row, int cell, JSONObject rowObject, 
int type);
         public void addListener(SelectionListener listener);
 
         public static class SelectionManagerImpl extends SelectionManager
@@ -205,9 +205,9 @@ public class TestSelector extends Composite implements 
DataTableListener, Change
         display.getTestTable().refreshWidgets();
     }
 
-    public Widget createWidget(int row, int cell, JSONObject rowObject) {
+    public Widget createWidget(int row, int cell, JSONObject rowObject, int 
type) {
         TableClickWidget widget =
-            (TableClickWidget) display.getTestSelection().createWidget(row, 
cell, rowObject);
+            (TableClickWidget) display.getTestSelection().createWidget(row, 
cell, rowObject, type);
         if (!enabled) {
             widget.getContainedWidget().setEnabled(false);
         }
diff --git 
a/frontend/client/src/autotest/afe/create/CreateJobViewPresenter.java 
b/frontend/client/src/autotest/afe/create/CreateJobViewPresenter.java
index c62e715..bbd4fe2 100644
--- a/frontend/client/src/autotest/afe/create/CreateJobViewPresenter.java
+++ b/frontend/client/src/autotest/afe/create/CreateJobViewPresenter.java
@@ -589,6 +589,7 @@ public class CreateJobViewPresenter implements 
TestSelectorListener {
 
                 HostSelector.HostSelection hosts = 
hostSelector.getSelectedHosts();
                 args.put("hosts", Utils.stringsToJSON(hosts.hosts));
+                args.put("profiles", Utils.stringsToJSON(hosts.profiles));
                 args.put("meta_hosts", Utils.stringsToJSON(hosts.metaHosts));
                 args.put("one_time_hosts",
                     Utils.stringsToJSON(hosts.oneTimeHosts));
diff --git a/frontend/client/src/autotest/common/table/DataTable.java 
b/frontend/client/src/autotest/common/table/DataTable.java
index 8420a4d..1db8d10 100644
--- a/frontend/client/src/autotest/common/table/DataTable.java
+++ b/frontend/client/src/autotest/common/table/DataTable.java
@@ -60,7 +60,7 @@ public class DataTable extends Composite implements 
ClickHandler, ContextMenuHan
 
 
     public static interface TableWidgetFactory {
-        public Widget createWidget(int row, int cell, JSONObject rowObject);
+        public Widget createWidget(int row, int cell, JSONObject rowObject, 
int type);
     }
 
     /**
@@ -163,8 +163,10 @@ public class DataTable extends Composite implements 
ClickHandler, ContextMenuHan
     protected void addRowFromData(String[] rowData) {
         int row = table.getRowCount();
         for(int i = 0; i < columns.length; i++) {
-            if(isWidgetColumn(i)) {
-                table.setWidget(row, i, getWidgetForCell(row, i));
+            if (isProfileColumn(i)) {
+                table.setWidget(row, i, getWidgetForCell(row, i, 1));
+            } else if(isWidgetColumn(i)) {
+                table.setWidget(row, i, getWidgetForCell(row, i, 0));
             } else {
                 table.setText(row, i, rowData[i]);
             }
@@ -177,7 +179,11 @@ public class DataTable extends Composite implements 
ClickHandler, ContextMenuHan
     }
 
     protected boolean isClickableWidgetColumn(int column) {
-        return columns[column][COL_NAME].equals(CLICKABLE_WIDGET_COLUMN);
+        return columns[column][COL_NAME].equals(CLICKABLE_WIDGET_COLUMN) || 
isProfileColumn(column);
+    }
+
+    protected boolean isProfileColumn(int column) {
+        return columns[column][COL_NAME].equals("current_profile");
     }
 
     /**
@@ -303,12 +309,15 @@ public class DataTable extends Composite implements 
ClickHandler, ContextMenuHan
                     continue;
                 }
                 table.clearCell(row, column);
-                table.setWidget(row, column, getWidgetForCell(row, column));
+                if (isProfileColumn(column))
+                    table.setWidget(row, column, getWidgetForCell(row, column, 
1));
+                else if (isWidgetColumn(column))
+                    table.setWidget(row, column, getWidgetForCell(row, column, 
0));
             }
         }
     }
 
-    private Widget getWidgetForCell(int row, int column) {
-        return widgetFactory.createWidget(row - 1, column, jsonObjects.get(row 
- 1));
+    private Widget getWidgetForCell(int row, int column, int type) {
+        return widgetFactory.createWidget(row - 1, column, jsonObjects.get(row 
- 1), type);
     }
 }
diff --git a/frontend/client/src/autotest/tko/TableView.java 
b/frontend/client/src/autotest/tko/TableView.java
index c3d04b0..193572d 100644
--- a/frontend/client/src/autotest/tko/TableView.java
+++ b/frontend/client/src/autotest/tko/TableView.java
@@ -535,7 +535,7 @@ public class TableView extends ConditionTabView
         return getGroupingFromFields(savedColumns());
     }
 
-    public Widget createWidget(int row, int cell, JSONObject rowObject) {
+    public Widget createWidget(int row, int cell, JSONObject rowObject, int 
type) {
         assert getActiveGrouping() == GroupingType.STATUS_COUNTS;
         StatusSummary statusSummary = 
StatusSummary.getStatusSummary(rowObject);
         SimplePanel panel = new SimplePanel();
-- 
1.7.7.6

-- 
Nishanth Aravamudan <[email protected]>
IBM Linux Technology Center

_______________________________________________
Autotest mailing list
[email protected]
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest

Reply via email to