Browse Source

Merge pull request #109 in DESIGN/design from ~RICHIE/design:feature/10.0 to feature/10.0

* commit '20d7b397a669155720bdade84e1db6fca190d38c':
  无JIRA任务 读取资源文件
  无JIRA任务 密码加密
  无JIRA任务 远程设计登录登出修改(部分)
master
superman 7 years ago
parent
commit
319fa725f5
  1. 189
      designer-base/src/com/fr/design/DesignerEnvManager.java
  2. 36
      designer-base/src/com/fr/design/actions/file/SwitchExistEnv.java
  3. 22
      designer-base/src/com/fr/design/env/EnvGenerator.java
  4. 134
      designer-base/src/com/fr/design/env/RemoteEnvConfig.java
  5. 5
      designer-base/src/com/fr/design/gui/itree/filetree/TemplateFileTree.java
  6. 17
      designer-base/src/com/fr/design/mainframe/DesignerFrame.java
  7. 57
      designer-base/src/com/fr/design/mainframe/TemplatePane.java
  8. 14
      designer-base/src/com/fr/design/mainframe/loghandler/socketio/DesignerSocketIO.java
  9. 33
      designer-base/src/com/fr/design/utils/DesignUtils.java
  10. 4
      designer-base/src/com/fr/env/EnvListPane.java
  11. 2
      designer-base/src/com/fr/env/LocalEnvPane.java
  12. 24
      designer-base/src/com/fr/env/RemoteEnv.java
  13. 8
      designer-base/src/com/fr/env/RemoteEnvPane.java
  14. 86
      designer-base/src/com/fr/env/RemoteEnvPane2.java
  15. 11
      designer-base/src/com/fr/env/SignIn.java
  16. 6
      designer-base/src/com/fr/start/ServerStarter.java
  17. 12
      designer-realize/src/com/fr/start/EnvSwitcher.java
  18. 18
      designer-realize/src/com/fr/start/module/DesignerEnvProvider.java

189
designer-base/src/com/fr/design/DesignerEnvManager.java

@ -6,19 +6,19 @@ package com.fr.design;
import com.fr.base.BaseXMLUtils; import com.fr.base.BaseXMLUtils;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.base.Utils; import com.fr.base.Utils;
import com.fr.base.env.EnvUpdater;
import com.fr.core.env.EnvConfig; import com.fr.core.env.EnvConfig;
import com.fr.core.env.resource.EnvConfigUtils; import com.fr.core.env.impl.LocalEnvConfig;
import com.fr.core.env.resource.LocalEnvConfig;
import com.fr.core.env.resource.RemoteEnvConfig;
import com.fr.design.actions.help.alphafine.AlphaFineConfigManager; import com.fr.design.actions.help.alphafine.AlphaFineConfigManager;
import com.fr.design.constants.UIConstants; import com.fr.design.constants.UIConstants;
import com.fr.env.SignIn; import com.fr.design.env.EnvGenerator;
import com.fr.file.FILEFactory; import com.fr.file.FILEFactory;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.FRLogFormatter; import com.fr.general.FRLogFormatter;
import com.fr.general.GeneralContext; import com.fr.general.GeneralContext;
import com.fr.general.IOUtils; import com.fr.general.IOUtils;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.general.xml.GeneralXMLTools;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.stable.Constants; import com.fr.stable.Constants;
import com.fr.stable.EnvChangedListener; import com.fr.stable.EnvChangedListener;
@ -73,7 +73,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
private boolean showPaintToolBar = true; private boolean showPaintToolBar = true;
private int maxNumberOrPreviewRow = 200; private int maxNumberOrPreviewRow = 200;
// name和Env的键值对 // name和Env的键值对
private Map<String, EnvConfig> nameEnvMap = new ListMap(); private Map<String, EnvConfig> nameEnvMap = new ListMap<>();
// marks: 当前报表服务器名字 // marks: 当前报表服务器名字
private String curEnvName = null; private String curEnvName = null;
private boolean showProjectPane = true; private boolean showProjectPane = true;
@ -526,11 +526,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
if (isCurrentEnvDefault()) { if (isCurrentEnvDefault()) {
return; return;
} }
try { EnvUpdater.updateEnv(EnvGenerator.generate(getDefaultEnv()));
SignIn.signIn(getDefaultEnv());
} catch (Exception e) {
FRContext.getLogger().error(e.getMessage());
}
} }
/** /**
@ -1311,8 +1307,8 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
this.readReportPaneAttributions(reader); this.readReportPaneAttributions(reader);
} else if ("RecentOpenedFilePathList".equals(name) || "ResentOpenedFilePathList".equals(name)) { } else if ("RecentOpenedFilePathList".equals(name) || "ResentOpenedFilePathList".equals(name)) {
this.readRecentOpenFileList(reader); this.readRecentOpenFileList(reader);
} else if ("Envs".equals(name) || name.equals("ReportServerMap")) { } else if ("EnvConfigMap".equals(name)) {
this.readCurEnv(reader); this.readEnvConfigMap(reader);
} else if (name.equals("ActivationKey")) { } else if (name.equals("ActivationKey")) {
readActiveKey(reader); readActiveKey(reader);
} else if ("LogLocation".equals(name)) { } else if ("LogLocation".equals(name)) {
@ -1457,32 +1453,30 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
} }
} }
private void readCurEnv(XMLableReader reader) { private void readEnvConfigMap(XMLableReader reader) {
String tmpVal; String currentEnv = reader.getAttrAsString("currentEnv", StringUtils.EMPTY);
// marks:设置默认的webInf名字 this.setCurEnvName(currentEnv);
if ((tmpVal = reader.getAttrAsString("currentEnv", null)) != null) {
this.setCurEnvName(tmpVal);
}
reader.readXMLObject(new XMLReadable() { reader.readXMLObject(new XMLReadable() {
@Override @Override
public void readXML(XMLableReader reader) { public void readXML(XMLableReader reader) {
if (reader.isAttr()) { if (reader.isAttr()) {
DesignerEnvManager.this.clearAllEnv(); clearAllEnv();
} } else if (reader.isChildNode()) {
String tagName = reader.getTagName();
if ("EnvConfigElement".equals(tagName)) {
final String name = reader.getAttrAsString("name", StringUtils.EMPTY);
reader.readXMLObject(new XMLReadable() {
@Override
public void readXML(XMLableReader reader) {
if (reader.isChildNode()) { if (reader.isChildNode()) {
if (reader.getTagName().contains("Env")) { // description. String tagName = reader.getTagName();
// marks:获取名字 if (EnvConfig.XML_TAG.equals(tagName)) {
String reportServerName = reader.getAttrAsString("name", null); EnvConfig envConfig = (EnvConfig) GeneralXMLTools.readXMLable(reader);
putEnv(name, envConfig);
EnvConfig env = readEnv(reader);
if (env == null) {
return;
} }
}
DesignerEnvManager.this.putEnv(reportServerName, env); }
});
} }
} }
} }
@ -1524,7 +1518,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
public void writeXML(XMLPrintWriter writer) { public void writeXML(XMLPrintWriter writer) {
writer.startTAG("Designer"); writer.startTAG("Designer");
writeAttrues(writer); writeAttributes(writer);
writeReportPaneAttributions(writer); writeReportPaneAttributions(writer);
writeRecentOpenFileAndEnvList(writer); writeRecentOpenFileAndEnvList(writer);
writeSomeAttr(writer); writeSomeAttr(writer);
@ -1596,22 +1590,20 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
} }
writer.end(); writer.end();
writer.startTAG("Envs"); writer.startTAG("EnvConfigMap");
if (this.curEnvName != null) { if (this.curEnvName != null) {
writer.attr("currentEnv", this.curEnvName); writer.attr("currentEnv", this.curEnvName);
} }
Iterator<String> nameIt = this.getEnvNameIterator(); for (Entry<String, EnvConfig> entry : nameEnvMap.entrySet()) {
while (nameIt.hasNext()) { writer.startTAG("EnvConfigElement").attr("name", entry.getKey());
String envName = nameIt.next(); EnvConfig envConfig = entry.getValue();
EnvConfig env = this.getEnv(envName); GeneralXMLTools.writeXMLable(writer, envConfig, EnvConfig.XML_TAG);
writer.end();
writeEnv(writer, envName, env);
} }
writer.end(); writer.end();
} }
private void writeAttrues(XMLPrintWriter writer) { private void writeAttributes(XMLPrintWriter writer) {
writer.startTAG("Attributes"); writer.startTAG("Attributes");
if (this.getWindowBounds() != null) { if (this.getWindowBounds() != null) {
writer.attr("windowBounds", BaseXMLUtils.getRectangleText(this.getWindowBounds())); writer.attr("windowBounds", BaseXMLUtils.getRectangleText(this.getWindowBounds()));
@ -1767,46 +1759,6 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
.end(); .end();
} }
/*
* 写Env为xml
*/
private static void writeEnv(XMLPrintWriter writer, String name, EnvConfig env) {
if (env == null) {
return;
}
writer.startTAG("EnvConfig");
writer.classAttr(env.getClass());
writer.attr("name", name);
EnvConfigXMLAdapter xmlAdapter = env instanceof RemoteEnvConfig
? new RemoteEnvConfigXMLAdapter()
: new LocalEnvConfigXMLAdapter();
xmlAdapter.fromEnvConfig(env).writeXML(writer);
writer.end();
}
/*
* 从xml读Env
*/
private static EnvConfig readEnv(XMLableReader reader) {
EnvConfigXMLAdapter xmlAdapter = null;
String tmpVal; //temp value
if ((tmpVal = reader.getAttrAsString("class", null)) != null) {
if (tmpVal.contains(".LocalEnv")) {
xmlAdapter = new LocalEnvConfigXMLAdapter();
} else if (tmpVal.contains(".RemoteEnv")) {
xmlAdapter = new RemoteEnvConfigXMLAdapter();
}
}
if (xmlAdapter == null) {
return null;
}
reader.readXMLObject(xmlAdapter);
return xmlAdapter.toEnvConfig();
}
public AlphaFineConfigManager getAlphaFineConfigManager() { public AlphaFineConfigManager getAlphaFineConfigManager() {
return alphaFineConfigManager; return alphaFineConfigManager;
@ -1816,79 +1768,6 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
this.alphaFineConfigManager = alphaFineConfigManager; this.alphaFineConfigManager = alphaFineConfigManager;
} }
private interface EnvConfigXMLAdapter extends XMLReadable, XMLWriter {
EnvConfig toEnvConfig();
EnvConfigXMLAdapter fromEnvConfig(EnvConfig envConfig);
}
private static class LocalEnvConfigXMLAdapter implements EnvConfigXMLAdapter {
private String path;
public void readXML(XMLableReader reader) {
if (reader.isChildNode()) {
if ("DIR".equals(reader.getTagName())) {
this.path = reader.getElementValue();
}
}
}
public void writeXML(XMLPrintWriter writer) {
writer.startTAG("DIR").textNode(this.path).end();
}
public EnvConfig toEnvConfig() {
return new LocalEnvConfig(path);
}
public EnvConfigXMLAdapter fromEnvConfig(EnvConfig envConfig) {
this.path = envConfig.getPath();
return this;
}
}
private static class RemoteEnvConfigXMLAdapter implements EnvConfigXMLAdapter {
private String path;
private String username;
private String password;
public void readXML(XMLableReader reader) {
if (reader.isChildNode()) {
String tmpVal;
if ("DIR".equals(reader.getTagName())) {
if ((tmpVal = reader.getAttrAsString("path", null)) != null) {
this.path = tmpVal;
}
if ((tmpVal = reader.getAttrAsString("user", null)) != null) {
this.username = tmpVal;
}
if ((tmpVal = reader.getAttrAsString("password", null)) != null) {
this.password = tmpVal;
}
}
}
}
public void writeXML(XMLPrintWriter writer) {
writer.startTAG("DIR")
.attr("path", this.path)
.attr("user", this.username)
.attr("password", this.password)
.end();
}
public EnvConfig toEnvConfig() {
return new RemoteEnvConfig(path, username, password);
}
public EnvConfigXMLAdapter fromEnvConfig(EnvConfig envConfig) {
this.path = envConfig.getPath();
this.username = EnvConfigUtils.getUsername(envConfig);
this.password = EnvConfigUtils.getPassword(envConfig);
return this;
}
}
public boolean isImageCompress() { public boolean isImageCompress() {
return imageCompress; return imageCompress;
} }

36
designer-base/src/com/fr/design/actions/file/SwitchExistEnv.java

@ -1,13 +1,16 @@
package com.fr.design.actions.file; package com.fr.design.actions.file;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.base.env.Callback;
import com.fr.base.env.EnvUpdater;
import com.fr.core.env.EnvConfig; import com.fr.core.env.EnvConfig;
import com.fr.core.env.resource.LocalEnvConfig; import com.fr.core.env.impl.LocalEnvConfig;
import com.fr.core.env.resource.RemoteEnvConfig;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.actions.UpdateAction; import com.fr.design.actions.UpdateAction;
import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.DesignTableDataManager;
import com.fr.design.data.tabledata.ResponseDataSourceChange; import com.fr.design.data.tabledata.ResponseDataSourceChange;
import com.fr.design.env.EnvGenerator;
import com.fr.design.env.RemoteEnvConfig;
import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.JTemplate;
@ -15,14 +18,14 @@ import com.fr.design.mainframe.TemplatePane;
import com.fr.design.menu.KeySetUtils; import com.fr.design.menu.KeySetUtils;
import com.fr.design.menu.MenuDef; import com.fr.design.menu.MenuDef;
import com.fr.design.menu.SeparatorDef; import com.fr.design.menu.SeparatorDef;
import com.fr.design.utils.DesignUtils;
import com.fr.env.RemoteEnv; import com.fr.env.RemoteEnv;
import com.fr.env.SignIn;
import com.fr.general.GeneralContext; import com.fr.general.GeneralContext;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.stable.EnvChangedListener; import com.fr.stable.EnvChangedListener;
import javax.swing.JOptionPane; import javax.swing.*;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
@ -97,24 +100,25 @@ public class SwitchExistEnv extends MenuDef {
*/ */
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
DesignerEnvManager envManager = DesignerEnvManager.getEnvManager(); DesignerEnvManager envManager = DesignerEnvManager.getEnvManager();
EnvConfig selectedEnv = envManager.getEnv(this.getName()); final String envName = getName();
try { EnvConfig selectedEnv = envManager.getEnv(envName);
if (selectedEnv instanceof RemoteEnv && !((RemoteEnv) selectedEnv).testServerConnection()) { EnvUpdater.updateEnv(EnvGenerator.generate(selectedEnv), new Callback() {
JOptionPane.showMessageDialog( @Override
DesignerContext.getDesignerFrame(), public void success() {
Inter.getLocText(new String[]{"M-SwitchWorkspace", "Failed"})); DesignerEnvManager.getEnvManager().setCurEnvName(envName);
return; DesignUtils.refreshDesignerFrame();
}
SignIn.signIn(selectedEnv);
HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().refreshToolArea(); HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().refreshToolArea();
fireDSChanged(); fireDSChanged();
} catch (Exception em) { }
FineLoggerFactory.getLogger().error(em.getMessage(), em);
@Override
public void fail() {
TemplatePane.getInstance().editItems();
JOptionPane.showMessageDialog( JOptionPane.showMessageDialog(
DesignerContext.getDesignerFrame(), DesignerContext.getDesignerFrame(),
Inter.getLocText(new String[]{"M-SwitchWorkspace", "Failed"})); Inter.getLocText(new String[]{"M-SwitchWorkspace", "Failed"}));
TemplatePane.getInstance().editItems();
} }
});
} }
} }
} }

22
designer-base/src/com/fr/design/env/EnvGenerator.java vendored

@ -0,0 +1,22 @@
package com.fr.design.env;
import com.fr.base.Env;
import com.fr.core.env.EnvConfig;
import com.fr.core.env.impl.LocalEnvConfig;
import com.fr.dav.LocalEnv;
import com.fr.env.RemoteEnv;
/**
* 根据配置生成运行环境
*/
public class EnvGenerator {
public static Env generate(EnvConfig config) {
Env env = null;
if (config instanceof LocalEnvConfig) {
env = new LocalEnv((LocalEnvConfig)config);
} else if (config instanceof RemoteEnvConfig) {
env = new RemoteEnv((RemoteEnvConfig) config);
}
return env;
}
}

134
designer-base/src/com/fr/design/env/RemoteEnvConfig.java vendored

@ -0,0 +1,134 @@
package com.fr.design.env;
import com.fr.core.env.impl.AbstractEnvConfig;
import com.fr.general.Inter;
import com.fr.security.SecurityToolbox;
import com.fr.stable.AssistUtils;
import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils;
import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLableReader;
public class RemoteEnvConfig extends AbstractEnvConfig {
public static final int DEFAULT_RPC_PORT = 39999;
private String host;
private int port;
private String username;
private String password;
public RemoteEnvConfig() {
}
public RemoteEnvConfig(String host, int port, String username, String password) {
this.host = host;
this.port = port;
this.username = username;
this.password = password;
}
@Override
public String getPath() {
return StableUtils.join(new Object[]{host, port}, ":");
}
public String getHost() {
return host;
}
public void setHost(String host) {
this.host = host;
}
public int getPort() {
return port;
}
public void setPort(int port) {
this.port = port;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
@Override
public String getDescription(String name) {
return username + "@" + name + "[" + Inter.getLocText("Fine-Designer_Basic_Remote_Env") + "]";
}
@Override
public void readXML(XMLableReader reader) {
super.readXML(reader);
if (reader.isChildNode()) {
String tagName = reader.getTagName();
if ("Attr".equals(tagName)) {
this.host = reader.getAttrAsString("host", StringUtils.EMPTY);
this.port = reader.getAttrAsInt("port", DEFAULT_RPC_PORT);
this.username = reader.getAttrAsString("username", StringUtils.EMPTY);
String password = reader.getAttrAsString("password", StringUtils.EMPTY);
if (StringUtils.isNotEmpty(password)) {
this.password = SecurityToolbox.decrypt(password);
}
} else if ("Username".equals(tagName)) {
this.username = reader.getElementValue();
} else if ("Password".equals(tagName)) {
String txt = reader.getElementValue();
this.password = SecurityToolbox.decrypt(txt);
}
}
}
@Override
public void writeXML(XMLPrintWriter writer) {
super.writeXML(writer);
writer.startTAG("Attr")
.attr("host", host)
.attr("port", port);
writer.end();
writer.startTAG("Username").textNode(username).end();
if (StringUtils.isNotEmpty(password)) {
writer.startTAG("Password").textNode(SecurityToolbox.encrypt(password)).end();
}
}
@Override
public boolean equals(Object o) {
return o instanceof RemoteEnvConfig
&& AssistUtils.equals(((RemoteEnvConfig) o).host, host)
&& AssistUtils.equals(((RemoteEnvConfig) o).port, port)
&& AssistUtils.equals(((RemoteEnvConfig) o).username, username)
&& AssistUtils.equals(((RemoteEnvConfig) o).password, password);
}
@Override
public int hashCode() {
return AssistUtils.hashCode(host, port, username, password);
}
@Override
public Object clone() throws CloneNotSupportedException {
RemoteEnvConfig cloned = (RemoteEnvConfig) super.clone();
cloned.host = host;
cloned.port = port;
cloned.username = username;
cloned.password = password;
return cloned;
}
}

5
designer-base/src/com/fr/design/gui/itree/filetree/TemplateFileTree.java

@ -1,10 +1,12 @@
package com.fr.design.gui.itree.filetree; package com.fr.design.gui.itree.filetree;
import com.fr.base.Env; import com.fr.base.Env;
import com.fr.base.FRContext;
import com.fr.base.operator.file.FileOperator; import com.fr.base.operator.file.FileOperator;
import com.fr.core.env.proxy.EnvProxy; import com.fr.core.env.proxy.EnvProxy;
import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode; import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode;
import com.fr.file.filetree.FileNode; import com.fr.file.filetree.FileNode;
import com.fr.general.web.ParameterConstants;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
@ -102,8 +104,7 @@ public class TemplateFileTree extends EnvFileTree {
} }
public FileNode[] listFile(String path) throws Exception { public FileNode[] listFile(String path) throws Exception {
String extra = EnvProxy.get(FileOperator.class).readExtraResourcePath(path); return FRContext.getCurrentEnv().getFileOperator().list("reportlets", path);
return EnvProxy.get(FileOperator.class).list(extra, path);
} }
/* /*

17
designer-base/src/com/fr/design/mainframe/DesignerFrame.java

@ -4,11 +4,9 @@
package com.fr.design.mainframe; package com.fr.design.mainframe;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.base.Env;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.base.env.EnvUpdater;
import com.fr.core.env.EnvConfig; import com.fr.core.env.EnvConfig;
import com.fr.core.env.EnvContext;
import com.fr.core.env.resource.EnvConfigUtils;
import com.fr.design.DesignModelAdapter; import com.fr.design.DesignModelAdapter;
import com.fr.design.DesignState; import com.fr.design.DesignState;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
@ -37,15 +35,14 @@ import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus;
import com.fr.design.menu.MenuManager; import com.fr.design.menu.MenuManager;
import com.fr.design.utils.DesignUtils; import com.fr.design.utils.DesignUtils;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.event.EventDispatcher;
import com.fr.file.FILE; import com.fr.file.FILE;
import com.fr.file.FILEFactory; import com.fr.file.FILEFactory;
import com.fr.file.FileFILE; import com.fr.file.FileFILE;
import com.fr.file.FileNodeFILE; import com.fr.file.FileNodeFILE;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.general.GeneralContext; import com.fr.general.GeneralContext;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.log.FineLoggerFactory;
import com.fr.plugin.context.PluginContext; import com.fr.plugin.context.PluginContext;
import com.fr.plugin.injectable.PluginModule; import com.fr.plugin.injectable.PluginModule;
import com.fr.plugin.manage.PluginFilter; import com.fr.plugin.manage.PluginFilter;
@ -84,9 +81,6 @@ import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import static com.fr.core.env.EnvEvent.AFTER_SIGN_OUT;
import static com.fr.core.env.EnvEvent.BEFORE_SIGN_OUT;
public class DesignerFrame extends JFrame implements JTemplateActionListener, TargetModifiedListener { public class DesignerFrame extends JFrame implements JTemplateActionListener, TargetModifiedListener {
public static final String DESIGNER_FRAME_NAME = "designer_frame"; public static final String DESIGNER_FRAME_NAME = "designer_frame";
public static final Dimension MIN_SIZE = new Dimension(100, 100); public static final Dimension MIN_SIZE = new Dimension(100, 100);
@ -648,13 +642,12 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
defaultTitleSB.append(ProductConstants.PRODUCT_NAME); defaultTitleSB.append(ProductConstants.PRODUCT_NAME);
defaultTitleSB.append(" "); defaultTitleSB.append(" ");
defaultTitleSB.append(ProductConstants.BRANCH); defaultTitleSB.append(ProductConstants.BRANCH);
defaultTitleSB.append(" ");
// james:标识登录的用户和登录的ENV // james:标识登录的用户和登录的ENV
String envName = DesignerEnvManager.getEnvManager().getCurEnvName(); String envName = DesignerEnvManager.getEnvManager().getCurEnvName();
EnvConfig env = DesignerEnvManager.getEnvManager().getEnv(envName); EnvConfig env = DesignerEnvManager.getEnvManager().getEnv(envName);
if (env != null) { if (env != null) {
defaultTitleSB.append(EnvConfigUtils.getUsername(env)).append('@').append(envName).append('['); defaultTitleSB.append(env.getDescription(envName));
defaultTitleSB.append(Inter.getLocText("Env-Remote_Server"));
defaultTitleSB.append(']');
if (editingTemplate != null) { if (editingTemplate != null) {
String path = editingTemplate.getEditingFILE().getPath(); String path = editingTemplate.getEditingFILE().getPath();
if (!editingTemplate.getEditingFILE().exists()) { if (!editingTemplate.getEditingFILE().exists()) {
@ -981,7 +974,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
DesignerEnvManager.getEnvManager().saveXMLFile(); DesignerEnvManager.getEnvManager().saveXMLFile();
EnvContext.signOut(); EnvUpdater.disconnect();
this.setVisible(false); this.setVisible(false);
this.dispose(); this.dispose();

57
designer-base/src/com/fr/design/mainframe/TemplatePane.java

@ -1,40 +1,34 @@
package com.fr.design.mainframe; package com.fr.design.mainframe;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.base.env.Callback;
import com.fr.base.env.EnvUpdater;
import com.fr.core.env.EnvConfig; import com.fr.core.env.EnvConfig;
import com.fr.dav.LocalEnv; import com.fr.core.env.impl.LocalEnvConfig;
import com.fr.design.DesignModelAdapter; import com.fr.design.DesignModelAdapter;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.dialog.InformationWarnPane; import com.fr.design.dialog.InformationWarnPane;
import com.fr.design.env.EnvGenerator;
import com.fr.design.env.RemoteEnvConfig;
import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.file.TemplateTreePane; import com.fr.design.file.TemplateTreePane;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.utils.DesignUtils;
import com.fr.env.EnvListPane; import com.fr.env.EnvListPane;
import com.fr.env.RemoteEnv; import com.fr.env.RemoteEnv;
import com.fr.env.SignIn;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.GeneralContext; import com.fr.general.GeneralContext;
import com.fr.general.IOUtils;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.stable.EnvChangedListener; import com.fr.stable.EnvChangedListener;
import com.fr.stable.ProductConstants; import com.fr.stable.ProductConstants;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import javax.swing.BorderFactory; import javax.swing.*;
import javax.swing.Icon; import java.awt.*;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.GradientPaint;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
@ -121,27 +115,23 @@ public class TemplatePane extends JPanel implements MouseListener {
} }
private boolean envListOkAction(EnvListPane envListPane) { private boolean envListOkAction(EnvListPane envListPane) {
String selectedName = envListPane.updateEnvManager(); final String selectedName = envListPane.updateEnvManager();
DesignerEnvManager envManager = DesignerEnvManager.getEnvManager(); DesignerEnvManager envManager = DesignerEnvManager.getEnvManager();
EnvConfig selectedEnv = envManager.getEnv(selectedName); EnvConfig selectedEnv = envManager.getEnv(selectedName);
GeneralContext.fireEnvWillChangeListener(); GeneralContext.fireEnvWillChangeListener();
try { try {
//如果是远程的还要先测试下,如果失败就不切换 EnvUpdater.updateEnv(EnvGenerator.generate(selectedEnv), new Callback() {
if (selectedEnv instanceof RemoteEnv) { @Override
if (!((RemoteEnv) selectedEnv).testServerConnection()) { public void fail() {
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Inter.getLocText(new String[]{"M-SwitchWorkspace", "Failed"})); JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Inter.getLocText(new String[]{"M-SwitchWorkspace", "Failed"}));
return false;
} else {
String remoteVersion = getDesignerVersion(selectedEnv);
if (StringUtils.isBlank(remoteVersion) || ComparatorUtils.compare(remoteVersion, ProductConstants.DESIGNER_VERSION) < 0) {
String infor = Inter.getLocText("Server-version-tip");
String moreInfo = Inter.getLocText("Server-version-tip-moreInfo");
new InformationWarnPane(infor, moreInfo, Inter.getLocText("Tooltips")).show();
return false;
}
} }
@Override
public void success() {
DesignerEnvManager.getEnvManager().setCurEnvName(selectedName);
DesignUtils.refreshDesignerFrame();
} }
SignIn.signIn(selectedEnv); });
JTemplate template = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); JTemplate template = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate();
if (template != null) { if (template != null) {
template.refreshToolArea(); template.refreshToolArea();
@ -185,11 +175,12 @@ public class TemplatePane extends JPanel implements MouseListener {
} }
private void setJLabel(String name) { private void setJLabel(String name) {
if (DesignerEnvManager.getEnvManager().getEnv(name) instanceof LocalEnv) { EnvConfig config = DesignerEnvManager.getEnvManager().getEnv(name);
envLabel.setIcon(BaseUtils.readIcon("com/fr/design/images/data/bind/localconnect.png")); if (config instanceof LocalEnvConfig) {
envLabel.setIcon(IOUtils.readIcon("com/fr/design/images/data/bind/localconnect.png"));
} else if (DesignerEnvManager.getEnvManager().getEnv(name) instanceof RemoteEnv) { } else if (config instanceof RemoteEnvConfig) {
envLabel.setIcon(BaseUtils.readIcon("com/fr/design/images/data/bind/distanceconnect.png")); envLabel.setIcon(IOUtils.readIcon("com/fr/design/images/data/bind/distanceconnect.png"));
} }
envLabel.setText(name); envLabel.setText(name);
envLabel.repaint(); envLabel.repaint();

14
designer-base/src/com/fr/design/mainframe/loghandler/socketio/DesignerSocketIO.java

@ -1,14 +1,18 @@
package com.fr.design.mainframe.loghandler.socketio; package com.fr.design.mainframe.loghandler.socketio;
import com.fr.base.Env;
import com.fr.base.FRContext;
import com.fr.config.ConfigEvent; import com.fr.config.ConfigEvent;
import com.fr.config.Configuration; import com.fr.config.Configuration;
import com.fr.core.env.EnvConfig; import com.fr.core.env.EnvConfig;
import com.fr.core.env.EnvConstants; import com.fr.core.env.EnvConstants;
import com.fr.core.env.EnvContext; import com.fr.core.env.EnvContext;
import com.fr.core.env.EnvEvent; import com.fr.core.env.EnvEvent;
import com.fr.core.env.resource.LocalEnvConfig; import com.fr.core.env.impl.LocalEnvConfig;
import com.fr.decision.webservice.utils.DecisionServiceConstants; import com.fr.decision.webservice.utils.DecisionServiceConstants;
import com.fr.design.env.RemoteEnvConfig;
import com.fr.design.mainframe.loghandler.DesignerLogHandler; import com.fr.design.mainframe.loghandler.DesignerLogHandler;
import com.fr.env.RemoteEnv;
import com.fr.event.Event; import com.fr.event.Event;
import com.fr.event.EventDispatcher; import com.fr.event.EventDispatcher;
import com.fr.event.Listener; import com.fr.event.Listener;
@ -66,14 +70,14 @@ public class DesignerSocketIO {
} }
private static void updateSocket() { private static void updateSocket() {
EnvConfig env = EnvContext.currentEnv(); Env env = FRContext.getCurrentEnv();
if (env instanceof LocalEnvConfig) { if (env.isLocalEnv()) {
return; return;
} }
try { try {
RemoteEnvConfig config = ((RemoteEnv)env).getEnvConfig();
String uri = String.format("http://%s:%s%s?%s=%s", String uri = String.format("http://%s:%s%s?%s=%s",
new URL(env.getPath()).getHost(), config.getHost(),
WebSocketConfig.getInstance().getPort(), WebSocketConfig.getInstance().getPort(),
EnvConstants.WS_NAMESPACE, EnvConstants.WS_NAMESPACE,
DecisionServiceConstants.WEB_SOCKET_TOKEN_NAME, DecisionServiceConstants.WEB_SOCKET_TOKEN_NAME,

33
designer-base/src/com/fr/design/utils/DesignUtils.java

@ -7,8 +7,6 @@ import com.fr.base.FeedBackInfo;
import com.fr.base.ServerConfig; import com.fr.base.ServerConfig;
import com.fr.base.Utils; import com.fr.base.Utils;
import com.fr.base.remote.RemoteDeziConstants; import com.fr.base.remote.RemoteDeziConstants;
import com.fr.core.env.EnvConfig;
import com.fr.core.env.EnvContext;
import com.fr.dav.DavXMLUtils; import com.fr.dav.DavXMLUtils;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.ExtraDesignClassManager; import com.fr.design.ExtraDesignClassManager;
@ -31,11 +29,8 @@ import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.start.ServerStarter; import com.fr.start.ServerStarter;
import javax.swing.JOptionPane; import javax.swing.*;
import javax.swing.SwingUtilities; import java.awt.*;
import javax.swing.UIManager;
import java.awt.Desktop;
import java.awt.Font;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.BufferedWriter; import java.io.BufferedWriter;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
@ -187,30 +182,6 @@ public class DesignUtils {
}); });
} }
/**
* 当前的报表运行环境切换到env
*
* @param env 需要切换去的环境
*/
public static void switchToEnv(EnvConfig env) {
if (env == null) {
return;
}
// 看一下这个env在DesignerEnvManager里面有没有对应的,有的话就setCurrentEnvName
DesignerEnvManager envManager = DesignerEnvManager.getEnvManager();
java.util.Iterator<String> nameIt = envManager.getEnvNameIterator();
while (nameIt.hasNext()) {
String name = nameIt.next();
if (ComparatorUtils.equals(envManager.getEnv(name), env)) {
envManager.setCurEnvName(name);
break;
}
}
EnvContext.signIn(env);
refreshDesignerFrame();
}
public static void refreshDesignerFrame() { public static void refreshDesignerFrame() {
// 刷新DesignerFrame里面的面板 // 刷新DesignerFrame里面的面板

4
designer-base/src/com/fr/env/EnvListPane.java vendored

@ -1,8 +1,8 @@
package com.fr.env; package com.fr.env;
import com.fr.core.env.EnvConfig; import com.fr.core.env.EnvConfig;
import com.fr.core.env.resource.LocalEnvConfig; import com.fr.core.env.impl.LocalEnvConfig;
import com.fr.core.env.resource.RemoteEnvConfig; import com.fr.design.env.RemoteEnvConfig;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.gui.controlpane.JListControlPane; import com.fr.design.gui.controlpane.JListControlPane;
import com.fr.design.gui.controlpane.NameObjectCreator; import com.fr.design.gui.controlpane.NameObjectCreator;

2
designer-base/src/com/fr/env/LocalEnvPane.java vendored

@ -1,6 +1,6 @@
package com.fr.env; package com.fr.env;
import com.fr.core.env.resource.LocalEnvConfig; import com.fr.core.env.impl.LocalEnvConfig;
import com.fr.design.beans.BasicBeanPane; import com.fr.design.beans.BasicBeanPane;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itextarea.UITextArea; import com.fr.design.gui.itextarea.UITextArea;

24
designer-base/src/com/fr/env/RemoteEnv.java vendored

@ -2,6 +2,7 @@ package com.fr.env;
import com.fr.base.EnvException; import com.fr.base.EnvException;
import com.fr.base.TableData; import com.fr.base.TableData;
import com.fr.base.operator.common.CommonOperator;
import com.fr.base.operator.connect.ConnectOperator; import com.fr.base.operator.connect.ConnectOperator;
import com.fr.base.operator.file.FileOperator; import com.fr.base.operator.file.FileOperator;
import com.fr.base.remote.RemoteDeziConstants; import com.fr.base.remote.RemoteDeziConstants;
@ -10,7 +11,7 @@ import com.fr.common.rpc.netty.MessageSendExecutor;
import com.fr.common.rpc.netty.RemoteCallClient; import com.fr.common.rpc.netty.RemoteCallClient;
import com.fr.core.env.EnvConstants; import com.fr.core.env.EnvConstants;
import com.fr.core.env.EnvContext; import com.fr.core.env.EnvContext;
import com.fr.core.env.resource.RemoteEnvConfig; import com.fr.design.env.RemoteEnvConfig;
import com.fr.data.TableDataSource; import com.fr.data.TableDataSource;
import com.fr.data.impl.EmbeddedTableData; import com.fr.data.impl.EmbeddedTableData;
import com.fr.data.impl.storeproc.StoreProcedure; import com.fr.data.impl.storeproc.StoreProcedure;
@ -93,13 +94,9 @@ public class RemoteEnv extends AbstractEnv<RemoteEnvConfig> implements DesignAut
this.config = config; this.config = config;
} }
public RemoteEnv(String path, String userName, String password) {
config = new RemoteEnvConfig(path, userName, password);
}
@Override @Override
public void connect() throws Exception { public void connect() throws Exception {
RemoteCallClient.getInstance().load(config.getHost(), config.getPort(), RemoteCallServerConfig.getInstance().getSerializeProtocol());
} }
@Override @Override
@ -128,6 +125,16 @@ public class RemoteEnv extends AbstractEnv<RemoteEnvConfig> implements DesignAut
return MessageSendExecutor.getInstance().execute(FileOperator.class); return MessageSendExecutor.getInstance().execute(FileOperator.class);
} }
@Override
public CommonOperator getCommonOperator() throws Exception {
return MessageSendExecutor.getInstance().execute(CommonOperator.class);
}
@Override
public RemoteEnvConfig getEnvConfig() {
return config;
}
@Override @Override
public String getPath() { public String getPath() {
return config.getPath(); return config.getPath();
@ -147,6 +154,11 @@ public class RemoteEnv extends AbstractEnv<RemoteEnvConfig> implements DesignAut
return EnvContext.currentToken(); return EnvContext.currentToken();
} }
@Override
public boolean isLocalEnv() {
return false;
}
/** /**
* execute method之后,取返回的 InputStream * execute method之后,取返回的 InputStream
*/ */

8
designer-base/src/com/fr/env/RemoteEnvPane.java vendored

@ -2,7 +2,7 @@ package com.fr.env;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.core.env.resource.EnvConfigUtils; import com.fr.core.env.resource.EnvConfigUtils;
import com.fr.core.env.resource.RemoteEnvConfig; import com.fr.design.env.RemoteEnvConfig;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.beans.BasicBeanPane; import com.fr.design.beans.BasicBeanPane;
import com.fr.design.border.UITitledBorder; import com.fr.design.border.UITitledBorder;
@ -280,8 +280,9 @@ public class RemoteEnvPane extends BasicBeanPane<RemoteEnvConfig> {
String path = remoteEnvURL.getURL(); String path = remoteEnvURL.getURL();
String user = this.usernameInput.getText(); String user = this.usernameInput.getText();
String password = new String(this.passwordInput.getPassword()); String password = new String(this.passwordInput.getPassword());
return null;
return new RemoteEnvConfig(path, user, password); //return new RemoteEnvConfig(path, user, password);
} }
@Override @Override
@ -471,7 +472,8 @@ public class RemoteEnvPane extends BasicBeanPane<RemoteEnvConfig> {
private boolean testConnection() { private boolean testConnection() {
String url = remoteEnvURL.getURL(); String url = remoteEnvURL.getURL();
RemoteEnv env = new RemoteEnv(url, usernameInput.getText(), new String(passwordInput.getPassword())); //RemoteEnv env = new RemoteEnv(url, usernameInput.getText(), new String(passwordInput.getPassword()));
RemoteEnv env = null;
boolean connect = false; boolean connect = false;
try { try {
if (StringUtils.isNotEmpty(url)) { if (StringUtils.isNotEmpty(url)) {

86
designer-base/src/com/fr/env/RemoteEnvPane2.java vendored

@ -1,6 +1,6 @@
package com.fr.env; package com.fr.env;
import com.fr.core.env.resource.RemoteEnvConfig; import com.fr.design.env.RemoteEnvConfig;
import com.fr.design.beans.BasicBeanPane; import com.fr.design.beans.BasicBeanPane;
import com.fr.design.border.UITitledBorder; import com.fr.design.border.UITitledBorder;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
@ -12,14 +12,14 @@ import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper; import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.log.FineLoggerFactory;
import javax.swing.*; import javax.swing.*;
import javax.swing.border.EmptyBorder; import javax.swing.border.EmptyBorder;
import java.awt.*; import java.awt.*;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.util.concurrent.ExecutionException; import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
/** /**
* 远程环境设置界面暂时命名为2待做完功能直接替代掉老的RemoteEnvPane * 远程环境设置界面暂时命名为2待做完功能直接替代掉老的RemoteEnvPane
@ -30,6 +30,10 @@ public class RemoteEnvPane2 extends BasicBeanPane<RemoteEnvConfig> {
private UIIntNumberField portTextField; private UIIntNumberField portTextField;
private UITextField usernameTextField; private UITextField usernameTextField;
private UIPassWordField passwordTextField; private UIPassWordField passwordTextField;
private JDialog dialog;
private UILabel message;
private UIButton okButton;
private UIButton cancelButton;
public RemoteEnvPane2() { public RemoteEnvPane2() {
initComponents(); initComponents();
@ -73,46 +77,82 @@ public class RemoteEnvPane2 extends BasicBeanPane<RemoteEnvConfig> {
} }
}); });
contentPanel.add(valuePane, BorderLayout.CENTER); contentPanel.add(valuePane, BorderLayout.CENTER);
message = new UILabel();
okButton = new UIButton(Inter.getLocText("OK"));
cancelButton = new UIButton(Inter.getLocText("Cancel"));
} }
private void tryConnectRemoteEnv() { private void tryConnectRemoteEnv() {
final RemoteEnv remoteEnv = new RemoteEnv(this.updateBean()); final SwingWorker<Void, Void> worker = new SwingWorker<Void, Void>() {
new SwingWorker<Void, Void>() {
@Override @Override
protected Void doInBackground() throws Exception { protected Void doInBackground() throws Exception {
final RemoteEnv remoteEnv = new RemoteEnv(updateBean());
remoteEnv.connectOnce(); remoteEnv.connectOnce();
return null; return null;
} }
@Override @Override
protected void done() { protected void done() {
okButton.setEnabled(true);
try { try {
get(); get();
showConnectMessage(); message.setText(Inter.getLocText("Fine-Designer_Basic_Remote_Connect_Successful"));
} catch (Exception e) { } catch (Exception e) {
showCannotConnectMessage(); message.setText(Inter.getLocText("Fine-Designer_Basic_Remote_Connect_Failed"));
}
} }
};
worker.execute();
initMessageDialog();
okButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
dialog.dispose();
} }
}.execute(); });
cancelButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
dialog.dispose();
worker.cancel(true);
} }
});
private void showCannotConnectMessage() { dialog.addWindowListener(new WindowAdapter() {
JOptionPane.showMessageDialog( public void windowClosed(WindowEvent e) {
this, worker.cancel(true);
Inter.getLocText("Fine-Designer_Basic_Remote_Connect_Failed"),
UIManager.getString("OptionPane.messageDialogTitle", this.getLocale()),
JOptionPane.ERROR_MESSAGE
);
} }
});
private void showConnectMessage() { dialog.setVisible(true);
JOptionPane.showMessageDialog( dialog.dispose();
this, }
Inter.getLocText("Fine-Designer_Basic_Remote_Connect_Successful"),
UIManager.getString("OptionPane.messageDialogTitle", this.getLocale()), private void initMessageDialog() {
JOptionPane.INFORMATION_MESSAGE message.setText(Inter.getLocText("Fine-Designer_Basic_Remote_Env_Try") + "...");
); message.setBorder(BorderFactory.createEmptyBorder(8, 5, 0, 0));
okButton.setEnabled(false);
dialog = new JDialog((Dialog) SwingUtilities.getWindowAncestor(RemoteEnvPane2.this), Inter.getLocText("Datasource-Test_Connection"), true);
dialog.setSize(new Dimension(268, 118));
okButton.setEnabled(false);
JPanel jp = new JPanel();
JPanel upPane = new JPanel();
JPanel downPane = new JPanel();
UILabel uiLabel = new UILabel(UIManager.getIcon("OptionPane.informationIcon"));
upPane.setLayout(new FlowLayout(FlowLayout.LEFT, 10, 10));
upPane.add(uiLabel);
upPane.add(message);
downPane.setLayout(new FlowLayout(FlowLayout.CENTER, 6, 0));
downPane.add(okButton);
downPane.add(cancelButton);
jp.setLayout(new BoxLayout(jp, BoxLayout.Y_AXIS));
jp.add(upPane);
jp.add(downPane);
dialog.add(jp);
dialog.setResizable(false);
dialog.setLocationRelativeTo(SwingUtilities.getWindowAncestor(RemoteEnvPane2.this));
} }
@Override @Override
@ -125,7 +165,7 @@ public class RemoteEnvPane2 extends BasicBeanPane<RemoteEnvConfig> {
if (config == null) { if (config == null) {
return; return;
} }
hostTextField.setText(config.getPath()); hostTextField.setText(config.getHost());
if (config.getPort() != 0) { if (config.getPort() != 0) {
portTextField.setValue(config.getPort()); portTextField.setValue(config.getPort());
} }

11
designer-base/src/com/fr/env/SignIn.java vendored

@ -1,6 +1,8 @@
package com.fr.env; package com.fr.env;
import com.fr.base.Env;
import com.fr.base.FRContext;
import com.fr.core.env.EnvConfig; import com.fr.core.env.EnvConfig;
import com.fr.core.env.EnvContext; import com.fr.core.env.EnvContext;
import com.fr.core.env.EnvEvent; import com.fr.core.env.EnvEvent;
@ -12,6 +14,7 @@ import com.fr.event.Listener;
import com.fr.event.Null; import com.fr.event.Null;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.stable.AssistUtils;
import javax.swing.*; import javax.swing.*;
@ -34,10 +37,10 @@ public class SignIn {
* @throws Exception 异常 * @throws Exception 异常
*/ */
public static void signIn(EnvConfig selectedEnv) throws Exception { public static void signIn(EnvConfig selectedEnv) throws Exception {
Env env = FRContext.getCurrentEnv();
if (EnvContext.currentEnv() != null && !ComparatorUtils.equals(EnvContext.currentEnv(), selectedEnv)) { if (env != null && AssistUtils.equals(env.getEnvConfig(), selectedEnv)) {
EnvContext.signOut(); env.disconnect();
} }
DesignUtils.switchToEnv(selectedEnv); //DesignUtils.switchToEnv(selectedEnv);
} }
} }

6
designer-base/src/com/fr/start/ServerStarter.java

@ -2,16 +2,17 @@ package com.fr.start;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.base.ServerConfig; import com.fr.base.ServerConfig;
import com.fr.base.env.EnvUpdater;
import com.fr.design.DesignModelAdapter; import com.fr.design.DesignModelAdapter;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.data.datapane.TableDataTreePane; import com.fr.design.data.datapane.TableDataTreePane;
import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.BasicPane;
import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.env.EnvGenerator;
import com.fr.design.file.TemplateTreePane; import com.fr.design.file.TemplateTreePane;
import com.fr.design.gui.itextarea.UITextArea; import com.fr.design.gui.itextarea.UITextArea;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.env.RemoteEnv; import com.fr.env.RemoteEnv;
import com.fr.env.SignIn;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.GeneralContext; import com.fr.general.GeneralContext;
import com.fr.general.Inter; import com.fr.general.Inter;
@ -52,9 +53,8 @@ public class ServerStarter {
@Override @Override
public void doOk() { public void doOk() {
try { try {
SignIn.signIn(DesignerEnvManager.getEnvManager().getDefaultEnv()); EnvUpdater.updateEnv(EnvGenerator.generate(DesignerEnvManager.getEnvManager().getDefaultEnv()));
TemplateTreePane.getInstance().refreshDockingView(); TemplateTreePane.getInstance().refreshDockingView();
TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter()); TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter());
} catch (Exception e) { } catch (Exception e) {

12
designer-realize/src/com/fr/start/EnvSwitcher.java

@ -1,10 +1,10 @@
package com.fr.start; package com.fr.start;
import com.fr.base.FRContext; import com.fr.base.Env;
import com.fr.base.env.EnvUpdater;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.env.EnvGenerator;
import com.fr.design.mainframe.TemplatePane; import com.fr.design.mainframe.TemplatePane;
import com.fr.env.SignIn;
import com.fr.general.Inter;
/** /**
* Created by juhaoyu on 2018/1/31. * Created by juhaoyu on 2018/1/31.
@ -16,10 +16,8 @@ public class EnvSwitcher {
try { try {
String current = DesignerEnvManager.getEnvManager().getCurEnvName(); String current = DesignerEnvManager.getEnvManager().getCurEnvName();
SignIn.signIn(DesignerEnvManager.getEnvManager().getEnv(current)); Env env = EnvGenerator.generate(DesignerEnvManager.getEnvManager().getEnv(current));
if (!FRContext.getCurrentEnv().testServerConnectionWithOutShowMessagePane()) { EnvUpdater.updateEnv(env);
throw new Exception(Inter.getLocText("Datasource-Connection_failed"));
}
} catch (Exception e) { } catch (Exception e) {
TemplatePane.getInstance().dealEvnExceptionWhenStartDesigner(); TemplatePane.getInstance().dealEvnExceptionWhenStartDesigner();
} }

18
designer-realize/src/com/fr/start/module/DesignerEnvProvider.java

@ -1,26 +1,23 @@
package com.fr.start.module; package com.fr.start.module;
import com.fr.base.FRContext; import com.fr.base.Env;
import com.fr.base.ModifiedTable; import com.fr.base.ModifiedTable;
import com.fr.base.Parameter; import com.fr.base.Parameter;
import com.fr.base.StoreProcedureParameter; import com.fr.base.StoreProcedureParameter;
import com.fr.base.TableData; import com.fr.base.TableData;
import com.fr.base.env.EnvUpdater;
import com.fr.base.env.serializer.OldSerializerAdapter; import com.fr.base.env.serializer.OldSerializerAdapter;
import com.fr.base.env.serializer.ProcedureDataModelSerializer; import com.fr.base.env.serializer.ProcedureDataModelSerializer;
import com.fr.core.env.EnvConfig; import com.fr.core.env.EnvConfig;
import com.fr.core.env.EnvEvent; import com.fr.core.env.EnvEvent;
import com.fr.core.env.proxy.EnvProxy; import com.fr.core.env.proxy.EnvProxy;
import com.fr.core.env.resource.EnvConfigUtils;
import com.fr.core.env.resource.LocalEnvConfig;
import com.fr.core.env.resource.RemoteEnvConfig;
import com.fr.data.core.db.TableProcedure; import com.fr.data.core.db.TableProcedure;
import com.fr.data.impl.Connection; import com.fr.data.impl.Connection;
import com.fr.data.impl.storeproc.ProcedureDataModel; import com.fr.data.impl.storeproc.ProcedureDataModel;
import com.fr.data.impl.storeproc.StoreProcedure; import com.fr.data.impl.storeproc.StoreProcedure;
import com.fr.dav.DavXMLUtils; import com.fr.dav.DavXMLUtils;
import com.fr.dav.LocalEnv;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.env.RemoteEnv; import com.fr.design.env.EnvGenerator;
import com.fr.event.Event; import com.fr.event.Event;
import com.fr.event.EventDispatcher; import com.fr.event.EventDispatcher;
import com.fr.event.Listener; import com.fr.event.Listener;
@ -64,17 +61,12 @@ public class DesignerEnvProvider extends Activator {
EventDispatcher.listen(EnvEvent.BEFORE_SIGN_IN, new Listener<EnvConfig>() { EventDispatcher.listen(EnvEvent.BEFORE_SIGN_IN, new Listener<EnvConfig>() {
@Override @Override
public void on(Event event, EnvConfig envConfig) { public void on(Event event, EnvConfig envConfig) {
if (envConfig instanceof RemoteEnvConfig) { Env env = EnvGenerator.generate(envConfig);
RemoteEnv remoteEnv = new RemoteEnv(envConfig.getPath(), EnvConfigUtils.getUsername(envConfig), EnvConfigUtils.getPassword(envConfig)); EnvUpdater.updateEnv(env);
FRContext.setCurrentEnv(remoteEnv);
} else if (envConfig instanceof LocalEnvConfig) {
FRContext.setCurrentEnv(new LocalEnv());
}
} }
}); });
} }
private void addSerializers() { private void addSerializers() {
EnvProxy.addSerializer(ProcedureDataModel[].class, new ProcedureDataModelSerializer()); EnvProxy.addSerializer(ProcedureDataModel[].class, new ProcedureDataModelSerializer());

Loading…
Cancel
Save