From 28a9280829021793c88a08d90c1763c29cecbffd Mon Sep 17 00:00:00 2001 From: richie Date: Sat, 9 Mar 2019 09:34:20 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=A0JIRA=E4=BB=BB=E5=8A=A1=20=E6=8F=90?= =?UTF-8?q?=E4=BE=9B=E5=86=85=E7=BD=AE=E7=A4=BA=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/actions/help/FineUIAction.java | 70 ++++++ .../mainframe/toolbar/ToolBarMenuDock.java | 9 +- .../resources/com/fr/design/ui/help/demo.js | 220 ++++++++++++++++++ .../java/com/fr/design/ui/FineUIDemo.java | 2 +- .../com/fr/design/ui/script/start.js | 162 ------------- 5 files changed, 299 insertions(+), 164 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/design/actions/help/FineUIAction.java create mode 100644 designer-base/src/main/resources/com/fr/design/ui/help/demo.js diff --git a/designer-base/src/main/java/com/fr/design/actions/help/FineUIAction.java b/designer-base/src/main/java/com/fr/design/actions/help/FineUIAction.java new file mode 100644 index 0000000000..39008ee144 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/actions/help/FineUIAction.java @@ -0,0 +1,70 @@ +package com.fr.design.actions.help; + +import com.fr.design.actions.UpdateAction; +import com.fr.design.dialog.BasicDialog; +import com.fr.design.dialog.DialogActionAdapter; +import com.fr.design.mainframe.DesignerContext; +import com.fr.design.ui.ModernUIPane; +import com.fr.locale.InterProviderFactory; +import com.fr.web.struct.AssembleComponent; +import com.fr.web.struct.Atom; +import com.fr.web.struct.browser.RequestClient; +import com.fr.web.struct.category.ScriptPath; +import com.fr.web.struct.impl.FineUI; +import com.teamdev.jxbrowser.chromium.JSValue; +import com.teamdev.jxbrowser.chromium.events.ScriptContextAdapter; +import com.teamdev.jxbrowser.chromium.events.ScriptContextEvent; + +import java.awt.event.ActionEvent; + +/** + * @author richie + * @version 10.0 + * Created by richie on 2019-03-08 + */ +public class FineUIAction extends UpdateAction { + + public FineUIAction() { + setName("FineUI"); + } + + @Override + public void actionPerformed(final ActionEvent e) { + ModernUIPane pane = new ModernUIPane.Builder<>() + .prepare(new ScriptContextAdapter() { + @Override + public void onScriptContextCreated(ScriptContextEvent event) { + JSValue pool = event.getBrowser().executeJavaScriptAndReturnValue("window.Pool"); + pool.asObject().setProperty("i18n", new I18n()); + } + }) + .withComponent(new AssembleComponent() { + + @Override + public ScriptPath script(RequestClient req) { + return ScriptPath.build("/com/fr/design/ui/help/demo.js"); + } + + @Override + public Atom[] refer() { + return new Atom[] {FineUI.KEY}; + } + }) + .build(); + BasicDialog dialog = pane.showLargeWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { + @Override + public void doOk() { + + } + }); + dialog.setVisible(true); + + } + + public static class I18n { + + public String i18nText(String key) { + return InterProviderFactory.getProvider().getLocText(key); + } + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java b/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java index 3885ff71d5..ff31f01564 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java @@ -6,6 +6,7 @@ package com.fr.design.mainframe.toolbar; import com.fr.base.FRContext; import com.fr.base.vcs.DesignerMode; import com.fr.design.DesignState; +import com.fr.design.DesignerEnvManager; import com.fr.design.ExtraDesignClassManager; import com.fr.design.actions.UpdateAction; import com.fr.design.actions.community.BBSAction; @@ -24,6 +25,7 @@ import com.fr.design.actions.file.OpenTemplateAction; import com.fr.design.actions.file.PreferenceAction; import com.fr.design.actions.file.SwitchExistEnv; import com.fr.design.actions.help.AboutAction; +import com.fr.design.actions.help.FineUIAction; import com.fr.design.actions.help.TutorialAction; import com.fr.design.actions.help.WebDemoAction; import com.fr.design.actions.help.alphafine.AlphaFineAction; @@ -499,9 +501,14 @@ public abstract class ToolBarMenuDock { if (AlphaFineConfigManager.isALPHALicAvailable()) { shortCuts.add(new AlphaFineAction()); } + shortCuts.add(SeparatorDef.DEFAULT); + if (DesignerEnvManager.getEnvManager().isOpenDebug()) { + shortCuts.add(new FineUIAction()); + } shortCuts.add(new AboutAction()); - return shortCuts.toArray(new ShortCut[shortCuts.size()]); + + return shortCuts.toArray(new ShortCut[0]); } /** diff --git a/designer-base/src/main/resources/com/fr/design/ui/help/demo.js b/designer-base/src/main/resources/com/fr/design/ui/help/demo.js new file mode 100644 index 0000000000..fd4694d1a4 --- /dev/null +++ b/designer-base/src/main/resources/com/fr/design/ui/help/demo.js @@ -0,0 +1,220 @@ +window.addEventListener("load", function (ev) { + window.BI.i18nText = function(key) {return window.Pool.i18n.i18nText(key);} + var combo1 = BI.createWidget({ + type: "bi.vertical", + items: [ + { + type: "bi.text_value_combo", + text: "选项1", + width: 300, + items: [ + { + el: { + type: "bi.single_select_radio_item", + width: 290, + text: "选项1", + value: 1 + }, + text: "选项1", + value: 1, + lgap: 10 + }, + { + el: { + type: "bi.single_select_radio_item", + width: 290, + text: "选项2", + value: 2 + }, + lgap: 10, + text: "选项2", + value: 2 + }, + { + el: { + type: "bi.single_select_radio_item", + width: 290, + text: "选项3", + value: 3 + }, + lgap: 10, + text: "选项3", + value: 3 + } + ] + } + ] + }); + + var date = BI.createWidget({ + type: "bi.left", + items: [{ + el: { + type: "bi.date_time_combo", + value: { + year: 2018, + month: 9, + day: 28, + hour: 13, + minute: 31, + second: 1 + } + } + }] + }); + + var comboTree = BI.createWidget({ + type: "bi.vertical", + items: [ + { + type: "bi.tree_value_chooser_combo", + width: 300, + itemsCreator: function(op, callback) { + callback([ + { + id: 1, + text: "第1项", + value: "1" + }, + { + id: 2, + text: "第2项", + value: "2" + }, + { + id: 3, + text: "第3项", + value: "3", + open: true + }, + { + id: 11, + pId: 1, + text: "子项1", + value: "11" + }, + { + id: 12, + pId: 1, + text: "子项2", + value: "12" + }, + { + id: 13, + pId: 1, + text: "子项3", + value: "13" + }, + { + id: 31, + pId: 3, + text: "子项1", + value: "31" + }, + { + id: 32, + pId: 3, + text: "子项2", + value: "32" + }, + { + id: 33, + pId: 3, + text: "子项3", + value: "33" + } + ]); + } + } + ] + }); + + var color = BI.createWidget({ + type: "bi.left", + items: [{ + type: "bi.simple_color_chooser", + width: 24, + height: 24 + }, { + el: { + type: "bi.color_chooser", + width: 230, + height: 24 + }, + lgap: 10 + }] + }); + + var Slider = BI.inherit(BI.Widget, { + props: { + width: 300, + height: 50, + min: 0, + max: 100 + }, + + mounted: function() { + var o = this.options; + this.singleSliderInterval.setMinAndMax({ + min: o.min, + max: o.max + }); + + this.singleSliderInterval.setValue({ + min: 10, + max: 80 + }); + this.singleSliderInterval.populate(); + }, + + render: function() { + var self = this, + o = this.options; + return { + type: "bi.vertical", + element: this, + items: [ + { + type: "bi.interval_slider", + digit: 0, + width: o.width, + height: o.height, + ref: function(_ref) { + self.singleSliderInterval = _ref; + } + } + ] + }; + } + }); + BI.shortcut("demo.slider_interval", Slider); + var slider = BI.createWidget({ + type: "demo.slider_interval" + }); + + BI.createWidget({ + type:"bi.absolute", + element: "body", + items: [{ + el: combo1, + left: 100, + top: 100 + }, { + el : date, + left: 100, + top : 150 + }, { + el : comboTree, + left : 100, + top : 200 + }, { + el : color, + left : 100, + top : 250 + }, { + el : slider, + left : 400, + top : 100 + }] + }); +}); \ No newline at end of file diff --git a/designer-base/src/test/java/com/fr/design/ui/FineUIDemo.java b/designer-base/src/test/java/com/fr/design/ui/FineUIDemo.java index afd0a5d1d9..c7dd4b6821 100644 --- a/designer-base/src/test/java/com/fr/design/ui/FineUIDemo.java +++ b/designer-base/src/test/java/com/fr/design/ui/FineUIDemo.java @@ -20,7 +20,7 @@ public class FineUIDemo { DesignerEnvManager.getEnvManager().setOpenDebug(true); final ModernUIPane pane = new ModernUIPane.Builder() - .withComponent(StartComponent.KEY).namespace("Pool").build(); + .withComponent(StartComponent.KEY).build(); contentPane.add(pane, BorderLayout.CENTER); frame.setVisible(true); frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); diff --git a/designer-base/src/test/resources/com/fr/design/ui/script/start.js b/designer-base/src/test/resources/com/fr/design/ui/script/start.js index 4eaff6f464..529aa92ff4 100644 --- a/designer-base/src/test/resources/com/fr/design/ui/script/start.js +++ b/designer-base/src/test/resources/com/fr/design/ui/script/start.js @@ -45,152 +45,6 @@ window.addEventListener("load", function (ev) { ] }); - var date = BI.createWidget({ - type: "bi.left", - items: [{ - el: { - type: "bi.date_time_combo", - value: { - year: 2018, - month: 9, - day: 28, - hour: 13, - minute: 31, - second: 1 - } - } - }] - }); - - var comboTree = BI.createWidget({ - type: "bi.vertical", - items: [ - { - type: "bi.tree_value_chooser_combo", - width: 300, - itemsCreator: function(op, callback) { - callback([ - { - id: 1, - text: "第1项", - value: "1" - }, - { - id: 2, - text: "第2项", - value: "2" - }, - { - id: 3, - text: "第3项", - value: "3", - open: true - }, - { - id: 11, - pId: 1, - text: "子项1", - value: "11" - }, - { - id: 12, - pId: 1, - text: "子项2", - value: "12" - }, - { - id: 13, - pId: 1, - text: "子项3", - value: "13" - }, - { - id: 31, - pId: 3, - text: "子项1", - value: "31" - }, - { - id: 32, - pId: 3, - text: "子项2", - value: "32" - }, - { - id: 33, - pId: 3, - text: "子项3", - value: "33" - } - ]); - } - } - ] - }); - - var color = BI.createWidget({ - type: "bi.left", - items: [{ - type: "bi.simple_color_chooser", - width: 24, - height: 24 - }, { - el: { - type: "bi.color_chooser", - width: 230, - height: 24 - }, - lgap: 10 - }] - }); - - var Slider = BI.inherit(BI.Widget, { - props: { - width: 300, - height: 50, - min: 0, - max: 100 - }, - - mounted: function() { - var o = this.options; - this.singleSliderInterval.setMinAndMax({ - min: o.min, - max: o.max - }); - - this.singleSliderInterval.setValue({ - min: 10, - max: 80 - }); - this.singleSliderInterval.populate(); - }, - - render: function() { - var self = this, - o = this.options; - return { - type: "bi.vertical", - element: this, - items: [ - { - type: "bi.interval_slider", - digit: 0, - width: o.width, - height: o.height, - ref: function(_ref) { - self.singleSliderInterval = _ref; - } - } - ] - }; - } - }); - BI.shortcut("demo.slider_interval", Slider); - var slider = BI.createWidget({ - type: "demo.slider_interval" - }); - BI.createWidget({ type:"bi.absolute", element: "body", @@ -198,22 +52,6 @@ window.addEventListener("load", function (ev) { el: combo1, left: 100, top: 100 - }, { - el : date, - left: 100, - top : 150 - }, { - el : comboTree, - left : 100, - top : 200 - }, { - el : color, - left : 100, - top : 250 - }, { - el : slider, - left : 400, - top : 100 }] }); }); \ No newline at end of file