Browse Source

REPORT-22587 新版本插件管理,下载资源交互样式

research/11.0
author 5 years ago
parent
commit
c004e4172b
  1. 29
      designer-base/src/main/java/com/fr/design/upm/UpmFinder.java
  2. 69
      designer-base/src/main/java/com/fr/design/upm/UpmShowPane.java

29
designer-base/src/main/java/com/fr/design/upm/UpmFinder.java

@ -1,6 +1,7 @@
package com.fr.design.upm; package com.fr.design.upm;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.decision.webservice.v10.plugin.helper.category.impl.UpmResourceLoader;
import com.fr.design.dialog.UIDialog; import com.fr.design.dialog.UIDialog;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
@ -8,6 +9,7 @@ import com.fr.design.update.ui.dialog.UpdateMainDialog;
import com.fr.event.Event; import com.fr.event.Event;
import com.fr.event.EventDispatcher; import com.fr.event.EventDispatcher;
import com.fr.event.Listener; import com.fr.event.Listener;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
import com.fr.workspace.Workspace; import com.fr.workspace.Workspace;
import com.fr.workspace.WorkspaceEvent; import com.fr.workspace.WorkspaceEvent;
@ -60,11 +62,30 @@ public class UpmFinder {
flag = false; flag = false;
} }
if (flag) { if (flag) {
UpmShowPane upmPane = new UpmShowPane(); if (!checkUPMResourcesExist()){
if (dialog == null) { // upm下载
dialog = new UpmShowDialog(DesignerContext.getDesignerFrame(), upmPane); int val = JOptionPane.showConfirmDialog(null, Toolkit.i18nText("Fine-Design_Basic_Plugin_Shop_Need_Install"),
Toolkit.i18nText("Fine-Design_Basic_Alert"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE);
if (val == JOptionPane.OK_OPTION){
try {
UpmResourceLoader.INSTANCE.download();
UpmResourceLoader.INSTANCE.install();
JOptionPane.showMessageDialog(null, Toolkit.i18nText("Fine-Design_Basic_Plugin_Shop_Installed"),
Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), JOptionPane.INFORMATION_MESSAGE);
} catch (Exception e){
FineLoggerFactory.getLogger().error(e.getMessage(), e);
JOptionPane.showMessageDialog(null, Toolkit.i18nText("Fine-Design_Updater_Download_Failed"),
Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), JOptionPane.INFORMATION_MESSAGE);
}
}
}
else {
UpmShowPane upmPane = new UpmShowPane();
if (dialog == null) {
dialog = new UpmShowDialog(DesignerContext.getDesignerFrame(), upmPane);
}
dialog.setVisible(true);
} }
dialog.setVisible(true);
} else { } else {
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Update_Info_Plugin_Message")); JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Update_Info_Plugin_Message"));
UpdateMainDialog dialog = new UpdateMainDialog(DesignerContext.getDesignerFrame()); UpdateMainDialog dialog = new UpdateMainDialog(DesignerContext.getDesignerFrame());

69
designer-base/src/main/java/com/fr/design/upm/UpmShowPane.java

@ -29,40 +29,41 @@ public class UpmShowPane extends BasicPane {
UpmShowPane() { UpmShowPane() {
setLayout(new BorderLayout()); setLayout(new BorderLayout());
if (UpmFinder.checkUPMResourcesExist()) { // 先屏蔽掉这个判断,后续可能修改交互
modernUIPane = new ModernUIPane.Builder<>() // if (UpmFinder.checkUPMResourcesExist()) {
.prepare(new ScriptContextAdapter() { modernUIPane = new ModernUIPane.Builder<>()
@Override .prepare(new ScriptContextAdapter() {
public void onScriptContextCreated(ScriptContextEvent event) { @Override
JSValue window = event.getBrowser().executeJavaScriptAndReturnValue("window"); public void onScriptContextCreated(ScriptContextEvent event) {
window.asObject().setProperty("PluginHelper", UpmBridge.getBridge(event.getBrowser())); JSValue window = event.getBrowser().executeJavaScriptAndReturnValue("window");
} window.asObject().setProperty("PluginHelper", UpmBridge.getBridge(event.getBrowser()));
}) }
.withURL(UpmFinder.getMainResourcePath(), UpmUtils.renderMap()) })
.build(); .withURL(UpmFinder.getMainResourcePath(), UpmUtils.renderMap())
EventDispatcher.listen(DownloadEvent.UPDATE, new Listener<String>() { .build();
@Override EventDispatcher.listen(DownloadEvent.UPDATE, new Listener<String>() {
public void on(Event event, String param) { @Override
modernUIPane.redirect(UpmFinder.getMainResourcePath(), UpmUtils.renderMap()); public void on(Event event, String param) {
} modernUIPane.redirect(UpmFinder.getMainResourcePath(), UpmUtils.renderMap());
}); }
} else { });
modernUIPane = new ModernUIPane.Builder<>() // } else {
.withComponent(WarnComponent.KEY) // modernUIPane = new ModernUIPane.Builder<>()
.prepare(new ScriptContextAdapter() { // .withComponent(WarnComponent.KEY)
@Override // .prepare(new ScriptContextAdapter() {
public void onScriptContextCreated(ScriptContextEvent event) { // @Override
JSValue window = event.getBrowser().executeJavaScriptAndReturnValue("window"); // public void onScriptContextCreated(ScriptContextEvent event) {
window.asObject().setProperty("PluginHelper", UpmBridge.getBridge(event.getBrowser())); // JSValue window = event.getBrowser().executeJavaScriptAndReturnValue("window");
} // window.asObject().setProperty("PluginHelper", UpmBridge.getBridge(event.getBrowser()));
}).build(); // }
EventDispatcher.listen(DownloadEvent.SUCCESS, new Listener<String>() { // }).build();
@Override // EventDispatcher.listen(DownloadEvent.SUCCESS, new Listener<String>() {
public void on(Event event, String param) { // @Override
modernUIPane.redirect(UpmFinder.getMainResourcePath(), UpmUtils.renderMap()); // public void on(Event event, String param) {
} // modernUIPane.redirect(UpmFinder.getMainResourcePath(), UpmUtils.renderMap());
}); // }
} // });
// }
add(modernUIPane, BorderLayout.CENTER); add(modernUIPane, BorderLayout.CENTER);
} }
} }

Loading…
Cancel
Save