List of usage examples for com.google.gwt.user.client.ui CheckBox setChecked
@Deprecated public void setChecked(boolean checked)
From source file:com.objetdirect.tatami.demo.client.GfxDemo.java
License:Open Source License
/** * Shows a popup to select a color for the background or the stroke. * The popup contains a TabPanel with 3 tab, a <code>ColorChooser</code>, * a <code>Slider</code> to change the opacity of the <code>Color</code>, * some <code>Pattern</code> to apply *///from w ww. jav a 2s . c o m private void showPopupColor(Widget sender) { final PopupPanel popupColor = new PopupPanel(true); popupColor.addStyleName("GfxDemo-popupColor"); TabPanel tabPanel = new TabPanel(); FlowPanel colPanel = new FlowPanel(); final CheckBox checkFill = new CheckBox("Background"); checkFill.setChecked(true); colPanel.add(checkFill); final ColorChooser colorChooser = new ColorChooser(); colPanel.add(colorChooser); tabPanel.add(colPanel, new Label("Color")); ChangeListener colorChange = new ChangeListener() { public void onChange(Widget sender) { String color = colorChooser.getColor(); Color colorSelected = Color.getColor(color); if (checkFill.isChecked()) { currentFillColor = colorSelected; DOM.setStyleAttribute(fill.getElement(), "backgroundColor", color); //currentFillColor.setAlpha(opacity.getValue()); if (current != null) { current.setFillColor(currentFillColor); } } else { currentStrokeColor = colorSelected; lastStrokeColor = currentStrokeColor; DOM.setStyleAttribute(fill.getElement(), "borderColor", color); if (current != null) { current.setStroke(currentStrokeColor, 1); } } } }; colorChooser.addChangeListener(colorChange); FlowPanel patternContainer = new FlowPanel(); patternContainer.add(createImagePattern("gfx/none.gif")); patternContainer.add(createImagePattern("littleNero.png")); patternContainer.add(createImagePattern("littleTrajan.png")); patternContainer.add(createImagePattern("cubic.jpg")); patternContainer.add(createImagePattern("logo_ft.gif")); patternContainer.add(createImagePattern("od-logo.jpg")); tabPanel.add(patternContainer, new Label("Pattern")); tabPanel.add(this.opacity, new Label("Opacity")); tabPanel.selectTab(0); popupColor.add(tabPanel); popupColor.setPopupPosition(sender.getAbsoluteLeft(), sender.getAbsoluteTop()); popupColor.show(); }
From source file:com.qualogy.qafe.gwt.client.vo.functions.execute.SetValueExecute.java
License:Apache License
public static void processValue(UIObject uiObject, Object valueToSet, SetValueGVO setValue, DataContainerGVO valueDTC) {/*from ww w. j a va 2 s .c om*/ if (uiObject != null) { if (uiObject instanceof HasText) { if (uiObject instanceof QRadioButton) { QRadioButton qRadioButton = (QRadioButton) uiObject; qRadioButton.reset(); if (valueToSet != null) { qRadioButton.setValue(valueToSet.toString()); } } else if (uiObject instanceof CheckBox) { CheckBox checkBox = (CheckBox) uiObject; String checkedValue = DOM.getElementAttribute(checkBox.getElement(), CheckBoxGVO.CHECKED_VALUE_ATTRIBUTE_TAG); String unCheckedValue = DOM.getElementAttribute(checkBox.getElement(), CheckBoxGVO.UNCHECKED_VALUE_ATTRIBUTE_TAG); String checkedValueDomain = DOM.getElementAttribute(checkBox.getElement(), CheckBoxGVO.CHECKED_VALUE_DOMAIN_ATTRIBUTE_TAG); String unCheckedValueDomain = DOM.getElementAttribute(checkBox.getElement(), CheckBoxGVO.UNCHECKED_VALUE_DOMAIN_ATTRIBUTE_TAG); if (valueToSet != null) { if (checkedValue != null && checkedValue.equals(valueToSet)) { checkBox.setChecked(true); } else if (unCheckedValue != null && unCheckedValue.equals(valueToSet)) { checkBox.setChecked(false); } else if (isInDomain(valueToSet.toString(), checkedValueDomain)) { checkBox.setChecked(true); } else if (isInDomain(valueToSet.toString(), unCheckedValueDomain)) { checkBox.setChecked(false); } } else { checkBox.setChecked(false); } } else if (uiObject instanceof HTML) { HTML html = (HTML) uiObject; if (valueToSet != null) { html.setHTML(valueToSet.toString()); } else { html.setHTML(""); } } else if (uiObject instanceof PushButton) { ((PushButton) uiObject).getUpFace().setText(valueToSet.toString()); ((PushButton) uiObject).getDownFace().setText(valueToSet.toString()); } else if (uiObject instanceof RichTextArea) { RichTextArea richTextArea = (RichTextArea) uiObject; richTextArea.setHTML(valueToSet.toString()); } else { HasText hasText = (HasText) uiObject; if (valueDTC != null) { if (valueDTC.getKind() == DataContainerGVO.KIND_STRING) { if (valueDTC.getStringDataType() == DataContainerGVO.TYPE_DATE) { if (uiObject instanceof QDatePicker) { ((QDatePicker) uiObject).setValue(valueDTC.getDateData()); } } else { hasText.setText(valueToSet.toString()); uiObject.setStyleName(uiObject.getStyleName().replaceAll("qafe_invalid_field", "qafe_valid_field")); } } else { hasText.setText(valueToSet.toString()); } } else if (valueToSet != null) { hasText.setText(valueToSet.toString()); } else { hasText.setText(""); } } } else if (uiObject instanceof Frame) { Frame frame = (Frame) uiObject; if (valueToSet != null) { frame.setUrl(valueToSet.toString()); } else { frame.setUrl(""); } } if (uiObject instanceof ListBox) { ListBox listBox = (ListBox) uiObject; // If it is needed to populate data and select a data from dropdown it should be seperate calls. if (valueDTC != null && valueDTC.getListofDC() != null) { processListBox(setValue, uiObject, valueDTC); } else { processValue4ListBox(listBox, valueToSet, setValue.getAction()); } } if (uiObject instanceof Image) { Image image = (Image) uiObject; if (valueToSet != null) { image.setUrl(valueToSet.toString()); } } if (uiObject instanceof QDatePicker) { QDatePicker qDatePicker = (QDatePicker) uiObject; if (valueDTC != null) { qDatePicker.setValue(valueDTC.getDateData(), true); } } if (uiObject instanceof QSliderBar) { QSliderBar slider = (QSliderBar) uiObject; slider.setValue(valueToSet); } if (uiObject instanceof HasDataGridMethods) { HasDataGridMethods dataGrid = (HasDataGridMethods) uiObject; List<DataContainerGVO> listOfDataMap = new ArrayList<DataContainerGVO>(); if (valueDTC.getKind() == DataContainerGVO.KIND_MAP) { listOfDataMap.add(new DataContainerGVO(valueDTC.getDataMap())); dataGrid.insertData(listOfDataMap, false, setValue.getSenderId(), setValue.getListenerType()); } else if (valueDTC.getKind() == DataContainerGVO.KIND_COLLECTION) { listOfDataMap = valueDTC.getListofDC(); dataGrid.insertData(listOfDataMap, false, setValue.getSenderId(), setValue.getListenerType()); } else if (valueDTC.getKind() == DataContainerGVO.KIND_STRING) { String cellOnRowToSet = setValue.getComponentId(); listOfDataMap.add(new DataContainerGVO(valueDTC.getDataString())); dataGrid.setDataToCell(new DataContainerGVO(valueDTC.getDataString()), false, setValue.getSenderId(), cellOnRowToSet); } dataGrid.redraw(); } } }
From source file:com.qualogy.qafe.gwt.client.vo.handlers.SetValueHandler.java
License:Apache License
private void processValue(UIObject uiObject, Object value, SetValueGVO setValueGVO, DataContainerGVO dataContainerGVO) { if (uiObject != null) { if (uiObject instanceof HasText) { if (uiObject instanceof QRadioButton) { QRadioButton qRadioButton = (QRadioButton) uiObject; qRadioButton.reset();//from w w w.java2 s. c om if (value != null) { qRadioButton.setValue(value.toString()); } } else if (uiObject instanceof CheckBox) { CheckBox checkBox = (CheckBox) uiObject; String checkedValue = DOM.getElementAttribute(checkBox.getElement(), CheckBoxGVO.CHECKED_VALUE_ATTRIBUTE_TAG); String unCheckedValue = DOM.getElementAttribute(checkBox.getElement(), CheckBoxGVO.UNCHECKED_VALUE_ATTRIBUTE_TAG); String checkedValueDomain = DOM.getElementAttribute(checkBox.getElement(), CheckBoxGVO.CHECKED_VALUE_DOMAIN_ATTRIBUTE_TAG); String unCheckedValueDomain = DOM.getElementAttribute(checkBox.getElement(), CheckBoxGVO.UNCHECKED_VALUE_DOMAIN_ATTRIBUTE_TAG); if (value != null) { if (checkedValue != null && checkedValue.equals(value)) { checkBox.setChecked(true); } else if (unCheckedValue != null && unCheckedValue.equals(value)) { checkBox.setChecked(false); } else if (isInDomain(value.toString(), checkedValueDomain)) { checkBox.setChecked(true); } else if (isInDomain(value.toString(), unCheckedValueDomain)) { checkBox.setChecked(false); } } else { checkBox.setChecked(false); } } else if (uiObject instanceof HTML) { HTML html = (HTML) uiObject; if (value != null) { html.setHTML(value.toString()); } else { html.setHTML(""); } } else if (uiObject instanceof PushButton) { ((PushButton) uiObject).getUpFace().setText(value.toString()); ((PushButton) uiObject).getDownFace().setText(value.toString()); } else if (uiObject instanceof RichTextArea) { RichTextArea richTextArea = (RichTextArea) uiObject; richTextArea.setHTML(value.toString()); } else { HasText hasText = (HasText) uiObject; if (dataContainerGVO != null) { if (dataContainerGVO.getKind() == DataContainerGVO.KIND_STRING) { if (dataContainerGVO.getStringDataType() == DataContainerGVO.TYPE_DATE) { if (uiObject instanceof QDatePicker) { ((QDatePicker) uiObject).setValue(dataContainerGVO.getDateData()); } } else { hasText.setText(value.toString()); uiObject.setStyleName(uiObject.getStyleName().replaceAll("qafe_invalid_field", "qafe_valid_field")); } } else { hasText.setText(value.toString()); } } else if (value != null) { hasText.setText(value.toString()); } else { hasText.setText(""); } } } else if (uiObject instanceof Frame) { Frame frame = (Frame) uiObject; if (value != null) { frame.setUrl(value.toString()); } else { frame.setUrl(""); } } if (uiObject instanceof ListBox) { ListBox listBox = (ListBox) uiObject; // If it is needed to populate data and select a data from dropdown it should be seperate calls. if (dataContainerGVO != null && dataContainerGVO.getListofDC() != null) { processListBox(uiObject, setValueGVO, dataContainerGVO); } else { processValue4ListBox(listBox, value, setValueGVO.getAction()); } } if (uiObject instanceof Image) { Image image = (Image) uiObject; if (value != null) { image.setUrl(value.toString()); } } if (uiObject instanceof QDatePicker) { QDatePicker qDatePicker = (QDatePicker) uiObject; if (dataContainerGVO != null) { qDatePicker.setValue(dataContainerGVO.getDateData(), true); } } if (uiObject instanceof QSliderBar) { QSliderBar slider = (QSliderBar) uiObject; slider.setValue(value); } if (uiObject instanceof HasDataGridMethods) { HasDataGridMethods dataGrid = (HasDataGridMethods) uiObject; List<DataContainerGVO> listOfDataMap = new ArrayList<DataContainerGVO>(); if (dataContainerGVO.getKind() == DataContainerGVO.KIND_MAP) { listOfDataMap.add(new DataContainerGVO(dataContainerGVO.getDataMap())); dataGrid.insertData(listOfDataMap, false, setValueGVO.getSenderId(), setValueGVO.getListenerType()); } else if (dataContainerGVO.getKind() == DataContainerGVO.KIND_COLLECTION) { listOfDataMap = dataContainerGVO.getListofDC(); dataGrid.insertData(listOfDataMap, false, setValueGVO.getSenderId(), setValueGVO.getListenerType()); } else if (dataContainerGVO.getKind() == DataContainerGVO.KIND_STRING) { String cellOnRowToSet = setValueGVO.getComponentId(); listOfDataMap.add(new DataContainerGVO(dataContainerGVO.getDataString())); dataGrid.setDataToCell(new DataContainerGVO(dataContainerGVO.getDataString()), false, setValueGVO.getSenderId(), cellOnRowToSet); } dataGrid.redraw(); } } }
From source file:com.sun.labs.aura.dbbrowser.client.viz.RepLogDialog.java
License:Open Source License
public RepLogDialog(String idStr, List<String> logNames, List<String> selected, String logLevel) { super(false); this.idStr = idStr; this.logNames = logNames; this.selected = selected; initialLogLevel = logLevel;//from w ww. java2 s. com setText("Change Log Settings"); FlowPanel mainPanel = new FlowPanel(); // // Put in a grid of check boxes for setting what methods are logged checks = new ArrayList<CheckBox>(); int numColumns = logNames.size() / 15; if (logNames.size() % 15 > 0) { numColumns++; } Grid grid = new Grid(15, numColumns); int currCol = 0; int currRow = 0; HTMLTable.CellFormatter fmt = grid.getCellFormatter(); for (String currName : logNames) { CheckBox cb = new CheckBox(currName); cb.setName(currName); String dispName = Util.logCodeToDisplay(currName); if (dispName != null) { cb.setText(dispName); } if (selected.contains(currName)) { cb.setChecked(true); } checks.add(cb); fmt.setStylePrimaryName(currRow, currCol, "viz-logGridCell"); grid.setWidget(currRow++, currCol, cb); if (currRow >= 15) { currRow = 0; currCol++; } } mainPanel.add(grid); // // Add in the pop-up for setting the log level levelMenu = new ListBox(); String[] levels = new String[] { "SEVERE", "WARNING", "INFO", "CONFIG", "FINE", "FINER", "FINEST" }; for (int i = 0; i < levels.length; i++) { levelMenu.addItem(levels[i]); if (levels[i].equals(initialLogLevel)) { levelMenu.setSelectedIndex(i); } } levelMenu.setVisibleItemCount(1); HorizontalPanel selectLevelPanel = new HorizontalPanel(); selectLevelPanel.add(new Label("Set log level: ")); selectLevelPanel.add(levelMenu); selectLevelPanel.setStylePrimaryName("viz-logLevelSelect"); mainPanel.add(selectLevelPanel); Button cancel = new Button("Cancel"); cancel.addClickListener(new ClickListener() { public void onClick(Widget arg0) { hide(); } }); mainPanel.add(cancel); Button changeMe = new Button("Change " + this.idStr); changeMe.addClickListener(new ClickListener() { public void onClick(Widget w) { doChange(false); } }); mainPanel.add(changeMe); Button changeAll = new Button("Change All"); changeAll.addClickListener(new ClickListener() { public void onClick(Widget w) { doChange(true); } }); mainPanel.add(changeAll); setWidget(mainPanel); setPopupPosition(30, 30); }
From source file:com.sun.labs.aura.dbbrowser.client.viz.SettingsDialog.java
License:Open Source License
public SettingsDialog(List<String> logCodes) { super(false); this.logCodes = logCodes; String[] selectedCodes = Util.getStatDisplayCodes(); List<String> selected = Arrays.asList(selectedCodes); setText("Edit Settings"); FlowPanel mainPanel = new FlowPanel(); FlowPanel repStatPanel = new FlowPanel(); repStatPanel.setStylePrimaryName("viz-settingsGroup"); repStatPanel.add(new Label("Show these Replicant Stats:")); checks = new ArrayList<CheckBox>(); int numColumns = logCodes.size() / 15; if (logCodes.size() % 15 > 0) { numColumns++;// ww w .j a v a 2s . c o m } Grid grid = new Grid(15, numColumns); int currCol = 0; int currRow = 0; HTMLTable.CellFormatter fmt = grid.getCellFormatter(); for (String currName : logCodes) { CheckBox cb = new CheckBox(currName); cb.setName(currName); String dispName = Util.logCodeToDisplay(currName); if (dispName != null) { cb.setText(dispName); } if (selected.contains(currName)) { cb.setChecked(true); } checks.add(cb); fmt.setStylePrimaryName(currRow, currCol, "viz-logGridCell"); grid.setWidget(currRow++, currCol, cb); if (currRow >= 15) { currRow = 0; currCol++; } } repStatPanel.add(grid); mainPanel.add(repStatPanel); Button cancel = new Button("Cancel"); cancel.addClickListener(new ClickListener() { public void onClick(Widget arg0) { hide(); } }); mainPanel.add(cancel); Button save = new Button("Save"); save.addClickListener(new ClickListener() { public void onClick(Widget w) { doSave(); hide(); } }); mainPanel.add(save); setWidget(mainPanel); setPopupPosition(30, 30); }
From source file:com.xpn.xwiki.watch.client.ui.filterbar.StateSelectorsWidget.java
License:Open Source License
public StateSelectorsWidget(Watch w) { super(w);/*from w w w . j a va2 s . c o m*/ setPanel(new FlowPanel()); initWidget(panel); init(); panel.setStyleName(watch.getStyleName("filter", "filter")); panel.add(getSeeOnlyTitlePanel()); this.flaggedCheckBox = new CheckBox(); panel.add(getCheckBoxPanel(this.flaggedCheckBox, "flagged", (watch.getFilterStatus().getFlagged() == 1), new ClickListener() { public void onClick(Widget widget) { if (((CheckBox) widget).isChecked()) { watch.refreshOnShowOnlyFlaggedArticles(); // Uncheck the trashed checkbox CheckBox trashedCheckBox = getTrashedCheckBox(); if (trashedCheckBox.isChecked()) { trashedCheckBox.setChecked(false); } } else { watch.refreshOnNotShowOnlyFlaggedArticles(); } } })); this.readCheckBox = new CheckBox(); panel.add(getCheckBoxPanel(this.readCheckBox, "read", (watch.getFilterStatus().getRead() == 1), new ClickListener() { public void onClick(Widget widget) { if (((CheckBox) widget).isChecked()) { watch.refreshOnShowOnlyReadArticles(); // Uncheck the unread checkbox CheckBox unreadCheckBox = getUnreadCheckBox(); if (unreadCheckBox.isChecked()) { unreadCheckBox.setChecked(false); } } else { watch.refreshOnNotShowOnlyReadArticles(); } } })); this.unreadCheckBox = new CheckBox(); panel.add(getCheckBoxPanel(this.unreadCheckBox, "unread", (watch.getFilterStatus().getRead() == -1), new ClickListener() { public void onClick(Widget widget) { if (((CheckBox) widget).isChecked()) { watch.refreshOnShowOnlyUnReadArticles(); // Uncheck the read articles checkbox CheckBox readCheckBox = getReadCheckBox(); if (readCheckBox.isChecked()) { readCheckBox.setChecked(false); } } else { watch.refreshOnNotShowOnlyUnReadArticles(); } } })); this.trashedCheckBox = new CheckBox(); panel.add(getCheckBoxPanel(this.trashedCheckBox, "trashed", (watch.getFilterStatus().getTrashed() == 1), new ClickListener() { public void onClick(Widget widget) { if (((CheckBox) widget).isChecked()) { watch.refreshOnShowOnlyTrashedArticles(); // Uncheck the flagged checkbox CheckBox flaggedCheckBox = getFlaggedCheckBox(); if (flaggedCheckBox.isChecked()) { flaggedCheckBox.setChecked(false); } } else { watch.refreshOnNotShowOnlyTrashedArticles(); } } })); }
From source file:com.xpn.xwiki.watch.client.ui.filterbar.StateSelectorsWidget.java
License:Open Source License
private Widget getCheckBoxPanel(CheckBox checkBox, String name, boolean checked, ClickListener clickListener) { FlowPanel p = new FlowPanel(); p.setStyleName(watch.getStyleName("filter", "seeonly-" + name)); if (checked)/*from w w w.j av a 2 s. c o m*/ checkBox.setChecked(true); checkBox.setHTML(watch.getTranslation("filter.seeonly." + name)); checkBox.addClickListener(clickListener); p.add(checkBox); return p; }
From source file:edu.ucsb.eucalyptus.admin.client.ClusterInfoTable.java
License:Open Source License
private Grid addClusterEntry(int row, ClusterInfoWeb clusterInfo, final StorageInfoWeb storageInfo) { final ArrayList<String> storageParams = storageInfo.getStorageParams(); numStorageParams = storageParams.size() / 4; Grid g = new Grid(8 + numStorageParams, 2); g.setStyleName("euca-table"); if (row > 0) { g.setStyleName("euca-nonfirst-cluster-entry"); }//ww w. java 2 s . c o m g.setCellPadding(4); int i = 0; // row 1 g.setWidget(i, 0, new HTML("<b>Name:</b>")); g.getCellFormatter().setHorizontalAlignment(i, 0, HasHorizontalAlignment.ALIGN_RIGHT); final HorizontalPanel namePanel = new HorizontalPanel(); namePanel.setSpacing(0); if (clusterInfo.isCommitted()) { namePanel.add(new Label(clusterInfo.getName())); } else { final TextBox nb = new TextBox(); nb.addChangeListener(new ChangeCallback(this, row)); nb.setVisibleLength(12); nb.setText(clusterInfo.getName()); nb.addFocusListener(new FocusHandler(this.hint, this.warningMessage)); namePanel.add(nb); } namePanel.add(new Button("Deregister Cluster", new DeleteCallback(this, row))); g.setWidget(i, 1, namePanel); i++; // next row g.setWidget(i, 1, new Label("Cluster Controller")); i++; // next row g.setWidget(i, 0, new Label("Host:")); g.getCellFormatter().setHorizontalAlignment(i, 0, HasHorizontalAlignment.ALIGN_RIGHT); final TextBox hb = new TextBox(); hb.addChangeListener(new ChangeCallback(this, row)); hb.setVisibleLength(20); hb.setText(clusterInfo.getHost()); hb.addFocusListener(new FocusHandler(this.hint, this.warningMessage)); g.setWidget(i, 1, hb); i++; // next row /* g.setWidget( i, 0, new Label( "Port:" ) ); g.getCellFormatter().setHorizontalAlignment(i, 0, HasHorizontalAlignment.ALIGN_RIGHT); final TextBox pb = new TextBox(); pb.addChangeListener (new ChangeCallback (this, row)); pb.setVisibleLength( 5 ); pb.setText( "" + clusterInfo.getPort() ); pb.addFocusListener (new FocusHandler (this.hint, this.warningMessage)); g.setWidget( i, 1, pb );*/ final TextBox reservedAddressesBox = new TextBox(); // declare here, set up after the checkbox later final CheckBox dynamicAddressesCheckbox = new CheckBox(); g.getCellFormatter().setHorizontalAlignment(i, 0, HasHorizontalAlignment.ALIGN_RIGHT); g.setWidget(i, 0, dynamicAddressesCheckbox); if (systemConfig.isDoDynamicPublicAddresses()) { dynamicAddressesCheckbox.setChecked(true); reservedAddressesBox.setEnabled(false); } else { dynamicAddressesCheckbox.setChecked(false); reservedAddressesBox.setEnabled(true); } dynamicAddressesCheckbox.addClickListener(new ClickListener() { public void onClick(Widget sender) { if (((CheckBox) sender).isChecked()) { reservedAddressesBox.setEnabled(false); systemConfig.setDoDynamicPublicAddresses(true); } else { reservedAddressesBox.setEnabled(true); systemConfig.setDoDynamicPublicAddresses(false); } } }); g.setWidget(i, 1, new Label("Dynamic public IP address assignment")); i++; // next row g.setWidget(i, 0, new Label("Reserve for assignment")); g.getCellFormatter().setHorizontalAlignment(i, 0, HasHorizontalAlignment.ALIGN_RIGHT); reservedAddressesBox.addChangeListener(new ChangeCallback(this, row)); reservedAddressesBox.setVisibleLength(5); reservedAddressesBox.setText("" + systemConfig.getSystemReservedPublicAddresses()); final HorizontalPanel reservedAddressesPanel = new HorizontalPanel(); reservedAddressesPanel.setSpacing(4); reservedAddressesPanel.add(reservedAddressesBox); reservedAddressesPanel.add(new HTML("public IP addresses")); reservedAddressesBox.setText("" + systemConfig.getSystemReservedPublicAddresses()); g.setWidget(i, 1, reservedAddressesPanel); i++; // next row g.setWidget(i, 0, new Label("Maximum of")); g.getCellFormatter().setHorizontalAlignment(i, 0, HasHorizontalAlignment.ALIGN_RIGHT); final TextBox publicAddressesBox = new TextBox(); publicAddressesBox.addChangeListener(new ChangeCallback(this, row)); publicAddressesBox.setVisibleLength(5); publicAddressesBox.setText("" + systemConfig.getMaxUserPublicAddresses()); final HorizontalPanel publicAddressesPanel = new HorizontalPanel(); publicAddressesPanel.setSpacing(4); publicAddressesPanel.add(publicAddressesBox); publicAddressesPanel.add(new HTML("public IP addresses per user")); g.setWidget(i, 1, publicAddressesPanel); i++; g.setWidget(i, 0, new Label("Use VLAN tags")); g.getCellFormatter().setHorizontalAlignment(i, 0, HasHorizontalAlignment.ALIGN_RIGHT); final TextBox minVlanBox = new TextBox(); minVlanBox.addChangeListener(new ChangeCallback(this, row)); minVlanBox.setVisibleLength(4); minVlanBox.setText(String.valueOf(clusterInfo.getMinVlans())); final TextBox maxVlanBox = new TextBox(); maxVlanBox.addChangeListener(new ChangeCallback(this, row)); maxVlanBox.setVisibleLength(4); maxVlanBox.setText(String.valueOf(clusterInfo.getMaxVlans())); final HorizontalPanel vlanPanel = new HorizontalPanel(); vlanPanel.setSpacing(4); vlanPanel.add(minVlanBox); vlanPanel.add(new HTML("through")); vlanPanel.add(maxVlanBox); g.setWidget(i, 1, vlanPanel); i++; // next row g.setWidget(i, 1, new Label("Storage Controller")); for (int paramidx = 0; paramidx < numStorageParams; ++paramidx) { i++; // next row if ("KEYVALUE".equals(storageParams.get(4 * paramidx))) { g.setWidget(i, 0, new Label(storageParams.get(4 * paramidx + 1) + ": ")); g.getCellFormatter().setHorizontalAlignment(i, 0, HasHorizontalAlignment.ALIGN_RIGHT); final TextBox propTextBox = new TextBox(); propTextBox.addChangeListener(new ChangeCallback(this, row)); propTextBox.setVisibleLength(30); propTextBox.setText(storageParams.get(4 * paramidx + 2)); propTextBox.addFocusListener(new FocusHandler(this.hint, this.warningMessage)); g.setWidget(i, 1, propTextBox); } else if ("PASSWORD".equals(storageParams.get(4 * paramidx))) { g.setWidget(i, 0, new Label(storageParams.get(4 * paramidx + 1) + ": ")); g.getCellFormatter().setHorizontalAlignment(i, 0, HasHorizontalAlignment.ALIGN_RIGHT); final TextBox propTextBox = new PasswordTextBox(); propTextBox.addChangeListener(new ChangeCallback(this, row)); propTextBox.setVisibleLength(30); propTextBox.setText(storageParams.get(4 * paramidx + 2)); propTextBox.addFocusListener(new FocusHandler(this.hint, this.warningMessage)); g.setWidget(i, 1, propTextBox); } else if ("BOOLEAN".equals(storageParams.get(4 * paramidx))) { final int index = paramidx; final CheckBox propCheckbox = new CheckBox(); g.getCellFormatter().setHorizontalAlignment(i, 0, HasHorizontalAlignment.ALIGN_RIGHT); g.setWidget(i, 0, propCheckbox); if (Boolean.parseBoolean(storageParams.get(4 * index + 2))) { propCheckbox.setChecked(true); } else { propCheckbox.setChecked(false); } propCheckbox.addClickListener(new ClickListener() { public void onClick(Widget sender) { if (((CheckBox) sender).isChecked()) { storageParams.set(4 * index + 2, String.valueOf(true)); } else { storageParams.set(4 * index + 2, String.valueOf(false)); } } }); g.setWidget(i, 1, new Label(storageParams.get(paramidx * 4 + 1))); } } return g; }
From source file:edu.ucsb.eucalyptus.admin.client.EucalyptusWebInterface.java
License:Open Source License
public void displayUserRecordPage(Panel parent, UserInfoWeb userToEdit) { final String oldPassword; final boolean admin; final boolean newUser; final boolean showSkipConfirmed; boolean isAdminChecked = false; // not admin by default boolean skipConfirmationChecked = previousSkipConfirmation; if (loggedInUser != null && (loggedInUser.isAdministrator() != null && loggedInUser.isAdministrator())) { admin = true;//from www. j a v a 2s . co m } else { admin = false; } if (userToEdit == null) { newUser = true; showSkipConfirmed = true; userToEdit = new UserInfoWeb(); oldPassword = ""; if (admin) { label_box.setText("Please, fill out the form to add a user"); } else { label_box.setText(signup_greeting); // Please, fill out the form: } } else { newUser = false; oldPassword = userToEdit.getPassword(); isAdminChecked = userToEdit.isAdministrator() != null && userToEdit.isAdministrator(); showSkipConfirmed = userToEdit.isConfirmed() == null || !userToEdit.isConfirmed(); skipConfirmationChecked = userToEdit.isConfirmed() != null && userToEdit.isConfirmed(); String status; if (userToEdit.isApproved() == null || !userToEdit.isApproved()) { status = "unapproved"; } else if (userToEdit.isEnabled() == null || !userToEdit.isEnabled()) { status = "disabled"; } else if (userToEdit.isConfirmed() == null || !userToEdit.isConfirmed()) { status = "unconfirmed"; } else { status = "active"; } if (userToEdit.isAdministrator() != null && userToEdit.isAdministrator()) { status += " & admin"; } label_box.setText("Editing information for user '" + userToEdit.getUserName() + "' (" + status + ")"); } label_box.setStyleName("euca-greeting-normal"); int rowsMandatory = 5; if (admin) { rowsMandatory++; // for admin checkbox if (showSkipConfirmed) { rowsMandatory++; // for skip confirmation checkbox } } final Grid g1 = new Grid(rowsMandatory, 3); g1.getColumnFormatter().setWidth(0, "180"); g1.getColumnFormatter().setWidth(1, "180"); g1.getColumnFormatter().setWidth(2, "180"); int i = 0; final Label label_mandatory = new Label("Mandatory fields:"); label_mandatory.setStyleName("euca-section-header"); final int userName_row = i; g1.setWidget(i, 0, new Label("Username:")); g1.getCellFormatter().setHorizontalAlignment(i, 0, HasHorizontalAlignment.ALIGN_RIGHT); final TextBox userName_box = new TextBox(); userName_box.setText(userToEdit.getUserName()); userName_box.setWidth("180"); if (!newUser) { userName_box.setEnabled(false); } g1.setWidget(i++, 1, userName_box); // optional row final CheckBox userIsAdmin = new CheckBox("Administrator"); userIsAdmin.setChecked(isAdminChecked); userIsAdmin.setStyleName("euca-remember-text"); if (admin) { g1.setWidget(i++, 1, userIsAdmin); } final int password1_row = i; g1.setWidget(i, 0, new Label("Password:")); g1.getCellFormatter().setHorizontalAlignment(i, 0, HasHorizontalAlignment.ALIGN_RIGHT); final PasswordTextBox cleartextPassword1_box = new PasswordTextBox(); cleartextPassword1_box.setText(userToEdit.getPassword()); cleartextPassword1_box.setWidth("180"); if ((!admin && !newUser) || (userToEdit.isAdministrator() != null && userToEdit.isAdministrator().booleanValue())) { cleartextPassword1_box.setEnabled(false); } g1.setWidget(i++, 1, cleartextPassword1_box); final int password2_row = i; g1.setWidget(i, 0, new Label("Password, again:")); g1.getCellFormatter().setHorizontalAlignment(i, 0, HasHorizontalAlignment.ALIGN_RIGHT); final PasswordTextBox cleartextPassword2_box = new PasswordTextBox(); cleartextPassword2_box.setText(userToEdit.getPassword()); cleartextPassword2_box.setWidth("180"); if ((!admin && !newUser) || (userToEdit.isAdministrator() != null && userToEdit.isAdministrator().booleanValue())) { cleartextPassword2_box.setEnabled(false); } g1.setWidget(i++, 1, cleartextPassword2_box); final int realName_row = i; g1.setWidget(i, 0, new Label("Full Name:")); g1.getCellFormatter().setHorizontalAlignment(i, 0, HasHorizontalAlignment.ALIGN_RIGHT); final TextBox realName_box = new TextBox(); realName_box.setText(userToEdit.getRealName()); realName_box.setWidth("180"); g1.setWidget(i++, 1, realName_box); final int emailAddress_row = i; g1.setWidget(i, 0, new Label("Email address:")); g1.getCellFormatter().setHorizontalAlignment(i, 0, HasHorizontalAlignment.ALIGN_RIGHT); final TextBox emailAddress_box = new TextBox(); emailAddress_box.setText(userToEdit.getEmail()); emailAddress_box.setWidth("180"); g1.setWidget(i++, 1, emailAddress_box); // optional row final CheckBox skipConfirmation = new CheckBox("Skip email confirmation"); skipConfirmation.setChecked(skipConfirmationChecked); skipConfirmation.setStyleName("euca-remember-text"); if (admin && showSkipConfirmed) { g1.setWidget(i++, 1, skipConfirmation); } /* these widgets are allocated, but not necessarily used */ final Grid g2 = new Grid(); final Label label_optional = new Label("Optional fields:"); label_optional.setStyleName("euca-section-header"); final TextBox telephoneNumber_box = new TextBox(); final TextBox projectPIName_box = new TextBox(); final TextBox affiliation_box = new TextBox(); final TextArea projectDescription_box = new TextArea(); int extra_fields = 0; if (request_telephone) { extra_fields++; } if (request_project_leader) { extra_fields++; } if (request_affiliation) { extra_fields++; } if (request_project_description) { extra_fields++; } if (extra_fields > 0) { g2.resize(extra_fields, 2); g2.getColumnFormatter().setWidth(0, "180"); g2.getColumnFormatter().setWidth(1, "360"); i = 0; if (request_telephone) { g2.setWidget(i, 0, new Label("Telephone Number:")); g2.getCellFormatter().setHorizontalAlignment(i, 0, HasHorizontalAlignment.ALIGN_RIGHT); telephoneNumber_box.setWidth("180"); telephoneNumber_box.setText(userToEdit.getTelephoneNumber()); g2.setWidget(i++, 1, telephoneNumber_box); } if (request_project_leader) { g2.setWidget(i, 0, new Label("Project Leader:")); g2.getCellFormatter().setHorizontalAlignment(i, 0, HasHorizontalAlignment.ALIGN_RIGHT); projectPIName_box.setText(userToEdit.getProjectPIName()); projectPIName_box.setWidth("180"); g2.setWidget(i++, 1, projectPIName_box); } if (request_affiliation) { g2.setWidget(i, 0, new Label("Affiliation:")); g2.getCellFormatter().setHorizontalAlignment(i, 0, HasHorizontalAlignment.ALIGN_RIGHT); affiliation_box.setText(userToEdit.getAffiliation()); affiliation_box.setWidth("360"); g2.setWidget(i++, 1, affiliation_box); } if (request_project_description) { g2.setWidget(i, 0, new Label("Project Description:")); g2.getCellFormatter().setHorizontalAlignment(i, 0, HasHorizontalAlignment.ALIGN_RIGHT); projectDescription_box.setText(userToEdit.getProjectDescription()); projectDescription_box.setWidth("360"); projectDescription_box.setHeight("50"); g2.setWidget(i++, 1, projectDescription_box); } } ClickListener SignupButtonListener = new ClickListener() { public void onClick(Widget sender) { boolean formOk = true; for (int j = 0; j < 4; j++) { g1.clearCell(j, 2); /* clear previous right-hand-side annotations */ } // perform checks if (userName_box.getText().length() < 1) { Label l = new Label("Username is empty!"); l.setStyleName("euca-error-hint"); g1.setWidget(userName_row, 2, l); formOk = false; } else { // do this in the else-clause so the empty username doesn't match here if (cleartextPassword1_box.getText().toLowerCase() .matches(".*" + userName_box.getText().toLowerCase() + ".*")) { Label l = new Label("Password may not contain the username!"); l.setStyleName("euca-error-hint"); g1.setWidget(password1_row, 2, l); formOk = false; } } if (userName_box.getText().matches(".*[^\\w\\-\\.@]+.*")) { Label l = new Label("Invalid characters in the username!"); l.setStyleName("euca-error-hint"); g1.setWidget(userName_row, 2, l); formOk = false; } if (userName_box.getText().length() > 30) { Label l = new Label("Username is too long, sorry!"); l.setStyleName("euca-error-hint"); g1.setWidget(userName_row, 2, l); formOk = false; } if (cleartextPassword1_box.getText().length() < minPasswordLength) { Label l = new Label("Password must be at least " + minPasswordLength + " characters long!"); l.setStyleName("euca-error-hint"); g1.setWidget(password1_row, 2, l); formOk = false; } if (!cleartextPassword1_box.getText().equals(cleartextPassword2_box.getText())) { Label l = new Label("Passwords do not match!"); l.setStyleName("euca-error-hint"); g1.setWidget(password2_row, 2, l); formOk = false; } if (realName_box.getText().equalsIgnoreCase(cleartextPassword1_box.getText()) || userName_box.getText().equalsIgnoreCase(cleartextPassword1_box.getText())) { Label l = new Label("Password may not be your name or username!"); l.setStyleName("euca-error-hint"); g1.setWidget(password1_row, 2, l); formOk = false; } if (realName_box.getText().length() < 1) { Label l = new Label("Name is empty!"); l.setStyleName("euca-error-hint"); g1.setWidget(realName_row, 2, l); formOk = false; } if (emailAddress_box.getText().length() < 1) { Label l = new Label("Email address is empty!"); l.setStyleName("euca-error-hint"); g1.setWidget(emailAddress_row, 2, l); formOk = false; } if (formOk) { label_box.setText("Checking with the server..."); label_box.setStyleName("euca-greeting-pending"); String enteredPassword = cleartextPassword1_box.getText(); String encryptedPassword = GWTUtils.md5(enteredPassword); if (enteredPassword.equals(oldPassword)) { encryptedPassword = enteredPassword; // it was not changed in the edit } final UserInfoWeb userToSave = new UserInfoWeb(userName_box.getText(), realName_box.getText(), emailAddress_box.getText(), encryptedPassword); if (admin) { userToSave.setAdministrator(userIsAdmin.isChecked()); if (showSkipConfirmed) { previousSkipConfirmation = skipConfirmation.isChecked(); // remember value for the future userToSave.setConfirmed(previousSkipConfirmation); } } if (telephoneNumber_box.getText().length() > 0) { userToSave.setTelephoneNumber(telephoneNumber_box.getText()); } if (affiliation_box.getText().length() > 0) { userToSave.setAffiliation(affiliation_box.getText()); } if (projectDescription_box.getText().length() > 0) { userToSave.setProjectDescription(projectDescription_box.getText()); } if (projectPIName_box.getText().length() > 0) { userToSave.setProjectPIName(projectPIName_box.getText()); } if (newUser) { EucalyptusWebBackend.App.getInstance().addUserRecord( sessionId, /* will be null if anonymous user signs up */ userToSave, new AsyncCallback() { public void onSuccess(Object result) { displayDialog("Thank you!", (String) result); } public void onFailure(Throwable caught) { String m = caught.getMessage(); if (m.equals("User already exists")) { g1.setWidget(userName_row, 2, new Label("Username is taken!")); label_box.setText("Please, fix the error and resubmit:"); label_box.setStyleName("euca-greeting-warning"); } else { displayErrorPage(m); } } }); } else { EucalyptusWebBackend.App.getInstance().updateUserRecord(sessionId, userToSave, new AsyncCallback() { public void onSuccess(Object result) { if (loggedInUser.getUserName().equals(userToSave.getUserName())) { loggedInUser.setRealName(userToSave.getRealName()); loggedInUser.setEmail(userToSave.getEmail()); loggedInUser.setPassword(userToSave.getPassword()); loggedInUser.setTelephoneNumber(userToSave.getTelephoneNumber()); loggedInUser.setAffiliation(userToSave.getAffiliation()); loggedInUser.setProjectDescription(userToSave.getProjectDescription()); loggedInUser.setProjectPIName(userToSave.getProjectPIName()); displayDialog("", (String) result); } else { // admin updating a user displayBarAndTabs(""); statusMessage.setText((String) result); } } public void onFailure(Throwable caught) { String m = caught.getMessage(); displayErrorPage(m); } }); } } else { label_box.setText("Please, fix the errors and resubmit:"); label_box.setStyleName("euca-greeting-warning"); } } }; Button submit_button; if (newUser) { if (admin) { submit_button = new Button("Add user", SignupButtonListener); } else { submit_button = new Button("Sign up", SignupButtonListener); } } else { submit_button = new Button("Update Record", SignupButtonListener); } Button cancel_button = new Button("Cancel", DefaultPageButtonListener); VerticalPanel mpanel = new VerticalPanel(); mpanel.add(label_mandatory); mpanel.add(g1); VerticalPanel opanel = new VerticalPanel(); if (extra_fields > 0) { opanel.add(label_optional); opanel.add(g2); } HorizontalPanel bpanel = new HorizontalPanel(); bpanel.add(submit_button); bpanel.add(new HTML(" or ")); bpanel.add(cancel_button); VerticalPanel vpanel = new VerticalPanel(); vpanel.setSpacing(15); vpanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); vpanel.add(new HTML("<br/>")); if (logo != null) { addLogoWithText(vpanel); vpanel.add(new HTML("<br/>")); } ; vpanel.add(label_box); vpanel.add(mpanel); vpanel.add(opanel); vpanel.add(bpanel); VerticalPanel wrapper = new VerticalPanel(); wrapper.add(vpanel); wrapper.setSize("100%", "100%"); wrapper.setCellHorizontalAlignment(vpanel, VerticalPanel.ALIGN_CENTER); // wrapper.setCellVerticalAlignment(vpanel, VerticalPanel.ALIGN_MIDDLE); parent.clear(); parent.add(wrapper); }
From source file:edu.ucsb.eucalyptus.admin.client.VmTypeTable.java
License:Open Source License
private void addVmTypeEntry(int row, VmTypeWeb VmType) { if ((row % 2) == 1) { this.grid.getRowFormatter().setStyleName(row, "euca-table-odd-row"); } else {/* w w w. java2s. co m*/ this.grid.getRowFormatter().setStyleName(row, "euca-table-even-row"); } final CheckBox cb = new CheckBox(); cb.addClickListener(new ChangeCallback(this, row)); cb.setChecked(true); // TODO: get this from server //this.grid.setWidget( row, 0, cb ); final Label name_b = new Label(); name_b.setText(VmType.getName()); this.grid.setWidget(row, 1, name_b); final TextBox cpu_b = new TextBox(); cpu_b.addChangeListener(new ChangeCallback(this, row)); cpu_b.setVisibleLength(2); cpu_b.setText("" + VmType.getCpu()); this.grid.setWidget(row, 2, cpu_b); this.grid.getCellFormatter().setHorizontalAlignment(row, 2, HasHorizontalAlignment.ALIGN_CENTER); // michael had these three commented out final TextBox mem_b = new TextBox(); mem_b.addChangeListener(new ChangeCallback(this, row)); mem_b.setVisibleLength(4); mem_b.setText("" + VmType.getMemory()); this.grid.setWidget(row, 3, mem_b); this.grid.getCellFormatter().setHorizontalAlignment(row, 3, HasHorizontalAlignment.ALIGN_CENTER); final TextBox disk_b = new TextBox(); disk_b.addChangeListener(new ChangeCallback(this, row)); disk_b.setVisibleLength(4); disk_b.setText("" + VmType.getDisk()); this.grid.setWidget(row, 4, disk_b); this.grid.getCellFormatter().setHorizontalAlignment(row, 4, HasHorizontalAlignment.ALIGN_CENTER); }