Browse Source

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

* commit 'a91e579f9b0f6855524387530f9cdcf2a1d1d5b1':
  unused import
  KERNEL-594 更新好插件管理器后自动刷新
bugfix/10.0
richie 6 years ago
parent
commit
8fa2aab4d7
  1. 10
      designer-base/src/main/java/com/fr/design/ui/ModernUIPane.java
  2. 14
      designer-base/src/main/java/com/fr/design/upm/UpmBridge.java
  3. 8
      designer-base/src/main/java/com/fr/design/upm/UpmShowPane.java
  4. 2
      designer-base/src/main/java/com/fr/design/upm/event/DownloadEvent.java

10
designer-base/src/main/java/com/fr/design/ui/ModernUIPane.java

@ -116,6 +116,16 @@ public class ModernUIPane<T> extends BasicPane {
browser.loadURL(url);
}
/**
* 转向一个新的地址相当于重新加载
* @param url 新的地址
* @param map 初始化参数
*/
public void redirect(String url, Map<String, String> map) {
Assistant.setEmbProtocolHandler(browser, new EmbProtocolHandler(map));
browser.loadURL(url);
}
@Override
protected String title4PopupWindow() {
return "Modern";

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

@ -68,7 +68,16 @@ public class UpmBridge {
*/
@JSBridge
public void update(final JSFunction callback) {
startDownload(callback);
callback.invoke(window, "start", Toolkit.i18nText("Fine-Design_Basic_Update_Plugin_Manager_Download_Start"));
try {
UpmResourceLoader.INSTANCE.download();
UpmResourceLoader.INSTANCE.install();
callback.invoke(window, "success", Toolkit.i18nText("Fine-Design_Basic_Update_Plugin_Manager_Download_Success"));
EventDispatcher.fire(DownloadEvent.UPDATE, "success");
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
callback.invoke(window, "error", Toolkit.i18nText("Fine-Design_Basic_Update_Plugin_Manager_Download_Error"));
}
}
/**
@ -77,11 +86,10 @@ public class UpmBridge {
*/
@JSBridge
public void startDownload(final JSFunction callback) {
callback.invoke(window, "start", Toolkit.i18nText("Fine-Design_Basic_Update_Plugin_Manager_Download_Start"));
new SwingWorker<Void, Void>(){
@Override
protected Void doInBackground() throws Exception {
callback.invoke(window, "start", Toolkit.i18nText("Fine-Design_Basic_Update_Plugin_Manager_Download_Start"));
UpmResourceLoader.INSTANCE.download();
UpmResourceLoader.INSTANCE.install();
return null;

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

@ -40,6 +40,12 @@ public class UpmShowPane extends BasicPane {
})
.withURL(UpmFinder.getMainResourcePath(), UpmUtils.renderMap())
.build();
EventDispatcher.listen(DownloadEvent.UPDATE, new Listener<String>() {
@Override
public void on(Event event, String param) {
modernUIPane.redirect(UpmFinder.getMainResourcePath(), UpmUtils.renderMap());
}
});
} else {
modernUIPane = new ModernUIPane.Builder<>()
.withComponent(WarnComponent.KEY)
@ -53,7 +59,7 @@ public class UpmShowPane extends BasicPane {
EventDispatcher.listen(DownloadEvent.SUCCESS, new Listener<String>() {
@Override
public void on(Event event, String param) {
modernUIPane.redirect(UpmFinder.getMainResourcePath());
modernUIPane.redirect(UpmFinder.getMainResourcePath(), UpmUtils.renderMap());
}
});
}

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> {
SUCCESS, ERROR
SUCCESS, ERROR, UPDATE
}

Loading…
Cancel
Save