Browse Source

KERNEL-594 更新好插件管理器后自动刷新

bugfix/10.0
richie 6 years ago
parent
commit
9d7cd51d6c
  1. 10
      designer-base/src/main/java/com/fr/design/ui/ModernUIPane.java
  2. 15
      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); 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 @Override
protected String title4PopupWindow() { protected String title4PopupWindow() {
return "Modern"; return "Modern";

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

@ -43,6 +43,7 @@ import java.util.List;
import java.util.concurrent.Callable; import java.util.concurrent.Callable;
import java.util.concurrent.FutureTask; import java.util.concurrent.FutureTask;
import java.util.concurrent.RunnableFuture; import java.util.concurrent.RunnableFuture;
import java.util.concurrent.TimeUnit;
/** /**
* @author richie * @author richie
@ -68,7 +69,16 @@ public class UpmBridge {
*/ */
@JSBridge @JSBridge
public void update(final JSFunction callback) { 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 +87,10 @@ public class UpmBridge {
*/ */
@JSBridge @JSBridge
public void startDownload(final JSFunction callback) { public void startDownload(final JSFunction callback) {
callback.invoke(window, "start", Toolkit.i18nText("Fine-Design_Basic_Update_Plugin_Manager_Download_Start"));
new SwingWorker<Void, Void>(){ new SwingWorker<Void, Void>(){
@Override @Override
protected Void doInBackground() throws Exception { protected Void doInBackground() throws Exception {
callback.invoke(window, "start", Toolkit.i18nText("Fine-Design_Basic_Update_Plugin_Manager_Download_Start"));
UpmResourceLoader.INSTANCE.download(); UpmResourceLoader.INSTANCE.download();
UpmResourceLoader.INSTANCE.install(); UpmResourceLoader.INSTANCE.install();
return null; 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()) .withURL(UpmFinder.getMainResourcePath(), UpmUtils.renderMap())
.build(); .build();
EventDispatcher.listen(DownloadEvent.UPDATE, new Listener<String>() {
@Override
public void on(Event event, String param) {
modernUIPane.redirect(UpmFinder.getMainResourcePath(), UpmUtils.renderMap());
}
});
} else { } else {
modernUIPane = new ModernUIPane.Builder<>() modernUIPane = new ModernUIPane.Builder<>()
.withComponent(WarnComponent.KEY) .withComponent(WarnComponent.KEY)
@ -53,7 +59,7 @@ public class UpmShowPane extends BasicPane {
EventDispatcher.listen(DownloadEvent.SUCCESS, new Listener<String>() { EventDispatcher.listen(DownloadEvent.SUCCESS, new Listener<String>() {
@Override @Override
public void on(Event event, String param) { 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> { public enum DownloadEvent implements Event<String> {
SUCCESS, ERROR SUCCESS, ERROR, UPDATE
} }

Loading…
Cancel
Save