Prevent NullPointerException when clicking on a test in Create Job.

No functional effect, just keeps the exception from showing up in DevMode.

Signed-off-by: James Ren <[email protected]>

--- autotest/frontend/client/src/autotest/common/table/DataTable.java   
2010-07-14 15:23:54.000000000 -0700
+++ autotest/frontend/client/src/autotest/common/table/DataTable.java   
2010-07-14 15:23:54.000000000 -0700
@@ -20,7 +20,7 @@
 import java.util.List;
 
 /**
- * A table to display data from JSONObjects.  Each row displays data from one 
+ * A table to display data from JSONObjects.  Each row displays data from one
  * JSONObject.  A header row with column titles is automatically generated, and
  * support is included for adding other arbitrary header rows.
  * <br><br>
@@ -41,44 +41,44 @@
     public static final String CLICKABLE_WIDGET_COLUMN = 
"_CLICKABLE_WIDGET_COLUMN_";
     // for indexing into column subarrays (i.e. columns[1][COL_NAME])
     public static final int COL_NAME = 0, COL_TITLE = 1;
-    
+
     public static interface DataTableListener {
         public void onRowClicked(int rowIndex, JSONObject row, boolean 
isRightClick);
     }
-    
+
     protected RightClickTable table;
-    
+
     protected String[][] columns;
     protected int headerRow = 0;
     protected boolean clickable = false;
-    
+
     protected TableWidgetFactory widgetFactory = null;
     private List<DataTableListener> listeners = new 
ArrayList<DataTableListener>();
-    
+
     // keep a list of JSONObjects corresponding to rows in the table
     protected List<JSONObject> jsonObjects = new ArrayList<JSONObject>();
 
-    
+
     public static interface TableWidgetFactory {
         public Widget createWidget(int row, int cell, JSONObject rowObject);
     }
-    
+
     /**
      * @param columns An array specifying the name of each column and the field
      * to which it corresponds.  The array should have the form
-     * {{'field_name1', 'Column Title 1'}, 
+     * {{'field_name1', 'Column Title 1'},
      *  {'field_name2', 'Column Title 2'}, ...}.
-     */ 
+     */
     public DataTable(String[][] columns) {
         int rows = columns.length;
         this.columns = new String[rows][2];
         for (int i = 0; i < rows; i++) {
             System.arraycopy(columns[i], 0, this.columns[i], 0, 2);
         }
-        
+
         table = new RightClickTable();
         initWidget(table);
-        
+
         table.setCellSpacing(0);
         table.setCellPadding(0);
         table.setStylePrimaryName("data-table");
@@ -91,7 +91,7 @@
         table.getRowFormatter().setStylePrimaryName(0, HEADER_STYLE);
         table.addClickHandler(this);
     }
-    
+
     /**
      * Causes the last column of the data table to fill the remainder of the 
width left in the
      * parent widget.
@@ -99,7 +99,7 @@
     public void fillParent() {
         table.getColumnFormatter().setWidth(table.getCellCount(0) - 1, "100%");
     }
-    
+
     public void setWidgetFactory(TableWidgetFactory widgetFactory) {
         this.widgetFactory = widgetFactory;
     }
@@ -113,7 +113,7 @@
             table.getRowFormatter().addStyleName(row, CLICKABLE_STYLE);
         }
     }
-    
+
     public void setClickable(boolean clickable) {
         this.clickable = clickable;
         for(int i = headerRow + 1; i < table.getRowCount(); i++)
@@ -129,22 +129,22 @@
         }
         jsonObjects.clear();
     }
-    
+
     /**
      * This gets called for every JSONObject that gets added to the table using
-     * addRow().  This allows subclasses to customize objects before they are 
-     * added to the table, for example to reformat fields or generate new 
+     * addRow().  This allows subclasses to customize objects before they are
+     * added to the table, for example to reformat fields or generate new
      * fields from the existing data.
      * @param row The row object about to be added to the table.
      */
     protected void preprocessRow(JSONObject row) {}
-    
+
     protected String[] getRowText(JSONObject row) {
         String[] rowText = new String[columns.length];
         for (int i = 0; i < columns.length; i++) {
             if (isWidgetColumn(i))
                 continue;
-            
+
             String columnKey = columns[i][0];
             JSONValue columnValue = row.get(columnKey);
             if (columnValue == null || columnValue.isNull() != null) {
@@ -155,7 +155,7 @@
         }
         return rowText;
     }
-    
+
     /**
      * Add a row from an array of Strings, one String for each column.
      * @param rowData Data for each column, in left-to-right column order.
@@ -175,7 +175,7 @@
     protected boolean isWidgetColumn(int column) {
         return columns[column][COL_NAME].equals(WIDGET_COLUMN) || 
isClickableWidgetColumn(column);
     }
-    
+
     protected boolean isClickableWidgetColumn(int column) {
         return columns[column][COL_NAME].equals(CLICKABLE_WIDGET_COLUMN);
     }
@@ -190,7 +190,7 @@
         jsonObjects.add(row);
         addRowFromData(getRowText(row));
     }
-    
+
     /**
      * Add all objects in a JSONArray.
      * @param rows An array of JSONObjects
@@ -215,83 +215,87 @@
         for(int i = realRow; i < table.getRowCount(); i++)
             setRowStyle(i);
     }
-    
+
     /**
-     * Returns the number of data rows in the table.  The actual number of 
+     * Returns the number of data rows in the table.  The actual number of
      * visible table rows is more than this, due to the header row.
      */
     public int getRowCount() {
         return table.getRowCount() - 1;
     }
-    
+
     /**
      * Get the JSONObject corresponding to the indexed row.
      */
     public JSONObject getRow(int rowIndex) {
         return jsonObjects.get(rowIndex);
     }
-    
+
     public List<JSONObject> getAllRows() {
         return Collections.unmodifiableList(jsonObjects);
     }
-    
+
     public void highlightRow(int row) {
         row++; // account for header row
         table.getRowFormatter().addStyleName(row, HIGHLIGHTED_STYLE);
     }
-    
+
     public void unhighlightRow(int row) {
         row++; // account for header row
         table.getRowFormatter().removeStyleName(row, HIGHLIGHTED_STYLE);
     }
-    
+
     public void sinkRightClickEvents() {
         table.addContextMenuHandler(this);
     }
-    
+
     @Override
     public void onClick(ClickEvent event) {
         onCellClicked(event, false);
     }
-    
+
     @Override
     public void onContextMenu(ContextMenuEvent event) {
         onCellClicked(event, true);
     }
-    
+
     private void onCellClicked(DomEvent<?> event, boolean isRightClick) {
         HTMLTable.Cell tableCell = table.getCellForDomEvent(event);
+        if (tableCell == null) {
+            return;
+        }
+
         int row = tableCell.getRowIndex();
         int cell = tableCell.getCellIndex();
-        
+
         if (isClickableWidgetColumn(cell) && table.getWidget(row, cell) != 
null) {
             return;
         }
-        
+
         onCellClicked(row, cell, isRightClick);
     }
-    
+
     protected void onCellClicked(int row, int cell, boolean isRightClick) {
         if (row != headerRow) {
             notifyListenersClicked(row - headerRow - 1, isRightClick);
         }
     }
-    
+
     public void addListener(DataTableListener listener) {
         listeners.add(listener);
     }
-    
+
     public void removeListener(DataTableListener listener) {
         listeners.remove(listener);
     }
-    
+
     protected void notifyListenersClicked(int rowIndex, boolean isRightClick) {
         JSONObject row = getRow(rowIndex);
         for (DataTableListener listener : listeners) {
             listener.onRowClicked(rowIndex, row, isRightClick);
         }
     }
-    
+
     public void refreshWidgets() {
         for (int row = 1; row < table.getRowCount(); row++) {
             for (int column = 0; column < columns.length; column++) {
_______________________________________________
Autotest mailing list
[email protected]
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest

Reply via email to