cleaned up GWT log messages.

- removed final from AbstractSpeedWithBearingImpl and HasPermission to prevent filed not to be immutable.
- exchanged pure HTML inserts to style and href attributes with secured SafetyStyles and SafeUri.
This commit is contained in:
Udo Wessels
2021-09-06 12:12:07 +02:00
parent 13f8a426fb
commit 4124f34465
11 changed files with 54 additions and 20 deletions
@@ -5,9 +5,9 @@ import com.sap.sse.common.Bearing;
public abstract class AbstractSpeedWithBearingImpl extends AbstractSpeedWithAbstractBearingImpl implements SpeedWithBearing {
private static final long serialVersionUID = -8594305027333573010L;
private final Bearing bearing;
protected AbstractSpeedWithBearingImpl(Bearing bearing) {
/* #gwtnofinal */ private Bearing bearing;
protected AbstractSpeedWithBearingImpl(final Bearing bearing) {
this.bearing = bearing;
}
@@ -325,6 +325,8 @@ public class Header extends Composite implements HeaderConstants {
logoAnchor.setHref("");
logoAnchor.setTitle(StringMessages.INSTANCE.sapSailingAnalytics());
menuItemVisibilityHandler.addIgnore(solutionsPageLink);
} else {
logoAnchor.setHref(UriUtils.fromString(StringMessages.INSTANCE.sapAnalyticsURL()).asString());
}
logoImage.setAttribute(DebugConstants.DEBUG_ID_ATTRIBUTE, "logoImage");
solutionsPageLink.getElement().setAttribute(DEBUG_ID_ATTRIBUTE, "solutionsPageLink");
@@ -9,7 +9,7 @@
<!-- Website header-->
<div class="{res.mediaCss.grid}" style="display:flex;">
<div class="{local_res.css.siteheader_logo}">
<a ui:field="logoAnchor" href="{i18n.sapAnalyticsURL}" title="{i18n.sapAnalytics}">
<a ui:field="logoAnchor" title="{i18n.sapAnalytics}">
<img ui:field="logoImage" src="images/home/logo-small@2x.png" alt="{i18n.headerLogo}" class="{local_res.css.siteheader_logo_image}"></img>
<p class="{local_res.css.siteheader_logo_title}">
<ui:text from='{i18n.headerLogo}' />
@@ -49,6 +49,8 @@ public class RaceListColumnFactory {
private static final LocalCss CSS = RaceListResources.INSTANCE.css();
private static final StringMessages I18N = StringMessages.INSTANCE;
private static final CellTemplates TEMPLATE = GWT.create(CellTemplates.class);
private static final String TRUSTED_WINNER_STYLE_STRING = "vertical-align:middle;background-repeat:no-repeat;"
+ "background-size:contain;display:inline-block;width:18px;height:12px;";
interface CellTemplates extends SafeHtmlTemplates {
@Template("<div style=\"{1}\" class=\"{0}\"></div>")
@@ -60,8 +62,8 @@ public class RaceListColumnFactory {
@Template("<img style=\"{0}\" src=\"{1}\"/>")
SafeHtml windDirection(SafeStyles rotation, SafeUri imageUrl);
@SafeHtmlTemplates.Template("<div style='vertical-align:middle;background-repeat:no-repeat;background-size:contain;display:inline-block;width:18px;height:12px;background-image:url({2})'></div><span class=\"{0}\">{3}</span><div class=\"{1}\" title=\"{4}\">{4}</div>")
SafeHtml winner(String styleNamesSailId, String styleNamesText, String flagImageURL, String sailId, String name);
@SafeHtmlTemplates.Template("<div style='{2}'></div><span class=\"{0}\">{3}</span><div class=\"{1}\" title=\"{4}\">{4}</div>")
SafeHtml winner(String styleNamesSailId, String styleNamesText, SafeStyles safeStyles, String sailId, String name);
@Template("<img src=\"{1}\" class=\"{0}\" />")
SafeHtml imageHeader(String styleNames, SafeUri imageURL);
@@ -452,7 +454,10 @@ public class RaceListColumnFactory {
value.getTwoLetterIsoCountryCode());
String sailIdStyle = CSS.race_item_sailid();
String nameStyle = CSS.race_item_winner();
sb.append(TEMPLATE.winner( sailIdStyle, nameStyle, flagImageUri.asString(),
SafeStylesBuilder safeStylesBuilder = new SafeStylesBuilder();
safeStylesBuilder.appendTrustedString(TRUSTED_WINNER_STYLE_STRING);
safeStylesBuilder.backgroundImage(flagImageUri);
sb.append(TEMPLATE.winner(sailIdStyle, nameStyle, safeStylesBuilder.toSafeStyles(),
value.getShortInfo(), value.getName()));
}
}
@@ -7,6 +7,7 @@ import com.google.gwt.cell.client.AbstractCell;
import com.google.gwt.cell.client.ButtonCell;
import com.google.gwt.cell.client.TextCell;
import com.google.gwt.core.client.GWT;
import com.google.gwt.safecss.shared.SafeStylesBuilder;
import com.google.gwt.safehtml.shared.SafeHtml;
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
import com.google.gwt.uibinder.client.UiBinder;
@@ -165,8 +166,13 @@ public class SailorProfileOverviewImpl extends Composite implements SailorProfil
@Override
public void render(Context context, SailorProfileDTO value, SafeHtmlBuilder sb) {
for (BoatClassDTO boatclass : value.getBoatclasses()) {
sb.append(SharedSailorProfileResources.TEMPLATES.buildBoatclassIcon(BoatClassImageResolver
.getBoatClassIconResource(boatclass.getName()).getSafeUri().asString()));
SafeStylesBuilder safeStylesBuilder = new SafeStylesBuilder();
safeStylesBuilder.appendTrustedString(
SharedSailorProfileResources.TRUSTED_BUILD_BOAT_CLASS_ICON_STYLE_STRING);
safeStylesBuilder.backgroundImage(
BoatClassImageResolver.getBoatClassIconResource(boatclass.getName()).getSafeUri());
sb.append(SharedSailorProfileResources.TEMPLATES
.buildBoatclassIcon(safeStylesBuilder.toSafeStyles()));
}
}
}) {
@@ -128,6 +128,8 @@ public class Header extends Composite implements HeaderConstants {
logoImage.getStyle().setDisplay(Display.NONE);
logoAnchor.setHref("");
logoAnchor.setTitle(StringMessages.INSTANCE.sapSailingAnalytics());
} else {
logoAnchor.setHref(UriUtils.fromString(StringMessages.INSTANCE.sapAnalyticsURL()).asString());
}
}
@@ -18,7 +18,7 @@
<div class="{res.mediaCss.grid}">
<header class="{local_res.css.header} {res.mediaCss.small12} {res.mediaCss.columns}">
<div class="{local_res.css.header_logo}">
<a ui:field="logoAnchor" href="{i18n.sapAnalyticsURL}" title="{i18n.sapAnalytics}">
<a ui:field="logoAnchor" title="{i18n.sapAnalytics}">
<img ui:field="logoImage" src="images/mobile/logo-small@2x.png" alt="{i18n.headerLogo}" class="{local_res.css.header_logo_image}"></img>
</a>
</div>
@@ -1,6 +1,7 @@
package com.sap.sailing.gwt.home.mobile.places.user.profile.sailorprofiles;
import com.google.gwt.dom.client.Element;
import com.google.gwt.safecss.shared.SafeStylesBuilder;
import com.google.gwt.user.client.DOM;
import com.sap.sailing.domain.common.dto.BoatClassDTO;
import com.sap.sailing.gwt.common.client.BoatClassImageResolver;
@@ -15,9 +16,13 @@ public final class BoatclassElementBuilder {
public static Element generateBoatclassElementForMobile(final BoatClassDTO boatclass) {
SailorProfileMobileResources.INSTANCE.css().ensureInjected();
Element elem = DOM.createDiv();
elem.setInnerSafeHtml(SharedSailorProfileResources.TEMPLATES.buildBoatclassIconWithName(
BoatClassImageResolver.getBoatClassIconResource(boatclass.getName()).getSafeUri().asString(),
boatclass.getName()));
SafeStylesBuilder safeStylesBuilder = new SafeStylesBuilder();
safeStylesBuilder
.appendTrustedString(SharedSailorProfileResources.TRUSTED_BUILD_BOAT_CLASS_ICON_WITH_NAME_STYLE_STRING);
safeStylesBuilder
.backgroundImage(BoatClassImageResolver.getBoatClassIconResource(boatclass.getName()).getSafeUri());
elem.setInnerSafeHtml(SharedSailorProfileResources.TEMPLATES
.buildBoatclassIconWithName(safeStylesBuilder.toSafeStyles(), boatclass.getName()));
elem.addClassName(SailorProfileMobileResources.INSTANCE.css().boatclassWithNameEntry());
return elem;
}
@@ -7,6 +7,7 @@ import com.google.gwt.dom.client.DivElement;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.Style.Display;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.safecss.shared.SafeStylesBuilder;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler;
@@ -83,8 +84,13 @@ public class SailorProfileOverviewEntry extends Composite {
// add boatclasses
for (BoatClassDTO boatclass : entry.getBoatclasses()) {
Element elem = DOM.createDiv();
elem.setInnerSafeHtml(SharedSailorProfileResources.TEMPLATES.buildBoatclassIcon(
BoatClassImageResolver.getBoatClassIconResource(boatclass.getName()).getSafeUri().asString()));
SafeStylesBuilder safeStylesBuilder = new SafeStylesBuilder();
safeStylesBuilder
.appendTrustedString(SharedSailorProfileResources.TRUSTED_BUILD_BOAT_CLASS_ICON_STYLE_STRING);
safeStylesBuilder
.backgroundImage(BoatClassImageResolver.getBoatClassIconResource(boatclass.getName()).getSafeUri());
elem.setInnerSafeHtml(
SharedSailorProfileResources.TEMPLATES.buildBoatclassIcon(safeStylesBuilder.toSafeStyles()));
elem.getStyle().setDisplay(Display.INLINE_BLOCK);
boatclassesDivUi.appendChild(elem);
}
@@ -3,6 +3,7 @@ package com.sap.sailing.gwt.home.shared.places.user.profile.sailorprofile;
import com.google.gwt.core.shared.GWT;
import com.google.gwt.resources.client.ClientBundle;
import com.google.gwt.resources.client.CssResource;
import com.google.gwt.safecss.shared.SafeStyles;
import com.google.gwt.safehtml.client.SafeHtmlTemplates;
import com.google.gwt.safehtml.shared.SafeHtml;
@@ -12,15 +13,22 @@ public interface SharedSailorProfileResources extends ClientBundle {
public static final SailorProfileTemplates TEMPLATES = GWT.create(SailorProfileTemplates.class);
public static final String TRUSTED_BUILD_BOAT_CLASS_ICON_STYLE_STRING = "height: 40px; width: 40px; margin-left: 5px; "
+ "display: inline-block; background-size: cover; background-repeat: no-repeat; background-position: center;";
public static final String TRUSTED_BUILD_BOAT_CLASS_ICON_WITH_NAME_STYLE_STRING = "height: 30px; width: 30px; "
+ "display: inline-block; background-size: cover; background-repeat: no-repeat; "
+ "background-position: center; vertical-align:middle;";
@Source("SailorProfiles.gss")
SailorProfilesCss css();
public interface SailorProfileTemplates extends SafeHtmlTemplates {
@Template("<div style=\"height: 40px; width: 40px; margin-left: 5px; display: inline-block; background-size: cover; background-repeat: no-repeat; background-position: center;background-image: url('{0}');\"></div>")
SafeHtml buildBoatclassIcon(String boatClassUrl);
@Template("<div style=\"{0}\"></div>")
SafeHtml buildBoatclassIcon(SafeStyles styles);
@Template("<div style=\"height: 30px; width: 30px; display: inline-block; background-size: cover; background-repeat: no-repeat; background-position: center;background-image: url('{0}'); vertical-align:middle;\"></div><span style=\"vertical-align: middle;font-size: 0.75em;margin-left: 5px;\">{1}</span>")
SafeHtml buildBoatclassIconWithName(String boatClassUrl, String boatClassName);
@Template("<div style=\"{0}\"></div><span style=\"vertical-align: middle;font-size: 0.75em;margin-left: 5px;\">{1}</span>")
SafeHtml buildBoatclassIconWithName(SafeStyles styles, String boatClassName);
}
public interface SailorProfilesCss extends CssResource {
@@ -12,7 +12,7 @@ import com.sap.sse.security.shared.WithQualifiedObjectIdentifier;
public class HasPermissionsImpl extends NamedImpl implements HasPermissions {
private static final long serialVersionUID = -7901836864741040400L;
private final Action[] availableActions;
/* #gwtnofinal */ private Action[] availableActions;
/**
* By default, all actions as provided by {@link DefaultActions} are supported by logical types with permissions