Finished
This commit is contained in:
@@ -45,7 +45,7 @@ public interface DomHost {
|
||||
* Sets the element text content.
|
||||
*
|
||||
* @param elementId element id
|
||||
* @param text new text
|
||||
* @param text new text
|
||||
*/
|
||||
void setTextContent(String elementId, String text);
|
||||
|
||||
@@ -53,7 +53,7 @@ public interface DomHost {
|
||||
* Returns an attribute value or null if missing.
|
||||
*
|
||||
* @param elementId element id
|
||||
* @param name attribute name
|
||||
* @param name attribute name
|
||||
* @return value or null if missing
|
||||
*/
|
||||
String getAttribute(String elementId, String name);
|
||||
@@ -62,8 +62,8 @@ public interface DomHost {
|
||||
* Sets an attribute value (empty string allowed).
|
||||
*
|
||||
* @param elementId element id
|
||||
* @param name attribute name
|
||||
* @param value attribute value
|
||||
* @param name attribute name
|
||||
* @param value attribute value
|
||||
*/
|
||||
void setAttribute(String elementId, String name, String value);
|
||||
|
||||
@@ -71,7 +71,7 @@ public interface DomHost {
|
||||
* Removes an attribute from the element.
|
||||
*
|
||||
* @param elementId element id
|
||||
* @param name attribute name
|
||||
* @param name attribute name
|
||||
*/
|
||||
void removeAttribute(String elementId, String name);
|
||||
|
||||
@@ -94,7 +94,7 @@ public interface DomHost {
|
||||
/**
|
||||
* Creates an element and makes it addressable immediately.
|
||||
*
|
||||
* @param tagName tag name
|
||||
* @param tagName tag name
|
||||
* @param requestedId requested id or null
|
||||
* @return created element id
|
||||
*/
|
||||
@@ -111,15 +111,15 @@ public interface DomHost {
|
||||
* Appends a child element to a parent.
|
||||
*
|
||||
* @param parentId parent id
|
||||
* @param childId child id
|
||||
* @param childId child id
|
||||
*/
|
||||
void appendChild(String parentId, String childId);
|
||||
|
||||
/**
|
||||
* Inserts {@code childId} before {@code beforeChildId} within {@code parentId}.
|
||||
*
|
||||
* @param parentId parent id
|
||||
* @param childId child id
|
||||
* @param parentId parent id
|
||||
* @param childId child id
|
||||
* @param beforeChildId existing child id
|
||||
*/
|
||||
void insertBefore(String parentId, String childId, String beforeChildId);
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package org.openautonomousconnection.luascript.hosts;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Abstraction over DOM event subscription for scripting.
|
||||
*
|
||||
|
||||
@@ -58,11 +58,11 @@ public interface HostServices {
|
||||
/**
|
||||
* Creates a HostServices container.
|
||||
*
|
||||
* @param ui ui host
|
||||
* @param dom dom host
|
||||
* @param events event host
|
||||
* @param ui ui host
|
||||
* @param dom dom host
|
||||
* @param events event host
|
||||
* @param resources resource host
|
||||
* @param console console host
|
||||
* @param console console host
|
||||
*/
|
||||
public Default(UiHost ui, DomHost dom, EventHost events, ResourceHost resources, ConsoleHost console) {
|
||||
this.ui = ui;
|
||||
@@ -113,6 +113,10 @@ public interface HostServices {
|
||||
this.prefix = Objects.requireNonNull(prefix, "prefix");
|
||||
}
|
||||
|
||||
private static String safe(String s) {
|
||||
return s == null ? "" : s;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void info(String message) {
|
||||
System.out.println(prefix + "[info] " + safe(message));
|
||||
@@ -137,9 +141,5 @@ public interface HostServices {
|
||||
public void exception(String message) {
|
||||
System.err.println(prefix + "[exception] " + safe(message));
|
||||
}
|
||||
|
||||
private static String safe(String s) {
|
||||
return s == null ? "" : s;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,7 @@ public interface UiHost {
|
||||
/**
|
||||
* Displays a prompt-like query.
|
||||
*
|
||||
* @param message message
|
||||
* @param message message
|
||||
* @param defaultValue default value
|
||||
* @return user response or default
|
||||
*/
|
||||
@@ -33,7 +33,7 @@ public interface UiHost {
|
||||
* Sets element text.
|
||||
*
|
||||
* @param elementId element id
|
||||
* @param text text
|
||||
* @param text text
|
||||
*/
|
||||
void setText(String elementId, String text);
|
||||
|
||||
@@ -49,7 +49,7 @@ public interface UiHost {
|
||||
* Sets element HTML (best-effort for non-JS hosts).
|
||||
*
|
||||
* @param elementId element id
|
||||
* @param html html
|
||||
* @param html html
|
||||
*/
|
||||
void setHtml(String elementId, String html);
|
||||
|
||||
@@ -65,7 +65,7 @@ public interface UiHost {
|
||||
* Sets a form-like value.
|
||||
*
|
||||
* @param elementId element id
|
||||
* @param value value
|
||||
* @param value value
|
||||
*/
|
||||
void setValue(String elementId, String value);
|
||||
|
||||
@@ -81,7 +81,7 @@ public interface UiHost {
|
||||
* Enables/disables an element.
|
||||
*
|
||||
* @param elementId element id
|
||||
* @param enabled enabled
|
||||
* @param enabled enabled
|
||||
*/
|
||||
void setEnabled(String elementId, boolean enabled);
|
||||
|
||||
@@ -89,7 +89,7 @@ public interface UiHost {
|
||||
* Shows/hides an element.
|
||||
*
|
||||
* @param elementId element id
|
||||
* @param visible visible
|
||||
* @param visible visible
|
||||
*/
|
||||
void setVisible(String elementId, boolean visible);
|
||||
|
||||
@@ -131,8 +131,8 @@ public interface UiHost {
|
||||
* Sets a CSS property via style attribute (best-effort).
|
||||
*
|
||||
* @param elementId element id
|
||||
* @param property css property
|
||||
* @param value css value
|
||||
* @param property css property
|
||||
* @param value css value
|
||||
*/
|
||||
void setStyle(String elementId, String property, String value);
|
||||
|
||||
@@ -140,7 +140,7 @@ public interface UiHost {
|
||||
* Gets a CSS property via style attribute (best-effort).
|
||||
*
|
||||
* @param elementId element id
|
||||
* @param property css property
|
||||
* @param property css property
|
||||
* @return css value or empty string
|
||||
*/
|
||||
String getStyle(String elementId, String property);
|
||||
@@ -149,8 +149,8 @@ public interface UiHost {
|
||||
* Sets an attribute.
|
||||
*
|
||||
* @param elementId element id
|
||||
* @param name attribute name
|
||||
* @param value value
|
||||
* @param name attribute name
|
||||
* @param value value
|
||||
*/
|
||||
void setAttribute(String elementId, String name, String value);
|
||||
|
||||
@@ -158,7 +158,7 @@ public interface UiHost {
|
||||
* Gets an attribute value or null if missing.
|
||||
*
|
||||
* @param elementId element id
|
||||
* @param name attribute name
|
||||
* @param name attribute name
|
||||
* @return value or null
|
||||
*/
|
||||
String getAttribute(String elementId, String name);
|
||||
@@ -167,7 +167,7 @@ public interface UiHost {
|
||||
* Removes an attribute.
|
||||
*
|
||||
* @param elementId element id
|
||||
* @param name attribute name
|
||||
* @param name attribute name
|
||||
*/
|
||||
void removeAttribute(String elementId, String name);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user