From 5c66b02c7b7b438e535bce2c1ba69cb7e55053a0 Mon Sep 17 00:00:00 2001 From: ju Date: Mon, 18 Jun 2018 14:28:02 +0800 Subject: [PATCH] f --- .../src/com/fr/design/DesignerEnvManager.java | 12 +++++----- .../env/LocalDesignerWorkspaceInfo.java | 4 +--- .../env/RemoteDesignerWorkspaceInfo.java | 4 +--- .../com/fr/design/mainframe/TemplatePane.java | 2 +- .../src/com/fr/env/RemoteEnvPane.java | 24 +++++++++++-------- .../src/com/fr/start/EnvSwitcher.java | 9 ------- 6 files changed, 23 insertions(+), 32 deletions(-) diff --git a/designer-base/src/com/fr/design/DesignerEnvManager.java b/designer-base/src/com/fr/design/DesignerEnvManager.java index d8a76b564..30f5507d0 100644 --- a/designer-base/src/com/fr/design/DesignerEnvManager.java +++ b/designer-base/src/com/fr/design/DesignerEnvManager.java @@ -10,6 +10,7 @@ import com.fr.design.actions.help.alphafine.AlphaFineConfigManager; import com.fr.design.constants.UIConstants; import com.fr.design.env.DesignerWorkspaceGenerator; import com.fr.design.env.DesignerWorkspaceInfo; +import com.fr.design.env.DesignerWorkspaceType; import com.fr.design.env.LocalDesignerWorkspaceInfo; import com.fr.design.env.RemoteDesignerWorkspaceInfo; import com.fr.file.FILEFactory; @@ -35,10 +36,9 @@ import com.fr.stable.xml.XMLWriter; import com.fr.stable.xml.XMLableReader; import com.fr.workspace.WorkContext; -import javax.swing.SwingWorker; +import javax.swing.*; import javax.swing.SwingWorker.StateValue; -import java.awt.Color; -import java.awt.Rectangle; +import java.awt.*; import java.io.File; import java.io.FileOutputStream; import java.io.FileReader; @@ -1475,10 +1475,10 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { public void readXML(XMLableReader reader) { if (reader.isChildNode()) { String tagName = reader.getTagName(); - if (LocalDesignerWorkspaceInfo.XML_TAG.equals(tagName)) { + if (DesignerWorkspaceType.Local.toString().equals(tagName)) { LocalDesignerWorkspaceInfo envConfig = (LocalDesignerWorkspaceInfo) GeneralXMLTools.readXMLable(reader); putEnv(name, envConfig); - } else if (RemoteDesignerWorkspaceInfo.XML_TAG.equals(tagName)) { + } else if (DesignerWorkspaceType.Remote.toString().equals(tagName)) { RemoteDesignerWorkspaceInfo envConfig = (RemoteDesignerWorkspaceInfo) GeneralXMLTools.readXMLable(reader); putEnv(name, envConfig); } @@ -1605,7 +1605,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { for (Entry entry : nameEnvMap.entrySet()) { writer.startTAG("EnvConfigElement").attr("name", entry.getKey()); DesignerWorkspaceInfo envConfig = entry.getValue(); - GeneralXMLTools.writeXMLable(writer, envConfig, envConfig.XML_TAG); + GeneralXMLTools.writeXMLable(writer, envConfig, envConfig.getType().toString()); writer.end(); } writer.end(); diff --git a/designer-base/src/com/fr/design/env/LocalDesignerWorkspaceInfo.java b/designer-base/src/com/fr/design/env/LocalDesignerWorkspaceInfo.java index 709df5dd7..87e556d92 100644 --- a/designer-base/src/com/fr/design/env/LocalDesignerWorkspaceInfo.java +++ b/designer-base/src/com/fr/design/env/LocalDesignerWorkspaceInfo.java @@ -9,9 +9,7 @@ import com.fr.workspace.connect.WorkspaceConnection; * Created by juhaoyu on 2018/6/15. */ public class LocalDesignerWorkspaceInfo implements DesignerWorkspaceInfo { - - public static final String XML_TAG = "LocalDesignerWorkspaceInfo"; - + private String name; private String path; diff --git a/designer-base/src/com/fr/design/env/RemoteDesignerWorkspaceInfo.java b/designer-base/src/com/fr/design/env/RemoteDesignerWorkspaceInfo.java index a35ea4e25..428878dea 100644 --- a/designer-base/src/com/fr/design/env/RemoteDesignerWorkspaceInfo.java +++ b/designer-base/src/com/fr/design/env/RemoteDesignerWorkspaceInfo.java @@ -7,9 +7,7 @@ import com.fr.stable.xml.XMLableReader; import com.fr.workspace.connect.WorkspaceConnection; public class RemoteDesignerWorkspaceInfo implements DesignerWorkspaceInfo { - - public static final String XML_TAG = "RemoteDesignerWorkspaceInfo"; - + private String name; private WorkspaceConnection connection; diff --git a/designer-base/src/com/fr/design/mainframe/TemplatePane.java b/designer-base/src/com/fr/design/mainframe/TemplatePane.java index f312e73c5..fc165928b 100644 --- a/designer-base/src/com/fr/design/mainframe/TemplatePane.java +++ b/designer-base/src/com/fr/design/mainframe/TemplatePane.java @@ -142,7 +142,7 @@ public class TemplatePane extends JPanel implements MouseListener { @Override public void success() { - + DesignerEnvManager.getEnvManager().setCurEnvName(selectedName); DesignUtils.refreshDesignerFrame(); } }); diff --git a/designer-base/src/com/fr/env/RemoteEnvPane.java b/designer-base/src/com/fr/env/RemoteEnvPane.java index 5e749e230..137db5ff6 100644 --- a/designer-base/src/com/fr/env/RemoteEnvPane.java +++ b/designer-base/src/com/fr/env/RemoteEnvPane.java @@ -47,6 +47,7 @@ import java.awt.event.MouseEvent; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.io.File; +import java.util.concurrent.ExecutionException; import static com.fr.design.layout.TableLayout.FILL; import static com.fr.design.layout.TableLayout.PREFERRED; @@ -60,9 +61,10 @@ public class RemoteEnvPane extends BasicBeanPane { private static final Color TIPS_FONT_COLOR = new Color(0x8f8f92); private JDialog dialog; - private UILabel message; - private UIButton okButton; - private UIButton cancelButton; + private UILabel message = new UILabel(); + private UIButton okButton = new UIButton(Inter.getLocText("OK")); + private UIButton cancelButton = new UIButton(Inter.getLocText("Cancel")); + ; /** * 是否启用 https 勾选框 @@ -469,23 +471,25 @@ public class RemoteEnvPane extends BasicBeanPane { } private void tryConnectRemoteEnv() { - final SwingWorker worker = new SwingWorker() { + final SwingWorker worker = new SwingWorker() { @Override - protected Void doInBackground() throws Exception { + protected Boolean doInBackground() throws Exception { final RemoteDesignerWorkspaceInfo remoteEnv = updateBean(); - WorkContext.getConnector().testConnection(remoteEnv.getConnection()); - return null; + return WorkContext.getConnector().testConnection(remoteEnv.getConnection()); } @Override protected void done() { okButton.setEnabled(true); try { - get(); - message.setText(Inter.getLocText("Fine-Designer_Basic_Remote_Connect_Successful")); - } catch (Exception e) { + if (get()) { + message.setText(Inter.getLocText("Fine-Designer_Basic_Remote_Connect_Successful")); + } else { + message.setText(Inter.getLocText("Fine-Designer_Basic_Remote_Connect_Failed")); + } + } catch (InterruptedException | ExecutionException e) { message.setText(Inter.getLocText("Fine-Designer_Basic_Remote_Connect_Failed")); } } diff --git a/designer-realize/src/com/fr/start/EnvSwitcher.java b/designer-realize/src/com/fr/start/EnvSwitcher.java index ce334bd8e..301c38f2d 100644 --- a/designer-realize/src/com/fr/start/EnvSwitcher.java +++ b/designer-realize/src/com/fr/start/EnvSwitcher.java @@ -26,13 +26,4 @@ public class EnvSwitcher { TemplatePane.getInstance().dealEvnExceptionWhenStartDesigner(); } } - - /** - * 找不到默认的工作空间时,让用户手动选择一个 - */ - private Workspace chooseWorkspace() { - - return null; - } - }