Browse Source

Merge pull request #827 in DESIGN/design from ~RICHIE/design:release/10.0 to release/10.0

* commit 'f11a5605c66567f462848b09ec0ddcc185bb20ce':
  KERNEL-442 没有资源文件时的下载页面
bugfix/10.0
richie 6 years ago
parent
commit
269adda981
  1. 23
      designer-base/src/main/java/com/fr/design/upm/UpmBridge.java
  2. 2
      designer-base/src/main/java/com/fr/design/upm/UpmPane.java
  3. 2
      designer-base/src/main/java/com/fr/design/upm/event/DownloadEvent.java
  4. 63
      designer-base/src/main/resources/com/fr/design/upm/warn.js

23
designer-base/src/main/java/com/fr/design/upm/UpmBridge.java

@ -18,6 +18,7 @@ import com.fr.design.upm.event.CertificateEvent;
import com.fr.design.upm.event.DownloadEvent;
import com.fr.design.upm.exec.UpmBrowserExecutor;
import com.fr.design.upm.task.UpmTaskWorker;
import com.fr.event.Event;
import com.fr.event.EventDispatcher;
import com.fr.general.CloudCenter;
import com.fr.general.GeneralUtils;
@ -60,14 +61,30 @@ public class UpmBridge {
this.window = browser.executeJavaScriptAndReturnValue("window").asObject();
}
public void startDownload() {
try {
public void startDownload(final JSFunction callback) {
new SwingWorker<Void, Void>(){
@Override
protected Void doInBackground() throws Exception {
callback.invoke(window, Toolkit.i18nText("Fine-Design_Basic_Update_Plugin_Manager_Download_Start"));
UpmResourceLoader.INSTANCE.download();
UpmResourceLoader.INSTANCE.install();
return null;
}
@Override
protected void done() {
try {
get();
callback.invoke(window, Toolkit.i18nText("Fine-Design_Basic_Update_Plugin_Manager_Download_Success"));
EventDispatcher.fire(DownloadEvent.SUCCESS, "success");
} catch (Exception e) {
callback.invoke(window, Toolkit.i18nText("Fine-Design_Basic_Update_Plugin_Manager_Download_Error"));
FineLoggerFactory.getLogger().error(e.getMessage(), e);
EventDispatcher.fire(DownloadEvent.ERROR, "error");
}
}
EventDispatcher.fire(DownloadEvent.FINISH, "start");
}.execute();
}
@JSBridge

2
designer-base/src/main/java/com/fr/design/upm/UpmPane.java

@ -50,7 +50,7 @@ public class UpmPane extends BasicPane {
window.asObject().setProperty("PluginHelper", UpmBridge.getBridge(event.getBrowser()));
}
}).build();
EventDispatcher.listen(DownloadEvent.FINISH, new Listener<String>() {
EventDispatcher.listen(DownloadEvent.SUCCESS, new Listener<String>() {
@Override
public void on(Event event, String param) {
modernUIPane.redirect(UpmFinder.getMainResourcePath());

2
designer-base/src/main/java/com/fr/design/upm/event/DownloadEvent.java

@ -9,5 +9,5 @@ import com.fr.event.Event;
*/
public enum DownloadEvent implements Event<String> {
FINISH
SUCCESS, ERROR
}

63
designer-base/src/main/resources/com/fr/design/upm/warn.js

@ -1,20 +1,61 @@
window.onload = function () {
let button = BI.createWidget({
type : "bi.button",
text : PluginHelper.i18nText("Fine-Design_Basic_Update_Plugin_Manager_Resource_Warn"),
let label = BI.createWidget({
type: "bi.label",
text: PluginHelper.i18nText("Fine-Design_Basic_Update_Plugin_Manager_Resource_Warn"),
height: 30
});
let callback = function(text) {
download.setValue(text);
};
let buttonOK = BI.createWidget({
type: "bi.button",
text: PluginHelper.i18nText("Fine-Design_Basic_Update_Plugin_Manager_Download"),
level: 'common',
height: 30,
handler : function () {
PluginHelper.startDownload();
handler: function () {
PluginHelper.startDownload(callback);
}
});
let buttonClose = BI.createWidget({
type: "bi.button",
text: PluginHelper.i18nText("Fine-Design_Basic_Update_Plugin_Manager_Close"),
level: 'warning',
height: 30,
handler: function () {
PluginHelper.closeWindow();
}
});
let download = BI.createWidget({
type: "bi.label",
height: 30
});
let left = 300;
let top = 200;
BI.createWidget({
type:"bi.absolute",
type: "bi.absolute",
element: "body",
items: [{
el: button,
left: 100,
top: 100
}]
items: [
{
el: label,
left: left,
top: top
},
{
el : buttonOK,
left : left,
top : top + 40
},
{
el : buttonClose,
left : left + 100,
top : top + 40
},
{
el : download,
left : left,
top : top + 80
}
]
});
};
Loading…
Cancel
Save