-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
external FS dialog provider and confirmations
- Loading branch information
Showing
20 changed files
with
225 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
demo-edit-es-module/src/main/java/org/sudu/experiments/esm/JsDialogProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package org.sudu.experiments.esm; | ||
|
||
import org.sudu.experiments.esm.dlg.JsDialogInput; | ||
import org.sudu.experiments.esm.dlg.JsDialogResult; | ||
import org.sudu.experiments.js.Promise; | ||
import org.teavm.jso.JSObject; | ||
|
||
// export interface ExternalDialogProvider | ||
public interface JsDialogProvider extends JSObject { | ||
// showModalDialog(input: DialogInput): Promise<DialogResult | null> | ||
Promise<JsDialogResult> showModalDialog(JsDialogInput input); | ||
} |
8 changes: 0 additions & 8 deletions
8
demo-edit-es-module/src/main/java/org/sudu/experiments/esm/JsExternalDialogProvider.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
demo-edit-es-module/src/main/java/org/sudu/experiments/esm/dlg/FsDialogs.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package org.sudu.experiments.esm.dlg; | ||
|
||
import org.sudu.experiments.esm.JsDialogProvider; | ||
import org.sudu.experiments.js.JsArray; | ||
import org.sudu.experiments.js.JsHelper; | ||
|
||
public class FsDialogs { | ||
public static void showDlg( | ||
JsDialogProvider p, | ||
String from, String to, | ||
Runnable action | ||
) { | ||
var bOk = JsNative.createButton("OK", true); | ||
var bCancel = JsNative.createButton("cancel", false); | ||
var i = JsNative.createInput( | ||
"confirm file copy operation", | ||
"from file " + from + " to " + to, | ||
JsArray.create(), | ||
JsHelper.toJsArray(bOk, bCancel) | ||
); | ||
p.showModalDialog(i).then( | ||
result -> { | ||
if (result.getButton() == bOk) | ||
action.run(); | ||
}, e -> {} | ||
); | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
demo-edit-es-module/src/main/java/org/sudu/experiments/esm/dlg/JsDialogButton.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package org.sudu.experiments.esm.dlg; | ||
|
||
import org.sudu.experiments.js.JsHelper; | ||
import org.teavm.jso.JSFunctor; | ||
import org.teavm.jso.JSObject; | ||
import org.teavm.jso.JSProperty; | ||
import org.teavm.jso.core.JSString; | ||
|
||
// export type DialogButton | ||
public interface JsDialogButton extends JSObject { | ||
// title: string | ||
@JSProperty | ||
JSString getTitle(); | ||
|
||
@JSProperty | ||
boolean isDefault(); | ||
|
||
// isDefault?: boolean | ||
static boolean isDefault(JsDialogButton button) { | ||
return JsHelper.hasProperty(button, "default") | ||
&& button.isDefault(); | ||
} | ||
|
||
// isEnabled: (state: DialogState) => boolean | ||
@JSProperty | ||
IsEnabled getIsEnabled(); | ||
|
||
@JSFunctor | ||
interface IsEnabled extends JSObject { | ||
boolean get(JsDialogState state); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
demo-edit-es-module/src/main/java/org/sudu/experiments/esm/dlg/JsDialogInput.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package org.sudu.experiments.esm.dlg; | ||
|
||
import org.sudu.experiments.js.JsArray; | ||
import org.teavm.jso.JSObject; | ||
import org.teavm.jso.JSProperty; | ||
import org.teavm.jso.core.JSString; | ||
|
||
// export type DialogInput | ||
public interface JsDialogInput extends JSObject { | ||
// title: string | ||
@JSProperty | ||
JSString getTitle(); | ||
|
||
// text: string | ||
@JSProperty | ||
JSString getText(); | ||
|
||
// options: DialogOption[] | ||
@JSProperty | ||
JsArray<JsDialogOption> getOptions(); | ||
|
||
// buttons: DialogButton[] | ||
@JSProperty | ||
JsArray<JsDialogButton> getButtons(); | ||
} |
19 changes: 19 additions & 0 deletions
19
demo-edit-es-module/src/main/java/org/sudu/experiments/esm/dlg/JsDialogOption.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package org.sudu.experiments.esm.dlg; | ||
|
||
import org.teavm.jso.JSObject; | ||
import org.teavm.jso.JSProperty; | ||
|
||
/* | ||
export type DialogOption = { | ||
title: string | ||
isEnabled: boolean | ||
} | ||
*/ | ||
|
||
public interface JsDialogOption extends JSObject { | ||
@JSProperty | ||
JSObject getTitle(); | ||
|
||
@JSProperty | ||
boolean getIsEnabled(); | ||
} |
16 changes: 16 additions & 0 deletions
16
demo-edit-es-module/src/main/java/org/sudu/experiments/esm/dlg/JsDialogResult.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package org.sudu.experiments.esm.dlg; | ||
|
||
import org.sudu.experiments.js.JsArray; | ||
import org.teavm.jso.JSObject; | ||
import org.teavm.jso.JSProperty; | ||
|
||
// export type DialogResult | ||
public interface JsDialogResult extends JSObject { | ||
// button: DialogButton | ||
@JSProperty | ||
JsDialogButton getButton(); | ||
|
||
// options: DialogOption[] | ||
@JSProperty | ||
JsArray<JsDialogOption> getOptions(); | ||
} |
12 changes: 12 additions & 0 deletions
12
demo-edit-es-module/src/main/java/org/sudu/experiments/esm/dlg/JsDialogState.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package org.sudu.experiments.esm.dlg; | ||
|
||
import org.sudu.experiments.js.JsArray; | ||
import org.teavm.jso.JSObject; | ||
import org.teavm.jso.JSProperty; | ||
|
||
// export type DialogState | ||
public interface JsDialogState extends JSObject { | ||
// options: DialogOption[] | ||
@JSProperty | ||
JsArray<JsDialogOption> getOptions(); | ||
} |
55 changes: 55 additions & 0 deletions
55
demo-edit-es-module/src/main/java/org/sudu/experiments/esm/dlg/JsNative.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package org.sudu.experiments.esm.dlg; | ||
|
||
import org.sudu.experiments.js.JsArray; | ||
import org.teavm.jso.JSBody; | ||
|
||
public class JsNative { | ||
@JSBody( | ||
params = {"title", "isDefault", "isEnabled"}, | ||
script = "return {title:title, isDefault:isDefault, isEnabled:isEnabled};" | ||
) | ||
public static native JsDialogButton createButton( | ||
String title, | ||
boolean isDefault, | ||
JsDialogButton.IsEnabled isEnabled | ||
); | ||
|
||
@JSBody( | ||
params = {"title", "isDefault"}, | ||
script = | ||
"return {title:title, isDefault:isDefault, " + | ||
"isEnabled: state => true };" | ||
) | ||
public static native JsDialogButton createButton( | ||
String title, | ||
boolean isDefault | ||
); | ||
|
||
@JSBody( | ||
params = {"title", "isDefault"}, | ||
script = "return {title:title, isDefault:isDefault};" | ||
) | ||
public static native JsDialogOption createOption( | ||
String title, | ||
boolean isDefault | ||
); | ||
|
||
@JSBody( | ||
params = "options", | ||
script = "return {options:options};" | ||
) | ||
public static native JsDialogState createState( | ||
JsArray<JsDialogOption> options | ||
); | ||
|
||
@JSBody( | ||
params = {"title", "text", "options", "buttons"}, | ||
script = "return {title:title, text:text, options:options, buttons:buttons};" | ||
) | ||
public static native JsDialogInput createInput( | ||
String title, | ||
String text, | ||
JsArray<JsDialogOption> options, | ||
JsArray<JsDialogButton> buttons | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters