List of usage examples for com.google.gwt.safehtml.shared SafeHtmlUtils fromString
public static SafeHtml fromString(String s)
From source file:com.unilorraine.projetdevie.client.ui.viewmodules.preparationmodule.PreparationModuleViewImpl.java
License:Open Source License
@Override public void setCategory(String category) { this.categoryLabel.setText(SafeHtmlUtils.fromString(category).asString()); }
From source file:com.vo.search.admin.client.ContentWidget.java
License:Apache License
/** * Construct a {@link ContentWidget}.//from w w w .j a v a2 s .c om * * @param name the text name of the example * @param description a text description of the example * @param hasStyle true if the example has associated styles */ public ContentWidget(String name, String description, boolean hasStyle) { this(name, SafeHtmlUtils.fromString(description), hasStyle); }
From source file:de.knightsoftnet.validationexample.client.ui.navigation.MyNavigationStructure.java
License:Apache License
@Override protected final List<NavigationEntryInterface> buildNavigation() { final List<NavigationEntryInterface> navigationEntries = new ArrayList<NavigationEntryInterface>(); final NavigationConstants navigationConstants = GWT.create(NavigationConstants.class); navigationEntries.add(new NavigationEntry(SafeHtmlUtils.fromString(navigationConstants.menuPostalAddress()), NameTokens.ADDRESS, null));/* www . j a va 2s. c o m*/ navigationEntries.add(new NavigationEntry(SafeHtmlUtils.fromString(navigationConstants.menuSepa()), NameTokens.SEPA, null)); navigationEntries.add(new NavigationEntry(SafeHtmlUtils.fromString(navigationConstants.menuPhoneNumber()), NameTokens.PHONE_NUMBER, null)); navigationEntries.add(new NavigationEntry(SafeHtmlUtils.fromString(navigationConstants.menuSettings()), NameTokens.SETTINGS, null)); navigationEntries.add(new NavigationEntry(SafeHtmlUtils.fromString(navigationConstants.menuLogin()), NameTokens.SECRET + "/" + NameTokens.LOGIN, this.loggedOutGatekeeper)); navigationEntries.add(new NavigationEntry(SafeHtmlUtils.fromString(navigationConstants.menuLogout()), NameTokens.LOGOUT, this.loggedInGatekeeper)); final NavigationEntryFolder testFolder = new NavigationEntryFolder( SafeHtmlUtils.fromString(navigationConstants.menuTestFolder()), true); testFolder.addSubEntry(new NavigationEntry(SafeHtmlUtils.fromString(navigationConstants.menuSecret()), NameTokens.SECRET, this.loggedInGatekeeper)); testFolder.addSubEntry(new NavigationEntry(SafeHtmlUtils.fromString(navigationConstants.menuPerson()), NameTokens.PERSON, this.loggedInGatekeeper)); navigationEntries.add(testFolder); return navigationEntries; }
From source file:edu.arizona.biosemantics.gxt.theme.green.client.base.field.Css3TextAreaAppearance.java
License:sencha.com license
@Override public void render(SafeHtmlBuilder sb, String value, FieldAppearanceOptions options) { String inputStyles = ""; String wrapStyles = ""; int width = options.getWidth(); int height = options.getHeight(); String name = options.getName() != null ? "name='" + options.getName() + "'" : ""; String disabled = options.isDisabled() ? "disabled=true" : ""; String placeholder = options.getEmptyText() != null ? " placeholder='" + SafeHtmlUtils.htmlEscape(options.getEmptyText()) + "' " : ""; boolean empty = false; if ((value == null || value.equals("")) && options.getEmptyText() != null) { if (GXT.isIE8() || GXT.isIE9()) { value = options.getEmptyText(); }/*from w ww. j ava 2 s.co m*/ empty = true; } Size adjusted = adjustTextAreaSize(width, height); if (width != -1) { wrapStyles += "width:" + width + "px;"; width = adjusted.getWidth(); inputStyles += "width:" + width + "px;"; } if (height != -1) { height = adjusted.getHeight(); inputStyles += "height: " + height + "px;"; } String cls = style.area() + " " + style.field(); if (empty) { cls += " " + style.empty(); } String ro = options.isReadonly() ? " readonly" : ""; if (options instanceof TextAreaCellOptions) { TextAreaCellOptions opts = (TextAreaCellOptions) options; inputStyles += "resize:" + opts.getResizable().name().toLowerCase() + ";"; } sb.appendHtmlConstant("<div style='" + wrapStyles + "' class='" + style.wrap() + "'>"); sb.appendHtmlConstant("<textarea " + name + disabled + " style='" + inputStyles + "' type='text' class='" + cls + "'" + ro + placeholder + ">"); sb.append(SafeHtmlUtils.fromString(value)); sb.appendHtmlConstant("</textarea></div>"); }
From source file:edu.arizona.biosemantics.gxt.theme.green.client.base.progressbar.Css3ProgressBarAppearance.java
License:sencha.com license
@Override public void render(SafeHtmlBuilder sb, Double value, ProgressBarAppearanceOptions options) { value = value == null ? 0 : value;//from w w w .ja va 2 s. c om String text = options.getProgressText(); if (text != null) { int v = (int) Math.round(value * 100); text = Format.substitute(text, v); } SafeHtml txt; if (text == null) { txt = SafeHtmlUtils.fromSafeConstant(" "); } else { txt = SafeHtmlUtils.fromString(text); } SafeStyles widthStyles = SafeStylesUtils.fromTrustedNameAndValue("width", options.getWidth() + "px"); final SafeStyles progressBarStyles; if (value <= 0) { progressBarStyles = SafeStylesUtils.fromTrustedNameAndValue("visibility", "hidden"); } else { progressBarStyles = SafeStylesUtils.fromTrustedNameAndValue("width", value * 100 + "%"); } sb.append(template.render(txt, styles, null, progressBarStyles, null, widthStyles)); }
From source file:edu.caltech.ipac.firefly.commands.JwstFootprintCmd.java
private void updateData(OverlayMarker m, WebPlot plot, boolean drawHandles) { if (m.isReady()) { List<DrawObj> data = new ArrayList<DrawObj>(); List<DrawObj> editData = new ArrayList<DrawObj>(); ShapeDataObj centerShape = (ShapeDataObj) m.getShape().get(0);//circle data.addAll(m.getShape());/*from w w w. j a v a 2s . co m*/ if (!StringUtils.isEmpty(m.getTitle()) && plot != null) { centerShape.setFontName(m.getFont()); centerShape.setText(SafeHtmlUtils.fromString(m.getTitle()).asString()); centerShape.setTextLocation(convertTextLoc(m.getTextCorner())); } if (drawHandles) { int size = 5; centerShape.setLineWidth(2); //fp.set(0, centerShape); editData.add(centerShape); editData.add(ShapeDataObj.makeRectangle(m.getCorner(OverlayMarker.Corner.NW, plot), size, size)); editData.add(ShapeDataObj.makeRectangle(m.getCorner(OverlayMarker.Corner.NE, plot), -size, size)); editData.add(ShapeDataObj.makeRectangle(m.getCorner(OverlayMarker.Corner.SW, plot), size, -size)); editData.add(ShapeDataObj.makeRectangle(m.getCorner(OverlayMarker.Corner.SE, plot), -size, -size)); // for (DrawObj drawObj : fp) { // if(drawObj instanceof FootprintObj){ // for(WorldPt[] pt:((FootprintObj)drawObj).getPos()){ // for (int i = 0; i < pt.length; i++) { // ScreenPt spt= plot.getScreenCoords(pt[i]); // editData.add(ShapeDataObj.makeRectangle(spt, -size, -size));//FIXME make those point as point object and movable from the marker // } // } // } // } } else { if (!StringUtils.isEmpty(m.getTitle()) && plot != null) { centerShape.setLineWidth(0); } else { data.remove(0); } } _markerMap.get(m).getConnect().setData(data, editData, plot); } }
From source file:edu.caltech.ipac.firefly.commands.MarkerToolCmd.java
private void updateData(Marker m, WebPlot plot, boolean drawHandles) { if (m.isReady()) { List<DrawObj> data = new ArrayList<DrawObj>(1); List<DrawObj> editData = new ArrayList<DrawObj>(1); // ShapeDataObj markerShape= m.getShape().get(0); // main shape // data.add(markerShape); // data.add(ShapeDataObj.makeCircle(m.getStartPt(), m.getEndPt())); ShapeDataObj markerShape = ShapeDataObj.makeCircle(m.getStartPt(), m.getEndPt()); data.add(markerShape);/*from ww w. j ava 2 s .com*/ if (drawHandles) { int size = 5; editData.add(ShapeDataObj.makeRectangle(m.getCorner(Marker.Corner.NW, plot), size, size)); editData.add(ShapeDataObj.makeRectangle(m.getCorner(Marker.Corner.NE, plot), -size, size)); editData.add(ShapeDataObj.makeRectangle(m.getCorner(Marker.Corner.SW, plot), size, -size)); editData.add(ShapeDataObj.makeRectangle(m.getCorner(Marker.Corner.SE, plot), -size, -size)); } if (!StringUtils.isEmpty(m.getTitle()) && plot != null) { markerShape.setFontName(m.getFont()); markerShape.setText(SafeHtmlUtils.fromString(m.getTitle()).asString()); markerShape.setTextLocation(convertTextLoc(m.getTextCorner())); } _markerMap.get(m).getConnect().setData(data, editData, plot); } }
From source file:fr.putnami.pwt.core.error.client.widget.ErrorAlert.java
License:Open Source License
public ErrorAlert(String title, String message, String errorDetails, Severity severity) { Binder.BINDER.createAndBindUi(this); StyleUtils.addStyle(this.detailButton, Alert.STYLE_ALERT_LINK); this.titleOutput.setInnerSafeHtml(SafeHtmlUtils.fromString(title)); this.messageOutput.setText(message); this.detailOutput.setInnerSafeHtml(SafeHtmlUtils.fromString(errorDetails)); this.alert.setType(this.getAlertTypeFromSeverity(severity)); this.collapseHelper = CollapseHelper.apply(this.detailButton, this.detailOutput, true); this.collapseHelper.addCollapseHandler(this); }
From source file:fr.putnami.pwt.doc.client.application.error.SingleErrorDisplay.java
License:Open Source License
public void show(String title, String message) { this.titleOutput.setInnerSafeHtml(SafeHtmlUtils.fromString(title)); this.messageOutput.setText(message); if (!this.showing) { RootPanel.get().add(this.modal); this.modal.show(); }// ww w .j a va2 s .c o m this.showing = true; }
From source file:gov.wa.wsdot.mobile.client.activities.amtrakcascades.schedules.details.AmtrakCascadesSchedulesDetailsViewGwtImpl.java
License:Open Source License
public AmtrakCascadesSchedulesDetailsViewGwtImpl() { pullToRefresh = new PullPanel(); pullArrowHeader = new PullArrowHeader(); pullToRefresh.setHeader(pullArrowHeader); cellList = new CellList<AmtrakCascadesServiceItem>( new AmtrakCascadesSchedulesDetailsCell<AmtrakCascadesServiceItem>() { @Override//from w w w . j a va 2s. co m public SafeHtml getScheduledDeparture(AmtrakCascadesServiceItem model) { String schedDepartureTime = model.getLocation().get(0).get(fromLocation) .getScheduledDepartureTime(); if (schedDepartureTime != null) { Date scheduledDepartureTime = new Date(Long.parseLong( model.getLocation().get(0).get(fromLocation).getScheduledDepartureTime())); return SafeHtmlUtils.fromString(dateFormat.format(scheduledDepartureTime, usPacific)); } else { return SafeHtmlUtils.fromString(""); } } @Override public SafeHtml getScheduledArrival(AmtrakCascadesServiceItem model) { String schedDepartureTime = model.getLocation().get(0).get(fromLocation) .getScheduledDepartureTime(); String schedArrivalTime = model.getLocation().get(0).get(toLocation) .getScheduledArrivalTime(); if ((fromLocation.equalsIgnoreCase(toLocation)) && (schedDepartureTime != null && schedArrivalTime != null)) { return SafeHtmlUtils.fromString(""); } else { if (schedArrivalTime != null) { Date scheduledArrivalTime = new Date(Long.parseLong( model.getLocation().get(0).get(toLocation).getScheduledArrivalTime())); return SafeHtmlUtils.fromString(dateFormat.format(scheduledArrivalTime, usPacific)); } else if (schedDepartureTime != null && !toLocation.equalsIgnoreCase(fromLocation)) { /* When a station only has a scheduled departure time and not arrival, * it is assumed that the train only stops for a short time at that station. * In these cases, the Amtrak site appears to show this scheduled departure * time as the scheduled arrival time so we'll do the same thing for the app. */ Date scheduledArrivalTime = new Date(Long.parseLong( model.getLocation().get(0).get(toLocation).getScheduledDepartureTime())); return SafeHtmlUtils.fromString(dateFormat.format(scheduledArrivalTime, usPacific)); } else { return SafeHtmlUtils.fromString(""); } } } @Override public SafeHtml getLastUpdated(AmtrakCascadesServiceItem model) { if (model.getLocation().get(0).get(fromLocation).getUpdateTime() != null) { String updateTime = updateDateFormat.format(new Date( Long.parseLong(model.getLocation().get(0).get(fromLocation).getUpdateTime()))); return SafeHtmlUtils .fromString(ParserUtils.relativeTime(updateTime, "MMMM d, yyyy h:mm a", false)); } else { return SafeHtmlUtils.fromString(""); } } @Override public SafeHtml getTrain(AmtrakCascadesServiceItem model) { if (model.getLocation().get(0).get(fromLocation).getTrainMessage() == null) { return SafeHtmlUtils .fromString(model.getLocation().get(0).get(fromLocation).getTrainName()); } else { return SafeHtmlUtils .fromString(model.getLocation().get(0).get(fromLocation).getTrainName() + " - " + model.getLocation().get(0).get(fromLocation).getTrainMessage()); } } @Override public SafeHtml getDepartureComment(AmtrakCascadesServiceItem model) { if (model.getLocation().get(0).get(fromLocation).getDepartureTime() != null) { Date departureTime = new Date(Long .parseLong(model.getLocation().get(0).get(fromLocation).getDepartureTime())); Date scheduledDepartureTime = new Date(Long.parseLong( model.getLocation().get(0).get(fromLocation).getScheduledDepartureTime())); int minutesDiff = (int) (((departureTime.getTime() - scheduledDepartureTime.getTime()) / 1000) / 60); String scheduleType = model.getLocation().get(0).get(fromLocation) .getDepartureScheduleType(); String timelyType = "on time"; if (minutesDiff < 0) { timelyType = " early "; } else if (minutesDiff > 0) { timelyType = " late "; } if (scheduleType.equalsIgnoreCase("Estimated")) { if (minutesDiff == 0) { return SafeHtmlUtils.fromString("Estimated " + timelyType); } else { return SafeHtmlUtils .fromString("Estimated " + getHoursMinutes(Math.abs(minutesDiff)) + timelyType + " at " + dateFormat.format(departureTime)); } } else { if (minutesDiff == 0) { return SafeHtmlUtils.fromString("Departed " + timelyType); } else { return SafeHtmlUtils .fromString("Departed " + getHoursMinutes(Math.abs(minutesDiff)) + timelyType + " at " + dateFormat.format(departureTime)); } } } else { return SafeHtmlUtils.fromString(""); } } @Override public SafeHtml getArrivalComment(AmtrakCascadesServiceItem model) { String schedDepartureTime = model.getLocation().get(0).get(fromLocation) .getScheduledDepartureTime(); String schedArrivalTime = model.getLocation().get(0).get(toLocation) .getScheduledArrivalTime(); if ((fromLocation.equalsIgnoreCase(toLocation)) && (schedDepartureTime != null && schedArrivalTime != null)) { return SafeHtmlUtils.fromString(""); } else { if (model.getLocation().get(0).get(toLocation).getArrivalTime() != null) { Date arrivalTime = new Date(Long .parseLong(model.getLocation().get(0).get(toLocation).getArrivalTime())); Date scheduledArrivalTime; if (schedArrivalTime != null) { scheduledArrivalTime = new Date(Long.parseLong(schedArrivalTime)); } else { /* Stop looking for the scheduled departure time if origin and destination * stations are the same */ if (!toLocation.equalsIgnoreCase(fromLocation)) { /* When a station only has a scheduled departure time and not arrival, * it is assumed that the train only stops for a short time at that station. * In these cases, the Amtrak site appears to show this scheduled departure * time as the scheduled arrival time so we'll do the same thing for the app. */ scheduledArrivalTime = new Date(Long.parseLong(model.getLocation().get(0) .get(toLocation).getScheduledDepartureTime())); } else { return SafeHtmlUtils.fromString(""); } } int minutesDiff = (int) (((arrivalTime.getTime() - scheduledArrivalTime.getTime()) / 1000) / 60); String scheduleType = model.getLocation().get(0).get(toLocation) .getArrivalScheduleType(); String timelyType = "on time"; if (minutesDiff < 0) { timelyType = " early "; } else if (minutesDiff > 0) { timelyType = " late "; } if (scheduleType.equalsIgnoreCase("Estimated")) { if (minutesDiff == 0) { return SafeHtmlUtils.fromString("Estimated " + timelyType); } else { return SafeHtmlUtils .fromString("Estimated " + getHoursMinutes(Math.abs(minutesDiff)) + timelyType + " at " + dateFormat.format(arrivalTime)); } } else { if (minutesDiff == 0) { return SafeHtmlUtils.fromString("Arrived " + timelyType); } else { return SafeHtmlUtils .fromString("Arrived " + getHoursMinutes(Math.abs(minutesDiff)) + timelyType + " at " + dateFormat.format(arrivalTime)); } } } else { return SafeHtmlUtils.fromString(""); } } } @Override public boolean canBeSelected(AmtrakCascadesServiceItem model) { /* if (model.getLocation().get(0).size() > 2) { return true; } else { return false; } */ return false; } /** * * @param minutesDiff * @return */ private String getHoursMinutes(int minutesDiff) { int hours = (int) Math.floor(minutesDiff / 60); int minutes = (minutesDiff % 60); if (hours == 0) { return minutes + ParserUtils.pluralize(minutes, " minute ", " minutes "); } else { if (minutes == 0) { return hours + ParserUtils.pluralize(minutes, " hour ", " hours "); } else { return hours + ParserUtils.pluralize(hours, " hour ", " hours ") + minutes + ParserUtils.pluralize(minutes, " minute ", " minutes "); } } } }); initWidget(uiBinder.createAndBindUi(this)); accessibilityPrepare(); if (MGWT.getOsDetection().isAndroid()) { leftFlexSpacer.setVisible(false); } }