Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

removed elemento, because it's not supported anymore #88

Merged
merged 1 commit into from
Mar 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions internal-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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>
Expand Down
4 changes: 0 additions & 4 deletions ui/databinding/api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
}
Expand Down
4 changes: 0 additions & 4 deletions ui/navigation/api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand All @@ -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).
Expand All @@ -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
Expand Up @@ -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.
*
Expand All @@ -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
Expand Up @@ -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;
Expand All @@ -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.
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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(
Expand All @@ -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));
}
}
}
Expand All @@ -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
Expand Up @@ -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 {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Loading