diff options
author | Pekka Hyvönen <pekka@vaadin.com> | 2017-02-01 19:13:08 +0200 |
---|---|---|
committer | Henri Sara <henri.sara@gmail.com> | 2017-02-01 19:13:08 +0200 |
commit | 6c624e86e39d8dc59452a2ce3e182d78b1f9eaeb (patch) | |
tree | add20750a4ee6a729cf828af25e685b1981b76b7 /server/src/main | |
parent | 53674a7cafc22e8e21f5a7d46df0f5c126fb76c6 (diff) | |
download | vaadin-framework-6c624e86e39d8dc59452a2ce3e182d78b1f9eaeb.tar.gz vaadin-framework-6c624e86e39d8dc59452a2ce3e182d78b1f9eaeb.zip |
Replace FontAwesome with Vaadin Icons (#8208)
* Include FontAwesome by default for easier migration
* Fix JSComponentLoadingIndicatorTest
Fixes #7979
Addresses part of #8219
Diffstat (limited to 'server/src/main')
3 files changed, 25 insertions, 13 deletions
diff --git a/server/src/main/java/com/vaadin/server/FontAwesome.java b/server/src/main/java/com/vaadin/server/FontAwesome.java index 54101df70f..c867eb4ce2 100644 --- a/server/src/main/java/com/vaadin/server/FontAwesome.java +++ b/server/src/main/java/com/vaadin/server/FontAwesome.java @@ -31,10 +31,10 @@ package com.vaadin.server; * * @since 7.2 * @author Vaadin Ltd - * @see http://fortawesome.github.io/Font-Awesome/ - * @deprecated Planned to replace with Vaadin Icons https://vaadin.com/icons for - * 8.0.0 (#7979). Will be moved to {@code compability-server} - * package and not updated to include new icons + * @see http://fontawesome.github.io/Font-Awesome/ + * @deprecated Since 8.0 replaced with included Vaadin Icons + * https://vaadin.com/icons (#7979). Will not be updated to include + * new icons. */ @Deprecated public enum FontAwesome implements FontIcon { diff --git a/server/src/main/java/com/vaadin/ui/declarative/converters/DesignResourceConverter.java b/server/src/main/java/com/vaadin/ui/declarative/converters/DesignResourceConverter.java index e1ef5563fe..f1a4fcde23 100644 --- a/server/src/main/java/com/vaadin/ui/declarative/converters/DesignResourceConverter.java +++ b/server/src/main/java/com/vaadin/ui/declarative/converters/DesignResourceConverter.java @@ -17,13 +17,16 @@ package com.vaadin.ui.declarative.converters; import java.io.File; import java.io.Serializable; +import java.util.Arrays; import java.util.HashMap; import java.util.Locale; import java.util.Map; +import java.util.stream.Collectors; import com.vaadin.data.Converter; import com.vaadin.data.Result; import com.vaadin.data.ValueContext; +import com.vaadin.icons.VaadinIcons; import com.vaadin.server.ExternalResource; import com.vaadin.server.FileResource; import com.vaadin.server.FontAwesome; @@ -38,12 +41,15 @@ import com.vaadin.ui.declarative.DesignAttributeHandler; * A converter for {@link Resource} implementations supported by * {@link DesignAttributeHandler}. * - * @since 7.4 * @author Vaadin Ltd + * @since 7.4 */ @SuppressWarnings("serial") public class DesignResourceConverter implements Converter<String, Resource> { + private static final Map<Integer, VaadinIcons> CODE_POINTS = + Arrays.stream(VaadinIcons.values()).collect(Collectors.toMap(VaadinIcons::getCodepoint, icon -> icon)); + @Override public Result<Resource> convertToModel(String value, ValueContext context) { if (!value.contains("://")) { @@ -101,14 +107,18 @@ public class DesignResourceConverter implements Converter<String, Resource> { FONTICON { @Override public Resource parse(String value) { - final String address = (value.split("://", 2))[1]; + final String address = value.split("://", 2)[1]; final String[] familyAndCode = address.split("/", 2); final int codepoint = Integer.valueOf(familyAndCode[1], 16); - if (FontAwesome.FONT_FAMILY.equals(familyAndCode[0])) { - return FontAwesome.fromCodepoint(codepoint); + if (VAADIN_ICONS_NAME.equals(familyAndCode[0])) { + return CODE_POINTS.get(codepoint); } + if (FontAwesome.FONT_FAMILY.equals(familyAndCode[0])) { //Left for compatibility + return FontAwesome.fromCodepoint(codepoint); + } + // all vaadin icons should have a codepoint FontIcon generic = new GenericFontIcon(familyAndCode[0], codepoint); return generic; @@ -128,7 +138,7 @@ public class DesignResourceConverter implements Converter<String, Resource> { public Resource parse(String value) { // Deprecated, 7.4 syntax is // font://"+FontAwesome.valueOf(foo) eg. "font://AMBULANCE" - final String iconName = (value.split("://", 2))[1]; + final String iconName = value.split("://", 2)[1]; return FontAwesome.valueOf(iconName); } @@ -158,6 +168,8 @@ public class DesignResourceConverter implements Converter<String, Resource> { }; + public static final String VAADIN_ICONS_NAME = VaadinIcons.ABACUS.getFontFamily(); + @Override public Resource parse(String value) { // default behavior for HTTP, HTTPS, FTP and FTPS @@ -171,6 +183,7 @@ public class DesignResourceConverter implements Converter<String, Resource> { } private static final Map<Class<? extends Resource>, ResourceConverterByProtocol> typeToConverter = new HashMap<>(); + static { typeToConverter.put(ExternalResource.class, HTTP); // ^ any of non-specialized would actually work diff --git a/server/src/main/java/com/vaadin/ui/themes/ValoTheme.java b/server/src/main/java/com/vaadin/ui/themes/ValoTheme.java index fd670a175b..2a6f87a7e1 100644 --- a/server/src/main/java/com/vaadin/ui/themes/ValoTheme.java +++ b/server/src/main/java/com/vaadin/ui/themes/ValoTheme.java @@ -15,7 +15,6 @@ */ package com.vaadin.ui.themes; -import com.vaadin.server.FontAwesome; import com.vaadin.ui.Notification.Type; /** @@ -1036,14 +1035,14 @@ public class ValoTheme { * <p> * The text content of the logo should be very short, since the logo area * only shows approximately three letters. Using one of the - * {@link FontAwesome} icons is a good way to quickly create a logo for your - * application. + * Vaadin Icons is a good way to quickly create a logo for your + * application. Vaadin Icons are included in the Valo theme. * <p> * * <h4>Example</h4> * * <pre> - * Label logo = new Label(FontAwesome.ROCKET.getHtml(), ContentMode.HTML); + * Label logo = new Label(VaadinIcons.ROCKET.getHtml(), ContentMode.HTML); * logo.setSizeUndefined(); * logo.setPrimaryStyleName(ValoTheme.MENU_LOGO); * </pre> |