Skip to content

Commit

Permalink
removed elemento, because it's not supported anymore
Browse files Browse the repository at this point in the history
treblereel committed Mar 17, 2022
1 parent bfaf11e commit 336293d
Showing 18 changed files with 99 additions and 122 deletions.
6 changes: 0 additions & 6 deletions internal-bom/pom.xml
Original file line number Diff line number Diff line change
@@ -63,7 +63,6 @@
<apache.commons.commons-lang3.version>3.11</apache.commons.commons-lang3.version>
<apache.commons.io.version>2.8.0</apache.commons.io.version>

<elemento.version>1.0.3</elemento.version>
<jsoup.version>1.11.3</jsoup.version>
<javax.inject.version>1</javax.inject.version>
<lesscss.version>1.10</lesscss.version>
@@ -107,11 +106,6 @@
<artifactId>elemental2-dom</artifactId>
<version>${elemental2.version}</version>
</dependency>
<dependency>
<groupId>org.jboss.elemento</groupId>
<artifactId>elemento-core</artifactId>
<version>${elemento.version}</version>
</dependency>
<dependency>
<groupId>com.google.auto</groupId>
<artifactId>auto-common</artifactId>
4 changes: 0 additions & 4 deletions ui/databinding/api/pom.xml
Original file line number Diff line number Diff line change
@@ -53,10 +53,6 @@
<groupId>org.gwtproject.widgets</groupId>
<artifactId>gwt-widgets</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.elemento</groupId>
<artifactId>elemento-core</artifactId>
</dependency>
<dependency>
<groupId>io.crysknife</groupId>
<artifactId>crysknife-annotations</artifactId>
Original file line number Diff line number Diff line change
@@ -27,6 +27,7 @@

import elemental2.dom.DomGlobal;
import elemental2.dom.HTMLElement;
import io.crysknife.client.IsElement;
import jsinterop.annotations.JsFunction;
import jsinterop.base.Js;
import org.gwtproject.core.client.JavaScriptObject;
@@ -45,7 +46,6 @@
import org.gwtproject.user.client.ui.HasValue;
import org.gwtproject.user.client.ui.ValueBoxBase;
import org.gwtproject.user.client.ui.Widget;
import org.jboss.elemento.IsElement;
import io.crysknife.client.internal.Assert;
import io.crysknife.client.internal.collections.Multimap;
import io.crysknife.ui.databinding.client.api.Convert;
@@ -153,10 +153,7 @@ private static Supplier<Map<Class<? extends org.gwtproject.event.shared.Event>,
if (component instanceof HasValue) {
registrar = mergeHasValueChangeHandler(component, modelUpdater, registrar);
} else if (component instanceof IsElement) {
registrar = mergeNativeChangeEventListener(((IsElement) component).element(), uiGetter,
modelUpdater, registrar);
} else if (component instanceof IsElement) {
registrar = mergeNativeChangeEventListener(((IsElement) component).element(), uiGetter,
registrar = mergeNativeChangeEventListener(((IsElement) component).getElement(), uiGetter,
modelUpdater, registrar);
} else if (isElement(component)) {
registrar = mergeNativeChangeEventListener(component, uiGetter, modelUpdater, registrar);
@@ -169,10 +166,7 @@ private static Supplier<Map<Class<? extends org.gwtproject.event.shared.Event>,
registrar = mergeNativeKeyUpEventListener(((ElementWrapperWidget) component).getElement(),
uiGetter, modelUpdater, registrar);
} else if (component instanceof IsElement) {
registrar = mergeNativeKeyUpEventListener(((IsElement) component).element(), uiGetter,
modelUpdater, registrar);
} else if (component instanceof IsElement) {
registrar = mergeNativeKeyUpEventListener(((IsElement) component).element(), uiGetter,
registrar = mergeNativeKeyUpEventListener(((IsElement) component).getElement(), uiGetter,
modelUpdater, registrar);
} else if (isElement(component)) {
registrar = mergeNativeKeyUpEventListener(component, uiGetter, modelUpdater, registrar);
@@ -384,9 +378,8 @@ private Optional<Supplier<Object>> maybeCreateUIGetter(final Object component) {
} else if (component instanceof HasText) {
return createHasTextGetter((HasText) component);
} else if (component instanceof IsElement) {
return maybeCreateElementValueGetter(BoundUtil.asElement(((IsElement) component).element()));
} else if (component instanceof IsElement) {
return maybeCreateElementValueGetter(BoundUtil.asElement(((IsElement) component).element()));
return maybeCreateElementValueGetter(
BoundUtil.asElement(((IsElement) component).getElement()));
} else if (isElement(component)) {
return maybeCreateElementValueGetter(BoundUtil.asElement(component));
} else {
@@ -762,9 +755,7 @@ private <P> void updateWidgetsAndFireEvent(final boolean sync, final String prop

private Object getUIPart(final Object component) {
if (component instanceof IsElement) {
return ((IsElement) component).element();
} else if (component instanceof IsElement) {
return ((IsElement) component).element();
return ((IsElement) component).getElement();
} else {
return component;
}
4 changes: 0 additions & 4 deletions ui/navigation/api/pom.xml
Original file line number Diff line number Diff line change
@@ -49,10 +49,6 @@
<groupId>io.crysknife</groupId>
<artifactId>crysknife-core</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.elemento</groupId>
<artifactId>elemento-core</artifactId>
</dependency>
<dependency>
<groupId>org.gwtproject.regexp</groupId>
<artifactId>gwt-regexp</artifactId>
Original file line number Diff line number Diff line change
@@ -14,8 +14,8 @@

package io.crysknife.ui.navigation.client.local;

import elemental2.core.JsArray;
import elemental2.dom.HTMLElement;
import org.jboss.elemento.ElementsBag;
import io.crysknife.ui.navigation.client.local.api.DelegationControl;

/**
@@ -34,8 +34,8 @@ public interface ContentDelegation {
* @param previousPage the previous page, <b>this can be null</b>.
* @param control the delegation control for proceeding navigation process.
*/
void showContent(Object page, HTMLElement container, ElementsBag elements, Object previousPage,
DelegationControl control);
void showContent(Object page, HTMLElement container, JsArray<HTMLElement> elements,
Object previousPage, DelegationControl control);

/**
* Called when the page is hiding its content (clearing the navigation container).
@@ -46,6 +46,6 @@ void showContent(Object page, HTMLElement container, ElementsBag elements, Objec
* @param nextPage potential next requested page, <b>this can be null</b>.
* @param control the delegation control for proceeding navigation process.
*/
void hideContent(Object page, HTMLElement container, ElementsBag elements, Object nextPage,
DelegationControl control);
void hideContent(Object page, HTMLElement container, JsArray<HTMLElement> elements,
Object nextPage, DelegationControl control);
}
Original file line number Diff line number Diff line change
@@ -14,13 +14,10 @@

package io.crysknife.ui.navigation.client.local;

import elemental2.core.JsArray;
import elemental2.dom.HTMLElement;
import org.jboss.elemento.ElementsBag;
import io.crysknife.ui.navigation.client.local.api.DelegationControl;

import static org.jboss.elemento.Elements.removeChildrenFrom;
import static org.jboss.elemento.Elements.wrapHtmlElement;

/**
* Default content delegation procedure.
*
@@ -29,18 +26,26 @@
public class DefaultContentDelegation implements ContentDelegation {

@Override
public void showContent(Object page, HTMLElement container, ElementsBag elements,
public void showContent(Object page, HTMLElement container, JsArray<HTMLElement> elements,
Object previousPage, DelegationControl control) {
if (container != null && elements != null) {
wrapHtmlElement(container).addAll(elements.elements());

elements.forEach((node, p1, p2) -> {
container.append(node);
return null;
});
}
control.proceed();
}

@Override
public void hideContent(Object page, HTMLElement container, ElementsBag elements, Object nextPage,
DelegationControl control) {
removeChildrenFrom(container);
public void hideContent(Object page, HTMLElement container, JsArray<HTMLElement> elements,
Object nextPage, DelegationControl control) {
if (container != null) {
while (container.firstChild != null) {
container.removeChild(container.firstChild);
}
}
control.proceed();
}
}
Original file line number Diff line number Diff line change
@@ -14,24 +14,18 @@

package io.crysknife.ui.navigation.client.local;

import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Queue;
import java.util.*;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;

import elemental2.core.JsArray;
import elemental2.dom.DomGlobal;
import elemental2.dom.HTMLElement;
import jsinterop.base.Js;
import org.gwtproject.event.shared.HandlerRegistration;
import org.jboss.elemento.By;
import org.jboss.elemento.Elements;
import org.jboss.elemento.ElementsBag;
import org.jboss.elemento.IsElement;
import io.crysknife.client.internal.collections.Multimap;
import io.crysknife.ui.navigation.client.local.api.DelegationControl;
import io.crysknife.ui.navigation.client.local.api.NavigationControl;
@@ -44,7 +38,6 @@

import static elemental2.dom.DomGlobal.console;
import static elemental2.dom.DomGlobal.document;
import static org.jboss.elemento.Elements.removeChildrenFrom;

/**
* Central control point for navigating between pages of the application.
@@ -120,12 +113,12 @@ private static String getAppContextFromHostPage() {

// @Inject
// @NavigationSelector
private By navigationContainerSelector;
private String navigationContainerSelector;
private HTMLElement navigationContainer;

private PageNode<Object> currentNode;
private Object currentPage;
private ElementsBag currentElements;
private JsArray<HTMLElement> currentElements;
private HistoryToken currentToken;

private ContentDelegation contentDelegation = new DefaultContentDelegation();
@@ -361,13 +354,18 @@ private <P> void hideCurrentPage(P requestPage, NavigationControl control) {
requestPage, hideControl);
} else {
// Cannot call content delegation. The contract requests that currentPage != null!
removeChildrenFrom(navigationContainer);
if (navigationContainer != null) {
while (navigationContainer.firstChild != null) {
navigationContainer.removeChild(navigationContainer.firstChild);
}
}

hideControl.proceed();
}
}
}

private <P> void pageHiding(P page, ElementsBag pageElements, Request<P> request,
private <P> void pageHiding(P page, JsArray<HTMLElement> pageElements, Request<P> request,
boolean fireEvent) {
HTMLElement navigationContainer = navigationContainer();
if (navigationContainer != null) {
@@ -408,17 +406,17 @@ && sameElements(navigationContainer, pageElements)) {
}
}

private boolean sameElements(HTMLElement navigationContainer, ElementsBag elements) {
private boolean sameElements(HTMLElement navigationContainer, JsArray<HTMLElement> elements) {
int currentElementCount = (int) navigationContainer.childElementCount;
int newElementsCount = 0;
for (HTMLElement ignored : elements.elements()) {
for (HTMLElement ignored : elements.asList()) {
newElementsCount++;
}
if (currentElementCount != newElementsCount) {
return false;
}
Iterator<HTMLElement> currentIterator = Elements.iterator(navigationContainer);
Iterator<HTMLElement> newIterator = elements.elements().iterator();
Iterator<HTMLElement> currentIterator = new JsArrayElementIterator(navigationContainer);
Iterator<HTMLElement> newIterator = elements.asList().iterator();
while (currentIterator.hasNext() && newIterator.hasNext()) {
HTMLElement currentElement = currentIterator.next();
HTMLElement newElement = newIterator.next();
@@ -488,10 +486,10 @@ public void setContentDelegation(ContentDelegation contentDelegation) {
this.contentDelegation = contentDelegation;
}

public void setNavigationContainerSelector(By selector) {
public void setNavigationContainerSelector(String selector) {
this.navigationContainerSelector = selector;
if (selector != null) {
this.navigationContainer = Elements.find(document.body, navigationContainerSelector);
document.body.querySelector(navigationContainerSelector);
}
}

@@ -524,7 +522,7 @@ private HTMLElement navigationContainer() {
return navigationContainer;
}
if (navigationContainerSelector != null) {
navigationContainer = Elements.find(document.body, navigationContainerSelector);
navigationContainer = (HTMLElement) document.body.querySelector(navigationContainerSelector);
}
if (navigationContainer == null) {
console.warn(
@@ -538,21 +536,17 @@ private HTMLElement navigationContainer() {
}

@SuppressWarnings("rawtypes")
private ElementsBag pageElements(Object page) {
ElementsBag elements = new ElementsBag();
private JsArray<HTMLElement> pageElements(Object page) {
JsArray<HTMLElement> elements = new JsArray<>();
if (page != null) {
if (page instanceof IsElement) {
elements.add(((IsElement) page).element());
} else if (page instanceof io.crysknife.client.IsElement) {
elements.add(((io.crysknife.client.IsElement) page).getElement());
if (page instanceof io.crysknife.client.IsElement) {
elements.push(((io.crysknife.client.IsElement) page).getElement());
} else if (page instanceof Iterable) {
for (Object o : ((Iterable) page)) {
if (o instanceof IsElement) {
elements.add(((IsElement) o).element());
} else if (page instanceof io.crysknife.client.IsElement) {
elements.add(((io.crysknife.client.IsElement) o).getElement());
if (page instanceof io.crysknife.client.IsElement) {
elements.push(((io.crysknife.client.IsElement) o).getElement());
} else if (o instanceof HTMLElement) {
elements.add(((HTMLElement) o));
elements.push(((HTMLElement) o));
}
}
}
@@ -573,4 +567,39 @@ private Request(PageNode<P> pageNode, HistoryToken state) {
this.state = state;
}
}

private static class JsArrayElementIterator implements Iterator<HTMLElement> {

private HTMLElement parent, last, next;

public JsArrayElementIterator(HTMLElement parent) {
this.parent = parent;
next = (HTMLElement) parent.firstElementChild;
}

@Override
public boolean hasNext() {
return next != null;
}

@Override
public HTMLElement next() {
if (!hasNext()) {
throw new NoSuchElementException();
}
last = next;
next = (HTMLElement) last.nextElementSibling;
return last;
}

@Override
public void remove() {
if (last == null) {
throw new IllegalStateException();
}
parent.removeChild(last);
last = null;
}
}

}
Original file line number Diff line number Diff line change
@@ -14,11 +14,11 @@

package io.crysknife.ui.navigation.client.local;

import io.crysknife.client.IsElement;

import javax.inject.Inject;
import javax.inject.Singleton;

import org.jboss.elemento.IsElement;

@Singleton
public class PageTransitionProvider {

Original file line number Diff line number Diff line change
@@ -14,11 +14,11 @@

package io.crysknife.ui.navigation.client.local;

import io.crysknife.client.IsElement;

import javax.inject.Inject;
import javax.inject.Singleton;

import org.jboss.elemento.IsElement;

/**
* Provides new instances of the {@link TransitionAnchorFactory} class, which allows them to be
* injected.
Original file line number Diff line number Diff line change
@@ -24,8 +24,8 @@
import javax.enterprise.event.Event;
import javax.inject.Inject;

import io.crysknife.client.IsElement;
import io.crysknife.client.utils.CreationalCallback;
import org.jboss.elemento.IsElement;
import io.crysknife.client.BeanManager;
import io.crysknife.client.internal.collections.Multimap;
import io.crysknife.ui.navigation.client.local.PageRole;
4 changes: 0 additions & 4 deletions ui/navigation/generator/pom.xml
Original file line number Diff line number Diff line change
@@ -45,10 +45,6 @@
<groupId>com.google.elemental2</groupId>
<artifactId>elemental2-dom</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.elemento</groupId>
<artifactId>elemento-core</artifactId>
</dependency>
<dependency>
<groupId>io.crysknife</groupId>
<artifactId>crysknife-processor</artifactId>
Original file line number Diff line number Diff line change
@@ -50,8 +50,8 @@
import com.github.javaparser.ast.stmt.ReturnStmt;
import com.github.javaparser.ast.type.ClassOrInterfaceType;
import com.google.auto.common.MoreElements;
import io.crysknife.client.IsElement;
import io.crysknife.client.utils.CreationalCallback;
import org.jboss.elemento.IsElement;
import io.crysknife.client.BeanManager;
import io.crysknife.client.internal.collections.BiMap;
import io.crysknife.exception.GenerationException;
@@ -161,8 +161,7 @@ protected void build(String fileName, String source, GenerationContext context)
}

private void generatePage(TypeElement page, ConstructorDeclaration ctor) {
if (!(isAssignable(page.asType(), IsElement.class)
|| isAssignable(page.asType(), io.crysknife.client.IsElement.class))) {
if (!(isAssignable(page.asType(), IsElement.class))) {
throw new GenerationException("Class " + page
+ " is annotated with @Page, so it must implement org.jboss.elemento.IsElement or io.crysknife.client.IsElement");
}
10 changes: 0 additions & 10 deletions ui/templates/api/pom.xml
Original file line number Diff line number Diff line change
@@ -44,16 +44,6 @@
<groupId>com.google.elemental2</groupId>
<artifactId>elemental2-dom</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.elemento</groupId>
<artifactId>elemento-core</artifactId>
<exclusions>
<exclusion>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.gwtproject.event</groupId>
<artifactId>gwt-event-dom</artifactId>
Original file line number Diff line number Diff line change
@@ -24,10 +24,10 @@
import elemental2.dom.Node;
import elemental2.dom.NodeFilter;
import elemental2.dom.TreeWalker;
import io.crysknife.client.IsElement;
import jsinterop.base.Js;
import org.gwtproject.safehtml.shared.SafeHtml;
import org.gwtproject.safehtml.shared.SafeHtmlUtils;
import org.jboss.elemento.IsElement;

/**
* Static helper methods used from code generated by {@code @Templated} annotation processors. You
@@ -56,11 +56,6 @@ public static <E extends HTMLElement> E resolveElementAs(HTMLElement context, St
return htmlElement;
}

public static void replaceIsElement(HTMLElement context, String identifier,
IsElement newElement) {
replaceElement(context, identifier, newElement.element());
}

// ------------------------------------------------------ IsElement / (Is)Widget methods

public static void replaceElement(HTMLElement context, String identifier,
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<module>
<inherits name="io.crysknife.Crysknife"/>
<inherits name="org.jboss.elemento.Core"/>
<inherits name="elemental2.dom.Dom"/>
<source path="client"/>
</module>
Original file line number Diff line number Diff line change
@@ -33,6 +33,7 @@
import com.inet.lib.less.Less;
import elemental2.dom.*;
import io.crysknife.annotation.Generator;
import io.crysknife.client.IsElement;
import io.crysknife.client.Reflect;
import io.crysknife.definition.BeanDefinition;
import io.crysknife.definition.InjectionParameterDefinition;
@@ -53,7 +54,6 @@
import io.crysknife.util.Utils;
import jsinterop.base.Js;
import org.apache.commons.io.IOUtils;
import org.jboss.elemento.IsElement;
import org.jboss.gwt.elemento.processor.*;
import org.jboss.gwt.elemento.processor.context.StyleSheet;
import org.jboss.gwt.elemento.processor.context.*;
@@ -634,12 +634,7 @@ public MethodCallExpr getFieldAccessCallExpr(VariableElement field) {

// TODO this method must be refactored
public Expression getInstanceByElementKind(DataElementInfo element, Expression instance) {
if (element.getKind().equals(DataElementInfo.Kind.ElementoIsElement)) {
instance = new MethodCallExpr(
new EnclosedExpr(new CastExpr(
new ClassOrInterfaceType().setName(IsElement.class.getCanonicalName()), instance)),
"element");
} else if (element.getKind().equals(DataElementInfo.Kind.CrysknifeIsElement)) {
if (element.getKind().equals(DataElementInfo.Kind.IsElement)) {
instance = new MethodCallExpr(
new EnclosedExpr(new CastExpr(new ClassOrInterfaceType()
.setName(io.crysknife.client.IsElement.class.getCanonicalName()), instance)),
@@ -946,9 +941,7 @@ private void validateType(TypeElement type, Templated templated) {
|| templatedGeneratorUtils.isAssignable(type, io.crysknife.client.IsElement.class)
|| templatedGeneratorUtils.maybeGwtWidget(type.asType()))) {
abortWithError(type, "%s must implement %s", type.getQualifiedName(),
(IsElement.class.getCanonicalName() + " or "
+ io.crysknife.client.IsElement.class.getCanonicalName() + " or "
+ templatedGeneratorUtils.isWidgetType));
(IsElement.class.getCanonicalName() + " or " + templatedGeneratorUtils.isWidgetType));
}
}

Original file line number Diff line number Diff line change
@@ -21,7 +21,6 @@
import io.crysknife.exception.GenerationException;
import io.crysknife.generator.context.IOCContext;
import jsinterop.base.Js;
import org.jboss.elemento.IsElement;
import org.jboss.gwt.elemento.processor.context.DataElementInfo;
import org.jboss.gwt.elemento.processor.context.TemplateContext;

@@ -63,10 +62,7 @@ public boolean maybeGwtDom(TypeMirror dataElementType) {
}

public String getMethodName(DataElementInfo.Kind kind) {
if (kind.equals(DataElementInfo.Kind.ElementoIsElement)
|| kind.equals(DataElementInfo.Kind.HTMLElement)) {
return "element";
} else if (kind.equals(DataElementInfo.Kind.CrysknifeIsElement)) {
if (kind.equals(DataElementInfo.Kind.IsElement)) {
return "getElement";
} else if (kind.equals(DataElementInfo.Kind.IsWidget)) {
return "getIsWidgetElement";
@@ -105,9 +101,7 @@ public DataElementInfo.Kind getDataElementInfoKind(TypeMirror dataElementType) {
if (isAssignable(dataElementType, HTMLElement.class)) {
return DataElementInfo.Kind.HTMLElement;
} else if (isAssignable(dataElementType, io.crysknife.client.IsElement.class)) {
return DataElementInfo.Kind.CrysknifeIsElement;
} else if (isAssignable(dataElementType, IsElement.class)) {
return DataElementInfo.Kind.ElementoIsElement;
return DataElementInfo.Kind.IsElement;
} else if (maybeGwtWidget(dataElementType)) {
return DataElementInfo.Kind.IsWidget;
} else if (maybeGwtDom(dataElementType)) {
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@ public class DataElementInfo {

public enum Kind {
// Name them after the related type for nicer error messages
HTMLElement, CrysknifeIsElement, ElementoIsElement, IsWidget, Custom, GWT_DOM
HTMLElement, IsElement, IsWidget, Custom, GWT_DOM
}

private final String type;

0 comments on commit 336293d

Please sign in to comment.