Skip to content

Commit

Permalink
chore!: deperecate PageConfigurator since it has broken design (#11521)
Browse files Browse the repository at this point in the history
Part of #11518
  • Loading branch information
Denis authored Aug 6, 2021
1 parent 9f02c16 commit bfe1071
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,28 @@
import java.util.List;
import java.util.Map;

import org.jsoup.nodes.Element;
import org.jsoup.parser.Tag;

import com.vaadin.flow.component.PushConfiguration;
import com.vaadin.flow.component.ReconnectDialogConfiguration;
import com.vaadin.flow.component.UI;
import com.vaadin.flow.component.page.LoadingIndicatorConfiguration;
import com.vaadin.flow.router.AfterNavigationEvent;
import com.vaadin.flow.shared.ui.Dependency;
import com.vaadin.flow.shared.ui.LoadMode;

import elemental.json.Json;
import elemental.json.JsonObject;
import org.jsoup.nodes.Element;
import org.jsoup.parser.Tag;

/**
* Initial page settings class for modifying the bootstrap page.
*
* @since 1.0
* @deprecated Use {@link BootstrapPageResponse} instance passed via
* {@link BootstrapListener} instead
*/
@Deprecated
public class InitialPageSettings implements Serializable {

/**
Expand Down Expand Up @@ -72,16 +77,16 @@ public enum WrapMode {
* Create new initial page settings object.
*
* @param request
* initial request
* initial request
* @param ui
* target ui
* target ui
* @param afterNavigationEvent
* after navigation event
* after navigation event
* @param browser
* browser information
* browser information
*/
public InitialPageSettings(VaadinRequest request, UI ui,
AfterNavigationEvent afterNavigationEvent, WebBrowser browser) {
AfterNavigationEvent afterNavigationEvent, WebBrowser browser) {
this.request = request;
this.ui = ui;
this.afterNavigationEvent = afterNavigationEvent;
Expand Down Expand Up @@ -128,7 +133,7 @@ public WebBrowser getBrowser() {
* Set the viewport value.
*
* @param viewport
* viewport value to set
* viewport value to set
*/
public void setViewport(String viewport) {
this.viewport = viewport;
Expand All @@ -150,9 +155,9 @@ protected String getViewport() {
* Inline contents from classpath file to append to head of initial page.
*
* @param file
* dependency file to read and write to head
* dependency file to read and write to head
* @param type
* dependency type
* dependency type
*/
public void addInlineFromFile(String file, WrapMode type) {
addInlineFromFile(Position.APPEND, file, type);
Expand All @@ -162,14 +167,14 @@ public void addInlineFromFile(String file, WrapMode type) {
* Inline contents from classpath file to head of initial page.
*
* @param position
* prepend or append
* prepend or append
* @param file
* dependency file to read and write to head
* dependency file to read and write to head
* @param type
* dependency type
* dependency type
*/
public void addInlineFromFile(Position position, String file,
WrapMode type) {
WrapMode type) {
JsonObject prepend = createInlineObject(type);
prepend.put(Dependency.KEY_CONTENTS,
BootstrapUtils.getDependencyContents(request, file));
Expand All @@ -180,9 +185,9 @@ public void addInlineFromFile(Position position, String file,
* Add content to append to head of initial page.
*
* @param contents
* inline content to be added to the page
* inline content to be added to the page
* @param type
* type of content which can be JavaScript or Stylesheet (CSS)
* type of content which can be JavaScript or Stylesheet (CSS)
*/
public void addInlineWithContents(String contents, WrapMode type) {
addInlineWithContents(Position.APPEND, contents, type);
Expand All @@ -192,14 +197,14 @@ public void addInlineWithContents(String contents, WrapMode type) {
* Add content to head of initial page.
*
* @param position
* prepend or append
* prepend or append
* @param contents
* inline content to be added to the page
* inline content to be added to the page
* @param type
* type of content which can be JavaScript or Stylesheet (CSS)
* type of content which can be JavaScript or Stylesheet (CSS)
*/
public void addInlineWithContents(Position position, String contents,
WrapMode type) {
WrapMode type) {
JsonObject prepend = createInlineObject(type);
prepend.put(Dependency.KEY_CONTENTS, contents);
getInline(position).add(prepend);
Expand All @@ -209,7 +214,7 @@ public void addInlineWithContents(Position position, String contents,
* Get the list of inline objects to append to head.
*
* @param position
* prepend or append
* prepend or append
* @return current list of inline objects
*/
protected List<JsonObject> getInline(Position position) {
Expand All @@ -220,7 +225,7 @@ protected List<JsonObject> getInline(Position position) {
* Get the list of links to append to head.
*
* @param position
* prepend or append
* prepend or append
* @return current list of links
*/
protected List<Element> getElement(Position position) {
Expand All @@ -231,7 +236,7 @@ protected List<Element> getElement(Position position) {
* Add a link to be appended to initial page head.
*
* @param href
* link href
* link href
*/
public void addLink(String href) {
addLink(Position.APPEND, href);
Expand All @@ -241,9 +246,9 @@ public void addLink(String href) {
* Add a link to initial page head.
*
* @param position
* prepend or append
* prepend or append
* @param href
* link href
* link href
*/
public void addLink(Position position, String href) {
addLink(position, href, new HashMap<>());
Expand All @@ -253,9 +258,9 @@ public void addLink(Position position, String href) {
* Append a link to initial page head.
*
* @param href
* location of the linked document
* location of the linked document
* @param attributes
* map of attributes for link element
* map of attributes for link element
*/
public void addLink(String href, Map<String, String> attributes) {
addLink(Position.APPEND, href, attributes);
Expand All @@ -265,14 +270,14 @@ public void addLink(String href, Map<String, String> attributes) {
* Add a link to initial page head.
*
* @param position
* prepend or append
* prepend or append
* @param href
* location of the linked document
* location of the linked document
* @param attributes
* map of attributes for link element
* map of attributes for link element
*/
public void addLink(Position position, String href,
Map<String, String> attributes) {
Map<String, String> attributes) {
Element link = new Element(Tag.valueOf("link"), "").attr("href", href);
attributes.forEach((key, value) -> link.attr(key, value));
getElement(position).add(link);
Expand All @@ -282,9 +287,9 @@ public void addLink(Position position, String href,
* Append a link to initial page head.
*
* @param rel
* link relationship
* link relationship
* @param href
* location of the linked document
* location of the linked document
*/
public void addLink(String rel, String href) {
addLink(Position.APPEND, rel, href);
Expand All @@ -294,11 +299,11 @@ public void addLink(String rel, String href) {
* Add a link to initial page head.
*
* @param position
* prepend or append
* prepend or append
* @param rel
* link relationship
* link relationship
* @param href
* location of the linked document
* location of the linked document
*/
public void addLink(Position position, String rel, String href) {
Element link = new Element(Tag.valueOf("link"), "").attr("href", href);
Expand All @@ -310,11 +315,11 @@ public void addLink(Position position, String rel, String href) {
* Append a fav icon link to initial page head.
*
* @param rel
* link relationship
* link relationship
* @param href
* location of the fav icon
* location of the fav icon
* @param sizes
* size of the linked fav icon
* size of the linked fav icon
*/
public void addFavIcon(String rel, String href, String sizes) {
addFavIcon(Position.APPEND, rel, href, sizes);
Expand All @@ -324,16 +329,16 @@ public void addFavIcon(String rel, String href, String sizes) {
* Append a fav icon link to initial page head.
*
* @param position
* prepend or append
* prepend or append
* @param rel
* link relationship
* link relationship
* @param href
* location of the fav icon
* location of the fav icon
* @param sizes
* size of the linked fav icon
* size of the linked fav icon
*/
public void addFavIcon(Position position, String rel, String href,
String sizes) {
String sizes) {
Element link = new Element(Tag.valueOf("link"), "").attr("href", href);
link.attr("rel", rel);
link.attr("sizes", sizes);
Expand All @@ -344,9 +349,9 @@ public void addFavIcon(Position position, String rel, String href,
* Add a meta tag to be appended to initial page head.
*
* @param name
* meta tag name
* meta tag name
* @param content
* meta tag content
* meta tag content
*/
public void addMetaTag(String name, String content) {
addMetaTag(Position.APPEND, name, content);
Expand All @@ -356,11 +361,11 @@ public void addMetaTag(String name, String content) {
* Add a meta tag to initial page head.
*
* @param position
* prepend or append
* prepend or append
* @param name
* meta tag name
* meta tag name
* @param content
* meta tag content
* meta tag content
*/
public void addMetaTag(Position position, String name, String content) {
Element meta = new Element(Tag.valueOf("meta"), "").attr("name", name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@
* Configures the initial page contents.
*
* @since 1.0
*
* @deprecated Use {@link BootstrapListener} instead
*/
@Deprecated
@FunctionalInterface
public interface PageConfigurator extends Serializable {

Expand Down

0 comments on commit bfe1071

Please sign in to comment.