List of usage examples for com.google.gwt.user.client.ui Label Label
protected Label(Element element)
From source file:burrito.client.sitelet.SiteletEditPanel.java
License:Apache License
public SiteletEditPanel(String containerName, Long id) { this.containerName = containerName; wrapper.add(types);//from w ww .j a v a 2 s. com wrapper.add(editFormPlaceHolder); if (id.longValue() == -1L) { service.getSiteletTypes(new AsyncCallback<List<CrudEntityInfo>>() { public void onSuccess(List<CrudEntityInfo> result) { types.add(new Label(labels.selectSiteletType())); types.add(new VerticalSpacer(5)); for (CrudEntityInfo crudEntityInfo : result) { addEntityOption(crudEntityInfo); } } public void onFailure(Throwable caught) { throw new RuntimeException("Failed to get sitelet types"); } }); } else { service.getSitelet(id, new AsyncCallback<SiteletDescription>() { public void onSuccess(SiteletDescription result) { loadEntity(result.getEntityName(), result.getEntityId()); } public void onFailure(Throwable caught) { throw new RuntimeException("Failed to get sitelet", caught); } }); } initWidget(wrapper); }
From source file:burrito.client.widgets.blobstore.BlobStoreImageField.java
License:Apache License
public BlobStoreImageField(boolean required, Integer requiredWidth, Integer requiredHeight) { this.required = required; this.requiredWidth = requiredWidth; this.requiredHeight = requiredHeight; validationError.addStyleName("validationError"); validationError.setVisible(false);/* w w w .j av a 2 s. c o m*/ wrapper.add(validationError); String descText; if (requiredWidth != null) { if (requiredHeight != null) descText = messages.blobImageRequiredSize(requiredWidth, requiredHeight); else descText = messages.blobImageRequiredWidth(requiredWidth); } else { if (requiredHeight != null) descText = messages.blobImageRequiredHeight(requiredHeight); else descText = messages.blobImageAnySize(); } Label desc = new Label(descText); desc.addStyleName("k5-BlobStoreImageField-desc"); wrapper.add(desc); wrapper.add(imageWrapper); HorizontalPanel buttons = new HorizontalPanel(); changeImage.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { uploader.setVisible(true); changeImage.setVisible(false); } }); buttons.add(changeImage); changeImage.setVisible(false); deleteImage.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { blobStoreKey = null; updateImage(); fireChange(); updateDeleteButton(); } }); buttons.add(deleteImage); wrapper.add(buttons); updateDeleteButton(); createNewUploaderWidget(); initWidget(wrapper); addStyleName("k5-BlobStoreImageField"); }
From source file:burrito.client.widgets.date.DateTimePickerWidget.java
License:Apache License
public DateTimePickerWidget(boolean required) { initWidget(wrapper);/*w ww .java2 s. c o m*/ this.required = required; List<Integer> hoursModel = new ArrayList<Integer>(); for (int hour = 0; hour <= 23; hour++) { hoursModel.add(hour); } hourSelector.setModel(hoursModel); hourSelector.setLabelCreator(labelCreator); hourSelector.addChangeHandler(dateTimeChangeHandler); hourSelector.render(); List<Integer> minutesModel = new ArrayList<Integer>(); for (int minute = 0; minute <= 59; minute++) { minutesModel.add(minute); } minuteSelector.setModel(minutesModel); minuteSelector.setLabelCreator(labelCreator); minuteSelector.addChangeHandler(dateTimeChangeHandler); minuteSelector.render(); clear = new Anchor(messages.clear()); clear.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { clearFields(); } }); timeWrapper.add(hourSelector); timeWrapper.add(new Label(" : ")); timeWrapper.add(minuteSelector); wrapper.addStyleName("k5-DateTimePicker-wrapper"); dateBox.addStyleName("k5-DateTimePicker-datepicker"); dateBox.addValueChangeHandler(new ValueChangeHandler<Date>() { @Override public void onValueChange(ValueChangeEvent<Date> event) { update(event.getValue()); } }); dateBox.getTextBox().setTitle(messages.dateHelpText()); Label dateHeader = new Label(messages.date()); dateHeader.addStyleName("k5-DateTimePicker-dateHeader"); Label timeHeader = new Label(messages.time()); timeHeader.addStyleName("k5-DateTimePicker-timeheader"); errorMessage = new Label(); errorMessage.addStyleName("validationError"); wrapper.clear(); wrapper.setWidget(0, 0, dateHeader); wrapper.setWidget(0, 1, timeHeader); wrapper.setWidget(1, 0, dateBox); wrapper.setWidget(1, 1, timeWrapper); if (required) { wrapper.setWidget(1, 2, requiredStar); } wrapper.setWidget(2, 0, clear); setVisible(true); }
From source file:burrito.client.widgets.draganddrop.VerticalPanelWithSpacer.java
License:Apache License
public VerticalPanelWithSpacer() { Label spacer = new Label(""); spacer.setStyleName(CSS_CLASS); super.add(spacer); }
From source file:burrito.client.widgets.form.EditForm.java
License:Apache License
public void add(Widget widget, String label, String description) { if (widget instanceof HasValidators) { validateables.add((HasValidators) widget); }/*from w w w. j a va 2s.co m*/ if (widget instanceof HasKeyDownHandlers) { ((HasKeyDownHandlers) widget).addKeyDownHandler(saveEnablerKeyDownAction); } if (widget instanceof HasChangeHandlers) { ((HasChangeHandlers) widget).addChangeHandler(saveEnablerChangeHandler); } if (widget instanceof CheckBox) { ((CheckBox) widget).addClickHandler(saveEnablerClickHandler); } List<Widget> companionWidgets = new ArrayList<Widget>(); if (label == null) { label = ""; } Label l = new Label(label); l.addStyleName("k5-EditForm-label"); if (!widget.isVisible()) l.setVisible(false); main.getFlexCellFormatter().setRowSpan(this.currentRow, 0, 2); main.setWidget(this.currentRow, 0, l); companionWidgets.add(l); main.setWidget(this.currentRow, 1, widget); widget.addStyleName("cell-widget-inner"); main.getCellFormatter().addStyleName(this.currentRow, 1, "cell-widget"); main.getCellFormatter().addStyleName(this.currentRow, 0, "cell-label"); if (description == null) { description = ""; } this.currentRow++; Label desc = new Label(description); desc.addStyleName("k5-EditForm-description"); if (!widget.isVisible()) desc.setVisible(false); main.setWidget(this.currentRow, 0, desc); main.getCellFormatter().addStyleName(this.currentRow, 0, "cell-description"); companionWidgets.add(desc); this.currentRow++; VerticalSpacer spacer = new VerticalSpacer(10); main.setWidget(this.currentRow, 0, spacer); companionWidgets.add(spacer); this.currentRow++; companionWidgetsMap.put(widget, companionWidgets); }
From source file:burrito.client.widgets.inputfield.ListInputField.java
License:Apache License
public ListInputField(boolean required, boolean unique) { this.required = required; this.unique = unique; inputWrapper = new FlowPanel(); inputWrapper.add(field);//from w w w .j a va 2 s.c o m addButton = new Button(messages.add()); addButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { if (validateInputField()) { model.add(parseValue(field.getText())); onChange(model); field.setText(""); updateModelObjects(); } } }); if (required) { requiredStar = new Label("*"); inputWrapper.add(requiredStar); } inputWrapper.add(addButton); validationError = new Label(""); inputWrapper.add(validationError); wrapper.add(inputWrapper); listWrapper = new FlowPanel(); listWrapper.addStyleName("k5-ListInputField-listwrapper"); wrapper.add(listWrapper); initWidget(wrapper); wrapper.addStyleName("k5-ListInputField"); }
From source file:burrito.client.widgets.inputfield.ListInputField.java
License:Apache License
private Widget createObjectWidget(T modelObj) { final T value = modelObj; FlowPanel widget = new FlowPanel(); Label itemLabel = new Label(getDisplayString(modelObj)); itemLabel.addStyleName("k5-ListInputField-itemlabel"); widget.add(itemLabel);/*from ww w. j av a2 s . co m*/ PushButton removeButton = new PushButton(new Image(GWT.getModuleBaseURL() + "remove.png"), new ClickHandler() { @Override public void onClick(ClickEvent event) { remove(value); } }); removeButton.addStyleName("k5-ListInputField-remove"); widget.add(removeButton); widget.addStyleName("k5-ListInputField-listitem"); return widget; }
From source file:burrito.client.widgets.panels.table.PageController.java
License:Apache License
/** * Creates a new pagecontroller// w w w . jav a2 s.c o m * * @param showPageLabel * @param maxPagesShown * If not <code>null</code> then this will be the maximum number * of pages shown in the page controller. */ public PageController(boolean showPageLabel) { HorizontalPanel wrapper = new HorizontalPanel(); wrapper.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); wrapper.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT); if (showPageLabel) { Label label = new Label(messages.page()); label.addStyleName("k5-PageController-label"); wrapper.add(label); } next = new PushButton(new Image(GWT.getModuleBaseURL() + "images/page-next.png?v=2")); previous = new PushButton(new Image(GWT.getModuleBaseURL() + "images/page-previous.png?v=2")); next.getUpDisabledFace().setImage(new Image(GWT.getModuleBaseURL() + "images/page-next-disabled.png?v=2")); previous.getUpDisabledFace() .setImage(new Image(GWT.getModuleBaseURL() + "images/page-previous-disabled.png?v=2")); next.addStyleName("k5-PageController-nextButton"); previous.addStyleName("k5-PageController-previousButton"); currentPageLabel = createCurrentPageAnchor(); currentPageLabel.addStyleName("k5-PageController-link-selected"); next.setEnabled(false); previous.setEnabled(false); next.setTitle(messages.next()); previous.setTitle(messages.previous()); wrapper.add(previous); wrapper.add(currentPageLabel); wrapper.add(next); next.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { for (PageControllerHandler handler : handlers) { handler.loadPage(currentPageZeroIndexed + 1); } } }); previous.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { for (PageControllerHandler handler : handlers) { handler.loadPage(currentPageZeroIndexed - 1); } } }); initWidget(wrapper); addStyleName("k5-PageController"); setVisible(false); }
From source file:burrito.client.widgets.panels.table.Table.java
License:Apache License
/** * Creates a new table. Don't forget to make calls to addHeader(), * addCellRenderer() and render() after creating the object. * //from w ww . j a v a 2 s . c o m * @param numberOfColumns * The number of columns. Only count those that you will specify * (i.e. Don't count the select checkbox as a column) * @param rowsSelectable * true if rows should be selectable. This will work in * combination with addBatchAction() * @param rowsEditable * true if an edit-link should be rendered next to each row * @param rowsOrderable * true if rows should be able to re-order */ public Table(int numberOfColumns, boolean rowsSelectable, boolean rowsEditable, boolean rowsOrderable) { this.rowsSelectable = rowsSelectable; this.rowsEditable = rowsEditable; this.numberOfModelColumns = numberOfColumns; this.numberOfColumns = numberOfModelColumns; this.rowsOrderable = rowsOrderable; if (rowsSelectable) { this.numberOfColumns++; } if (rowsEditable) { this.numberOfColumns++; } if (rowsOrderable) { this.numberOfColumns++; } this.table = new Grid(1, this.numberOfColumns); this.loadingLabel = new Label(messages.loading()); FlowPanel centerWrapper = new FlowPanel(); centerWrapper.add(loadingLabel); centerWrapper.add(table); Button searchButton = new Button(messages.searchButton()); searchButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { load(0); } }); Button resetButton = new Button(messages.resetButton()); resetButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { filterText.setValue(""); load(0); } }); search.setVerticalAlignment(VerticalPanel.ALIGN_MIDDLE); search.setHorizontalAlignment(VerticalPanel.ALIGN_LEFT); search.add(new Label(messages.search())); search.add(filterText); search.add(searchButton); search.add(resetButton); search.setStyleName("k5-table-searchbox"); search.setVisible(false); centerWrapper.add(search); batchJobsWrapper.addStyleName("batchJobs"); dock.add(pageController, DockPanel.NORTH); dock.add(centerWrapper, DockPanel.CENTER); batchJobsWrapper.add(batchJobs); dock.add(batchJobsWrapper, DockPanel.SOUTH); pageController.addPageControllerHandler(new PageControllerHandler() { @Override public void loadPage(int zeroIndexedPage) { load(zeroIndexedPage); } }); initWidget(dock); this.setStyleName("k5-Table"); }
From source file:burrito.client.widgets.panels.table.Table.java
License:Apache License
/** * Adds a batch action to this table. A batch action is performed on * selected rows in the table./* ww w. j a va2s. co m*/ * * @param batchAction */ public void addBatchAction(final BatchAction<T> batchAction) { batchJobs.add(new VerticalSpacer(10)); HorizontalPanel hp = new HorizontalPanel(); hp.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); final Button b = new Button(batchAction.getButtonText()); ClickHandler ch = new ClickHandler() { @Override public void onClick(ClickEvent event) { final List<T> selected = getSelectedRows(); if (selected == null || selected.isEmpty()) { return; } batchAction.performAction(selected, new AsyncCallback<Void>() { @Override public void onSuccess(Void result) { b.setEnabled(true); b.removeStyleName("loading"); infoPopup.setTextAndShow(batchAction.getSuccessText(selected)); load(pageController.getCurrentPage()); } @Override public void onFailure(Throwable caught) { b.setEnabled(true); b.removeStyleName("loading"); throw new RuntimeException(caught); } }); b.setEnabled(false); b.addStyleName("loading"); } }; b.addClickHandler(ch); hp.add(b); hp.add(new Label(batchAction.getDescription())); batchJobs.add(hp); }