Browse Source

Merge branch 'feature/10.0' of ssh://cloud.finedevelop.com:7999/~lanlan/design into feature/10.0

feature/10.0
Lanlan 4 years ago
parent
commit
f15e9df331
  1. 11
      designer-base/src/main/java/com/fr/design/mod/ContentReplacerCenter.java
  2. 24
      designer-base/src/main/java/com/fr/design/update/actions/SyncFileProcess.java
  3. 28
      designer-base/src/main/java/com/fr/design/versioncheck/VersionCheckUtils.java
  4. 18
      designer-base/src/main/java/com/fr/env/CheckServiceDialog.java
  5. 26
      designer-base/src/main/java/com/fr/env/SyncFailedPluginsDialog.java
  6. 15
      designer-realize/src/main/java/com/fr/design/share/SharableManager.java

11
designer-base/src/main/java/com/fr/design/mod/ContentReplacerCenter.java

@ -30,6 +30,7 @@ import com.fr.event.Listener;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -51,7 +52,7 @@ public class ContentReplacerCenter {
} }
private List<ContentChange> contentChangeList = new ArrayList<>(); private List<ContentChange> contentChangeList = new ArrayList<>();
private List<ContentChangeItem> items = new ArrayList<>(); private Map<ChangeItem, ContentChangeItem> itemsMap = new HashMap<>();
private ContentReplacerCenter() { private ContentReplacerCenter() {
@ -61,21 +62,21 @@ public class ContentReplacerCenter {
if (param.getChangeMap().isEmpty()) { if (param.getChangeMap().isEmpty()) {
return; return;
} }
items.add(param); itemsMap.put(param.getChangeItem(), param);
} }
}); });
EventDispatcher.listen(TableDataModifyEvent.INSTANCE, new Listener<ContentChangeItem>() { EventDispatcher.listen(TableDataModifyEvent.INSTANCE, new Listener<ContentChangeItem>() {
@Override @Override
public void on(Event event, ContentChangeItem param) { public void on(Event event, ContentChangeItem param) {
items.add(param); itemsMap.put(param.getChangeItem(), param);
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
ContentObjectManager.getInstance().searchObject(param.getObject()); ContentObjectManager.getInstance().searchObject(param.getObject());
FineLoggerFactory.getLogger().debug("search object spend {} ms", (System.currentTimeMillis() - start)); FineLoggerFactory.getLogger().debug("search object spend {} ms", (System.currentTimeMillis() - start));
FineLoggerFactory.getLogger().debug("search result: {}", ContentObjectManager.getInstance().getObjectMap() == null FineLoggerFactory.getLogger().debug("search result: {}", ContentObjectManager.getInstance().getObjectMap() == null
? null : ContentObjectManager.getInstance().getObjectMap().keySet()); ? null : ContentObjectManager.getInstance().getObjectMap().keySet());
List<ContentChangeItem> itemsCopy = new ArrayList<>(items); List<ContentChangeItem> itemsCopy = new ArrayList<>(itemsMap.values());
items.clear(); itemsMap.clear();
onRename(itemsCopy, contentChangeList); onRename(itemsCopy, contentChangeList);
} }
}); });

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 = false;
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(detailsTextArea.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);
} }
}; };
} }

15
designer-realize/src/main/java/com/fr/design/share/SharableManager.java

@ -9,15 +9,21 @@ import com.fr.design.mainframe.share.collect.ComponentCollector;
import com.fr.design.mainframe.share.collect.SharableCollectorManager; import com.fr.design.mainframe.share.collect.SharableCollectorManager;
import com.fr.design.mainframe.share.encrypt.clipboard.impl.EncryptSelectionClipboardHandler; import com.fr.design.mainframe.share.encrypt.clipboard.impl.EncryptSelectionClipboardHandler;
import com.fr.design.mainframe.share.encrypt.clipboard.impl.EncryptTransferableClipboardHandler; import com.fr.design.mainframe.share.encrypt.clipboard.impl.EncryptTransferableClipboardHandler;
import com.fr.design.mainframe.share.ui.block.LocalWidgetBlock;
import com.fr.design.mainframe.share.ui.local.LocalWidgetRepoPane;
import com.fr.design.mainframe.share.util.ShareComponentUtils; import com.fr.design.mainframe.share.util.ShareComponentUtils;
import com.fr.design.share.utils.EffectItemUtils; import com.fr.design.share.utils.EffectItemUtils;
import com.fr.form.share.ShareLoader;
import com.fr.general.GeneralContext;
import com.fr.json.JSONArray; import com.fr.json.JSONArray;
import com.fr.stable.EnvChangedListener;
import java.util.List; import java.util.List;
public class SharableManager { public class SharableManager {
public static void start() { public static void start() {
SharableCollectorManager.getInstance().execute(); SharableCollectorManager.getInstance().execute();
listenEnv();
ClipboardFilter.registerClipboardHandler(EncryptSelectionClipboardHandler.getInstance()); ClipboardFilter.registerClipboardHandler(EncryptSelectionClipboardHandler.getInstance());
ClipboardFilter.registerClipboardHandler(EncryptTransferableClipboardHandler.getInstance()); ClipboardFilter.registerClipboardHandler(EncryptTransferableClipboardHandler.getInstance());
} }
@ -44,4 +50,13 @@ public class SharableManager {
} }
} }
} }
private static void listenEnv() {
GeneralContext.addEnvChangedListenerToLast(new EnvChangedListener() {
@Override
public void envChanged() {
LocalWidgetRepoPane.getInstance().refreshPane();
}
});
}
} }

Loading…
Cancel
Save