Java Code Examples for com.google.gwt.user.client.ui.TextBox

The following are top voted examples for showing how to use com.google.gwt.user.client.ui.TextBox. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: WebConsole   File: SlidingToolbar.java   View source code 7 votes vote down vote up
private void validateInput(TextBox input) {
	String inputStr = input.getValue();
	boolean valid = inputStr.matches("^\\d+$");
	
	if (valid) {
		input.getElement().removeClassName("invalid");
	} else {
		input.getElement().addClassName("invalid");
	}
	
	if (input == widthInput) {
		widthValid = valid;
	} else {
		heightValid = valid;
	}
}
 
Example 2
Project: EasyML   File: SqlETLGrid.java   View source code 6 votes vote down vote up
protected void init(){

		//Panel information
		this.setWidget(0,0,url);
		urlTB = new TextBox();
		urlTB.setStyleName("bda-etlpanel-textbox");
		this.setWidget(0,1,urlTB);

		this.setWidget(1,0,user);
		userTB = new TextBox();
		userTB.setStyleName("bda-etlpanel-textbox");
		this.setWidget(1,1,userTB);

		this.setWidget(2,0,password);
		passwordTB = new TextBox();
		passwordTB.setStyleName("bda-etlpanel-textbox");
		this.setWidget(2,1,passwordTB);


	}
 
Example 3
Project: unitimes   File: CourseNumbersSuggestBox.java   View source code 6 votes vote down vote up
private String getConfiguration() {
	String conf = iConfiguration;
	for (MatchResult matcher = iRegExp.exec(conf); matcher != null; matcher = iRegExp.exec(conf)) {
		Element element = DOM.getElementById(matcher.getGroup(1));
		String value = "";
		if ("select".equalsIgnoreCase(element.getTagName())) {
			ListBox list = ListBox.wrap(element);
			for (int i = 0; i < list.getItemCount(); i++) {
				if (list.isItemSelected(i))
					value += (value.isEmpty() ? "" : ",") + list.getValue(i);
			}
		} else if ("input".equalsIgnoreCase(element.getTagName())) {
			TextBox text = TextBox.wrap(element);
			value = text.getText();
		} else {
			Hidden hidden = Hidden.wrap(element);
			value = hidden.getValue();
		}
		conf = conf.replace("${" + matcher.getGroup(1) + "}", value);
	}
	return conf;
}
 
Example 4
Project: appinventor-extensions   File: GalleryPage.java   View source code 6 votes vote down vote up
/**
 * Helper method called by constructor to initialize the report section
 */
private void initAppShare() {
  final HTML sharePrompt = new HTML();
  sharePrompt.setHTML(MESSAGES.gallerySharePrompt());
  sharePrompt.addStyleName("primary-prompt");
  final TextBox urlText = new TextBox();
  urlText.addStyleName("action-textbox");
  urlText.setText(Window.Location.getHost() + MESSAGES.galleryGalleryIdAction() + app.getGalleryAppId());
  urlText.addClickHandler(new ClickHandler() {
    @Override
    public void onClick(ClickEvent event) {
      urlText.selectAll();
    }
  });
  appSharePanel.add(sharePrompt);
  appSharePanel.add(urlText);
}
 
Example 5
Project: appinventor-extensions   File: GalleryList.java   View source code 6 votes vote down vote up
/**
 * Creates the GUI components for search tab.
 *
 * @param searchApp: the FlowPanel that search tab will reside.
 */
private void addGallerySearchTab(FlowPanel searchApp) {
  // Add search GUI
  FlowPanel searchPanel = new FlowPanel();
  final TextBox searchText = new TextBox();
  searchText.addStyleName("gallery-search-textarea");
  Button sb = new Button(MESSAGES.gallerySearchForAppsButton());
  searchPanel.add(searchText);
  searchPanel.add(sb);
  searchPanel.addStyleName("gallery-search-panel");
  searchApp.add(searchPanel);
  appSearchContent.addStyleName("gallery-search-results");
  searchApp.add(appSearchContent);
  searchApp.addStyleName("gallery-search");

  sb.addClickHandler(new ClickHandler() {
    //  @Override
    public void onClick(ClickEvent event) {
      gallery.FindApps(searchText.getText(), 0, NUMAPPSTOSHOW, 0, true);
    }
  });
}
 
Example 6
Project: appinventor-extensions   File: LabeledTextBox.java   View source code 6 votes vote down vote up
/**
 * Use this TextBox if you want to have text validation while a user is typing
 *
 * @param caption    caption for leading label
 * @param validator  The validator to use for a specific textBox
 */
public LabeledTextBox(String caption, Validator validator) {
  this.validator = validator;

  HorizontalPanel panel = new HorizontalPanel();
  Label label = new Label(caption);
  panel.add(label);
  textbox = new TextBox();
  defaultTextBoxColor = textbox.getElement().getStyle().getBorderColor();
  textbox.setWidth("100%");
  panel.add(textbox);
  panel.setCellWidth(label, "40%");

  HorizontalPanel errorPanel = new HorizontalPanel();
  errorLabel = new Label("");
  errorPanel.add(errorLabel);

  VerticalPanel vp = new VerticalPanel();
  vp.add(panel);
  vp.add(errorPanel);
  vp.setHeight("85px");

  initWidget(vp);

  setWidth("100%");
}
 
Example 7
Project: WebConsole   File: FormField.java   View source code 6 votes vote down vote up
private void validateInput() {
	String value = "";
	switch (inputType) {
		case TEXTBOX:
			value = ((TextBox)input).getValue();
			break;
		case TEXTAREA:
			value = ((TextArea)input).getValue();
			break;
		case PASSWORD:
			value = ((PasswordTextBox)input).getValue();
			break;
	}
	if (isOptional && value.length() == 0) {
		setInputValid(true);
	} else {
		if (validationStr != null) {
			setInputValid(value.matches(validationStr));
		} else {
			setInputValid(true);
		}
	}
}
 
Example 8
Project: LAS   File: OptionsWidget.java   View source code 6 votes vote down vote up
public Map<String, String> getState() {
	Map<String, String> state = new HashMap<String, String>();
	for (Iterator widIt = widgets.iterator(); widIt.hasNext();) {
		Widget w = (Widget) widIt.next();
		if (w instanceof TextBox) {
			TextBox t = (TextBox) w;
			if (t.getText() != null && !t.getText().equals("")) {
				state.put(t.getName(), t.getText());
			}
		} else if (w instanceof ListBox) {
			ListBox l = (ListBox) w;
			state.put(l.getName(), l.getValue(l.getSelectedIndex()));
		}
	}
	return state;
}
 
Example 9
Project: tristar-eye   File: ClassicMapService.java   View source code 6 votes vote down vote up
private Autocomplete createAutoCompleteWithChangeListener(TextBox searchBox) {
    Element element = searchBox.getElement();
    final Autocomplete autoComplete = Autocomplete.newInstance(element, getAutoCompleteOptions());

    autoComplete.addPlaceChangeHandler(event -> {

        PlaceResult result = autoComplete.getPlace();

        PlaceGeometry geometry = result.getGeometry();
        LatLng center = geometry.getLocation();

        getMapWidget().panTo(center);
        getMapWidget().setZoom(ZOOM);
    });
    return autoComplete;
}
 
Example 10
Project: blogwt   File: UiHelper.java   View source code 6 votes vote down vote up
/**
 * Swaps a TextBox with an element of the same type for remember password. The text box needs to be within an panel. The styles of the text box are also
 * copied
 * 
 * @param textBox
 * @param elementId
 * @return
 */
@SuppressWarnings("unchecked")
public static <T extends TextBox> T swap (T textBox, String elementId) {
	Panel parent = (Panel) textBox.getParent();
	T newTextBox = null;

	if (textBox instanceof PasswordTextBox) {
		newTextBox = (T) PasswordTextBox
				.wrap(DOM.getElementById(elementId));
	} else if (textBox instanceof TextBox) {
		newTextBox = (T) TextBox.wrap(DOM.getElementById(elementId));
	}

	newTextBox.getElement().setAttribute("class",
			textBox.getElement().getAttribute("class"));
	newTextBox.removeFromParent();
	parent.getElement().insertBefore(newTextBox.getElement(),
			textBox.getElement());

	textBox.removeFromParent();

	return newTextBox;
}
 
Example 11
Project: gerrit-ci   File: JobPanels.java   View source code 6 votes vote down vote up
private static HTMLPanel getPublishPanel() {
    HTMLPanel publishPanel = new HTMLPanel(GerritCiPlugin.publishJobPanel.toString());
    TextBox publishCommand = new TextBox();
    publishCommand.setName("publishCommand");
    publishCommand.setText("./scripts/publish.sh");
    TextBox publishBranchRegex = new TextBox();
    publishBranchRegex.setName("publishBranchRegex");
    publishBranchRegex.setText("refs/heads/(develop|master)");
    TextBox jobType = new TextBox();
    jobType.setText("publish");
    jobType.setName("jobType");
    jobType.setVisible(false);
    publishPanel.add(jobType);
    publishPanel.addAndReplaceElement(publishCommand, "publishCommand");
    publishPanel.addAndReplaceElement(publishBranchRegex, "publishBranchRegex");
    addCommonFields(publishPanel);
    return publishPanel;
}
 
Example 12
Project: unitimes   File: CurriculaClassifications.java   View source code 5 votes vote down vote up
public Integer getProjection(int column) {
	String text = ((TextBox)iTable.getWidget(3, 1 + column)).getText();
	if (text.isEmpty()) return null;
	try {
		return Integer.parseInt(text);
	} catch (Exception e) {
		return null;
	}
}
 
Example 13
Project: unitimes   File: CurriculaClassifications.java   View source code 5 votes vote down vote up
public Integer getRequested(int column) {
	String text = ((TextBox)iTable.getWidget(6, 1 + column)).getText();
	if (text.isEmpty()) return null;
	try {
		return Integer.parseInt(text);
	} catch (Exception e) {
		return null;
	}
}
 
Example 14
Project: unitimes   File: CurriculaClassifications.java   View source code 5 votes vote down vote up
public Integer getSnapshotExpected(int column) {
	String text = ((TextBox)iTable.getWidget(7, 1 + column)).getText();
	if (text.isEmpty()) return null;
	try {
		return Integer.parseInt(text);
	} catch (Exception e) {
		return null;
	}
}
 
Example 15
Project: unitimes   File: CurriculaClassifications.java   View source code 5 votes vote down vote up
public Integer getSnapshotProjection(int column) {
	String text = ((TextBox)iTable.getWidget(8, 1 + column)).getText();
	if (text.isEmpty()) return null;
	try {
		return Integer.parseInt(text);
	} catch (Exception e) {
		return null;
	}
}
 
Example 16
Project: appinventor-extensions   File: LabeledTextBox.java   View source code 5 votes vote down vote up
/**
 * Creates a new TextBox with the given leading caption.
 *
 * @param caption  caption for leading label
 */
public LabeledTextBox(String caption) {
  HorizontalPanel panel = new HorizontalPanel();
  Label label = new Label(caption);
  panel.add(label);
  textbox = new TextBox();
  textbox.setWidth("100%");
  panel.add(textbox);
  panel.setCellWidth(label, "40%");

  initWidget(panel);

  setWidth("100%");
}
 
Example 17
Project: appinventor-extensions   File: AdditionalChoicePropertyEditor.java   View source code 5 votes vote down vote up
/**
 * Creates a new additional choice dialog.
 */
protected AdditionalChoicePropertyEditor() {
  summary = new TextBox();
  summary.setReadOnly(true);
  summary.addClickHandler(new ClickHandler() {
    @Override
    public void onClick(ClickEvent event) {
      openAdditionalChoiceDialog();
    }
  });

  initWidget(summary);
}
 
Example 18
Project: appinventor-extensions   File: ComponentImportWizard.java   View source code 5 votes vote down vote up
private Grid createUrlGrid() {
  TextBox urlTextBox = new TextBox();
  urlTextBox.setWidth("100%");
  Grid grid = new Grid(2, 1);
  grid.setWidget(0, 0, new Label("Url:"));
  grid.setWidget(1, 0, urlTextBox);
  return grid;
}
 
Example 19
Project: appinventor-extensions   File: MockListView.java   View source code 5 votes vote down vote up
private void createFilterBox() {
  textBoxWidget = new TextBox();
  textBoxWidget.setText("Search list...");
  textBoxWidget.setSize(ComponentConstants.LISTVIEW_PREFERRED_WIDTH + "px",
      ComponentConstants.LISTVIEW_FILTER_PREFERRED_HEIGHT + "px");
  textBoxWidget.setVisible(false);
  listViewWidget.add(textBoxWidget);
}
 
Example 20
Project: appinventor-extensions   File: MockTextBoxBase.java   View source code 5 votes vote down vote up
/**
 * Creates a new MockTextBox component.
 *
 * @param editor  editor of source file the component belongs to
 */
MockTextBoxBase(SimpleEditor editor, String type, ImageResource icon) {
  super(editor, type, icon);

  // Initialize mock textbox UI
  textBoxWidget = new TextBox();
  initWrapper(textBoxWidget);
}
 
Example 21
Project: WebConsole   File: FormField.java   View source code 5 votes vote down vote up
public void setValue(String value) {
	switch (inputType) {
		case TEXTBOX:
		case PASSWORD:
			((TextBox)input).setText(value); 
			break;
	}
}
 
Example 22
Project: WebConsole   File: FormField.java   View source code 5 votes vote down vote up
public String getValue() {
	String value = "";
	switch (inputType) {
		case TEXTBOX:
		case PASSWORD:
			value = ((TextBox)input).getText(); 
			break;
	}
	return value;
}
 
Example 23
Project: WebConsole   File: FormField.java   View source code 5 votes vote down vote up
@Override
public void onFocus(FocusEvent event) {
	// Force cursor to end of input
	if (input instanceof TextBox) {
		TextBox inputBox = (TextBox)input;
		inputBox.setCursorPos(inputBox.getText().length());
	}
}
 
Example 24
Project: LAS   File: LatLonWidget.java   View source code 5 votes vote down vote up
/**
	 * Constructs an empty widget.
	 */
	public LatLonWidget() {
		panel = new Grid(1,3);
		middle = new VerticalPanel();
		
		rose = new Image(GWT.getModuleBaseURL()+"../images/compass_rose.png");
		rose.addStyleName("OL_MAP-middle");

		southLat = new TextBox();
		northLat = new TextBox();

		southLat.setWidth(boxWidth);
		northLat.setWidth(boxWidth);

		eastLon = new TextBox();
		westLon = new TextBox();

		eastLon.setWidth(boxWidth);
		westLon.setWidth(boxWidth);
        
		panel.setWidget(0, 0, westLon);	
		middle.add(northLat);
		middle.add(rose);
		middle.add(southLat);
		panel.setWidget(0, 1, middle);
		panel.setWidget(0, 2, eastLon);
//		panel.getFlexCellFormatter().setColSpan(2, 0, 2);
		
		initWidget(panel);
	}
 
Example 25
Project: LAS   File: Correlation.java   View source code 5 votes vote down vote up
@Override
public void onChange(ChangeEvent event) {
	TextBox w = (TextBox) event.getSource();
	Widget wp = w.getParent();
	Widget gp = wp.getParent();
	if (gp instanceof VariableConstraintWidget) {
		VariableConstraintWidget vcw = (VariableConstraintWidget) gp;
		vcw.setApply(true);
	}
	setConstraints();
}
 
Example 26
Project: LAS   File: SimplePropPropViewer.java   View source code 5 votes vote down vote up
@Override
public void onChange(ChangeEvent event) {
    TextBox w = (TextBox) event.getSource();
    Widget wp = w.getParent();
    Widget gp = wp.getParent();
    if (gp instanceof VariableConstraintWidget) {
        VariableConstraintWidget vcw = (VariableConstraintWidget) gp;
        vcw.setApply(true);
    }
    setConstraints();
}
 
Example 27
Project: LAS   File: VariableMetadataActivity.java   View source code 5 votes vote down vote up
/**
 * @see com.google.gwt.event.logical.shared.SelectionHandler#onSelection(com.google.gwt.event.logical.shared.SelectionEvent)
 */
@Override
public void onSelection(SelectionEvent<TreeItem> event) {
    if ( (view != null) && (event != null) ) {
        Object source = event.getSource();
        // Only proceed if the source was from the same panel
        if ( (source != null) && (source instanceof HasName) ) {
            String sourceName = ((HasName) source).getName();
            if ( view.getName().equalsIgnoreCase(sourceName) ) {
                TextBox breadcrumbs = view.getBreadcrumbs();
                TreeItem selectedItem = event.getSelectedItem();
                if ( selectedItem != null ) {
                    String selectedItemText = selectedItem.getText();
                    // Only bother to update the bread crumbs if the
                    // user
                    // has
                    // selected an item that has actually loaded
                    if ( !selectedItemText.equalsIgnoreCase(DatasetWidget.LOADING) ) {
                        // Update bread crumbs by walking the meta data
                        // categories GUI tree already in memory
                        TreeItem parentItem = selectedItem.getParentItem();
                        if ( parentItem != null ) {
                            // First clear bread crumbs so events fire
                            // even
                            // when there is no change in
                            // breadcrumbsText
                            // characters, but set boolean fireEvents to
                            // false to avoid unnecessary event firing.
                            breadcrumbs.setValue("", false);
                            String breadcrumbsText = getBreadcrumbsText(parentItem);
                            breadcrumbs.setValue(breadcrumbsText, true);
                        }
                    }
                }
            }
        }
    }
}
 
Example 28
Project: autorest-nominatim-example   File: ExampleEntryPoint.java   View source code 5 votes vote down vote up
public void onModuleLoad() {
    PublishSubject<String> query = PublishSubject.create();

    TextBox text = new TextBox(); RootPanel.get().add(text);
    text.addValueChangeHandler(e -> query.onNext(e.getValue()));

    Button search = new Button("search"); RootPanel.get().add(search);
    search.addClickHandler(e -> query.onNext(text.getValue()));

    ListBox url = new ListBox(); RootPanel.get().add(url);
    url.addItem(NOMINATIM_OPENSTREETMAP);
    url.addItem("http://localhost:8080/");
    url.addChangeHandler(e -> query.onNext(text.getValue()));

    FlowPanel results = new FlowPanel(); RootPanel.get().add(results);

    // remember last selected server
    Storage storage = Storage.getLocalStorageIfSupported();
    if (storage != null) {
        try {
            url.setSelectedIndex(Integer.valueOf(storage.getItem("nominatim.url")));
        } catch (Exception ignore) {}
        url.addChangeHandler(c -> storage.setItem("nominatim.url", Integer.toString(url.getSelectedIndex())));
    }

    // on each tick, re-configure root resource and fire new request
    query.switchMap(q -> {
        results.clear();
        if (q == null || q.isEmpty()) return Observable.empty();
        Nominatim nominatim = new Nominatim_RestServiceModel(() -> osm(url.getSelectedItemText()));
        return nominatim.search(q, "json").doOnNext(n -> results.add(new Label(
                "[" + (int) (n.importance * 10.) + "] " + n.display_name + " (" + n.lon + "," + n.lat + ")")));
    }).retry((cnt, err) -> {
        GWT.log("request error: " + err, err); return true;
    }).subscribe();

     // fires initial search
    text.setValue("Málaga,España", true);
}
 
Example 29
Project: document-management-system   File: FileTextBox.java   View source code 5 votes vote down vote up
/**
 * File textBox
 */
public FileTextBox() {
	textBox = new TextBox();
	textBox.addKeyUpHandler(new KeyUpHandler() {
		@Override
		public void onKeyUp(KeyUpEvent event) {
			switch (event.getNativeKeyCode()) {
				case (char) KeyCodes.KEY_ENTER:
					switch (action) {
						case ACTION_RENAME:
							if (textBox.getText().length() > 0) {
								Main.get().mainPanel.desktop.browser.fileBrowser.rename(textBox.getText());
							} else {
								Main.get().mainPanel.desktop.browser.fileBrowser.hideRename();
							}
							break;
					}
					Main.get().mainPanel.enableKeyShorcuts(); // Enables general keys applications
					break;

				case (char) KeyCodes.KEY_ESCAPE:
					switch (action) {
						case ACTION_RENAME:
							Main.get().mainPanel.desktop.browser.fileBrowser.hideRename();
							break;
					}
					Main.get().mainPanel.enableKeyShorcuts(); // Enables general keys applications
					break;
			}
		}
	});
	textBox.setVisibleLength(20);
	textBox.setStyleName("okm-FileBrowser-TextBox");
	initWidget(textBox);
}
 
Example 30
Project: tristar-eye   File: ClassicMapService.java   View source code 5 votes vote down vote up
public void bindTextBoxWithAutoComplete(TextBox searchBox) {
    final Autocomplete autoComplete = createAutoCompleteWithChangeListener(searchBox);

    getMapWidget().addBoundsChangeHandler(event -> {
        LatLngBounds bounds = getMapWidget().getBounds();
        autoComplete.setBounds(bounds);
    });
}
 
Example 31
Project: MIBO-IDE   File: WCInspectorItem.java   View source code 5 votes vote down vote up
public void saveClicked() {
	
	// Save the information from the input elements
	// in the corresponding attribute models
	// Note: This does not contain any validation since this is done by
	// every model on its own.
	for (Map.Entry<Attribute, Object> entry : inputModelMap.entrySet())
	{
		if(entry.getValue() instanceof TextBox){
			TextBox text = (TextBox)entry.getValue();
			entry.getKey().setValue(text.getText());
		}
		else if(entry.getValue() instanceof Element){
			Element checkbox = (Element)entry.getValue();
			entry.getKey().setValue(checkbox.getPropertyString("checked"));
		}
	}
	WCEvent event = new WCEvent(this, WCEventType.INSPECTOR_ITEM_CLICK_SAVE);
	fireEvent(event);
}
 
Example 32
Project: x-cure-chat   File: FileUploadManagerDialog.java   View source code 5 votes vote down vote up
/**
 * Allows to add the hidden file upload form parameters, which will be send to the server.
 * Create a TextBox, giving it a name so that it will be submitted. From descendant dialogs,
 * has to be called only after the dialog is populated, i.e. the populateDialog() is executed.
 * @param fieldName the name of the parameter to add
 * @param fieldValue the value of the parameter to add
 */
protected void addHiddenUploadFormParameter( final String fieldName, final String fieldValue){
	final TextBox field = new TextBox();
	field.setVisible(false);
	field.setName( fieldName );
	field.setText( fieldValue );
	verticalPanel.add( field );
}
 
Example 33
Project: ephesoft   File: ValidatableWidget.java   View source code 5 votes vote down vote up
private void addValueChangeHandler() {
	if (this.widget != null && this.widget instanceof TextBox) {
		((TextBox) widget).addValueChangeHandler(new ValueChangeHandler<String>() {

			@Override
			public void onValueChange(ValueChangeEvent<String> val) {
				String value = val.getValue();
				if (value != null) {
					((TextBox) widget).setValue(value.trim());
				}
			}
		});
	}
}
 
Example 34
Project: dhcalc   File: GearPanel.java   View source code 5 votes vote down vote up
protected void renameItem() {
	final int i = savedItems.getSelectedIndex();

	if (i >= 0) {
		final String name = savedItems.getItemText(i);
		final String item = savedItems.getValue(i);

		final TextBox field = new TextBox();
		field.setText(name);

		ApplicationPanel.showDialogBox("Rename Item", field,
				ApplicationPanel.OK | ApplicationPanel.CANCEL,
				new DialogBoxResultHandler() {

					@Override
					public void dialogBoxResult(int result) {

						if (result == ApplicationPanel.OK) {
							JsoArray<Entry> list = removeItem(
									getSavedItems(), name, item);
							Entry e = (Entry) JavaScriptObject
									.createObject();
							e.setName(field.getText());
							e.setItem(item);
							list.push(e);
							saveItems(list);

							savedItems.removeItem(i);
							savedItems.insertItem(e.getName(), item, i);
							savedItems.setSelectedIndex(i);
						}

					}
				});
	}

}
 
Example 35
Project: gwtlib   File: PagingBar.java   View source code 5 votes vote down vote up
protected void updateGotoWidget(Widget widget) {
  widget.setVisible(computeNumPages() > 1);
  // Update allowed number of characters in the goto page textbox in case page size has changed (Yuck!)
  if(widget instanceof HorizontalPanel) {
    HorizontalPanel panel = (HorizontalPanel)widget;
    if(panel.getWidgetCount() == 3 && panel.getWidget(1) instanceof TextBox) {
      TextBox gotoPage = (TextBox)panel.getWidget(1);
      int maxlen = String.valueOf(computeNumPages()).length();
      gotoPage.setMaxLength(maxlen);
      gotoPage.setVisibleLength(maxlen);
    }
  }
}
 
Example 36
Project: onecmdb   File: NewURIFieldWidget.java   View source code 5 votes vote down vote up
public NewURIFieldWidget(AttributeValue v) {
	super(v.getLabel());
	this.value = v;
	if (value.getCtrl().isReadonly()) {
		HTML html = new HTML();
		if (!this.value.isNullValue()) {
			html.setHTML("<a href='javascript:;'>" + this.value.getStringValue() +"</a>");
		}
		html.addClickListener(new ClickListener() {

			public void onClick(Widget sender) {
				Window.open(value.getStringValue(), "_blank", "");
				
			}
			
		});
		
		html.setWordWrap(true);
		html.setTitle(this.value.getStringValue());
		addField(html);
		html.setStyleName("mdv-form-input-readonly");			
		setRequired(false);
		
	} else {
		box = new TextBox();
		box.setText(value.getStringValue());
		box.addKeyboardListener(this);
		setRequired(value.getCtrl().isRequiered());
		addField(box);
	}
	
}
 
Example 37
Project: gerrit-ci   File: JobPanels.java   View source code 5 votes vote down vote up
private static HTMLPanel getCronPanel() {
    HTMLPanel cronPanel = new HTMLPanel(GerritCiPlugin.cronPanel.toString());
    TextBox cronCommand = new TextBox();
    cronCommand.setName("cronCommand");
    cronCommand.setText("./scripts/cron.sh");
    TextBox cronSchedule = new TextBox();
    cronSchedule.setName("cronJob");
    TextBox jobType = new TextBox();
    jobType.setText("cron");
    jobType.setName("jobType");
    jobType.setVisible(false);
    cronPanel.add(jobType);
    cronPanel.addAndReplaceElement(cronCommand, "cronCommand");
    cronPanel.addAndReplaceElement(cronSchedule, "cronJob");
    addCommonFields(cronPanel);
    return cronPanel;
}
 
Example 38
Project: gwtlib   File: MessageBox.java   View source code 5 votes vote down vote up
public static MessageBox prompt(String caption, String message, boolean asHTML, 
                                boolean multiline, int buttons, MessageBoxListener listener) {
  final MessageBox mb = new MessageBox();
  mb.setText(caption);
  mb.setButtons(buttons, listener);
  mb._dockPanel.add(asHTML ? new HTML(message) : new Label(message), DockPanel.NORTH);
  if(multiline) {
    mb._textArea = new TextArea();
    mb._dockPanel.add(mb._textArea, DockPanel.CENTER);
    mb.center();
    mb._textArea.setFocus(true);
  } else {
    mb._textBox = new TextBox();
    mb._dockPanel.add(mb._textBox, DockPanel.CENTER);
    mb.center();
    mb._textBox.setFocus(true);
  }
  return mb;
}
 
Example 39
Project: dhcalc   File: BasePanel.java   View source code 5 votes vote down vote up
protected double getValue(TextBox textBox) {

		try {
			String text = textBox.getText();
			return Double.valueOf(text);
		} catch (Exception e) {
			textBox.setValue("0");
			return 0.0;
		}
	}
 
Example 40
Project: ephesoft   File: LandingPresenter.java   View source code 5 votes vote down vote up
private boolean checkTextEntered(TextBox searchBatchTextBox) {
	boolean check = true;
	if (searchBatchTextBox == null || searchBatchTextBox.getText().isEmpty()) {
		check = false;
	}
	return check;
}