| OLD | NEW |
| 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.SimpleCallback; | 4 import autotest.common.SimpleCallback; |
| 5 import autotest.common.Utils; | 5 import autotest.common.Utils; |
| 6 import autotest.common.table.DataSource; | 6 import autotest.common.table.DataSource; |
| 7 import autotest.common.table.DataTable; | |
| 8 import autotest.common.table.DynamicTable; | |
| 9 import autotest.common.table.RpcDataSource; | |
| 10 import autotest.common.table.SelectionManager; | |
| 11 import autotest.common.table.SimpleFilter; | |
| 12 import autotest.common.table.TableDecorator; | |
| 13 import autotest.common.table.DataSource.DataCallback; | 7 import autotest.common.table.DataSource.DataCallback; |
| 14 import autotest.common.table.DataSource.Query; | 8 import autotest.common.table.DataSource.Query; |
| 15 import autotest.common.table.DataSource.SortDirection; | 9 import autotest.common.table.DataSource.SortDirection; |
| 10 import autotest.common.table.DataTable; |
| 11 import autotest.common.table.DynamicTable; |
| 16 import autotest.common.table.DynamicTable.DynamicTableListener; | 12 import autotest.common.table.DynamicTable.DynamicTableListener; |
| 13 import autotest.common.table.RpcDataSource; |
| 14 import autotest.common.table.SelectionManager; |
| 17 import autotest.common.table.SelectionManager.SelectableRowFilter; | 15 import autotest.common.table.SelectionManager.SelectableRowFilter; |
| 16 import autotest.common.table.SimpleFilter; |
| 17 import autotest.common.table.TableDecorator; |
| 18 import autotest.common.ui.ContextMenu; | 18 import autotest.common.ui.ContextMenu; |
| 19 import autotest.common.ui.DetailView; | 19 import autotest.common.ui.DetailView; |
| 20 import autotest.common.ui.NotifyManager; | 20 import autotest.common.ui.NotifyManager; |
| 21 import autotest.common.ui.TableActionsPanel.TableActionsListener; | 21 import autotest.common.ui.TableActionsPanel.TableActionsListener; |
| 22 | 22 |
| 23 import com.google.gwt.event.dom.client.ClickEvent; | 23 import com.google.gwt.event.dom.client.ClickEvent; |
| 24 import com.google.gwt.event.dom.client.ClickHandler; | 24 import com.google.gwt.event.dom.client.ClickHandler; |
| 25 import com.google.gwt.json.client.JSONArray; | 25 import com.google.gwt.json.client.JSONArray; |
| 26 import com.google.gwt.json.client.JSONBoolean; | 26 import com.google.gwt.json.client.JSONBoolean; |
| 27 import com.google.gwt.json.client.JSONObject; | 27 import com.google.gwt.json.client.JSONObject; |
| 28 import com.google.gwt.json.client.JSONString; | 28 import com.google.gwt.json.client.JSONString; |
| 29 import com.google.gwt.json.client.JSONValue; | 29 import com.google.gwt.json.client.JSONValue; |
| 30 import com.google.gwt.user.client.Command; | 30 import com.google.gwt.user.client.Command; |
| 31 import com.google.gwt.user.client.ui.Button; | 31 import com.google.gwt.user.client.ui.Button; |
| 32 import com.google.gwt.user.client.ui.CheckBox; | 32 import com.google.gwt.user.client.ui.CheckBox; |
| 33 | 33 |
| 34 import java.util.List; | 34 import java.util.List; |
| 35 | 35 |
| 36 public class HostDetailView extends DetailView | 36 public class HostDetailView extends DetailView |
| 37 implements DataCallback, TableActionsListener, Selec
tableRowFilter { | 37 implements DataCallback, TableActionsListener, Selec
tableRowFilter { |
| 38 private static final String[][] HOST_JOBS_COLUMNS = { | 38 private static final String[][] HOST_JOBS_COLUMNS = { |
| 39 {DataTable.WIDGET_COLUMN, ""}, {"type", "Type"}, {"job__id", "Job ID
"}, | 39 {DataTable.WIDGET_COLUMN, ""}, {"type", "Type"}, {"job__id", "Job ID
"}, |
| 40 {"job_owner", "Job Owner"}, {"job_name", "Job Name"}, {"started_on",
"Time started"}, | 40 {"job_owner", "Job Owner"}, {"job_name", "Job Name"}, {"started_on",
"Time started"}, |
| 41 {"status", "Status"} | 41 {"status", "Status"} |
| 42 }; | 42 }; |
| 43 public static final int JOBS_PER_PAGE = 20; | 43 public static final int JOBS_PER_PAGE = 20; |
| 44 | 44 |
| 45 public interface HostDetailListener { | 45 public interface HostDetailListener { |
| 46 public void onJobSelected(int jobId); | 46 public void onJobSelected(int jobId); |
| 47 } | 47 } |
| 48 | 48 |
| 49 private static class HostQueueEntryDataSource extends RpcDataSource { | 49 private static class HostQueueEntryDataSource extends RpcDataSource { |
| 50 public HostQueueEntryDataSource() { | 50 public HostQueueEntryDataSource() { |
| 51 super("get_host_queue_entries", "get_num_host_queue_entries"); | 51 super("get_host_queue_entries", "get_num_host_queue_entries"); |
| 52 } | 52 } |
| 53 | 53 |
| 54 @Override | 54 @Override |
| 55 protected List<JSONObject> handleJsonResult(JSONValue result) { | 55 protected List<JSONObject> handleJsonResult(JSONValue result) { |
| 56 List<JSONObject> resultArray = super.handleJsonResult(result); | 56 List<JSONObject> resultArray = super.handleJsonResult(result); |
| 57 for (JSONObject row : resultArray) { | 57 for (JSONObject row : resultArray) { |
| 58 // get_host_queue_entries() doesn't return type, so fill it in f
or consistency with | 58 // get_host_queue_entries() doesn't return type, so fill it in f
or consistency with |
| 59 // get_host_queue_entries_and_special_tasks() | 59 // get_host_queue_entries_and_special_tasks() |
| 60 row.put("type", new JSONString("Job")); | 60 row.put("type", new JSONString("Job")); |
| 61 } | 61 } |
| 62 return resultArray; | 62 return resultArray; |
| 63 } | 63 } |
| 64 } | 64 } |
| 65 | 65 |
| 66 private static class HostJobsTable extends DynamicTable { | 66 private static class HostJobsTable extends DynamicTable { |
| 67 private static final DataSource normalDataSource = new HostQueueEntryDat
aSource(); | 67 private static final DataSource normalDataSource = new HostQueueEntryDat
aSource(); |
| 68 private static final DataSource dataSourceWithSpecialTasks = | 68 private static final DataSource dataSourceWithSpecialTasks = |
| 69 new RpcDataSource("get_host_queue_entries_and_special_tasks", | 69 new RpcDataSource("get_host_queue_entries_and_special_tasks", |
| 70 "get_num_host_queue_entries_and_special_tasks"); | 70 "get_num_host_queue_entries_and_special_tasks"); |
| 71 | 71 |
| 72 private SimpleFilter hostFilter = new SimpleFilter(); | 72 private SimpleFilter hostFilter = new SimpleFilter(); |
| 73 private String hostname; | 73 private String hostname; |
| 74 | 74 |
| 75 public HostJobsTable() { | 75 public HostJobsTable() { |
| 76 super(HOST_JOBS_COLUMNS, normalDataSource); | 76 super(HOST_JOBS_COLUMNS, normalDataSource); |
| 77 addFilter(hostFilter); | 77 addFilter(hostFilter); |
| 78 } | 78 } |
| 79 | 79 |
| 80 public void setHostname(String hostname) { | 80 public void setHostname(String hostname) { |
| 81 this.hostname = hostname; | 81 this.hostname = hostname; |
| 82 updateFilter(); | 82 updateFilter(); |
| 83 } | 83 } |
| 84 | 84 |
| 85 private void updateFilter() { | 85 private void updateFilter() { |
| 86 String key; | 86 String key; |
| 87 if (getDataSource() == normalDataSource) { | 87 if (getDataSource() == normalDataSource) { |
| 88 key = "host__hostname"; | 88 key = "host__hostname"; |
| 89 sortOnColumn("job__id", SortDirection.DESCENDING); | 89 sortOnColumn("job__id", SortDirection.DESCENDING); |
| 90 } else { | 90 } else { |
| 91 key = "hostname"; | 91 key = "hostname"; |
| 92 clearSorts(); | 92 clearSorts(); |
| 93 } | 93 } |
| 94 | 94 |
| 95 hostFilter.clear(); | 95 hostFilter.clear(); |
| 96 hostFilter.setParameter(key, new JSONString(hostname)); | 96 hostFilter.setParameter(key, new JSONString(hostname)); |
| 97 } | 97 } |
| 98 | 98 |
| 99 public void setSpecialTasksEnabled(boolean enabled) { | 99 public void setSpecialTasksEnabled(boolean enabled) { |
| 100 if (enabled) { | 100 if (enabled) { |
| 101 setDataSource(dataSourceWithSpecialTasks); | 101 setDataSource(dataSourceWithSpecialTasks); |
| 102 } else { | 102 } else { |
| 103 setDataSource(normalDataSource); | 103 setDataSource(normalDataSource); |
| 104 } | 104 } |
| 105 | 105 |
| 106 updateFilter(); | 106 updateFilter(); |
| 107 } | 107 } |
| 108 | 108 |
| 109 @Override | 109 @Override |
| 110 protected void preprocessRow(JSONObject row) { | 110 protected void preprocessRow(JSONObject row) { |
| 111 JSONObject job = row.get("job").isObject(); | 111 JSONObject job = row.get("job").isObject(); |
| 112 JSONString blank = new JSONString(""); | 112 JSONString blank = new JSONString(""); |
| 113 JSONString jobId = blank, owner = blank, name = blank; | 113 JSONString jobId = blank, owner = blank, name = blank; |
| 114 if (job != null) { | 114 if (job != null) { |
| 115 int id = (int) job.get("id").isNumber().doubleValue(); | 115 int id = (int) job.get("id").isNumber().doubleValue(); |
| 116 jobId = new JSONString(Integer.toString(id)); | 116 jobId = new JSONString(Integer.toString(id)); |
| 117 owner = job.get("owner").isString(); | 117 owner = job.get("owner").isString(); |
| 118 name = job.get("name").isString(); | 118 name = job.get("name").isString(); |
| 119 } | 119 } |
| 120 | 120 |
| 121 row.put("job__id", jobId); | 121 row.put("job__id", jobId); |
| 122 row.put("job_owner", owner); | 122 row.put("job_owner", owner); |
| 123 row.put("job_name", name); | 123 row.put("job_name", name); |
| 124 } | 124 } |
| 125 } | 125 } |
| 126 | 126 |
| 127 private String hostname = ""; | 127 private String hostname = ""; |
| 128 private DataSource hostDataSource = new HostDataSource(); | 128 private DataSource hostDataSource = new HostDataSource(); |
| 129 private HostJobsTable jobsTable = new HostJobsTable(); | 129 private HostJobsTable jobsTable = new HostJobsTable(); |
| 130 private TableDecorator tableDecorator = new TableDecorator(jobsTable); | 130 private TableDecorator tableDecorator = new TableDecorator(jobsTable); |
| 131 private HostDetailListener hostDetailListener = null; | 131 private HostDetailListener hostDetailListener = null; |
| 132 private JobCreateListener jobCreateListener = null; | 132 private JobCreateListener jobCreateListener = null; |
| 133 private SelectionManager selectionManager; | 133 private SelectionManager selectionManager; |
| 134 | 134 |
| 135 private JSONObject currentHostObject; | 135 private JSONObject currentHostObject; |
| 136 | 136 |
| 137 private Button lockButton = new Button(); | 137 private Button lockButton = new Button(); |
| 138 private Button reverifyButton = new Button("Reverify"); | 138 private Button reverifyButton = new Button("Reverify"); |
| 139 private Button reinstallButton = new Button("Reinstall"); | 139 private Button reinstallButton = new Button("Reinstall"); |
| 140 private CheckBox showSpecialTasks = new CheckBox(); | 140 private CheckBox showSpecialTasks = new CheckBox(); |
| 141 | 141 |
| 142 public HostDetailView(HostDetailListener hostDetailListener, | 142 public HostDetailView(HostDetailListener hostDetailListener, |
| 143 JobCreateListener jobCreateListener) { | 143 JobCreateListener jobCreateListener) { |
| 144 this.hostDetailListener = hostDetailListener; | 144 this.hostDetailListener = hostDetailListener; |
| 145 this.jobCreateListener = jobCreateListener; | 145 this.jobCreateListener = jobCreateListener; |
| 146 } | 146 } |
| 147 | 147 |
| 148 @Override | 148 @Override |
| 149 public String getElementId() { | 149 public String getElementId() { |
| 150 return "view_host"; | 150 return "view_host"; |
| 151 } | 151 } |
| 152 | 152 |
| 153 @Override | 153 @Override |
| 154 protected String getFetchControlsElementId() { | 154 protected String getFetchControlsElementId() { |
| 155 return "view_host_fetch_controls"; | 155 return "view_host_fetch_controls"; |
| 156 } | 156 } |
| 157 | 157 |
| 158 @Override | 158 @Override |
| 159 protected String getDataElementId() { | 159 protected String getDataElementId() { |
| 160 return "view_host_data"; | 160 return "view_host_data"; |
| 161 } | 161 } |
| 162 | 162 |
| 163 @Override | 163 @Override |
| 164 protected String getTitleElementId() { | 164 protected String getTitleElementId() { |
| 165 return "view_host_title"; | 165 return "view_host_title"; |
| 166 } | 166 } |
| 167 | 167 |
| 168 @Override | 168 @Override |
| 169 protected String getNoObjectText() { | 169 protected String getNoObjectText() { |
| 170 return "No host selected"; | 170 return "No host selected"; |
| 171 } | 171 } |
| 172 | 172 |
| 173 @Override | 173 @Override |
| 174 protected String getObjectId() { | 174 protected String getObjectId() { |
| 175 return hostname; | 175 return hostname; |
| 176 } | 176 } |
| 177 | 177 |
| 178 @Override | 178 @Override |
| 179 protected void setObjectId(String id) { | 179 protected void setObjectId(String id) { |
| 180 if (id.length() == 0) | 180 if (id.length() == 0) { |
| 181 throw new IllegalArgumentException(); | 181 throw new IllegalArgumentException(); |
| 182 } |
| 182 this.hostname = id; | 183 this.hostname = id; |
| 183 } | 184 } |
| 184 | 185 |
| 185 @Override | 186 @Override |
| 186 protected void fetchData() { | 187 protected void fetchData() { |
| 187 JSONObject params = new JSONObject(); | 188 JSONObject params = new JSONObject(); |
| 188 params.put("hostname", new JSONString(hostname)); | 189 params.put("hostname", new JSONString(hostname)); |
| 189 params.put("valid_only", JSONBoolean.getInstance(false)); | 190 params.put("valid_only", JSONBoolean.getInstance(false)); |
| 190 hostDataSource.query(params, this); | 191 hostDataSource.query(params, this); |
| 191 } | 192 } |
| 192 | 193 |
| 193 @Override | 194 @Override |
| 194 public void handleTotalResultCount(int totalCount) {} | 195 public void handleTotalResultCount(int totalCount) {} |
| 195 | 196 |
| 196 @Override | 197 @Override |
| 197 public void onQueryReady(Query query) { | 198 public void onQueryReady(Query query) { |
| 198 query.getPage(null, null, null, this); | 199 query.getPage(null, null, null, this); |
| 199 } | 200 } |
| 200 | 201 |
| 201 public void handlePage(List<JSONObject> data) { | 202 public void handlePage(List<JSONObject> data) { |
| 202 try { | 203 try { |
| 203 currentHostObject = Utils.getSingleObjectFromList(data); | 204 currentHostObject = Utils.getSingleObjectFromList(data); |
| 204 } | 205 } |
| 205 catch (IllegalArgumentException exc) { | 206 catch (IllegalArgumentException exc) { |
| 206 NotifyManager.getInstance().showError("No such host found"); | 207 NotifyManager.getInstance().showError("No such host found"); |
| 207 resetPage(); | 208 resetPage(); |
| 208 return; | 209 return; |
| 209 } | 210 } |
| 210 | 211 |
| 211 String lockedText = Utils.jsonToString(currentHostObject.get(HostDataSou
rce.LOCKED_TEXT)); | 212 String lockedText = Utils.jsonToString(currentHostObject.get(HostDataSou
rce.LOCKED_TEXT)); |
| 212 if (currentHostObject.get("locked").isBoolean().booleanValue()) { | 213 if (currentHostObject.get("locked").isBoolean().booleanValue()) { |
| 213 String lockedBy = Utils.jsonToString(currentHostObject.get("locked_b
y")); | 214 String lockedBy = Utils.jsonToString(currentHostObject.get("locked_b
y")); |
| 214 String lockedTime = Utils.jsonToString(currentHostObject.get("lock_t
ime")); | 215 String lockedTime = Utils.jsonToString(currentHostObject.get("lock_t
ime")); |
| 215 lockedText += ", by " + lockedBy + " on " + lockedTime; | 216 lockedText += ", by " + lockedBy + " on " + lockedTime; |
| 216 } | 217 } |
| 217 | 218 |
| 218 showField(currentHostObject, "status", "view_host_status"); | 219 showField(currentHostObject, "status", "view_host_status"); |
| 219 showField(currentHostObject, "platform", "view_host_platform"); | 220 showField(currentHostObject, "platform", "view_host_platform"); |
| 220 showField(currentHostObject, HostDataSource.HOST_ACLS, "view_host_acls")
; | 221 showField(currentHostObject, HostDataSource.HOST_ACLS, "view_host_acls")
; |
| 221 showField(currentHostObject, HostDataSource.OTHER_LABELS, "view_host_lab
els"); | 222 showField(currentHostObject, HostDataSource.OTHER_LABELS, "view_host_lab
els"); |
| 222 showText(lockedText, "view_host_locked"); | 223 showText(lockedText, "view_host_locked"); |
| 223 showField(currentHostObject, "protection", "view_host_protection"); | 224 showField(currentHostObject, "protection", "view_host_protection"); |
| 224 String pageTitle = "Host " + hostname; | 225 String pageTitle = "Host " + hostname; |
| 225 updateLockButton(); | 226 updateLockButton(); |
| 226 displayObjectData(pageTitle); | 227 displayObjectData(pageTitle); |
| 227 | 228 |
| 228 jobsTable.setHostname(hostname); | 229 jobsTable.setHostname(hostname); |
| 229 jobsTable.refresh(); | 230 jobsTable.refresh(); |
| 230 } | 231 } |
| 231 | 232 |
| 232 @Override | 233 @Override |
| 233 public void initialize() { | 234 public void initialize() { |
| 234 super.initialize(); | 235 super.initialize(); |
| 235 | 236 |
| 236 jobsTable.setRowsPerPage(JOBS_PER_PAGE); | 237 jobsTable.setRowsPerPage(JOBS_PER_PAGE); |
| 237 jobsTable.setClickable(true); | 238 jobsTable.setClickable(true); |
| 238 jobsTable.addListener(new DynamicTableListener() { | 239 jobsTable.addListener(new DynamicTableListener() { |
| 239 public void onRowClicked(int rowIndex, JSONObject row, boolean isRig
htClick) { | 240 public void onRowClicked(int rowIndex, JSONObject row, boolean isRig
htClick) { |
| 240 if (isJobRow(row)) { | 241 if (isJobRow(row)) { |
| 241 JSONObject job = row.get("job").isObject(); | 242 JSONObject job = row.get("job").isObject(); |
| 242 int jobId = (int) job.get("id").isNumber().doubleValue(); | 243 int jobId = (int) job.get("id").isNumber().doubleValue(); |
| 243 hostDetailListener.onJobSelected(jobId); | 244 hostDetailListener.onJobSelected(jobId); |
| 244 } else { | 245 } else { |
| 245 String resultsPath = Utils.jsonToString(row.get("execution_p
ath")); | 246 String resultsPath = Utils.jsonToString(row.get("execution_p
ath")); |
| 246 Utils.openUrlInNewWindow(Utils.getRetrieveLogsUrl(resultsPat
h)); | 247 Utils.openUrlInNewWindow(Utils.getRetrieveLogsUrl(resultsPat
h)); |
| 247 } | 248 } |
| 248 } | 249 } |
| 249 | 250 |
| 250 public void onTableRefreshed() {} | 251 public void onTableRefreshed() {} |
| 251 }); | 252 }); |
| 252 tableDecorator.addPaginators(); | 253 tableDecorator.addPaginators(); |
| 253 selectionManager = tableDecorator.addSelectionManager(false); | 254 selectionManager = tableDecorator.addSelectionManager(false); |
| 254 selectionManager.setSelectableRowFilter(this); | 255 selectionManager.setSelectableRowFilter(this); |
| 255 jobsTable.setWidgetFactory(selectionManager); | 256 jobsTable.setWidgetFactory(selectionManager); |
| 256 tableDecorator.addTableActionsPanel(this, true); | 257 tableDecorator.addTableActionsPanel(this, true); |
| 257 tableDecorator.addControl("Show verifies, repairs and cleanups", showSpe
cialTasks); | 258 tableDecorator.addControl("Show verifies, repairs and cleanups", showSpe
cialTasks); |
| 258 addWidget(tableDecorator, "view_host_jobs_table"); | 259 addWidget(tableDecorator, "view_host_jobs_table"); |
| 259 | 260 |
| 260 showSpecialTasks.addClickHandler(new ClickHandler() { | 261 showSpecialTasks.addClickHandler(new ClickHandler() { |
| 261 public void onClick(ClickEvent event) { | 262 public void onClick(ClickEvent event) { |
| 262 jobsTable.setSpecialTasksEnabled(showSpecialTasks.getValue()); | 263 jobsTable.setSpecialTasksEnabled(showSpecialTasks.getValue()); |
| 263 jobsTable.refresh(); | 264 jobsTable.refresh(); |
| 264 } | 265 } |
| 265 }); | 266 }); |
| 266 | 267 |
| 267 lockButton.addClickHandler(new ClickHandler() { | 268 lockButton.addClickHandler(new ClickHandler() { |
| 268 public void onClick(ClickEvent event) { | 269 public void onClick(ClickEvent event) { |
| 269 boolean locked = currentHostObject.get("locked").isBoolean().bool
eanValue(); | 270 boolean locked = currentHostObject.get("locked").isBoolean().bool
eanValue(); |
| 270 changeLock(!locked); | 271 changeLock(!locked); |
| 271 } | 272 } |
| 272 }); | 273 }); |
| 273 addWidget(lockButton, "view_host_lock_button"); | 274 addWidget(lockButton, "view_host_lock_button"); |
| 274 | 275 |
| 275 reverifyButton.addClickHandler(new ClickHandler() { | 276 reverifyButton.addClickHandler(new ClickHandler() { |
| 276 public void onClick(ClickEvent event) { | 277 public void onClick(ClickEvent event) { |
| 277 JSONObject params = new JSONObject(); | 278 JSONObject params = new JSONObject(); |
| 278 | 279 |
| 279 params.put("id", currentHostObject.get("id")); | 280 params.put("id", currentHostObject.get("id")); |
| 280 AfeUtils.callReverify(params, new SimpleCallback() { | 281 AfeUtils.callReverify(params, new SimpleCallback() { |
| 281 public void doCallback(Object source) { | 282 public void doCallback(Object source) { |
| 282 refresh(); | 283 refresh(); |
| 283 } | 284 } |
| 284 }, "Host " + hostname); | 285 }, "Host " + hostname); |
| 285 } | 286 } |
| 286 }); | 287 }); |
| 287 addWidget(reverifyButton, "view_host_reverify_button"); | 288 addWidget(reverifyButton, "view_host_reverify_button"); |
| 288 | 289 |
| 289 reinstallButton.addClickHandler(new ClickHandler() { | 290 reinstallButton.addClickHandler(new ClickHandler() { |
| 290 public void onClick(ClickEvent event) { | 291 public void onClick(ClickEvent event) { |
| 291 JSONArray array = new JSONArray(); | 292 JSONArray array = new JSONArray(); |
| 292 array.set(0, new JSONString(hostname)); | 293 array.set(0, new JSONString(hostname)); |
| 293 AfeUtils.scheduleReinstall(array, hostname, jobCreateListener); | 294 AfeUtils.scheduleReinstall(array, hostname, jobCreateListener); |
| 294 } | 295 } |
| 295 }); | 296 }); |
| 296 addWidget(reinstallButton, "view_host_reinstall_button"); | 297 addWidget(reinstallButton, "view_host_reinstall_button"); |
| 297 } | 298 } |
| 298 | 299 |
| 299 public void onError(JSONObject errorObject) { | 300 public void onError(JSONObject errorObject) { |
| 300 // RPC handler will display error | 301 // RPC handler will display error |
| 301 } | 302 } |
| 302 | 303 |
| 303 public ContextMenu getActionMenu() { | 304 public ContextMenu getActionMenu() { |
| 304 ContextMenu menu = new ContextMenu(); | 305 ContextMenu menu = new ContextMenu(); |
| 305 menu.addItem("Abort job entries", new Command() { | 306 menu.addItem("Abort job entries", new Command() { |
| 306 public void execute() { | 307 public void execute() { |
| 307 abortSelectedQueueEntries(); | 308 abortSelectedQueueEntries(); |
| 308 } | 309 } |
| 309 }); | 310 }); |
| 310 return menu; | 311 return menu; |
| 311 } | 312 } |
| 312 | 313 |
| 313 private void abortSelectedQueueEntries() { | 314 private void abortSelectedQueueEntries() { |
| 314 AfeUtils.abortHostQueueEntries(selectionManager.getSelectedObjects(), ne
w SimpleCallback() { | 315 AfeUtils.abortHostQueueEntries(selectionManager.getSelectedObjects(), ne
w SimpleCallback() { |
| 315 public void doCallback(Object source) { | 316 public void doCallback(Object source) { |
| 316 refresh(); | 317 refresh(); |
| 317 } | 318 } |
| 318 }); | 319 }); |
| 319 } | 320 } |
| 320 | 321 |
| 321 private void updateLockButton() { | 322 private void updateLockButton() { |
| 322 boolean locked = currentHostObject.get("locked").isBoolean().booleanValu
e(); | 323 boolean locked = currentHostObject.get("locked").isBoolean().booleanValu
e(); |
| 323 if (locked) { | 324 if (locked) { |
| 324 lockButton.setText("Unlock"); | 325 lockButton.setText("Unlock"); |
| 325 } else { | 326 } else { |
| 326 lockButton.setText("Lock"); | 327 lockButton.setText("Lock"); |
| 327 } | 328 } |
| 328 } | 329 } |
| 329 | 330 |
| 330 private void changeLock(final boolean lock) { | 331 private void changeLock(final boolean lock) { |
| 331 JSONArray hostIds = new JSONArray(); | 332 JSONArray hostIds = new JSONArray(); |
| 332 hostIds.set(0, currentHostObject.get("id")); | 333 hostIds.set(0, currentHostObject.get("id")); |
| 333 | 334 |
| 334 AfeUtils.changeHostLocks(hostIds, lock, "Host " + hostname, new SimpleCa
llback() { | 335 AfeUtils.changeHostLocks(hostIds, lock, "Host " + hostname, new SimpleCa
llback() { |
| 335 public void doCallback(Object source) { | 336 public void doCallback(Object source) { |
| 336 refresh(); | 337 refresh(); |
| 337 } | 338 } |
| 338 }); | 339 }); |
| 339 } | 340 } |
| 340 | 341 |
| 341 private boolean isJobRow(JSONObject row) { | 342 private boolean isJobRow(JSONObject row) { |
| 342 String type = Utils.jsonToString(row.get("type")); | 343 String type = Utils.jsonToString(row.get("type")); |
| 343 return type.equals("Job"); | 344 return type.equals("Job"); |
| 344 } | 345 } |
| 345 | 346 |
| 346 public boolean isRowSelectable(JSONObject row) { | 347 public boolean isRowSelectable(JSONObject row) { |
| 347 return isJobRow(row); | 348 return isJobRow(row); |
| 348 } | 349 } |
| 349 } | 350 } |
| OLD | NEW |