Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(409)

Side by Side Diff: frontend/client/src/autotest/afe/AfeUtils.java

Issue 3554003: Merge remote branch 'cros/upstream' into tempbranch3 (Closed) Base URL: http://git.chromium.org/git/autotest.git
Patch Set: Created 10 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 package autotest.afe; 1 package autotest.afe;
2 2
3 import autotest.afe.CreateJobView.JobCreateListener; 3 import autotest.afe.create.CreateJobViewPresenter.JobCreateListener;
4 import autotest.common.JSONArrayList; 4 import autotest.common.JSONArrayList;
5 import autotest.common.JsonRpcCallback; 5 import autotest.common.JsonRpcCallback;
6 import autotest.common.JsonRpcProxy; 6 import autotest.common.JsonRpcProxy;
7 import autotest.common.SimpleCallback; 7 import autotest.common.SimpleCallback;
8 import autotest.common.StaticDataRepository; 8 import autotest.common.StaticDataRepository;
9 import autotest.common.Utils; 9 import autotest.common.Utils;
10 import autotest.common.table.JSONObjectSet; 10 import autotest.common.table.JSONObjectSet;
11 import autotest.common.ui.NotifyManager; 11 import autotest.common.ui.NotifyManager;
12 import autotest.common.ui.RadioChooser; 12 import autotest.common.ui.RadioChooser;
13 import autotest.common.ui.SimplifiedList;
13 14
14 import com.google.gwt.json.client.JSONArray; 15 import com.google.gwt.json.client.JSONArray;
15 import com.google.gwt.json.client.JSONBoolean; 16 import com.google.gwt.json.client.JSONBoolean;
16 import com.google.gwt.json.client.JSONObject; 17 import com.google.gwt.json.client.JSONObject;
17 import com.google.gwt.json.client.JSONString; 18 import com.google.gwt.json.client.JSONString;
18 import com.google.gwt.json.client.JSONValue; 19 import com.google.gwt.json.client.JSONValue;
19 import com.google.gwt.user.client.DOM; 20 import com.google.gwt.user.client.DOM;
20 import com.google.gwt.user.client.Element; 21 import com.google.gwt.user.client.Element;
21 import com.google.gwt.user.client.ui.ListBox; 22 import com.google.gwt.user.client.ui.ListBox;
22 23
(...skipping 30 matching lines...) Expand all
53 } 54 }
54 return result.toString(); 55 return result.toString();
55 } 56 }
56 57
57 public static String[] getLabelStrings() { 58 public static String[] getLabelStrings() {
58 return getFilteredLabelStrings(false, false); 59 return getFilteredLabelStrings(false, false);
59 } 60 }
60 61
61 protected static String[] getFilteredLabelStrings(boolean onlyPlatforms, 62 protected static String[] getFilteredLabelStrings(boolean onlyPlatforms,
62 boolean onlyNonPlatforms) { 63 boolean onlyNonPlatforms) {
63 assert( !(onlyPlatforms && onlyNonPlatforms)); 64 assert !(onlyPlatforms && onlyNonPlatforms);
64 JSONArray labels = staticData.getData("labels").isArray(); 65 JSONArray labels = staticData.getData("labels").isArray();
65 List<String> result = new ArrayList<String>(); 66 List<String> result = new ArrayList<String>();
66 for (int i = 0; i < labels.size(); i++) { 67 for (int i = 0; i < labels.size(); i++) {
67 JSONObject label = labels.get(i).isObject(); 68 JSONObject label = labels.get(i).isObject();
68 String name = label.get("name").isString().stringValue(); 69 String name = label.get("name").isString().stringValue();
69 boolean labelIsPlatform = label.get("platform").isBoolean().booleanV alue(); 70 boolean labelIsPlatform = label.get("platform").isBoolean().booleanV alue();
70 JSONObject atomicGroup = label.get("atomic_group").isObject(); 71 JSONObject atomicGroup = label.get("atomic_group").isObject();
71 if (atomicGroup != null) { 72 if (atomicGroup != null) {
72 name += ATOMIC_GROUP_SUFFIX; 73 name += ATOMIC_GROUP_SUFFIX;
73 } 74 }
74 if ((onlyPlatforms && labelIsPlatform) || 75 if (onlyPlatforms && labelIsPlatform ||
75 (onlyNonPlatforms && !labelIsPlatform)) { 76 onlyNonPlatforms && !labelIsPlatform) {
76 result.add(name); 77 result.add(name);
77 } else if (!onlyPlatforms && !onlyNonPlatforms) { 78 } else if (!onlyPlatforms && !onlyNonPlatforms) {
78 if (labelIsPlatform) { 79 if (labelIsPlatform) {
79 name += PLATFORM_SUFFIX; 80 name += PLATFORM_SUFFIX;
80 } 81 }
81 result.add(name); 82 result.add(name);
82 } 83 }
83 } 84 }
84 return result.toArray(new String[result.size()]); 85 return result.toArray(new String[result.size()]);
85 } 86 }
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 return Utils.jsonToString(job.get("id")) + "-" + Utils.jsonToString(job. get("owner")); 313 return Utils.jsonToString(job.get("id")) + "-" + Utils.jsonToString(job. get("owner"));
313 } 314 }
314 315
315 public static void populateRadioChooser(RadioChooser chooser, String name) { 316 public static void populateRadioChooser(RadioChooser chooser, String name) {
316 JSONArray options = staticData.getData(name + "_options").isArray(); 317 JSONArray options = staticData.getData(name + "_options").isArray();
317 for (JSONString jsonOption : new JSONArrayList<JSONString>(options)) { 318 for (JSONString jsonOption : new JSONArrayList<JSONString>(options)) {
318 chooser.addChoice(Utils.jsonToString(jsonOption)); 319 chooser.addChoice(Utils.jsonToString(jsonOption));
319 } 320 }
320 } 321 }
321 322
322 public static void popualateListBox(ListBox box, String staticDataKey) { 323 public static void populateListBox(ListBox box, String staticDataKey) {
323 JSONArray options = staticData.getData(staticDataKey).isArray(); 324 JSONArray options = staticData.getData(staticDataKey).isArray();
324 for (JSONString jsonOption : new JSONArrayList<JSONString>(options)) { 325 for (JSONString jsonOption : new JSONArrayList<JSONString>(options)) {
325 box.addItem(Utils.jsonToString(jsonOption)); 326 box.addItem(Utils.jsonToString(jsonOption));
326 } 327 }
327 } 328 }
328 329
330 public static void populateListBox(SimplifiedList box, String staticDataKey) {
331 JSONArray options = staticData.getData(staticDataKey).isArray();
332 for (JSONString jsonOption : new JSONArrayList<JSONString>(options)) {
333 String option = Utils.jsonToString(jsonOption);
334 box.addItem(option, option);
335 }
336 }
337
329 public static void setSelectedItem(ListBox box, String item) { 338 public static void setSelectedItem(ListBox box, String item) {
330 box.setSelectedIndex(0); 339 box.setSelectedIndex(0);
331 for (int i = 0; i < box.getItemCount(); i++) { 340 for (int i = 0; i < box.getItemCount(); i++) {
332 if (box.getItemText(i).equals(item)) { 341 if (box.getItemText(i).equals(item)) {
333 box.setSelectedIndex(i); 342 box.setSelectedIndex(i);
334 break; 343 break;
335 } 344 }
336 } 345 }
337 } 346 }
338 347
(...skipping 24 matching lines...) Expand all
363 String targetFieldName) { 372 String targetFieldName) {
364 JSONValue dateValue = row.get(sourceFieldName); 373 JSONValue dateValue = row.get(sourceFieldName);
365 String date = ""; 374 String date = "";
366 if (dateValue.isNull() == null) { 375 if (dateValue.isNull() == null) {
367 date = dateValue.isString().stringValue(); 376 date = dateValue.isString().stringValue();
368 date = date.substring(0, date.length() - 3); 377 date = date.substring(0, date.length() - 3);
369 } 378 }
370 row.put(targetFieldName, new JSONString(date)); 379 row.put(targetFieldName, new JSONString(date));
371 } 380 }
372 } 381 }
OLDNEW
« no previous file with comments | « frontend/client/src/autotest/afe/AfeClient.java ('k') | frontend/client/src/autotest/afe/CheckBoxPanel.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698