Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ matrix:
- ant $OPTS build
script:
- travis_retry hide-logs.sh ant $OPTS -f platform/api.htmlui test
- travis_retry hide-logs.sh ant $OPTS -f platform/htmlui test
- hide-logs.sh ant $OPTS -f platform/api.intent test
- hide-logs.sh ant $OPTS -f platform/api.io test
- hide-logs.sh ant $OPTS -f platform/api.progress test
Expand Down
9 changes: 5 additions & 4 deletions harness/nbjunit/src/org/netbeans/junit/MockServices.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@
import java.util.NoSuchElementException;
import java.util.logging.Level;
import java.util.logging.Logger;
import junit.framework.Assert;
import junit.framework.AssertionFailedError;

/**
* Lets you register mock implementations of global services.
Expand Down Expand Up @@ -161,7 +159,10 @@ public ServiceClassLoader(Class<?>[] services, ClassLoader l, boolean test) {
for (Class<?> c : services) {
try {
if (test) {
Assert.assertEquals(c, getParent().loadClass(c.getName()));
final Class<?> real = getParent().loadClass(c.getName());
if (!c.equals(real)) {
throw new AssertionError("Service " + c + " isn't " + real);
}
}
int mods = c.getModifiers();
if (!Modifier.isPublic(mods) || Modifier.isAbstract(mods)) {
Expand All @@ -173,7 +174,7 @@ public ServiceClassLoader(Class<?>[] services, ClassLoader l, boolean test) {
} catch (NoSuchMethodException x) {
throw (IllegalArgumentException) new IllegalArgumentException("Class " + c.getName() + " has no public no-arg constructor").initCause(x);
} catch (Exception x) {
throw (AssertionFailedError) new AssertionFailedError(x.toString()).initCause(x);
throw new AssertionError(x.toString(), x);
}
}
this.services = services;
Expand Down
2 changes: 2 additions & 0 deletions nbbuild/cluster.properties
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ nb.cluster.platform=\
editor.mimelookup,\
editor.mimelookup.impl,\
favorites,\
htmlui,\
janitor,\
javahelp,\
junitlib,\
Expand Down Expand Up @@ -263,6 +264,7 @@ nb.cluster.platform=\
o.apache.commons.logging,\
o.n.core,\
o.n.html.ko4j,\
o.n.html.presenters.spi,\
o.n.html.xhr4j,\
o.n.swing.laf.dark,\
o.n.swing.laf.flatlaf,\
Expand Down
3 changes: 1 addition & 2 deletions platform/api.htmlui/manifest.mf
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
Manifest-Version: 1.0
OpenIDE-Module: org.netbeans.api.htmlui
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/htmlui/Bundle.properties
OpenIDE-Module-Specification-Version: 1.22

OpenIDE-Module-Specification-Version: 1.23
29 changes: 10 additions & 19 deletions platform/api.htmlui/nbproject/project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,6 @@
<compile-dependency/>
<run-dependency/>
</dependency>
<dependency>
<code-name-base>net.java.html.boot.fx</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency/>
</dependency>
<dependency>
<code-name-base>net.java.html.json</code-name-base>
<build-prerequisite/>
Expand All @@ -57,14 +51,6 @@
<code-name-base>org.netbeans.html.xhr4j</code-name-base>
<run-dependency/>
</dependency>
<dependency>
<code-name-base>org.netbeans.libs.javafx</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<specification-version>2.4</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>org.netbeans.libs.asm</code-name-base>
<build-prerequisite/>
Expand Down Expand Up @@ -94,27 +80,27 @@
</run-dependency>
</dependency>
<dependency>
<code-name-base>org.openide.util.ui</code-name-base>
<code-name-base>org.openide.util</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<specification-version>9.3</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>org.openide.util</code-name-base>
<code-name-base>org.openide.util.lookup</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<specification-version>9.3</specification-version>
<specification-version>8.25</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>org.openide.util.lookup</code-name-base>
<code-name-base>org.openide.util.ui</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<specification-version>8.25</specification-version>
<specification-version>9.3</specification-version>
</run-dependency>
</dependency>
<dependency>
Expand Down Expand Up @@ -142,10 +128,15 @@
<code-name-base>org.netbeans.libs.testng</code-name-base>
<compile-dependency/>
</test-dependency>
<test-dependency>
<code-name-base>org.netbeans.modules.nbjunit</code-name-base>
<compile-dependency/>
</test-dependency>
</test-type>
</test-dependencies>
<public-packages>
<package>org.netbeans.api.htmlui</package>
<package>org.netbeans.spi.htmlui</package>
</public-packages>
</data>
</configuration>
Expand Down
101 changes: 67 additions & 34 deletions platform/api.htmlui/src/org/netbeans/api/htmlui/HTMLDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,15 @@
import java.lang.annotation.Target;
import java.util.Locale;
import java.awt.event.ActionEvent;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import net.java.html.json.Model;
import net.java.html.json.Property;
import org.netbeans.html.context.spi.Contexts.Id;
import org.netbeans.modules.htmlui.HTMLDialogImpl;
import org.netbeans.modules.htmlui.HTMLDialogBase;

/** Generates method that opens an HTML based modal dialog. Sample of a typical
/** Generates method that opens an HTML based modal dialog. Sample of a typical
* usage follows.
* <b>HTML Page <small>dialog.html</small></b>
* <pre>
Expand Down Expand Up @@ -60,9 +63,9 @@

{@link Override @Override} <b>public void</b> actionPerformed({@link ActionEvent} e) {
// shows dialog with a question, checkbox is checked by default
// {@link #className() Pages} is automatically generated class
// {@link #className() Pages} is automatically generated class
String ret = Pages.showHelloWorld(true);

System.out.println("User selected: " + ret);
}
}
Expand All @@ -71,13 +74,13 @@
* The method is generated into <code>Pages</code> class in the same package
* (unless one changes the name via {@link #className()}) and has the same name,
* and parameters as the method annotated by this annotation. When the method
* is invoked, it opens a dialog, loads an HTML page into it. When the page is
* is invoked, it opens a dialog, loads an HTML page into it. When the page is
* loaded, it calls back the method annotated by this annotation and passes it
* its own arguments. The method is supposed to make the page live, preferrably
* by using {@link net.java.html.json.Model} generated class and calling
* its own arguments. The method is supposed to make the page live, preferrably
* by using {@link net.java.html.json.Model} generated class and calling
* <code>applyBindings()</code> on it.
* <p>
* The HTML page may contain hidden <code>&lt;button&gt;</code> elements. If it does so,
* The HTML page may contain hidden <code>&lt;button&gt;</code> elements. If it does so,
* those buttons are copied to the dialog frame and displayed underneath the page.
* Their enabled/disabled state reflects the state of the buttons in the page.
* When one of the buttons is selected, the dialog closes and the generated
Expand All @@ -88,7 +91,7 @@
* <code>&lt;button&gt;</code> elements, two buttons are added. One representing
* the <em>OK</em> choice (with <code>id="OK"</code>) and one representing
* the cancel choice (with <code>null</code> id). Both buttons are always
* enabled. One can check the
* enabled. One can check the
* return value from the dialog showing method
* to be <code>"OK"</code> to know whether the
* user approved the dialog.
Expand All @@ -102,100 +105,130 @@
* Will be resolved by the annotation processor and converted into
* <code>nbresloc</code> protocol - as such the HTML page can be L10Ned
* later by adding classical L10N suffixes. E.g. <code>index_cs.html</code>
* will take preceedence over <code>index.html</code> if the user is
* will take preceedence over <code>index.html</code> if the user is
* running in Czech {@link Locale}.
*
*
* @return relative path the HTML page
*/
String url();

/** Name of the file to generate the method that opens the dialog
* into. Class of such name will be generated into the same
* package.
*
* package.
*
* @return name of class to generate
*/
String className() default "Pages";

/** Selects some of provided technologies. The HTML/Java API @ version 1.1
* supports {@link Id technology ids}. One can specify the preferred ones
* to use in this NetBeans component by using this attribute.
*
*
* @return list of preferred technology ids
* @since 1.3
*/
String[] techIds() default {};

/** Rather than using this class directly, consider
* {@link HTMLDialog}. The {@link HTMLDialog} annotation

/**
*
* @since 1.23
*/
@FunctionalInterface
public interface OnSubmit {
/** Callback when a button is pressed.
*
* @param button the ID of the pressed button or {@code null} on cancel
* @return {@code true} to close the dialog, {@code false} to ignore
* the button press and leave the dialog open
* @since 1.23
*/
boolean onSubmit(String button);
}

/** Rather than using this class directly, consider
* {@link HTMLDialog}. The {@link HTMLDialog} annotation
* generates boilderplate code for you
* and can do some compile times checks helping you to warnings
* as soon as possible.
*/
public static final class Builder {
private final HTMLDialogImpl impl;

private final String url;
private List<String> techIds = new ArrayList<>();
private Runnable onPageLoad;

private Builder(String u) {
impl = new HTMLDialogImpl();
impl.setUrl(u);
this.url = u;
}

/** Starts creation of a new HTML dialog. The page
* can contain hidden buttons as described at
* {@link HTMLDialog}.
*
*
* @param url URL (usually using <code>nbresloc</code> protocol)
* of the page to display in the dialog.
* @return instance of the builder
*/
public static Builder newDialog(String url) {
return new Builder(url);
}

/** Registers a runnable to be executed when the page
* becomes ready.
*
*
* @param run runnable to run
* @return this builder
*/
public Builder loadFinished(Runnable run) {
impl.setOnPageLoad(run);
this.onPageLoad = run;
return this;
}

/** Requests some of provided technologies. The HTML/Java API @ version 1.1
* supports {@link Id technology ids}. One can specify the preferred ones
* to use in this NetBeans component by using calling this method.
*
*
* @param ids list of preferred technology ids to add to the builder
* @return instance of the builder
* @since 1.3
*/
public Builder addTechIds(String... ids) {
impl.addTechIds(ids);
techIds.addAll(Arrays.asList(ids));
return this;
}

/** Displays the dialog. This method blocks waiting for the
* dialog to be shown and closed by the user.
*
/** Displays the dialog and waits. This method blocks waiting for the
* dialog to be shown and closed by the user.
*
* @return 'id' of a selected button element or <code>null</code>
* if the dialog was closed without selecting a button
*/
public String showAndWait() {
HTMLDialogBase impl = HTMLDialogBase.create(url, onPageLoad, null, techIds.toArray(new String[0]), null);
return impl.showAndWait();
}


/** Displays the dialog and returns immediately.
*
* @param s callback to call when a button is clicked and dialog
* is about to be closed
* @since 1.23
*/
public void show(OnSubmit s) {
HTMLDialogBase impl = HTMLDialogBase.create(url, onPageLoad, s, techIds.toArray(new String[0]), null);
impl.show(s);
}

/** Obtains the component from the builder. The parameter
* can either be {@link javafx.embed.swing.JFXPanel}.<b>class</b> or
* {@link javafx.scene.web.WebView}.<b>class</b>. After calling this
* method the builder becomes useless.
*
*
* @param <C> requested component type
* @param type either {@link javafx.embed.swing.JFXPanel} or {@link javafx.scene.web.WebView} class
* @return instance of the requested component
*/
public <C> C component(Class<C> type) {
HTMLDialogBase impl = HTMLDialogBase.create(url, onPageLoad, null, techIds.toArray(new String[0]), type);
return impl.component(type);
}
}
Expand Down
Loading