-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
196 additions
and
206 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
162 changes: 81 additions & 81 deletions
162
src/main/java/com/jwebmp/core/base/page/CSSLinksInsertPageConfigurator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,101 +1,101 @@ | ||
package com.jwebmp.core.base.page; | ||
|
||
import com.guicedee.client.*; | ||
import com.guicedee.client.IGuiceContext; | ||
import com.jwebmp.core.Page; | ||
import com.jwebmp.core.base.ComponentHierarchyBase; | ||
import com.jwebmp.core.base.html.Paragraph; | ||
import com.jwebmp.core.base.servlets.enumarations.RequirementsPriority; | ||
import com.jwebmp.core.services.*; | ||
|
||
|
||
import com.jwebmp.core.services.IPage; | ||
import com.jwebmp.core.services.RenderAfterLinks; | ||
import com.jwebmp.core.services.RenderBeforeLinks; | ||
import jakarta.validation.constraints.NotNull; | ||
import java.util.Set; | ||
|
||
import static com.jwebmp.core.implementations.JWebMPServicesBindings.*; | ||
import java.util.ServiceLoader; | ||
import java.util.Set; | ||
|
||
/** | ||
* Inserts the CSS Links into the page | ||
*/ | ||
@SuppressWarnings("unused") | ||
public class CSSLinksInsertPageConfigurator | ||
extends RequirementsPriorityAbstractInsertPageConfigurator<CSSLinksInsertPageConfigurator> | ||
extends RequirementsPriorityAbstractInsertPageConfigurator<CSSLinksInsertPageConfigurator> | ||
{ | ||
/** | ||
* Constructor CSSLinksInsertPageConfigurator creates a new CSSLinksInsertPageConfigurator instance. | ||
*/ | ||
public CSSLinksInsertPageConfigurator() | ||
{ | ||
//No config required | ||
} | ||
/** | ||
* Constructor CSSLinksInsertPageConfigurator creates a new CSSLinksInsertPageConfigurator instance. | ||
*/ | ||
public CSSLinksInsertPageConfigurator() | ||
{ | ||
//No config required | ||
} | ||
|
||
@NotNull | ||
@Override | ||
public Page<?> configure(IPage<?> pager) | ||
{ | ||
Page page = (Page)pager; | ||
if (!page.isConfigured() && enabled()) | ||
{ | ||
renderBeforeLinks(page); | ||
for (RequirementsPriority requirementsPriority : RequirementsPriority.values()) | ||
{ | ||
page.getHead() | ||
.getChildren() | ||
.addAll(getAllCssLinks(page, requirementsPriority)); | ||
} | ||
for (Object o : page.getHead() | ||
.getChildren()) | ||
{ | ||
ComponentHierarchyBase<?,?,?,?,?> headObject = (ComponentHierarchyBase<?,?,?,?,?>) o; | ||
headObject.preConfigure(); | ||
} | ||
renderAfterLinks(page); | ||
} | ||
return page; | ||
} | ||
@NotNull | ||
@Override | ||
public Page<?> configure(IPage<?> pager) | ||
{ | ||
Page page = (Page) pager; | ||
if (!page.isConfigured() && enabled()) | ||
{ | ||
renderBeforeLinks(page); | ||
for (RequirementsPriority requirementsPriority : RequirementsPriority.values()) | ||
{ | ||
page.getHead() | ||
.getChildren() | ||
.addAll(getAllCssLinks(page, requirementsPriority)); | ||
} | ||
for (Object o : page.getHead() | ||
.getChildren()) | ||
{ | ||
ComponentHierarchyBase<?, ?, ?, ?, ?> headObject = (ComponentHierarchyBase<?, ?, ?, ?, ?>) o; | ||
headObject.preConfigure(); | ||
} | ||
renderAfterLinks(page); | ||
} | ||
return page; | ||
} | ||
|
||
private void renderBeforeLinks(Page<?> page) | ||
{ | ||
Set<RenderBeforeLinks> renderB = IGuiceContext.get(RenderBeforeLinksKey); | ||
Paragraph<?> before = new Paragraph<>().setTextOnly(true); | ||
for (RenderBeforeLinks render : renderB) | ||
{ | ||
before.setText(before.getText(0) | ||
.toString() + render.render(page) | ||
.toString()); | ||
} | ||
if (before.getText(0) | ||
.toString() | ||
.trim() | ||
.length() > 0) | ||
{ | ||
page.getHead() | ||
.add(before); | ||
} | ||
} | ||
private void renderBeforeLinks(Page<?> page) | ||
{ | ||
Set<RenderBeforeLinks> renderB = IGuiceContext.loaderToSetNoInjection(ServiceLoader.load(RenderBeforeLinks.class));//.get(RenderBeforeLinksKey); | ||
Paragraph<?> before = new Paragraph<>().setTextOnly(true); | ||
for (RenderBeforeLinks render : renderB) | ||
{ | ||
before.setText(before.getText(0) | ||
.toString() + render.render(page) | ||
.toString()); | ||
} | ||
if (before.getText(0) | ||
.toString() | ||
.trim() | ||
.length() > 0) | ||
{ | ||
page.getHead() | ||
.add(before); | ||
} | ||
} | ||
|
||
private void renderAfterLinks(Page<?> page) | ||
{ | ||
Set<RenderAfterLinks> renderA = IGuiceContext.get(RenderAfterLinksKey); | ||
Paragraph<?> after = new Paragraph<>().setTextOnly(true); | ||
for (RenderAfterLinks render : renderA) | ||
{ | ||
after.setText(after.getText(0) | ||
.toString() + render.render(page) | ||
.toString()); | ||
} | ||
if (after.getText(0) | ||
.toString() | ||
.trim() | ||
.length() > 0) | ||
{ | ||
page.getHead() | ||
.add(after); | ||
} | ||
} | ||
private void renderAfterLinks(Page<?> page) | ||
{ | ||
Set<RenderAfterLinks> renderA = IGuiceContext.loaderToSetNoInjection(ServiceLoader.load(RenderAfterLinks.class));//.get(RenderAfterLinksKey); | ||
Paragraph<?> after = new Paragraph<>().setTextOnly(true); | ||
for (RenderAfterLinks render : renderA) | ||
{ | ||
after.setText(after.getText(0) | ||
.toString() + render.render(page) | ||
.toString()); | ||
} | ||
if (after.getText(0) | ||
.toString() | ||
.trim() | ||
.length() > 0) | ||
{ | ||
page.getHead() | ||
.add(after); | ||
} | ||
} | ||
|
||
@Override | ||
public Integer sortOrder() | ||
{ | ||
return Integer.MAX_VALUE - 10; | ||
} | ||
@Override | ||
public Integer sortOrder() | ||
{ | ||
return Integer.MAX_VALUE - 10; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.