List of usage examples for com.google.gwt.user.client.ui Label setText
public void setText(String text)
From source file:com.sensia.tools.client.swetools.editors.sensorml.panels.widgets.sml.SMLSensorSetValueWidget.java
License:Open Source License
/** * Inits the widget./*from w ww .j av a2 s .co m*/ */ private void init() { label = new HTML(""); valuePanel = new HorizontalPanel(); uomPanel = new HorizontalPanel(); container.add(label); container.add(new HTML(SensorConstants.HTML_SPACE + SensorConstants.HTML_SPACE)); container.add(valuePanel); container.add(new HTML(SensorConstants.HTML_SPACE + SensorConstants.HTML_SPACE)); container.add(uomPanel); //add advanced panel Panel advancedPanel = getEditPanel(new IButtonCallback() { @Override public void onClick() { refreshChildren(getElements()); refreshParents(getParent()); final StringBuffer text = new StringBuffer(); final Label uom = new Label(); Panel newValuePanel = null; //on edit, we have to resolve the path again for (ISensorWidget widget : getElements()) { if (widget.getType() == TAG_TYPE.ATTRIBUTE && widget.getName().equals("ref")) { String path = widget.getElements().get(0).getName(); List<String> pathList = Arrays.asList(path.split("/")); //resolve the name resolver.resolvePath(SMLSensorSetValueWidget.this, pathList, new ICallback<String>() { @Override public void callback(String... result) { text.append(result[0]); uom.setText(result[1]); } }); } else if (widget.getType() == TAG_TYPE.VALUE) { newValuePanel = widget.getPanel(); } } //if no error after resolving path if (text.length() > 0) { valuePanel.clear(); uomPanel.clear(); label.setText(text.toString()); uomPanel.add(uom); valuePanel.add(newValuePanel); } } }); container.add(advancedPanel); resolver = new NameRefResolver(); resolver.build(root, grammar); }
From source file:com.spaceapplications.vaadin.addon.eventtimeline.gwt.client.VEventTimelineBrowser.java
@SuppressWarnings("deprecation") private void plotHorizontalScale(long startTime, long endTime, long unitTime, float xUnit, boolean leftAlign) { float width = unitTime * xUnit; boolean shortDateFormat = width < 100; int year = timelineWidget.getStartDate().getYear(); long time = (new Date(year, 0, 1)).getTime(); DateTimeFormat formatter;//from w w w . ja v a 2s . c om if (unitTime < VEventTimelineDisplay.DAY) { formatter = shortDateFormat ? timeFormatShort : timeFormatLong; } else if (unitTime < VEventTimelineDisplay.MONTH) { formatter = shortDateFormat ? dayFormatShort : dayFormatLong; } else if (unitTime < VEventTimelineDisplay.YEAR) { formatter = shortDateFormat ? monthFormatShort : monthFormatLong; } else { formatter = shortDateFormat ? yearFormatShort : yearFormatLong; } canvas.setStrokeStyle("rgb(200,200,200)"); canvas.beginPath(); long stepsUntilInRange = (startTime - time) / unitTime; time += stepsUntilInRange * unitTime; while (time <= endTime) { if (time >= startTime - unitTime && time <= endTime + unitTime) { Label lbl = new Label(); lbl.setStyleName(CLASSNAME_SCALELABEL); lbl.setWidth(width + "px"); Date date = new Date(time); lbl.setText(formatter.format(date)); long timeFromStart = time - startTime; float x = timeFromStart * xUnit; canvas.moveTo(x, 0); canvas.lineTo(x, canvas.getHeight()); horizontalScalePanel.add(lbl, (int) x + 14 + 1, horizontalScalePanel.getOffsetHeight() - scrollBar.getOffsetHeight() - 13); horizontalScaleComponents.add(lbl); } if (unitTime == VEventTimelineDisplay.MONTH) { /* * Month resolution is not so easy since it changes depending on * the month. We use the Date to resolve the new time */ time += DateTimeService.getNumberOfDaysInMonth(new Date(time)) * VEventTimelineDisplay.DAY; } else if (unitTime == VEventTimelineDisplay.YEAR) { /* * Take leap years into account */ if (DateTimeService.isLeapYear(new Date(time))) { time += unitTime + VEventTimelineDisplay.DAY; } else { time += unitTime; } } else { time += unitTime; } } canvas.closePath(); canvas.stroke(); }
From source file:com.spaceapplications.vaadin.addon.eventtimeline.gwt.client.VEventTimelineDisplay.java
@SuppressWarnings("deprecation") private void plotHorizontalScale(long startTime, long endTime, long unitTime, float xUnit, boolean leftAlign) { if (unitTime <= 0 || xUnit <= 0) { return;//w ww. j av a 2 s .com } float width = unitTime * xUnit; boolean shortDateFormat = width < 100; int year = widget.getStartDate().getYear(); long time = (new Date(year, 0, 1)).getTime(); DateTimeFormat formatter; if (unitTime < DAY) { formatter = shortDateFormat ? timeFormatShort : timeFormatLong; } else if (unitTime < MONTH) { formatter = shortDateFormat ? dayFormatShort : dayFormatLong; } else if (unitTime < YEAR) { formatter = shortDateFormat ? monthFormatShort : monthFormatLong; } else { formatter = shortDateFormat ? yearFormatShort : yearFormatLong; } if (gridColor != null) { canvas.setStrokeStyle(gridColor); canvas.setLineWidth(0.8); canvas.beginPath(); } long stepsUntilInRange = (startTime - time) / unitTime; time += stepsUntilInRange * unitTime; while (time <= endTime) { if (time >= startTime - unitTime && time <= endTime + unitTime) { Label lbl = new Label(); lbl.setStyleName(leftAlign ? CLASSNAME_SCALEDATE_LEFT : CLASSNAME_SCALEDATE); lbl.setWidth(width + "px"); Date date = new Date(time); lbl.setText(widget.getDateTimeService().formatDate(date, formatter.getPattern())); long timeFromStart = time - startTime; float x = timeFromStart * xUnit; if (gridColor != null) { canvas.moveTo(x, 0); canvas.lineTo(x, canvas.getHeight()); } displayComponentPanel.add(lbl, (int) x, displayComponentPanel.getOffsetHeight() - 15); horizontalScaleComponents.add(lbl); } if (unitTime == MONTH) { /* * Month resolution is not so easy since it changes depending on * the month. We use the Date to resolve the new time */ time += DateTimeService.getNumberOfDaysInMonth(new Date(time)) * DAY; } else if (unitTime == YEAR) { /* * Take leap years into account */ if (DateTimeService.isLeapYear(new Date(time))) { time += unitTime + DAY; } else { time += unitTime; } } else { time += unitTime; } } if (gridColor != null) { canvas.closePath(); canvas.stroke(); } }
From source file:com.spaceapplications.vaadin.addon.eventtimeline.gwt.client.VEventTimelineWidget.java
public VEventTimelineWidget() { dts = new DateTimeService(); root.setStyleName(CLASSNAME);//w ww. j a v a2 s . c o m initWidget(root); caption = new Label(""); caption.setStyleName(CAPTION_CLASSNAME); caption.setVisible(false); root.add(caption); endDate = new Date(); startDate = new Date(endDate.getTime() - VEventTimelineDisplay.MONTH); topBar = new HorizontalPanel(); topBar.setStyleName(CLASSNAME_TOPBAR); topBar.setVisible(zoomIsVisible || dateSelectVisible || bandPagingVisible); root.add(topBar); zoomBar = new HorizontalPanel(); zoomBar.setStyleName(CLASSNAME_ZOOMBAR); zoomBar.setVisible(zoomIsVisible); Label zoomLbl = new Label("Zoom:"); zoomLbl.addStyleName(CLASSNAME_ZOOMBARLABEL); zoomBar.add(zoomLbl); topBar.add(zoomBar); dateRangeBar = new HorizontalPanel(); dateRangeBar.setStyleName(CLASSNAME_DATERANGE); dateRangeBar.setHorizontalAlignment(HorizontalPanel.ALIGN_RIGHT); dateRangeBar.setVisible(dateSelectVisible); dateFrom = new TextBox(); dateFrom.addValueChangeHandler(new ValueChangeHandler<String>() { public void onValueChange(ValueChangeEvent<String> event) { try { Date newDate = dts.parseDate(event.getValue(), editFormat.getPattern(), true); if ((newDate.equals(startDate) || newDate.after(startDate)) && (newDate.equals(endDate) || newDate.before(endDate))) { intervalStartDate = newDate; setBrowserRange(intervalStartDate, intervalEndDate); setDisplayRange(intervalStartDate, intervalEndDate); dateFrom.setFocus(false); } else { dateFrom.setText(dts.formatDate(intervalStartDate, editFormat.getPattern())); } } catch (IllegalArgumentException iae) { dateFrom.setText(dts.formatDate(intervalStartDate, editFormat.getPattern())); } } }); dateFrom.addFocusHandler(new FocusHandler() { public void onFocus(FocusEvent event) { dateFrom.setStyleName(CLASSNAME_DATEFIELDEDIT); dateFrom.setText(dts.formatDate(intervalStartDate, editFormat.getPattern())); dateFrom.selectAll(); } }); dateFrom.addBlurHandler(new BlurHandler() { public void onBlur(BlurEvent event) { dateFrom.setStyleName(CLASSNAME_DATEFIELD); dateFrom.setText(dts.formatDate(intervalStartDate, displayFormat.getPattern())); } }); dateFrom.setReadOnly(!dateSelectEnabled); dateFrom.setStyleName(CLASSNAME_DATEFIELD); dateRangeBar.add(dateFrom); Label dash = new Label(); dash.setText("-"); dateRangeBar.add(dash); dateTo = new TextBox(); dateTo.addValueChangeHandler(new ValueChangeHandler<String>() { public void onValueChange(ValueChangeEvent<String> event) { try { Date newDate = dts.parseDate(event.getValue(), editFormat.getPattern(), true); if ((newDate.equals(startDate) || newDate.after(startDate)) && (newDate.equals(endDate) || newDate.before(endDate))) { intervalEndDate = newDate; setBrowserRange(intervalStartDate, intervalEndDate); setDisplayRange(intervalStartDate, intervalEndDate); dateTo.setFocus(false); } else { dateTo.setText(dts.formatDate(intervalEndDate, editFormat.getPattern())); } } catch (IllegalArgumentException iae) { dateTo.setText(dts.formatDate(intervalEndDate, editFormat.getPattern())); } } }); dateTo.addFocusHandler(new FocusHandler() { public void onFocus(FocusEvent event) { dateTo.setStyleName(CLASSNAME_DATEFIELDEDIT); dateTo.setText(dts.formatDate(intervalEndDate, editFormat.getPattern())); dateTo.selectAll(); } }); dateTo.addBlurHandler(new BlurHandler() { public void onBlur(BlurEvent event) { dateTo.setStyleName(CLASSNAME_DATEFIELD); dateTo.setText(dts.formatDate(intervalEndDate, displayFormat.getPattern())); } }); dateTo.setReadOnly(!dateSelectEnabled); dateTo.setStyleName(CLASSNAME_DATEFIELD); dateRangeBar.add(dateTo); topBar.add(dateRangeBar); topBar.setCellHorizontalAlignment(dateRangeBar, HorizontalPanel.ALIGN_RIGHT); // // band navigation area // pageNavigationBar = new HorizontalPanel(); pageNavigationBar.setHorizontalAlignment(HorizontalPanel.ALIGN_RIGHT); pageNavigationBar.setStyleName(CLASSNAME_BANDPAGE); pageNavigationBar.setVisible(bandPagingVisible); pageNavigationBar.setHeight("31px"); topBar.add(pageNavigationBar); topBar.setCellHorizontalAlignment(pageNavigationBar, HorizontalPanel.ALIGN_RIGHT); Label navigationLbl = new Label("Navigation:"); navigationLbl.addStyleName(CLASSNAME_BANDPAGE_LABEL); pageNavigationBar.add(navigationLbl); previousPage = new Anchor("Previous page"); pageNavigationBar.add(previousPage); previousPage.addStyleName(CLASSNAME_BANDPAGE_PREVIOUS); previousPage.addClickHandler(pageNavigationClickHandler); pageNumberText = new Label(); pageNavigationBar.add(pageNumberText); pageNumberText.addStyleName(CLASSNAME_BANDPAGE_PAGENUMBER); pageNumberText.setText("1"); nextPage = new Anchor("Next page"); pageNavigationBar.add(nextPage); nextPage.addStyleName(CLASSNAME_BANDPAGE_NEXT); nextPage.addClickHandler(pageNavigationClickHandler); legend = new HorizontalPanel(); legend.setVisible(legendVisible); legend.setHeight("30px"); legend.setStyleName(CLASSNAME_LEGEND); modeLegendBar = new HorizontalPanel(); modeLegendBar.setVisible(legendVisible); modeLegendBar.setWidth("100%"); modeLegendBar.setHeight("31px"); modeLegendBar.setStyleName(CLASSNAME_MODELEGEND_ROW); modeLegendBar.add(legend); modeLegendBar.setCellHorizontalAlignment(legend, HorizontalPanel.ALIGN_RIGHT); root.add(modeLegendBar); // // the band area // HorizontalPanel layout = new HorizontalPanel(); bandArea = new VEventTimelineBandArea(this); bandArea.setWidth("100px"); layout.add(bandArea); VerticalPanel main = new VerticalPanel(); // Add the display display = new VEventTimelineDisplay(this); main.add(display); // Add the browser browser = new VEventTimelineBrowser(this); browser.setVisible(browserIsVisible); main.add(browser); layout.add(main); root.add(layout); }
From source file:com.spaceapplications.vaadin.addon.eventtimeline.gwt.client.VEventTimelineWidget.java
private void setZoomCaption(UIDL uidl) { if (uidl.hasAttribute("zlvlcaption")) { String caption = uidl.getStringAttribute("zlvlcaption"); Label lbl = (Label) zoomBar.getWidget(0); lbl.setText(caption); }// www . jav a 2 s.c o m }
From source file:com.spaceapplications.vaadin.addon.eventtimeline.gwt.client.VEventTimelineWidget.java
private void setPageNavigationCaptions(UIDL uidl) { if (uidl.hasAttribute("bpgingCaption")) { String caption = uidl.getStringAttribute("bpgingCaption"); Label lbl = (Label) pageNavigationBar.getWidget(0); lbl.setText(caption); }/*from w w w.ja v a2s . c o m*/ if (uidl.hasAttribute("bpgingCptPrevious")) { String caption = uidl.getStringAttribute("bpgingCptPrevious"); previousPage.setText(caption); } if (uidl.hasAttribute("bpgingCptNext")) { String caption = uidl.getStringAttribute("bpgingCptNext"); nextPage.setText(caption); } }
From source file:com.spaceapplications.vaadin.addon.eventtimeline.gwt.client.VEventTimelineWidget.java
/** * Sets the legend value//from w w w. j a v a2 s. c om * * @param graph * The graph the value is from * @param value * The value */ public void setLegendValue(int graph, String value) { if (legendValues.size() > graph) { Label lbl = legendValues.get(graph); if (lbl != null) { lbl.setText(value); } } }
From source file:com.square.client.gwt.client.util.agenda.DayViewHeader.java
License:Open Source License
public void setDays(Date date, int days) { dayPanel.clear();// w ww. ja va2 s.c o m float dayWidth = 100f / days; float dayLeft; for (int i = 0; i < days; i++) { // increment the date by 1 if (i > 0) { DateUtils.moveOneDayForward(date); } // set the left position of the day splitter to // the width * incremented value dayLeft = dayWidth * i; //String headerTitle = DAY_LIST[date.getDay()] + ", " // + MONTH_LIST[date.getMonth()] + " " + date.getDate(); 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 + "%"); // set the style of the header to show that it is today if (DateUtils.areOnTheSameDay(new Date(), date)) { dayLabel.setStyleName("day-cell-today"); } dayPanel.add(dayLabel); } }
From source file:com.square.client.gwt.client.view.personne.action.PersonneActionsViewImpl.java
License:Open Source License
@Override public void afficherInfoBulleAction(ActionModel action, PersonneInfosActionView personneInfosActionView) { final VerticalPanel contenuInfoBulle = new VerticalPanel(); contenuInfoBulle.setWidth("400px"); contenuInfoBulle.setSpacing(5);/* ww w . j a va2s .c o m*/ final Label libelleDate = new Label(); if (action.getStatut().getIdentifiant().equals(constantes.getIdStatutTerminer())) { libelleDate.setText(viewConstants.aFaireLe() + ESPACE + action.getDateAction() + ", " + viewConstants.faitLe() + ESPACE + action.getDateTerminee()); } else if (action.getStatut().getIdentifiant().equals(constantes.getIdStatutAnnuler())) { libelleDate.setText(viewConstants.le() + ESPACE + action.getDateAction()); } String lValueCreateur = ""; if (action.getRessource() != null) { final IdentifiantLibelleGwt agence = action.getCreateur().getAgence() != null ? action.getCreateur().getAgence() : null; lValueCreateur = action.getCreateur().getNom() + ESPACE + action.getCreateur().getPrenom() + (agence != null ? ", " + agence.getLibelle() : ""); } final Label lCreateur = new Label(viewConstants.creePar() + ESPACE + lValueCreateur); String lValueRessource = ""; if (action.getRessource() != null) { final IdentifiantLibelleGwt agence = action.getRessource().getAgence() != null ? action.getRessource().getAgence() : action.getAgence(); lValueRessource = action.getRessource().getNom() + ESPACE + action.getRessource().getPrenom() + (agence != null ? ", " + agence.getLibelle() : ""); } else if (action.getAgence() != null) { lValueRessource = action.getAgence().getLibelle(); } final Label lRessource = new Label(viewConstants.par() + ESPACE + lValueRessource); final Label lCommentaires = new Label(viewConstants.commentaires() + ESPACE); final VerticalPanel conteneurCommentaires = new VerticalPanel(); conteneurCommentaires.add(lCommentaires); if (action.getCommentaires() != null) { for (HistoriqueCommentaireModel ligneHisto : action.getCommentaires()) { conteneurCommentaires.add(new HTML(ligneHisto.getDescriptif())); } } contenuInfoBulle.add(libelleDate); contenuInfoBulle.add(lCreateur); contenuInfoBulle.add(lRessource); contenuInfoBulle.add(conteneurCommentaires); infoBulleAction.setWidget(contenuInfoBulle, 0); infoBulleAction.showRelativeTo(personneInfosActionView.asWidget(), false, personneInfosActionView.asWidget().getOffsetWidth(), -(contenuInfoBulle.getOffsetHeight() / 2)); }
From source file:com.square.composant.contrat.square.client.view.ContratsViewImpl.java
License:Open Source License
@Override public HasClickHandlers ajouterGarantieEtValeursRecapGaranties(String libelleGarantie, boolean possedeGrillePresta, List<InfosGarantieBeneficiaireModel> listeValeurs, ConstantesModel constantes) {// w w w . j av a2 s. c om int idxColonneGarantieSuivante = panelRecapitulatifGaranties.getCellCount(1); // Remplissage de l'entte final Label enteteGarantie = new Label(libelleGarantie); // Ajout d'une image PDF si la garantie possde une grille de presta Image imagePdf = null; if (possedeGrillePresta) { imagePdf = new Image(ContratsPresenter.RESOURCES.imageIconePdf()); imagePdf.setStylePrimaryName(ContratsPresenter.RESOURCES.css().imagePdfCliquable()); imagePdf.setTitle(viewConstants.libelleVoirGrillePresta()); } final VerticalPanel panelEnteteGarantie = new VerticalPanel(); panelEnteteGarantie.setVerticalAlignment(HasVerticalAlignment.ALIGN_TOP); panelEnteteGarantie.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); panelEnteteGarantie.add(enteteGarantie); if (imagePdf != null) { panelEnteteGarantie.add(imagePdf); } panelRecapitulatifGaranties.setWidget(0, idxColonneGarantieSuivante, panelEnteteGarantie); panelRecapitulatifGaranties.getFlexCellFormatter().setVerticalAlignment(0, idxColonneGarantieSuivante, HasVerticalAlignment.ALIGN_TOP); panelRecapitulatifGaranties.getCellFormatter().setHorizontalAlignment(0, idxColonneGarantieSuivante, HasHorizontalAlignment.ALIGN_CENTER); if (listeValeurs != null) { for (int idxValeur = 0; idxValeur < listeValeurs.size(); idxValeur++) { final Label valeur = new Label(); if (listeValeurs.get(idxValeur) != null && listeValeurs.get(idxValeur).getDateAdhesion() != null && !"".equals(listeValeurs.get(idxValeur).getDateAdhesion())) { valeur.setText(listeValeurs.get(idxValeur).getDateAdhesion()); } panelRecapitulatifGaranties.setWidget(idxValeur + 1, idxColonneGarantieSuivante, valeur); panelRecapitulatifGaranties.getCellFormatter().setHorizontalAlignment(idxValeur + 1, idxColonneGarantieSuivante, HasHorizontalAlignment.ALIGN_CENTER); // on change la couleur de case suivant le statut String css = ContratsPresenter.RESOURCES.css().celluleRecapitulatifGarantie(); if (listeValeurs.get(idxValeur) != null && listeValeurs.get(idxValeur).getStatut() != null && listeValeurs.get(idxValeur).getStatut().getIdentifiant() != null) { final IdentifiantLibelleGwt statut = listeValeurs.get(idxValeur).getStatut(); if (constantes.getIdStatutGarantieEnCours().equals(statut.getIdentifiant())) { css = ContratsPresenter.RESOURCES.css().couleurFondGarantieEnCours(); } else if (constantes.getIdStatutGarantieResiliee().equals(statut.getIdentifiant())) { css = ContratsPresenter.RESOURCES.css().couleurFondGarantieResiliee(); } else if (constantes.getIdStatutGarantieFutur().equals(statut.getIdentifiant())) { css = ContratsPresenter.RESOURCES.css().couleurFondGarantieFutur(); } } panelRecapitulatifGaranties.getCellFormatter().addStyleName(idxValeur + 1, idxColonneGarantieSuivante, css); } } // Incrmentation de l'index de colonne suivante idxColonneGarantieSuivante++; return imagePdf; }