List of usage examples for com.google.gwt.user.client.ui TextBox setVisibleLength
public void setVisibleLength(int length)
From source file:edu.ucsb.eucalyptus.admin.client.EucalyptusWebInterface.java
License:Open Source License
public void displayWalrusURLChangePage() { label_box.setText("One last thing! Really!!!"); label_box.setStyleName("euca-greeting-error"); HorizontalPanel hpanel = new HorizontalPanel(); hpanel.add(new Label("Walrus URL:")); final TextBox box = new TextBox(); box.setVisibleLength(55); hpanel.add(box);/*www.j a va 2s . c o m*/ EucalyptusWebBackend.App.getInstance().getSystemConfig(sessionId, new AsyncCallback() { public void onSuccess(final Object result) { conf = (SystemConfigWeb) result; box.setText(conf.getCloudHost()); } public void onFailure(Throwable caught) { } }); Button change_button = new Button("Confirm URL", new ClickListener() { public void onClick(Widget sender) { conf.setCloudHost(box.getText()); EucalyptusWebBackend.App.getInstance().setSystemConfig(sessionId, conf, new AsyncCallback() { public void onSuccess(final Object result) { currentTabIndex = 3; // TODO: change this to confTabIndex displayDefaultPage(""); } public void onFailure(Throwable caught) { displayErrorPage("Failed to save the URL (check 'Configuration' tab)."); } }); } }); HTML message = new HTML(admin_cloud_ip_setup_text); message.setWidth("460"); VerticalPanel vpanel = new VerticalPanel(); vpanel.setSpacing(15); vpanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); if (logo != null) { vpanel.add(logo); } vpanel.add(label_box); vpanel.add(message); vpanel.add(hpanel); vpanel.add(change_button); VerticalPanel wrapper = new VerticalPanel(); wrapper.add(vpanel); wrapper.setSize("100%", "100%"); wrapper.setCellHorizontalAlignment(vpanel, VerticalPanel.ALIGN_CENTER); wrapper.setCellVerticalAlignment(vpanel, VerticalPanel.ALIGN_MIDDLE); RootPanel.get().clear(); RootPanel.get().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 {/*from w w w. j a v a 2s . 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); }
From source file:edu.ucsb.eucalyptus.admin.client.WalrusInfoTable.java
License:Open Source License
private Grid addWalrusEntry(int row, WalrusInfoWeb walrusInfo) { final ArrayList<String> properties = walrusInfo.getProperties(); int numProperties = properties.size() / 4; Grid g = new Grid(1 + numProperties, 2); g.setStyleName("euca-table"); g.setCellPadding(4);/*from w ww .j av a2 s . c o m*/ int i = 0; // row 1 g.setWidget(i, 0, new Label("Walrus host:")); g.getCellFormatter().setHorizontalAlignment(i, 0, HasHorizontalAlignment.ALIGN_RIGHT); HorizontalPanel p = new HorizontalPanel(); p.setSpacing(0); g.setWidget(i, 1, p); final TextBox walrusHost_box = new TextBox(); walrusHost_box.addChangeListener(new ChangeCallback(this, row)); walrusHost_box.setVisibleLength(35); walrusHost_box.setText(walrusInfo.getHost()); p.add(walrusHost_box); p.add(new EucaButton("Deregister", new DeleteCallback(this, row))); for (int propIdx = 0; propIdx < numProperties; ++propIdx) { i++; // next row if ("KEYVALUE".equals(properties.get(4 * propIdx))) { g.setWidget(i, 0, new Label(properties.get(4 * propIdx + 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(properties.get(4 * propIdx + 2)); propTextBox.addFocusListener(new FocusHandler(this.hint, this.warningMessage)); g.setWidget(i, 1, propTextBox); } else if ("KEYVALUEHIDDEN".equals(properties.get(4 * propIdx))) { g.setWidget(i, 0, new Label(properties.get(4 * propIdx + 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(properties.get(4 * propIdx + 2)); propTextBox.addFocusListener(new FocusHandler(this.hint, this.warningMessage)); g.setWidget(i, 1, propTextBox); } else if ("BOOLEAN".equals(properties.get(4 * propIdx))) { final int index = propIdx; final CheckBox propCheckbox = new CheckBox(); g.getCellFormatter().setHorizontalAlignment(i, 0, HasHorizontalAlignment.ALIGN_RIGHT); g.setWidget(i, 0, propCheckbox); if (Boolean.parseBoolean(properties.get(4 * index + 2))) { propCheckbox.setChecked(true); } else { propCheckbox.setChecked(false); } propCheckbox.addClickListener(new ClickListener() { public void onClick(Widget sender) { if (((CheckBox) sender).isChecked()) { properties.set(4 * index + 2, String.valueOf(true)); } else { properties.set(4 * index + 2, String.valueOf(false)); } } }); g.setWidget(i, 1, new Label(properties.get(propIdx * 4 + 1))); } } return g; }
From source file:main.client.ui.RowLayoutPortlet.java
License:Open Source License
public RowLayoutPortlet() { LayoutPanel panel = new LayoutPanel(); initWidget(panel);/*from ww w. java 2s. c o m*/ final CheckBox column = new CheckBox("Column"); column.addValueChangeHandler(new ValueChangeHandler<Boolean>() { public void onValueChange(ValueChangeEvent<Boolean> event) { getTargetLayout().setColumn(column.getValue()); target.layout(); } }); final TextBox spacing = new TextBox(); spacing.setVisibleLength(4); spacing.addChangeHandler(new ChangeHandler() { public void onChange(ChangeEvent event) { try { getTargetLayout().setSpacing(Integer.parseInt(spacing.getText())); } catch (NumberFormatException e) { // ignore } target.layout(); } }); final Label bounds = new Label(); target.addLayoutHandler(new LayoutHandler() { public void onLayoutUpdated(LayoutEvent layoutEvent) { bounds.setText(LDOM.getBounds(target).toString()); column.setValue(getTargetLayout().isColumn()); spacing.setText(Integer.toString(getTargetLayout().getSpacing())); } }); demoList.addItem("Buttons & Body"); demoList.addItem("Sidebar & Margin"); demoList.addItem("Border Layout"); demoList.setSelectedIndex(0); Button add = new CssButton("Add Widget", new ClickHandler() { public void onClick(ClickEvent event) { target.add(new Thing("Widget-" + (target.getWidgetCount() + 1))); target.layout(); } }, "Add a new widget to the layout"); final Button go = new CssButton("Go", new ClickHandler() { public void onClick(ClickEvent event) { go(); } }, "Reset the layout to the selected state"); demoList.addChangeHandler(new ChangeHandler() { public void onChange(ChangeEvent event) { go.click(); } }); FormBuilder b = new FormBuilder(); b.add(add).label("Spacing").field(spacing).field(column).add("").field(bounds).wrap().width("100%") .add(demoList).add(go).endRow(); panel.add(b.getForm(), 22); panel.add(target, LayoutConstraints.HIDDEN); go(); }
From source file:net.opentsdb.tsd.client.DateTimeBox.java
License:Open Source License
public DateTimeBox() { super(new DateTimePicker(), null, DATE_FORMAT); ((DateTimePicker) getDatePicker()).setDateTimeBox(this); final TextBox textbox = getTextBox(); // Chrome 7.0.5xx versions, Safari 5.0.x and similar render a text box // that's too small for 19 characters (WTF?). So we ask for space for // an extra 2 characters. On Firefox the text box's width is computed // properly, so it simply appears slightly wider than necessary. textbox.setVisibleLength(19 + 2); textbox.setMaxLength(19);/*ww w . ja v a 2 s .c o m*/ }
From source file:org.drools.brms.client.modeldriven.ui.ActionSetFieldWidget.java
License:Apache License
private Widget valueEditor(final ActionFieldValue val) { String type = ""; if (this.completions.isGlobalVariable(this.model.variable)) { type = (String) this.completions.globalTypes.get(this.model.variable); } else {/* w w w. j ava 2s . c o m*/ type = this.modeller.getModel().getBoundFact(this.model.variable).factType; } String[] enums = this.completions.getEnums(type, this.model.fieldValues, val.field); if (enums != null && enums.length > 0) { return ConstraintValueEditor.enumDropDown(val.value, new ConstraintValueEditor.ValueChanged() { public void valueChanged(String newValue) { val.value = newValue; } }, enums); } else { SimplePanel panel = new SimplePanel(); final TextBox box = new TextBox(); box.setText(val.value); if (val.value.length() != 0) { box.setVisibleLength(val.value.length()); } if (val.type.equals(SuggestionCompletionEngine.TYPE_NUMERIC)) { box.addKeyboardListener(getNumericFilter(box)); } box.addChangeListener(new ChangeListener() { public void onChange(Widget w) { val.value = box.getText(); } }); box.addKeyboardListener(new FieldEditListener(new Command() { public void execute() { box.setVisibleLength(box.getText().length()); } })); panel.add(box); return panel; } }
From source file:org.drools.brms.client.modeldriven.ui.ConstraintValueEditor.java
License:Apache License
private TextBox boundTextBox(final ISingleFieldConstraint c) { final TextBox box = new TextBox(); box.setStyleName("constraint-value-Editor"); if (c.value == null) { box.setText(""); } else {/* w ww. j av a 2 s .co m*/ box.setText(c.value); } if (c.value == null || c.value.length() < 5) { box.setVisibleLength(3); } else { box.setVisibleLength(c.value.length() - 1); } box.addChangeListener(new ChangeListener() { public void onChange(Widget w) { c.value = box.getText(); makeDirty(); } }); box.addKeyboardListener(new FieldEditListener(new Command() { public void execute() { box.setVisibleLength(box.getText().length()); } })); return box; }
From source file:org.drools.brms.client.modeldriven.ui.FactPatternWidget.java
License:Apache License
/** * This adds in (optionally) the editor for changing the bound variable name. * If its a bindable pattern, it will show the editor, * if it is already bound, and the name is used, it should * not be editable.//w w w . ja va 2s . c om */ private void doBindingEditor(final FormStylePopup popup) { if (bindable && !(modeller.getModel().isBoundFactUsed(pattern.boundName))) { HorizontalPanel varName = new HorizontalPanel(); final TextBox varTxt = new TextBox(); if (pattern.boundName == null) { varTxt.setText(""); } else { varTxt.setText(pattern.boundName); } varTxt.setVisibleLength(3); varName.add(varTxt); Button bindVar = new Button("Set"); bindVar.addClickListener(new ClickListener() { public void onClick(Widget w) { String var = varTxt.getText(); if (modeller.isVariableNameUsed(var)) { Window.alert("The variable name [" + var + "] is already taken."); return; } pattern.boundName = varTxt.getText(); modeller.refreshWidget(); popup.hide(); } }); varName.add(bindVar); popup.addAttribute("Variable name", varName); } }
From source file:org.drools.brms.client.modeldriven.ui.RuleAttributeWidget.java
License:Apache License
private TextBox textBoxEditor(final RuleAttribute at) { final TextBox box = new TextBox(); box.setVisibleLength((at.value.length() < 3) ? 3 : at.value.length()); box.setText(at.value);//from ww w.j a v a 2 s . c o m box.addChangeListener(new ChangeListener() { public void onChange(Widget w) { at.value = box.getText(); makeDirty(); } }); if (at.attributeName.equals("date-effective") || at.attributeName.equals("date-expires")) { if (at.value == null || "".equals(at.value)) box.setText("dd-MMM-yyyy"); box.setVisibleLength(10); } box.addKeyboardListener(new KeyboardListener() { public void onKeyDown(Widget arg0, char arg1, int arg2) { } public void onKeyPress(Widget arg0, char arg1, int arg2) { } public void onKeyUp(Widget arg0, char arg1, int arg2) { box.setVisibleLength(box.getText().length()); } }); return box; }
From source file:org.drools.guvnor.client.asseteditor.drools.modeldriven.ui.ActionValueEditor.java
License:Apache License
private void attachDisplayLengthHandler(final TextBox box) { int length = box.getText().length(); box.setVisibleLength(length > 0 ? length : 1); box.addKeyUpHandler(new KeyUpHandler() { public void onKeyUp(KeyUpEvent event) { int length = box.getText().length(); box.setVisibleLength(length > 0 ? length : 1); }/*from w ww. ja v a 2 s . c o m*/ }); }