List of usage examples for com.google.gwt.user.client.ui Label setText
public void setText(String text)
From source file:es.deusto.weblab.client.lab.ui.themes.es.deusto.weblab.defaultmobile.LoginWindow.java
License:Open Source License
private void hideError(Label where) { where.setText(""); where.setStyleName(".invisible"); }
From source file:eu.cloud4soa.gwt.client.Application.java
License:Apache License
/** * This is the entry point method.// w w w. j a va 2 s . c o m */ public void onModuleLoad() { final Button sendButton = new Button("Try UC9 Sequence"); final TextBox nameField = new TextBox(); nameField.setText("webapp"); final Label errorLabel = new Label(); // We can add style names to widgets sendButton.addStyleName("sendButton"); // 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); // Focus the cursor on the name field when the app loads nameField.setFocus(true); nameField.selectAll(); // Create the popup dialog box final DialogBox dialogBox = new DialogBox(); dialogBox.setText("Remote Procedure Call"); dialogBox.setAnimationEnabled(true); final Button closeButton = new Button("Close"); // We can set the id of a widget by accessing its Element closeButton.getElement().setId("closeButton"); final Label textToServerLabel = new Label(); final HTML serverResponseLabel = new HTML(); VerticalPanel dialogVPanel = new VerticalPanel(); dialogVPanel.addStyleName("dialogVPanel"); dialogVPanel.add(new HTML("<b>Sending application to the server:</b>")); dialogVPanel.add(textToServerLabel); dialogVPanel.add(new HTML("<br><b>Server replies:</b>")); dialogVPanel.add(serverResponseLabel); dialogVPanel.setHorizontalAlignment(VerticalPanel.ALIGN_RIGHT); dialogVPanel.add(closeButton); dialogBox.setWidget(dialogVPanel); // Add a handler to close the DialogBox closeButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { dialogBox.hide(); sendButton.setEnabled(true); sendButton.setFocus(true); } }); // 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) { sendNameToServer(); } /** * Fired when the user types in the nameField. */ public void onKeyUp(KeyUpEvent event) { if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) { sendNameToServer(); } } /** * Send the name from the nameField to the server and wait for a response. */ private void sendNameToServer() { // First, we validate the input. errorLabel.setText(""); String textToServer = nameField.getText(); if (!FieldVerifier.isValidName(textToServer)) { errorLabel.setText("Please enter at least four characters"); return; } // Then, we send the input to the server. sendButton.setEnabled(false); textToServerLabel.setText(textToServer); serverResponseLabel.setText(""); greetingService.greetServer(textToServer, new AsyncCallback<String>() { public void onFailure(Throwable caught) { // Show the RPC error message to the user dialogBox.setText("Remote Procedure Call - Failure"); serverResponseLabel.addStyleName("serverResponseLabelError"); serverResponseLabel.setHTML(SERVER_ERROR); dialogBox.center(); closeButton.setFocus(true); } public void onSuccess(String result) { dialogBox.setText("Remote Procedure Call"); serverResponseLabel.removeStyleName("serverResponseLabelError"); serverResponseLabel.setHTML(result); dialogBox.center(); closeButton.setFocus(true); } }); } } // Add a handler to send the name to the server MyHandler handler = new MyHandler(); sendButton.addClickHandler(handler); nameField.addKeyUpHandler(handler); }
From source file:fi.jyu.student.jatahama.onlineinquirytool.client.ClaimAnalysisPanel.java
License:Open Source License
public ClaimAnalysisPanel(OnlineInquiryTool parent) { super();//w w w . j av a 2 s.co m // Add debug info if it exists if (_debug_info != null) { add(_debug_info); //_debug_info.setVisible(false); } // Group wrapper that wraps all hozontal and vertival grouping groupWrapper.setStyleName("cap-group-wrapper"); // Init Group wrapper fills (used for spacing at top and bottom) for (int i = 0; i < groupWrapperFill.length; i++) { groupWrapperFill[i].setStyleName("cap-group-wrapper-fill"); } // Init vertical groupings (perspectives, arguments, counter-arguments) for (int i = 0; i < vGroups.length; i++) { groupWrapper.add(vGroups[i]); vGroups[i].setStyleName("cap-vertical-grouping"); } // Claim and concluding statement texts + header group final Label claimHeader = new Label(); claimHeader.setStyleName("cap-claim-header"); claimHeader.setText(OnlineInquiryTool.constants.tcLblClaim()); claimTextWrap.setStyleName("cap-claim-text-wrapper"); claimText.setStyleName("cap-claim-text"); claimText.addFocusHandler(this); claimText.addBlurHandler(this); claimTextWrap.add(claimText); final Label summaryHeader = new Label(); summaryHeader.setStyleName("cap-summary-header"); summaryHeader.setText(OnlineInquiryTool.constants.tcLblClaimSummary()); concludingStatementTextWrap.setStyleName("cap-summary-text-wrapper"); concludingStatementText.setStyleName("cap-summary-text"); concludingStatementText.addFocusHandler(this); concludingStatementText.addBlurHandler(this); concludingStatementTextWrap.add(concludingStatementText); // Header styling headerGroup.setStyleName("cap-horizontal-grouping-header"); // Add perspective button styling and title addPerspective.setStyleName("cap-add-perspective"); addPerspective.setTitle(OnlineInquiryTool.constants.tcBtnAddPerspective()); addPerspective.setText(OnlineInquiryTool.constants.tcBtnAddPerspective()); addPerspective.addClickHandler(this); // Initial groupWrapper population and layout add(claimHeader); add(claimTextWrap); groupWrapper.add(groupWrapperFill[0]); groupWrapper.add(headerGroup); groupWrapper.add(addPerspective); groupWrapper.add(groupWrapperFill[1]); add(groupWrapper); add(summaryHeader); add(concludingStatementTextWrap); // Headers, add them in same kind of subpanel like stuff in other horizontal groups to get things aligned nicely for (int i = 0; i < capHeader.length; i++) { capHeaderWrap[i].setStyleName(i > 0 ? "cap-group-subcontainer" : "cap-group-subcontainer-first"); capHeader[i].setStyleName(i > 0 ? "cap-header-arg" : "cap-header"); capHeader[i].setText(OnlineInquiryTool.messages.tmLblPerspectiveHeaderN(i)); capHeaderWrap[i].add(capHeader[i]); headerGroup.add(capHeaderWrap[i]); } // Cleaner div to fix the messing up the layout Label cleaner = new Label(); cleaner.setStyleName("clearer"); headerGroup.add(cleaner); // Confim popup confirmPopup.setStylePrimaryName("confirm-popup"); final VerticalPanel sv = new VerticalPanel(); sv.setStylePrimaryName("confirm-wrap"); confirmHeader.setStyleName("confirm-header"); sv.add(confirmHeader); confirmLabel.setStylePrimaryName("confirm-label"); sv.add(confirmLabel); final HorizontalPanel sh = new HorizontalPanel(); sh.setStylePrimaryName("confirm-button-wrap"); sh.add(btnConfirmNo); sh.add(btnConfirmYes); sv.add(sh); btnConfirmNo.addClickHandler(this); btnConfirmYes.addClickHandler(this); confirmPopup.setWidget(sv); confirmPopup.setGlassEnabled(true); confirmPopup.setGlassStyleName("confirm-glass"); // Prefill component pools prefillPools(); // Set all to defaults setClaim(null); // Initial layout update updateWidgets(); updateLayout(); }
From source file:fr.aliasource.webmail.client.composer.AttachmentUploadWidget.java
License:GNU General Public License
private void buildUpload(final DockPanel dp) { setEncoding(FormPanel.ENCODING_MULTIPART); setMethod(FormPanel.METHOD_POST);// w ww . j av a2s .c o m setAction(GWT.getModuleBaseURL() + "attachements"); Label l = new Label(); dp.add(l, DockPanel.WEST); dp.setCellVerticalAlignment(l, VerticalPanel.ALIGN_MIDDLE); upload = new FileUpload(); upload.setName(attachementId); dp.add(upload, DockPanel.CENTER); droppAttachmentLink = new Anchor(I18N.strings.delete()); droppAttachmentLink.addClickHandler(createDropAttachmentClickListener()); HorizontalPanel eastPanel = new HorizontalPanel(); upSpinner = new Image("minig/images/spinner_moz.gif"); upSpinner.setVisible(false); eastPanel.add(upSpinner); eastPanel.add(droppAttachmentLink); dp.add(eastPanel, DockPanel.EAST); addSubmitHandler(new SubmitHandler() { @Override public void onSubmit(SubmitEvent event) { GWT.log("on submit " + attachementId, null); upSpinner.setVisible(true); droppAttachmentLink.setVisible(false); attachPanel.notifyUploadStarted(attachementId); } }); addSubmitCompleteHandler(new SubmitCompleteHandler() { @Override public void onSubmitComplete(SubmitCompleteEvent event) { GWT.log("on submit complete " + attachementId, null); upSpinner.setVisible(false); droppAttachmentLink.setVisible(true); attachPanel.notifyUploadComplete(attachementId); HorizontalPanel hp = new HorizontalPanel(); Label uploadInfo = new Label(); uploadInfo.setText("File '" + attachementId + "' attached."); hp.add(uploadInfo); dp.remove(upload); dp.add(hp, DockPanel.CENTER); updateMetadata(hp); } }); Timer t = new Timer() { public void run() { if (upload.getFilename() != null && upload.getFilename().length() > 0) { GWT.log("filename before upload: " + upload.getFilename(), null); cancel(); submit(); } } }; t.scheduleRepeating(300); }
From source file:fr.aliasource.webmail.client.reader.AbstractMessageWidget.java
License:GNU General Public License
protected VerticalPanel showQuotedText(String body) { VerticalPanel newBody = new VerticalPanel(); newBody.addStyleName("messageText"); if (body == null) { return newBody; }/*from w w w . j a v a 2 s. c om*/ if (body.contains("<table") || body.contains("<div") || body.contains("<blockquote") || body.contains("<ul")) { newBody.add(new HTML(body)); return newBody; } body = body.replace("<br>\n", "\n"); body = body.replace("<BR>\n", "\n"); body = body.replace("<br/>\n", "\n"); body = body.replace("<BR/>\n", "\n"); body = body.replace("<br>", "\n"); body = body.replace("<BR>", "\n"); body = body.replace("<br/>", "\n"); body = body.replace("<BR/>", "\n"); String[] lines = body.split("\n"); StringBuilder quoted = new StringBuilder(); StringBuilder text = new StringBuilder(); for (int i = 0; i < lines.length; i++) { if (lines[i].startsWith(">")) { quoted.append(lines[i]).append("<br/>"); final DisclosurePanel quotedText = new DisclosurePanel(); final Label quotedHeader = new Label("- " + I18N.strings.showQuotedText() + " -"); if (i + 1 < lines.length && !lines[i + 1].startsWith(">")) { quotedHeader.addClickHandler(new ClickHandler() { public void onClick(ClickEvent ev) { if (!quotedText.isOpen()) { quotedHeader.setText("- " + I18N.strings.hideQuotedText() + " -"); } else { quotedHeader.setText("- " + I18N.strings.showQuotedText() + " -"); } } }); quotedText.setHeader(quotedHeader); quotedText.setStyleName("quotedText"); quotedText.add(new HTML(quoted.toString())); newBody.add(quotedText); quoted.delete(0, quoted.length()); } else if (i + 1 == lines.length) { quotedText.setHeader(quotedHeader); quotedText.setStyleName("quotedText"); quotedText.add(new HTML(quoted.toString())); newBody.add(quotedText); quoted.delete(0, quoted.length()); } } else { text.append(lines[i]).append("<br/>"); if (i + 1 < lines.length && lines[i + 1].startsWith(">")) { newBody.add(new HTML(text.toString())); text.delete(0, text.length()); } else { if (text.length() > 0) { newBody.add(new HTML(text.toString())); text.delete(0, text.length()); } } } } return newBody; }
From source file:fr.drop.client.content.about.CwBasicText.java
License:Apache License
/** * Update the text in one of the selection labels. * * @param textBox the text box//from www . j av a2 s. c o m * @param label the label to update */ @DropSource private void updateSelectionLabel(TextBoxBase textBox, Label label) { label.setText(constants.cwBasicTextSelected() + ": " + textBox.getCursorPos() + ", " + textBox.getSelectionLength()); }
From source file:fr.gael.dhus.gwt.client.page.SearchViewPage.java
License:Open Source License
private static void generateDownloadLink() { Label downloadLink = Label.wrap(RootPanel.get("searchView_download").getElement()); if (GWTClient.getCurrentUser().getRoles().contains(RoleData.DOWNLOAD)) { downloadLink.setText("Download the product"); downloadLink.getElement().setClassName("searchView_download"); downloadLink.addClickHandler(new ClickHandler() { @Override// w ww. j av a2 s . c o m public void onClick(ClickEvent event) { openUrl(displayedProduct.getOdataDownaloadPath(GWT.getHostPageBaseURL())); } }); } else { downloadLink.setText("Explore the product"); downloadLink.getElement().setClassName(""); } }
From source file:fr.putnami.pwt.core.widget.client.TableEditorTH.java
License:Open Source License
@Override public void redraw() { super.redraw(); this.clear(); if (!this.aspects.isEmpty()) { FlowPanel flowPanel = new FlowPanel(); int countAspectWidget = 0; for (AbstractTableColumnAspect<T> aspect : this.aspects) { Widget aspectWidget = aspect.asWidget(); if (aspectWidget != null) { flowPanel.add(aspectWidget); countAspectWidget++;//from w w w . j a v a 2 s . c o m } } if (countAspectWidget > 0) { StyleUtils.addStyle(flowPanel, TableEditorTH.STYLE_FLOAT_RIGHT); this.append(flowPanel); } } if (this.text != null) { Label label = new Label(); label.setText(this.text); this.append(label); } }
From source file:gov.nih.nci.ncicb.tcgaportal.level4.gwt.anomalysearch.client.results.ProgressBar.java
private void setupProgressPanel() { Label progressLabel = new Label(); progressLabel.setText("Search progress: "); progressBarOuter.setStyleName("progressBarOuter"); progressBarOuter.setWidth("200px"); progressBar.setStyleName("progressBar"); progressBar.setWidth("1px"); progressBar.add(new HTML(" ")); progressBarOuter.add(progressBar);/*from w w w . j a va2 s.c o m*/ progressPanel.add(progressLabel); progressPanel.add(progressBarOuter); progressPanel.add(progressPercent); progressBarOuter.setCellHorizontalAlignment(progressBar, HasHorizontalAlignment.ALIGN_LEFT); progressPanel.setCellVerticalAlignment(progressLabel, HasVerticalAlignment.ALIGN_MIDDLE); progressPanel.setCellVerticalAlignment(progressBarOuter, HasVerticalAlignment.ALIGN_MIDDLE); progressPanel.setCellHorizontalAlignment(progressLabel, HasHorizontalAlignment.ALIGN_RIGHT); progressPanel.setCellHorizontalAlignment(progressBarOuter, HasHorizontalAlignment.ALIGN_LEFT); }
From source file:gov.nist.spectrumbrowser.admin.FftPowerSensorBands.java
License:Open Source License
public void draw() { verticalPanel.clear();//from w w w . j a v a2s . com HTML html = new HTML("<H2>Bands for sensor : " + sensor.getSensorId() + "</H2>"); verticalPanel.add(html); JSONObject sensorThresholds = sensor.getThresholds(); Grid grid = new Grid(sensorThresholds.keySet().size() + 1, 10); grid.setBorderWidth(2); grid.setCellPadding(2); grid.setCellSpacing(2); grid.setText(0, 0, "System To Detect"); grid.setText(0, 1, "Min Freq (Hz)"); grid.setText(0, 2, "Max Freq (Hz)"); grid.setText(0, 3, "Channel Count"); grid.setText(0, 4, "Sampling Rate"); grid.setText(0, 5, "FFT-Size"); grid.setText(0, 6, "Occupancy Threshold (dBm/Hz)"); grid.setText(0, 7, "Occupancy Threshold (dBm)"); grid.setText(0, 8, "Enabled?"); grid.setText(0, 9, "Delete Band"); grid.setBorderWidth(2); grid.setCellPadding(2); grid.setCellSpacing(2); CellFormatter formatter = grid.getCellFormatter(); for (int i = 0; i < grid.getRowCount(); i++) { for (int j = 0; j < grid.getColumnCount(); j++) { formatter.setHorizontalAlignment(i, j, HasHorizontalAlignment.ALIGN_CENTER); formatter.setVerticalAlignment(i, j, HasVerticalAlignment.ALIGN_MIDDLE); } } for (int i = 0; i < grid.getColumnCount(); i++) { grid.getCellFormatter().setStyleName(0, i, "textLabelStyle"); } int row = 1; for (String key : sensorThresholds.keySet()) { final FftPowerBand threshold = new FftPowerBand(sensorThresholds.get(key).isObject()); grid.setText(row, 0, threshold.getSystemToDetect()); grid.setText(row, 1, Long.toString(threshold.getMinFreqHz())); grid.setText(row, 2, Long.toString(threshold.getMaxFreqHz())); final TextBox channelCountTextBox = new TextBox(); channelCountTextBox.setText(Long.toString(threshold.getChannelCount())); channelCountTextBox.addValueChangeHandler(new ValueChangeHandler<String>() { @Override public void onValueChange(ValueChangeEvent<String> event) { Long oldValue = Long.parseLong(channelCountTextBox.getValue()); try { long newValue = Long.parseLong(event.getValue()); threshold.setChannelCount((long) newValue); } catch (Exception ex) { Window.alert(ex.getMessage()); channelCountTextBox.setValue(Double.toString(oldValue)); } } }); grid.setWidget(row, 3, channelCountTextBox); final TextBox samplingRateTextBox = new TextBox(); samplingRateTextBox.setText(Long.toString(threshold.getSamplingRate())); samplingRateTextBox.addValueChangeHandler(new ValueChangeHandler<String>() { @Override public void onValueChange(ValueChangeEvent<String> event) { Long oldValue = Long.parseLong(samplingRateTextBox.getValue()); try { long newValue = Long.parseLong(event.getValue()); threshold.setSamplingRate((long) newValue); } catch (Exception ex) { Window.alert(ex.getMessage()); samplingRateTextBox.setValue(Double.toString(oldValue)); } } }); grid.setWidget(row, 4, samplingRateTextBox); final TextBox fftSizeTextBox = new TextBox(); fftSizeTextBox.setText(Long.toString(threshold.getFftSize())); fftSizeTextBox.addValueChangeHandler(new ValueChangeHandler<String>() { @Override public void onValueChange(ValueChangeEvent<String> event) { Long oldValue = Long.parseLong(fftSizeTextBox.getValue()); try { long newValue = Long.parseLong(event.getValue()); threshold.setFftSize((long) newValue); } catch (Exception ex) { Window.alert(ex.getMessage()); fftSizeTextBox.setValue(Double.toString(oldValue)); } } }); grid.setWidget(row, 5, fftSizeTextBox); final Label thresholdDbmLabel = new Label(); final TextBox thresholdTextBox = new TextBox(); thresholdTextBox.setText(Double.toString(threshold.getThresholdDbmPerHz())); thresholdTextBox.addValueChangeHandler(new ValueChangeHandler<String>() { @Override public void onValueChange(ValueChangeEvent<String> event) { Double oldThreshold = Double.parseDouble(thresholdTextBox.getValue()); try { double newThreshold = Double.parseDouble(event.getValue()); threshold.setThresholdDbmPerHz(newThreshold); thresholdDbmLabel.setText(Float.toString(threshold.getThresholdDbm())); } catch (Exception ex) { Window.alert(ex.getMessage()); thresholdTextBox.setValue(Double.toString(oldThreshold)); } } }); grid.setWidget(row, 6, thresholdTextBox); thresholdDbmLabel.setText(Float.toString(threshold.getThresholdDbm())); grid.setWidget(row, 7, thresholdDbmLabel); CheckBox activeCheckBox = new CheckBox(); grid.setWidget(row, 8, activeCheckBox); if (!sensor.isStreamingEnabled()) { activeCheckBox.setValue(true); activeCheckBox.setEnabled(false); } else { activeCheckBox.setValue(threshold.isActive()); } activeCheckBox.addValueChangeHandler(new ValueChangeHandler<Boolean>() { @Override public void onValueChange(ValueChangeEvent<Boolean> event) { if (sensor.isStreamingEnabled()) { if (event.getValue()) { for (String key : sensor.getThresholds().keySet()) { FftPowerBand th = new FftPowerBand(sensor.getThreshold(key)); th.setActive(false); } } threshold.setActive(event.getValue()); draw(); } } }); Button deleteButton = new Button("Delete Band"); deleteButton.addClickHandler(new DeleteThresholdClickHandler(threshold)); grid.setWidget(row, 9, deleteButton); row++; } verticalPanel.add(grid); HorizontalPanel horizontalPanel = new HorizontalPanel(); Button addButton = new Button("Add Band"); addButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { new AddFftPowerSensorBand(admin, FftPowerSensorBands.this, sensorConfig, sensor, verticalPanel) .draw(); } }); horizontalPanel.add(addButton); Button doneButton = new Button("Done"); doneButton.setTitle("Return to Sensors screen"); doneButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { sensorConfig.redraw(); } }); horizontalPanel.add(doneButton); Button updateButton = new Button("Update"); updateButton.setTitle("Update sensor on the server"); updateButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { Admin.getAdminService().updateSensor(sensor.toString(), sensorConfig); } }); horizontalPanel.add(updateButton); Button logoffButton = new Button("Log Off"); logoffButton.setTitle("Log off from admin"); logoffButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { admin.logoff(); } }); Button recomputeButton = new Button("Recompute Occupancies"); recomputeButton.setTitle("Recomputes per message summary occupancies."); recomputeButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { boolean yes = Window.confirm( "Ensure no users are using the system. This can take a long time. Sensor will be disabled. Proceed?"); if (yes) { final HTML html = new HTML( "<h3>Recomputing occupancies - this can take a while. Sensor will be disabled. Please wait. </h3>"); verticalPanel.add(html); Admin.getAdminService().updateSensor(sensor.toString(), sensorConfig); Admin.getAdminService().recomputeOccupancies(sensor.getSensorId(), new SpectrumBrowserCallback<String>() { @Override public void onSuccess(String result) { verticalPanel.remove(html); } @Override public void onFailure(Throwable throwable) { Window.alert("Error communicating with server"); admin.logoff(); } }); } } }); horizontalPanel.add(recomputeButton); horizontalPanel.add(logoffButton); verticalPanel.add(horizontalPanel); }