List of usage examples for com.google.gwt.user.client.ui CheckBox addValueChangeHandler
@Override
public HandlerRegistration addValueChangeHandler(ValueChangeHandler<Boolean> handler)
From source file:es.upm.fi.dia.oeg.map4rdf.client.widget.FacetWidget.java
License:Open Source License
public void addFacetSelectionOption(final String id, String label) { CheckBox checkBox = new CheckBox(label); checkBox.addValueChangeHandler(new ValueChangeHandler<Boolean>() { @Override//from w w w.j av a2s. c o m public void onValueChange(ValueChangeEvent<Boolean> event) { fireSelectionChanged(id, event.getValue()); } }); if (stylesheet != null) { checkBox.addStyleName(stylesheet.facetSelectionOption()); } selectionOptions.put(id, checkBox); selectionsPanel.add(checkBox); }
From source file:eu.cloud4soa.frontend.widget.search.client.views.gxt.CustomizeFacetsPanel.java
License:Open Source License
private void addFacetCheckbox(VBoxLayoutData vboxData, ValueChangeHandler<Boolean> facetHandler, Facet facet, boolean show) { CheckBox cb = new CheckBox(facet.getLabel()); cb.addValueChangeHandler(facetHandler); add(cb, vboxData);// w w w. j a va 2 s .c o m cb.setValue(show); cbFacets.put(facet, cb); }
From source file:eu.riscoss.client.entities.EntityPropertyPage.java
License:Apache License
private void loadContextualInfoData() { tb = new FlexTable(); userForm = new ContextualInfoTable(); custom = new FlexTable(); types = new ArrayList<>(); int row = 0;/*from w w w . j a va 2 s . com*/ int rowC = 0; for (int i = 0; i < info.getUserData().size(); i++) { JsonRiskDataList.RiskDataItem item = info.getUserData().get(i); if (item.getDataType().equals("CUSTOM")) { userForm.addField(item.getId(), item.getValue()); } else { String val = item.getValue(); contextualInfo = val.split(";"); String extrainfo = ""; for (int k = 1; k < contextualInfo.length; ++k) { extrainfo += ";" + contextualInfo[k]; } extraInfoList.add(extrainfo); tb.insertRow(row); tb.insertCell(row, 0); tb.insertCell(row, 1); Label id = new Label(item.getId()); id.setStyleName("bold"); tb.setWidget(row, 0, id); if (item.getDataType().equals("Integer")) { TextBox t = new TextBox(); t.setText(contextualInfo[0]); t.addValueChangeHandler(new ValueChangeHandler<String>() { @Override public void onValueChange(ValueChangeEvent<String> event) { changedData = true; } }); tb.setWidget(row, 1, t); types.add("Integer"); } else if (item.getDataType().equals("Boolean")) { CheckBox c = new CheckBox(); if (Integer.parseInt(contextualInfo[0]) == 1) c.setChecked(true); c.addValueChangeHandler(new ValueChangeHandler<Boolean>() { @Override public void onValueChange(ValueChangeEvent<Boolean> event) { changedData = true; } }); tb.setWidget(row, 1, c); types.add("Boolean"); } else if (item.getDataType().equals("Date")) { DateTimeFormat dateFormat = DateTimeFormat.getLongDateFormat(); DateBox dateBox = new DateBox(); dateBox.setFormat(new DateBox.DefaultFormat(dateFormat)); dateBox.getDatePicker().setYearArrowsVisible(true); dateBox.addValueChangeHandler(new ValueChangeHandler<Date>() { @Override public void onValueChange(ValueChangeEvent<Date> event) { changedData = true; } }); Grid g = new Grid(1, 7); g.setWidget(0, 0, dateBox); String inf[] = contextualInfo[0].split(":"); TextBox t = new TextBox(); TextBox t2 = new TextBox(); TextBox t3 = new TextBox(); if (inf.length > 1) { String date[] = inf[0].split("-"); String time[] = inf[1].split("-"); int year = Integer.parseInt(date[0]) - 1900; int month = Integer.parseInt(date[1]) - 1; if (month == 0) { month = 12; --year; } int day = Integer.parseInt(date[2]); Date d = new Date(year, month, day); dateBox.setValue(d); t.setText(String.valueOf(time[0])); t2.setText(String.valueOf(time[1])); t3.setText(String.valueOf(time[2])); } t.setWidth("30px"); t.addValueChangeHandler(new ValueChangeHandler<String>() { @Override public void onValueChange(ValueChangeEvent<String> event) { changedData = true; } }); g.setWidget(0, 1, t); g.setWidget(0, 2, new Label("hh")); t2.setWidth("30px"); t2.addValueChangeHandler(new ValueChangeHandler<String>() { @Override public void onValueChange(ValueChangeEvent<String> event) { changedData = true; } }); g.setWidget(0, 3, t2); g.setWidget(0, 4, new Label("mm")); t3.setWidth("30px"); t3.addValueChangeHandler(new ValueChangeHandler<String>() { @Override public void onValueChange(ValueChangeEvent<String> event) { changedData = true; } }); g.setWidget(0, 5, t3); g.setWidget(0, 6, new Label("ss")); tb.setWidget(row, 1, g); types.add("Date"); } else if (item.getDataType().equals("List")) { ListBox lb = new ListBox(); for (int k = 1; k < contextualInfo.length; ++k) { lb.addItem(contextualInfo[k]); } lb.setSelectedIndex(Integer.parseInt(contextualInfo[0])); lb.addChangeHandler(new ChangeHandler() { @Override public void onChange(ChangeEvent event) { changedData = true; } }); tb.setWidget(row, 1, lb); types.add("List"); } else if (item.getDataType().equals("Text")) { TextBox t = new TextBox(); t.setText(contextualInfo[0]); t.addValueChangeHandler(new ValueChangeHandler<String>() { @Override public void onValueChange(ValueChangeEvent<String> event) { changedData = true; } }); tb.setWidget(row, 1, t); types.add("Text"); } ++row; } } HorizontalPanel newCIElement = new HorizontalPanel(); newCIElement.setStyleName("layerData"); Label newIDL = new Label("ID"); newIDL.setStyleName("bold"); newID = new TextBox(); Label newValueL = new Label("Value"); newValueL.setStyleName("bold"); newValue = new TextBox(); newCIElement.add(newIDL); newCIElement.add(newID); newCIElement.add(newValueL); newCIElement.add(newValue); Button newCustomInfo = new Button("New custom information"); newCustomInfo.setStyleName("button"); newCustomInfo.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { boolean b = userForm.newField(newID.getText(), newValue.getText()); if (b) { newID.setText(""); newValue.setText(""); } } }); VerticalPanel vPanel = new VerticalPanel(); vPanel.add(newCIElement); vPanel.add(newCustomInfo); vPanel.add(userForm.getWidget()); summaryPanel.setWidget(propertiesPanel); dataCollectors.setWidget(confDialog.getDock()); ciPanel.setWidget(vPanel); }
From source file:gov.nist.spectrumbrowser.admin.AccountManagement.java
License:Open Source License
@Override public void draw() { verticalPanel.clear();//from w ww. j a v a2s . c o m HTML html = new HTML("<h3>User Accounts</h3>"); int rows = userAccounts.size(); verticalPanel.add(html); HTML helpText = new HTML("<p>Add button to add new accounts.</p> " + "<p>Admin accounts are always authenticated. For User account, ensure authentication is enbled on System Config page.</p>"); grid = new Grid(rows + 1, 11); grid.setText(0, 0, "Email Adddress"); grid.setText(0, 1, "First Name"); grid.setText(0, 2, "Last Name"); grid.setText(0, 3, "Admin Privilege"); grid.setText(0, 4, "Failed Login Attempts"); grid.setText(0, 5, "Account Locked?"); grid.setText(0, 6, "Unlock Account"); grid.setText(0, 7, "Password Expiry Date"); grid.setText(0, 8, "Reset Expiration"); grid.setText(0, 9, "Creation Date"); grid.setText(0, 10, "Delete Account"); // TODO: add session information like currently logged in, time logged in, time session expires // & ability to delete a session object grid.setBorderWidth(2); grid.setCellPadding(2); for (int i = 1; i < rows + 1; i++) { JSONObject account = userAccounts.get(i - 1).isObject(); grid.setText(i, 0, account.get(Defines.ACCOUNT_EMAIL_ADDRESS).isString().stringValue()); grid.setText(i, 1, account.get(Defines.ACCOUNT_FIRST_NAME).isString().stringValue()); grid.setText(i, 2, account.get(Defines.ACCOUNT_LAST_NAME).isString().stringValue()); String priv = account.get(Defines.ACCOUNT_PRIVILEGE).isString().stringValue(); CheckBox togglePrivilege = new CheckBox(); togglePrivilege.setValue(priv.equals("admin")); togglePrivilege.addValueChangeHandler(new TogglePrivilegeValueChangeHandler( account.get(Defines.ACCOUNT_EMAIL_ADDRESS).isString().stringValue())); grid.setWidget(i, 3, togglePrivilege); grid.setText(i, 4, Integer .toString((int) account.get(Defines.ACCOUNT_NUM_FAILED_LOGINS).isNumber().doubleValue())); grid.setText(i, 5, Boolean.toString(account.get(Defines.ACCOUNT_LOCKED).isBoolean().booleanValue())); Button unlock = new Button("Unlock"); unlock.addClickHandler( new UnlockClickHandler(account.get(Defines.ACCOUNT_EMAIL_ADDRESS).isString().stringValue())); grid.setWidget(i, 6, unlock); //JEK: note: the 'datePasswordExpires' and 'dateAccountCreated' are not in accounts database since we store time in seconds. // These date fields are just for display here so we do not need to define constants for JSON strings. grid.setText(i, 7, account.get("datePasswordExpires").isString().stringValue()); Button reset = new Button("Reset Expiration"); reset.addClickHandler(new ResetExpirationClickHandler( account.get(Defines.ACCOUNT_EMAIL_ADDRESS).isString().stringValue())); grid.setWidget(i, 8, reset); grid.setText(i, 9, account.get("dateAccountCreated").isString().stringValue()); Button delete = new Button("Delete"); delete.addClickHandler( new DeleteClickHandler(account.get(Defines.ACCOUNT_EMAIL_ADDRESS).isString().stringValue())); grid.setWidget(i, 10, delete); } for (int i = 0; i < grid.getColumnCount(); i++) { grid.getCellFormatter().setStyleName(0, i, "textLabelStyle"); } for (int i = 0; i < grid.getRowCount(); i++) { for (int j = 0; j < grid.getColumnCount(); j++) { grid.getCellFormatter().setHorizontalAlignment(i, j, HasHorizontalAlignment.ALIGN_CENTER); grid.getCellFormatter().setVerticalAlignment(i, j, HasVerticalAlignment.ALIGN_MIDDLE); } } verticalPanel.add(grid); HorizontalPanel buttonPanel = new HorizontalPanel(); Button addAccountButton = new Button("Add"); addAccountButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { //JEK: I commented out this line because we not want to go back to account management if add account failed //redraw = true; new AddAccount(admin, AccountManagement.this, verticalPanel).draw(); } }); buttonPanel.add(addAccountButton); Button refreshButton = new Button("Refresh"); refreshButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { redraw = true; Admin.getAdminService().getUserAccounts(AccountManagement.this); } }); buttonPanel.add(refreshButton); Button logoffButton = new Button("Log Off"); logoffButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { admin.logoff(); } }); buttonPanel.add(logoffButton); verticalPanel.add(buttonPanel); }
From source file:gov.nist.spectrumbrowser.admin.AddNewSensor.java
License:Open Source License
public void draw() { try {//from ww w .j a v a2 s . c o m logger.finer("AddNewSensor: draw()"); HTML html = new HTML("<h2>Add New Sensor</h2>"); verticalPanel.clear(); verticalPanel.add(html); Grid grid = new Grid(7, 2); grid.setCellPadding(2); grid.setCellSpacing(2); grid.setBorderWidth(2); int row = 0; grid.setText(row, 0, "Sensor ID"); final TextBox sensorIdTextBox = new TextBox(); sensorIdTextBox.setText(sensor.getSensorId()); sensorIdTextBox.addValueChangeHandler(new ValueChangeHandler<String>() { @Override public void onValueChange(ValueChangeEvent<String> event) { String sensorId = event.getValue(); if (sensorId == null || sensorId.equals("") || sensorId.equals("UNKNOWN")) { Window.alert("Please enter a valid sensor ID"); return; } ArrayList<Sensor> sensors = sensorConfig.getSensors(); for (Sensor sensor : sensors) { if (sensorId.equals(sensor.getSensorId())) { Window.alert("Please enter a unique sensor ID"); return; } } sensor.setSensorId(sensorId); } }); grid.setWidget(row, 1, sensorIdTextBox); row++; grid.setText(row, 0, "Sensor Key"); final TextBox sensorKeyTextBox = new TextBox(); sensorKeyTextBox.addValueChangeHandler(new ValueChangeHandler<String>() { @Override public void onValueChange(ValueChangeEvent<String> event) { String key = event.getValue(); if (key == null || (passwordCheckingEnabled && !key.matches("((?=.*[0-9])(?=.*[a-z])(?=.*[A-Z])(?=.*[!@#$%^&+=])).{12,}$"))) { Window.alert("Please enter a key : " + "\n1) at least 12 characters, " + "\n2) a digit, " + "\n3) an upper case letter, " + "\n4) a lower case letter, and " + "\n5) a special character(!@#$%^&+=)."); return; } sensor.setSensorKey(key); } }); sensorKeyTextBox.setText(sensor.getSensorKey()); grid.setWidget(row, 1, sensorKeyTextBox); row++; grid.setText(row, 0, "Measurement Type"); final TextBox measurementTypeTextBox = new TextBox(); measurementTypeTextBox.setTitle("Enter Swept-frequency or FFT-Power"); measurementTypeTextBox.addValueChangeHandler(new ValueChangeHandler<String>() { @Override public void onValueChange(ValueChangeEvent<String> event) { String mtype = event.getValue(); if (mtype.equals(Defines.FFT_POWER) || mtype.equals(Defines.SWEPT_FREQUENCY)) { sensor.setMeasurementType(mtype); } else { Window.alert("Please enter FFT-Power or Swept-frequency (Case sensitive)"); } } }); grid.setWidget(row, 1, measurementTypeTextBox); row++; grid.setText(row, 0, "Is Streaming Enabled?"); final CheckBox streamingEnabled = new CheckBox(); streamingEnabled.setValue(false); streamingEnabled.addValueChangeHandler(new ValueChangeHandler<Boolean>() { @Override public void onValueChange(ValueChangeEvent<Boolean> event) { boolean value = event.getValue(); sensor.setStreamingEnabled(value); } }); grid.setWidget(row, 1, streamingEnabled); row++; grid.setText(row, 0, "Data Retention(months)"); final TextBox dataRetentionTextBox = new TextBox(); dataRetentionTextBox.setText(Integer.toString(sensor.getDataRetentionDurationMonths())); dataRetentionTextBox.addValueChangeHandler(new ValueChangeHandler<String>() { @Override public void onValueChange(ValueChangeEvent<String> event) { try { String valueStr = event.getValue(); if (valueStr == null) { Window.alert("Please enter integer >= 0"); return; } int value = Integer.parseInt(valueStr); if (value < 0) { Window.alert("Please enter integer >= 0"); return; } sensor.setDataRetentionDurationMonths(value); } catch (NumberFormatException ex) { Window.alert("Please enter positive integer"); return; } } }); grid.setWidget(row, 1, dataRetentionTextBox); row++; grid.setText(row, 0, "Sensor Admin Email"); final TextBox sensorAdminEmailTextBox = new TextBox(); sensorAdminEmailTextBox.setText(sensor.getSensorAdminEmail()); sensorAdminEmailTextBox.addValueChangeHandler(new ValueChangeHandler<String>() { @Override public void onValueChange(ValueChangeEvent<String> event) { String email = event.getValue(); if (!email.matches( "^[_A-Za-z0-9-]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\\.[A-Za-z0-9-]+)*(\\.[A-Za-z]{2,})$")) { Window.alert("Please enter valid email address"); return; } sensor.setSensorAdminEmail(email); } }); grid.setWidget(row, 1, sensorAdminEmailTextBox); row++; grid.setText(row, 0, "Sensor Command Line Startup Params"); final TextBox startupParamsTextBox = new TextBox(); startupParamsTextBox.setWidth("200px"); startupParamsTextBox.setText(sensor.getStartupParams()); startupParamsTextBox.addValueChangeHandler(new ValueChangeHandler<String>() { @Override public void onValueChange(ValueChangeEvent<String> event) { sensor.setStartupParams(event.getValue()); } }); Button submitButton = new Button("Apply"); submitButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { if (!sensor.validate()) { Window.alert("Error in entry - please enter all fields."); } else { logger.log(Level.FINER, "Adding Sensor " + sensor.getSensorId()); sensorConfig.setUpdateFlag(true); Admin.getAdminService().addSensor(sensor.toString(), sensorConfig); } } }); grid.setWidget(row, 1, startupParamsTextBox); verticalPanel.add(grid); HorizontalPanel hpanel = new HorizontalPanel(); hpanel.add(submitButton); Button cancelButton = new Button("Cancel"); cancelButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { sensorConfig.redraw(); } }); hpanel.add(cancelButton); Button logoffButton = new Button("Log Off"); logoffButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { admin.logoff(); } }); hpanel.add(logoffButton); verticalPanel.add(hpanel); } catch (Throwable th) { logger.log(Level.SEVERE, "Problem drawing screen", th); } }
From source file:gov.nist.spectrumbrowser.admin.DebugConfiguration.java
License:Open Source License
@Override public void draw() { verticalPanel.clear();//from www . j a v a2s . c om HTML title = new HTML("<h3>Debug flags</h3>"); HTML helpText = new HTML("<p>Note: Debug flags return to default values on server restart.</p>"); verticalPanel.add(title); verticalPanel.add(helpText); grid = new Grid(jsonObject.keySet().size() + 1, 2); grid.setBorderWidth(2); grid.setCellPadding(2); grid.setCellPadding(2); grid.setText(0, 0, "Name"); grid.setText(0, 1, "Value"); int i = 1; for (final String key : jsonObject.keySet()) { grid.setWidget(i, 0, new Label(key)); final CheckBox checkBox = new CheckBox(); boolean value = jsonObject.get(key).isBoolean().booleanValue(); checkBox.setValue(value); checkBox.addValueChangeHandler(new ValueChangeHandler<Boolean>() { @Override public void onValueChange(ValueChangeEvent<Boolean> event) { boolean value = event.getValue(); jsonObject.put(key, JSONBoolean.getInstance(value)); Admin.getAdminService().setDebugFlags(jsonObject.toString(), new SpectrumBrowserCallback<String>() { @Override public void onSuccess(String result) { try { JSONObject retval = JSONParser.parseLenient(result).isObject(); String status = retval.get("status").isString().stringValue(); if (!status.equals("OK")) { Window.alert("Unexpected response code"); admin.logoff(); } } catch (Throwable th) { Window.alert("error parsing response"); logger.log(Level.SEVERE, "Error parsing response", th); admin.logoff(); } } @Override public void onFailure(Throwable throwable) { Window.alert("error communicating with server"); logger.log(Level.SEVERE, "Error communicating with server", throwable); admin.logoff(); } }); } }); grid.setWidget(i, 1, checkBox); i++; } for (i = 0; i < grid.getColumnCount(); i++) { grid.getCellFormatter().setStyleName(0, i, "textLabelStyle"); } for (i = 0; i < grid.getRowCount(); i++) { for (int j = 0; j < grid.getColumnCount(); j++) { grid.getCellFormatter().setHorizontalAlignment(i, j, HasHorizontalAlignment.ALIGN_CENTER); grid.getCellFormatter().setVerticalAlignment(i, j, HasVerticalAlignment.ALIGN_MIDDLE); } } verticalPanel.add(grid); final HorizontalPanel urlPanel = new HorizontalPanel(); urlPanel.add(new Label("Click on logs button to fetch server logs")); Button getDebugLog = new Button("Logs"); getDebugLog.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { Admin.getAdminService().getLogs(new SpectrumBrowserCallback<String>() { @Override public void onSuccess(String result) { try { JSONObject debugLogs = JSONParser.parseLenient(result).isObject(); String url = debugLogs.get("url").isString().stringValue(); urlPanel.clear(); Label label = new Label(url); urlPanel.add(label); } catch (Throwable throwable) { logger.log(Level.SEVERE, "Error Parsing response ", throwable); admin.logoff(); } } @Override public void onFailure(Throwable throwable) { logger.log(Level.SEVERE, "Error contacting server ", throwable); Window.alert("Error Parsing response"); admin.logoff(); } }); } }); verticalPanel.add(urlPanel); Button logoff = new Button("Log off"); logoff.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { admin.logoff(); } }); Button getTestCases = new Button("Get Test Cases"); getTestCases.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { Window.alert("Not yet implemented"); } }); Button clearLogs = new Button("Clear logs"); clearLogs.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { Window.alert("Not yet implemented"); /*boolean yesno = Window.confirm("This will restart services after clearing logs and log you off. Proceed?"); if (yesno) { Admin.getAdminService().clearLogs(new SpectrumBrowserCallback<String>() { @Override public void onSuccess(String result) { } @Override public void onFailure(Throwable throwable) { Window.alert("Error in processing request"); }} ); admin.logoff(); }*/ } }); HorizontalPanel buttonPanel = new HorizontalPanel(); buttonPanel.add(getDebugLog); buttonPanel.add(getTestCases); buttonPanel.add(clearLogs); buttonPanel.add(logoff); verticalPanel.add(buttonPanel); }
From source file:gov.nist.spectrumbrowser.admin.FftPowerSensorBands.java
License:Open Source License
public void draw() { verticalPanel.clear();/*from w ww . ja va2 s . c om*/ HTML html = new HTML("<H2>Bands for sensor : " + sensor.getSensorId() + "</H2>"); verticalPanel.add(html); JSONObject sensorThresholds = sensor.getThresholds(); Grid grid = new Grid(sensorThresholds.keySet().size() + 1, 10); grid.setBorderWidth(2); grid.setCellPadding(2); grid.setCellSpacing(2); grid.setText(0, 0, "System To Detect"); grid.setText(0, 1, "Min Freq (Hz)"); grid.setText(0, 2, "Max Freq (Hz)"); grid.setText(0, 3, "Channel Count"); grid.setText(0, 4, "Sampling Rate"); grid.setText(0, 5, "FFT-Size"); grid.setText(0, 6, "Occupancy Threshold (dBm/Hz)"); grid.setText(0, 7, "Occupancy Threshold (dBm)"); grid.setText(0, 8, "Enabled?"); grid.setText(0, 9, "Delete Band"); grid.setBorderWidth(2); grid.setCellPadding(2); grid.setCellSpacing(2); CellFormatter formatter = grid.getCellFormatter(); for (int i = 0; i < grid.getRowCount(); i++) { for (int j = 0; j < grid.getColumnCount(); j++) { formatter.setHorizontalAlignment(i, j, HasHorizontalAlignment.ALIGN_CENTER); formatter.setVerticalAlignment(i, j, HasVerticalAlignment.ALIGN_MIDDLE); } } for (int i = 0; i < grid.getColumnCount(); i++) { grid.getCellFormatter().setStyleName(0, i, "textLabelStyle"); } int row = 1; for (String key : sensorThresholds.keySet()) { final FftPowerBand threshold = new FftPowerBand(sensorThresholds.get(key).isObject()); grid.setText(row, 0, threshold.getSystemToDetect()); grid.setText(row, 1, Long.toString(threshold.getMinFreqHz())); grid.setText(row, 2, Long.toString(threshold.getMaxFreqHz())); final TextBox channelCountTextBox = new TextBox(); channelCountTextBox.setText(Long.toString(threshold.getChannelCount())); channelCountTextBox.addValueChangeHandler(new ValueChangeHandler<String>() { @Override public void onValueChange(ValueChangeEvent<String> event) { Long oldValue = Long.parseLong(channelCountTextBox.getValue()); try { long newValue = Long.parseLong(event.getValue()); threshold.setChannelCount((long) newValue); } catch (Exception ex) { Window.alert(ex.getMessage()); channelCountTextBox.setValue(Double.toString(oldValue)); } } }); grid.setWidget(row, 3, channelCountTextBox); final TextBox samplingRateTextBox = new TextBox(); samplingRateTextBox.setText(Long.toString(threshold.getSamplingRate())); samplingRateTextBox.addValueChangeHandler(new ValueChangeHandler<String>() { @Override public void onValueChange(ValueChangeEvent<String> event) { Long oldValue = Long.parseLong(samplingRateTextBox.getValue()); try { long newValue = Long.parseLong(event.getValue()); threshold.setSamplingRate((long) newValue); } catch (Exception ex) { Window.alert(ex.getMessage()); samplingRateTextBox.setValue(Double.toString(oldValue)); } } }); grid.setWidget(row, 4, samplingRateTextBox); final TextBox fftSizeTextBox = new TextBox(); fftSizeTextBox.setText(Long.toString(threshold.getFftSize())); fftSizeTextBox.addValueChangeHandler(new ValueChangeHandler<String>() { @Override public void onValueChange(ValueChangeEvent<String> event) { Long oldValue = Long.parseLong(fftSizeTextBox.getValue()); try { long newValue = Long.parseLong(event.getValue()); threshold.setFftSize((long) newValue); } catch (Exception ex) { Window.alert(ex.getMessage()); fftSizeTextBox.setValue(Double.toString(oldValue)); } } }); grid.setWidget(row, 5, fftSizeTextBox); final Label thresholdDbmLabel = new Label(); final TextBox thresholdTextBox = new TextBox(); thresholdTextBox.setText(Double.toString(threshold.getThresholdDbmPerHz())); thresholdTextBox.addValueChangeHandler(new ValueChangeHandler<String>() { @Override public void onValueChange(ValueChangeEvent<String> event) { Double oldThreshold = Double.parseDouble(thresholdTextBox.getValue()); try { double newThreshold = Double.parseDouble(event.getValue()); threshold.setThresholdDbmPerHz(newThreshold); thresholdDbmLabel.setText(Float.toString(threshold.getThresholdDbm())); } catch (Exception ex) { Window.alert(ex.getMessage()); thresholdTextBox.setValue(Double.toString(oldThreshold)); } } }); grid.setWidget(row, 6, thresholdTextBox); thresholdDbmLabel.setText(Float.toString(threshold.getThresholdDbm())); grid.setWidget(row, 7, thresholdDbmLabel); CheckBox activeCheckBox = new CheckBox(); grid.setWidget(row, 8, activeCheckBox); if (!sensor.isStreamingEnabled()) { activeCheckBox.setValue(true); activeCheckBox.setEnabled(false); } else { activeCheckBox.setValue(threshold.isActive()); } activeCheckBox.addValueChangeHandler(new ValueChangeHandler<Boolean>() { @Override public void onValueChange(ValueChangeEvent<Boolean> event) { if (sensor.isStreamingEnabled()) { if (event.getValue()) { for (String key : sensor.getThresholds().keySet()) { FftPowerBand th = new FftPowerBand(sensor.getThreshold(key)); th.setActive(false); } } threshold.setActive(event.getValue()); draw(); } } }); Button deleteButton = new Button("Delete Band"); deleteButton.addClickHandler(new DeleteThresholdClickHandler(threshold)); grid.setWidget(row, 9, deleteButton); row++; } verticalPanel.add(grid); HorizontalPanel horizontalPanel = new HorizontalPanel(); Button addButton = new Button("Add Band"); addButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { new AddFftPowerSensorBand(admin, FftPowerSensorBands.this, sensorConfig, sensor, verticalPanel) .draw(); } }); horizontalPanel.add(addButton); Button doneButton = new Button("Done"); doneButton.setTitle("Return to Sensors screen"); doneButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { sensorConfig.redraw(); } }); horizontalPanel.add(doneButton); Button updateButton = new Button("Update"); updateButton.setTitle("Update sensor on the server"); updateButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { Admin.getAdminService().updateSensor(sensor.toString(), sensorConfig); } }); horizontalPanel.add(updateButton); Button logoffButton = new Button("Log Off"); logoffButton.setTitle("Log off from admin"); logoffButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { admin.logoff(); } }); Button recomputeButton = new Button("Recompute Occupancies"); recomputeButton.setTitle("Recomputes per message summary occupancies."); recomputeButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { boolean yes = Window.confirm( "Ensure no users are using the system. This can take a long time. Sensor will be disabled. Proceed?"); if (yes) { final HTML html = new HTML( "<h3>Recomputing occupancies - this can take a while. Sensor will be disabled. Please wait. </h3>"); verticalPanel.add(html); Admin.getAdminService().updateSensor(sensor.toString(), sensorConfig); Admin.getAdminService().recomputeOccupancies(sensor.getSensorId(), new SpectrumBrowserCallback<String>() { @Override public void onSuccess(String result) { verticalPanel.remove(html); } @Override public void onFailure(Throwable throwable) { Window.alert("Error communicating with server"); admin.logoff(); } }); } } }); horizontalPanel.add(recomputeButton); horizontalPanel.add(logoffButton); verticalPanel.add(horizontalPanel); }
From source file:gov.nist.spectrumbrowser.admin.SensorConfig.java
License:Open Source License
@Override public void draw() { verticalPanel.clear();/*from w ww . j ava 2 s .c o m*/ HTML title = new HTML("<h3>Configured sensors. </h3>"); titlePanel = new HorizontalPanel(); titlePanel.add(title); HTML subtitle = new HTML("<p>Select Add button to add a new sensor. " + "Buttons on each sensor row allow you to reconfigure the sensor.</p>"); verticalPanel.add(titlePanel); verticalPanel.add(subtitle); ; grid = new Grid(sensors.size() + 1, 13); for (int i = 0; i < grid.getColumnCount(); i++) { grid.getCellFormatter().setStyleName(0, i, "textLabelStyle"); } for (int i = 0; i < grid.getRowCount(); i++) { for (int j = 0; j < grid.getColumnCount(); j++) { grid.getCellFormatter().setHorizontalAlignment(i, j, HasHorizontalAlignment.ALIGN_CENTER); grid.getCellFormatter().setVerticalAlignment(i, j, HasVerticalAlignment.ALIGN_MIDDLE); } } grid.setCellPadding(2); grid.setCellSpacing(2); grid.setBorderWidth(2); int col = 0; // Column headings. grid.setText(0, col++, "Sensor Identity"); //1 grid.setText(0, col++, "Storage Management");//2 grid.setText(0, col++, "Frequency Bands");//3 grid.setText(0, col++, "Show Activity");//4 grid.setText(0, col++, "Enabled?");//5 grid.setText(0, col++, "Get System Messages");//6 grid.setText(0, col++, "Measurement Params");//7 grid.setText(0, col++, "Startup Params");//8 grid.setText(0, col++, "Duplicate Settings");//9 grid.setText(0, col++, "Purge Data");//10 grid.setText(0, col++, "Remove Sensor");//11 grid.setText(0, col++, "Configuration Status"); //12 grid.setText(0, col++, "Run Status"); //13 int row = 1; for (final Sensor sensor : sensors) { col = 0; Button sensorIdentityButton = new Button(sensor.getSensorId()); sensorIdentityButton.setWidth("100%"); grid.setWidget(row, col++, sensorIdentityButton); sensorIdentityButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { new SensorIdentity(admin, SensorConfig.this, sensor, verticalPanel).draw(); } }); final Button manageStorage = new Button("Manage Storage"); manageStorage.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { if (sensor.getSensorStatus().equals("ENABLED")) { Window.alert("Please disable sensor first (click on check box)."); } else { new ManageStorage(admin, verticalPanel, sensors, sensor, SensorConfig.this).draw(); } } }); grid.setWidget(row, col++, manageStorage); int thresholdCount = sensor.getThresholds().keySet().size(); Button thresholdButton; if (thresholdCount == 0) thresholdButton = new Button("Add"); else thresholdButton = new Button("Change/Add"); thresholdButton.setTitle("Define Band Occupancy Threshold."); if (thresholdCount == 0) { thresholdButton.setStyleName("dangerous"); } thresholdButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { if (sensor.getMeasurementType().equals(Defines.SWEPT_FREQUENCY)) { new SweptFrequencySensorBands(admin, SensorConfig.this, sensor, verticalPanel).draw(); } else { new FftPowerSensorBands(admin, SensorConfig.this, sensor, verticalPanel).draw(); } } }); grid.setWidget(row, col++, thresholdButton); Button getMessageDates = new Button("Show"); getMessageDates.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { new ShowMessageDates(admin, SensorConfig.this, sensor, verticalPanel).draw(); } }); grid.setWidget(row, col++, getMessageDates); CheckBox statusCheckBox = new CheckBox(); statusCheckBox.setValue(sensor.getSensorStatus().equals("ENABLED")); statusCheckBox.addValueChangeHandler(new ValueChangeHandler<Boolean>() { @Override public void onValueChange(ValueChangeEvent<Boolean> event) { SensorConfig.this.updateFlag = true; Admin.getAdminService().toggleSensorStatus(sensor.getSensorId(), SensorConfig.this); } }); grid.setWidget(row, col++, statusCheckBox); Button downloadSysMessages = new Button("Get"); grid.setWidget(row, col++, downloadSysMessages); downloadSysMessages.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { Admin.getAdminService().getSystemMessages(sensor.getSensorId(), new SpectrumBrowserCallback<String>() { @Override public void onSuccess(String result) { JSONObject jsonObj = JSONParser.parseLenient(result).isObject(); String status = jsonObj.get("status").isString().stringValue(); if (status.equals("OK")) { Window.alert("Please check your email in 10 minutes for notification"); } else { Window.alert(jsonObj.get("ErrorMessage").isString().stringValue()); } } @Override public void onFailure(Throwable throwable) { // TODO Auto-generated method stub } }); } }); Button streamingButton = new Button(); if (!sensor.isStreamingEnabled()) { streamingButton.setText("Measurement Params"); if (!sensor.isMeasurementConfigured()) { streamingButton.setStyleName("dangerous"); } streamingButton.setTitle("Configure sensor measurement parameters"); } else { streamingButton.setText("Streaming Params"); streamingButton.setTitle("Streaming Params"); if (!sensor.isStreamingConfigured()) { streamingButton.setStyleName("dangerous"); } } grid.setWidget(row, col++, streamingButton); // 9 streamingButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { if (sensor.isStreamingEnabled()) { new SetStreamingParams(admin, verticalPanel, sensor, SensorConfig.this).draw(); } else { new SetMeasurementParams(admin, verticalPanel, sensor, SensorConfig.this).draw(); } } }); TextBox startupParamsTextBox = new TextBox(); startupParamsTextBox.setWidth("120px"); grid.setWidget(row, col++, startupParamsTextBox); startupParamsTextBox.setTitle("Startup parameters (read by sensor on startup)"); startupParamsTextBox.setText(sensor.getStartupParams()); startupParamsTextBox.addValueChangeHandler(new ValueChangeHandler<String>() { @Override public void onValueChange(ValueChangeEvent<String> event) { sensor.setStartupParams(event.getValue()); Admin.getAdminService().updateSensor(sensor.toString(), SensorConfig.this); } }); Button dupButton = new Button("Dup"); dupButton.setTitle("Creates a new sensor with the same settings"); dupButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { new AddNewSensor(admin, verticalPanel, sensor, SensorConfig.this).draw(); } }); grid.setWidget(row, col++, dupButton); Button purgeButton = new Button("Purge Data"); purgeButton.setTitle("WARNING: Removes Sensor and all data associated with it"); purgeButton.setStyleName("dangerous"); purgeButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { if (sensor.getSensorStatus().equals("ENABLED")) { Window.alert("Please toggle state of sensor"); return; } boolean yes = Window.confirm( "Remove the all associated data? Cannot be undone! Ensure no active sessions."); if (yes) { titlePanel.clear(); HTML html = new HTML( "<h3>Purging sensor " + sensor.getSensorId() + ". This can take a while! </h3>"); titlePanel.add(html); SensorConfig.this.updateFlag = true; Admin.getAdminService().purgeSensor(sensor.getSensorId(), SensorConfig.this); } } }); grid.setWidget(row, col++, purgeButton); Button removeButton = new Button("Remove Sensor"); removeButton.setTitle("WARNING: Removes Sensor and all data associated with it"); removeButton.setStyleName("dangerous"); removeButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { if (sensor.getSensorStatus().equals("ENABLED")) { Window.alert("Please toggle state of sensor"); return; } boolean yes = Window.confirm("Remove Sensor?"); if (yes) { titlePanel.clear(); HTML html = new HTML( "<h3>Removing " + sensor.getSensorId() + ". This can take a while! </h3>"); titlePanel.add(html); SensorConfig.this.updateFlag = true; Admin.getAdminService().deleteSensor(sensor.getSensorId(), SensorConfig.this); } } }); grid.setWidget(row, col++, removeButton); boolean isConfigured = true; if (sensor.getThresholdCount() == 0) { isConfigured = false; } else if (sensor.isStreamingEnabled()) { if (!new StreamingParams(sensor.getStreamingConfig()).verify()) { isConfigured = false; } } else if (!new MeasurementParams(sensor.getMeasurementParams()).verify()) { isConfigured = false; } grid.setText(row, col++, isConfigured ? "Configured" : "Incomplete"); grid.setText(row, col++, sensor.getSensorStatus()); row++; } verticalPanel.add(grid); HorizontalPanel buttonPanel = new HorizontalPanel(); Button addNewSensorButton = new Button("Add new sensor"); addNewSensorButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { new AddNewSensor(admin, verticalPanel, SensorConfig.this).draw(); } }); buttonPanel.add(addNewSensorButton); Button refreshButton = new Button("Refresh"); refreshButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { SensorConfig.this.redraw(); } }); buttonPanel.add(refreshButton); Button logoffButton = new Button("Log Off"); logoffButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { admin.logoff(); } }); buttonPanel.add(logoffButton); verticalPanel.add(buttonPanel); }
From source file:gov.nist.spectrumbrowser.admin.SetStreamingParams.java
License:Open Source License
public void draw() { HTML html = new HTML("<h2>Streaming and I/Q capture settings for " + sensor.getSensorId() + "</h2>"); verticalPanel.clear();/* w w w . j a va 2 s. c om*/ verticalPanel.add(html); Grid grid = new Grid(5, 2); grid.setBorderWidth(2); grid.setCellPadding(2); grid.setCellSpacing(2); int row = 0; final TextBox streamingCaptureIntervalTextBox = new TextBox(); streamingCaptureIntervalTextBox .setText(Integer.toString(sensorStreamingParams.getStreamingCaptureSamplingIntervalSeconds())); streamingCaptureIntervalTextBox.addValueChangeHandler(new ValueChangeHandler<String>() { @Override public void onValueChange(ValueChangeEvent<String> event) { try { int streamingCaptureInterval = Integer.parseInt(event.getValue()); if (!sensorStreamingParams .setStreamingCaptureSamplingIntervalSeconds(streamingCaptureInterval)) { Window.alert("Please enter a valid integer > 0"); streamingCaptureIntervalTextBox.setValue(Integer .toString(sensorStreamingParams.getStreamingCaptureSamplingIntervalSeconds())); } } catch (Exception ex) { Window.alert("Please enter a valid integer >0"); streamingCaptureIntervalTextBox.setValue( Integer.toString(sensorStreamingParams.getStreamingCaptureSamplingIntervalSeconds())); } } }); grid.setText(row, 0, "Time per spectrogram capture (s)"); grid.setWidget(row, 1, streamingCaptureIntervalTextBox); row++; final CheckBox enableStreamingCapture = new CheckBox(); enableStreamingCapture.setValue(sensorStreamingParams.getEnableStreamingCapture()); grid.setText(row, 0, "Enable spectrogram capture"); enableStreamingCapture.addValueChangeHandler(new ValueChangeHandler<Boolean>() { @Override public void onValueChange(ValueChangeEvent<Boolean> event) { boolean newValue = event.getValue(); sensorStreamingParams.setEnableStreamingCapture(newValue); } }); grid.setWidget(row, 1, enableStreamingCapture); row++; final CheckBox enableIqCapture = new CheckBox(); enableIqCapture.setValue(sensorStreamingParams.isIqCaptureEnabled()); grid.setText(row, 0, "Enable I/Q capture"); enableIqCapture.addValueChangeHandler(new ValueChangeHandler<Boolean>() { @Override public void onValueChange(ValueChangeEvent<Boolean> event) { boolean newValue = event.getValue(); sensorStreamingParams.setIqCaptureEnabled(newValue); } }); grid.setWidget(row, 1, enableIqCapture); row++; final TextBox streamingSecondsPerFrameTextBox = new TextBox(); streamingSecondsPerFrameTextBox .setText(Float.toString(sensorStreamingParams.getStreamingSecondsPerFrame())); streamingSecondsPerFrameTextBox.addValueChangeHandler(new ValueChangeHandler<String>() { @Override public void onValueChange(ValueChangeEvent<String> event) { try { float streamingSecondsPerFrame = Float.parseFloat(event.getValue()); if (!sensorStreamingParams.setStreamingSecondsPerFrame(streamingSecondsPerFrame)) { Window.alert("Please set a float > 0"); streamingSecondsPerFrameTextBox .setText(Float.toString(sensorStreamingParams.getStreamingSecondsPerFrame())); } } catch (Exception ex) { Window.alert(ex.getMessage()); streamingSecondsPerFrameTextBox .setText(Float.toString(sensorStreamingParams.getStreamingSecondsPerFrame())); } } }); grid.setText(row, 0, "Time between readings (aggregation window) (s)"); grid.setWidget(row, 1, streamingSecondsPerFrameTextBox); streamingSecondsPerFrameTextBox.setTitle("Time between readings sent from the sensor"); row++; final TextBox streamingFilterTextBox = new TextBox(); streamingFilterTextBox.setText(sensorStreamingParams.getStreamingFilter()); streamingFilterTextBox.addValueChangeHandler(new ValueChangeHandler<String>() { @Override public void onValueChange(ValueChangeEvent<String> event) { String newFilter = event.getValue(); if (!sensorStreamingParams.setStreamingFilter(newFilter)) { Window.alert("Please specify MAX_HOLD or MEAN"); streamingFilterTextBox.setText(sensorStreamingParams.getStreamingFilter()); } } }); grid.setText(row, 0, "Aggregation Filter (MAX_HOLD or MEAN)"); grid.setWidget(row, 1, streamingFilterTextBox); verticalPanel.add(grid); HorizontalPanel hpanel = new HorizontalPanel(); Button applyButton = new Button("Apply"); applyButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { if (!sensorStreamingParams.verify()) { Window.alert( "Please specify all fields correctly. Capture interval must be > sampling interval."); return; } else { sensor.setStreamingEnabled(true); sensorConfig.setUpdateFlag(true); Admin.getAdminService().updateSensor(sensor.toString(), sensorConfig); } } }); hpanel.add(applyButton); for (int i = 0; i < grid.getRowCount(); i++) { grid.getCellFormatter().setStyleName(i, 0, "textLabelStyle"); } Button cancelButton = new Button("Cancel"); cancelButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { sensorStreamingParams.restore(); sensorConfig.draw(); } }); hpanel.add(cancelButton); Button clearButton = new Button("Clear"); clearButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { sensorStreamingParams.clear(); sensorConfig.setUpdateFlag(true); Admin.getAdminService().updateSensor(sensor.toString(), sensorConfig); } }); hpanel.add(clearButton); Button armButton = new Button("Arm for I/Q Capture (one-shot)"); armButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { if (!sensorStreamingParams.isIqCaptureEnabled()) { Window.alert("I/Q capture not enabled"); return; } Admin.getAdminService().armSensor(sensor.getSensorId(), true, new SpectrumBrowserCallback<String>() { @Override public void onSuccess(String result) { Window.alert("Sensor is armed for one-shot capture"); } @Override public void onFailure(Throwable throwable) { Window.alert("Error communicating with server"); admin.logoff(); } }); } }); hpanel.add(armButton); Button deleteIQCaptureButton = new Button("Delete Capture Events"); deleteIQCaptureButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { Admin.getAdminService().deleteAllCaptureEvents(sensor.getSensorId(), new SpectrumBrowserCallback<String>() { @Override public void onSuccess(String result) { Window.alert("Capture Events Deleted"); } @Override public void onFailure(Throwable throwable) { Window.alert("Error communicating with server"); admin.logoff(); } }); } }); hpanel.add(deleteIQCaptureButton); Button logoffButton = new Button("Log Off"); logoffButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { admin.logoff(); } }); hpanel.add(logoffButton); verticalPanel.add(hpanel); }
From source file:gov.nist.spectrumbrowser.admin.SweptFrequencySensorBands.java
License:Open Source License
public void draw() { verticalPanel.clear();//w ww .jav a 2s .c om HTML html = new HTML("<H2>Bands for sensor : " + sensor.getSensorId() + "</H2>"); verticalPanel.add(html); JSONObject sensorThresholds = sensor.getThresholds(); Grid grid = new Grid(sensorThresholds.keySet().size() + 1, 8); grid.setBorderWidth(2); grid.setCellPadding(2); grid.setCellSpacing(2); grid.setText(0, 0, "System To Detect"); grid.setText(0, 1, "Min Freq (Hz)"); grid.setText(0, 2, "Max Freq (Hz)"); grid.setText(0, 3, "Channel Count"); grid.setText(0, 4, "Occupancy Threshold (dBm/Hz)"); grid.setText(0, 5, "Occupancy Threshold (dBm)"); grid.setText(0, 6, "Enabled?"); grid.setText(0, 7, "Delete Band"); grid.setBorderWidth(2); grid.setCellPadding(2); grid.setCellSpacing(2); CellFormatter formatter = grid.getCellFormatter(); for (int i = 0; i < grid.getRowCount(); i++) { for (int j = 0; j < grid.getColumnCount(); j++) { formatter.setHorizontalAlignment(i, j, HasHorizontalAlignment.ALIGN_CENTER); formatter.setVerticalAlignment(i, j, HasVerticalAlignment.ALIGN_MIDDLE); } } for (int i = 0; i < grid.getColumnCount(); i++) { grid.getCellFormatter().setStyleName(0, i, "textLabelStyle"); } int row = 1; for (String key : sensorThresholds.keySet()) { final SweptFrequencyBand threshold = new SweptFrequencyBand(sensorThresholds.get(key).isObject()); grid.setText(row, 0, threshold.getSystemToDetect()); grid.setText(row, 1, Long.toString(threshold.getMinFreqHz())); grid.setText(row, 2, Long.toString(threshold.getMaxFreqHz())); final TextBox channelCountTextBox = new TextBox(); channelCountTextBox.setText(Long.toString(threshold.getChannelCount())); channelCountTextBox.addValueChangeHandler(new ValueChangeHandler<String>() { @Override public void onValueChange(ValueChangeEvent<String> event) { Long oldValue = Long.parseLong(channelCountTextBox.getValue()); try { long newValue = Long.parseLong(event.getValue()); threshold.setChannelCount((long) newValue); } catch (Exception ex) { Window.alert(ex.getMessage()); channelCountTextBox.setValue(Double.toString(oldValue)); } } }); grid.setWidget(row, 3, channelCountTextBox); final Label thresholdLabel = new Label(); final TextBox thresholdTextBox = new TextBox(); thresholdTextBox.setText(Double.toString(threshold.getThresholdDbmPerHz())); thresholdTextBox.addValueChangeHandler(new ValueChangeHandler<String>() { @Override public void onValueChange(ValueChangeEvent<String> event) { Double oldThreshold = Double.parseDouble(thresholdTextBox.getValue()); try { double newThreshold = Double.parseDouble(event.getValue()); threshold.setThresholdDbmPerHz(newThreshold); thresholdLabel.setText(Float.toString(threshold.getThresholdDbm())); } catch (Exception ex) { Window.alert(ex.getMessage()); thresholdTextBox.setValue(Double.toString(oldThreshold)); } } }); grid.setWidget(row, 4, thresholdTextBox); thresholdLabel.setText(Float.toString(threshold.getThresholdDbm())); grid.setWidget(row, 5, thresholdLabel); CheckBox activeCheckBox = new CheckBox(); grid.setWidget(row, 6, activeCheckBox); activeCheckBox.setValue(threshold.isActive()); activeCheckBox.addValueChangeHandler(new ValueChangeHandler<Boolean>() { @Override public void onValueChange(ValueChangeEvent<Boolean> event) { if (event.getValue()) { for (String key : sensor.getThresholds().keySet()) { SweptFrequencyBand th = new SweptFrequencyBand(sensor.getThreshold(key)); th.setActive(false); } } threshold.setActive(event.getValue()); draw(); } }); Button deleteButton = new Button("Delete Band"); deleteButton.addClickHandler(new DeleteThresholdClickHandler(threshold)); grid.setWidget(row, 7, deleteButton); row++; } verticalPanel.add(grid); HorizontalPanel horizontalPanel = new HorizontalPanel(); Button addButton = new Button("Add Band"); addButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { new AddSweptFrequencySensorBand(admin, SweptFrequencySensorBands.this, sensorConfig, sensor, verticalPanel).draw(); } }); horizontalPanel.add(addButton); Button recomputeButton = new Button("Recompute Occupancies"); recomputeButton.setTitle("Recomputes per message summary occupancies."); recomputeButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { boolean yes = Window.confirm( "Ensure no users are using the system. Update sensor before proceeding. This can take a long time. Proceed?"); if (yes) { final HTML html = new HTML( "<h3>Recomputing thresholds - this can take a while. Please wait. </h3>"); verticalPanel.add(html); Admin.getAdminService().recomputeOccupancies(sensor.getSensorId(), new SpectrumBrowserCallback<String>() { @Override public void onSuccess(String result) { verticalPanel.remove(html); } @Override public void onFailure(Throwable throwable) { Window.alert("Error communicating with server"); admin.logoff(); } }); } } }); horizontalPanel.add(recomputeButton); Button doneButton = new Button("Done"); doneButton.setTitle("Return to sensors screen"); doneButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { sensorConfig.redraw(); } }); horizontalPanel.add(doneButton); Button updateButton = new Button("Update"); updateButton.setTitle("Update sensor on server"); updateButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { Admin.getAdminService().updateSensor(sensor.toString(), sensorConfig); } }); horizontalPanel.add(updateButton); Button logoffButton = new Button("Log Off"); logoffButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { admin.logoff(); } }); horizontalPanel.add(logoffButton); verticalPanel.add(horizontalPanel); }