List of usage examples for com.google.gwt.user.client.ui Label Label
public Label()
From source file:client.reservation.panel.RefreshReservationPanel.java
License:Open Source License
/** * Constructor. Create the whole panel at once. * // w ww.j av a 2 s. com * @param callback * Callback Object which gets the Refresh parameters. * @param list * ListPanel which should be attached to the refresh Panel. */ public RefreshReservationPanel(final AsyncCallback callback, final ListPanel list) { final Label labelOne = new Label(); labelOne.setText("Period: "); // TODO: user those values?? this.dropdown = new ListBox(); this.dropdown.addItem("Now", "0"); this.dropdown.addItem("1 Hour", "1"); this.dropdown.addItem("3 Hours", "3"); this.dropdown.addItem("1 Day", "24"); this.dropdown.addItem("3 Days", "72"); this.dropdown.addItem("1 Week", "168"); // activity indicator this.button = new Button(); this.button.setText("refresh"); this.activity = new Image("ajaxloader.gif"); this.activity.setVisible(false); // tell refresh-Button which elements to update final RefreshButtonListener listener = new RefreshButtonListener(); listener.setButton(this.button); listener.setActivity(this.activity); listener.setCallback(callback); listener.setList(list); listener.setListBox(this.dropdown); this.button.addClickListener(listener); this.add(labelOne); this.add(this.dropdown); this.add(this.button); this.add(this.activity); this.setStyleName("res-Top"); this.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT); }
From source file:com.achow101.bctalkaccountpricer.client.Bitcointalk_Account_Pricer.java
License:Open Source License
/** * This is the entry point method./*www . ja va2 s . co m*/ */ public void onModuleLoad() { // Add Gui stuff final Button sendButton = new Button("Estimate Price"); final TextBox nameField = new TextBox(); nameField.setText("User ID/Token"); final Label errorLabel = new Label(); final Label uidLabel = new Label(); final Label usernameLabel = new Label(); final Label postsLabel = new Label(); final Label activityLabel = new Label(); final Label potActivityLabel = new Label(); final Label postQualityLabel = new Label(); final Label trustLabel = new Label(); final Label priceLabel = new Label(); final Label loadingLabel = new Label(); final Label tokenLabel = new Label(); final InlineHTML estimateShareLabel = new InlineHTML(); final InlineHTML reportTimeStamp = new InlineHTML(); final RadioButton radioNormal = new RadioButton("merch", "Normal"); final RadioButton radioMerchant = new RadioButton("merch", "Merchant"); // We can add style names to widgets sendButton.addStyleName("sendButton"); radioNormal.setValue(true); radioMerchant.setValue(false); // Add the nameField and sendButton to the RootPanel // Use RootPanel.get() to get the entire body element RootPanel.get("nameFieldContainer").add(nameField); RootPanel.get("sendButtonContainer").add(sendButton); RootPanel.get("errorLabelContainer").add(errorLabel); RootPanel.get("uidLabelContainer").add(uidLabel); RootPanel.get("usernameLabelContainer").add(usernameLabel); RootPanel.get("postsLabelContainer").add(postsLabel); RootPanel.get("activityLabelContainer").add(activityLabel); RootPanel.get("potActivityLabelContainer").add(potActivityLabel); RootPanel.get("postQualityLabelContainer").add(postQualityLabel); RootPanel.get("trustLabelContainer").add(trustLabel); RootPanel.get("priceLabelContainer").add(priceLabel); RootPanel.get("loadingLabelContainer").add(loadingLabel); RootPanel.get("tokenLabelContainer").add(tokenLabel); RootPanel.get("tokenShareLabelContainer").add(estimateShareLabel); RootPanel.get("radioNormalContainer").add(radioNormal); RootPanel.get("radioMerchantContainer").add(radioMerchant); RootPanel.get("reportTimeStamp").add(reportTimeStamp); // Create activity breakdown panel final VerticalPanel actPanel = new VerticalPanel(); final FlexTable actTable = new FlexTable(); actPanel.add(actTable); RootPanel.get("activityBreakdown").add(actPanel); // Create posts breakdown panel final VerticalPanel postsPanel = new VerticalPanel(); final FlexTable postsTable = new FlexTable(); postsPanel.add(postsTable); RootPanel.get("postsBreakdown").add(postsPanel); // Create addresses breakdown panel final VerticalPanel addrPanel = new VerticalPanel(); final FlexTable addrTable = new FlexTable(); postsPanel.add(addrTable); RootPanel.get("addrBreakdown").add(addrTable); // Focus the cursor on the name field when the app loads nameField.setFocus(true); nameField.selectAll(); // Create a handler for the sendButton and nameField class MyHandler implements ClickHandler, KeyUpHandler { /** * Fired when the user clicks on the sendButton. */ public void onClick(ClickEvent event) { // Add request to queue addToQueue(); } /** * Fired when the user types in the nameField. */ public void onKeyUp(KeyUpEvent event) { if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) { addToQueue(); } } // Adds the request to server queue private void addToQueue() { // Clear previous output uidLabel.setText(""); usernameLabel.setText(""); postsLabel.setText(""); activityLabel.setText(""); potActivityLabel.setText(""); postQualityLabel.setText(""); trustLabel.setText(""); priceLabel.setText(""); sendButton.setEnabled(false); errorLabel.setText(""); loadingLabel.setText(""); tokenLabel.setText(""); estimateShareLabel.setText(""); reportTimeStamp.setText(""); actTable.removeAllRows(); postsTable.removeAllRows(); addrTable.removeAllRows(); // Create and add request request = new QueueRequest(); request.setMerchant(radioMerchant.getValue()); if (nameField.getText().matches("^[0-9]+$")) request.setUid(Integer.parseInt(escapeHtml(nameField.getText()))); else { request.setToken(escapeHtml(nameField.getText())); request.setOldReq(); } final String urlPath = com.google.gwt.user.client.Window.Location.getPath(); final String host = com.google.gwt.user.client.Window.Location.getHost(); final String protocol = com.google.gwt.user.client.Window.Location.getProtocol(); final String url = protocol + "//" + host + urlPath + "?token="; // Request check loop Timer requestTimer = new Timer() { public void run() { // send request to server pricingService.queueServer(request, new AsyncCallback<QueueRequest>() { @Override public void onFailure(Throwable caught) { errorLabel.setText("Request Queuing failed. Please try again."); sendButton.setEnabled(true); pricingService.removeRequest(request, null); cancel(); } @Override public void onSuccess(QueueRequest result) { if (result.getQueuePos() == -3) { loadingLabel.setText( "Please wait for your previous request to finish and try again"); sendButton.setEnabled(true); cancel(); } else if (result.getQueuePos() == -2) { loadingLabel.setText("Please wait 2 minutes before requesting again."); sendButton.setEnabled(true); cancel(); } else if (result.getQueuePos() == -4) { loadingLabel.setText("Invalid token"); sendButton.setEnabled(true); cancel(); } else { tokenLabel.setText("Your token is " + result.getToken()); estimateShareLabel.setHTML("Share this estimate: <a href=\"" + url + result.getToken() + "\">" + url + result.getToken() + "</a>"); if (!result.isProcessing() && !result.isDone()) { loadingLabel.setText("Please wait. You are number " + result.getQueuePos() + " in the queue."); } if (result.isProcessing()) { loadingLabel.setText("Request is processing. Please wait."); } if (result.isDone()) { // Clear other messages errorLabel.setText(""); loadingLabel.setText(""); // Output results uidLabel.setText(result.getResult()[0]); usernameLabel.setText(result.getResult()[1]); postsLabel.setText(result.getResult()[2]); activityLabel.setText(result.getResult()[3]); potActivityLabel.setText(result.getResult()[4]); postQualityLabel.setText(result.getResult()[5]); trustLabel.setText(result.getResult()[6]); priceLabel.setText(result.getResult()[7]); int indexOfLastAct = 0; int startAddrIndex = 0; for (int i = 8; i < result.getResult().length; i++) { if (result.getResult()[i].equals("<b>Post Sections Breakdown</b>")) { indexOfLastAct = i; break; } actTable.setHTML(i - 8, 0, result.getResult()[i]); } for (int i = indexOfLastAct; i < result.getResult().length; i++) { if (result.getResult()[i] .contains("<b>Addresses posted in non-quoted text</b>")) { startAddrIndex = i; break; } postsTable.setHTML(i - indexOfLastAct, 0, result.getResult()[i]); } if (!result.isMerchant()) { for (int i = startAddrIndex; i < result.getResult().length; i++) { addrTable.setHTML(i - startAddrIndex, 0, result.getResult()[i]); } } // Set the right radio radioMerchant.setValue(result.isMerchant()); radioNormal.setValue(!result.isMerchant()); // Report the time stamp DateTimeFormat fmt = DateTimeFormat.getFormat("MMMM dd, yyyy, hh:mm:ss a"); Date completedDate = new Date(1000L * result.getCompletedTime()); Date expireDate = new Date( 1000L * (result.getCompletedTime() + result.getExpirationTime())); reportTimeStamp .setHTML("<i>Report generated at " + fmt.format(completedDate) + " and expires at " + fmt.format(expireDate) + "</i>"); // Kill the timer after everything is done cancel(); } request = result; request.setPoll(true); sendButton.setEnabled(true); } } }); } }; requestTimer.scheduleRepeating(2000); } } // Add a handler to send the name to the server MyHandler handler = new MyHandler(); sendButton.addClickHandler(handler); nameField.addKeyUpHandler(handler); // Check the URL for URL parameters String urlTokenParam = com.google.gwt.user.client.Window.Location.getParameter("token"); if (!urlTokenParam.isEmpty()) { nameField.setText(urlTokenParam); handler.addToQueue(); } }
From source file:com.ait.toolkit.clientio.uploader.client.Uploader.java
License:Apache License
@Override protected void onLoad() { // Make sure our entire panel fits the size that they wanted for the button if (this.buttonWidth >= 0) { this.setWidth(this.buttonWidth + "px"); }/*from w w w .j av a2s .com*/ if (this.buttonHeight >= 0) { this.setHeight(this.buttonHeight + "px"); } if (ajaxUploadEnabled && isAjaxUploadWithProgressEventsSupported()) { // If the browser supports the XMLHttpRequest Level 2 type then we can avoid rendering the flash component // and just stick with a DOM/Ajax approach. // Use a hidden file input component to handle allowing the user to popup the file system dialog // (but keep it outside of the button itself so it doesn't interfere with the mouse events) this.add(createFileUpload()); // Create the main element that will hold all of the inner workings of the uploader component Label button = new Label(); button.setWidth("100%"); button.setHeight("100%"); if (this.buttonCursor != null) { switch (this.buttonCursor) { case ARROW: button.getElement().getStyle().setCursor(Style.Cursor.DEFAULT); break; case HAND: button.getElement().getStyle().setCursor(Style.Cursor.POINTER); break; } } // Setup what we want to happen when someone clicks anywhere on the button button.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { if (buttonDisabled) { return; } switch (buttonAction) { case START_UPLOAD: startUpload(); break; case SELECT_FILES: openFileDialog(fileUpload, true); break; case SELECT_FILE: default: openFileDialog(fileUpload, false); break; } } }); button.addMouseOverHandler(new MouseOverHandler() { public void onMouseOver(MouseOverEvent event) { if (buttonImageURL != null && buttonHeight >= 0 && !buttonDisabled) { buttonImageElement.getStyle().setProperty("backgroundPosition", "0px -" + buttonHeight + "px"); } } }); button.addMouseOutHandler(new MouseOutHandler() { public void onMouseOut(MouseOutEvent event) { if (buttonImageURL != null && buttonHeight >= 0 && !buttonDisabled) { buttonImageElement.getStyle().setProperty("backgroundPosition", "0px 0px"); } } }); button.addMouseDownHandler(new MouseDownHandler() { public void onMouseDown(MouseDownEvent event) { if (buttonImageURL != null && buttonHeight >= 0 && !buttonDisabled) { buttonImageElement.getStyle().setProperty("backgroundPosition", "0px -" + (buttonHeight * 2) + "px"); } } }); button.addMouseUpHandler(new MouseUpHandler() { public void onMouseUp(MouseUpEvent event) { if (buttonImageURL != null && buttonHeight >= 0 && !buttonDisabled) { buttonImageElement.getStyle().setProperty("backgroundPosition", "0px 0px"); } } }); // Depending on the way they wanted the uploader button rendered, create the appropriate elements // in the DOM that the user will click on. if (this.buttonTextStyle != null) { buttonTextStyleElement = Document.get().createStyleElement(); buttonTextStyleElement.setInnerText(this.buttonTextStyle); button.getElement().appendChild(buttonTextStyleElement); } if (this.buttonText != null) { buttonTextElement = Document.get().createDivElement(); buttonTextElement.setInnerHTML(this.buttonText); buttonTextElement.getStyle().setWidth(100, Style.Unit.PCT); buttonTextElement.getStyle().setHeight(100, Style.Unit.PCT); if (this.buttonTextLeftPadding > Integer.MIN_VALUE) { buttonTextElement.getStyle().setPaddingLeft(this.buttonTextLeftPadding, Style.Unit.PX); } if (this.buttonTextTopPadding > Integer.MIN_VALUE) { buttonTextElement.getStyle().setPaddingTop(this.buttonTextTopPadding, Style.Unit.PX); } button.getElement().appendChild(buttonTextElement); } if (this.buttonImageURL != null) { buttonImageElement = Document.get().createDivElement(); buttonImageElement.getStyle().setBackgroundImage("url(\"" + this.buttonImageURL + "\")"); if (this.buttonDisabled) { buttonImageElement.getStyle().setProperty("backgroundPosition", "0px -" + (buttonHeight * 3) + "px"); } else { buttonImageElement.getStyle().setProperty("backgroundPosition", "0px 0px"); } buttonImageElement.getStyle().setWidth(100, Style.Unit.PCT); buttonImageElement.getStyle().setHeight(100, Style.Unit.PCT); button.getElement().appendChild(buttonImageElement); } // Add the entire button to the DOM this.add(button); } else { // If the browser doesn't support the XMLHttpRequest Level 2 type, then our only option is to use // the Flash/SWFUpload component. // The SWFUpload JS code completely replaces the DOM element that you give it as a target, // so we're creating an inner component that it can replace - leaving the outer component // for the caller to use as the GWT Widget that they can manage and style within the appropriate // container within their GWT application DivElement swfUploadElement = Document.get().createDivElement(); swfUploadElement.setId(Document.get().createUniqueId()); this.getElement().appendChild(swfUploadElement); JavaScriptObject nativeOptions = createNativeOptions(swfUploadElement.getId()); // Build a map that we'll use during the native creation process to setup // the necessary JSNI bridges to our Java event handlers... JSONObject eventHandlers = new JSONObject(); eventHandlers.put("swfupload_loaded_handler", JSONBoolean.getInstance(swfUploadLoadedHandler != null)); eventHandlers.put("file_dialog_start_handler", JSONBoolean.getInstance(fileDialogStartHandler != null)); eventHandlers.put("file_queued_handler", JSONBoolean.getInstance(fileQueuedHandler != null)); eventHandlers.put("file_queue_error_handler", JSONBoolean.getInstance(fileQueueErrorHandler != null)); eventHandlers.put("file_dialog_complete_handler", JSONBoolean.getInstance(fileDialogCompleteHandler != null)); eventHandlers.put("upload_start_handler", JSONBoolean.getInstance(uploadStartHandler != null)); eventHandlers.put("upload_progress_handler", JSONBoolean.getInstance(uploadProgressHandler != null)); eventHandlers.put("upload_error_handler", JSONBoolean.getInstance(uploadErrorHandler != null)); eventHandlers.put("upload_success_handler", JSONBoolean.getInstance(uploadSuccessHandler != null)); eventHandlers.put("upload_complete_handler", JSONBoolean.getInstance(uploadCompleteHandler != null)); swfUpload = nativeCreateSWFUpload(nativeOptions, eventHandlers.getJavaScriptObject()); } }
From source file:com.algorithmstudy.visualizer.client.sort.BarChartVisualizer.java
License:Open Source License
public BarChartVisualizer(int[] elements, boolean isSingle) { setStyleName(STYLE_BAR_CHART);/* www . j av a 2 s . com*/ HorizontalPanel timePanel = new HorizontalPanel(); timePanel.setWidth("100%"); timePanel.setHorizontalAlignment(HorizontalPanel.ALIGN_RIGHT); movesLabel = new Label(); movesLabel.setStyleName(STYLE_MOVES_LABEL); movesLabel.setText(MOVES_BASE + "0"); movesLabel.setWidth("8em"); numberOfMoves = 0; timePanel.add(movesLabel); this.add(timePanel); chart = new Chart(elements, isSingle); this.add(chart); }
From source file:com.alkacon.geranium.client.ui.input.ErrorWidget.java
License:Open Source License
/** * Creates the a new error label.<p> * /*from ww w .j av a2 s .co m*/ * @return a label with the appropriate style for an error label */ private static Label createErrorLabel() { Label label = new Label(); label.addStyleName(I_LayoutBundle.INSTANCE.generalCss().cornerAll()); label.addStyleName(I_InputLayoutBundle.INSTANCE.inputCss().error()); return label; }
From source file:com.apress.progwt.client.gui.timeline.ZoomableTimeline.java
License:Apache License
private void createDecorations() { whenlabel = new Label(); magBig = ConstHolder.images.magnifyingBig().createImage(); magBig.addClickListener(new ClickListener() { public void onClick(Widget arg0) { zoomIn();/*from w w w.j av a 2 s. c o m*/ } }); magSmall = ConstHolder.images.magnifyingSmall().createImage(); magSmall.addClickListener(new ClickListener() { public void onClick(Widget arg0) { zoomOut(); } }); editWidget = new SimplePanel(); add(editWidget); add(magSmall); add(whenlabel); add(magBig); }
From source file:com.arcbees.chosen.integrationtest.client.testcases.SimpleMultiValueListBoxOnChange.java
License:Apache License
@Override public void run() { super.run();/*w ww .ja v a 2 s . c om*/ final Label label = new Label(); label.getElement().setId(LABEL_ID); getListBox().addValueChangeHandler(new ValueChangeHandler<List<CarBrand>>() { @Override public void onValueChange(ValueChangeEvent<List<CarBrand>> event) { label.setText(joinValues(event.getValue())); } }); RootPanel.get().add(label); }
From source file:com.arcbees.chosen.integrationtest.client.testcases.SimpleValueListBoxOnChange.java
License:Apache License
@Override public void run() { super.run();/*from w w w.ja v a 2 s . com*/ final Label label = new Label(); label.getElement().setId(LABEL_ID); getListBox().addValueChangeHandler(new ValueChangeHandler<CarBrand>() { @Override public void onValueChange(ValueChangeEvent<CarBrand> event) { CarBrand value = event.getValue(); label.setText(value == null ? "" : value.name()); } }); RootPanel.get().add(label); }
From source file:com.areahomeschoolers.baconbits.client.content.calendar.dayview.DayViewHeader.java
License:Open Source License
public void setDays(Date date, int days) { dayPanel.clear();//from w w w .j a v a2s . c o m weekPanel.clear(); float dayWidth = 100f / days; float dayLeft; int week = DateUtils.calendarWeekIso(date); int previousDayWeek = week; Date previousDate = date; float weekWidth = 0f; float weekLeft = 0f; for (int i = 0; i < days; i++) { // set the left position of the day splitter to // the width * incremented value dayLeft = dayWidth * i; // increment the date by 1 if (i > 0) { DateUtils.moveOneDayForward(date); } else { // initialize the week values weekLeft = dayLeft; weekWidth = dayWidth; } String headerTitle = CalendarFormat.INSTANCE.getDateFormat().format(date); Label dayLabel = new Label(); dayLabel.setStylePrimaryName("day-cell"); dayLabel.setWidth(dayWidth + "%"); dayLabel.setText(headerTitle); DOM.setStyleAttribute(dayLabel.getElement(), "left", dayLeft + "%"); addDayClickHandler(dayLabel, (Date) date.clone()); boolean found = false; for (Date day : settings.getSettings().getHolidays()) { if (DateUtils.areOnTheSameDay(day, date)) { dayLabel.setStyleName("day-cell-holiday"); found = true; break; } } // set the style of the header to show that it is today if (DateUtils.areOnTheSameDay(new Date(), date)) { dayLabel.setStyleName("day-cell-today"); } else if (!found && DateUtils.isWeekend(date)) { dayLabel.setStyleName("day-cell-weekend"); } if (showWeekNumbers) { week = DateUtils.calendarWeekIso(date); boolean lastDay = i + 1 == days; if ((previousDayWeek != week) || lastDay) { if (lastDay) { previousDayWeek = week; previousDate = date; } String weekTitle = "W " + previousDayWeek; Label weekLabel = new Label(); weekLabel.setStylePrimaryName("week-cell"); weekLabel.setWidth(weekWidth + "%"); weekLabel.setText(weekTitle); DOM.setStyleAttribute(weekLabel.getElement(), "left", weekLeft + "%"); addWeekClickHandler(weekLabel, previousDate); weekPanel.add(weekLabel); weekWidth = dayWidth; weekLeft = dayLeft + dayWidth; } else { weekWidth += dayWidth; } previousDayWeek = week; previousDate = date; } dayPanel.add(dayLabel); } }
From source file:com.bedatadriven.renjin.appengine.client.CommandPrompt.java
License:Apache License
public CommandPrompt(CommandEnteredCallback callback) { panel = new HorizontalPanel(); prompt = new Label(); prompt.setStyleName("prompt"); panel.add(prompt);//ww w. j a va2s .c om inputArea = new TextArea(); inputArea.setStyleName("script"); inputArea.setVisibleLines(2); inputAreaDiv = new SimplePanel(); inputAreaDiv.add(inputArea); inputAreaDiv.getElement().getStyle().setProperty("width", "100%"); panel.add(inputAreaDiv); panel.setCellWidth(inputAreaDiv, "100%"); updatePromptText(); inputArea.addKeyDownHandler(new KeyDownHandler() { public void onKeyDown(KeyDownEvent event) { onInputAreaKeyDown(event); } }); history = new CommandHistory(); commandEnteredCallback = callback; }