Browse Source

Pull request #4550: REPORT-53651 & REPORT-53591 & REPORT-53610 插件检测结果展示和重启

Merge in DESIGN/design from ~PENGDA/design:feature/10.0 to feature/10.0

* commit 'bc4e274d32f733b6e1b9ea6a6c75fdb834ce8258':
  REPORT-53651 & REPORT-53591 & REPORT-53610 插件检测结果展示和重启
  REPORT-53651 & REPORT-53591 & REPORT-53610 插件检测结果展示和重启
feature/10.0
pengda 3 years ago
parent
commit
c58bab2933
  1. 24
      designer-base/src/main/java/com/fr/design/update/actions/SyncFileProcess.java
  2. 28
      designer-base/src/main/java/com/fr/design/versioncheck/VersionCheckUtils.java
  3. 18
      designer-base/src/main/java/com/fr/env/CheckServiceDialog.java
  4. 26
      designer-base/src/main/java/com/fr/env/SyncFailedPluginsDialog.java

24
designer-base/src/main/java/com/fr/design/update/actions/SyncFileProcess.java

@ -5,6 +5,7 @@ import com.fr.decision.update.info.UpdateCallBack;
import com.fr.decision.update.info.UpdateProgressCallBack; import com.fr.decision.update.info.UpdateProgressCallBack;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.versioncheck.VersionCheckUtils; import com.fr.design.versioncheck.VersionCheckUtils;
import com.fr.env.SyncFailedPluginsDialog;
import com.fr.json.JSONArray; import com.fr.json.JSONArray;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
@ -14,11 +15,12 @@ import javax.swing.SwingWorker;
public abstract class SyncFileProcess extends SwingWorker<Boolean, Void> { public abstract class SyncFileProcess extends SwingWorker<Boolean, Void> {
private String buildNo; private String buildNo;
private JProgressBar bar; private JProgressBar bar;
private JSONArray syncFailedPlugins; private SyncFailedPluginsDialog syncFailedPluginsDialog;
public SyncFileProcess(JProgressBar bar, String buildNo) { public SyncFileProcess(JProgressBar bar, String buildNo, SyncFailedPluginsDialog syncFailedPluginsDialog) {
this.bar = bar; this.bar = bar;
this.buildNo = buildNo; this.buildNo = buildNo;
this.syncFailedPluginsDialog = syncFailedPluginsDialog;
} }
@Override @Override
@ -26,8 +28,19 @@ public abstract class SyncFileProcess extends SwingWorker<Boolean, Void> {
UpdateCallBack callBack = new UpdateProgressCallBack(bar); UpdateCallBack callBack = new UpdateProgressCallBack(bar);
bar.setValue(0); bar.setValue(0);
bar.setString(Toolkit.i18nText("Fine-Design_Basic_Sync_Plugins")); bar.setString(Toolkit.i18nText("Fine-Design_Basic_Sync_Plugins"));
syncFailedPlugins = VersionCheckUtils.syncPlugins(VersionCheckUtils.checkLocalAndRemotePlugin()); JSONArray syncFailedPlugins = VersionCheckUtils.syncPlugins(VersionCheckUtils.checkLocalAndRemotePlugin());
return SyncExecutor.getInstance().execute(callBack, buildNo); if (syncFailedPlugins.size() > 0) {
syncFailedPluginsDialog.showSyncFailedPluginsInfo(syncFailedPlugins);
}
RecoverForDesigner recoverForDesigner = new RecoverForDesigner();
if (!recoverForDesigner.backup()) {
return false;
}
boolean result = SyncExecutor.getInstance().execute(callBack, buildNo);
if (!result) {
recoverForDesigner.recover();
}
return result;
} }
@Override @Override
@ -48,9 +61,6 @@ public abstract class SyncFileProcess extends SwingWorker<Boolean, Void> {
} }
} }
public JSONArray getSyncFailedPlugins(){
return syncFailedPlugins;
}
/** /**
* 下载成功 * 下载成功

28
designer-base/src/main/java/com/fr/design/versioncheck/VersionCheckUtils.java

@ -2,13 +2,11 @@ package com.fr.design.versioncheck;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.dialog.NotificationDialog;
import com.fr.design.env.DesignerWorkspaceInfo; import com.fr.design.env.DesignerWorkspaceInfo;
import com.fr.design.env.DesignerWorkspaceType; import com.fr.design.env.DesignerWorkspaceType;
import com.fr.design.env.RemoteWorkspace; import com.fr.design.env.RemoteWorkspace;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.env.CheckServiceDialog;
import com.fr.env.VersionCheckMessageDialog; import com.fr.env.VersionCheckMessageDialog;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.GeneralUtils; import com.fr.general.GeneralUtils;
@ -24,6 +22,7 @@ import com.fr.plugin.manage.control.PluginControllerHelper;
import com.fr.plugin.manage.control.PluginTaskCallback; import com.fr.plugin.manage.control.PluginTaskCallback;
import com.fr.plugin.manage.control.PluginTaskResult; import com.fr.plugin.manage.control.PluginTaskResult;
import com.fr.plugin.manage.control.ProgressCallback; import com.fr.plugin.manage.control.ProgressCallback;
import com.fr.report.ReportHelper;
import com.fr.rpc.Result; import com.fr.rpc.Result;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContext;
@ -33,9 +32,6 @@ import com.fr.workspace.engine.base.FineObjectPool;
import com.fr.workspace.engine.channel.http.FunctionalHttpRequest; import com.fr.workspace.engine.channel.http.FunctionalHttpRequest;
import com.fr.workspace.engine.exception.WorkspaceConnectionException; import com.fr.workspace.engine.exception.WorkspaceConnectionException;
import com.fr.workspace.engine.rpc.WorkspaceProxyPool; import com.fr.workspace.engine.rpc.WorkspaceProxyPool;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.text.ParsePosition; import java.text.ParsePosition;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
@ -206,10 +202,7 @@ public class VersionCheckUtils {
} }
private static boolean needCheckBranch(DesignerWorkspaceInfo selectedEnv) { private static boolean needCheckBranch(DesignerWorkspaceInfo selectedEnv) {
if (selectedEnv.getType() == DesignerWorkspaceType.Remote) { return selectedEnv.getType() == DesignerWorkspaceType.Remote;
return true;
}
return false;
} }
public static JSONArray checkLocalAndRemotePlugin() { public static JSONArray checkLocalAndRemotePlugin() {
@ -221,21 +214,26 @@ public class VersionCheckUtils {
localPluginsMap.put(pluginContext.getID(), pluginContext); localPluginsMap.put(pluginContext.getID(), pluginContext);
} }
JSONObject remotePlugin; JSONObject remotePlugin;
Map<String, String> pluginsNameMap = ReportHelper.getPluginNameMap();
for (int i = 0; i < remotePlugins.size(); i++) { for (int i = 0; i < remotePlugins.size(); i++) {
remotePlugin = remotePlugins.getJSONObject(i); remotePlugin = remotePlugins.getJSONObject(i);
if (localPluginsMap.containsKey(remotePlugin.getString(ID))) { if (ComparatorUtils.equals(remotePlugin.getString("running"), "false")) {
if (ComparatorUtils.equals(localPluginsMap.get(remotePlugin.getString(ID)).getVersion(), remotePlugin.getString(VERSION))) { continue;
}
String remotePluginID = remotePlugin.getString(ID);
if (localPluginsMap.containsKey(remotePluginID)) {
if (ComparatorUtils.equals(localPluginsMap.get(remotePluginID).getVersion(), remotePlugin.getString(VERSION))) {
continue; continue;
} else { } else {
if (remotePlugin.getString(NAME) == null) { if (remotePlugin.getString(NAME) == null) {
remotePlugin.put(NAME, localPluginsMap.get(remotePlugin.getString(ID)).getName()); remotePlugin.put(NAME, localPluginsMap.get(remotePluginID).getName());
} }
remotePlugin.put("type", INCONSISTENCY); remotePlugin.put("type", INCONSISTENCY);
} }
} else { } else {
remotePlugin.put("type", MISSING); remotePlugin.put("type", MISSING);
if (remotePlugin.getString(NAME) == null) { if (remotePlugin.getString(NAME) == null) {
remotePlugin.put(NAME, remotePlugin.getString("id")); remotePlugin.put(NAME, pluginsNameMap.getOrDefault(remotePluginID, remotePluginID));
} }
} }
differentPlugins.put(remotePlugin); differentPlugins.put(remotePlugin);
@ -303,7 +301,7 @@ public class VersionCheckUtils {
return uninstallFailedID; return uninstallFailedID;
} }
private static JSONArray getPluginsSyncFailed(JSONArray differentPlugins){ private static JSONArray getPluginsSyncFailed(JSONArray differentPlugins) {
JSONArray pluginsNeedSync = JSONArray.create(); JSONArray pluginsNeedSync = JSONArray.create();
List<PluginContext> localPlugins = PluginManager.getContexts(); List<PluginContext> localPlugins = PluginManager.getContexts();
Map<String, String> localPluginsInfo = new HashMap<>(); Map<String, String> localPluginsInfo = new HashMap<>();
@ -333,8 +331,10 @@ public class VersionCheckUtils {
@Override @Override
public void done(PluginTaskResult result) { public void done(PluginTaskResult result) {
latch.countDown(); latch.countDown();
if(result.isSuccess()) {
FineLoggerFactory.getLogger().info("installPlugin: " + result.getCurrentTask().getMarker().getPluginID()); FineLoggerFactory.getLogger().info("installPlugin: " + result.getCurrentTask().getMarker().getPluginID());
} }
}
}); });
} }
try { try {

18
designer-base/src/main/java/com/fr/env/CheckServiceDialog.java vendored

@ -308,33 +308,31 @@ public class CheckServiceDialog extends JDialog implements ActionListener {
private MouseListener syncButtonClickListener = new MouseAdapter() { private MouseListener syncButtonClickListener = new MouseAdapter() {
@Override @Override
public void mouseClicked(MouseEvent e) { public void mouseClicked(MouseEvent e) {
ignoreButton.setEnabled(false);
String[] option = {Toolkit.i18nText("Fine-Design_Report_Yes"), Toolkit.i18nText("Fine-Design_Report_No")}; String[] option = {Toolkit.i18nText("Fine-Design_Report_Yes"), Toolkit.i18nText("Fine-Design_Report_No")};
if (!jarConsistency) {
int a = FineJOptionPane.showOptionDialog(getParent(), Toolkit.i18nText("Fine-Design_Basic_Sync_Info_Information"), int a = FineJOptionPane.showOptionDialog(getParent(), Toolkit.i18nText("Fine-Design_Basic_Sync_Info_Information"),
Toolkit.i18nText("Fine-Design_Basic_Confirm"), JOptionPane.YES_NO_OPTION, QUESTION_MESSAGE, IOUtils.readIcon("com/fr/design/icon/versioncheck/question.png"), option, 1); Toolkit.i18nText("Fine-Design_Basic_Confirm"), JOptionPane.YES_NO_OPTION, QUESTION_MESSAGE, IOUtils.readIcon("com/fr/design/icon/versioncheck/question.png"), option, 1);
if (0 == a) { if (0 == a) {
//jar包一致的话只更新插件
progressBar.setVisible(true); progressBar.setVisible(true);
progressBar.setString(Toolkit.i18nText("Fine-Design_Update_Info_Wait_Message")); progressBar.setString(Toolkit.i18nText("Fine-Design_Update_Info_Wait_Message"));
syncButton.setEnabled(false); syncButton.setEnabled(false);
if (!jarConsistency) {
deletePreviousPropertyFile(); deletePreviousPropertyFile();
final String installLib = StableUtils.pathJoin(StableUtils.getInstallHome(), ProjectConstants.LOGS_NAME, UpdateConstants.INSTALL_LIB); final String installLib = StableUtils.pathJoin(StableUtils.getInstallHome(), ProjectConstants.LOGS_NAME, UpdateConstants.INSTALL_LIB);
final JFrame frame = DesignerContext.getDesignerFrame(); final JFrame frame = DesignerContext.getDesignerFrame();
final RestartHelper helper = new RestartHelper(); final RestartHelper helper = new RestartHelper();
FineProcessContext.getParentPipe().fire(FineProcessEngineEvent.DESTROY); FineProcessContext.getParentPipe().fire(FineProcessEngineEvent.DESTROY);
SyncFailedPluginsDialog syncFailedPluginsDialog = new SyncFailedPluginsDialog(DesignerContext.getDesignerFrame(),JSONArray.create()); SyncFailedPluginsDialog syncFailedPluginsDialog = new SyncFailedPluginsDialog(frame, JSONArray.create());
new SyncFileProcess(progressBar, remoteBuildNo) { new SyncFileProcess(progressBar, remoteBuildNo, syncFailedPluginsDialog) {
@Override @Override
public void onDownloadSuccess() { public void onDownloadSuccess() {
deleteForDesignerUpdate(installLib); deleteForDesignerUpdate(installLib);
progressBar.setVisible(false); progressBar.setVisible(false);
JSONArray syncFailedPlugins = getSyncFailedPlugins(); syncFailedPluginsDialog.showDialog();
if (syncFailedPlugins.size() > 0) { if (!syncFailedPluginsDialog.restartClicked()) {
syncFailedPluginsDialog.showSyncFailedPluginsInfo(syncFailedPlugins);
syncFailedPluginsDialog.setVisible(true);
}
helper.restartForUpdate(frame); helper.restartForUpdate(frame);
} }
}
@Override @Override
public void onDownloadFailed() { public void onDownloadFailed() {
@ -345,6 +343,7 @@ public class CheckServiceDialog extends JDialog implements ActionListener {
helper.restartForUpdate(frame); helper.restartForUpdate(frame);
} }
}.execute(); }.execute();
}
} else { } else {
//到这边说明主jar是一致的,就只尝试同步插件 //到这边说明主jar是一致的,就只尝试同步插件
new SwingWorker<JSONArray, Void>() { new SwingWorker<JSONArray, Void>() {
@ -379,7 +378,6 @@ public class CheckServiceDialog extends JDialog implements ActionListener {
}.execute(); }.execute();
} }
} }
}
}; };
private boolean deletePreviousPropertyFile() { private boolean deletePreviousPropertyFile() {

26
designer-base/src/main/java/com/fr/env/SyncFailedPluginsDialog.java vendored

@ -10,6 +10,7 @@ import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.CloudCenter; import com.fr.general.CloudCenter;
import com.fr.general.ComparatorUtils;
import com.fr.general.GeneralContext; import com.fr.general.GeneralContext;
import com.fr.general.IOUtils; import com.fr.general.IOUtils;
import com.fr.json.JSONArray; import com.fr.json.JSONArray;
@ -25,6 +26,7 @@ import java.util.Locale;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.Icon; import javax.swing.Icon;
import javax.swing.JDialog; import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel; import javax.swing.JLabel;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.JScrollPane; import javax.swing.JScrollPane;
@ -39,7 +41,11 @@ public class SyncFailedPluginsDialog extends JDialog {
private UILabel detailsLabel; private UILabel detailsLabel;
private JScrollPane scrollPane; private JScrollPane scrollPane;
private UITextArea detailsTextArea; private UITextArea detailsTextArea;
public SyncFailedPluginsDialog(Frame parent, JSONArray syncFailedPlugins) { private JFrame frame = DesignerContext.getDesignerFrame();
private RestartHelper restartHelper = new RestartHelper();
private UIButton restartButton;
private boolean show;
public SyncFailedPluginsDialog(JFrame parent, JSONArray syncFailedPlugins) {
super(parent, true); super(parent, true);
JPanel body = FRGUIPaneFactory.createBorderLayout_L_Pane(); JPanel body = FRGUIPaneFactory.createBorderLayout_L_Pane();
@ -79,7 +85,7 @@ public class SyncFailedPluginsDialog extends JDialog {
centerPanel.add(scrollPane,BorderLayout.CENTER); centerPanel.add(scrollPane,BorderLayout.CENTER);
JPanel southPane = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane(); JPanel southPane = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane();
UIButton restartButton = new UIButton(Toolkit.i18nText("Fine-Design_Updater_Restart_Designer")); restartButton = new UIButton(Toolkit.i18nText("Fine-Design_Updater_Restart_Designer"));
restartButton.addMouseListener(restartButtonClickListener); restartButton.addMouseListener(restartButtonClickListener);
southPane.add(restartButton); southPane.add(restartButton);
@ -104,6 +110,15 @@ public class SyncFailedPluginsDialog extends JDialog {
detailsText.append(plugin.getString("name")).append(",").append(Toolkit.i18nText("Fine-Design_Basic_Sync_Server_Version")).append(plugin.getString("version")).append("\n"); detailsText.append(plugin.getString("name")).append(",").append(Toolkit.i18nText("Fine-Design_Basic_Sync_Server_Version")).append(plugin.getString("version")).append("\n");
} }
detailsTextArea.setText(detailsText.toString()); detailsTextArea.setText(detailsText.toString());
if(!ComparatorUtils.equals(detailsLabel.getText(),StringUtils.EMPTY)){
show = true;
}
}
public void showDialog(){
if(show){
this.setVisible(true);
}
} }
private MouseListener detailsLabelClickListener = new MouseAdapter() { private MouseListener detailsLabelClickListener = new MouseAdapter() {
@ -119,10 +134,15 @@ public class SyncFailedPluginsDialog extends JDialog {
} }
}; };
public boolean restartClicked(){
return !restartButton.isEnabled();
}
private MouseListener restartButtonClickListener = new MouseAdapter() { private MouseListener restartButtonClickListener = new MouseAdapter() {
@Override @Override
public void mouseClicked(MouseEvent e) { public void mouseClicked(MouseEvent e) {
RestartHelper.restartForUpdate(DesignerContext.getDesignerFrame()); restartButton.setEnabled(false);
restartHelper.restartForUpdate(frame);
} }
}; };
} }

Loading…
Cancel
Save