Browse Source

无JIRA任务 提供内置示例

bugfix/10.0
richie 6 years ago
parent
commit
28a9280829
  1. 70
      designer-base/src/main/java/com/fr/design/actions/help/FineUIAction.java
  2. 9
      designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java
  3. 220
      designer-base/src/main/resources/com/fr/design/ui/help/demo.js
  4. 2
      designer-base/src/test/java/com/fr/design/ui/FineUIDemo.java
  5. 162
      designer-base/src/test/resources/com/fr/design/ui/script/start.js

70
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);
}
}
}

9
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.FRContext;
import com.fr.base.vcs.DesignerMode; import com.fr.base.vcs.DesignerMode;
import com.fr.design.DesignState; import com.fr.design.DesignState;
import com.fr.design.DesignerEnvManager;
import com.fr.design.ExtraDesignClassManager; import com.fr.design.ExtraDesignClassManager;
import com.fr.design.actions.UpdateAction; import com.fr.design.actions.UpdateAction;
import com.fr.design.actions.community.BBSAction; 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.PreferenceAction;
import com.fr.design.actions.file.SwitchExistEnv; import com.fr.design.actions.file.SwitchExistEnv;
import com.fr.design.actions.help.AboutAction; 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.TutorialAction;
import com.fr.design.actions.help.WebDemoAction; import com.fr.design.actions.help.WebDemoAction;
import com.fr.design.actions.help.alphafine.AlphaFineAction; import com.fr.design.actions.help.alphafine.AlphaFineAction;
@ -499,9 +501,14 @@ public abstract class ToolBarMenuDock {
if (AlphaFineConfigManager.isALPHALicAvailable()) { if (AlphaFineConfigManager.isALPHALicAvailable()) {
shortCuts.add(new AlphaFineAction()); shortCuts.add(new AlphaFineAction());
} }
shortCuts.add(SeparatorDef.DEFAULT); shortCuts.add(SeparatorDef.DEFAULT);
if (DesignerEnvManager.getEnvManager().isOpenDebug()) {
shortCuts.add(new FineUIAction());
}
shortCuts.add(new AboutAction()); shortCuts.add(new AboutAction());
return shortCuts.toArray(new ShortCut[shortCuts.size()]);
return shortCuts.toArray(new ShortCut[0]);
} }
/** /**

220
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
}]
});
});

2
designer-base/src/test/java/com/fr/design/ui/FineUIDemo.java

@ -20,7 +20,7 @@ public class FineUIDemo {
DesignerEnvManager.getEnvManager().setOpenDebug(true); DesignerEnvManager.getEnvManager().setOpenDebug(true);
final ModernUIPane<ModernUIPaneTest.Model> pane = new ModernUIPane.Builder<ModernUIPaneTest.Model>() final ModernUIPane<ModernUIPaneTest.Model> pane = new ModernUIPane.Builder<ModernUIPaneTest.Model>()
.withComponent(StartComponent.KEY).namespace("Pool").build(); .withComponent(StartComponent.KEY).build();
contentPane.add(pane, BorderLayout.CENTER); contentPane.add(pane, BorderLayout.CENTER);
frame.setVisible(true); frame.setVisible(true);
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

162
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({ BI.createWidget({
type:"bi.absolute", type:"bi.absolute",
element: "body", element: "body",
@ -198,22 +52,6 @@ window.addEventListener("load", function (ev) {
el: combo1, el: combo1,
left: 100, left: 100,
top: 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
}] }]
}); });
}); });
Loading…
Cancel
Save