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 4 years ago
parent
commit
c58bab2933
  1. 24
      designer-base/src/main/java/com/fr/design/update/actions/SyncFileProcess.java
  2. 30
      designer-base/src/main/java/com/fr/design/versioncheck/VersionCheckUtils.java
  3. 90
      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.design.i18n.Toolkit;
import com.fr.design.versioncheck.VersionCheckUtils;
import com.fr.env.SyncFailedPluginsDialog;
import com.fr.json.JSONArray;
import com.fr.log.FineLoggerFactory;
import java.util.concurrent.ExecutionException;
@ -14,11 +15,12 @@ import javax.swing.SwingWorker;
public abstract class SyncFileProcess extends SwingWorker<Boolean, Void> {
private String buildNo;
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.buildNo = buildNo;
this.syncFailedPluginsDialog = syncFailedPluginsDialog;
}
@Override
@ -26,8 +28,19 @@ public abstract class SyncFileProcess extends SwingWorker<Boolean, Void> {
UpdateCallBack callBack = new UpdateProgressCallBack(bar);
bar.setValue(0);
bar.setString(Toolkit.i18nText("Fine-Design_Basic_Sync_Plugins"));
syncFailedPlugins = VersionCheckUtils.syncPlugins(VersionCheckUtils.checkLocalAndRemotePlugin());
return SyncExecutor.getInstance().execute(callBack, buildNo);
JSONArray syncFailedPlugins = VersionCheckUtils.syncPlugins(VersionCheckUtils.checkLocalAndRemotePlugin());
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
@ -48,9 +61,6 @@ public abstract class SyncFileProcess extends SwingWorker<Boolean, Void> {
}
}
public JSONArray getSyncFailedPlugins(){
return syncFailedPlugins;
}
/**
* 下载成功

30
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.design.DesignerEnvManager;
import com.fr.design.dialog.NotificationDialog;
import com.fr.design.env.DesignerWorkspaceInfo;
import com.fr.design.env.DesignerWorkspaceType;
import com.fr.design.env.RemoteWorkspace;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext;
import com.fr.env.CheckServiceDialog;
import com.fr.env.VersionCheckMessageDialog;
import com.fr.general.ComparatorUtils;
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.PluginTaskResult;
import com.fr.plugin.manage.control.ProgressCallback;
import com.fr.report.ReportHelper;
import com.fr.rpc.Result;
import com.fr.stable.StringUtils;
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.exception.WorkspaceConnectionException;
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.text.ParsePosition;
import java.text.SimpleDateFormat;
@ -206,10 +202,7 @@ public class VersionCheckUtils {
}
private static boolean needCheckBranch(DesignerWorkspaceInfo selectedEnv) {
if (selectedEnv.getType() == DesignerWorkspaceType.Remote) {
return true;
}
return false;
return selectedEnv.getType() == DesignerWorkspaceType.Remote;
}
public static JSONArray checkLocalAndRemotePlugin() {
@ -221,21 +214,26 @@ public class VersionCheckUtils {
localPluginsMap.put(pluginContext.getID(), pluginContext);
}
JSONObject remotePlugin;
Map<String, String> pluginsNameMap = ReportHelper.getPluginNameMap();
for (int i = 0; i < remotePlugins.size(); i++) {
remotePlugin = remotePlugins.getJSONObject(i);
if (localPluginsMap.containsKey(remotePlugin.getString(ID))) {
if (ComparatorUtils.equals(localPluginsMap.get(remotePlugin.getString(ID)).getVersion(), remotePlugin.getString(VERSION))) {
if (ComparatorUtils.equals(remotePlugin.getString("running"), "false")) {
continue;
}
String remotePluginID = remotePlugin.getString(ID);
if (localPluginsMap.containsKey(remotePluginID)) {
if (ComparatorUtils.equals(localPluginsMap.get(remotePluginID).getVersion(), remotePlugin.getString(VERSION))) {
continue;
} else {
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);
}
} else {
remotePlugin.put("type", MISSING);
if (remotePlugin.getString(NAME) == null) {
remotePlugin.put(NAME, remotePlugin.getString("id"));
remotePlugin.put(NAME, pluginsNameMap.getOrDefault(remotePluginID, remotePluginID));
}
}
differentPlugins.put(remotePlugin);
@ -303,7 +301,7 @@ public class VersionCheckUtils {
return uninstallFailedID;
}
private static JSONArray getPluginsSyncFailed(JSONArray differentPlugins){
private static JSONArray getPluginsSyncFailed(JSONArray differentPlugins) {
JSONArray pluginsNeedSync = JSONArray.create();
List<PluginContext> localPlugins = PluginManager.getContexts();
Map<String, String> localPluginsInfo = new HashMap<>();
@ -333,7 +331,9 @@ public class VersionCheckUtils {
@Override
public void done(PluginTaskResult result) {
latch.countDown();
FineLoggerFactory.getLogger().info("installPlugin: " + result.getCurrentTask().getMarker().getPluginID());
if(result.isSuccess()) {
FineLoggerFactory.getLogger().info("installPlugin: " + result.getCurrentTask().getMarker().getPluginID());
}
}
});
}

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

@ -308,32 +308,30 @@ public class CheckServiceDialog extends JDialog implements ActionListener {
private MouseListener syncButtonClickListener = new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
ignoreButton.setEnabled(false);
String[] option = {Toolkit.i18nText("Fine-Design_Report_Yes"), Toolkit.i18nText("Fine-Design_Report_No")};
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);
if (0 == a) {
//jar包一致的话只更新插件
progressBar.setVisible(true);
progressBar.setString(Toolkit.i18nText("Fine-Design_Update_Info_Wait_Message"));
syncButton.setEnabled(false);
if (!jarConsistency) {
if (!jarConsistency) {
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);
if (0 == a) {
progressBar.setVisible(true);
progressBar.setString(Toolkit.i18nText("Fine-Design_Update_Info_Wait_Message"));
syncButton.setEnabled(false);
deletePreviousPropertyFile();
final String installLib = StableUtils.pathJoin(StableUtils.getInstallHome(), ProjectConstants.LOGS_NAME, UpdateConstants.INSTALL_LIB);
final JFrame frame = DesignerContext.getDesignerFrame();
final RestartHelper helper = new RestartHelper();
FineProcessContext.getParentPipe().fire(FineProcessEngineEvent.DESTROY);
SyncFailedPluginsDialog syncFailedPluginsDialog = new SyncFailedPluginsDialog(DesignerContext.getDesignerFrame(),JSONArray.create());
new SyncFileProcess(progressBar, remoteBuildNo) {
SyncFailedPluginsDialog syncFailedPluginsDialog = new SyncFailedPluginsDialog(frame, JSONArray.create());
new SyncFileProcess(progressBar, remoteBuildNo, syncFailedPluginsDialog) {
@Override
public void onDownloadSuccess() {
deleteForDesignerUpdate(installLib);
progressBar.setVisible(false);
JSONArray syncFailedPlugins = getSyncFailedPlugins();
if (syncFailedPlugins.size() > 0) {
syncFailedPluginsDialog.showSyncFailedPluginsInfo(syncFailedPlugins);
syncFailedPluginsDialog.setVisible(true);
syncFailedPluginsDialog.showDialog();
if (!syncFailedPluginsDialog.restartClicked()) {
helper.restartForUpdate(frame);
}
helper.restartForUpdate(frame);
}
@Override
@ -345,39 +343,39 @@ public class CheckServiceDialog extends JDialog implements ActionListener {
helper.restartForUpdate(frame);
}
}.execute();
} else {
//到这边说明主jar是一致的,就只尝试同步插件
new SwingWorker<JSONArray, Void>() {
@Override
protected JSONArray doInBackground() {
progressBar.setString(Toolkit.i18nText("Fine-Design_Basic_Sync_Plugins"));
progressBar.setValue(0);
return VersionCheckUtils.syncPlugins(differentPlugins);
}
} else {
//到这边说明主jar是一致的,就只尝试同步插件
new SwingWorker<JSONArray, Void>() {
@Override
protected JSONArray doInBackground() {
progressBar.setString(Toolkit.i18nText("Fine-Design_Basic_Sync_Plugins"));
progressBar.setValue(0);
return VersionCheckUtils.syncPlugins(differentPlugins);
}
@Override
protected void done() {
progressBar.setVisible(false);
JSONArray syncFailedPlugins = null;
try {
syncFailedPlugins = get();
} catch (Exception ex) {
FineLoggerFactory.getLogger().error(ex.getMessage(), ex);
}
@Override
protected void done() {
progressBar.setVisible(false);
JSONArray syncFailedPlugins = null;
try {
syncFailedPlugins = get();
} catch (Exception ex) {
FineLoggerFactory.getLogger().error(ex.getMessage(), ex);
}
if (syncFailedPlugins != null && syncFailedPlugins.size() > 0) {
SyncFailedPluginsDialog syncFailedPluginsDialog = new SyncFailedPluginsDialog(DesignerContext.getDesignerFrame(), syncFailedPlugins);
syncFailedPluginsDialog.setVisible(true);
} else {
FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Design_Basic_Sync_Success"),
Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"),
FineJOptionPane.INFORMATION_MESSAGE);
}
close();
if (syncFailedPlugins != null && syncFailedPlugins.size() > 0) {
SyncFailedPluginsDialog syncFailedPluginsDialog = new SyncFailedPluginsDialog(DesignerContext.getDesignerFrame(), syncFailedPlugins);
syncFailedPluginsDialog.setVisible(true);
} else {
FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Design_Basic_Sync_Success"),
Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"),
FineJOptionPane.INFORMATION_MESSAGE);
}
}.execute();
}
close();
}
}.execute();
}
}
};

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.utils.gui.GUICoreUtils;
import com.fr.general.CloudCenter;
import com.fr.general.ComparatorUtils;
import com.fr.general.GeneralContext;
import com.fr.general.IOUtils;
import com.fr.json.JSONArray;
@ -25,6 +26,7 @@ import java.util.Locale;
import javax.swing.BorderFactory;
import javax.swing.Icon;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
@ -39,7 +41,11 @@ public class SyncFailedPluginsDialog extends JDialog {
private UILabel detailsLabel;
private JScrollPane scrollPane;
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);
JPanel body = FRGUIPaneFactory.createBorderLayout_L_Pane();
@ -79,7 +85,7 @@ public class SyncFailedPluginsDialog extends JDialog {
centerPanel.add(scrollPane,BorderLayout.CENTER);
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);
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");
}
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() {
@ -119,10 +134,15 @@ public class SyncFailedPluginsDialog extends JDialog {
}
};
public boolean restartClicked(){
return !restartButton.isEnabled();
}
private MouseListener restartButtonClickListener = new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
RestartHelper.restartForUpdate(DesignerContext.getDesignerFrame());
restartButton.setEnabled(false);
restartHelper.restartForUpdate(frame);
}
};
}

Loading…
Cancel
Save