diff --git a/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java b/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java index c5a4a7dd2..4ab6b3089 100644 --- a/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java +++ b/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java @@ -18,11 +18,10 @@ import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.JTemplate; import com.fr.design.utils.DesignUtils; -import com.fr.env.CheckServiceDialog; +import com.fr.design.versioncheck.VersionCheckUtils; import com.fr.env.EnvListPane; import com.fr.env.RemoteWorkspaceURL; import com.fr.env.TestConnectionResult; -import com.fr.env.VersionCheckMessageDialog; import com.fr.exit.DesignerExiter; import com.fr.general.ComparatorUtils; import com.fr.general.GeneralUtils; diff --git a/designer-base/src/main/java/com/fr/design/update/actions/SyncFileProcess.java b/designer-base/src/main/java/com/fr/design/update/actions/SyncFileProcess.java index 1614d1084..b41d099cb 100644 --- a/designer-base/src/main/java/com/fr/design/update/actions/SyncFileProcess.java +++ b/designer-base/src/main/java/com/fr/design/update/actions/SyncFileProcess.java @@ -2,22 +2,33 @@ package com.fr.design.update.actions; import com.fr.decision.update.SyncExecutor; 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.log.FineLoggerFactory; import java.util.concurrent.ExecutionException; +import javax.swing.JProgressBar; import javax.swing.SwingWorker; public abstract class SyncFileProcess extends SwingWorker { - private UpdateCallBack callBack; private String buildNo; + private JProgressBar bar; - public SyncFileProcess(UpdateCallBack callBack,String buildNo) { - this.callBack = callBack; + public SyncFileProcess(JProgressBar bar, String buildNo) { + this.bar = bar; this.buildNo = buildNo; } @Override protected Boolean doInBackground() throws Exception { - return SyncExecutor.getInstance().execute(callBack,buildNo); + UpdateCallBack callBack = new UpdateProgressCallBack(bar); + boolean result = SyncExecutor.getInstance().execute(callBack, buildNo); + if (result) { + bar.setValue(0); + bar.setString(Toolkit.i18nText("Fine-Design_Basic_Sync_Plugins")); + VersionCheckUtils.syncPlugins(VersionCheckUtils.checkLocalAndRemotePlugin()); + } + return SyncExecutor.getInstance().execute(callBack, buildNo); } @Override diff --git a/designer-base/src/main/java/com/fr/design/VersionCheckUtils.java b/designer-base/src/main/java/com/fr/design/versioncheck/VersionCheckUtils.java similarity index 94% rename from designer-base/src/main/java/com/fr/design/VersionCheckUtils.java rename to designer-base/src/main/java/com/fr/design/versioncheck/VersionCheckUtils.java index 17dcd51a1..11780409a 100644 --- a/designer-base/src/main/java/com/fr/design/VersionCheckUtils.java +++ b/designer-base/src/main/java/com/fr/design/versioncheck/VersionCheckUtils.java @@ -1,11 +1,14 @@ -package com.fr.design; +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; @@ -30,6 +33,9 @@ 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; @@ -226,21 +232,21 @@ public class VersionCheckUtils { } remotePlugin.put("type", INCONSISTENCY); } - } - remotePlugin.put("type", MISSING); - if (remotePlugin.getString(NAME) == null) { - remotePlugin.put(NAME, remotePlugin.getString("id")); + } else { + remotePlugin.put("type", MISSING); + if (remotePlugin.getString(NAME) == null) { + remotePlugin.put(NAME, remotePlugin.getString("id")); + } } differentPlugins.put(remotePlugin); } return differentPlugins; } - public static JSONArray syncPlugins(JSONArray differentPlugins) { + public static void syncPlugins(JSONArray differentPlugins) { Set uninstallFailed = uninstallPlugins(differentPlugins); List plugins = getSyncPlugins(differentPlugins, uninstallFailed); installPlugins(plugins); - return getPluginsSyncFailed(differentPlugins); } private static List getSyncPlugins(JSONArray differentPlugins, Set uninstallFailed) { @@ -296,7 +302,7 @@ public class VersionCheckUtils { return uninstallFailedID; } - private static JSONArray getPluginsSyncFailed(JSONArray differentPlugins){ + public static JSONArray getPluginsSyncFailed(JSONArray differentPlugins){ JSONArray pluginsNeedSync = JSONArray.create(); List localPlugins = PluginManager.getContexts(); Map localPluginsInfo = new HashMap<>(); @@ -326,6 +332,7 @@ public class VersionCheckUtils { @Override public void done(PluginTaskResult result) { latch.countDown(); + FineLoggerFactory.getLogger().info("installPlugin: " + result.getCurrentTask().getMarker().getPluginID()); } }); } diff --git a/designer-base/src/main/java/com/fr/env/CheckServiceDialog.java b/designer-base/src/main/java/com/fr/env/CheckServiceDialog.java index 062b20acd..7e9e74ebc 100644 --- a/designer-base/src/main/java/com/fr/env/CheckServiceDialog.java +++ b/designer-base/src/main/java/com/fr/env/CheckServiceDialog.java @@ -1,10 +1,7 @@ package com.fr.env; import com.fr.decision.update.data.UpdateConstants; -import com.fr.decision.update.info.UpdateCallBack; -import com.fr.decision.update.info.UpdateProgressCallBack; import com.fr.design.RestartHelper; -import com.fr.design.VersionCheckUtils; import com.fr.design.dialog.FineJOptionPane; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ilable.UILabel; @@ -15,6 +12,7 @@ import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.DesignerContext; import com.fr.design.update.actions.SyncFileProcess; import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.design.versioncheck.VersionCheckUtils; import com.fr.general.CloudCenter; import com.fr.general.CloudCenterConfig; import com.fr.general.ComparatorUtils; @@ -315,7 +313,6 @@ public class CheckServiceDialog extends JDialog implements ActionListener { 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包一致的话只更新插件 - UpdateCallBack callBack = new UpdateProgressCallBack(progressBar); progressBar.setVisible(true); progressBar.setString(Toolkit.i18nText("Fine-Design_Update_Info_Wait_Message")); syncButton.setEnabled(false); @@ -325,40 +322,17 @@ public class CheckServiceDialog extends JDialog implements ActionListener { final JFrame frame = DesignerContext.getDesignerFrame(); final RestartHelper helper = new RestartHelper(); FineProcessContext.getParentPipe().fire(FineProcessEngineEvent.DESTROY); - new SyncFileProcess(callBack, remoteBuildNo) { + new SyncFileProcess(progressBar, remoteBuildNo) { @Override public void onDownloadSuccess() { deleteForDesignerUpdate(installLib); - if (differentPlugins.size() > 0) { - //主jar下载成功之后再卸载安装插件 - new SwingWorker() { - - @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); - } - if (syncFailedPlugins != null && syncFailedPlugins.size() > 0) { - SyncFailedPluginsDialog syncFailedPluginsDialog = new SyncFailedPluginsDialog(DesignerContext.getDesignerFrame(), syncFailedPlugins); - syncFailedPluginsDialog.setVisible(true); - } - helper.restartForUpdate(frame); - } - }.execute(); - } else { - helper.restartForUpdate(frame); + progressBar.setVisible(false); + JSONArray syncFailedPlugins = VersionCheckUtils.getPluginsSyncFailed(differentPlugins); + if (syncFailedPlugins.size() > 0) { + SyncFailedPluginsDialog syncFailedPluginsDialog = new SyncFailedPluginsDialog(DesignerContext.getDesignerFrame(), syncFailedPlugins); + syncFailedPluginsDialog.setVisible(true); } + helper.restartForUpdate(frame); } @Override @@ -378,7 +352,8 @@ public class CheckServiceDialog extends JDialog implements ActionListener { protected JSONArray doInBackground() { progressBar.setString(Toolkit.i18nText("Fine-Design_Basic_Sync_Plugins")); progressBar.setValue(0); - return VersionCheckUtils.syncPlugins(differentPlugins); + VersionCheckUtils.syncPlugins(differentPlugins); + return VersionCheckUtils.getPluginsSyncFailed(differentPlugins); } @Override diff --git a/designer-base/src/main/java/com/fr/env/VersionCheckMessageDialog.java b/designer-base/src/main/java/com/fr/env/VersionCheckMessageDialog.java index 657b13e0a..5fd4c9ec0 100644 --- a/designer-base/src/main/java/com/fr/env/VersionCheckMessageDialog.java +++ b/designer-base/src/main/java/com/fr/env/VersionCheckMessageDialog.java @@ -1,6 +1,6 @@ package com.fr.env; -import com.fr.design.VersionCheckUtils; +import com.fr.design.versioncheck.VersionCheckUtils; import com.fr.design.gui.ilable.UILabel; import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; diff --git a/designer-realize/src/main/java/com/fr/start/module/DesignerWorkspaceProvider.java b/designer-realize/src/main/java/com/fr/start/module/DesignerWorkspaceProvider.java index 4c759822b..220a4e39e 100644 --- a/designer-realize/src/main/java/com/fr/start/module/DesignerWorkspaceProvider.java +++ b/designer-realize/src/main/java/com/fr/start/module/DesignerWorkspaceProvider.java @@ -2,7 +2,6 @@ package com.fr.start.module; import com.fr.design.DesignerEnvManager; import com.fr.design.EnvChangeEntrance; -import com.fr.design.VersionCheckUtils; import com.fr.design.constants.DesignerLaunchStatus; import com.fr.design.editlock.ConnectionLockChangeChecker; import com.fr.design.editlock.ServerTableDataLockChangeChecker; @@ -10,6 +9,7 @@ import com.fr.design.env.DesignerWorkspaceGenerator; import com.fr.design.env.DesignerWorkspaceInfo; import com.fr.design.env.LocalDesignerWorkspaceInfo; import com.fr.design.i18n.Toolkit; +import com.fr.design.versioncheck.VersionCheckUtils; import com.fr.env.TestConnectionResult; import com.fr.event.Event; import com.fr.event.EventDispatcher;