Browse Source

Merge pull request #1167 in DESIGN/design from ~BRYANT/design:feature/10.0 to feature/10.0

* commit '8133b368d04ce08c565efd4c4884470dbb20a4dc':
  KERNEL-418 更新升级重构
  KERNEL-418 更新升级重构
research/11.0
Bryant 5 years ago
parent
commit
1ad18a68af
  1. 33
      designer-base/src/main/java/com/fr/design/upm/UpmFinder.java
  2. 93
      designer-base/src/main/java/com/fr/design/upm/UpmShowPane.java

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

@ -2,11 +2,16 @@ package com.fr.design.upm;
import com.fr.base.FRContext;
import com.fr.design.dialog.UIDialog;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.update.domain.UpdateConstants;
import com.fr.design.update.ui.dialog.UpdateMainDialog;
import com.fr.event.Event;
import com.fr.event.EventDispatcher;
import com.fr.event.Listener;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.StableUtils;
import com.fr.stable.project.ProjectConstants;
import com.fr.workspace.Workspace;
import com.fr.workspace.WorkspaceEvent;
@ -51,11 +56,31 @@ public class UpmFinder {
}
public static void showUPMDialog() {
UpmShowPane upmPane = new UpmShowPane();
if (dialog == null) {
dialog = new UpmShowDialog(DesignerContext.getDesignerFrame(), upmPane);
boolean flag = false;
File file = new File(StableUtils.pathJoin(StableUtils.getInstallHome(), ProjectConstants.LIB_NAME));
File[] files = file.listFiles();
if (files != null) {
for (File file1 : files) {
if (file1.getName().contains(UpdateConstants.JXBROWSER)) {
flag = true;
break;
}
}
}else {
FineLoggerFactory.getLogger().error("Designer lib can not be null");
}
if (flag) {
UpmShowPane upmPane = new UpmShowPane();
if (dialog == null) {
dialog = new UpmShowDialog(DesignerContext.getDesignerFrame(), upmPane);
}
dialog.setVisible(true);
} else {
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Update_Info_Plugin_Message"));
UpdateMainDialog dialog = new UpdateMainDialog(DesignerContext.getDesignerFrame());
dialog.setAutoUpdateAfterInit();
dialog.showDialog();
}
dialog.setVisible(true);
}
public static void closeWindow() {

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

@ -1,26 +1,16 @@
package com.fr.design.upm;
import com.fr.design.dialog.BasicPane;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.ui.ModernUIPane;
import com.fr.design.update.domain.UpdateConstants;
import com.fr.design.update.ui.dialog.UpdateMainDialog;
import com.fr.design.upm.event.DownloadEvent;
import com.fr.event.Event;
import com.fr.event.EventDispatcher;
import com.fr.event.Listener;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.StableUtils;
import com.fr.stable.project.ProjectConstants;
import com.teamdev.jxbrowser.chromium.JSValue;
import com.teamdev.jxbrowser.chromium.events.ScriptContextAdapter;
import com.teamdev.jxbrowser.chromium.events.ScriptContextEvent;
import javax.swing.*;
import java.awt.*;
import java.io.File;
import java.io.FileNotFoundException;
/**
* @author richie
@ -39,61 +29,40 @@ public class UpmShowPane extends BasicPane {
UpmShowPane() {
setLayout(new BorderLayout());
boolean flag = false;
File file = new File(StableUtils.pathJoin(StableUtils.getInstallHome(),ProjectConstants.LIB_NAME));
File[] files = file.listFiles();
if (files != null) {
for (File file1 : files) {
if (file1.getName().contains(UpdateConstants.JXBROWSER)) {
flag = true;
break;
if (UpmFinder.checkUPMResourcesExist()) {
modernUIPane = new ModernUIPane.Builder<>()
.prepare(new ScriptContextAdapter() {
@Override
public void onScriptContextCreated(ScriptContextEvent event) {
JSValue window = event.getBrowser().executeJavaScriptAndReturnValue("window");
window.asObject().setProperty("PluginHelper", UpmBridge.getBridge(event.getBrowser()));
}
})
.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 {
FineLoggerFactory.getLogger().error("Designer lib can not be null");
}
if (flag) {
if (UpmFinder.checkUPMResourcesExist()) {
modernUIPane = new ModernUIPane.Builder<>()
.prepare(new ScriptContextAdapter() {
@Override
public void onScriptContextCreated(ScriptContextEvent event) {
JSValue window = event.getBrowser().executeJavaScriptAndReturnValue("window");
window.asObject().setProperty("PluginHelper", UpmBridge.getBridge(event.getBrowser()));
}
})
.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)
.prepare(new ScriptContextAdapter() {
@Override
public void onScriptContextCreated(ScriptContextEvent event) {
JSValue window = event.getBrowser().executeJavaScriptAndReturnValue("window");
window.asObject().setProperty("PluginHelper", UpmBridge.getBridge(event.getBrowser()));
}
}).build();
EventDispatcher.listen(DownloadEvent.SUCCESS, new Listener<String>() {
@Override
public void on(Event event, String param) {
modernUIPane.redirect(UpmFinder.getMainResourcePath(), UpmUtils.renderMap());
}
});
}
});
} else {
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Update_Info_Plugin_Message"));
UpdateMainDialog dialog = new UpdateMainDialog(DesignerContext.getDesignerFrame());
dialog.setAutoUpdateAfterInit();
dialog.showDialog();
modernUIPane = new ModernUIPane.Builder<>()
.withComponent(WarnComponent.KEY)
.prepare(new ScriptContextAdapter() {
@Override
public void onScriptContextCreated(ScriptContextEvent event) {
JSValue window = event.getBrowser().executeJavaScriptAndReturnValue("window");
window.asObject().setProperty("PluginHelper", UpmBridge.getBridge(event.getBrowser()));
}
}).build();
EventDispatcher.listen(DownloadEvent.SUCCESS, new Listener<String>() {
@Override
public void on(Event event, String param) {
modernUIPane.redirect(UpmFinder.getMainResourcePath(), UpmUtils.renderMap());
}
});
}
add(modernUIPane, BorderLayout.CENTER);
}
}

Loading…
Cancel
Save