List of usage examples for com.google.gwt.user.client.ui CheckBox setEnabled
@Override public void setEnabled(boolean enabled)
From source file:eml.studio.client.mvp.presenter.AccountLoader.java
License:Open Source License
/** * Reload search result//from w w w.ja v a 2s . com */ private void reload() { resultStart = (currentPage - 1) * 13; if (currentPage == lastPage) { everyPageSize = resultSize - resultStart; } else { everyPageSize = 13; } adminView.getUserGrid().resize(everyPageSize + 1, 7); adminView.getUserGrid().setText(0, 0, "Email"); adminView.getUserGrid().setText(0, 1, "Username"); adminView.getUserGrid().setText(0, 2, "Company"); adminView.getUserGrid().setText(0, 3, "Position"); adminView.getUserGrid().setText(0, 4, "Join Date"); adminView.getUserGrid().setText(0, 5, "Power"); adminView.getUserGrid().setText(0, 6, "Operation"); Account currentAccount = new Account(); currentAccount.setEmail(Cookies.getCookie("bdaemail")); accountService.search(currentAccount, searchAccount, resultStart, everyPageSize, new AsyncCallback<List<Account>>() { @Override public void onFailure(Throwable caught) { // TODO Auto-generated method stub alertPanel.setContent(caught.getMessage()); alertPanel.show(); } @Override public void onSuccess(List<Account> result) { // TODO Auto-generated method stub for (int i = 0; i < everyPageSize; i++) { adminView.getUserGrid().setText(i + 1, 0, result.get(i).getEmail()); adminView.getUserGrid().setText(i + 1, 1, result.get(i).getUsername()); adminView.getUserGrid().setText(i + 1, 2, result.get(i).getCompany()); adminView.getUserGrid().setText(i + 1, 3, result.get(i).getPosition()); adminView.getUserGrid().setText(i + 1, 4, formatter.format(result.get(i).getCreatetime())); final HorizontalPanel powerField = new HorizontalPanel(); final CheckBox cb1 = new CheckBox(); final CheckBox cb2 = new CheckBox(); final CheckBox cb3 = new CheckBox(); Label lb1 = new Label(Constants.adminUIMsg.power1()); Label lb2 = new Label(Constants.adminUIMsg.power2()); Label lb3 = new Label(Constants.adminUIMsg.power3()); lb1.getElement().getStyle().setMarginTop(1, Unit.PX); lb2.getElement().getStyle().setMarginTop(1, Unit.PX); lb3.getElement().getStyle().setMarginTop(1, Unit.PX); cb1.getElement().getStyle().setMarginLeft(5, Unit.PX); cb2.getElement().getStyle().setMarginLeft(5, Unit.PX); cb3.getElement().getStyle().setMarginLeft(5, Unit.PX); powerField.add(cb1); powerField.add(lb1); powerField.add(cb2); powerField.add(lb2); powerField.add(cb3); powerField.add(lb3); String arr[] = result.get(i).getPower().split(""); if (arr[1].equals("1")) { cb1.setValue(true); } if (arr[2].equals("1")) { cb2.setValue(true); } if (arr[3].equals("1")) { cb3.setValue(true); } cb1.setEnabled(false); cb2.setEnabled(false); cb3.setEnabled(false); adminView.getUserGrid().setWidget(i + 1, 5, powerField); final String userEmail = result.get(i).getEmail(); final Label editUser = new Label(); editUser.setTitle(Constants.adminUIMsg.editPower()); editUser.addStyleName("admin-user-edit"); editUser.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { // TODO Auto-generated method stub cb1.setEnabled(true); cb2.setEnabled(true); cb3.setEnabled(true); editUser.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { // TODO Auto-generated method stub String newPower = ""; if (cb1.getValue()) { newPower = newPower + "1"; } else { newPower = newPower + "0"; } if (cb2.getValue()) { newPower = newPower + "1"; } else { newPower = newPower + "0"; } if (cb3.getValue()) { newPower = newPower + "1"; } else { newPower = newPower + "0"; } Account account = new Account(); account.setEmail(userEmail); account.setPower(newPower); accountService.updatePower(account, new AsyncCallback<Account>() { @Override public void onFailure(Throwable caught) { // TODO Auto-generated method stub alertPanel.setContent(caught.getMessage()); alertPanel.show(); } @Override public void onSuccess(Account result) { // TODO Auto-generated method stub if (result != null) { alertPanel.setContent(Constants.adminUIMsg.powerSuccess()); alertPanel.show(); } } }); } }); } }); Label deleteUser = new Label(); deleteUser.setTitle(Constants.adminUIMsg.deleteUser()); deleteUser.addStyleName("admin-user-delete"); deleteUser.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { // TODO Auto-generated method stub deletePanel.setContent(Constants.adminUIMsg.userDelete1() + userEmail + Constants.adminUIMsg.userDelete2()); deletePanel.show(); deletePanel.getConfirmBtn().addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { // TODO Auto-generated method stub Account account = new Account(); account.setEmail(userEmail); accountService.deleteAccount(account, new AsyncCallback<String>() { @Override public void onFailure(Throwable caught) { // TODO Auto-generated method stub deletePanel.hide(); alertPanel.setContent(caught.getMessage()); alertPanel.show(); } @Override public void onSuccess(String result) { // TODO Auto-generated method stub if (result.equals("success")) { deletePanel.hide(); alertPanel.setContent(Constants.adminUIMsg.userSuccess()); alertPanel.show(); } else { deletePanel.hide(); alertPanel.setContent(result); alertPanel.show(); } } }); } }); } }); HorizontalPanel operate = new HorizontalPanel(); operate.addStyleName("admin-user"); operate.add(editUser); operate.add(deleteUser); if (!userEmail.equals(AppController.email)) { adminView.getUserGrid().setWidget(i + 1, 6, operate); } } } }); }
From source file:gov.nist.spectrumbrowser.admin.FftPowerSensorBands.java
License:Open Source License
public void draw() { verticalPanel.clear();/*from ww w.j a va 2s . co m*/ 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:ilarkesto.gwt.client.desktop.fields.AEditableMultiSelectionField.java
License:Open Source License
private IsWidget createCheckboxesEditorWidget(Collection<String> optionKeys) { checkboxes = new LinkedHashMap<String, CheckBox>(); boolean horizontal = isHorizontal(); Panel panel = horizontal ? new FlowPanel() : new VerticalPanel(); Collection<String> selectedKeys = getSelectedOptionKeys(); int inRow = 0; for (String key : optionKeys) { String label = getTextForOption(getValueForKey(key)); CheckBox checkBox = new CheckBox(label); checkBox.getElement().setId(getId() + "_checkbox_" + key); checkBox.setValue(selectedKeys.contains(key)); if (getEditVetoMessage() == null) { } else {/*from w w w . ja va 2 s. c om*/ checkBox.setEnabled(false); checkBox.setTitle(getEditVetoMessage()); } updateStyle(checkBox); checkBox.addValueChangeHandler(new CheckboxChangeHandler(checkBox)); if (horizontal) { Style style = checkBox.getElement().getStyle(); style.setProperty("minWidth", "100px"); style.setDisplay(Display.BLOCK); style.setFloat(com.google.gwt.dom.client.Style.Float.LEFT); style.setWidth(220, Unit.PX); style.setMarginRight(Widgets.defaultSpacing, Unit.PX); } checkboxes.put(key, checkBox); panel.add(checkBox); inRow++; if (horizontal && inRow >= 3) { panel.add(new HTML("<br>")); inRow = 0; } } if (horizontal) { panel.add(Widgets.clear()); } if (optionKeys.size() >= 10) { panel.add(new ActionButton(new SelectAllCheckboxesAction())); panel.add(new ActionButton(new DeselectAllCheckboxesAction())); } return panel; }
From source file:net.europa13.taikai.web.client.ui.PlayerTable.java
License:Open Source License
public void setPlayerList(List<PlayerProxy> playerList) { reset();/*from w w w . j a v a2 s .co m*/ if (playerList == null) { return; } // int columnCount = getColumnCount(); int playerCount = playerList.size(); // resize(playerCount + 1, columnCount); for (int i = 0; i < playerCount; ++i) { final PlayerProxy player = playerList.get(i); CheckBox checkedIn = new CheckBox(); checkedIn.setChecked(player.isCheckedIn()); checkedIn.setEnabled(false); setWidget(i + 2, 0, checkedIn); setText(i + 2, 1, String.valueOf(player.getId())); setText(i + 2, 2, String.valueOf(player.getNumber())); setText(i + 2, 3, player.getName()); setText(i + 2, 4, player.getSurname()); setText(i + 2, 5, player.getGrade().toString()); String mfText = player.getGender() == Gender.FEMALE ? "K" : "M"; setText(i + 2, 6, mfText); } }
From source file:net.randomhacks.wave.voting.approval.client.ChoicesTable.java
License:Apache License
private void updateChoiceRow(int i, Choice choice, boolean isWritable) { Log.debug("Updating row " + Integer.toString(i) + ": " + choice.key); CheckBox checkBox = (CheckBox) getWidget(rowForChoiceIndex(i), 0); checkBox.setValue(choice.wasChosenByMe); String label = choice.name;// ww w .j a v a 2 s .c o m if (choice.votes > 0) label += " (" + Integer.toString(choice.votes) + ")"; checkBox.setText(label); if (choice.isWinner) checkBox.addStyleName("winningChoice"); else checkBox.removeStyleName("winningChoice"); checkBox.setEnabled(isWritable); }
From source file:net.s17fabu.vip.gwt.showcase.client.content.widgets.CwCheckBox.java
License:Apache License
/** * Initialize this example./*from www . ja v a2s. c o m*/ */ @Override public Widget onInitialize() { // Create a vertical panel to align the check boxes VerticalPanel vPanel = new VerticalPanel(); HTML label = new HTML(constants.cwCheckBoxCheckAll()); label.ensureDebugId("cwCheckBox-label"); vPanel.add(label); // Add a checkbox for each day of the week String[] daysOfWeek = constants.cwCheckBoxDays(); for (int i = 0; i < daysOfWeek.length; i++) { String day = daysOfWeek[i]; CheckBox checkBox = new CheckBox(day); checkBox.ensureDebugId("cwCheckBox-" + day); // Disable the weekends if (i >= 5) { checkBox.setEnabled(false); } vPanel.add(checkBox); } // Return the panel of checkboxes return vPanel; }
From source file:org.activityinfo.ui.client.component.form.field.CheckBoxFieldWidget.java
License:Open Source License
@Override public void setReadOnly(boolean readOnly) { for (CheckBox control : controls) { control.setEnabled(!readOnly); }/*from www . j ava 2 s . co m*/ }
From source file:org.bonitasoft.forms.client.view.widget.CheckboxGroupWidget.java
License:Open Source License
/** * Enable or disable the checkbox group/*from w w w . ja va 2 s. com*/ * * @param isEnabled */ public void setEnabled(final boolean isEnabled) { for (final CheckBox checkBox : checkboxes) { checkBox.setEnabled(isEnabled); } }
From source file:org.bonitasoft.forms.client.view.widget.FormFieldWidget.java
License:Open Source License
/** * Create a {@link CheckBox} widget//from w w w . ja va2 s.com * * @param widgetData * the widget data object * @param fieldValue * the widget value * @return a {@link CheckBox} */ @SuppressWarnings("unchecked") protected CheckBox createCheckBox(final ReducedFormWidget widgetData, final FormFieldValue fieldValue) { final CheckBox checkBox = new CheckBox(); checkBox.addClickHandler(this); checkBox.addValueChangeHandler(this); try { checkBox.setValue((Boolean) fieldValue.getValue()); } catch (final Exception e) { Window.alert("initial value for checkbox " + widgetData.getId() + " should be a boolean."); checkBox.setValue(false, false); } checkBox.setEnabled(!widgetData.isReadOnly()); return checkBox; }
From source file:org.cruxframework.crux.widgets.client.grid.AbstractGrid.java
License:Apache License
/** * Creates a cell to be used as first header cell. * If the row selection model is <code>multipleCheckBoxSelectAll</code>, * this cell will contain a check box which when clicked selects or deselects all enabled rows. * @param rowCount// w w w .ja v a 2s .c o m * @return the created cell */ private Cell createHeaderFristColumnCell(int rowCount) { Widget w = null; if (hasSelectionColumn()) { if (RowSelectionModel.multipleCheckBoxSelectAll.equals(rowSelection)) { CheckBox checkBox = new CheckBox(); checkBox.addClickHandler(createSelectAllRowsClickHandler()); if (rowCount <= 1) { checkBox.setEnabled(false); } w = checkBox; } } if (w == null) { w = new Label(" "); } return createHeaderCell(w); }