Browse Source

merge

master
hzzz 7 years ago
parent
commit
b9b023752e
  1. 178
      designer-base/src/com/fr/design/DesignerEnvManager.java
  2. 38
      designer-base/src/com/fr/design/actions/file/SwitchExistEnv.java
  3. 2
      designer-base/src/com/fr/design/file/HistoryTemplateListPane.java
  4. 55
      designer-base/src/com/fr/design/file/TemplateTreePane.java
  5. 121
      designer-base/src/com/fr/design/mainframe/DesignerFrame.java
  6. 80
      designer-base/src/com/fr/design/mainframe/DesignerFrameFileDealerPane.java
  7. 687
      designer-base/src/com/fr/design/mainframe/TemplatePane.java
  8. 18
      designer-base/src/com/fr/design/mainframe/loghandler/DesignerLogHandler.java
  9. 53
      designer-base/src/com/fr/design/utils/DesignUtils.java
  10. 525
      designer-base/src/com/fr/env/EnvListPane.java
  11. 9
      designer-base/src/com/fr/env/LocalEnvPane.java
  12. 1703
      designer-base/src/com/fr/env/RemoteEnv.java
  13. 5
      designer-base/src/com/fr/env/RemoteEnvPane.java
  14. 62
      designer-base/src/com/fr/env/SignIn.java
  15. 8
      designer-base/src/com/fr/start/server/FRTomcat.java
  16. 6
      designer-realize/src/com/fr/start/Designer4Debug.java

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

@ -4,9 +4,12 @@
package com.fr.design; package com.fr.design;
import com.fr.base.BaseXMLUtils; import com.fr.base.BaseXMLUtils;
import com.fr.base.Env;
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.resource.EnvConfigUtils;
import com.fr.base.env.resource.LocalEnvConfig;
import com.fr.base.env.resource.RemoteEnvConfig;
import com.fr.core.env.EnvConfig;
import com.fr.dav.LocalEnv; import com.fr.dav.LocalEnv;
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;
@ -61,7 +64,6 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
private static final int MAX_SHOW_NUM = 10; private static final int MAX_SHOW_NUM = 10;
private static final String VERSION_80 = "80"; private static final String VERSION_80 = "80";
private static final int CACHINGTEMPLATE_LIMIT = 5;
private static DesignerEnvManager designerEnvManager; // gui. private static DesignerEnvManager designerEnvManager; // gui.
private String activationKey = null; private String activationKey = null;
@ -73,7 +75,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, Env> 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;
@ -100,7 +102,6 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
private int language; private int language;
//2014-8-26默认显示全部, 因为以前的版本, 虽然是false, 实际上是显示所有表, 因此这边要兼容 //2014-8-26默认显示全部, 因为以前的版本, 虽然是false, 实际上是显示所有表, 因此这边要兼容
private boolean useOracleSystemSpace = true; private boolean useOracleSystemSpace = true;
private int cachingTemplateLimit = CACHINGTEMPLATE_LIMIT;
private boolean autoBackUp = true; private boolean autoBackUp = true;
private int undoLimit = 5; private int undoLimit = 5;
private short pageLengthUnit = Constants.UNIT_MM; private short pageLengthUnit = Constants.UNIT_MM;
@ -148,7 +149,6 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
private boolean isHttps = false; private boolean isHttps = false;
private static List<SwingWorker> mapWorkerList = new ArrayList<SwingWorker>(); private static List<SwingWorker> mapWorkerList = new ArrayList<SwingWorker>();
private boolean imageCompress = false;//图片压缩
/** /**
* DesignerEnvManager. * DesignerEnvManager.
@ -194,7 +194,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
if (installHome != null) { if (installHome != null) {
String name = Inter.getLocText("FR-Engine_DEFAULT"); String name = Inter.getLocText("FR-Engine_DEFAULT");
String envPath = StableUtils.pathJoin(new String[]{installHome, ProjectConstants.WEBAPP_NAME, ProjectConstants.WEBINF_NAME}); String envPath = StableUtils.pathJoin(new String[]{installHome, ProjectConstants.WEBAPP_NAME, ProjectConstants.WEBINF_NAME});
designerEnvManager.putEnv(name, LocalEnv.createEnv(envPath)); designerEnvManager.putEnv(name, new LocalEnvConfig(envPath));
designerEnvManager.setCurEnvName(name); designerEnvManager.setCurEnvName(name);
} }
} }
@ -247,8 +247,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
// 写文件的LogLocation // 写文件的LogLocation
String logLocation = DesignerEnvManager.getEnvManager().getLogLocation(); String logLocation = DesignerEnvManager.getEnvManager().getLogLocation();
//Mac下8.0,9.0 选项-日志设置为空时在根目录下检测文件存在会抛无权限,这里应该设个默认值比较好吧 if (logLocation != null) {
if (StringUtils.isNotEmpty(logLocation)) {
try { try {
Calendar calender = GregorianCalendar.getInstance(); Calendar calender = GregorianCalendar.getInstance();
calender.setTimeInMillis(System.currentTimeMillis()); calender.setTimeInMillis(System.currentTimeMillis());
@ -327,7 +326,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
FRContext.getLogger().error(e.getMessage(), e); FRContext.getLogger().error(e.getMessage(), e);
} }
// 清空前一个版本中的工作目录和最近打开 // 清空前一个版本中的工作目录和最近打开
nameEnvMap = new ListMap<String, Env>(); nameEnvMap = new ListMap<String, EnvConfig>();
recentOpenedFilePathList = new ArrayList<String>(); recentOpenedFilePathList = new ArrayList<String>();
curEnvName = null; curEnvName = null;
designerEnvManager.saveXMLFile(); designerEnvManager.saveXMLFile();
@ -474,7 +473,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
* @return 是默认则返回true * @return 是默认则返回true
*/ */
public boolean isCurrentEnvDefault() { public boolean isCurrentEnvDefault() {
Env currentEnv = this.getEnv(curEnvName); EnvConfig currentEnv = this.getEnv(curEnvName);
String defaultEnvPath = StableUtils.pathJoin(new String[]{StableUtils.getInstallHome(), ProjectConstants.WEBAPP_NAME, ProjectConstants.WEBINF_NAME}); String defaultEnvPath = StableUtils.pathJoin(new String[]{StableUtils.getInstallHome(), ProjectConstants.WEBAPP_NAME, ProjectConstants.WEBINF_NAME});
return ComparatorUtils.equals(new File(defaultEnvPath).getPath(), currentEnv.getPath()); return ComparatorUtils.equals(new File(defaultEnvPath).getPath(), currentEnv.getPath());
} }
@ -482,21 +481,19 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
/** /**
* 返回默认环境 * 返回默认环境
*/ */
public Env getDefaultEnv() { public EnvConfig getDefaultEnv() {
String installHome = StableUtils.getInstallHome(); String installHome = StableUtils.getInstallHome();
String defaultenvPath = StableUtils.pathJoin(new String[]{installHome, ProjectConstants.WEBAPP_NAME, ProjectConstants.WEBINF_NAME}); String defaultenvPath = StableUtils.pathJoin(installHome, ProjectConstants.WEBAPP_NAME, ProjectConstants.WEBINF_NAME);
defaultenvPath = new File(defaultenvPath).getPath(); defaultenvPath = new File(defaultenvPath).getPath();
if (nameEnvMap.size() >= 0) { Iterator<Entry<String, EnvConfig>> entryIt = nameEnvMap.entrySet().iterator();
Iterator<Entry<String, Env>> entryIt = nameEnvMap.entrySet().iterator();
while (entryIt.hasNext()) { while (entryIt.hasNext()) {
Entry<String, Env> entry = entryIt.next(); Entry<String, EnvConfig> entry = entryIt.next();
Env env = entry.getValue(); EnvConfig env = entry.getValue();
if (ComparatorUtils.equals(defaultenvPath, env.getPath())) { if (ComparatorUtils.equals(defaultenvPath, env.getPath())) {
return env; return env;
} }
} }
} EnvConfig newDefaultEnv = new LocalEnvConfig(defaultenvPath);
Env newDefaultEnv = LocalEnv.createEnv(defaultenvPath);
this.putEnv(Inter.getLocText(new String[]{"Default", "Utils-Report_Runtime_Env"}), newDefaultEnv); this.putEnv(Inter.getLocText(new String[]{"Default", "Utils-Report_Runtime_Env"}), newDefaultEnv);
return newDefaultEnv; return newDefaultEnv;
} }
@ -509,10 +506,10 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
String defaultenvPath = StableUtils.pathJoin(new String[]{installHome, ProjectConstants.WEBAPP_NAME, ProjectConstants.WEBINF_NAME}); String defaultenvPath = StableUtils.pathJoin(new String[]{installHome, ProjectConstants.WEBAPP_NAME, ProjectConstants.WEBINF_NAME});
defaultenvPath = new File(defaultenvPath).getPath(); defaultenvPath = new File(defaultenvPath).getPath();
if (nameEnvMap.size() >= 0) { if (nameEnvMap.size() >= 0) {
Iterator<Entry<String, Env>> entryIt = nameEnvMap.entrySet().iterator(); Iterator<Entry<String, EnvConfig>> entryIt = nameEnvMap.entrySet().iterator();
while (entryIt.hasNext()) { while (entryIt.hasNext()) {
Entry<String, Env> entry = entryIt.next(); Entry<String, EnvConfig> entry = entryIt.next();
Env env = entry.getValue(); EnvConfig env = entry.getValue();
if (ComparatorUtils.equals(defaultenvPath, env.getPath())) { if (ComparatorUtils.equals(defaultenvPath, env.getPath())) {
return entry.getKey(); return entry.getKey();
} }
@ -635,21 +632,6 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
this.useOracleSystemSpace = displayOracleSystem; this.useOracleSystemSpace = displayOracleSystem;
} }
/**
* 配置最大缓存模板个数
*/
public void setCachingTemplateLimit(int cachingTemplateLimit) {
this.cachingTemplateLimit = cachingTemplateLimit;
}
/**
* 获取最大缓存模板个数
*/
public int getCachingTemplateLimit() {
return this.cachingTemplateLimit;
}
/** /**
* 是否加入产品改良 * 是否加入产品改良
* *
@ -699,7 +681,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
/** /**
* 根据名称返回环境 * 根据名称返回环境
*/ */
public Env getEnv(String name) { public EnvConfig getEnv(String name) {
return this.nameEnvMap.get(name); return this.nameEnvMap.get(name);
} }
@ -709,7 +691,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
* @param name 名称 * @param name 名称
* @param env 对应的环境 * @param env 对应的环境
*/ */
public void putEnv(String name, Env env) { public void putEnv(String name, EnvConfig env) {
this.nameEnvMap.put(name, env); this.nameEnvMap.put(name, env);
} }
@ -1413,16 +1395,14 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
this.setMaxNumberOrPreviewRow(reader.getAttrAsInt("maxNumberOrPreviewRow", 200)); this.setMaxNumberOrPreviewRow(reader.getAttrAsInt("maxNumberOrPreviewRow", 200));
this.setOracleSystemSpace(reader.getAttrAsBoolean("useOracleSystemSpace", true)); this.setOracleSystemSpace(reader.getAttrAsBoolean("useOracleSystemSpace", true));
this.setCachingTemplateLimit(reader.getAttrAsInt("cachingTemplateLimit", CACHINGTEMPLATE_LIMIT));
this.setJoinProductImprove(reader.getAttrAsBoolean("joinProductImprove", true)); this.setJoinProductImprove(reader.getAttrAsBoolean("joinProductImprove", true));
this.setImageCompress(reader.getAttrAsBoolean("imageCompress", true));
this.setAutoBackUp(reader.getAttrAsBoolean("autoBackUp", true)); this.setAutoBackUp(reader.getAttrAsBoolean("autoBackUp", true));
this.setTemplateTreePaneExpanded(reader.getAttrAsBoolean("templateTreePaneExpanded", false)); this.setTemplateTreePaneExpanded(reader.getAttrAsBoolean("templateTreePaneExpanded", false));
// peter:读取webinfLocation // peter:读取webinfLocation
if ((tmpVal = reader.getAttrAsString("webinfLocation", null)) != null) { if ((tmpVal = reader.getAttrAsString("webinfLocation", null)) != null) {
// marks:兼容6.1的 // marks:兼容6.1的
// marks:设置默认的目录. // marks:设置默认的目录.
Env reportServer = LocalEnv.createEnv(tmpVal); EnvConfig reportServer = new LocalEnvConfig(tmpVal);
String curReportServerName = Inter.getLocText("Server-Embedded_Server"); String curReportServerName = Inter.getLocText("Server-Embedded_Server");
this.putEnv(curReportServerName, reportServer); this.putEnv(curReportServerName, reportServer);
@ -1479,7 +1459,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
// marks:获取名字 // marks:获取名字
String reportServerName = reader.getAttrAsString("name", null); String reportServerName = reader.getAttrAsString("name", null);
Env env = readEnv(reader); EnvConfig env = readEnv(reader);
if (env == null) { if (env == null) {
return; return;
} }
@ -1605,7 +1585,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
Iterator<String> nameIt = this.getEnvNameIterator(); Iterator<String> nameIt = this.getEnvNameIterator();
while (nameIt.hasNext()) { while (nameIt.hasNext()) {
String envName = nameIt.next(); String envName = nameIt.next();
Env env = this.getEnv(envName); EnvConfig env = this.getEnv(envName);
writeEnv(writer, envName, env); writeEnv(writer, envName, env);
} }
@ -1635,15 +1615,9 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
if (!this.isOracleSystemSpace()) { if (!this.isOracleSystemSpace()) {
writer.attr("useOracleSystemSpace", this.isOracleSystemSpace()); writer.attr("useOracleSystemSpace", this.isOracleSystemSpace());
} }
if (this.getCachingTemplateLimit() >= 0) {
writer.attr("cachingTemplateLimit", this.getCachingTemplateLimit());
}
if (!this.isJoinProductImprove()) { if (!this.isJoinProductImprove()) {
writer.attr("joinProductImprove", this.isJoinProductImprove()); writer.attr("joinProductImprove", this.isJoinProductImprove());
} }
if (!this.isImageCompress()) {
writer.attr("imageCompress", this.isImageCompress());
}
if (!this.isAutoBackUp()) { if (!this.isAutoBackUp()) {
writer.attr("autoBackUp", this.isAutoBackUp()); writer.attr("autoBackUp", this.isAutoBackUp());
} }
@ -1772,42 +1746,42 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
/* /*
* 写Env为xml * 写Env为xml
*/ */
private static void writeEnv(XMLPrintWriter writer, String name, Env env) { private static void writeEnv(XMLPrintWriter writer, String name, EnvConfig env) {
if (env == null) { if (env == null) {
return; return;
} }
writer.startTAG("Env"); writer.startTAG("EnvConfig");
writer.classAttr(env.getClass()); writer.classAttr(env.getClass());
writer.attr("name", name); writer.attr("name", name);
env.writeXML(writer); EnvConfigXMLAdapter xmlAdapter = env instanceof RemoteEnvConfig
? new RemoteEnvConfigXMLAdapter()
: new LocalEnvConfigXMLAdapter();
xmlAdapter.fromEnvConfig(env).writeXML(writer);
writer.end(); writer.end();
} }
/* /*
* 从xml读Env * 从xml读Env
*/ */
private static Env readEnv(XMLableReader reader) { private static EnvConfig readEnv(XMLableReader reader) {
Env env = null; EnvConfigXMLAdapter xmlAdapter = null;
String tmpVal; //temp value String tmpVal; //temp value
if ((tmpVal = reader.getAttrAsString("class", null)) != null) { if ((tmpVal = reader.getAttrAsString("class", null)) != null) {
if (tmpVal.endsWith(".LocalEnv")) { if (tmpVal.contains(".LocalEnv")) {
env = LocalEnv.createEnv(); xmlAdapter = new LocalEnvConfigXMLAdapter();
} else if (tmpVal.endsWith(".RemoteEnv")) { } else if (tmpVal.contains(".RemoteEnv")) {
env = new RemoteEnv(); xmlAdapter = new RemoteEnvConfigXMLAdapter();
} }
} }
if (env == null) { if (xmlAdapter == null) {
return env; return null;
} }
reader.readXMLObject(env); reader.readXMLObject(xmlAdapter);
return xmlAdapter.toEnvConfig();
return env;
} }
public AlphaFineConfigManager getAlphaFineConfigManager() { public AlphaFineConfigManager getAlphaFineConfigManager() {
@ -1818,11 +1792,77 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
this.alphaFineConfigManager = alphaFineConfigManager; this.alphaFineConfigManager = alphaFineConfigManager;
} }
public boolean isImageCompress() { private interface EnvConfigXMLAdapter extends XMLReadable, XMLWriter {
return imageCompress; 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 setImageCompress(boolean imageCompress) { public void writeXML(XMLPrintWriter writer) {
this.imageCompress = imageCompress; 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;
}
} }
} }

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

@ -3,6 +3,9 @@ package com.fr.design.actions.file;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.base.Env; import com.fr.base.Env;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.base.env.resource.LocalEnvConfig;
import com.fr.base.env.resource.RemoteEnvConfig;
import com.fr.core.env.EnvConfig;
import com.fr.dav.LocalEnv; import com.fr.dav.LocalEnv;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.actions.UpdateAction; import com.fr.design.actions.UpdateAction;
@ -36,9 +39,6 @@ import java.util.logging.Level;
public class SwitchExistEnv extends MenuDef { public class SwitchExistEnv extends MenuDef {
// 标志开始切换环境
private static boolean isSwitching = false;
public SwitchExistEnv() { public SwitchExistEnv() {
this.setMenuKeySet(KeySetUtils.SWITCH_ENV); this.setMenuKeySet(KeySetUtils.SWITCH_ENV);
this.setName(getMenuKeySet().getMenuName()); this.setName(getMenuKeySet().getMenuName());
@ -74,10 +74,10 @@ public class SwitchExistEnv extends MenuDef {
public GetExistEnvAction(String envName) { public GetExistEnvAction(String envName) {
this.setName(envName); this.setName(envName);
Env env = DesignerEnvManager.getEnvManager().getEnv(envName); EnvConfig env = DesignerEnvManager.getEnvManager().getEnv(envName);
if (env instanceof LocalEnv) { if (env instanceof LocalEnvConfig) {
this.setSmallIcon(BaseUtils.readIcon("com/fr/design/images/data/bind/localconnect.png")); this.setSmallIcon(BaseUtils.readIcon("com/fr/design/images/data/bind/localconnect.png"));
} else if (env instanceof RemoteEnv) { } else if (env instanceof RemoteEnvConfig) {
this.setSmallIcon(BaseUtils.readIcon("com/fr/design/images/data/bind/distanceconnect.png")); this.setSmallIcon(BaseUtils.readIcon("com/fr/design/images/data/bind/distanceconnect.png"));
} }
} }
@ -104,35 +104,29 @@ public class SwitchExistEnv extends MenuDef {
* @param e 事件 * @param e 事件
*/ */
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
isSwitching = true;
DesignerEnvManager envManager = DesignerEnvManager.getEnvManager(); DesignerEnvManager envManager = DesignerEnvManager.getEnvManager();
Env selectedEnv = envManager.getEnv(this.getName()); EnvConfig selectedEnv = envManager.getEnv(this.getName());
try { try {
if (selectedEnv instanceof RemoteEnv && !((RemoteEnv) selectedEnv).testServerConnection()) { if (selectedEnv instanceof RemoteEnv && !((RemoteEnv) selectedEnv).testServerConnection()) {
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Inter.getLocText(new String[]{"M-SwitchWorkspace", "Failed"})); JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Inter.getLocText(new String[]{"M-SwitchWorkspace", "Failed"}));
return; return;
} }
String remoteVersion = selectedEnv.getDesignerVersion(); // String remoteVersion = selectedEnv.getDesignerVersion();
if (StringUtils.isBlank(remoteVersion) || ComparatorUtils.compare(remoteVersion, ProductConstants.DESIGNER_VERSION) < 0) { // if (StringUtils.isBlank(remoteVersion) || ComparatorUtils.compare(remoteVersion, ProductConstants.DESIGNER_VERSION) < 0) {
String infor = Inter.getLocText("Server-version-tip"); // String infor = Inter.getLocText("Server-version-tip");
String moreInfo = Inter.getLocText("Server-version-tip-moreInfo"); // String moreInfo = Inter.getLocText("Server-version-tip-moreInfo");
FRLogger.getLogger().log(Level.WARNING, infor); // FRLogger.getLogger().log(Level.WARNING, infor);
new InformationWarnPane(infor, moreInfo, Inter.getLocText("Tooltips")).show(); // new InformationWarnPane(infor, moreInfo, Inter.getLocText("Tooltips")).show();
return; // return;
} // }
SignIn.signIn(selectedEnv); SignIn.signIn(selectedEnv);
HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().refreshToolArea();
fireDSChanged(); fireDSChanged();
} catch (Exception em) { } catch (Exception em) {
FRContext.getLogger().error(em.getMessage(), em); FRContext.getLogger().error(em.getMessage(), em);
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Inter.getLocText(new String[]{"M-SwitchWorkspace", "Failed"})); JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Inter.getLocText(new String[]{"M-SwitchWorkspace", "Failed"}));
TemplatePane.getInstance().editItems(); TemplatePane.getInstance().editItems();
} finally {
isSwitching = false;
} }
} }
} }
public static boolean isSwitching() {
return isSwitching;
}
} }

2
designer-base/src/com/fr/design/file/HistoryTemplateListPane.java

@ -38,7 +38,7 @@ import com.fr.design.utils.gui.GUIPaintUtils;
public class HistoryTemplateListPane extends JPanel implements FileOperations, CallbackEvent { public class HistoryTemplateListPane extends JPanel implements FileOperations, CallbackEvent {
//最大保存内存中面板数,为0时关闭优化内存 //最大保存内存中面板数,为0时关闭优化内存
private static final int DEAD_LINE = DesignerEnvManager.getEnvManager().getCachingTemplateLimit(); private static final int DEAD_LINE = 5;
private static final int LIST_BORDER = 4; private static final int LIST_BORDER = 4;
private List<JTemplate<?, ?>> historyList; private List<JTemplate<?, ?>> historyList;
private JTemplate<?, ?> editingTemplate; private JTemplate<?, ?> editingTemplate;

55
designer-base/src/com/fr/design/file/TemplateTreePane.java

@ -26,7 +26,11 @@ import com.sun.jna.platform.FileUtils;
import javax.swing.*; import javax.swing.*;
import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.DefaultMutableTreeNode;
import java.awt.*; import java.awt.*;
import java.awt.event.*; import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
@ -139,7 +143,7 @@ public class TemplateTreePane extends JPanel implements FileOperations {
public void openContainerFolder() { public void openContainerFolder() {
FileNode fn = TemplateTreePane.this.reportletsTree.getSelectedFileNode(); FileNode fn = TemplateTreePane.this.reportletsTree.getSelectedFileNode();
LocalEnv localEnv = (LocalEnv) FRContext.getCurrentEnv(); LocalEnv localEnv = (LocalEnv) FRContext.getCurrentEnv();
String filePath = StableUtils.pathJoin(new String[]{localEnv.path, fn.getEnvPath()}); String filePath = StableUtils.pathJoin(localEnv.getPath(), fn.getEnvPath());
filePath = filePath.substring(0, filePath.lastIndexOf(CoreConstants.SEPARATOR)); filePath = filePath.substring(0, filePath.lastIndexOf(CoreConstants.SEPARATOR));
try { try {
Desktop.getDesktop().open(new File(filePath)); Desktop.getDesktop().open(new File(filePath));
@ -189,6 +193,16 @@ public class TemplateTreePane extends JPanel implements FileOperations {
reportletsTree.refresh(); reportletsTree.refresh();
} }
@Override
public void lockFile() {
throw new UnsupportedOperationException("unsupport now");
}
@Override
public void unLockFile() {
throw new UnsupportedOperationException("unsupport now");
}
private void deleteHistory(String fileName) { private void deleteHistory(String fileName) {
int index = HistoryTemplateListPane.getInstance().contains(fileName); int index = HistoryTemplateListPane.getInstance().contains(fileName);
int size = HistoryTemplateListPane.getInstance().getHistoryCount(); int size = HistoryTemplateListPane.getInstance().getHistoryCount();
@ -214,41 +228,6 @@ public class TemplateTreePane extends JPanel implements FileOperations {
MutilTempalteTabPane.getInstance().repaint(); MutilTempalteTabPane.getInstance().repaint();
} }
/**
* 加上文件锁
*/
public void lockFile() {
FileNode fn = reportletsTree.getSelectedFileNode();
RemoteEnv remoteEnv = (RemoteEnv) FRContext.getCurrentEnv();
if (fn == null) {
return;
}
try {
remoteEnv.getLock(new String[]{fn.getEnvPath()});
} catch (Exception e) {
FRContext.getLogger().error(e.getMessage(), e);
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), e.getMessage());
}
reportletsTree.refresh();
}
/**
* 文件解锁
*/
public void unLockFile() {
FileNode fn = reportletsTree.getSelectedFileNode();
if (fn == null) {
return;
}
RemoteEnv remoteEnv = (RemoteEnv) FRContext.getCurrentEnv();
try {
remoteEnv.releaseLock(new String[]{fn.getEnvPath()});
} catch (Exception e) {
FRContext.getLogger().error(e.getMessage(), e);
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), e.getMessage());
}
reportletsTree.refresh();
}
public String getSelectedTemplatePath() { public String getSelectedTemplatePath() {
return reportletsTree.getSelectedTemplatePath(); return reportletsTree.getSelectedTemplatePath();
@ -315,6 +294,8 @@ public class TemplateTreePane extends JPanel implements FileOperations {
if (fileUtils.hasTrash()) { if (fileUtils.hasTrash()) {
try { try {
fileUtils.moveToTrash(new File[]{new File(StableUtils.pathJoin(nodeFile.getEnvPath(), nodeFile.getPath()))}); fileUtils.moveToTrash(new File[]{new File(StableUtils.pathJoin(nodeFile.getEnvPath(), nodeFile.getPath()))});
//todo 走下这个流程,否则集群下其它节点无法同步删除
FRContext.getCurrentEnv().deleteFile(nodeFile.getPath());
} catch (IOException e) { } catch (IOException e) {
FRLogger.getLogger().info(e.getMessage()); FRLogger.getLogger().info(e.getMessage());
FRContext.getCurrentEnv().deleteFile(nodeFile.getPath()); FRContext.getCurrentEnv().deleteFile(nodeFile.getPath());

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

@ -6,26 +6,19 @@ package com.fr.design.mainframe;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.base.Env; import com.fr.base.Env;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.base.vcs.DesignerMode; import com.fr.base.env.resource.EnvConfigUtils;
import com.fr.core.env.EnvConfig;
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;
import com.fr.design.ExtraDesignClassManager; import com.fr.design.ExtraDesignClassManager;
import com.fr.design.actions.core.ActionFactory;
import com.fr.design.actions.file.SwitchExistEnv;
import com.fr.design.constants.UIConstants; import com.fr.design.constants.UIConstants;
import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.DesignTableDataManager;
import com.fr.design.data.datapane.TableDataTreePane; import com.fr.design.data.datapane.TableDataTreePane;
import com.fr.design.event.DesignerOpenedListener;
import com.fr.design.event.TargetModifiedEvent; import com.fr.design.event.TargetModifiedEvent;
import com.fr.design.event.TargetModifiedListener; import com.fr.design.event.TargetModifiedListener;
import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.file.*;
import com.fr.design.file.MutilTempalteTabPane;
import com.fr.design.file.NewTemplatePane;
import com.fr.design.file.SaveSomeTemplatePane;
import com.fr.design.file.TemplateTreePane;
import com.fr.design.fun.TitlePlaceProcessor; import com.fr.design.fun.TitlePlaceProcessor;
import com.fr.design.fun.impl.AbstractTemplateTreeShortCutProvider;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.imenu.UIMenuHighLight; import com.fr.design.gui.imenu.UIMenuHighLight;
import com.fr.design.gui.iscrollbar.UIScrollBar; import com.fr.design.gui.iscrollbar.UIScrollBar;
@ -35,7 +28,6 @@ import com.fr.design.mainframe.loghandler.LogMessageBar;
import com.fr.design.mainframe.toolbar.ToolBarMenuDock; import com.fr.design.mainframe.toolbar.ToolBarMenuDock;
import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus; import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus;
import com.fr.design.menu.MenuManager; import com.fr.design.menu.MenuManager;
import com.fr.design.menu.ShortCut;
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.file.FILE; import com.fr.file.FILE;
@ -64,27 +56,14 @@ import javax.swing.border.MatteBorder;
import java.awt.*; import java.awt.*;
import java.awt.datatransfer.DataFlavor; import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable; import java.awt.datatransfer.Transferable;
import java.awt.dnd.DnDConstants; import java.awt.dnd.*;
import java.awt.dnd.DropTarget; import java.awt.event.*;
import java.awt.dnd.DropTargetDragEvent;
import java.awt.dnd.DropTargetDropEvent;
import java.awt.dnd.DropTargetEvent;
import java.awt.dnd.DropTargetListener;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Set;
import java.util.logging.Level; import java.util.logging.Level;
public class DesignerFrame extends JFrame implements JTemplateActionListener, TargetModifiedListener { public class DesignerFrame extends JFrame implements JTemplateActionListener, TargetModifiedListener {
@ -97,12 +76,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
private static final Integer TOP_LAYER = new Integer((200)); private static final Integer TOP_LAYER = new Integer((200));
private static java.util.List<App<?>> appList = new java.util.ArrayList<App<?>>(); private static java.util.List<App<?>> appList = new java.util.ArrayList<App<?>>();
private List<DesignerOpenedListener> designerOpenedListenerList = new ArrayList<>(); private ToolBarMenuDock ad;
//顶部日志+登陆按钮
private static final JPanel northEastPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
private static ToolBarMenuDock ad;
private DesktopCardPane centerTemplateCardPane; private DesktopCardPane centerTemplateCardPane;
@ -186,8 +160,8 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
} }
public void mouseReleased(MouseEvent e) { public void mouseReleased(MouseEvent e) {
if (DesignerMode.isAuthorityEditing()) { if (BaseUtils.isAuthorityEditing()) {
DesignerMode.setMode(DesignerMode.NORMARL); BaseUtils.setAuthorityEditing(false);
WestRegionContainerPane.getInstance().replaceDownPane( WestRegionContainerPane.getInstance().replaceDownPane(
TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter())); TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter()));
HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().refreshEastPropertiesPane(); HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().refreshEastPropertiesPane();
@ -263,7 +237,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
this.addComponentListener(new ComponentAdapter() { this.addComponentListener(new ComponentAdapter() {
public void componentResized(ComponentEvent e) { public void componentResized(ComponentEvent e) {
reCalculateFrameSize(); reCalculateFrameSize();
if (DesignerMode.isAuthorityEditing()) { if (BaseUtils.isAuthorityEditing()) {
doResize(); doResize();
} }
} }
@ -294,22 +268,6 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
} }
} }
/**
* 注册"设计器初始化完成"的监听
*/
public void addDesignerOpenedListener(DesignerOpenedListener listener) {
designerOpenedListenerList.add(listener);
}
/**
* 触发"设计器初始化完成"事件
*/
public void fireDesignerOpened() {
for (DesignerOpenedListener listener : designerOpenedListenerList) {
listener.designerOpened();
}
}
protected DesktopCardPane getCenterTemplateCardPane() { protected DesktopCardPane getCenterTemplateCardPane() {
return centerTemplateCardPane; return centerTemplateCardPane;
} }
@ -320,39 +278,41 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
protected void initMenuPane() { protected void initMenuPane() {
menuPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); menuPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
menuPane.add(new UIMenuHighLight(), BorderLayout.SOUTH); menuPane.add(new UIMenuHighLight(), BorderLayout.SOUTH);
menuPane.add(initNorthEastPane(), BorderLayout.EAST); menuPane.add(initNorthEastPane(ad), BorderLayout.EAST);
basePane.add(menuPane, BorderLayout.NORTH); basePane.add(menuPane, BorderLayout.NORTH);
this.resetToolkitByPlus(null); this.resetToolkitByPlus(null);
} }
/** /**
* @param ad
* @return * @return
*/ */
protected JPanel initNorthEastPane() { protected JPanel initNorthEastPane(final ToolBarMenuDock ad) {
//hugh: private修改为protected方便oem的时候修改右上的组件构成 //hugh: private修改为protected方便oem的时候修改右上的组件构成
//顶部日志+登陆按钮
final JPanel northEastPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
//优先级为-1,保证最后全面刷新一次 //优先级为-1,保证最后全面刷新一次
GeneralContext.listenPluginRunningChanged(new PluginEventListener(-1) { GeneralContext.listenPluginRunningChanged(new PluginEventListener(-1) {
@Override @Override
public void on(PluginEvent event) { public void on(PluginEvent event) {
refreshNorthEastPane(); refreshNorthEastPane(northEastPane, ad);
DesignUtils.refreshDesignerFrame(FRContext.getCurrentEnv()); DesignUtils.refreshDesignerFrame(FRContext.getCurrentEnv());
} }
}, new PluginFilter() { }, new PluginFilter() {
@Override @Override
public boolean accept(PluginContext context) { public boolean accept(PluginContext context) {
return !SwitchExistEnv.isSwitching()
&& context.contain(PluginModule.ExtraDesign); return context.contain(PluginModule.ExtraDesign);
} }
}); });
refreshNorthEastPane(); refreshNorthEastPane(northEastPane, ad);
return northEastPane; return northEastPane;
} }
public static void refreshNorthEastPane() { private void refreshNorthEastPane(JPanel northEastPane, ToolBarMenuDock ad) {
northEastPane.removeAll(); northEastPane.removeAll();
northEastPane.setLayout(new FlowLayout(FlowLayout.RIGHT, 0, 0)); northEastPane.setLayout(new FlowLayout(FlowLayout.RIGHT, 0, 0));
northEastPane.add(LogMessageBar.getInstance()); northEastPane.add(LogMessageBar.getInstance());
@ -457,7 +417,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
* 刷新 * 刷新
*/ */
public void refreshDottedLine() { public void refreshDottedLine() {
if (DesignerMode.isAuthorityEditing()) { if (BaseUtils.isAuthorityEditing()) {
populateAuthorityArea(); populateAuthorityArea();
populateCloseButton(); populateCloseButton();
addDottedLine(); addDottedLine();
@ -516,7 +476,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
for (int i = 0; i < fixButtons.length; i++) { for (int i = 0; i < fixButtons.length; i++) {
combineUp.add(fixButtons[i]); combineUp.add(fixButtons[i]);
} }
if (!DesignerMode.isAuthorityEditing()) { if (!BaseUtils.isAuthorityEditing()) {
combineUp.addSeparator(new Dimension(2, 16)); combineUp.addSeparator(new Dimension(2, 16));
if (toolbar4Form != null) { if (toolbar4Form != null) {
for (int i = 0; i < toolbar4Form.length; i++) { for (int i = 0; i < toolbar4Form.length; i++) {
@ -627,16 +587,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
*/ */
public void needToAddAuhtorityPaint() { public void needToAddAuhtorityPaint() {
newWorkBookPane.setButtonGray(DesignerMode.isAuthorityEditing()); newWorkBookPane.setButtonGray(BaseUtils.isAuthorityEditing());
// 进入或退出权限编辑模式,通知插件
Set<ShortCut> extraShortCuts = ExtraDesignClassManager.getInstance().getExtraShortCuts();
for (ShortCut shortCut : extraShortCuts) {
if (shortCut instanceof AbstractTemplateTreeShortCutProvider) {
((AbstractTemplateTreeShortCutProvider) shortCut).notifyFromAuhtorityChange(DesignerMode.isAuthorityEditing());
}
}
} }
/** /**
@ -660,10 +611,10 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
defaultTitleSB.append(ProductConstants.BRANCH); defaultTitleSB.append(ProductConstants.BRANCH);
// james:标识登录的用户和登录的ENV // james:标识登录的用户和登录的ENV
String envName = DesignerEnvManager.getEnvManager().getCurEnvName(); String envName = DesignerEnvManager.getEnvManager().getCurEnvName();
Env env = DesignerEnvManager.getEnvManager().getEnv(envName); EnvConfig env = DesignerEnvManager.getEnvManager().getEnv(envName);
if (env != null) { if (env != null) {
defaultTitleSB.append(env.getUser()).append('@').append(envName).append('['); defaultTitleSB.append(EnvConfigUtils.getUsername(env)).append('@').append(envName).append('[');
defaultTitleSB.append(env.getEnvDescription()); defaultTitleSB.append(Inter.getLocText("Env-Remote_Server"));
defaultTitleSB.append(']'); defaultTitleSB.append(']');
if (editingTemplate != null) { if (editingTemplate != null) {
String path = editingTemplate.getEditingFILE().getPath(); String path = editingTemplate.getEditingFILE().getPath();
@ -716,16 +667,13 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
* @param env 环境 * @param env 环境
*/ */
public void refreshEnv(Env env) { public void refreshEnv(Env env) {
this.setTitle(); this.setTitle();
DesignerFrameFileDealerPane.getInstance().refreshDockingView(); DesignerFrameFileDealerPane.getInstance().refreshDockingView();
TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter()); TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter());
TemplateTreePane.getInstance().refreshDockingView(); TemplateTreePane.getInstance().refreshDockingView();
DesignTableDataManager.clearGlobalDs(); DesignTableDataManager.clearGlobalDs();
EastRegionContainerPane.getInstance().refreshDownPane(); EastRegionContainerPane.getInstance().refreshDownPane();
JTemplate template = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate();
if (template != null) {
template.refreshToolArea();
}
} }
/** /**
@ -788,8 +736,6 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
* @param jt 添加的模板. * @param jt 添加的模板.
*/ */
public void addAndActivateJTemplate(JTemplate<?, ?> jt) { public void addAndActivateJTemplate(JTemplate<?, ?> jt) {
//释放模板对象
ActionFactory.editorRelease();
if (jt == null || jt.getEditingFILE() == null) { if (jt == null || jt.getEditingFILE() == null) {
return; return;
} }
@ -806,8 +752,6 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
* @param jt 模板 * @param jt 模板
*/ */
public void activateJTemplate(JTemplate<?, ?> jt) { public void activateJTemplate(JTemplate<?, ?> jt) {
//释放模板对象
ActionFactory.editorRelease();
if (jt == null || jt.getEditingFILE() == null) { if (jt == null || jt.getEditingFILE() == null) {
return; return;
} }
@ -913,16 +857,13 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
String fileExtention = fileName.substring(indexOfLastDot + 1); String fileExtention = fileName.substring(indexOfLastDot + 1);
for (int i = 0, len = appList.size(); i < len; i++) { for (int i = 0, len = appList.size(); i < len; i++) {
App<?> app = appList.get(i); App<?> app = appList.get(i);
String[] defaultAppExtentions = app.defaultExtentions(); String[] defaultAppExtentions = app.defaultExtensions();
boolean opened = false; boolean opened = false;
for (int j = 0; j < defaultAppExtentions.length; j++) { for (int j = 0; j < defaultAppExtentions.length; j++) {
if (defaultAppExtentions[j].equalsIgnoreCase(fileExtention)) { if (defaultAppExtentions[j].equalsIgnoreCase(fileExtention)) {
JTemplate jt = null; // 不要catch
try { JTemplate jt = app.openTemplate(tplFile);
jt = app.openTemplate(tplFile);
} catch (Exception e) {
FRLogger.getLogger().error(e.getMessage(), e);
}
if (jt == null) { if (jt == null) {
return; return;
} }
@ -969,6 +910,8 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
} else { } else {
this.addAndActivateJTemplate(jt); this.addAndActivateJTemplate(jt);
} }
//REPORT-5084:激活后刷新一下右側面板
jt.refreshEastPropertiesPane();
} }
/** /**

80
designer-base/src/com/fr/design/mainframe/DesignerFrameFileDealerPane.java

@ -2,7 +2,6 @@ package com.fr.design.mainframe;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.base.vcs.DesignerMode;
import com.fr.design.DesignModelAdapter; import com.fr.design.DesignModelAdapter;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.ExtraDesignClassManager; import com.fr.design.ExtraDesignClassManager;
@ -11,11 +10,7 @@ import com.fr.design.constants.UIConstants;
import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.DesignTableDataManager;
import com.fr.design.data.datapane.TableDataTreePane; import com.fr.design.data.datapane.TableDataTreePane;
import com.fr.design.data.tabledata.ResponseDataSourceChange; import com.fr.design.data.tabledata.ResponseDataSourceChange;
import com.fr.design.file.FileOperations; import com.fr.design.file.*;
import com.fr.design.file.FileToolbarStateChangeListener;
import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.file.MutilTempalteTabPane;
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.gui.imenu.UIMenuHighLight; import com.fr.design.gui.imenu.UIMenuHighLight;
@ -33,6 +28,7 @@ import com.fr.file.FileNodeFILE;
import com.fr.file.filetree.FileNode; import com.fr.file.filetree.FileNode;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.io.utils.ResourceIOUtils;
import com.fr.stable.CoreConstants; import com.fr.stable.CoreConstants;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
import com.fr.stable.project.ProjectConstants; import com.fr.stable.project.ProjectConstants;
@ -46,7 +42,6 @@ import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter; import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent; import java.awt.event.KeyEvent;
import java.io.File; import java.io.File;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
@ -57,11 +52,6 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
private CardLayout card; private CardLayout card;
private JPanel cardPane; private JPanel cardPane;
private java.util.List<FileToolbarStateChangeListener> otherToobarStateChangeListeners= new ArrayList<>();
public FileOperations getSelectedOperation() {
return selectedOperation;
}
private FileOperations selectedOperation; private FileOperations selectedOperation;
private UIToolbar toolBar; private UIToolbar toolBar;
@ -120,7 +110,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
HistoryTemplateListPane.getInstance().setCurrentEditingTemplate(jt); HistoryTemplateListPane.getInstance().setCurrentEditingTemplate(jt);
//处理自动新建的模板 //处理自动新建的模板
MutilTempalteTabPane.getInstance().doWithtemTemplate(); MutilTempalteTabPane.getInstance().doWithtemTemplate();
if (DesignerMode.isAuthorityEditing()) { if (BaseUtils.isAuthorityEditing()) {
RolesAlreadyEditedPane.getInstance().refreshDockingView(); RolesAlreadyEditedPane.getInstance().refreshDockingView();
} }
@ -144,7 +134,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
} }
toolbarDef.addShortCut(delFileAction); toolbarDef.addShortCut(delFileAction);
Set<ShortCut> extraShortCuts = ExtraDesignClassManager.getInstance().getExtraShortCuts(); Set<ShortCut> extraShortCuts = ExtraDesignClassManager.getInstance().getExtraShortCuts();
for (ShortCut shortCut : extraShortCuts) { for (ShortCut shortCut : extraShortCuts){
toolbarDef.addShortCut(shortCut); toolbarDef.addShortCut(shortCut);
} }
@ -171,7 +161,6 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
/** /**
* 响应数据集改变 * 响应数据集改变
*
* @param map 改变名字的数据集 * @param map 改变名字的数据集
*/ */
public void fireDSChanged(Map<String, String> map) { public void fireDSChanged(Map<String, String> map) {
@ -223,21 +212,6 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
public void actionPerformed(ActionEvent evt) { public void actionPerformed(ActionEvent evt) {
selectedOperation.refresh(); selectedOperation.refresh();
stateChange(); stateChange();
}
}
public void addToobarStateChangeListener(FileToolbarStateChangeListener toobarStateChangeListener) {
this.otherToobarStateChangeListeners.add(toobarStateChangeListener);
}
public void removeToobarStateChangeListener(FileToolbarStateChangeListener toobarStateChangeListener) {
this.otherToobarStateChangeListeners.remove(toobarStateChangeListener);
}
private void otherStateChange() {
for (FileToolbarStateChangeListener toobarStateChangeListener : otherToobarStateChangeListeners) {
toobarStateChangeListener.stateChange();
} }
} }
@ -275,38 +249,6 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
} }
} }
/*
* 加锁
*/
private class GetLockAction extends UpdateAction {
public GetLockAction() {
this.setName(Inter.getLocText("FR-Designer_Get_Lock"));
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/control/lock.png"));
}
@Override
public void actionPerformed(ActionEvent evt) {
selectedOperation.lockFile();
}
}
/*
* 解锁
*/
private class ReleaseLockAction extends UpdateAction {
public ReleaseLockAction() {
this.setName(Inter.getLocText("FR-Designer_Release_Lock"));
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/control/unlock.png"));
}
@Override
public void actionPerformed(ActionEvent evt) {
selectedOperation.unLockFile();
}
}
/** /**
* 按钮状态改变 * 按钮状态改变
*/ */
@ -321,8 +263,8 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
openReportAction.setEnabled(false); openReportAction.setEnabled(false);
} }
FileNode node = TemplateTreePane.getInstance().getTemplateFileTree().getSelectedFileNode(); FileNode node = TemplateTreePane.getInstance().getTemplateFileTree().getSelectedFileNode();
if (selectedOperation.getSelectedTemplatePath() != null) { if (selectedOperation.getSelectedTemplatePath() != null){
if (node.getLock() != null && !ComparatorUtils.equals(node.getUserID(), node.getLock())) { if (node.getLock() != null && !ComparatorUtils.equals(node.getUserID(),node.getLock())){
delFileAction.setEnabled(false); delFileAction.setEnabled(false);
} else { } else {
delFileAction.setEnabled(true); delFileAction.setEnabled(true);
@ -355,7 +297,6 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
delFileAction.setEnabled(true); delFileAction.setEnabled(true);
} }
otherStateChange();
} }
/** /**
@ -410,8 +351,8 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
return; return;
} }
final FileNodeFILE nodeFile = new FileNodeFILE(new FileNode(StableUtils.pathJoin(new String[]{ProjectConstants.REPORTLETS_NAME, reportPath}), false)); final FileNodeFILE nodeFile = new FileNodeFILE(new FileNode(StableUtils.pathJoin(ProjectConstants.REPORTLETS_NAME, reportPath), false));
final String path = StableUtils.pathJoin(new String[]{nodeFile.getEnvPath(), nodeFile.getPath()}); final String path = nodeFile.getPath();
oldName = nodeFile.getName(); oldName = nodeFile.getName();
suffix = oldName.substring(oldName.lastIndexOf(CoreConstants.DOT), oldName.length()); suffix = oldName.substring(oldName.lastIndexOf(CoreConstants.DOT), oldName.length());
oldName = oldName.replaceAll(suffix, ""); oldName = oldName.replaceAll(suffix, "");
@ -504,8 +445,9 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
String newPath = path.replace(nodeFile.getName(), userInput + suffix); String newPath = path.replace(nodeFile.getName(), userInput + suffix);
renameTemplateInMemory(nodeFile, userInput + suffix, oldName + suffix); renameTemplateInMemory(nodeFile, userInput + suffix, oldName + suffix);
DesignerEnvManager.getEnvManager().replaceRecentOpenedFilePath(oldPath, newPath.replaceAll("/", "\\\\")); DesignerEnvManager.getEnvManager().replaceRecentOpenedFilePath(oldPath, newPath.replaceAll("/", "\\\\"));
File newFile = new File(newPath);
new File(path).renameTo(newFile); //模版重命名
ResourceIOUtils.renameTo(path, newPath);
selectedOperation.refresh(); selectedOperation.refresh();
DesignerContext.getDesignerFrame().setTitle(); DesignerContext.getDesignerFrame().setTitle();
jd.dispose(); jd.dispose();

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

@ -1,598 +1,279 @@
package com.fr.design.mainframe; package com.fr.design.mainframe;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.base.FRContext; import com.fr.base.Env;
import com.fr.base.vcs.DesignerMode; import com.fr.core.env.EnvConfig;
import com.fr.dav.LocalEnv;
import com.fr.design.DesignModelAdapter; import com.fr.design.DesignModelAdapter;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.ExtraDesignClassManager; import com.fr.design.dialog.BasicDialog;
import com.fr.design.actions.UpdateAction; import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.constants.UIConstants; import com.fr.design.dialog.InformationWarnPane;
import com.fr.design.data.DesignTableDataManager;
import com.fr.design.data.datapane.TableDataTreePane;
import com.fr.design.data.tabledata.ResponseDataSourceChange;
import com.fr.design.file.FileOperations;
import com.fr.design.file.FileToolbarStateChangeListener;
import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.file.MutilTempalteTabPane;
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.gui.imenu.UIMenuHighLight; import com.fr.env.EnvListPane;
import com.fr.design.gui.itextfield.UITextField; import com.fr.env.RemoteEnv;
import com.fr.design.gui.itoolbar.UIToolbar; import com.fr.env.SignIn;
import com.fr.design.gui.itree.filetree.TemplateFileTree;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.menu.KeySetUtils;
import com.fr.design.menu.ShortCut;
import com.fr.design.menu.ToolBarDef;
import com.fr.design.roleAuthority.RolesAlreadyEditedPane;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.file.FILE;
import com.fr.file.FileNodeFILE;
import com.fr.file.filetree.FileNode;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.GeneralContext;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.stable.CoreConstants; import com.fr.stable.EnvChangedListener;
import com.fr.stable.StableUtils; import com.fr.stable.ProductConstants;
import com.fr.stable.project.ProjectConstants; import com.fr.stable.StringUtils;
import javax.swing.*; import javax.swing.*;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
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.awt.event.KeyAdapter; import java.awt.event.MouseEvent;
import java.awt.event.KeyEvent; import java.awt.event.MouseListener;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarStateChangeListener, ResponseDataSourceChange { //TODO: august TemplatePane和TemplateTreePane最好合并成一个类
private static final String FILE = "file"; public class TemplatePane extends JPanel implements MouseListener {
private static DesignerFrameFileDealerPane THIS; private static final long NUM = 1L;
private static int NUM200 = 200;
private CardLayout card; public static TemplatePane getInstance() {
private JPanel cardPane; return HOLDER.singleton;
private java.util.List<FileToolbarStateChangeListener> otherToobarStateChangeListeners= new ArrayList<>();
public FileOperations getSelectedOperation() {
return selectedOperation;
} }
private FileOperations selectedOperation; private static class HOLDER {
private UIToolbar toolBar; private static TemplatePane singleton = new TemplatePane();
}
private OpenReportAction openReportAction = new OpenReportAction();
private RefreshTreeAction refreshTreeAction = new RefreshTreeAction();
private OpenFolderAction openFolderAction = new OpenFolderAction();
private RenameAction renameAction = new RenameAction();
private DelFileAction delFileAction = new DelFileAction();
private static final long serialVersionUID = 2108412478281713143L;
public static final int HEIGHT = 23;// 最好和日志的高度统一 用同一个变量
private static javax.swing.Icon leftIcon = BaseUtils.readIcon("/com/fr/design/images/docking/left.png");
;
private static javax.swing.Icon rightIcon = BaseUtils.readIcon("/com/fr/design/images/docking/right.png");
;
private boolean isExpanded = false;
private UIButton editButton;
private UILabel envLabel;
/** private TemplatePane() {
* 刷新 super();
*/ this.initComponents();
public void refresh() { this.setFocusable(true);
selectedOperation.refresh(); this.addMouseListener(this);
isExpanded = DesignerEnvManager.getEnvManager().isTemplateTreePaneExpanded();
// TemplateTreePane.getInstance().setVisible(isExpanded);
TemplateTreePane.getInstance().setVisible(true);
} }
public static final DesignerFrameFileDealerPane getInstance() { private void initComponents() {
if (THIS == null) { GeneralContext.addEnvChangedListener(new EnvChangedListener() {
THIS = new DesignerFrameFileDealerPane(); public void envChanged() {
setJLabel(DesignerEnvManager.getEnvManager().getCurEnvName());
} }
return THIS; });
} this.setLayout(new BorderLayout(25, 0));
editButton = new UIButton(BaseUtils.readIcon("/com/fr/design/images/control/control-center2.png")) {
private DesignerFrameFileDealerPane() { private static final long serialVersionUID = NUM;
setLayout(new BorderLayout());
toolBar = ToolBarDef.createJToolBar();
toolBar.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, UIConstants.TOOLBAR_BORDER_COLOR));
toolBar.setBorderPainted(true);
JPanel tooBarPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
JPanel parent = new JPanel(new BorderLayout());
parent.add(toolBar, BorderLayout.CENTER);
parent.setBorder(BorderFactory.createEmptyBorder(3, 0, 4, 0));
tooBarPane.add(parent, BorderLayout.CENTER);
tooBarPane.add(new UIMenuHighLight(), BorderLayout.SOUTH);
add(tooBarPane, BorderLayout.NORTH);
cardPane = new JPanel(card = new CardLayout());
cardPane.add(TemplateTreePane.getInstance(), FILE);
selectedOperation = TemplateTreePane.getInstance();
card.show(cardPane, FILE);
TemplateTreePane.getInstance().setToobarStateChangeListener(this);
add(cardPane, BorderLayout.CENTER); @Override
stateChange(); public Point getToolTipLocation(MouseEvent event) {
return new Point(25, 2);
} }
};
editButton.setOpaque(false);
public final void setCurrentEditingTemplate(JTemplate<?, ?> jt) { editButton.setBorder(BorderFactory.createEmptyBorder(2, 0, 0, 10));
DesignModelAdapter.setCurrentModelAdapter(jt == null ? null : jt.getModel()); editButton.setMargin(null);
fireDSChanged(); editButton.setCursor(new Cursor(Cursor.HAND_CURSOR));
TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter()); editButton.setToolTipText(Inter.getLocText("Env-Configure_Workspace"));
HistoryTemplateListPane.getInstance().setCurrentEditingTemplate(jt); this.add(new UILabel(" "), BorderLayout.WEST);
//处理自动新建的模板 this.add(editButton, BorderLayout.EAST);
MutilTempalteTabPane.getInstance().doWithtemTemplate(); editButton.addActionListener(new ActionListener() {
if (DesignerMode.isAuthorityEditing()) { public void actionPerformed(ActionEvent evt) {
RolesAlreadyEditedPane.getInstance().refreshDockingView(); editItems();
} }
});
jt.setComposite(); envLabel = new UILabel();
jt.refreshToolArea(); envLabel.setForeground(new Color(102, 102, 102));
jt.fireJTemplateOpened(); setJLabel(DesignerEnvManager.getEnvManager().getCurEnvName());
jt.requestFocus(); this.add(envLabel, BorderLayout.CENTER);
jt.revert();
FRContext.getLogger().info("\"" + jt.getEditingFILE().getName() + "\"" + Inter.getLocText("LOG-Has_Been_Openned") + "!");
} }
/** /**
* 刷新菜单 * 是否可扩展
* @return 同上
*/ */
public void refreshDockingView() { public boolean IsExpanded() {
ToolBarDef toolbarDef = new ToolBarDef(); return this.isExpanded;
toolbarDef.addShortCut(openReportAction, refreshTreeAction);
if (FRContext.getCurrentEnv().isSupportLocalFileOperate()) {
toolbarDef.addShortCut(openFolderAction, renameAction);
}
toolbarDef.addShortCut(delFileAction);
Set<ShortCut> extraShortCuts = ExtraDesignClassManager.getInstance().getExtraShortCuts();
for (ShortCut shortCut : extraShortCuts) {
toolbarDef.addShortCut(shortCut);
}
toolbarDef.updateToolBar(toolBar);
refreshActions();
} }
public void setExpand(boolean b) {
private void refreshActions() { this.isExpanded = b;
openReportAction.setEnabled(false);
refreshTreeAction.setEnabled(true);
openFolderAction.setEnabled(false);
renameAction.setEnabled(false);
delFileAction.setEnabled(false);
this.repaint(); this.repaint();
} }
/** private boolean envListOkAction(EnvListPane envListPane) {
* 响应数据集改变 String selectedName = envListPane.updateEnvManager();
*/ DesignerEnvManager envManager = DesignerEnvManager.getEnvManager();
public void fireDSChanged() { EnvConfig selectedEnv = envManager.getEnv(selectedName);
fireDSChanged(new HashMap<String, String>()); GeneralContext.fireEnvWillChangeListener();
try {
//如果是远程的还要先测试下,如果失败就不切换
if (selectedEnv instanceof RemoteEnv) {
if (!((RemoteEnv) selectedEnv).testServerConnection()) {
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Inter.getLocText(new String[]{"M-SwitchWorkspace", "Failed"}));
return false;
} else {
// String remoteVersion = selectedEnv.getDesignerVersion();
// 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;
// }
} }
/**
* 响应数据集改变
*
* @param map 改变名字的数据集
*/
public void fireDSChanged(Map<String, String> map) {
DesignTableDataManager.fireDSChanged(map);
} }
SignIn.signIn(selectedEnv);
JTemplate template = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate();
/* if (template != null) {
* Open Report Action template.refreshToolArea();
*/
private class OpenReportAction extends UpdateAction {
public OpenReportAction() {
this.setName(KeySetUtils.OPEN_TEMPLATE.getMenuKeySetName());
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/buttonicon/open.png"));
} }
setJLabel(selectedName);
@Override } catch (Exception e) {
public void actionPerformed(ActionEvent evt) { JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Inter.getLocText(new String[]{"M-SwitchWorkspace", "Failed"}));
selectedOperation.openSelectedReport(); return false;
} }
TemplateTreePane.getInstance().refreshDockingView();
} DesignModelAdapter<?, ?> model = DesignModelAdapter.getCurrentModelAdapter();
if (model != null) {
private class OpenFolderAction extends UpdateAction { model.envChanged();
public OpenFolderAction() {
this.setName(Inter.getLocText("FR-Designer_Show_in_Containing_Folder"));
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_file/view_folder.png"));
}
@Override
public void actionPerformed(ActionEvent evt) {
selectedOperation.openContainerFolder();
} }
return true;
} }
/* /**
* 刷新ReportletsTree * 编辑items
*/ */
private class RefreshTreeAction extends UpdateAction { public void editItems() {
final EnvListPane envListPane = new EnvListPane();
final BasicDialog envListDialog = envListPane.showWindow(SwingUtilities.getWindowAncestor(DesignerContext.getDesignerFrame()));
public RefreshTreeAction() { envListPane.populateEnvManager(envLabel.getText());
this.setName(Inter.getLocText("FR-Designer_Refresh")); envListDialog.addDialogActionListener(new DialogActionAdapter() {
this.setSmallIcon(UIConstants.REFRESH_ICON); public void doOk() {
envListOkAction(envListPane);
} }
@Override public void doCancel() {
public void actionPerformed(ActionEvent evt) { envListDialog.setVisible(false);
selectedOperation.refresh();
stateChange();
} }
});
envListDialog.setVisible(true);
} }
public void addToobarStateChangeListener(FileToolbarStateChangeListener toobarStateChangeListener) { private void setJLabel(String name) {
this.otherToobarStateChangeListeners.add(toobarStateChangeListener); if (DesignerEnvManager.getEnvManager().getEnv(name) instanceof LocalEnv) {
} envLabel.setIcon(BaseUtils.readIcon("com/fr/design/images/data/bind/localconnect.png"));
public void removeToobarStateChangeListener(FileToolbarStateChangeListener toobarStateChangeListener) { } else if (DesignerEnvManager.getEnvManager().getEnv(name) instanceof RemoteEnv) {
this.otherToobarStateChangeListeners.remove(toobarStateChangeListener); envLabel.setIcon(BaseUtils.readIcon("com/fr/design/images/data/bind/distanceconnect.png"));
}
private void otherStateChange() {
for (FileToolbarStateChangeListener toobarStateChangeListener : otherToobarStateChangeListeners) {
toobarStateChangeListener.stateChange();
} }
} envLabel.setText(name);
envLabel.repaint();
/*
* 重命名文件
*/
private class RenameAction extends UpdateAction {
public RenameAction() {
this.setName(Inter.getLocText("FR-Designer_Rename"));
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/data/source/rename.png"));
} }
@Override @Override
public void actionPerformed(ActionEvent evt) { public Dimension getPreferredSize() {
new RenameDialog(); return new Dimension(250, HEIGHT);
MutilTempalteTabPane.getInstance().repaint();
} }
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
paintBackgroundIcon(g);
} }
/* private void paintBackgroundIcon(Graphics g) {
* 删除指定文件 int w = this.getWidth();
*/ int h = this.getHeight();
private class DelFileAction extends UpdateAction { Graphics2D g2d = (Graphics2D) g;
Color lightColor = new Color(226, 230, 234);
Color darkColor = new Color(183, 188, 195);
GradientPaint gp = new GradientPaint(1, 1, lightColor, 1, h - 1, darkColor);
g2d.setPaint(gp);
g2d.fillRect(1, 1, w - 2, h - 1);
g2d.setColor(lightColor);
g2d.drawLine(0, 2, 0, h - 1);
g2d.setColor(darkColor);
g2d.drawLine(w - 1, 2, w - 1, h - 1);
Icon icon = !isExpanded ? leftIcon : rightIcon;
icon.paintIcon(this, g2d, 4, 4);
public DelFileAction() {
this.setName(Inter.getLocText("FR-Designer_Remove"));
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/data/source/delete.png"));
} }
/**
* 鼠标点击
* @param e 事件
*/
@Override @Override
public void actionPerformed(ActionEvent evt) { public void mouseClicked(MouseEvent e) {
selectedOperation.deleteFile();
}
} }
/* /**
* 加锁 * 鼠标按下
* @param e 事件
*/ */
private class GetLockAction extends UpdateAction {
public GetLockAction() {
this.setName(Inter.getLocText("FR-Designer_Get_Lock"));
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/control/lock.png"));
}
@Override @Override
public void actionPerformed(ActionEvent evt) { public void mousePressed(MouseEvent e) {
selectedOperation.lockFile(); if (e.getX() < NUM200) {
isExpanded = !isExpanded;
TemplateTreePane.getInstance().setVisible(isExpanded);
this.setExpand(isExpanded);
DesignerEnvManager.getEnvManager().setTemplateTreePaneExpanded(isExpanded);
} }
} }
/* /**
* 解锁 * 鼠标放开
* @param e 事件
*/ */
private class ReleaseLockAction extends UpdateAction {
public ReleaseLockAction() {
this.setName(Inter.getLocText("FR-Designer_Release_Lock"));
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/control/unlock.png"));
}
@Override @Override
public void actionPerformed(ActionEvent evt) { public void mouseReleased(MouseEvent e) {
selectedOperation.unLockFile();
}
} }
/** /**
* 按钮状态改变 * 鼠标进入
* @param e 事件
*/ */
@Override @Override
public void stateChange() { public void mouseEntered(MouseEvent e) {
//当前环境为远程环境时
if (FRContext.getCurrentEnv() != null) {
if (!FRContext.getCurrentEnv().isSupportLocalFileOperate()) {
if (selectedOperation.getSelectedTemplatePath() != null) {
openReportAction.setEnabled(true);
} else {
openReportAction.setEnabled(false);
}
FileNode node = TemplateTreePane.getInstance().getTemplateFileTree().getSelectedFileNode();
if (selectedOperation.getSelectedTemplatePath() != null) {
if (node.getLock() != null && !ComparatorUtils.equals(node.getUserID(), node.getLock())) {
delFileAction.setEnabled(false);
} else {
delFileAction.setEnabled(true);
}
} else {
delFileAction.setEnabled(false);
}
} else {
//当前环境为本地环境时
if (selectedOperation.getSelectedTemplatePath() != null) {
openReportAction.setEnabled(true);
renameAction.setEnabled(true);
delFileAction.setEnabled(true);
} else {
openReportAction.setEnabled(false);
renameAction.setEnabled(false);
delFileAction.setEnabled(false);
}
openFolderAction.setEnabled(containsFolderNums() + seletedTemplateNums() != 0);
}
refreshTreeAction.setEnabled(true);
}
if (containsFolderNums() > 0 && (containsFolderNums() + seletedTemplateNums() > 1)) {
refreshActions();
} else if (containsFolderNums() == 0 && seletedTemplateNums() > 1) {
openReportAction.setEnabled(false);
refreshTreeAction.setEnabled(true);
openFolderAction.setEnabled(false);
renameAction.setEnabled(false);
delFileAction.setEnabled(true);
}
otherStateChange();
} }
/** /**
* 是否包含文件夹 * 鼠标离开
* * @param e 事件
* @return
*/ */
@Override
private int containsFolderNums() { public void mouseExited(MouseEvent e) {
TemplateFileTree fileTree = TemplateTreePane.getInstance().getTemplateFileTree();
if (fileTree.getSelectionPaths() == null) {
return 0;
}
//选择的包含文件和文件夹的数目
if (fileTree.getSelectionPaths().length == 0) {
return 0;
}
//所有的num减去模板的num,得到文件夹的num
return fileTree.getSelectionPaths().length - fileTree.getSelectedTemplatePaths().length;
} }
/** /**
* 是否选择了多个模板 * 处理异常
*
* @return
*/ */
private int seletedTemplateNums() { public void dealEvnExceptionWhenStartDesigner() {
TemplateFileTree fileTree = TemplateTreePane.getInstance().getTemplateFileTree(); final EnvListPane envListPane = new EnvListPane();
if (fileTree.getSelectionPaths() == null) { envListPane.populateEnvManager(envLabel.getText());
return 0; BasicDialog envListDialog = envListPane.showWindow(SwingUtilities.getWindowAncestor(DesignerContext.getDesignerFrame()));
} envListDialog.addDialogActionListener(new DialogActionAdapter() {
public void doOk() {
return fileTree.getSelectedTemplatePaths().length; if (!envListOkAction(envListPane)) {
} System.exit(0);
// js: 重命名对话框,模仿Eclipse的重命名,支持快捷键F2,Enter,ESC
private class RenameDialog {
private UITextField jt;
private String userInput;
private String oldName;
private UILabel hintsLabel;
private UIButton confirmButton;
private JDialog jd;
private String suffix;
public RenameDialog() {
final String reportPath = selectedOperation.getSelectedTemplatePath();
if (reportPath == null) {
return;
}
final FileNodeFILE nodeFile = new FileNodeFILE(new FileNode(StableUtils.pathJoin(new String[]{ProjectConstants.REPORTLETS_NAME, reportPath}), false));
final String path = StableUtils.pathJoin(new String[]{nodeFile.getEnvPath(), nodeFile.getPath()});
oldName = nodeFile.getName();
suffix = oldName.substring(oldName.lastIndexOf(CoreConstants.DOT), oldName.length());
oldName = oldName.replaceAll(suffix, "");
jd = new JDialog();
jd.setLayout(new GridLayout(2, 2));
jd.setModal(true);
UILabel newNameLabel = new UILabel(Inter.getLocText("FR-Designer_Enter-New-FileName"));
newNameLabel.setMinimumSize(new Dimension(150, 27));
newNameLabel.setHorizontalAlignment(SwingConstants.RIGHT);
jt = new UITextField(oldName);
jt.getDocument().addDocumentListener(getdoDocumentListener());
jt.selectAll();
jt.setPreferredSize(new Dimension(150, 20));
JPanel newNamePanel = new JPanel();
newNamePanel.setLayout(new BoxLayout(newNamePanel, BoxLayout.X_AXIS));
newNamePanel.add(Box.createHorizontalGlue());
newNamePanel.add(newNameLabel);
newNamePanel.add(Box.createHorizontalStrut(5));
jd.add(newNamePanel);
JPanel jtPanel = new JPanel();
jtPanel.setLayout(new BoxLayout(jtPanel, BoxLayout.Y_AXIS));
JPanel containJt = new JPanel(new BorderLayout());
containJt.add(jt, BorderLayout.WEST);
containJt.setMaximumSize(new Dimension(200, 20));
jtPanel.add(Box.createVerticalGlue());
jtPanel.add(containJt);
jtPanel.add(Box.createVerticalGlue());
jd.add(jtPanel);
addUITextFieldListener(nodeFile, path);
hintsLabel = new UILabel();
hintsLabel.setBounds(20, 50, 250, 30);
hintsLabel.setMaximumSize(new Dimension(200, 30));
hintsLabel.setHorizontalAlignment(SwingConstants.RIGHT);
hintsLabel.setForeground(Color.RED);
hintsLabel.setVisible(false);
confirmButton = new UIButton(Inter.getLocText("FR-Designer_Confirm"));
confirmButton.setPreferredSize(new Dimension(80, 25));
confirmButton.setMinimumSize(new Dimension(80, 25));
confirmButton.setMaximumSize(new Dimension(80, 25));
confirmButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
confirmClose(nodeFile, path);
}
});
UIButton cancelButton = new UIButton(Inter.getLocText("FR-Designer_Cancel"));
cancelButton.setPreferredSize(new Dimension(80, 25));
cancelButton.setMinimumSize(new Dimension(80, 25));
cancelButton.setMaximumSize(new Dimension(80, 25));
cancelButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
jd.dispose();
}
});
JPanel hintsPanel = new JPanel();
hintsPanel.setLayout(new BorderLayout());
hintsPanel.add(hintsLabel, BorderLayout.EAST);
jd.add(hintsLabel);
JPanel btPanel = new JPanel(new BorderLayout());
btPanel.setLayout(new BoxLayout(btPanel, BoxLayout.X_AXIS));
btPanel.add(Box.createHorizontalGlue());
btPanel.add(confirmButton);
btPanel.add(Box.createHorizontalStrut(5));
btPanel.add(cancelButton);
btPanel.add(Box.createHorizontalStrut(20));
jd.add(btPanel);
jd.setSize(380, 200);
jd.setTitle(Inter.getLocText("FR-Designer_Rename"));
jd.setResizable(false);
jd.setAlwaysOnTop(true);
jd.setIconImage(BaseUtils.readImage("/com/fr/base/images/oem/logo.png"));
jd.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
GUICoreUtils.centerWindow(jd);
jd.setVisible(true);
}
public void confirmClose(FileNodeFILE nodeFile, String path) {
userInput = userInput == null ? oldName : userInput;
String oldPath = path.replaceAll("/", "\\\\");
String newPath = path.replace(nodeFile.getName(), userInput + suffix);
renameTemplateInMemory(nodeFile, userInput + suffix, oldName + suffix);
DesignerEnvManager.getEnvManager().replaceRecentOpenedFilePath(oldPath, newPath.replaceAll("/", "\\\\"));
File newFile = new File(newPath);
new File(path).renameTo(newFile);
selectedOperation.refresh();
DesignerContext.getDesignerFrame().setTitle();
jd.dispose();
} }
private void renameTemplateInMemory(FILE tplFile, String newName, String oldName) {
JTemplate<?, ?> dPane = getSpecialTemplateByFILE(tplFile);
if (dPane == null) {
return;
}
FILE renameFile = dPane.getEditingFILE();
renameFile.setPath(renameFile.getPath().replace(oldName, newName));
} }
// 增加enter以及esc快捷键的支持 public void doCancel() {
public void addUITextFieldListener(final FileNodeFILE nodeFile, final String path) { System.exit(0);
jt.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
jd.dispose();
}
} }
}); });
envListDialog.setVisible(true);
jt.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
if (confirmButton.isEnabled()) {
confirmClose(nodeFile, path);
}
}
}
});
}
// UITextField的输入监听
public DocumentListener getdoDocumentListener() {
DocumentListener dl = new DocumentListener() {
public void changedUpdate(DocumentEvent e) {
isNameAlreadyExist();
}
public void insertUpdate(DocumentEvent e) {
isNameAlreadyExist();
}
public void removeUpdate(DocumentEvent e) {
isNameAlreadyExist();
}
};
return dl;
}
private void isNameAlreadyExist() {
userInput = jt.getText().trim();
if (selectedOperation.isNameAlreadyExist(userInput, oldName, suffix)) {
jt.selectAll();
// 如果文件名已存在,则灰掉确认按钮
hintsLabel.setText(Inter.getLocText(new String[]{"Utils-File_name", "Already_exists"}, new String[]{userInput}));
hintsLabel.setVisible(true);
confirmButton.setEnabled(false);
} else {
hintsLabel.setVisible(false);
confirmButton.setEnabled(true);
}
}
}
/**
* @param tplFile
* @return 内存中的template重命名一下
*/
private JTemplate<?, ?> getSpecialTemplateByFILE(FILE tplFile) {
HistoryTemplateListPane historyHandle = HistoryTemplateListPane.getInstance();
if (ComparatorUtils.equals(historyHandle.getCurrentEditingTemplate().getEditingFILE(), tplFile)) {
return historyHandle.getCurrentEditingTemplate();
}
for (int i = 0; i < historyHandle.getHistoryCount(); i++) {
if (ComparatorUtils.equals(historyHandle.get(i).getEditingFILE(), tplFile)) {
return historyHandle.get(i);
}
}
return null;
} }
} }

18
designer-base/src/com/fr/design/mainframe/loghandler/DesignerLogHandler.java

@ -1,7 +1,7 @@
package com.fr.design.mainframe.loghandler; package com.fr.design.mainframe.loghandler;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.base.ConfigManager; import com.fr.base.ServerConfig;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.imenu.UIMenuItem; import com.fr.design.gui.imenu.UIMenuItem;
@ -16,23 +16,13 @@ import com.fr.log.LogHandler;
import com.fr.stable.EnvChangedListener; import com.fr.stable.EnvChangedListener;
import com.fr.stable.xml.LogRecordTimeProvider; import com.fr.stable.xml.LogRecordTimeProvider;
import javax.swing.AbstractAction; import javax.swing.*;
import javax.swing.ActionMap;
import javax.swing.InputMap;
import javax.swing.JCheckBoxMenuItem;
import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JTextPane;
import javax.swing.KeyStroke;
import javax.swing.text.BadLocationException; import javax.swing.text.BadLocationException;
import javax.swing.text.DefaultEditorKit; import javax.swing.text.DefaultEditorKit;
import javax.swing.text.Document; import javax.swing.text.Document;
import javax.swing.text.SimpleAttributeSet; import javax.swing.text.SimpleAttributeSet;
import javax.swing.text.StyleConstants; import javax.swing.text.StyleConstants;
import java.awt.BorderLayout; import java.awt.*;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.awt.event.ItemEvent; import java.awt.event.ItemEvent;
@ -130,7 +120,7 @@ public class DesignerLogHandler {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
JPopupMenu showsetPopup = new JPopupMenu(); JPopupMenu showsetPopup = new JPopupMenu();
int logLevelvalue = ConfigManager.getProviderInstance().getServerLogLevel().intValue(); int logLevelvalue = ServerConfig.getInstance().getServerLogLevel().intValue();
if (logLevelvalue <= INFO_INT) { if (logLevelvalue <= INFO_INT) {
showsetPopup.add(showInfo); showsetPopup.add(showInfo);
showsetPopup.add(showError); showsetPopup.add(showError);

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

@ -1,6 +1,12 @@
package com.fr.design.utils; package com.fr.design.utils;
import com.fr.base.*; import com.fr.base.BaseUtils;
import com.fr.base.ServerConfig;
import com.fr.base.Env;
import com.fr.base.EnvException;
import com.fr.base.FRContext;
import com.fr.base.FeedBackInfo;
import com.fr.base.Utils;
import com.fr.base.remote.RemoteDeziConstants; import com.fr.base.remote.RemoteDeziConstants;
import com.fr.dav.DavXMLUtils; import com.fr.dav.DavXMLUtils;
import com.fr.dav.LocalEnv; import com.fr.dav.LocalEnv;
@ -9,18 +15,39 @@ import com.fr.design.ExtraDesignClassManager;
import com.fr.design.fun.DesignerEnvProcessor; import com.fr.design.fun.DesignerEnvProcessor;
import com.fr.design.gui.UILookAndFeel; import com.fr.design.gui.UILookAndFeel;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.DesignerFrame;
import com.fr.env.RemoteEnv; import com.fr.env.RemoteEnv;
import com.fr.file.FileFILE; import com.fr.file.FileFILE;
import com.fr.general.*; import com.fr.general.ComparatorUtils;
import com.fr.general.FRFont;
import com.fr.general.FRLogger;
import com.fr.general.GeneralContext;
import com.fr.general.Inter;
import com.fr.general.http.HttpClient; import com.fr.general.http.HttpClient;
import com.fr.stable.*; import com.fr.stable.ArrayUtils;
import com.fr.stable.CodeUtils;
import com.fr.stable.EncodeConstants;
import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils;
import com.fr.start.StartServer; import com.fr.start.StartServer;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
import java.io.*; import java.io.BufferedReader;
import java.net.*; import java.io.BufferedWriter;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.URI;
import java.net.URLEncoder;
import java.util.Calendar; import java.util.Calendar;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.Locale; import java.util.Locale;
@ -182,7 +209,7 @@ public class DesignUtils {
// 更新CurrentEnv于FRContext & DesignerEnvManager // 更新CurrentEnv于FRContext & DesignerEnvManager
FRContext.setCurrentEnv(env); FRContext.setCurrentEnv(env);
DesignerFrame.refreshNorthEastPane();
refreshDesignerFrame(env); refreshDesignerFrame(env);
// 当换了运行环境,重置服务器,让它下次预览时重启 // 当换了运行环境,重置服务器,让它下次预览时重启
if (env instanceof LocalEnv && !ComparatorUtils.equals(env.getPath(), oldEnvPath)) { if (env instanceof LocalEnv && !ComparatorUtils.equals(env.getPath(), oldEnvPath)) {
@ -282,13 +309,20 @@ public class DesignUtils {
|| ComparatorUtils.equals(defaultLocale, Locale.KOREA); || ComparatorUtils.equals(defaultLocale, Locale.KOREA);
} }
/**
* 访问服务器环境-空参数
*/
public static void visitEnvServer() {
visitEnvServerByParameters(StringUtils.EMPTY, new String[] {}, new String[] {});
}
/** /**
* 访问服务器环境 * 访问服务器环境
* *
* @param names 参数名字 * @param names 参数名字
* @param values 参数值 * @param values 参数值
*/ */
public static void visitEnvServerByParameters(String[] names, String[] values) { public static void visitEnvServerByParameters(String baseRoute, String[] names, String[] values) {
int len = Math.min(ArrayUtils.getLength(names), ArrayUtils.getLength(values)); int len = Math.min(ArrayUtils.getLength(names), ArrayUtils.getLength(values));
String[] segs = new String[len]; String[] segs = new String[len];
for (int i = 0; i < len; i++) { for (int i = 0; i < len; i++) {
@ -319,7 +353,8 @@ public class DesignUtils {
} else { } else {
try { try {
String web = GeneralContext.getCurrentAppNameOfEnv(); String web = GeneralContext.getCurrentAppNameOfEnv();
String url = "http://localhost:" + DesignerEnvManager.getEnvManager().getJettyServerPort() + "/" + web + "/" + ConfigManager.getProviderInstance().getServletMapping() String url = "http://localhost:" + DesignerEnvManager.getEnvManager().getJettyServerPort()
+ "/" + web + "/" + ServerConfig.getInstance().getServletName() + baseRoute
+ postfixOfUri; + postfixOfUri;
StartServer.browserURLWithLocalEnv(url); StartServer.browserURLWithLocalEnv(url);
} catch (Throwable e) { } catch (Throwable e) {

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

@ -1,73 +1,34 @@
package com.fr.env; package com.fr.env;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.File;
import java.util.*;
import javax.swing.BorderFactory;
import com.fr.design.gui.ilable.UILabel;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextPane;
import javax.swing.JToolBar;
import javax.swing.SwingUtilities;
import javax.swing.ToolTipManager;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
import javax.swing.text.AttributeSet;
import javax.swing.text.BadLocationException;
import javax.swing.text.SimpleAttributeSet;
import javax.swing.text.StyleConstants;
import com.fr.base.BaseUtils;
import com.fr.base.Env; import com.fr.base.Env;
import com.fr.base.FRContext; import com.fr.core.env.EnvConfig;
import com.fr.general.NameObject;
import com.fr.dav.LocalEnv; import com.fr.dav.LocalEnv;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.dialog.InformationWarnPane;
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;
import com.fr.design.gui.controlpane.NameableCreator; import com.fr.design.gui.controlpane.NameableCreator;
import com.fr.design.gui.ipasswordfield.UIPassWordField;
import com.fr.design.gui.itree.filetree.JFileTree;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.itextarea.UITextArea;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.scrollruler.ModLineBorder;
import com.fr.file.filter.OnlyShowDirectoryFileFilter;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.general.NameObject;
import com.fr.stable.Nameable; import com.fr.stable.Nameable;
import com.fr.stable.ProductConstants;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.stable.core.PropertyChangeAdapter; import com.fr.stable.core.PropertyChangeAdapter;
import com.fr.third.org.hibernate.boot.jaxb.SourceType;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
/**
* @author yaohwu
*/
public class EnvListPane extends JListControlPane { public class EnvListPane extends JListControlPane {
public EnvListPane() { public EnvListPane() {
super(); super();
addEditingListner(new PropertyChangeAdapter() { addEditingListner(new PropertyChangeAdapter() {
@Override
public void propertyChange() { public void propertyChange() {
String tempName = getEditingName(); String tempName = getEditingName();
String[] allListNames = nameableList.getAllNames(); String[] allListNames = nameableList.getAllNames();
@ -86,7 +47,6 @@ public class EnvListPane extends JListControlPane {
nameableList.stopEditing(); nameableList.stopEditing();
JOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(EnvListPane.this), Inter.getLocText(waning, sign)); JOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(EnvListPane.this), Inter.getLocText(waning, sign));
setWarnigText(editingIndex); setWarnigText(editingIndex);
return;
} }
} }
}); });
@ -97,6 +57,7 @@ public class EnvListPane extends JListControlPane {
* *
* @return 返回添加按钮的NameableCreator * @return 返回添加按钮的NameableCreator
*/ */
@Override
public NameableCreator[] createNameableCreators() { public NameableCreator[] createNameableCreators() {
NameableCreator local = new NameObjectCreator(Inter.getLocText("Env-Local_Directory"), "com/fr/design/images/data/bind/localconnect.png", NameableCreator local = new NameObjectCreator(Inter.getLocText("Env-Local_Directory"), "com/fr/design/images/data/bind/localconnect.png",
LocalEnv.class, LocalEnvPane.class); LocalEnv.class, LocalEnvPane.class);
@ -118,14 +79,13 @@ public class EnvListPane extends JListControlPane {
public void populateEnvManager(String selectedEnv) { public void populateEnvManager(String selectedEnv) {
DesignerEnvManager mgr = DesignerEnvManager.getEnvManager(); DesignerEnvManager mgr = DesignerEnvManager.getEnvManager();
Iterator<String> nameIt = mgr.getEnvNameIterator(); Iterator<String> nameIt = mgr.getEnvNameIterator();
List<NameObject> nameObjectList = new ArrayList<NameObject>(); List<NameObject> nameObjectList = new ArrayList<>();
nameIt.hasNext();
while (nameIt.hasNext()) { while (nameIt.hasNext()) {
String name = nameIt.next(); String name = nameIt.next();
nameObjectList.add(new NameObject(name, mgr.getEnv(name))); nameObjectList.add(new NameObject(name, mgr.getEnv(name)));
} }
this.populate(nameObjectList.toArray(new NameObject[nameObjectList.size()])); this.populate(nameObjectList.toArray(new NameObject[0]));
if (StringUtils.isBlank(selectedEnv)) { if (StringUtils.isBlank(selectedEnv)) {
selectedEnv = mgr.getCurEnvName(); selectedEnv = mgr.getCurEnvName();
@ -143,457 +103,10 @@ public class EnvListPane extends JListControlPane {
DesignerEnvManager mgr = DesignerEnvManager.getEnvManager(); DesignerEnvManager mgr = DesignerEnvManager.getEnvManager();
mgr.clearAllEnv(); mgr.clearAllEnv();
Nameable[] res = this.update(); Nameable[] res = this.update();
NameObject[] envNameObjectArray = new NameObject[res.length]; for (Nameable re : res) {
java.util.Arrays.asList(res).toArray(envNameObjectArray); NameObject nameObject = (NameObject) re;
for (int i = 0; i < envNameObjectArray.length; i++) { mgr.putEnv(nameObject.getName(), (EnvConfig) nameObject.getObject());
NameObject nameObject = envNameObjectArray[i];
mgr.putEnv(nameObject.getName(), (Env) nameObject.getObject());
} }
return this.getSelectedName(); return this.getSelectedName();
} }
public static class LocalEnvPane extends BasicBeanPane<LocalEnv> {
private UITextField pathTextField;
private JFileTree localEnvTree;
public LocalEnvPane() {
this.setLayout(FRGUIPaneFactory.createM_BorderLayout());
// northPane
JPanel northPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
this.add(northPane, BorderLayout.NORTH);
northPane.add(new UILabel(Inter.getLocText("Location") + ":"), BorderLayout.WEST);
northPane.add(pathTextField = new UITextField(), BorderLayout.CENTER);
// 删除选择文件按钮 添加JFileTree
// centerPane
JPanel centerPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
this.add(centerPane, BorderLayout.CENTER);
// 添加JFileTree
localEnvTree = new JFileTree();
JScrollPane localEnvPane = new JScrollPane(localEnvTree);
centerPane.add(localEnvPane, BorderLayout.CENTER);
// 设置根路径File 和 文件过滤类型
localEnvTree.setFileFilter(new OnlyShowDirectoryFileFilter());
localEnvTree.setRootFiles(File.listRoots());
localEnvTree.addTreeSelectionListener(new TreeSelectionListener() {
@Override
public void valueChanged(TreeSelectionEvent e) {
pathTextField.setText(localEnvTree.getSelectedFile().getPath());
}
});
UITextArea description = new UITextArea();
centerPane.add(description, BorderLayout.SOUTH);
description.setText(Inter.getLocText("Env-Des1"));
description.setEditable(false);
}
@Override
protected String title4PopupWindow() {
return Inter.getLocText("Location");
}
@Override
public LocalEnv updateBean() {
String path = pathTextField.getText();
return LocalEnv.createEnv(path);
}
public String getPath() {
return pathTextField.getText();
}
@Override
public void populateBean(LocalEnv ob) {
if (StringUtils.isBlank(ob.getPath())) {
return;
}
pathTextField.setText(ob.getPath());
final File tmpFile = new File(ob.getPath());
localEnvTree.selectFile(tmpFile);
localEnvTree.setEnabled(true);
}
}
public static class RemoteEnvPane extends BasicBeanPane<RemoteEnv> {
public static final int HTTPS_HOST_INDEX = 8;
public static final int HTTP_HOST_INDEX = 7;
private UICheckBox httpsCheckBox = new UICheckBox(Inter.getLocText("FR-Designer_Https_Enable"));
private UITextField servletPathField = new UITextField();
private UITextField hostNameField = new UITextField();
private UITextField portNameField = new UITextField();
private UITextField webApplyField = new UITextField();
private UITextField servletField = new UITextField();
private UITextField userTextField = new UITextField();
private UIPassWordField passwordTextField = new UIPassWordField();
private UITextField certificatePath = new UITextField();
private UIPassWordField certificatePass = new UIPassWordField();
private UIButton chooseDirBtn = new UIButton("...");
private String envPath;
private String hint;
// 各种参数面板
private JPanel northPane;
// 提示面板
private JPanel previewPane;
// 面板的所有组件
private Component[][] coms;
DocumentListener docListener = new DocumentListener() {
@Override
public void changedUpdate(DocumentEvent e) {
showServletPathField(httpsCheckBox.isSelected());
}
@Override
public void insertUpdate(DocumentEvent e) {
showServletPathField(httpsCheckBox.isSelected());
}
@Override
public void removeUpdate(DocumentEvent e) {
showServletPathField(httpsCheckBox.isSelected());
}
};
private void setHttpsState(boolean enable){
chooseDirBtn.setEnabled(enable);
DesignerEnvManager.getEnvManager().setHttps(enable);
}
public RemoteEnvPane() {
this.setBorder(BorderFactory.createTitledBorder(new ModLineBorder(ModLineBorder.TOP), Inter.getLocText("Config_Servlet")));
this.setLayout(FRGUIPaneFactory.createM_BorderLayout());
// 位置
JPanel servletPathPane = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane();
servletPathPane.add(new UILabel(Inter.getLocText("Server_Path") + ":"));
servletPathField.setEditable(false);
hostNameField.getDocument().addDocumentListener(docListener);
portNameField.getDocument().addDocumentListener(docListener);
webApplyField.getDocument().addDocumentListener(docListener);
servletField.getDocument().addDocumentListener(docListener);
// 主机名
JPanel servletNamePane = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane();
servletNamePane.add(new UILabel(Inter.getLocText("Host_Name") + "/IP" + ":"));
// 端口
JPanel portNamePane = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane();
portNamePane.add(new UILabel(Inter.getLocText("Port") + ":"));
// web应用
JPanel webApplyPane = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane();
webApplyPane.add(new UILabel(Inter.getLocText("Web_Apply") + ":"));
// servlet
JPanel servletPane = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane();
servletPane.add(new UILabel("Servlet" + ":"));
// 用户名
JPanel userNamePane = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane();
userNamePane.add(new UILabel(Inter.getLocText("Username") + ":"));
// 密码
JPanel passWordPane = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane();
passWordPane.add(new UILabel(Inter.getLocText("Password") + ":"));
// https证书路径
JPanel certificatePathPane = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane();
certificatePathPane.add(new UILabel(Inter.getLocText("FR-Designer_Certificate_Path")+ ":"));
// https秘钥
JPanel certificatePassPane = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane();
certificatePassPane.add(new UILabel(Inter.getLocText("FR-Designer_Certificate_Pass") + ":"));
//输入密码的时候检测下大写锁定
passwordTextField.addMouseListener(new MouseAdapter() {
public void mouseEntered(MouseEvent e) {
if (java.awt.Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK)) {
hint = Inter.getLocText("CapsLock");
} else {
hint = null;
}
ToolTipManager.sharedInstance().setInitialDelay(100);
passwordTextField.setToolTipText(hint);
}
});
coms = new Component[][]{
new Component[]{initHttpsCheckBoxPane(),new UILabel()},
new Component[]{servletPathPane, initServletNameToolBar()},
new Component[]{servletNamePane, hostNameField},
new Component[]{portNamePane, portNameField},
new Component[]{webApplyPane, webApplyField},
new Component[]{servletPane, servletField},
new Component[]{userNamePane, userTextField},
new Component[]{passWordPane, passwordTextField},
new Component[]{certificatePathPane,initHttpsPane()},
new Component[]{certificatePassPane,certificatePass}
};
setHttpsState(httpsCheckBox.isSelected());
initNorthPane(true);
initCenterPane();
this.add(northPane, BorderLayout.NORTH);
this.add(previewPane, BorderLayout.CENTER);
}
private JToolBar initServletNameToolBar(){
JToolBar servletNameToolBar = new JToolBar();
servletNameToolBar.setFloatable(false);
servletNameToolBar.setLayout(FRGUIPaneFactory.createBorderLayout());
servletNameToolBar.add(this.servletPathField);
UIButton testConnctionButton = new UIButton(BaseUtils.readIcon("/com/fr/design/images/m_web/cache.png"));
testConnctionButton.setToolTipText(Inter.getLocText("Datasource-Test_Connection"));
servletNameToolBar.add(testConnctionButton, BorderLayout.EAST);
testConnctionButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent ev) {
if (testConnection()) {
JOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(RemoteEnvPane.this), Inter.getLocText("Datasource-Connection_successfully"));
}
}
});
return servletNameToolBar;
}
private void initCenterPane(){
// centerPane
previewPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
previewPane.setBorder(BorderFactory.createTitledBorder(new ModLineBorder(ModLineBorder.TOP), Inter.getLocText("Note")));
JTextPane previewTextArea = new JTextPane();
// e:当行的长度大于所分配的宽度时,将换行.
// previewTextArea.setLineWrap(true);
previewTextArea.setEditable(false);
previewTextArea.setText(Inter.getLocText("Env-Des2"));
try {
previewTextArea.getDocument().insertString(previewTextArea.getText().length(), Inter.getLocText("Env_Des"), this.getRedSytleAttribute());
previewTextArea.getDocument().insertString(previewTextArea.getText().length(), "\n" + Inter.getLocText("FR-Designer_Env_Des_Https"), this.getRedSytleAttribute());
} catch (BadLocationException e) {
FRContext.getLogger().error(e.getMessage(), e);
}
previewPane.add(new JScrollPane(previewTextArea), BorderLayout.CENTER);
}
@Override
protected String title4PopupWindow() {
return "Remote";
}
private JPanel initHttpsPane(){
JPanel httpsPane = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane();
httpsPane.setLayout(FRGUIPaneFactory.createBorderLayout());
httpsPane.add(certificatePath,BorderLayout.CENTER);
httpsPane.add(chooseDirBtn, BorderLayout.EAST);
chooseDirBtn.setPreferredSize(new Dimension(25, 25));
chooseDirBtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
JFileChooser fileChooser = new JFileChooser();
fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
int saveValue = fileChooser.showOpenDialog(DesignerContext.getDesignerFrame());
if (saveValue == JFileChooser.APPROVE_OPTION) {
File selectedFile = fileChooser.getSelectedFile();
certificatePath.setText(selectedFile.getAbsolutePath());
}
}
});
return httpsPane;
}
private JPanel initHttpsCheckBoxPane(){
JPanel checkBoxPane = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane();
checkBoxPane.add(httpsCheckBox);
httpsCheckBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
boolean isHttps = httpsCheckBox.isSelected();
DesignerEnvManager manager = DesignerEnvManager.getEnvManager();
manager.setHttps(isHttps);
setHttpsState(isHttps);
updateNorthPane(isHttps);
}
});
return checkBoxPane;
}
private void setHttpsParas(){
System.setProperty("javax.net.ssl.trustStore", this.certificatePath.getText());
System.setProperty("javax.net.ssl.trustStorePassword", new String(this.certificatePass.getPassword()));
DesignerEnvManager manager = DesignerEnvManager.getEnvManager();
manager.setCertificatePath(this.certificatePath.getText());
manager.setCertificatePass(new String(this.certificatePass.getPassword()));
manager.setHttps(this.httpsCheckBox.isSelected());
}
private boolean testConnection() {
RemoteEnv env = new RemoteEnv();
String url = servletPathField.getText();
env.setPath(url);
env.setUser(userTextField.getText());
env.setPassword(new String(passwordTextField.getPassword()));
boolean connect = false;
try {
if (!StringUtils.isBlank(servletPathField.getText().trim())) {
if(url.startsWith("https:") && !this.httpsCheckBox.isSelected()){
JOptionPane.showMessageDialog(this, Inter.getLocText("Datasource-Connection_failed"));
return false;
}
if(url.startsWith("https:")){
setHttpsParas();
}
connect = env.testConnectionWithOutRegisteServer(this);
}
} catch (Exception e) {
JOptionPane.showMessageDialog(this, Inter.getLocText("Datasource-Connection_failed"));
FRContext.getLogger().error(e.getMessage(), e);
}
if (connect) {
try {
String remoteVersion = env.getDesignerVersion();
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;
}
} catch (Exception e) {
FRContext.getLogger().error(e.getMessage(), e);
}
}
return connect;
}
private AttributeSet getRedSytleAttribute() {
SimpleAttributeSet ds = new SimpleAttributeSet();
StyleConstants.setForeground(ds, Color.red);
return ds;
}
/**
* 显示show the content of serverPathFiled
* @param isHttps 是否启用https
*/
public void showServletPathField(boolean isHttps) {
String s = StringUtils.isBlank(webApplyField.getText()) ? "" : "/", t = StringUtils.isBlank(servletField.getText()) ? "" : "/", colon = StringUtils.isBlank(portNameField.getText()) ? ""
: ":";
String prefix = isHttps ? "https://" : "http://";
servletPathField.setText(prefix + hostNameField.getText() + colon + portNameField.getText() + s + webApplyField.getText() + t + servletField.getText());
}
@Override
public void populateBean(RemoteEnv ob) {
envPath = ob.getPath();
boolean isHttps = false;
if(envPath != null){
isHttps = envPath.startsWith("https");
httpsCheckBox.setSelected(isHttps);
setHttpsState(isHttps);
}
updateNorthPane(isHttps);
if (envPath == null || ComparatorUtils.equals(envPath, StringUtils.EMPTY)) {
this.hostNameField.setText(StringUtils.EMPTY);
this.portNameField.setText(StringUtils.EMPTY);
this.webApplyField.setText(StringUtils.EMPTY);
this.servletField.setText(StringUtils.EMPTY);
this.servletPathField.setText(StringUtils.EMPTY);
this.httpsCheckBox.setSelected(false);
} else {
DesignerEnvManager manager = DesignerEnvManager.getEnvManager();
this.certificatePath.setText(manager.getCertificatePath());
this.certificatePass.setText(manager.getCertificatePass());
// 第二次出现":"的地方,port位置起始点
int secondTime = envPath.indexOf(":", envPath.indexOf(":") + 1);
// 第三次出现"/"的地方
int thirdTime = envPath.indexOf("/", secondTime + 1);
// 最后出现"/"的地方
int lastTime = envPath.lastIndexOf("/");
String hostName = isHttps ? envPath.substring(HTTPS_HOST_INDEX, secondTime) : envPath.substring(HTTP_HOST_INDEX, secondTime);
this.hostNameField.setText(hostName);
if (thirdTime < 0) {
this.portNameField.setText(envPath.substring(secondTime + 1));
this.webApplyField.setText(StringUtils.EMPTY);
} else {
this.portNameField.setText(envPath.substring(secondTime + 1, thirdTime));
if (thirdTime == lastTime) {
this.webApplyField.setText(StringUtils.EMPTY);
} else {
this.webApplyField.setText(envPath.substring(thirdTime + 1, lastTime));
}
this.servletField.setText(envPath.substring(lastTime + 1));
}
this.servletPathField.setText(envPath);
}
this.userTextField.setText(ob.getUser() == null ? StringUtils.EMPTY : ob.getUser());
this.passwordTextField.setText(ob.getPassword() == null ? StringUtils.EMPTY : ob.getPassword());
}
private void initNorthPane(boolean isHttps){
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double[] rowSize;
double[] size = {p,p,p,p,p,p,p,p};
double[] httpsSize = {p,p,p,p,p,p,p,p,p,p};
if(isHttps){
rowSize = httpsSize;
}else{
rowSize = size;
}
double[] columnSize = {p, f};
northPane = TableLayoutHelper.createTableLayoutPane(coms, rowSize, columnSize);
}
private void updateNorthPane(boolean isHttps){
this.removeAll();
initNorthPane(isHttps);
this.add(northPane, BorderLayout.NORTH);
this.add(previewPane,BorderLayout.CENTER);
this.revalidate();
this.doLayout();
this.repaint();
}
@Override
public RemoteEnv updateBean() {
String hostName = this.hostNameField.getText();
// String port = this.portNameField.getText();
String webApply = this.webApplyField.getText();
String servlet = this.servletField.getText();
String path = this.servletPathField.getText();
String user = this.userTextField.getText();
String password = new String(this.passwordTextField.getPassword());
if (isAllEmpty(new String[]{hostName, webApply, servlet})) {
path = StringUtils.EMPTY;
}
return new RemoteEnv(path, user, password);
}
private boolean isAllEmpty(String[] strs) {
for (int i = 0; i < strs.length; i++) {
if (StringUtils.isNotEmpty(strs[i])) {
return false;
}
}
return true;
}
}
public static void main(String[] args) {
Byte[] a = new Byte[1];
System.out.println(a.getClass());
}
} }

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

@ -1,5 +1,6 @@
package com.fr.env; package com.fr.env;
import com.fr.base.env.resource.LocalEnvConfig;
import com.fr.dav.LocalEnv; import com.fr.dav.LocalEnv;
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;
@ -21,7 +22,7 @@ import java.io.File;
/** /**
* @author yaohwu * @author yaohwu
*/ */
public class LocalEnvPane extends BasicBeanPane<LocalEnv> { public class LocalEnvPane extends BasicBeanPane<LocalEnvConfig> {
private UITextField pathTextField; private UITextField pathTextField;
private JFileTree localEnvTree; private JFileTree localEnvTree;
@ -70,9 +71,9 @@ public class LocalEnvPane extends BasicBeanPane<LocalEnv> {
} }
@Override @Override
public LocalEnv updateBean() { public LocalEnvConfig updateBean() {
String path = pathTextField.getText(); String path = pathTextField.getText();
return LocalEnv.createEnv(path); return new LocalEnvConfig(path);
} }
public String getPath() { public String getPath() {
@ -80,7 +81,7 @@ public class LocalEnvPane extends BasicBeanPane<LocalEnv> {
} }
@Override @Override
public void populateBean(LocalEnv ob) { public void populateBean(LocalEnvConfig ob) {
if (StringUtils.isBlank(ob.getPath())) { if (StringUtils.isBlank(ob.getPath())) {
return; return;
} }

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

File diff suppressed because it is too large Load Diff

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

@ -465,11 +465,8 @@ public class RemoteEnvPane extends BasicBeanPane<RemoteEnv> {
} }
private boolean testConnection() { private boolean testConnection() {
RemoteEnv env = new RemoteEnv();
String url = remoteEnvURL.getURL(); String url = remoteEnvURL.getURL();
env.setPath(url); RemoteEnv env = new RemoteEnv(url, usernameInput.getText(), new String(passwordInput.getPassword()));
env.setUser(usernameInput.getText());
env.setPassword(new String(passwordInput.getPassword()));
boolean connect = false; boolean connect = false;
try { try {
if (StringUtils.isNotEmpty(url)) { if (StringUtils.isNotEmpty(url)) {

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

@ -1,43 +1,61 @@
package com.fr.env; package com.fr.env;
import com.fr.base.Env;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.base.env.EnvContext;
import com.fr.base.env.resource.EnvConfigUtils;
import com.fr.base.env.resource.RemoteEnvConfig;
import com.fr.core.env.EnvConfig;
import com.fr.core.env.EnvEvents;
import com.fr.dav.LocalEnv;
import com.fr.design.utils.DesignUtils; import com.fr.design.utils.DesignUtils;
import com.fr.event.Event;
import com.fr.event.EventDispatcher;
import com.fr.event.Listener;
import com.fr.event.Null;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.env.EnvContext; import com.fr.general.Inter;
import javax.swing.JOptionPane;
import javax.swing.UIManager;
public class SignIn { public class SignIn {
public static Env lastSelectedEnv;// 记录最后登录的Env
static {
EventDispatcher.listen(EnvEvents.CONNECTION_ERROR, new Listener<Null>() {
@Override
public void on(Event<Null> event, Null param) {
if (JOptionPane.showConfirmDialog(null, Inter.getLocText("FR-Remote_Connect2Server_Again"), UIManager.getString("OptionPane.titleText"), JOptionPane.YES_NO_OPTION)
== JOptionPane.OK_OPTION) {
try {
EnvContext.signIn(EnvContext.currentEnv());
} catch (Exception e) {
FRContext.getLogger().error(e.getMessage());
}
}
}
});
}
/** /**
* 注册入环境 * 注册入环境
* @param selectedEnv 选择的环境 * @param selectedEnv 选择的环境
* @throws Exception 异常 * @throws Exception 异常
*/ */
public static void signIn(Env selectedEnv) throws Exception { public static void signIn(EnvConfig selectedEnv) throws Exception {
boolean validServer; if (EnvContext.currentEnv() != null && !ComparatorUtils.equals(EnvContext.currentEnv(), selectedEnv)) {
signOutOldEnv(selectedEnv); EnvContext.signOut();
selectedEnv.signIn();
validServer = true;
if (validServer) {
DesignUtils.switchToEnv(selectedEnv);
lastSelectedEnv = selectedEnv;
} }
EnvContext.signIn(selectedEnv);
DesignUtils.switchToEnv(trans(selectedEnv));
} }
private static void signOutOldEnv(Env newEnv) { private static com.fr.base.Env trans(EnvConfig env) {
// 环境相同直接返回,避免浪费过多时间 if (env instanceof RemoteEnvConfig) {
if (lastSelectedEnv == null || ComparatorUtils.equals(lastSelectedEnv, newEnv)) { return new RemoteEnv(env.getPath(), EnvConfigUtils.getUsername(env), EnvConfigUtils.getPassword(env));
return; } else {
} return new LocalEnv();
try {
EnvContext.fireBeforeSignOut();
lastSelectedEnv.signOut();
EnvContext.fireAfterSignOut();
} catch (Exception e) {
FRContext.getLogger().error(e.getMessage(), e);
} }
} }
} }

8
designer-base/src/com/fr/start/server/FRTomcat.java

@ -20,9 +20,9 @@ public class FRTomcat extends Tomcat{
public Context addWebapp(String contextPath, String docBase) throws ServletException { public Context addWebapp(String contextPath, String docBase) throws ServletException {
silence(host, contextPath); silence(getHost(), contextPath);
Context ctx = createContext(host, contextPath); Context ctx = createContext(getHost(), contextPath);
if (ctx instanceof StandardContext) { if (ctx instanceof StandardContext) {
((StandardContext)ctx).setDelegate(true); ((StandardContext)ctx).setDelegate(true);
} }
@ -37,10 +37,10 @@ public class FRTomcat extends Tomcat{
ctxCfg.setDefaultWebXml(noDefaultWebXmlPath()); ctxCfg.setDefaultWebXml(noDefaultWebXmlPath());
if (host == null) { if (getHost() == null) {
getHost().addChild(ctx); getHost().addChild(ctx);
} else { } else {
host.addChild(ctx); getHost().addChild(ctx);
} }
return ctx; return ctx;

6
designer-realize/src/com/fr/start/Designer4Debug.java

@ -5,7 +5,7 @@ package com.fr.start;
*/ */
public class Designer4Debug { public class Designer4Debug {
public static void main(String... args) { // public static void main(String... args) {
org.swingexplorer.Launcher.main(new String[]{"com.fr.start.Designer"}); // org.swingexplorer.Launcher.main(new String[]{"com.fr.start.Designer"});
} // }
} }

Loading…
Cancel
Save