The CLI entrypoint is the dominokit command. It ships with standard Picocli flags (-h/--help, -V/--version) and commands for scaffolding applications/modules or managing cached dependency versions.
package com.google.gwt.user.client.ui;
import static java.util.Objects.nonNull;
/**
* Thin adapter that exposes a widget's protected attach and detach lifecycle methods.
*
* <p>Domino elements can manage attachment from the outside, but {@link Widget#onAttach()} and
* {@link Widget#onDetach()} remain protected in GWT. This class lives in the same package as
* {@link Widget} so the bridge code can forward lifecycle changes without subclassing the widget
* itself.
*/
public class WidgetWrapper {
private Widget widget;
/**
* Creates a wrapper around the supplied widget.
*
* @param widget the non-null widget whose lifecycle should be driven externally
*/
public WidgetWrapper(Widget widget) {
this.widget = widget;
}
/**
* Attaches the wrapped widget when it is not already attached.
*/
public void attach() {
onAttach();
}
/**
* Detaches the wrapped widget when it is currently attached.
*/
public void detach() {
onDetach();
}
/**
* Invokes {@link Widget#onAttach()} only when the widget is not yet attached.
*/
private void onAttach() {
if(!isAttached()) {
widget.onAttach();
}
}
/**
* Invokes {@link Widget#onDetach()} only when the widget is currently attached.
*/
private void onDetach() {
if(isAttached()) {
widget.onDetach();
}
}
/**
* Returns whether the wrapped widget exists and is already attached.
*
* @return {@code true} when the widget is non-null and attached; otherwise {@code false}
*/
private boolean isAttached() {
return nonNull(widget) && widget.isAttached();
}
}
help prints help for any command path.generate (gen) routes to project and module generators.list-versions prints the cached release profile versions (may prompt if newer releases are detected).update-versions checks for newer releases and updates the cache on confirmation. import com.google.gwt.user.client.ui.IsWidget;
import com.google.gwt.user.client.ui.Widget;
import com.google.gwt.user.client.ui.WidgetWrapper;
import elemental2.dom.HTMLElement;
import jsinterop.base.Js;
import org.dominokit.domino.ui.IsElement;
import org.dominokit.domino.ui.utils.BaseDominoElement;
import org.dominokit.domino.ui.utils.DominoElement;
import static org.dominokit.domino.ui.utils.Domino.wrap;
/**
* Bridges GWT widgets and Domino UI elements without requiring a full rewrite.
*
* <p>This helper supports both directions:
* <ul>
* <li>wrap a GWT {@link Widget} or {@link IsWidget} as a Domino {@link DominoElement}</li>
* <li>wrap a Domino {@link IsElement} back into a GWT {@link Widget}</li>
* </ul>
*
* <p>The widget-to-element path keeps the original widget root element and forwards attachment and
* detachment through {@link WidgetWrapper} so the widget lifecycle stays aligned with the Domino
* element lifecycle.
*/
public class WidgetElement extends BaseDominoElement<HTMLElement, WidgetElement> {
private final HTMLElement root;
/**
* Creates a Domino element view over the supplied widget.
*
* @param widget the widget whose root element should back this Domino element
*/
private WidgetElement(Widget widget) {
this.root = Js.uncheckedCast(widget.getElement());
init(this);
}
/**
* Returns the underlying HTML element that backs this Domino wrapper.
*
* @return the widget root element exposed as an {@link HTMLElement}
*/
@Override
public HTMLElement element() {
return this.root;
}
/**
* Wraps a Domino element as a GWT widget.
*
* <p>If the supplied element already is a {@link Widget}, it is returned unchanged. Otherwise a
* lightweight adapter is created that points the widget to the same DOM element.
*
* @param element the Domino element to expose through the Widget API
* @return the original widget or a widget adapter over the same root element
*/
public static Widget toElementWidget(IsElement<? extends HTMLElement> element) {
if (element instanceof Widget) {
return (Widget) element;
}
return new ElementWidget(element);
}
/**
* Converts an {@link IsWidget} into a {@link WidgetElement}.
*
* <p>The returned Domino element is backed by the same HTML element used by the widget.
*
* @param isWidget the source widget abstraction
* @return a Domino element wrapper over the widget root element
* @throws NullPointerException when the {@link IsWidget} cannot be resolved to a widget instance
*/
public static WidgetElement toWidgetElement(IsWidget isWidget) {
Widget widget = Widget.asWidgetOrNull(isWidget);
if (widget == null) {
throw new NullPointerException("isWidget cannot be null");
}
return new WidgetElement(widget);
}
/**
* Converts a GWT {@link Widget} into a Domino element and keeps its lifecycle synchronized.
*
* <p>When the Domino element is attached, the widget receives {@link Widget#onAttach()}; when
* it is detached, the widget receives {@link Widget#onDetach()}.
*
* @param widget the widget to expose as a Domino element
* @return a Domino element view backed by the widget's root HTML element
*/
public static DominoElement<HTMLElement> toWidgetElement(Widget widget) {
return wrap(Js.<HTMLElement>uncheckedCast(widget.getElement()))
.apply(dominoElement -> {
dominoElement.registerNowAndWhenAttached(() -> {
new WidgetWrapper(widget).attach();
});
dominoElement.nowAndWhenDetached(() -> {
new WidgetWrapper(widget).detach();
});
});
}
/**
* Simple widget adapter that exposes a Domino element as a GWT widget.
*/
private static class ElementWidget extends Widget {
/**
* Creates a widget that reuses the supplied Domino element's root HTML element.
*
* @param dominoElement the Domino element to expose through the Widget API
*/
public ElementWidget(IsElement<? extends HTMLElement> dominoElement) {
setElement(Js.uncheckedCast(dominoElement.element()));
}
}
}
Subcommands:
app — create a DominoKit project scaffold.brix-app — create a DominoKit Brix app scaffold (shortcut for -t brix).basic-app — create a DominoKit basic app scaffold (shortcut for -t basic).module — add a DominoKit module to an existing project.Prints the cached release profile versions (from ~/.domino-cli/versions.json). If Maven Central reports newer releases for auto-update groupIds, it prompts to update the cache.
import com.google.gwt.user.client.ui.TextBox;
import elemental2.dom.HTMLElement;
import org.dominokit.domino.ui.grid.Row;
import org.dominokit.domino.ui.utils.DominoElement;
TextBox legacyTextBox = new TextBox();
legacyTextBox.setValue("Legacy GWT widget");
DominoElement<HTMLElement> bridgedWidget = WidgetElement.toWidgetElement(legacyTextBox);
Row row = Row.create();
row.appendChild(bridgedWidget);
Checks Maven Central for newer release versions in the auto-update groupIds and updates the cache if approved. If stdin is unavailable, it defaults to "no" and keeps cached values.
import com.google.gwt.user.client.ui.IsWidget;
import elemental2.dom.HTMLElement;
import org.dominokit.domino.ui.utils.DominoElement;
IsWidget widgetView = someWidget;
DominoElement<HTMLElement> bridgedWidget = WidgetElement.toWidgetElement(widgetView);
Creates a new DominoKit project (basic or Brix). If you run it from inside an existing Maven project, the tool tries to read the parent pom.xml so the new module inherits groupId/version and is added to <modules>. For Brix apps, the CLI prompts to optionally create a default shell module after generation.
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.Widget;
import org.dominokit.domino.ui.forms.TextBox;
TextBox dominoTextBox = TextBox.create().withValue("Domino element exposed as a Widget");
Widget widgetAdapter = WidgetElement.toElementWidget(dominoTextBox);
RootPanel.get().add(widgetAdapter);
Options:
-n, --name (required): project name used as artifactId and to derive a module short name.-g, --groupId: group ID and root package. If omitted and a parent POM is found, the parent groupId is reused.-d, --dir: absolute output directory (defaults to CWD).-t, --type (default brix): template type. basic creates client/shared/server; brix creates a domino-brix frontend/backend/shared layout with assets and run configs.-dev, --dev (default false): use HEAD-SNAPSHOT DominoKit dependencies.--generate-api/-api (default true): generate a Quarkus REST API module (not for Brix apps).Example:
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.Widget;
import elemental2.dom.HTMLElement;
import org.dominokit.domino.ui.grid.Row;
import org.dominokit.domino.ui.utils.DominoElement;
public class BridgeExample implements EntryPoint {
@Override
public void onModuleLoad() {
TextBox legacyTextBox = new TextBox();
legacyTextBox.setValue("GWT widget inside Domino");
DominoElement<HTMLElement> bridgedWidget = WidgetElement.toWidgetElement(legacyTextBox);
Row row = Row.create();
row.appendChild(bridgedWidget);
org.dominokit.domino.ui.forms.TextBox dominoTextBox =
org.dominokit.domino.ui.forms.TextBox.create().withValue("Domino element inside GWT");
Widget widgetAdapter = WidgetElement.toElementWidget(dominoTextBox);
RootPanel.get().add(widgetAdapter);
}
}
Shortcut for generate app -t brix with the same options (without the -t flag).
dominokit generate brix-app \
-n <name> \
[-g <groupId>] \
[-d <absoluteOutputDir>] \
[-dev] \
[--generate-api[=<true|false>]]
Shortcut for generate app -t basic with the same options (without the -t flag).
dominokit generate basic-app \
-n <name> \
[-g <groupId>] \
[-d <absoluteOutputDir>] \
[-dev] \
[--generate-api[=<true|false>]]
Creates a module inside an existing DominoKit project. Use --dir to target a directory other than the current one. Module POMs reference versions from the parent project properties and expect the standard *-frontend/*-backend layout to exist.
dominokit generate module \
-n <name> \
[-sp <subPackage>] \
[-p <prefix>] \
[-d <absoluteOutputDir>]
Options:
-n, --name (required): module name and artifactId.-sp, --subpackage: subpackage appended to the application root package. Defaults to a lowercase, dot-separated form of the module name.-p, --prefix: prefix for generated class names; falls back to the module name when omitted.-d, --dir: absolute output directory (defaults to CWD).Example:
# Brix module (GWT only)
dominokit gen module -n dashboard -p Layout -sp layout