Browse Source

Merge pull request #132 in DESIGN/design from ~JU/design:feature/10.0 to feature/10.0

* commit '5546bb4461b45793baf34ac4ff000383f7464515':
  fix
  fix
  f
  f
  f
  f
  f
  f
  f
  f
  f
  f
  f
  f
  auth
  f
  f
  f
  REPORT-8790 改动太多了,先commit一次
  REPORT-8790 改动太多了,先commit一次
master
richie 6 years ago
parent
commit
dc86837640
  1. 13
      designer-base/src/com/fr/design/DesignState.java
  2. 72
      designer-base/src/com/fr/design/DesignerEnvManager.java
  3. 39
      designer-base/src/com/fr/design/actions/file/LocalePane.java
  4. 29
      designer-base/src/com/fr/design/actions/file/SwitchExistEnv.java
  5. 3
      designer-base/src/com/fr/design/actions/help/alphafine/AlphaFineConfigManager.java
  6. 3
      designer-base/src/com/fr/design/data/BasicTableDataTreePane.java
  7. 4
      designer-base/src/com/fr/design/data/datapane/ChoosePane.java
  8. 3
      designer-base/src/com/fr/design/data/datapane/connect/ConnectionComboBoxPanel.java
  9. 2
      designer-base/src/com/fr/design/data/datapane/connect/ConnectionManagerPane.java
  10. 12
      designer-base/src/com/fr/design/data/datapane/preview/PreviewTableModel.java
  11. 16
      designer-base/src/com/fr/design/data/tabledata/tabledatapane/ClassNameSelectPane.java
  12. 2
      designer-base/src/com/fr/design/data/tabledata/tabledatapane/ProcedureManagerPane.java
  13. 2
      designer-base/src/com/fr/design/data/tabledata/tabledatapane/TableDataManagerPane.java
  14. 6
      designer-base/src/com/fr/design/data/tabledata/wrapper/StoreProcedureNameWrapper.java
  15. 32
      designer-base/src/com/fr/design/env/DesignerWorkspaceGenerator.java
  16. 14
      designer-base/src/com/fr/design/env/DesignerWorkspaceInfo.java
  17. 10
      designer-base/src/com/fr/design/env/DesignerWorkspaceType.java
  18. 22
      designer-base/src/com/fr/design/env/EnvGenerator.java
  19. 68
      designer-base/src/com/fr/design/env/LocalDesignerWorkspaceInfo.java
  20. 81
      designer-base/src/com/fr/design/env/RemoteDesignerWorkspaceInfo.java
  21. 134
      designer-base/src/com/fr/design/env/RemoteEnvConfig.java
  22. 74
      designer-base/src/com/fr/design/env/RemoteWorkspace.java
  23. 4
      designer-base/src/com/fr/design/extra/WebViewDlgHelper.java
  24. 8
      designer-base/src/com/fr/design/file/HistoryTemplateListPane.java
  25. 12
      designer-base/src/com/fr/design/file/TemplateTreePane.java
  26. 6
      designer-base/src/com/fr/design/formula/FunctionManagerPane.java
  27. 10
      designer-base/src/com/fr/design/formula/JavaEditorPane.java
  28. 25
      designer-base/src/com/fr/design/gui/controlpane/JListControlPane.java
  29. 8
      designer-base/src/com/fr/design/gui/itree/filetree/EnvFileTree.java
  30. 18
      designer-base/src/com/fr/design/gui/itree/filetree/FileNodeComparator.java
  31. 16
      designer-base/src/com/fr/design/gui/itree/filetree/FileTreeIcon.java
  32. 29
      designer-base/src/com/fr/design/gui/itree/filetree/ReportletPane.java
  33. 8
      designer-base/src/com/fr/design/gui/itree/filetree/TemplateFileTree.java
  34. 57
      designer-base/src/com/fr/design/mainframe/DesignerFrame.java
  35. 73
      designer-base/src/com/fr/design/mainframe/DesignerFrameFileDealerPane.java
  36. 31
      designer-base/src/com/fr/design/mainframe/JTemplate.java
  37. 83
      designer-base/src/com/fr/design/mainframe/TemplatePane.java
  38. 53
      designer-base/src/com/fr/design/mainframe/loghandler/socketio/DesignerSocketIO.java
  39. 7
      designer-base/src/com/fr/design/mainframe/templateinfo/TemplateInfoCollector.java
  40. 26
      designer-base/src/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java
  41. 2
      designer-base/src/com/fr/design/parameter/ParameterManagerPane.java
  42. 16
      designer-base/src/com/fr/design/remote/action/RemoteDesignAuthorityManagerAction.java
  43. 7
      designer-base/src/com/fr/design/remote/ui/AuthorityEditorPane.java
  44. 8
      designer-base/src/com/fr/design/remote/ui/UserManagerPane.java
  45. 2
      designer-base/src/com/fr/design/roleAuthority/RoleDataWrapper.java
  46. 17
      designer-base/src/com/fr/design/utils/DesignUtils.java
  47. 8
      designer-base/src/com/fr/design/widget/IconDefinePane.java
  48. 19
      designer-base/src/com/fr/env/EnvListPane.java
  49. 10
      designer-base/src/com/fr/env/LocalEnvPane.java
  50. 1545
      designer-base/src/com/fr/env/RemoteEnv.java
  51. 176
      designer-base/src/com/fr/env/RemoteEnvPane.java
  52. 370
      designer-base/src/com/fr/env/RemoteEnvPane2.java
  53. 334
      designer-base/src/com/fr/env/RemoteEnvUtils.java
  54. 46
      designer-base/src/com/fr/env/SignIn.java
  55. 20
      designer-base/src/com/fr/file/FILEChooserPane.java
  56. 8
      designer-base/src/com/fr/file/FILEFactory.java
  57. 30
      designer-base/src/com/fr/file/FileNodeFILE.java
  58. 12
      designer-base/src/com/fr/start/ServerStarter.java
  59. 6
      designer-base/src/com/fr/start/server/FineEmbedServerActivator.java
  60. 11
      designer-chart/src/com/fr/design/chart/series/PlotSeries/MapGroupExtensionPane.java
  61. 18
      designer-chart/src/com/fr/van/chart/DownloadOnlineSourcesHelper.java
  62. 6
      designer-chart/src/com/fr/van/chart/map/server/ChartMapEditorAction.java
  63. 2
      designer-form/src/com/fr/design/parameter/FormParameterReader.java
  64. 2
      designer-realize/src/com/fr/design/actions/server/StyleManagerPane.java
  65. 3
      designer-realize/src/com/fr/design/mainframe/AuthorityToolBarPane.java
  66. 6
      designer-realize/src/com/fr/design/mainframe/JWorkBook.java
  67. 8
      designer-realize/src/com/fr/design/mainframe/alphafine/cell/model/PluginModel.java
  68. 7
      designer-realize/src/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java
  69. 31
      designer-realize/src/com/fr/design/mainframe/alphafine/search/manager/impl/FileSearchManager.java
  70. 4
      designer-realize/src/com/fr/design/mainframe/errorinfo/ErrorInfoLogAppender.java
  71. 2
      designer-realize/src/com/fr/design/parameter/WorkBookParameterReader.java
  72. 20
      designer-realize/src/com/fr/design/report/freeze/RepeatAndFreezeSettingPane.java
  73. 16
      designer-realize/src/com/fr/design/report/share/ShareButton.java
  74. 2
      designer-realize/src/com/fr/design/webattr/EditReportServerParameterPane.java
  75. 2
      designer-realize/src/com/fr/design/webattr/WidgetManagerPane.java
  76. 23
      designer-realize/src/com/fr/start/Designer.java
  77. 19
      designer-realize/src/com/fr/start/EnvSwitcher.java
  78. 234
      designer-realize/src/com/fr/start/module/DesignerEnvProvider.java
  79. 14
      designer-realize/src/com/fr/start/module/DesignerStartup.java
  80. 41
      designer-realize/src/com/fr/start/module/DesignerWorkspaceProvider.java

13
designer-base/src/com/fr/design/DesignState.java

@ -1,10 +1,8 @@
package com.fr.design; package com.fr.design;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.base.Env;
import com.fr.base.FRContext;
import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus; import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus;
import com.fr.env.RemoteEnv; import com.fr.workspace.WorkContext;
/** /**
* Created by IntelliJ IDEA. * Created by IntelliJ IDEA.
@ -41,11 +39,10 @@ public class DesignState {
public DesignState(ToolBarMenuDockPlus plus) { public DesignState(ToolBarMenuDockPlus plus) {
designState = plus.getMenuState(); designState = plus.getMenuState();
Env env = FRContext.getCurrentEnv(); // if (WorkContext.getCurrent().isLocal()) {
if (env != null && env instanceof RemoteEnv) { // designState += REMOTE;
designState += REMOTE; // }
} // isRoot = env != null && env.isRoot();
isRoot = env != null && env.isRoot();
isAuthority = BaseUtils.isAuthorityEditing(); isAuthority = BaseUtils.isAuthorityEditing();
} }

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

@ -6,12 +6,13 @@ package com.fr.design;
import com.fr.base.BaseXMLUtils; import com.fr.base.BaseXMLUtils;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.base.Utils; import com.fr.base.Utils;
import com.fr.base.env.EnvUpdater;
import com.fr.core.env.EnvConfig;
import com.fr.core.env.impl.LocalEnvConfig;
import com.fr.design.actions.help.alphafine.AlphaFineConfigManager; import com.fr.design.actions.help.alphafine.AlphaFineConfigManager;
import com.fr.design.constants.UIConstants; import com.fr.design.constants.UIConstants;
import com.fr.design.env.EnvGenerator; import com.fr.design.env.DesignerWorkspaceGenerator;
import com.fr.design.env.DesignerWorkspaceInfo;
import com.fr.design.env.DesignerWorkspaceType;
import com.fr.design.env.LocalDesignerWorkspaceInfo;
import com.fr.design.env.RemoteDesignerWorkspaceInfo;
import com.fr.file.FILEFactory; import com.fr.file.FILEFactory;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.FRLogFormatter; import com.fr.general.FRLogFormatter;
@ -33,6 +34,7 @@ import com.fr.stable.xml.XMLReadable;
import com.fr.stable.xml.XMLTools; import com.fr.stable.xml.XMLTools;
import com.fr.stable.xml.XMLWriter; import com.fr.stable.xml.XMLWriter;
import com.fr.stable.xml.XMLableReader; import com.fr.stable.xml.XMLableReader;
import com.fr.workspace.WorkContext;
import javax.swing.*; import javax.swing.*;
import javax.swing.SwingWorker.StateValue; import javax.swing.SwingWorker.StateValue;
@ -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, EnvConfig> nameEnvMap = new ListMap<>(); private Map<String, DesignerWorkspaceInfo> nameEnvMap = new ListMap<>();
// marks: 当前报表服务器名字 // marks: 当前报表服务器名字
private String curEnvName = null; private String curEnvName = null;
private boolean showProjectPane = true; private boolean showProjectPane = true;
@ -191,10 +193,10 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
return; return;
} }
String installHome = StableUtils.getInstallHome(); String installHome = StableUtils.getInstallHome();
if (installHome != null) { if (installHome != null && !".".equals(installHome)) {
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(installHome, ProjectConstants.WEBAPP_NAME, ProjectConstants.WEBINF_NAME);
designerEnvManager.putEnv(name, new LocalEnvConfig(envPath)); designerEnvManager.putEnv(name, LocalDesignerWorkspaceInfo.create(name, envPath));
designerEnvManager.setCurEnvName(name); designerEnvManager.setCurEnvName(name);
} }
} }
@ -327,7 +329,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
FRContext.getLogger().error(e.getMessage(), e); FRContext.getLogger().error(e.getMessage(), e);
} }
// 清空前一个版本中的工作目录和最近打开 // 清空前一个版本中的工作目录和最近打开
nameEnvMap = new ListMap<String, EnvConfig>(); nameEnvMap = new ListMap<String, DesignerWorkspaceInfo>();
recentOpenedFilePathList = new ArrayList<String>(); recentOpenedFilePathList = new ArrayList<String>();
curEnvName = null; curEnvName = null;
designerEnvManager.saveXMLFile(); designerEnvManager.saveXMLFile();
@ -474,28 +476,30 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
* @return 是默认则返回true * @return 是默认则返回true
*/ */
public boolean isCurrentEnvDefault() { public boolean isCurrentEnvDefault() {
EnvConfig currentEnv = this.getEnv(curEnvName);
DesignerWorkspaceInfo current = this.getWorkspaceInfo(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(), current.getPath());
} }
/** /**
* 返回默认环境 * 返回默认环境
*/ */
public EnvConfig getDefaultEnv() { public DesignerWorkspaceInfo getDefaultConfig() {
String installHome = StableUtils.getInstallHome(); String installHome = StableUtils.getInstallHome();
String defaultenvPath = StableUtils.pathJoin(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();
Iterator<Entry<String, EnvConfig>> entryIt = nameEnvMap.entrySet().iterator(); Iterator<Entry<String, DesignerWorkspaceInfo>> entryIt = nameEnvMap.entrySet().iterator();
while (entryIt.hasNext()) { while (entryIt.hasNext()) {
Entry<String, EnvConfig> entry = entryIt.next(); Entry<String, DesignerWorkspaceInfo> entry = entryIt.next();
EnvConfig env = entry.getValue(); DesignerWorkspaceInfo env = entry.getValue();
if (ComparatorUtils.equals(defaultenvPath, env.getPath())) { if (ComparatorUtils.equals(defaultenvPath, env.getPath())) {
return env; return env;
} }
} }
EnvConfig newDefaultEnv = new LocalEnvConfig(defaultenvPath); String name = Inter.getLocText(new String[]{"Default", "Utils-Report_Runtime_Env"});
this.putEnv(Inter.getLocText(new String[]{"Default", "Utils-Report_Runtime_Env"}), newDefaultEnv); LocalDesignerWorkspaceInfo newDefaultEnv = LocalDesignerWorkspaceInfo.create(name, defaultenvPath);
this.putEnv(name, newDefaultEnv);
return newDefaultEnv; return newDefaultEnv;
} }
@ -507,10 +511,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, EnvConfig>> entryIt = nameEnvMap.entrySet().iterator(); Iterator<Entry<String, DesignerWorkspaceInfo>> entryIt = nameEnvMap.entrySet().iterator();
while (entryIt.hasNext()) { while (entryIt.hasNext()) {
Entry<String, EnvConfig> entry = entryIt.next(); Entry<String, DesignerWorkspaceInfo> entry = entryIt.next();
EnvConfig env = entry.getValue(); DesignerWorkspaceInfo env = entry.getValue();
if (ComparatorUtils.equals(defaultenvPath, env.getPath())) { if (ComparatorUtils.equals(defaultenvPath, env.getPath())) {
return entry.getKey(); return entry.getKey();
} }
@ -526,7 +530,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
if (isCurrentEnvDefault()) { if (isCurrentEnvDefault()) {
return; return;
} }
EnvUpdater.updateEnv(EnvGenerator.generate(getDefaultEnv())); WorkContext.switchTo(DesignerWorkspaceGenerator.generate(getDefaultConfig()));
} }
/** /**
@ -693,7 +697,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
/** /**
* 根据名称返回环境 * 根据名称返回环境
*/ */
public EnvConfig getEnv(String name) { public DesignerWorkspaceInfo getWorkspaceInfo(String name) {
return this.nameEnvMap.get(name); return this.nameEnvMap.get(name);
} }
@ -701,10 +705,11 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
* 记录名称 和对应的环境 * 记录名称 和对应的环境
* *
* @param name 名称 * @param name 名称
* @param env 对应的环境 * @param info 对应的环境信息
*/ */
public void putEnv(String name, EnvConfig env) { public void putEnv(String name, DesignerWorkspaceInfo info) {
this.nameEnvMap.put(name, env);
this.nameEnvMap.put(name, info);
} }
/** /**
@ -1416,9 +1421,9 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
if ((tmpVal = reader.getAttrAsString("webinfLocation", null)) != null) { if ((tmpVal = reader.getAttrAsString("webinfLocation", null)) != null) {
// marks:兼容6.1的 // marks:兼容6.1的
// marks:设置默认的目录. // marks:设置默认的目录.
EnvConfig reportServer = new LocalEnvConfig(tmpVal);
String curReportServerName = Inter.getLocText("Server-Embedded_Server"); String curReportServerName = Inter.getLocText("Server-Embedded_Server");
LocalDesignerWorkspaceInfo reportServer = LocalDesignerWorkspaceInfo.create(curReportServerName, tmpVal);
this.putEnv(curReportServerName, reportServer); this.putEnv(curReportServerName, reportServer);
this.setCurEnvName(curReportServerName); this.setCurEnvName(curReportServerName);
} }
@ -1470,8 +1475,11 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
public void readXML(XMLableReader reader) { public void readXML(XMLableReader reader) {
if (reader.isChildNode()) { if (reader.isChildNode()) {
String tagName = reader.getTagName(); String tagName = reader.getTagName();
if (EnvConfig.XML_TAG.equals(tagName)) { if (DesignerWorkspaceType.Local.toString().equals(tagName)) {
EnvConfig envConfig = (EnvConfig) GeneralXMLTools.readXMLable(reader); LocalDesignerWorkspaceInfo envConfig = (LocalDesignerWorkspaceInfo) GeneralXMLTools.readXMLable(reader);
putEnv(name, envConfig);
} else if (DesignerWorkspaceType.Remote.toString().equals(tagName)) {
RemoteDesignerWorkspaceInfo envConfig = (RemoteDesignerWorkspaceInfo) GeneralXMLTools.readXMLable(reader);
putEnv(name, envConfig); putEnv(name, envConfig);
} }
} }
@ -1594,10 +1602,10 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
if (this.curEnvName != null) { if (this.curEnvName != null) {
writer.attr("currentEnv", this.curEnvName); writer.attr("currentEnv", this.curEnvName);
} }
for (Entry<String, EnvConfig> entry : nameEnvMap.entrySet()) { for (Entry<String, DesignerWorkspaceInfo> entry : nameEnvMap.entrySet()) {
writer.startTAG("EnvConfigElement").attr("name", entry.getKey()); writer.startTAG("EnvConfigElement").attr("name", entry.getKey());
EnvConfig envConfig = entry.getValue(); DesignerWorkspaceInfo envConfig = entry.getValue();
GeneralXMLTools.writeXMLable(writer, envConfig, EnvConfig.XML_TAG); GeneralXMLTools.writeXMLable(writer, envConfig, envConfig.getType().toString());
writer.end(); writer.end();
} }
writer.end(); writer.end();

39
designer-base/src/com/fr/design/actions/file/LocalePane.java

@ -4,7 +4,6 @@
package com.fr.design.actions.file; package com.fr.design.actions.file;
import com.fr.base.Env;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.BasicPane;
import com.fr.design.gui.frpane.UITabbedPane; import com.fr.design.gui.frpane.UITabbedPane;
@ -18,6 +17,7 @@ import com.fr.stable.ArrayUtils;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
import com.fr.stable.bridge.StableFactory; import com.fr.stable.bridge.StableFactory;
import com.fr.stable.project.ProjectConstants; import com.fr.stable.project.ProjectConstants;
import com.fr.workspace.WorkContext;
import javax.swing.*; import javax.swing.*;
import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentEvent;
@ -181,11 +181,8 @@ public class LocalePane extends BasicPane {
} }
private void initCustomProperties() throws Exception { private void initCustomProperties() throws Exception {
Env env = FRContext.getCurrentEnv();
if (env == null) { FileNode[] fileNodes = FRContext.getFileNodes().list(ProjectConstants.LOCALE_NAME);
return;
}
FileNode[] fileNodes = env.getFileOperator().list(ProjectConstants.LOCALE_NAME);
if (ArrayUtils.getLength(fileNodes) == 0) { if (ArrayUtils.getLength(fileNodes) == 0) {
return; return;
} }
@ -196,7 +193,7 @@ public class LocalePane extends BasicPane {
for (FileNode fileNode : fileNodes) { for (FileNode fileNode : fileNodes) {
String fileName = fileNode.getName(); String fileName = fileNode.getName();
if (fileName.endsWith(".properties")) { if (fileName.endsWith(".properties")) {
InputStream in = new ByteArrayInputStream(env.getFileOperator().read(StableUtils.pathJoin(ProjectConstants.LOCALE_NAME, fileName))); InputStream in = new ByteArrayInputStream(WorkContext.getWorkResource().readFully(StableUtils.pathJoin(ProjectConstants.LOCALE_NAME, fileName)));
Properties properties = new Properties(); Properties properties = new Properties();
properties.load(in); properties.load(in);
keys.addAll(properties.stringPropertyNames()); keys.addAll(properties.stringPropertyNames());
@ -209,8 +206,8 @@ public class LocalePane extends BasicPane {
for (String key : sortKeys) { for (String key : sortKeys) {
Vector<String> vector = new Vector<String>(); Vector<String> vector = new Vector<String>();
vector.add(key); vector.add(key);
for (int i = 0; i < list.size(); i ++) { for (Properties aList : list) {
vector.add(list.get(i).getProperty(key)); vector.add(aList.getProperty(key));
} }
customTableModel.addRow(vector); customTableModel.addRow(vector);
} }
@ -221,8 +218,8 @@ public class LocalePane extends BasicPane {
* *
*/ */
public void save() { public void save() {
Env env = FRContext.getCurrentEnv();
if (env == null) { if (WorkContext.getCurrent() == null) {
return; return;
} }
if (customTable.getCellEditor() == null) { if (customTable.getCellEditor() == null) {
@ -236,16 +233,16 @@ public class LocalePane extends BasicPane {
properties.setProperty(GeneralUtils.objectToString(customTableModel.getValueAt(j, 0)), GeneralUtils.objectToString(customTableModel.getValueAt(j, i))); properties.setProperty(GeneralUtils.objectToString(customTableModel.getValueAt(j, 0)), GeneralUtils.objectToString(customTableModel.getValueAt(j, i)));
} }
// OutputStream out = null; OutputStream out = null;
// try { try {
// out = env.writeBean(PREFIX + fileName + ".properties", ProjectConstants.LOCALE_NAME); out = FRContext.getCommonOperator().writeBean(PREFIX + fileName + ".properties", ProjectConstants.LOCALE_NAME);
// properties.store(out, null); properties.store(out, null);
//
// out.flush(); out.flush();
// out.close(); out.close();
// } catch (Exception e) { } catch (Exception e) {
// FineLoggerFactory.getLogger().info(e.getMessage()); FineLoggerFactory.getLogger().info(e.getMessage());
// } }
} }
} }

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

@ -1,16 +1,12 @@
package com.fr.design.actions.file; package com.fr.design.actions.file;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.base.env.Callback;
import com.fr.base.env.EnvUpdater;
import com.fr.core.env.EnvConfig;
import com.fr.core.env.impl.LocalEnvConfig;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.actions.UpdateAction; import com.fr.design.actions.UpdateAction;
import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.DesignTableDataManager;
import com.fr.design.data.tabledata.ResponseDataSourceChange; import com.fr.design.data.tabledata.ResponseDataSourceChange;
import com.fr.design.env.EnvGenerator; import com.fr.design.env.DesignerWorkspaceGenerator;
import com.fr.design.env.RemoteEnvConfig; import com.fr.design.env.DesignerWorkspaceInfo;
import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.JTemplate;
@ -19,13 +15,13 @@ import com.fr.design.menu.KeySetUtils;
import com.fr.design.menu.MenuDef; import com.fr.design.menu.MenuDef;
import com.fr.design.menu.SeparatorDef; import com.fr.design.menu.SeparatorDef;
import com.fr.design.utils.DesignUtils; import com.fr.design.utils.DesignUtils;
import com.fr.env.RemoteEnv;
import com.fr.general.GeneralContext; import com.fr.general.GeneralContext;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.EnvChangedListener; import com.fr.stable.EnvChangedListener;
import com.fr.workspace.WorkContext;
import com.fr.workspace.WorkContextCallback;
import javax.swing.*; import javax.swing.JOptionPane;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
@ -69,11 +65,16 @@ public class SwitchExistEnv extends MenuDef {
public GetExistEnvAction(String envName) { public GetExistEnvAction(String envName) {
this.setName(envName); this.setName(envName);
EnvConfig env = DesignerEnvManager.getEnvManager().getEnv(envName); DesignerWorkspaceInfo env = DesignerEnvManager.getEnvManager().getWorkspaceInfo(envName);
if (env instanceof LocalEnvConfig) { switch (env.getType()) {
case Local: {
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 RemoteEnvConfig) { break;
}
case Remote: {
this.setSmallIcon(BaseUtils.readIcon("com/fr/design/images/data/bind/distanceconnect.png")); this.setSmallIcon(BaseUtils.readIcon("com/fr/design/images/data/bind/distanceconnect.png"));
break;
}
} }
} }
@ -101,8 +102,8 @@ public class SwitchExistEnv extends MenuDef {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
DesignerEnvManager envManager = DesignerEnvManager.getEnvManager(); DesignerEnvManager envManager = DesignerEnvManager.getEnvManager();
final String envName = getName(); final String envName = getName();
EnvConfig selectedEnv = envManager.getEnv(envName); DesignerWorkspaceInfo selectedEnv = envManager.getWorkspaceInfo(envName);
EnvUpdater.updateEnv(EnvGenerator.generate(selectedEnv), new Callback() { WorkContext.switchTo(DesignerWorkspaceGenerator.generate(selectedEnv), new WorkContextCallback() {
@Override @Override
public void success() { public void success() {
DesignerEnvManager.getEnvManager().setCurEnvName(envName); DesignerEnvManager.getEnvManager().setCurEnvName(envName);

3
designer-base/src/com/fr/design/actions/help/alphafine/AlphaFineConfigManager.java

@ -1,6 +1,5 @@
package com.fr.design.actions.help.alphafine; package com.fr.design.actions.help.alphafine;
import com.fr.base.FRContext;
import com.fr.license.function.VT4FR; import com.fr.license.function.VT4FR;
import com.fr.stable.OperatingSystem; import com.fr.stable.OperatingSystem;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
@ -75,7 +74,7 @@ public class AlphaFineConfigManager implements XMLable {
public static boolean isALPHALicAvailable() { public static boolean isALPHALicAvailable() {
return FRContext.getCurrentEnv() != null && VT4FR.AlphaFine.isSupport(); return VT4FR.AlphaFine.isSupport();
} }
@Override @Override

3
designer-base/src/com/fr/design/data/BasicTableDataTreePane.java

@ -29,6 +29,7 @@ import com.fr.general.ComparatorUtils;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.general.NameObject; import com.fr.general.NameObject;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.workspace.WorkContext;
import javax.swing.*; import javax.swing.*;
import javax.swing.event.CellEditorListener; import javax.swing.event.CellEditorListener;
@ -152,7 +153,7 @@ public abstract class BasicTableDataTreePane extends DockingView implements Resp
protected void checkButtonEnabled(UpdateAction editAction, UpdateAction previewTableDataAction, UpdateAction removeAction, TableDataSourceOP op, TableDataTree dataTree) { protected void checkButtonEnabled(UpdateAction editAction, UpdateAction previewTableDataAction, UpdateAction removeAction, TableDataSourceOP op, TableDataTree dataTree) {
// august:BUG 9344 // august:BUG 9344
addMenuDef.setEnabled(true); addMenuDef.setEnabled(true);
connectionTableAction.setEnabled(FRContext.getCurrentEnv() != null && FRContext.getCurrentEnv().isRoot()); connectionTableAction.setEnabled(WorkContext.getCurrent() != null && WorkContext.getCurrent().isRoot());
if (op == null || op.interceptButtonEnabled()) { if (op == null || op.interceptButtonEnabled()) {
addMenuDef.setEnabled(false); addMenuDef.setEnabled(false);
editAction.setEnabled(false); editAction.setEnabled(false);

4
designer-base/src/com/fr/design/data/datapane/ChoosePane.java

@ -10,7 +10,6 @@ import com.fr.data.core.db.dialect.DialectFactory;
import com.fr.data.impl.Connection; import com.fr.data.impl.Connection;
import com.fr.data.impl.DBTableData; import com.fr.data.impl.DBTableData;
import com.fr.data.operator.DataOperator; import com.fr.data.operator.DataOperator;
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.beans.BasicBeanPane;
import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.DesignTableDataManager;
@ -37,6 +36,7 @@ import com.fr.general.ComparatorUtils;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.workspace.WorkContext;
import javax.swing.*; import javax.swing.*;
import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeEvent;
@ -463,7 +463,7 @@ public class ChoosePane extends BasicBeanPane<DataBaseItems> implements Refresha
// 显示Table数据. // 显示Table数据.
TableData tableData = null; TableData tableData = null;
if (FRContext.getCurrentEnv() instanceof LocalEnv) { if (WorkContext.getCurrent().isLocal()) {
tableData = new DBTableData(database, DataCoreUtils.createSelectSQL(paras.getSchemaName(), paras.getTableName(), tableData = new DBTableData(database, DataCoreUtils.createSelectSQL(paras.getSchemaName(), paras.getTableName(),
DialectFactory.getDialectByName(paras.getDatabaseName()))); DialectFactory.getDialectByName(paras.getDatabaseName())));
} else { } else {

3
designer-base/src/com/fr/design/data/datapane/connect/ConnectionComboBoxPanel.java

@ -15,6 +15,7 @@ import com.fr.general.ComparatorUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.transaction.Configurations; import com.fr.transaction.Configurations;
import com.fr.transaction.Worker; import com.fr.transaction.Worker;
import com.fr.workspace.WorkContext;
import javax.swing.*; import javax.swing.*;
import java.awt.event.ItemEvent; import java.awt.event.ItemEvent;
@ -127,7 +128,7 @@ public class ConnectionComboBoxPanel extends ItemEditableComboBoxPanel {
* @param connection 数据库链接 * @param connection 数据库链接
*/ */
public void populate(Connection connection) { public void populate(Connection connection) {
editButton.setEnabled(FRContext.getCurrentEnv().isRoot()); editButton.setEnabled(WorkContext.getCurrent().isRoot());
if (connection instanceof NameDatabaseConnection) { if (connection instanceof NameDatabaseConnection) {
this.setSelectedItem(((NameDatabaseConnection) connection).getName()); this.setSelectedItem(((NameDatabaseConnection) connection).getName());
} else { } else {

2
designer-base/src/com/fr/design/data/datapane/connect/ConnectionManagerPane.java

@ -46,7 +46,7 @@ public class ConnectionManagerPane extends LoadingBasicPane implements Connectio
} }
public void populate(ConnectionConfig datasourceManager) { public void populate(ConnectionConfig datasourceManager) {
// this.connectionTextField.setText(FRContext.getCurrentEnv().getPath() + File.separator + ProjectConstants.RESOURCES_NAME // this.connectionTextField.setText(WorkContext.getCurrent().getPath() + File.separator + ProjectConstants.RESOURCES_NAME
// + File.separator + datasourceManager.fileName()); // + File.separator + datasourceManager.fileName());
this.connectionListPane.populate(datasourceManager); this.connectionListPane.populate(datasourceManager);
} }

12
designer-base/src/com/fr/design/data/datapane/preview/PreviewTableModel.java

@ -1,18 +1,18 @@
package com.fr.design.data.datapane.preview; package com.fr.design.data.datapane.preview;
import javax.swing.table.AbstractTableModel;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.cache.list.IntList;
import com.fr.data.AbstractDataModel; import com.fr.data.AbstractDataModel;
import com.fr.data.impl.EmbeddedTableData.EmbeddedTDDataModel; import com.fr.data.impl.EmbeddedTableData.EmbeddedTDDataModel;
import com.fr.data.impl.storeproc.ProcedureDataModel; import com.fr.data.impl.storeproc.ProcedureDataModel;
import com.fr.env.RemoteEnv; import com.fr.design.utils.DesignUtils;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.general.data.DataModel; import com.fr.general.data.DataModel;
import com.fr.general.data.TableDataException; import com.fr.general.data.TableDataException;
import com.fr.cache.list.IntList;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.design.utils.DesignUtils; import com.fr.workspace.WorkContext;
import javax.swing.table.AbstractTableModel;
/** /**
* 这个TableModel主要是预览数据的. 字段TableData必须转化为内置的 * 这个TableModel主要是预览数据的. 字段TableData必须转化为内置的
@ -188,7 +188,7 @@ public class PreviewTableModel extends AbstractTableModel {
s = "?"; s = "?";
} else if (o instanceof String) { } else if (o instanceof String) {
s = Inter.getLocText("FR-Designer_Parameter_String"); s = Inter.getLocText("FR-Designer_Parameter_String");
if (FRContext.getCurrentEnv() instanceof RemoteEnv && dataModel instanceof EmbeddedTDDataModel) { if (!WorkContext.getCurrent().isLocal() && dataModel instanceof EmbeddedTDDataModel) {
Class clzz = ((EmbeddedTDDataModel) dataModel).getColumnClass(column); Class clzz = ((EmbeddedTDDataModel) dataModel).getColumnClass(column);
if (Number.class.isAssignableFrom(clzz)) { if (Number.class.isAssignableFrom(clzz)) {
s = Inter.getLocText("FR-Designer_Number");//bigdecimal s = Inter.getLocText("FR-Designer_Number");//bigdecimal

16
designer-base/src/com/fr/design/data/tabledata/tabledatapane/ClassNameSelectPane.java

@ -1,19 +1,15 @@
package com.fr.design.data.tabledata.tabledatapane; package com.fr.design.data.tabledata.tabledatapane;
import java.awt.BorderLayout; import com.fr.design.dialog.BasicPane;
import javax.swing.BorderFactory;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.tree.TreeSelectionModel;
import com.fr.base.FRContext;
import com.fr.design.gui.itree.filetree.ClassFileTree; import com.fr.design.gui.itree.filetree.ClassFileTree;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.dialog.BasicPane;
import com.fr.general.Inter; import com.fr.general.Inter;
import javax.swing.*;
import javax.swing.tree.TreeSelectionModel;
import java.awt.*;
public class ClassNameSelectPane extends BasicPane { public class ClassNameSelectPane extends BasicPane {
private ClassFileTree classFileTree; private ClassFileTree classFileTree;
@ -27,7 +23,7 @@ public class ClassNameSelectPane extends BasicPane {
Inter.getLocText("Function-Choose_Function_Class") + ":")); Inter.getLocText("Function-Choose_Function_Class") + ":"));
classFileTree = new ClassFileTree(); classFileTree = new ClassFileTree();
classFileTree.refreshEnv(FRContext.getCurrentEnv()); classFileTree.refreshEnv();
classFileTree.getSelectionModel().setSelectionMode( classFileTree.getSelectionModel().setSelectionMode(
TreeSelectionModel.SINGLE_TREE_SELECTION); TreeSelectionModel.SINGLE_TREE_SELECTION);
this.add(new JScrollPane(classFileTree), BorderLayout.CENTER); this.add(new JScrollPane(classFileTree), BorderLayout.CENTER);

2
designer-base/src/com/fr/design/data/tabledata/tabledatapane/ProcedureManagerPane.java

@ -37,7 +37,7 @@ public class ProcedureManagerPane extends LoadingBasicPane {
public void populate(ProcedureConfig procedureConfig) { public void populate(ProcedureConfig procedureConfig) {
//todo 原来界面上显示的xml路径 //todo 原来界面上显示的xml路径
// this.connectionTextField.setText(FRContext.getCurrentEnv().getPath() + File.separator + ProjectConstants.RESOURCES_NAME // this.connectionTextField.setText(WorkContext.getCurrent().getPath() + File.separator + ProjectConstants.RESOURCES_NAME
// + File.separator + datasourceManager.fileName()); // + File.separator + datasourceManager.fileName());
this.procedureListPane.populate(procedureConfig); this.procedureListPane.populate(procedureConfig);
} }

2
designer-base/src/com/fr/design/data/tabledata/tabledatapane/TableDataManagerPane.java

@ -76,7 +76,7 @@ public class TableDataManagerPane extends LoadingBasicPane {
public void populate(TableDataConfig tableDataConfig) { public void populate(TableDataConfig tableDataConfig) {
//todo 原来界面上显示的xml路径 //todo 原来界面上显示的xml路径
// this.tableDataTextField.setText(FRContext.getCurrentEnv().getPath() + File.separator + ProjectConstants.RESOURCES_NAME // this.tableDataTextField.setText(WorkContext.getCurrent().getPath() + File.separator + ProjectConstants.RESOURCES_NAME
// + File.separator + datasourceManager.fileName()); // + File.separator + datasourceManager.fileName());
this.tableDataPane.populate(tableDataConfig); this.tableDataPane.populate(tableDataConfig);
} }

6
designer-base/src/com/fr/design/data/tabledata/wrapper/StoreProcedureNameWrapper.java

@ -1,7 +1,6 @@
package com.fr.design.data.tabledata.wrapper; package com.fr.design.data.tabledata.wrapper;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.base.Env;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.base.TableData; import com.fr.base.TableData;
import com.fr.data.impl.storeproc.ProcedureDataModel; import com.fr.data.impl.storeproc.ProcedureDataModel;
@ -9,8 +8,8 @@ import com.fr.data.impl.storeproc.StoreProcedure;
import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.DesignTableDataManager;
import com.fr.design.data.datapane.preview.PreviewTablePane; import com.fr.design.data.datapane.preview.PreviewTablePane;
import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode; import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode;
import com.fr.env.RemoteEnv;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.workspace.WorkContext;
import javax.swing.*; import javax.swing.*;
import java.util.ArrayList; import java.util.ArrayList;
@ -94,8 +93,7 @@ public final class StoreProcedureNameWrapper implements TableDataWrapper {
return columnNameList; return columnNameList;
} }
columnNameList = new ArrayList<String>(); columnNameList = new ArrayList<String>();
Env env = FRContext.getCurrentEnv(); if (!WorkContext.getCurrent().isLocal()) {
if (env instanceof RemoteEnv) {
try { try {
createStore(false); createStore(false);
columnNameList = Arrays.asList(procedureDataModel.getColumnName()); columnNameList = Arrays.asList(procedureDataModel.getColumnName());

32
designer-base/src/com/fr/design/env/DesignerWorkspaceGenerator.java vendored

@ -0,0 +1,32 @@
package com.fr.design.env;
import com.fr.workspace.WorkContext;
import com.fr.workspace.Workspace;
import com.fr.workspace.connect.WorkspaceClient;
/**
* 根据配置生成运行环境
*/
public class DesignerWorkspaceGenerator {
public static Workspace generate(DesignerWorkspaceInfo config) {
if (config == null || config.getType() == null) {
return null;
}
Workspace workspace = null;
switch (config.getType()) {
case Local: {
workspace = WorkContext.getFactory().build(config.getPath());
break;
}
case Remote: {
WorkspaceClient client = WorkContext.getConnector().connect(config.getConnection());
workspace = new RemoteWorkspace(client, config.getConnection());
break;
}
}
return workspace;
}
}

14
designer-base/src/com/fr/design/env/DesignerWorkspaceInfo.java vendored

@ -0,0 +1,14 @@
package com.fr.design.env;
import com.fr.stable.xml.XMLable;
import com.fr.workspace.connect.WorkspaceConnection;
public interface DesignerWorkspaceInfo extends XMLable {
DesignerWorkspaceType getType();
String getName();
String getPath();
WorkspaceConnection getConnection();
}

10
designer-base/src/com/fr/design/env/DesignerWorkspaceType.java vendored

@ -0,0 +1,10 @@
package com.fr.design.env;
/**
* Created by juhaoyu on 2018/6/15.
* 设计器使用的workspace类型
*/
public enum DesignerWorkspaceType {
Local,
Remote
}

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

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

68
designer-base/src/com/fr/design/env/LocalDesignerWorkspaceInfo.java vendored

@ -0,0 +1,68 @@
package com.fr.design.env;
import com.fr.stable.StringUtils;
import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLableReader;
import com.fr.workspace.connect.WorkspaceConnection;
/**
* Created by juhaoyu on 2018/6/15.
*/
public class LocalDesignerWorkspaceInfo implements DesignerWorkspaceInfo {
private String name;
private String path;
public static LocalDesignerWorkspaceInfo create(String name, String path) {
LocalDesignerWorkspaceInfo info = new LocalDesignerWorkspaceInfo();
info.name = name;
info.path = path;
return info;
}
@Override
public DesignerWorkspaceType getType() {
return DesignerWorkspaceType.Local;
}
@Override
public String getName() {
return name;
}
@Override
public String getPath() {
return path;
}
@Override
public WorkspaceConnection getConnection() {
return null;
}
@Override
public void readXML(XMLableReader reader) {
if (reader.isAttr()) {
this.name = reader.getAttrAsString("name", StringUtils.EMPTY);
this.path = reader.getAttrAsString("path", StringUtils.EMPTY);
}
}
@Override
public void writeXML(XMLPrintWriter writer) {
writer.attr("name", name);
writer.attr("path", path);
}
@Override
public Object clone() throws CloneNotSupportedException {
return null;
}
}

81
designer-base/src/com/fr/design/env/RemoteDesignerWorkspaceInfo.java vendored

@ -0,0 +1,81 @@
package com.fr.design.env;
import com.fr.security.SecurityToolbox;
import com.fr.stable.StringUtils;
import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLableReader;
import com.fr.workspace.connect.WorkspaceConnection;
public class RemoteDesignerWorkspaceInfo implements DesignerWorkspaceInfo {
private String name;
private WorkspaceConnection connection;
public static RemoteDesignerWorkspaceInfo create(WorkspaceConnection connection) {
RemoteDesignerWorkspaceInfo info = new RemoteDesignerWorkspaceInfo();
info.connection = connection;
return info;
}
@Override
public DesignerWorkspaceType getType() {
return DesignerWorkspaceType.Remote;
}
@Override
public String getName() {
return name;
}
@Override
public String getPath() {
return null;
}
@Override
public WorkspaceConnection getConnection() {
return connection;
}
@Override
public void readXML(XMLableReader reader) {
if (reader.isAttr()) {
this.name = reader.getAttrAsString("name", StringUtils.EMPTY);
}
if (reader.isChildNode()) {
String tagName = reader.getTagName();
if ("Connection".equals(tagName)) {
String url = reader.getAttrAsString("url", StringUtils.EMPTY);
String username = reader.getAttrAsString("username", StringUtils.EMPTY);
//密码解密
String password = SecurityToolbox.defaultDecrypt(reader.getAttrAsString("password", StringUtils.EMPTY).replaceAll(" ","\r\n"));
this.connection = new WorkspaceConnection(url, username, password);
}
}
}
@Override
public void writeXML(XMLPrintWriter writer) {
writer.attr("name", name);
if (this.connection != null) {
writer.startTAG("Connection");
writer.attr("url", connection.getUrl());
writer.attr("username", connection.getUserName());
writer.attr("password", SecurityToolbox.defaultEncrypt(connection.getPassword()));
writer.end();
}
}
@Override
public Object clone() throws CloneNotSupportedException {
return null;
}
}

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

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

74
designer-base/src/com/fr/design/env/RemoteWorkspace.java vendored

@ -0,0 +1,74 @@
package com.fr.design.env;
import com.fr.env.operator.decision.DecisionOperator;
import com.fr.general.Inter;
import com.fr.report.util.RemoteDesignAuthenticateUtils;
import com.fr.workspace.WorkContext;
import com.fr.workspace.Workspace;
import com.fr.workspace.connect.WorkspaceClient;
import com.fr.workspace.connect.WorkspaceConnection;
/**
* Created by juhaoyu on 2018/6/14.
* 远程工作目录
*/
public class RemoteWorkspace implements Workspace {
private final WorkspaceClient client;
private final String address;
private final String userName;
RemoteWorkspace(WorkspaceClient client, WorkspaceConnection connection) {
this.client = client;
this.address = connection.getUrl();
this.userName = connection.getUserName();
}
@Override
public String getName() {
return userName;
}
@Override
public String getPath() {
return address;
}
@Override
public String getDescription() {
return userName + "@" + "[" + Inter.getLocText("Fine-Designer_Basic_Remote_Env") + "]";
}
@Override
public boolean isWarDeploy() {
return false;
}
@Override
public boolean isLocal() {
return false;
}
@Override
public boolean isRoot() {
try {
return WorkContext.getCurrent().get(DecisionOperator.class).isRoot(WorkContext.getConnector().currentUser());
} catch (Exception e) {
return false;
}
}
@Override
public <T> T get(Class<T> type) {
return client.getPool().get(type);
}
}

4
designer-base/src/com/fr/design/extra/WebViewDlgHelper.java

@ -44,7 +44,7 @@ public class WebViewDlgHelper {
private static final String LATEST = "latest"; private static final String LATEST = "latest";
private static final String SHOP_SCRIPTS = "shop_scripts"; private static final String SHOP_SCRIPTS = "shop_scripts";
private static final int VERSION_8 = 8; private static final int VERSION_8 = 8;
private static String installHome = FRContext.getCurrentEnv().getWebReportPath(); private static String installHome = FRContext.getCommonOperator().getWebReportPath();
private static final String MAIN_JS_PATH = "/scripts/plugin.html"; private static final String MAIN_JS_PATH = "/scripts/plugin.html";
private static final String ENV_VERSION = "ENV_VERSION"; private static final String ENV_VERSION = "ENV_VERSION";
@ -52,7 +52,7 @@ public class WebViewDlgHelper {
GeneralContext.addEnvChangedListener(new EnvChangedListener() { GeneralContext.addEnvChangedListener(new EnvChangedListener() {
@Override @Override
public void envChanged() { public void envChanged() {
installHome = FRContext.getCurrentEnv().getWebReportPath(); installHome = FRContext.getCommonOperator().getWebReportPath();
} }
}); });
} }

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

@ -1,9 +1,7 @@
package com.fr.design.file; package com.fr.design.file;
import com.fr.base.Env;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.base.chart.chartdata.CallbackEvent; import com.fr.base.chart.chartdata.CallbackEvent;
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.constants.UIConstants; import com.fr.design.constants.UIConstants;
@ -25,6 +23,7 @@ import com.fr.log.FineLoggerFactory;
import com.fr.stable.Constants; import com.fr.stable.Constants;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
import com.fr.stable.project.ProjectConstants; import com.fr.stable.project.ProjectConstants;
import com.fr.workspace.WorkContext;
import javax.swing.*; import javax.swing.*;
import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionEvent;
@ -366,9 +365,8 @@ public class HistoryTemplateListPane extends JPanel implements FileOperations, C
*/ */
public void openContainerFolder() { public void openContainerFolder() {
FileNode fileNode = new FileNode(((JTemplate<?, ?>) list.getSelectedValue()).getEditingFILE().getPath(), false); FileNode fileNode = new FileNode(((JTemplate<?, ?>) list.getSelectedValue()).getEditingFILE().getPath(), false);
Env env = FRContext.getCurrentEnv(); if (WorkContext.getCurrent().isLocal()) {
if (env.isLocalEnv()) { IOUtils.openWindowsFolder(StableUtils.pathJoin(WorkContext.getCurrent().getPath(), fileNode.getEnvPath()));
IOUtils.openWindowsFolder(StableUtils.pathJoin(env.getEnvConfig().getPath(), fileNode.getEnvPath()));
} }
} }

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

@ -3,10 +3,8 @@
*/ */
package com.fr.design.file; package com.fr.design.file;
import com.fr.base.Env;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.base.io.FileAssistUtils; import com.fr.base.io.FileAssistUtils;
import com.fr.dav.LocalEnv;
import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.itree.filetree.TemplateFileTree; import com.fr.design.gui.itree.filetree.TemplateFileTree;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
@ -23,6 +21,7 @@ import com.fr.stable.CoreConstants;
import com.fr.stable.ProductConstants; import com.fr.stable.ProductConstants;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
import com.fr.stable.project.ProjectConstants; import com.fr.stable.project.ProjectConstants;
import com.fr.workspace.WorkContext;
import javax.swing.*; import javax.swing.*;
import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.DefaultMutableTreeNode;
@ -99,8 +98,8 @@ public class TemplateTreePane extends JPanel implements FileOperations {
* 刷新 * 刷新
*/ */
public void refreshDockingView() { public void refreshDockingView() {
reportletsTree.setFileNodeFilter(new IOFileNodeFilter(FRContext.getCurrentEnv().getSupportedTypes())); reportletsTree.setFileNodeFilter(new IOFileNodeFilter(FRContext.getFileNodes().getSupportedTypes()));
reportletsTree.refreshEnv(FRContext.getCurrentEnv()); reportletsTree.refreshEnv();
} }
/* /*
@ -141,13 +140,12 @@ 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();
Env localEnv = FRContext.getCurrentEnv(); String filePath = StableUtils.pathJoin(WorkContext.getCurrent().getPath(), 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));
} catch (Exception e) { } catch (Exception e) {
IOUtils.openWindowsFolder(StableUtils.pathJoin(localEnv.getEnvConfig().getPath(), fn.getEnvPath())); IOUtils.openWindowsFolder(StableUtils.pathJoin(WorkContext.getCurrent().getPath(), fn.getEnvPath()));
} }
} }

6
designer-base/src/com/fr/design/formula/FunctionManagerPane.java

@ -1,6 +1,5 @@
package com.fr.design.formula; package com.fr.design.formula;
import com.fr.base.FRContext;
import com.fr.design.beans.BasicBeanPane; import com.fr.design.beans.BasicBeanPane;
import com.fr.design.data.tabledata.tabledatapane.ClassNameSelectPane; import com.fr.design.data.tabledata.tabledatapane.ClassNameSelectPane;
import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.BasicDialog;
@ -22,6 +21,7 @@ import com.fr.general.NameObject;
import com.fr.stable.Nameable; import com.fr.stable.Nameable;
import com.fr.stable.project.ProjectConstants; import com.fr.stable.project.ProjectConstants;
import com.fr.stable.script.FunctionDef; import com.fr.stable.script.FunctionDef;
import com.fr.workspace.WorkContext;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
@ -64,7 +64,7 @@ public class FunctionManagerPane extends BasicPane {
*/ */
public void populate(FunctionConfig functionManager) { public void populate(FunctionConfig functionManager) {
//todo 原来界面上显示的xml路径 //todo 原来界面上显示的xml路径
// this.functionTextField.setText(FRContext.getCurrentEnv().getPath() + File.separator // this.functionTextField.setText(WorkContext.getCurrent().getPath() + File.separator
// + ProjectConstants.RESOURCES_NAME // + ProjectConstants.RESOURCES_NAME
// + File.separator + functionManager.fileName()); // + File.separator + functionManager.fileName());
@ -162,7 +162,7 @@ public class FunctionManagerPane extends BasicPane {
northPane.add(descriptionArea); northPane.add(descriptionArea);
String path1 = getEscapePath(File.separator + ProjectConstants.WEBINF_NAME + File.separator + ProjectConstants.CLASSES_NAME); String path1 = getEscapePath(File.separator + ProjectConstants.WEBINF_NAME + File.separator + ProjectConstants.CLASSES_NAME);
String path2 = getEscapePath(FRContext.getCurrentEnv().getPath() + File.separator + ProjectConstants.CLASSES_NAME); String path2 = getEscapePath(WorkContext.getCurrent().getPath() + File.separator + ProjectConstants.CLASSES_NAME);
descriptionArea.setText(Inter.getLocText("FR-Designer_Function_Description_Area_Text", path1, path2)); descriptionArea.setText(Inter.getLocText("FR-Designer_Function_Description_Area_Text", path1, path2));
JPanel descriptionPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); //Description Pane JPanel descriptionPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); //Description Pane

10
designer-base/src/com/fr/design/formula/JavaEditorPane.java

@ -1,6 +1,5 @@
package com.fr.design.formula; package com.fr.design.formula;
import com.fr.base.Env;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.BasicPane;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
@ -16,6 +15,7 @@ import com.fr.stable.JavaCompileInfo;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.stable.project.ProjectConstants; import com.fr.stable.project.ProjectConstants;
import com.fr.workspace.WorkContext;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
@ -113,7 +113,7 @@ public class JavaEditorPane extends BasicPane {
private InputStream getJavaSourceInputStream() { private InputStream getJavaSourceInputStream() {
String javaPath = getJavaPath(); String javaPath = getJavaPath();
try { try {
return new ByteArrayInputStream(FRContext.getCurrentEnv().getFileOperator().read(StableUtils.pathJoin(ProjectConstants.CLASSES_NAME, javaPath))); return new ByteArrayInputStream(WorkContext.getWorkResource().readFully(StableUtils.pathJoin(ProjectConstants.CLASSES_NAME, javaPath)));
} catch (Exception e) { } catch (Exception e) {
FRContext.getLogger().error(e.getMessage(), e); FRContext.getLogger().error(e.getMessage(), e);
} }
@ -156,7 +156,7 @@ public class JavaEditorPane extends BasicPane {
return; return;
} }
try { try {
FRContext.getCurrentEnv().getFileOperator().write(text.getBytes(EncodeConstants.ENCODING_UTF_8), StableUtils.pathJoin(ProjectConstants.CLASSES_NAME, getJavaPath())); WorkContext.getWorkResource().write(StableUtils.pathJoin(ProjectConstants.CLASSES_NAME, getJavaPath()), text.getBytes(EncodeConstants.ENCODING_UTF_8));
JOptionPane.showMessageDialog(null, Inter.getLocText(new String[]{"Save", "Successfully"}) + "!"); JOptionPane.showMessageDialog(null, Inter.getLocText(new String[]{"Save", "Successfully"}) + "!");
fireSaveActionListener(); fireSaveActionListener();
} catch (Exception e) { } catch (Exception e) {
@ -175,8 +175,8 @@ public class JavaEditorPane extends BasicPane {
@Override @Override
protected JavaCompileInfo doInBackground() throws Exception { protected JavaCompileInfo doInBackground() throws Exception {
Env env = FRContext.getCurrentEnv();
return env.getCommonOperator().compile(javaText.getText()); return FRContext.getCommonOperator().compile(javaText.getText());
} }
public void done() { public void done() {

25
designer-base/src/com/fr/design/gui/controlpane/JListControlPane.java

@ -25,10 +25,20 @@ import com.fr.stable.ArrayUtils;
import com.fr.stable.Nameable; import com.fr.stable.Nameable;
import com.fr.stable.core.PropertyChangeAdapter; import com.fr.stable.core.PropertyChangeAdapter;
import javax.swing.*; import javax.swing.DefaultListCellRenderer;
import javax.swing.DefaultListModel;
import javax.swing.Icon;
import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.ListSelectionModel;
import javax.swing.SwingUtilities;
import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener; import javax.swing.event.ListSelectionListener;
import java.awt.*; import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Component;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
@ -383,7 +393,7 @@ public abstract class JListControlPane extends JControlPane {
private void wrapActionListener(NameableCreator[] creators) { private void wrapActionListener(NameableCreator[] creators) {
for (final NameableCreator creator : creators) { for (final NameableCreator creator : creators) {
if (!HyperlinkFilterHelper.whetherAddHyperlink4cell(creator.menuName())) { if (filterNameableCreator(creator)) {
continue; continue;
} }
boolean isTrue = ComparatorUtils.equals(creator.menuName(), Inter.getLocText("Datasource-Stored_Procedure")) || boolean isTrue = ComparatorUtils.equals(creator.menuName(), Inter.getLocText("Datasource-Stored_Procedure")) ||
@ -942,6 +952,7 @@ public abstract class JListControlPane extends JControlPane {
} }
return false; return false;
} }
/** /**
* 设置选中项 * 设置选中项
* *
@ -951,4 +962,12 @@ public abstract class JListControlPane extends JControlPane {
nameableList.setSelectedIndex(index); nameableList.setSelectedIndex(index);
} }
/**
* 用于在list面板中过滤某些下拉选项
* @return true过滤掉这个creator
*/
protected boolean filterNameableCreator(NameableCreator creator) {
return !HyperlinkFilterHelper.whetherAddHyperlink4cell(creator.menuName());
}
} }

8
designer-base/src/com/fr/design/gui/itree/filetree/EnvFileTree.java

@ -1,6 +1,5 @@
package com.fr.design.gui.itree.filetree; package com.fr.design.gui.itree.filetree;
import com.fr.base.Env;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.design.constants.UIConstants; import com.fr.design.constants.UIConstants;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
@ -12,6 +11,7 @@ import com.fr.general.ComparatorUtils;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.stable.CoreConstants; import com.fr.stable.CoreConstants;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
import com.fr.workspace.WorkContext;
import javax.swing.*; import javax.swing.*;
import javax.swing.tree.DefaultTreeCellRenderer; import javax.swing.tree.DefaultTreeCellRenderer;
@ -28,7 +28,6 @@ import java.util.Arrays;
public class EnvFileTree extends RefreshableJTree { public class EnvFileTree extends RefreshableJTree {
protected FileNodeFilter filter; protected FileNodeFilter filter;
protected Env env;
protected String treeRootPath = ""; protected String treeRootPath = "";
protected String[] subPathes; protected String[] subPathes;
@ -191,7 +190,7 @@ public class EnvFileTree extends RefreshableJTree {
FileNode[] res_fns = null; FileNode[] res_fns = null;
try { try {
res_fns = env == null ? new FileNode[0] : env.getFileOperator().list(filePath); res_fns = WorkContext.getCurrent() == null ? new FileNode[0] : FRContext.getFileNodes().list(filePath);
} catch (Exception e) { } catch (Exception e) {
FRContext.getLogger().error(e.getMessage(), e); FRContext.getLogger().error(e.getMessage(), e);
} }
@ -239,8 +238,7 @@ public class EnvFileTree extends RefreshableJTree {
/* /*
* 改变Env后,根据构造函数时设置的RootPathes,重新加载 * 改变Env后,根据构造函数时设置的RootPathes,重新加载
*/ */
public void refreshEnv(Env env) { public void refreshEnv() {
this.env = env;
DefaultTreeModel m_model = (DefaultTreeModel) this.getModel(); DefaultTreeModel m_model = (DefaultTreeModel) this.getModel();
ExpandMutableTreeNode rootTreeNode = (ExpandMutableTreeNode) m_model.getRoot(); ExpandMutableTreeNode rootTreeNode = (ExpandMutableTreeNode) m_model.getRoot();

18
designer-base/src/com/fr/design/gui/itree/filetree/FileNodeComparator.java

@ -1,10 +1,10 @@
package com.fr.design.gui.itree.filetree; package com.fr.design.gui.itree.filetree;
import java.util.Comparator; import com.fr.file.filetree.LocalFileNodes;
import com.fr.dav.LocalEnv;
import com.fr.file.filetree.FileNode; import com.fr.file.filetree.FileNode;
import java.util.Comparator;
/** /**
* FileTreeNode compare... * FileTreeNode compare...
* Directory is in the first. and normal file the in the last. * Directory is in the first. and normal file the in the last.
@ -26,8 +26,6 @@ public class FileNodeComparator implements Comparator<FileNode> {
* v1 is equal to v2, or < 0 if v1 is less than v2. * v1 is equal to v2, or < 0 if v1 is less than v2.
* It must handle null values for the comparison values. * It must handle null values for the comparison values.
* *
* @param v1 comparison value.
* @param v2 comparison value.
* @return < 0, 0, or > 0 for v1<v2, v1==v2, or v1>v2. * @return < 0, 0, or > 0 for v1<v2, v1==v2, or v1>v2.
*/ */
public int compare(FileNode nameNode1, FileNode nameNode2) { public int compare(FileNode nameNode1, FileNode nameNode2) {
@ -60,14 +58,14 @@ public class FileNodeComparator implements Comparator<FileNode> {
*/ */
private int groupByFileType(FileNode nameNode1, FileNode nameNode2, private int groupByFileType(FileNode nameNode1, FileNode nameNode2,
int i) { int i) {
if(i< LocalEnv.FILE_TYPE.length){
if(nameNode1.isFileType(LocalEnv.FILE_TYPE[i])) if (i < LocalFileNodes.FILE_TYPE.length) {
if(nameNode2.isFileType(LocalEnv.FILE_TYPE[i])) if (nameNode1.isFileType(LocalFileNodes.FILE_TYPE[i]))
if (nameNode2.isFileType(LocalFileNodes.FILE_TYPE[i]))
return nameNode1.getName().toLowerCase().compareTo(nameNode2.getName().toLowerCase()); return nameNode1.getName().toLowerCase().compareTo(nameNode2.getName().toLowerCase());
else else
return-1; return-1;
else else if (nameNode2.isFileType(LocalFileNodes.FILE_TYPE[i]))
if(nameNode2.isFileType(LocalEnv.FILE_TYPE[i]))
return 1; return 1;
else{ else{
return groupByFileType(nameNode1, nameNode2, i+1); return groupByFileType(nameNode1, nameNode2, i+1);

16
designer-base/src/com/fr/design/gui/itree/filetree/FileTreeIcon.java

@ -1,17 +1,15 @@
package com.fr.design.gui.itree.filetree; package com.fr.design.gui.itree.filetree;
import java.io.File;
import javax.swing.Icon;
import javax.swing.UIManager;
import javax.swing.filechooser.FileSystemView;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.dav.LocalEnv;
import com.fr.design.icon.LockIcon; import com.fr.design.icon.LockIcon;
import com.fr.file.filetree.FileNode; import com.fr.file.filetree.FileNode;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
import com.fr.workspace.WorkContext;
import javax.swing.*;
import javax.swing.filechooser.FileSystemView;
import java.io.File;
public class FileTreeIcon { public class FileTreeIcon {
private FileTreeIcon() {} private FileTreeIcon() {}
@ -117,8 +115,8 @@ public class FileTreeIcon {
} }
public static Icon getIcon(FileNode node, boolean isShowLock) { public static Icon getIcon(FileNode node, boolean isShowLock) {
String path = StableUtils.pathJoin(new String[]{FRContext.getCurrentEnv().getPath(), node.getEnvPath()}); String path = StableUtils.pathJoin(new String[]{WorkContext.getCurrent().getPath(), node.getEnvPath()});
if (FRContext.getCurrentEnv() instanceof LocalEnv) { if (WorkContext.getCurrent().isLocal()) {
File ff = new File(path); File ff = new File(path);
if (ff.exists()) { if (ff.exists()) {
if(node.isDirectory()){ if(node.isDirectory()){

29
designer-base/src/com/fr/design/gui/itree/filetree/ReportletPane.java

@ -1,23 +1,18 @@
package com.fr.design.gui.itree.filetree; package com.fr.design.gui.itree.filetree;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import com.fr.base.Env;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.design.dialog.BasicPane;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.itextarea.UITextArea; import com.fr.design.gui.itextarea.UITextArea;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.dialog.BasicPane; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.file.filetree.IOFileNodeFilter; import com.fr.file.filetree.IOFileNodeFilter;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.design.utils.gui.GUICoreUtils;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class ReportletPane extends BasicPane { public class ReportletPane extends BasicPane {
private TemplateFileTree templateReportletTree; private TemplateFileTree templateReportletTree;
@ -61,7 +56,7 @@ public class ReportletPane extends BasicPane {
classReportletTree = new ClassFileTree(); classReportletTree = new ClassFileTree();
cardPane.add(c_panel = new JScrollPane(classReportletTree), "CLASS"); cardPane.add(c_panel = new JScrollPane(classReportletTree), "CLASS");
this.refreshEnv(FRContext.getCurrentEnv()); this.refreshEnv();
} }
/* /*
@ -92,11 +87,11 @@ public class ReportletPane extends BasicPane {
/** /**
* 刷新Env * 刷新Env
* @param env 环境
*/ */
public void refreshEnv(Env env) { public void refreshEnv() {
this.templateReportletTree.refreshEnv(env);
this.classReportletTree.refreshEnv(env); this.templateReportletTree.refreshEnv();
this.classReportletTree.refreshEnv();
} }
@Override @Override

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

@ -1,13 +1,9 @@
package com.fr.design.gui.itree.filetree; package com.fr.design.gui.itree.filetree;
import com.fr.base.Env;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.base.extension.FileExtension; import com.fr.base.extension.FileExtension;
import com.fr.base.operator.file.FileOperator;
import com.fr.core.env.proxy.EnvProxy;
import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode; import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode;
import com.fr.file.filetree.FileNode; import com.fr.file.filetree.FileNode;
import com.fr.general.web.ParameterConstants;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
@ -105,7 +101,7 @@ public class TemplateFileTree extends EnvFileTree {
} }
public FileNode[] listFile(String path) throws Exception { public FileNode[] listFile(String path) throws Exception {
return FRContext.getCurrentEnv().getFileOperator().list( return FRContext.getFileNodes().list(
path, path,
new FileExtension[]{FileExtension.CPT, FileExtension.FRM, FileExtension.CPTX, FileExtension.FRMX}); new FileExtension[]{FileExtension.CPT, FileExtension.FRM, FileExtension.CPTX, FileExtension.FRMX});
} }
@ -113,7 +109,7 @@ public class TemplateFileTree extends EnvFileTree {
/* /*
* 改变Env后,根据构造函数时设置的RootPaths,重新加载 * 改变Env后,根据构造函数时设置的RootPaths,重新加载
*/ */
public void refreshEnv(Env env) { public void refreshEnv() {
DefaultTreeModel defaultTreeModel = (DefaultTreeModel) this.getModel(); DefaultTreeModel defaultTreeModel = (DefaultTreeModel) this.getModel();
ExpandMutableTreeNode rootTreeNode = (ExpandMutableTreeNode) defaultTreeModel.getRoot(); ExpandMutableTreeNode rootTreeNode = (ExpandMutableTreeNode) defaultTreeModel.getRoot();

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

@ -4,9 +4,6 @@
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.EnvUpdater;
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;
@ -54,24 +51,12 @@ import com.fr.stable.ProductConstants;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
import com.fr.stable.image4j.codec.ico.ICODecoder; import com.fr.stable.image4j.codec.ico.ICODecoder;
import com.fr.stable.project.ProjectConstants; import com.fr.stable.project.ProjectConstants;
import com.fr.workspace.WorkContext;
import com.fr.workspace.Workspace;
import javax.swing.Icon; import javax.swing.*;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JLayeredPane;
import javax.swing.JMenuBar;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.WindowConstants;
import javax.swing.border.MatteBorder; import javax.swing.border.MatteBorder;
import java.awt.BorderLayout; import java.awt.*;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Graphics;
import java.awt.Insets;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.Toolkit;
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.DnDConstants;
@ -664,15 +649,15 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
defaultTitleSB.append(" "); defaultTitleSB.append(" ");
// james:标识登录的用户和登录的ENV // james:标识登录的用户和登录的ENV
String envName = DesignerEnvManager.getEnvManager().getCurEnvName(); String envName = DesignerEnvManager.getEnvManager().getCurEnvName();
EnvConfig env = DesignerEnvManager.getEnvManager().getEnv(envName); Workspace workspace = WorkContext.getCurrent();
if (env != null) { if (workspace != null) {
defaultTitleSB.append(env.getDescription(envName)); defaultTitleSB.append(workspace.getDescription());
if (editingTemplate != null) { if (editingTemplate != null) {
String path = editingTemplate.getEditingFILE().getPath(); String path = editingTemplate.getEditingFILE().getPath();
if (!editingTemplate.getEditingFILE().exists()) { if (!editingTemplate.getEditingFILE().exists()) {
path = FILEFactory.MEM_PREFIX + path; path = FILEFactory.MEM_PREFIX + path;
} else if (path.startsWith(ProjectConstants.REPORTLETS_NAME)) { } else if (path.startsWith(ProjectConstants.REPORTLETS_NAME)) {
path = env.getPath() + File.separator + path; path = workspace.getPath() + File.separator + path;
} }
defaultTitleSB.append(" " + path); defaultTitleSB.append(" " + path);
} }
@ -850,18 +835,18 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
*/ */
public void openTemplate(FILE tplFile) { public void openTemplate(FILE tplFile) {
// 测试连接,如果连接失败,则提示 // 测试连接,如果连接失败,则提示
try { // try {
if (FRContext.getCurrentEnv() != null // if (FRContext.getCommonOperator() != null
&& !FRContext.getCurrentEnv().testServerConnectionWithOutShowMessagePane()) { // && !FRContext.getCommonOperator().testServerConnectionWithOutShowMessagePane()) {
JOptionPane.showMessageDialog( // JOptionPane.showMessageDialog(
DesignerContext.getDesignerFrame(), // DesignerContext.getDesignerFrame(),
Inter.getLocText(new String[]{"FR-Chart-Server_disconnected", "FR-Server-Design_template_unopened"}, new String[]{ // Inter.getLocText(new String[]{"FR-Chart-Server_disconnected", "FR-Server-Design_template_unopened"}, new String[]{
",", "!"}), Inter.getLocText("FR-Server-All_Error"), JOptionPane.ERROR_MESSAGE); // ",", "!"}), Inter.getLocText("FR-Server-All_Error"), JOptionPane.ERROR_MESSAGE);
return; // return;
} // }
} catch (Exception e) { // } catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage()); // FineLoggerFactory.getLogger().error(e.getMessage());
} // }
// p:判断一下,如何文件为空或者文件不存在,直接返回. // p:判断一下,如何文件为空或者文件不存在,直接返回.
if (tplFile == null || !tplFile.exists()) { if (tplFile == null || !tplFile.exists()) {
@ -993,7 +978,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
DesignerEnvManager.getEnvManager().saveXMLFile(); DesignerEnvManager.getEnvManager().saveXMLFile();
EnvUpdater.disconnect(); WorkContext.switchTo(null);
this.setVisible(false); this.setVisible(false);
this.dispose(); this.dispose();

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

@ -37,19 +37,10 @@ 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;
import javax.swing.BorderFactory; import javax.swing.*;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener; import javax.swing.event.DocumentListener;
import java.awt.BorderLayout; import java.awt.*;
import java.awt.CardLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.GridLayout;
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.KeyAdapter;
@ -59,19 +50,27 @@ import java.util.Map;
import java.util.Set; import java.util.Set;
public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarStateChangeListener, ResponseDataSourceChange { public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarStateChangeListener, ResponseDataSourceChange {
private static final String FILE = "file"; private static final String FILE = "file";
private static DesignerFrameFileDealerPane THIS; private static DesignerFrameFileDealerPane THIS;
private CardLayout card; private CardLayout card;
private JPanel cardPane; private JPanel cardPane;
private FileOperations selectedOperation; private FileOperations selectedOperation;
private UIToolbar toolBar; private UIToolbar toolBar;
private OpenReportAction openReportAction = new OpenReportAction(); private OpenReportAction openReportAction = new OpenReportAction();
private RefreshTreeAction refreshTreeAction = new RefreshTreeAction(); private RefreshTreeAction refreshTreeAction = new RefreshTreeAction();
private OpenFolderAction openFolderAction = new OpenFolderAction(); private OpenFolderAction openFolderAction = new OpenFolderAction();
private RenameAction renameAction = new RenameAction(); private RenameAction renameAction = new RenameAction();
private DelFileAction delFileAction = new DelFileAction(); private DelFileAction delFileAction = new DelFileAction();
@ -79,10 +78,12 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
* 刷新 * 刷新
*/ */
public void refresh() { public void refresh() {
selectedOperation.refresh(); selectedOperation.refresh();
} }
public static final DesignerFrameFileDealerPane getInstance() { public static final DesignerFrameFileDealerPane getInstance() {
if (THIS == null) { if (THIS == null) {
THIS = new DesignerFrameFileDealerPane(); THIS = new DesignerFrameFileDealerPane();
} }
@ -90,6 +91,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
} }
private DesignerFrameFileDealerPane() { private DesignerFrameFileDealerPane() {
setLayout(new BorderLayout()); setLayout(new BorderLayout());
toolBar = ToolBarDef.createJToolBar(); toolBar = ToolBarDef.createJToolBar();
toolBar.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, UIConstants.TOOLBAR_BORDER_COLOR)); toolBar.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, UIConstants.TOOLBAR_BORDER_COLOR));
@ -116,6 +118,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
public final void setCurrentEditingTemplate(JTemplate<?, ?> jt) { public final void setCurrentEditingTemplate(JTemplate<?, ?> jt) {
DesignModelAdapter.setCurrentModelAdapter(jt == null ? null : jt.getModel()); DesignModelAdapter.setCurrentModelAdapter(jt == null ? null : jt.getModel());
fireDSChanged(); fireDSChanged();
TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter()); TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter());
@ -139,12 +142,13 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
* 刷新菜单 * 刷新菜单
*/ */
public void refreshDockingView() { public void refreshDockingView() {
ToolBarDef toolbarDef = new ToolBarDef(); ToolBarDef toolbarDef = new ToolBarDef();
toolbarDef.addShortCut(openReportAction, refreshTreeAction); toolbarDef.addShortCut(openReportAction, refreshTreeAction);
toolbarDef.addShortCut(openFolderAction, renameAction); toolbarDef.addShortCut(openFolderAction, renameAction);
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);
} }
@ -154,6 +158,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
private void refreshActions() { private void refreshActions() {
openReportAction.setEnabled(false); openReportAction.setEnabled(false);
refreshTreeAction.setEnabled(true); refreshTreeAction.setEnabled(true);
openFolderAction.setEnabled(false); openFolderAction.setEnabled(false);
@ -166,14 +171,17 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
* 响应数据集改变 * 响应数据集改变
*/ */
public void fireDSChanged() { public void fireDSChanged() {
fireDSChanged(new HashMap<String, String>()); fireDSChanged(new HashMap<String, String>());
} }
/** /**
* 响应数据集改变 * 响应数据集改变
*
* @param map 改变名字的数据集 * @param map 改变名字的数据集
*/ */
public void fireDSChanged(Map<String, String> map) { public void fireDSChanged(Map<String, String> map) {
DesignTableDataManager.fireDSChanged(map); DesignTableDataManager.fireDSChanged(map);
} }
@ -184,12 +192,14 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
private class OpenReportAction extends UpdateAction { private class OpenReportAction extends UpdateAction {
public OpenReportAction() { public OpenReportAction() {
this.setName(KeySetUtils.OPEN_TEMPLATE.getMenuKeySetName()); this.setName(KeySetUtils.OPEN_TEMPLATE.getMenuKeySetName());
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/buttonicon/open.png")); this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/buttonicon/open.png"));
} }
@Override @Override
public void actionPerformed(ActionEvent evt) { public void actionPerformed(ActionEvent evt) {
selectedOperation.openSelectedReport(); selectedOperation.openSelectedReport();
} }
@ -198,12 +208,14 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
private class OpenFolderAction extends UpdateAction { private class OpenFolderAction extends UpdateAction {
public OpenFolderAction() { public OpenFolderAction() {
this.setName(Inter.getLocText("FR-Designer_Show_in_Containing_Folder")); this.setName(Inter.getLocText("FR-Designer_Show_in_Containing_Folder"));
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_file/view_folder.png")); this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_file/view_folder.png"));
} }
@Override @Override
public void actionPerformed(ActionEvent evt) { public void actionPerformed(ActionEvent evt) {
selectedOperation.openContainerFolder(); selectedOperation.openContainerFolder();
} }
} }
@ -214,12 +226,14 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
private class RefreshTreeAction extends UpdateAction { private class RefreshTreeAction extends UpdateAction {
public RefreshTreeAction() { public RefreshTreeAction() {
this.setName(Inter.getLocText("FR-Designer_Refresh")); this.setName(Inter.getLocText("FR-Designer_Refresh"));
this.setSmallIcon(UIConstants.REFRESH_ICON); this.setSmallIcon(UIConstants.REFRESH_ICON);
} }
@Override @Override
public void actionPerformed(ActionEvent evt) { public void actionPerformed(ActionEvent evt) {
selectedOperation.refresh(); selectedOperation.refresh();
stateChange(); stateChange();
} }
@ -231,12 +245,14 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
private class RenameAction extends UpdateAction { private class RenameAction extends UpdateAction {
public RenameAction() { public RenameAction() {
this.setName(Inter.getLocText("FR-Designer_Rename")); this.setName(Inter.getLocText("FR-Designer_Rename"));
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/data/source/rename.png")); this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/data/source/rename.png"));
} }
@Override @Override
public void actionPerformed(ActionEvent evt) { public void actionPerformed(ActionEvent evt) {
new RenameDialog(); new RenameDialog();
MutilTempalteTabPane.getInstance().repaint(); MutilTempalteTabPane.getInstance().repaint();
} }
@ -249,12 +265,14 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
private class DelFileAction extends UpdateAction { private class DelFileAction extends UpdateAction {
public DelFileAction() { public DelFileAction() {
this.setName(Inter.getLocText("FR-Designer_Remove")); this.setName(Inter.getLocText("FR-Designer_Remove"));
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/data/source/delete.png")); this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/data/source/delete.png"));
} }
@Override @Override
public void actionPerformed(ActionEvent evt) { public void actionPerformed(ActionEvent evt) {
selectedOperation.deleteFile(); selectedOperation.deleteFile();
} }
} }
@ -264,9 +282,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
*/ */
@Override @Override
public void stateChange() { public void stateChange() {
//当前环境为远程环境时
if (FRContext.getCurrentEnv() != null) {
//当前环境为本地环境时
if (selectedOperation.getSelectedTemplatePath() != null) { if (selectedOperation.getSelectedTemplatePath() != null) {
openReportAction.setEnabled(true); openReportAction.setEnabled(true);
renameAction.setEnabled(true); renameAction.setEnabled(true);
@ -277,7 +293,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
delFileAction.setEnabled(false); delFileAction.setEnabled(false);
} }
openFolderAction.setEnabled(containsFolderNums() + seletedTemplateNums() != 0); openFolderAction.setEnabled(containsFolderNums() + seletedTemplateNums() != 0);
}
refreshTreeAction.setEnabled(true); refreshTreeAction.setEnabled(true);
if (containsFolderNums() > 0 && (containsFolderNums() + seletedTemplateNums() > 1)) { if (containsFolderNums() > 0 && (containsFolderNums() + seletedTemplateNums() > 1)) {
refreshActions(); refreshActions();
@ -298,6 +314,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
*/ */
private int containsFolderNums() { private int containsFolderNums() {
TemplateFileTree fileTree = TemplateTreePane.getInstance().getTemplateFileTree(); TemplateFileTree fileTree = TemplateTreePane.getInstance().getTemplateFileTree();
if (fileTree.getSelectionPaths() == null) { if (fileTree.getSelectionPaths() == null) {
return 0; return 0;
@ -317,6 +334,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
* @return * @return
*/ */
private int seletedTemplateNums() { private int seletedTemplateNums() {
TemplateFileTree fileTree = TemplateTreePane.getInstance().getTemplateFileTree(); TemplateFileTree fileTree = TemplateTreePane.getInstance().getTemplateFileTree();
if (fileTree.getSelectionPaths() == null) { if (fileTree.getSelectionPaths() == null) {
return 0; return 0;
@ -330,14 +348,21 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
private class RenameDialog { private class RenameDialog {
private UITextField jt; private UITextField jt;
private String userInput; private String userInput;
private String oldName; private String oldName;
private UILabel hintsLabel; private UILabel hintsLabel;
private UIButton confirmButton; private UIButton confirmButton;
private JDialog jd; private JDialog jd;
private String suffix; private String suffix;
public RenameDialog() { public RenameDialog() {
final String reportPath = selectedOperation.getSelectedTemplatePath(); final String reportPath = selectedOperation.getSelectedTemplatePath();
if (reportPath == null) { if (reportPath == null) {
return; return;
@ -391,7 +416,9 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
confirmButton.setMinimumSize(new Dimension(80, 25)); confirmButton.setMinimumSize(new Dimension(80, 25));
confirmButton.setMaximumSize(new Dimension(80, 25)); confirmButton.setMaximumSize(new Dimension(80, 25));
confirmButton.addActionListener(new ActionListener() { confirmButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
confirmClose(nodeFile, path); confirmClose(nodeFile, path);
} }
}); });
@ -402,7 +429,9 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
cancelButton.setMaximumSize(new Dimension(80, 25)); cancelButton.setMaximumSize(new Dimension(80, 25));
cancelButton.addActionListener(new ActionListener() { cancelButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
jd.dispose(); jd.dispose();
} }
}); });
@ -432,6 +461,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
} }
public void confirmClose(FileNodeFILE nodeFile, String path) { public void confirmClose(FileNodeFILE nodeFile, String path) {
userInput = userInput == null ? oldName : userInput; userInput = userInput == null ? oldName : userInput;
String oldPath = path.replaceAll("/", "\\\\"); String oldPath = path.replaceAll("/", "\\\\");
String newPath = path.replace(nodeFile.getName(), userInput + suffix); String newPath = path.replace(nodeFile.getName(), userInput + suffix);
@ -446,6 +476,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
} }
private void renameTemplateInMemory(FILE tplFile, String newName, String oldName) { private void renameTemplateInMemory(FILE tplFile, String newName, String oldName) {
JTemplate<?, ?> dPane = getSpecialTemplateByFILE(tplFile); JTemplate<?, ?> dPane = getSpecialTemplateByFILE(tplFile);
if (dPane == null) { if (dPane == null) {
return; return;
@ -458,7 +489,9 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
public void addUITextFieldListener(final FileNodeFILE nodeFile, final String path) { public void addUITextFieldListener(final FileNodeFILE nodeFile, final String path) {
jt.addKeyListener(new KeyAdapter() { jt.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent e) { public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
jd.dispose(); jd.dispose();
} }
@ -466,7 +499,9 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
}); });
jt.addKeyListener(new KeyAdapter() { jt.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent e) { public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ENTER) { if (e.getKeyCode() == KeyEvent.VK_ENTER) {
if (confirmButton.isEnabled()) { if (confirmButton.isEnabled()) {
confirmClose(nodeFile, path); confirmClose(nodeFile, path);
@ -479,17 +514,21 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
// UITextField的输入监听 // UITextField的输入监听
public DocumentListener getdoDocumentListener() { public DocumentListener getdoDocumentListener() {
DocumentListener dl = new DocumentListener() { DocumentListener dl = new DocumentListener() {
public void changedUpdate(DocumentEvent e) { public void changedUpdate(DocumentEvent e) {
isNameAlreadyExist(); isNameAlreadyExist();
} }
public void insertUpdate(DocumentEvent e) { public void insertUpdate(DocumentEvent e) {
isNameAlreadyExist(); isNameAlreadyExist();
} }
public void removeUpdate(DocumentEvent e) { public void removeUpdate(DocumentEvent e) {
isNameAlreadyExist(); isNameAlreadyExist();
} }
}; };
@ -498,6 +537,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
} }
private void isNameAlreadyExist() { private void isNameAlreadyExist() {
userInput = jt.getText().trim(); userInput = jt.getText().trim();
if (selectedOperation.isNameAlreadyExist(userInput, oldName, suffix)) { if (selectedOperation.isNameAlreadyExist(userInput, oldName, suffix)) {
jt.selectAll(); jt.selectAll();
@ -517,6 +557,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
* @return 内存中的template重命名一下 * @return 内存中的template重命名一下
*/ */
private JTemplate<?, ?> getSpecialTemplateByFILE(FILE tplFile) { private JTemplate<?, ?> getSpecialTemplateByFILE(FILE tplFile) {
HistoryTemplateListPane historyHandle = HistoryTemplateListPane.getInstance(); HistoryTemplateListPane historyHandle = HistoryTemplateListPane.getInstance();
if (ComparatorUtils.equals(historyHandle.getCurrentEditingTemplate().getEditingFILE(), tplFile)) { if (ComparatorUtils.equals(historyHandle.getCurrentEditingTemplate().getEditingFILE(), tplFile)) {
return historyHandle.getCurrentEditingTemplate(); return historyHandle.getCurrentEditingTemplate();

31
designer-base/src/com/fr/design/mainframe/JTemplate.java

@ -55,6 +55,7 @@ import com.fr.stable.ProductConstants;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.stable.core.UUID; import com.fr.stable.core.UUID;
import com.fr.stable.project.ProjectConstants; import com.fr.stable.project.ProjectConstants;
import com.fr.workspace.WorkContext;
import javax.swing.*; import javax.swing.*;
import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.DefaultMutableTreeNode;
@ -522,18 +523,18 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
if (editingFILE == null) { if (editingFILE == null) {
return false; return false;
} }
//检查一下连接是否成功 // //检查一下连接是否成功
try { // try {
if (FRContext.getCurrentEnv() != null && !FRContext.getCurrentEnv().testServerConnectionWithOutShowMessagePane()) { // if (FRContext.getCommonOperator() != null && !FRContext.getCommonOperator().testServerConnectionWithOutShowMessagePane()) {
//连接不成功,提示 // //连接不成功,提示
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), // JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(),
Inter.getLocText(new String[]{"server_disconnected", "template_unsaved"}, new String[]{",", "!"}) // Inter.getLocText(new String[]{"server_disconnected", "template_unsaved"}, new String[]{",", "!"})
, Inter.getLocText("FR-Designer_Error"), JOptionPane.ERROR_MESSAGE); // , Inter.getLocText("FR-Designer_Error"), JOptionPane.ERROR_MESSAGE);
return false; // return false;
} // }
} catch (Exception e) { // } catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage()); // FineLoggerFactory.getLogger().error(e.getMessage());
} // }
// 检查一下editingFILE是不是已存在的文件,如果不存在则用saveAs // 检查一下editingFILE是不是已存在的文件,如果不存在则用saveAs
@ -543,7 +544,7 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
boolean access = false; boolean access = false;
try { try {
access = FRContext.getCurrentEnv().getOrganizationOperator().canAccess(this.getEditingFILE().getPath()); access = FRContext.getOrganizationOperator().canAccess(this.getEditingFILE().getPath());
} catch (Exception e) { } catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
} }
@ -593,7 +594,7 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
if (isOkOperation(chooseResult)) { if (isOkOperation(chooseResult)) {
boolean access = false; boolean access = false;
try { try {
access = FRContext.getCurrentEnv().getOrganizationOperator().canAccess(fileChooser.getSelectedFILE().getPath()); access = FRContext.getOrganizationOperator().canAccess(fileChooser.getSelectedFILE().getPath());
} catch (Exception e) { } catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
} }
@ -657,7 +658,7 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
try { try {
ByteArrayOutputStream out = new ByteArrayOutputStream(); ByteArrayOutputStream out = new ByteArrayOutputStream();
this.getTarget().export(out); this.getTarget().export(out);
FRContext.getCurrentEnv().getFileOperator().write(out.toByteArray(), editingFILE.getPath()); WorkContext.getWorkResource().write(editingFILE.getPath(), out.toByteArray());
} catch (Exception e) { } catch (Exception e) {
FRContext.getLogger().error(e.getMessage(), e); FRContext.getLogger().error(e.getMessage(), e);
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), e.getMessage(), "Save Error", JOptionPane.ERROR_MESSAGE); JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), e.getMessage(), "Save Error", JOptionPane.ERROR_MESSAGE);

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

@ -1,31 +1,24 @@
package com.fr.design.mainframe; package com.fr.design.mainframe;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.base.env.Callback;
import com.fr.base.env.EnvUpdater;
import com.fr.core.env.EnvConfig;
import com.fr.core.env.impl.LocalEnvConfig;
import com.fr.design.DesignModelAdapter; import com.fr.design.DesignModelAdapter;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.dialog.InformationWarnPane; import com.fr.design.env.DesignerWorkspaceGenerator;
import com.fr.design.env.EnvGenerator; import com.fr.design.env.DesignerWorkspaceInfo;
import com.fr.design.env.RemoteEnvConfig;
import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.file.TemplateTreePane; import com.fr.design.file.TemplateTreePane;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.utils.DesignUtils; import com.fr.design.utils.DesignUtils;
import com.fr.env.EnvListPane; import com.fr.env.EnvListPane;
import com.fr.env.RemoteEnv;
import com.fr.general.ComparatorUtils;
import com.fr.general.GeneralContext; import com.fr.general.GeneralContext;
import com.fr.general.IOUtils; import com.fr.general.IOUtils;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.stable.EnvChangedListener; import com.fr.stable.EnvChangedListener;
import com.fr.stable.ProductConstants; import com.fr.workspace.WorkContext;
import com.fr.stable.StringUtils; import com.fr.workspace.WorkContextCallback;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
@ -36,49 +29,63 @@ import java.awt.event.MouseListener;
//TODO: august TemplatePane和TemplateTreePane最好合并成一个类 //TODO: august TemplatePane和TemplateTreePane最好合并成一个类
public class TemplatePane extends JPanel implements MouseListener { public class TemplatePane extends JPanel implements MouseListener {
private static final long NUM = 1L; private static final long NUM = 1L;
private static int NUM200 = 200; private static int NUM200 = 200;
public static TemplatePane getInstance() { public static TemplatePane getInstance() {
return HOLDER.singleton; return HOLDER.singleton;
} }
private static class HOLDER { private static class HOLDER {
private static TemplatePane singleton = new TemplatePane(); private static TemplatePane singleton = new TemplatePane();
} }
private static final long serialVersionUID = 2108412478281713143L; private static final long serialVersionUID = 2108412478281713143L;
public static final int HEIGHT = 23;// 最好和日志的高度统一 用同一个变量 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 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 static javax.swing.Icon rightIcon = BaseUtils.readIcon("/com/fr/design/images/docking/right.png");
;
private boolean isExpanded = false; private boolean isExpanded = false;
private UIButton editButton; private UIButton editButton;
private UILabel envLabel; private UILabel envLabel;
private TemplatePane() { private TemplatePane() {
super(); super();
this.initComponents(); this.initComponents();
this.setFocusable(true); this.setFocusable(true);
this.addMouseListener(this); this.addMouseListener(this);
isExpanded = DesignerEnvManager.getEnvManager().isTemplateTreePaneExpanded(); isExpanded = DesignerEnvManager.getEnvManager().isTemplateTreePaneExpanded();
// TemplateTreePane.getInstance().setVisible(isExpanded); TemplateTreePane.getInstance().setVisible(isExpanded);
TemplateTreePane.getInstance().setVisible(true); TemplateTreePane.getInstance().setVisible(true);
} }
private void initComponents() { private void initComponents() {
GeneralContext.addEnvChangedListener(new EnvChangedListener() { GeneralContext.addEnvChangedListener(new EnvChangedListener() {
public void envChanged() { public void envChanged() {
setJLabel(DesignerEnvManager.getEnvManager().getCurEnvName()); setJLabel(DesignerEnvManager.getEnvManager().getCurEnvName());
} }
}); });
this.setLayout(new BorderLayout(25, 0)); this.setLayout(new BorderLayout(25, 0));
editButton = new UIButton(BaseUtils.readIcon("/com/fr/design/images/control/control-center2.png")) { editButton = new UIButton(BaseUtils.readIcon("/com/fr/design/images/control/control-center2.png")) {
private static final long serialVersionUID = NUM; private static final long serialVersionUID = NUM;
@Override @Override
public Point getToolTipLocation(MouseEvent event) { public Point getToolTipLocation(MouseEvent event) {
return new Point(25, 2); return new Point(25, 2);
} }
}; };
@ -90,7 +97,9 @@ public class TemplatePane extends JPanel implements MouseListener {
this.add(new UILabel(" "), BorderLayout.WEST); this.add(new UILabel(" "), BorderLayout.WEST);
this.add(editButton, BorderLayout.EAST); this.add(editButton, BorderLayout.EAST);
editButton.addActionListener(new ActionListener() { editButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) { public void actionPerformed(ActionEvent evt) {
editItems(); editItems();
} }
}); });
@ -106,23 +115,28 @@ public class TemplatePane extends JPanel implements MouseListener {
* @return 同上 * @return 同上
*/ */
public boolean IsExpanded() { public boolean IsExpanded() {
return this.isExpanded; return this.isExpanded;
} }
public void setExpand(boolean b) { public void setExpand(boolean b) {
this.isExpanded = b; this.isExpanded = b;
this.repaint(); this.repaint();
} }
private boolean envListOkAction(EnvListPane envListPane) { private boolean envListOkAction(EnvListPane envListPane) {
final String selectedName = envListPane.updateEnvManager(); final String selectedName = envListPane.updateEnvManager();
DesignerEnvManager envManager = DesignerEnvManager.getEnvManager(); DesignerEnvManager envManager = DesignerEnvManager.getEnvManager();
EnvConfig selectedEnv = envManager.getEnv(selectedName); DesignerWorkspaceInfo selectedEnv = envManager.getWorkspaceInfo(selectedName);
GeneralContext.fireEnvWillChangeListener(); GeneralContext.fireEnvWillChangeListener();
try { try {
EnvUpdater.updateEnv(EnvGenerator.generate(selectedEnv), new Callback() { WorkContext.switchTo(DesignerWorkspaceGenerator.generate(selectedEnv), new WorkContextCallback() {
@Override @Override
public void fail() { public void fail() {
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Inter.getLocText(new String[]{"M-SwitchWorkspace", "Failed"})); JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Inter.getLocText(new String[]{"M-SwitchWorkspace", "Failed"}));
} }
@ -149,25 +163,24 @@ public class TemplatePane extends JPanel implements MouseListener {
return true; return true;
} }
private String getDesignerVersion(EnvConfig selectedEnv) {
// return selectedEnv.getDesignerVersion();
throw new UnsupportedOperationException("unsupport now");
}
/** /**
* 编辑items * 编辑items
*/ */
public void editItems() { public void editItems() {
final EnvListPane envListPane = new EnvListPane(); final EnvListPane envListPane = new EnvListPane();
final BasicDialog envListDialog = envListPane.showWindow(SwingUtilities.getWindowAncestor(DesignerContext.getDesignerFrame())); final BasicDialog envListDialog = envListPane.showWindow(SwingUtilities.getWindowAncestor(DesignerContext.getDesignerFrame()));
envListPane.populateEnvManager(envLabel.getText()); envListPane.populateEnvManager(envLabel.getText());
envListDialog.addDialogActionListener(new DialogActionAdapter() { envListDialog.addDialogActionListener(new DialogActionAdapter() {
public void doOk() { public void doOk() {
envListOkAction(envListPane); envListOkAction(envListPane);
} }
public void doCancel() { public void doCancel() {
envListDialog.setVisible(false); envListDialog.setVisible(false);
} }
}); });
@ -175,29 +188,40 @@ public class TemplatePane extends JPanel implements MouseListener {
} }
private void setJLabel(String name) { private void setJLabel(String name) {
EnvConfig config = DesignerEnvManager.getEnvManager().getEnv(name);
if (config instanceof LocalEnvConfig) {
envLabel.setIcon(IOUtils.readIcon("com/fr/design/images/data/bind/localconnect.png"));
} else if (config instanceof RemoteEnvConfig) { DesignerWorkspaceInfo config = DesignerEnvManager.getEnvManager().getWorkspaceInfo(name);
if (config != null) {
switch (config.getType()) {
case Remote: {
envLabel.setIcon(IOUtils.readIcon("com/fr/design/images/data/bind/localconnect.png"));
break;
}
case Local: {
envLabel.setIcon(IOUtils.readIcon("com/fr/design/images/data/bind/distanceconnect.png")); envLabel.setIcon(IOUtils.readIcon("com/fr/design/images/data/bind/distanceconnect.png"));
break;
} }
}
}
envLabel.setText(name); envLabel.setText(name);
envLabel.repaint(); envLabel.repaint();
} }
@Override @Override
public Dimension getPreferredSize() { public Dimension getPreferredSize() {
return new Dimension(250, HEIGHT); return new Dimension(250, HEIGHT);
} }
@Override @Override
public void paintComponent(Graphics g) { public void paintComponent(Graphics g) {
super.paintComponent(g); super.paintComponent(g);
paintBackgroundIcon(g); paintBackgroundIcon(g);
} }
private void paintBackgroundIcon(Graphics g) { private void paintBackgroundIcon(Graphics g) {
int w = this.getWidth(); int w = this.getWidth();
int h = this.getHeight(); int h = this.getHeight();
Graphics2D g2d = (Graphics2D) g; Graphics2D g2d = (Graphics2D) g;
@ -222,6 +246,7 @@ public class TemplatePane extends JPanel implements MouseListener {
*/ */
@Override @Override
public void mouseClicked(MouseEvent e) { public void mouseClicked(MouseEvent e) {
} }
/** /**
@ -231,6 +256,7 @@ public class TemplatePane extends JPanel implements MouseListener {
*/ */
@Override @Override
public void mousePressed(MouseEvent e) { public void mousePressed(MouseEvent e) {
if (e.getX() < NUM200) { if (e.getX() < NUM200) {
isExpanded = !isExpanded; isExpanded = !isExpanded;
TemplateTreePane.getInstance().setVisible(isExpanded); TemplateTreePane.getInstance().setVisible(isExpanded);
@ -246,6 +272,7 @@ public class TemplatePane extends JPanel implements MouseListener {
*/ */
@Override @Override
public void mouseReleased(MouseEvent e) { public void mouseReleased(MouseEvent e) {
} }
/** /**
@ -255,6 +282,7 @@ public class TemplatePane extends JPanel implements MouseListener {
*/ */
@Override @Override
public void mouseEntered(MouseEvent e) { public void mouseEntered(MouseEvent e) {
} }
/** /**
@ -264,17 +292,21 @@ public class TemplatePane extends JPanel implements MouseListener {
*/ */
@Override @Override
public void mouseExited(MouseEvent e) { public void mouseExited(MouseEvent e) {
} }
/** /**
* 处理异常 * 处理异常
*/ */
public void dealEvnExceptionWhenStartDesigner() { public void dealEvnExceptionWhenStartDesigner() {
final EnvListPane envListPane = new EnvListPane(); final EnvListPane envListPane = new EnvListPane();
envListPane.populateEnvManager(envLabel.getText()); envListPane.populateEnvManager(envLabel.getText());
BasicDialog envListDialog = envListPane.showWindow(SwingUtilities.getWindowAncestor(DesignerContext.getDesignerFrame())); BasicDialog envListDialog = envListPane.showWindow(SwingUtilities.getWindowAncestor(DesignerContext.getDesignerFrame()));
envListDialog.addDialogActionListener(new DialogActionAdapter() { envListDialog.addDialogActionListener(new DialogActionAdapter() {
public void doOk() { public void doOk() {
if (!envListOkAction(envListPane)) { if (!envListOkAction(envListPane)) {
System.exit(0); System.exit(0);
} }
@ -282,6 +314,7 @@ public class TemplatePane extends JPanel implements MouseListener {
} }
public void doCancel() { public void doCancel() {
System.exit(0); System.exit(0);
} }
}); });

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

@ -1,18 +1,6 @@
package com.fr.design.mainframe.loghandler.socketio; package com.fr.design.mainframe.loghandler.socketio;
import com.fr.base.Env;
import com.fr.base.FRContext;
import com.fr.config.ConfigEvent;
import com.fr.config.Configuration;
import com.fr.core.env.EnvConfig;
import com.fr.core.env.EnvConstants;
import com.fr.core.env.EnvContext;
import com.fr.core.env.EnvEvent;
import com.fr.core.env.impl.LocalEnvConfig;
import com.fr.decision.webservice.utils.DecisionServiceConstants;
import com.fr.design.env.RemoteEnvConfig;
import com.fr.design.mainframe.loghandler.DesignerLogHandler; import com.fr.design.mainframe.loghandler.DesignerLogHandler;
import com.fr.env.RemoteEnv;
import com.fr.event.Event; import com.fr.event.Event;
import com.fr.event.EventDispatcher; import com.fr.event.EventDispatcher;
import com.fr.event.Listener; import com.fr.event.Listener;
@ -20,14 +8,13 @@ import com.fr.general.LogRecordTime;
import com.fr.general.LogUtils; import com.fr.general.LogUtils;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.third.guava.base.Optional; import com.fr.third.guava.base.Optional;
import com.fr.web.WebSocketConfig; import com.fr.workspace.WorkContext;
import io.socket.client.IO; import com.fr.workspace.Workspace;
import com.fr.workspace.WorkspaceEvent;
import io.socket.client.Socket; import io.socket.client.Socket;
import io.socket.emitter.Emitter; import io.socket.emitter.Emitter;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.net.URI;
import java.net.URL;
public class DesignerSocketIO { public class DesignerSocketIO {
@ -48,18 +35,18 @@ public class DesignerSocketIO {
}; };
static { static {
EventDispatcher.listen(EnvEvent.AFTER_SIGN_OUT, new Listener<EnvConfig>() { EventDispatcher.listen(WorkspaceEvent.BeforeSwitch, new Listener<Workspace>() {
@Override @Override
public void on(Event event, EnvConfig param) { public void on(Event event, Workspace param) {
if (socketIO.isPresent()) { if (socketIO.isPresent()) {
socketIO.get().close(); socketIO.get().close();
socketIO = Optional.absent(); socketIO = Optional.absent();
} }
} }
}); });
EventDispatcher.listen(EnvEvent.AFTER_SIGN_IN, new Listener<EnvConfig>() { EventDispatcher.listen(WorkspaceEvent.AfterSwitch, new Listener<Workspace>() {
@Override @Override
public void on(Event event, EnvConfig param) { public void on(Event event, Workspace param) {
updateSocket(); updateSocket();
} }
}); });
@ -70,21 +57,21 @@ public class DesignerSocketIO {
} }
private static void updateSocket() { private static void updateSocket() {
Env env = FRContext.getCurrentEnv();
if (env.isLocalEnv()) { if (WorkContext.getCurrent().isLocal()) {
return; return;
} }
try { try {
RemoteEnvConfig config = ((RemoteEnv)env).getEnvConfig(); // RemoteEnvConfig config = ((RemoteEnv)env).getEnvConfig();
String uri = String.format("http://%s:%s%s?%s=%s", // String uri = String.format("http://%s:%s%s?%s=%s",
config.getHost(), // config.getHost(),
WebSocketConfig.getInstance().getPort(), // WebSocketConfig.getInstance().getPort(),
EnvConstants.WS_NAMESPACE, // EnvConstants.WS_NAMESPACE,
DecisionServiceConstants.WEB_SOCKET_TOKEN_NAME, // DecisionServiceConstants.WEB_SOCKET_TOKEN_NAME,
EnvContext.currentToken()); // EnvContext.currentToken());
//
socketIO = Optional.of(IO.socket(new URI(uri))); // socketIO = Optional.of(IO.socket(new URI(uri)));
socketIO.get().on(EnvConstants.WS_LOGRECORD, printLog); // socketIO.get().on(EnvConstants.WS_LOGRECORD, printLog);
// socketIO.get().on(EnvConstants.CONFIG, new Emitter.Listener() { // socketIO.get().on(EnvConstants.CONFIG, new Emitter.Listener() {
// @Override // @Override
// public void call(Object... objects) { // public void call(Object... objects) {
@ -97,7 +84,7 @@ public class DesignerSocketIO {
// } // }
// } // }
// }); // });
socketIO.get().connect(); // socketIO.get().connect();
} catch (Exception e) { } catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
} }

7
designer-base/src/com/fr/design/mainframe/templateinfo/TemplateInfoCollector.java

@ -7,14 +7,13 @@ import com.fr.design.DesignerEnvManager;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.JTemplate;
import com.fr.design.mainframe.SiteCenterToken; import com.fr.design.mainframe.SiteCenterToken;
import com.fr.env.RemoteEnv;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.general.GeneralUtils; import com.fr.general.GeneralUtils;
import com.fr.general.IOUtils; import com.fr.general.IOUtils;
import com.fr.general.SiteCenter; import com.fr.general.SiteCenter;
import com.fr.general.http.HttpClient; import com.fr.general.http.HttpClient;
import com.fr.json.JSONObject; import com.fr.json.JSONObject;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.EncodeConstants; import com.fr.stable.EncodeConstants;
import com.fr.stable.ProductConstants; import com.fr.stable.ProductConstants;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
@ -25,6 +24,7 @@ import com.fr.stable.xml.XMLTools;
import com.fr.stable.xml.XMLWriter; import com.fr.stable.xml.XMLWriter;
import com.fr.stable.xml.XMLableReader; import com.fr.stable.xml.XMLableReader;
import com.fr.third.javax.xml.stream.XMLStreamException; import com.fr.third.javax.xml.stream.XMLStreamException;
import com.fr.workspace.WorkContext;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.File; import java.io.File;
@ -167,7 +167,8 @@ public class TemplateInfoCollector<T extends BaseBook> implements Serializable,
} }
private boolean shouldCollectInfo() { private boolean shouldCollectInfo() {
if (FRContext.getCurrentEnv() instanceof RemoteEnv) { // 远程设计不收集数据 //只收集本地环境的
if (!WorkContext.getCurrent().isLocal()) {
return false; return false;
} }
return DesignerEnvManager.getEnvManager().isJoinProductImprove() && FRContext.isChineseEnv(); return DesignerEnvManager.getEnvManager().isJoinProductImprove() && FRContext.isChineseEnv();

26
designer-base/src/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java

@ -48,7 +48,6 @@ import com.fr.design.menu.ShortCut;
import com.fr.design.menu.ToolBarDef; import com.fr.design.menu.ToolBarDef;
import com.fr.design.remote.action.RemoteDesignAuthorityManagerAction; import com.fr.design.remote.action.RemoteDesignAuthorityManagerAction;
import com.fr.design.utils.ThemeUtils; import com.fr.design.utils.ThemeUtils;
import com.fr.env.RemoteEnv;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.GeneralContext; import com.fr.general.GeneralContext;
import com.fr.general.Inter; import com.fr.general.Inter;
@ -60,19 +59,10 @@ import com.fr.plugin.observer.PluginEventListener;
import com.fr.plugin.observer.PluginEventType; import com.fr.plugin.observer.PluginEventType;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.workspace.WorkContext;
import javax.swing.Icon; import javax.swing.*;
import javax.swing.JComponent; import java.awt.*;
import javax.swing.JMenuBar;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import javax.swing.UIManager;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
@ -227,7 +217,7 @@ public abstract class ToolBarMenuDock {
menuList.addAll(Arrays.asList(menuDefs)); menuList.addAll(Arrays.asList(menuDefs));
// 添加服务器菜单 // 添加服务器菜单
if (FRContext.getCurrentEnv() != null && FRContext.getCurrentEnv().isRoot()) { if (WorkContext.getCurrent() != null && WorkContext.getCurrent().isRoot()) {
menuList.add(createServerMenuDef(plus)); menuList.add(createServerMenuDef(plus));
} }
@ -444,11 +434,13 @@ public abstract class ToolBarMenuDock {
} }
private boolean shouldShowRemotePermission() { private boolean shouldShowRemotePermission() {
return FRContext.getCurrentEnv() != null && !FRContext.getCurrentEnv().isLocalEnv() && FRContext.getCurrentEnv().isRoot();
return WorkContext.getCurrent() != null && !WorkContext.getCurrent().isLocal() && WorkContext.getCurrent().isRoot();
} }
protected boolean shouldShowPlugin() { private boolean shouldShowPlugin() {
return !(FRContext.getCurrentEnv() instanceof RemoteEnv) && FRContext.isChineseEnv();
return !(WorkContext.getCurrent().isLocal()) && FRContext.isChineseEnv();
} }
/** /**

2
designer-base/src/com/fr/design/parameter/ParameterManagerPane.java

@ -39,7 +39,7 @@ public class ParameterManagerPane extends BasicPane {
public void populate(Parameter[] parameters) { public void populate(Parameter[] parameters) {
//todo 原来界面上显示的xml路径 //todo 原来界面上显示的xml路径
// this.parameterTextField.setText(FRContext.getCurrentEnv().getPath() + File.separator + // this.parameterTextField.setText(WorkContext.getCurrent().getPath() + File.separator +
// ProjectConstants.RESOURCES_NAME + // ProjectConstants.RESOURCES_NAME +
// File.separator + configManager.fileName()); // File.separator + configManager.fileName());
this.parameterArrayPane.populate(parameters); this.parameterArrayPane.populate(parameters);

16
designer-base/src/com/fr/design/remote/action/RemoteDesignAuthorityManagerAction.java

@ -1,8 +1,6 @@
package com.fr.design.remote.action; package com.fr.design.remote.action;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.base.FRContext;
import com.fr.core.env.proxy.EnvProxy;
import com.fr.design.actions.UpdateAction; import com.fr.design.actions.UpdateAction;
import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.dialog.DialogActionAdapter;
@ -12,6 +10,7 @@ import com.fr.env.operator.authority.AuthorityOperator;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.report.DesignAuthority; import com.fr.report.DesignAuthority;
import com.fr.workspace.WorkContext;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
@ -34,10 +33,10 @@ public class RemoteDesignAuthorityManagerAction extends UpdateAction {
BasicDialog dialog = managerPane.showWindow(DesignerContext.getDesignerFrame()); BasicDialog dialog = managerPane.showWindow(DesignerContext.getDesignerFrame());
if (!FRContext.getCurrentEnv().isLocalEnv()) { if (!WorkContext.getCurrent().isLocal()) {
try { try {
// 远程设计获取全部设计成员的权限列表 // 远程设计获取全部设计成员的权限列表
DesignAuthority[] authorities = EnvProxy.get(AuthorityOperator.class).getAuthorities(); DesignAuthority[] authorities = WorkContext.getCurrent().get(AuthorityOperator.class).getAuthorities();
if (authorities != null && authorities.length != 0) { if (authorities != null && authorities.length != 0) {
managerPane.populate(authorities); managerPane.populate(authorities);
} }
@ -47,22 +46,25 @@ public class RemoteDesignAuthorityManagerAction extends UpdateAction {
} }
dialog.addDialogActionListener(new DialogActionAdapter() { dialog.addDialogActionListener(new DialogActionAdapter() {
@Override @Override
public void doOk() { public void doOk() {
DesignAuthority[] authorities = managerPane.update(); DesignAuthority[] authorities = managerPane.update();
if (!FRContext.getCurrentEnv().isLocalEnv()) { if (!WorkContext.getCurrent().isLocal()) {
boolean success = false; boolean success = false;
try { try {
success = EnvProxy.get(AuthorityOperator.class).updateAuthorities(authorities); success = WorkContext.getCurrent().get(AuthorityOperator.class).updateAuthorities(authorities);
} catch (Exception e) { } catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
} }
FRContext.getLogger().info("update remote design authority: " + success); FineLoggerFactory.getLogger().info("update remote design authority: " + success);
} }
} }
@Override @Override
public void doCancel() { public void doCancel() {
super.doCancel(); super.doCancel();
} }
}); });

7
designer-base/src/com/fr/design/remote/ui/AuthorityEditorPane.java

@ -1,6 +1,5 @@
package com.fr.design.remote.ui; package com.fr.design.remote.ui;
import com.fr.base.FRContext;
import com.fr.design.beans.BasicBeanPane; import com.fr.design.beans.BasicBeanPane;
import com.fr.design.border.UITitledBorder; import com.fr.design.border.UITitledBorder;
import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.icontainer.UIScrollPane;
@ -13,10 +12,10 @@ import com.fr.general.Inter;
import com.fr.report.DesignAuthority; import com.fr.report.DesignAuthority;
import com.fr.stable.CoreConstants; import com.fr.stable.CoreConstants;
import javax.swing.BorderFactory; import javax.swing.*;
import javax.swing.border.EmptyBorder; import javax.swing.border.EmptyBorder;
import javax.swing.tree.TreePath; import javax.swing.tree.TreePath;
import java.awt.BorderLayout; import java.awt.*;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -40,7 +39,7 @@ public class AuthorityEditorPane extends BasicBeanPane<DesignAuthority> {
tree.setDigIn(true); tree.setDigIn(true);
tree.setFileNodeFilter(filter); tree.setFileNodeFilter(filter);
this.add(new UIScrollPane(tree), BorderLayout.CENTER); this.add(new UIScrollPane(tree), BorderLayout.CENTER);
tree.refreshEnv(FRContext.getCurrentEnv()); tree.refreshEnv();
} }

8
designer-base/src/com/fr/design/remote/ui/UserManagerPane.java

@ -1,8 +1,5 @@
package com.fr.design.remote.ui; package com.fr.design.remote.ui;
import com.fr.core.env.EnvContext;
import com.fr.core.env.proxy.EnvProxy;
import com.fr.core.env.resource.EnvConfigUtils;
import com.fr.design.border.UITitledBorder; import com.fr.design.border.UITitledBorder;
import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.BasicPane;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
@ -21,6 +18,7 @@ import com.fr.env.operator.decision.DecisionOperator;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.third.guava.collect.ImmutableList; import com.fr.third.guava.collect.ImmutableList;
import com.fr.workspace.WorkContext;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.DefaultListModel; import javax.swing.DefaultListModel;
@ -281,8 +279,8 @@ public class UserManagerPane extends BasicPane {
@Override @Override
protected List<RemoteDesignMember> doInBackground() { protected List<RemoteDesignMember> doInBackground() {
addingMembers.clear(); addingMembers.clear();
String username = EnvConfigUtils.getUsername(EnvContext.currentEnv()); String username = WorkContext.getConnector().currentUser();
addingMembers.addAll(EnvProxy.get(DecisionOperator.class).getMembers(username, keyword)); addingMembers.addAll(WorkContext.getCurrent().get(DecisionOperator.class).getMembers(username, keyword));
return addingMembers; return addingMembers;
} }

2
designer-base/src/com/fr/design/roleAuthority/RoleDataWrapper.java

@ -1 +1 @@
package com.fr.design.roleAuthority; import com.fr.base.FRContext; import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode; import com.fr.design.gui.itree.refreshabletree.loader.ChildrenNodesLoader; import com.fr.general.Inter; import com.fr.log.FineLoggerFactory; import java.util.ArrayList; import java.util.Collections; import java.util.List; /** * 将权限细粒度的角色数据包装一下,区分报表平台管理角色和数据决策系统角色 * <p/> * Author : daisy * Date: 13-8-30 * Time: 下午3:42 */ public class RoleDataWrapper implements ChildrenNodesLoader { private List<String> rolelist = new ArrayList<String>(); private String roleTypename = null; public RoleDataWrapper(String roleName) { roleTypename = roleName; } /** * 在此计算并获得与管理类型相对应的 */ private void calculateRoleList() { try { Collections.addAll(rolelist, FRContext.getCurrentEnv().getOrganizationOperator().getRoleGroup()); } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); } } //加载所有的角色列表 public ExpandMutableTreeNode[] load() { calculateRoleList(); return this.load(this.rolelist); } //从workbook中读取的角色列表 public ExpandMutableTreeNode[] load(List<String> rolelist) { this.rolelist = rolelist; ExpandMutableTreeNode[] res = new ExpandMutableTreeNode[rolelist.size()]; for (int i = 0; i < res.length; i++) { res[i] = new ExpandMutableTreeNode(rolelist.get(i)); } return res; } public String getRoleTypename(){ return roleTypename; } } package com.fr.design.roleAuthority; import com.fr.base.FRContext; import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode; import com.fr.design.gui.itree.refreshabletree.loader.ChildrenNodesLoader; import com.fr.general.Inter; import com.fr.log.FineLoggerFactory; import java.util.ArrayList; import java.util.Collections; import java.util.List; /** * 将权限细粒度的角色数据包装一下,区分报表平台管理角色和数据决策系统角色 * <p/> * Author : daisy * Date: 13-8-30 * Time: 下午3:42 */ public class RoleDataWrapper implements ChildrenNodesLoader { private List<String> rolelist = new ArrayList<String>(); private String roleTypename = null; public RoleDataWrapper(String roleName) { roleTypename = roleName; } /** * 在此计算并获得与管理类型相对应的 */ private void calculateRoleList() { try { Collections.addAll(rolelist, FRContext.getOrganizationOperator().getRoleGroup()); } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); } } //加载所有的角色列表 public ExpandMutableTreeNode[] load() { calculateRoleList(); return this.load(this.rolelist); } //从workbook中读取的角色列表 public ExpandMutableTreeNode[] load(List<String> rolelist) { this.rolelist = rolelist; ExpandMutableTreeNode[] res = new ExpandMutableTreeNode[rolelist.size()]; for (int i = 0; i < res.length; i++) { res[i] = new ExpandMutableTreeNode(rolelist.get(i)); } return res; } public String getRoleTypename(){ return roleTypename; } }

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

@ -13,7 +13,6 @@ 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.env.RemoteEnv;
import com.fr.file.FileFILE; import com.fr.file.FileFILE;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.FRFont; import com.fr.general.FRFont;
@ -21,13 +20,13 @@ import com.fr.general.GeneralContext;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.general.http.HttpClient; import com.fr.general.http.HttpClient;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.security.JwtUtils;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
import com.fr.stable.CodeUtils; import com.fr.stable.CodeUtils;
import com.fr.stable.EncodeConstants; import com.fr.stable.EncodeConstants;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.start.ServerStarter; import com.fr.start.ServerStarter;
import com.fr.workspace.WorkContext;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
@ -47,7 +46,6 @@ import java.net.ServerSocket;
import java.net.Socket; import java.net.Socket;
import java.net.URI; import java.net.URI;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.util.Calendar;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.Locale; import java.util.Locale;
@ -300,17 +298,8 @@ public class DesignUtils {
} }
String postfixOfUri = (segs.length > 0 ? "?" + StableUtils.join(segs, "&") : StringUtils.EMPTY); String postfixOfUri = (segs.length > 0 ? "?" + StableUtils.join(segs, "&") : StringUtils.EMPTY);
if (FRContext.getCurrentEnv() instanceof RemoteEnv) { if (!WorkContext.getCurrent().isLocal()) {
try { try {
if (Utils.isEmbeddedParameter(postfixOfUri)) {
String time = Calendar.getInstance().getTime().toString().replaceAll(" ", "");
boolean isUserPrivilege = ((RemoteEnv) FRContext.getCurrentEnv()).writePrivilegeMap(time, postfixOfUri);
postfixOfUri = isUserPrivilege ? postfixOfUri + "&fr_check_url=" + time + "&id=" + FRContext.getCurrentEnv().getUserID() : postfixOfUri;
}
// 加参数给远程设计校验权限。
String design = JwtUtils.createDefaultJWT(FRContext.getCurrentEnv().getUser());
postfixOfUri = postfixOfUri + "&design=" + design;
String urlPath = getWebBrowserPath(); String urlPath = getWebBrowserPath();
Desktop.getDesktop().browse(new URI(urlPath + postfixOfUri)); Desktop.getDesktop().browse(new URI(urlPath + postfixOfUri));
} catch (Exception e) { } catch (Exception e) {
@ -330,7 +319,7 @@ public class DesignUtils {
} }
private static String getWebBrowserPath() { private static String getWebBrowserPath() {
String urlPath = FRContext.getCurrentEnv().getPath(); String urlPath = WorkContext.getCurrent().getPath();
DesignerEnvProcessor processor = ExtraDesignClassManager.getInstance().getSingle(DesignerEnvProcessor.XML_TAG); DesignerEnvProcessor processor = ExtraDesignClassManager.getInstance().getSingle(DesignerEnvProcessor.XML_TAG);
if (processor != null) { if (processor != null) {
//cas访问的时候, url要处理下. //cas访问的时候, url要处理下.

8
designer-base/src/com/fr/design/widget/IconDefinePane.java

@ -1,15 +1,13 @@
package com.fr.design.widget; package com.fr.design.widget;
import com.fr.base.Env; import com.fr.design.dialog.BasicDialog;
import com.fr.base.FRContext; import com.fr.design.dialog.BasicPane;
import com.fr.design.dialog.DialogActionAdapter;
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.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.web.CustomIconPane; import com.fr.design.web.CustomIconPane;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.BasicPane;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.form.ui.WidgetInfoConfig; import com.fr.form.ui.WidgetInfoConfig;
import com.fr.general.Inter; import com.fr.general.Inter;

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

@ -1,9 +1,9 @@
package com.fr.env; package com.fr.env;
import com.fr.core.env.EnvConfig;
import com.fr.core.env.impl.LocalEnvConfig;
import com.fr.design.env.RemoteEnvConfig;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.env.DesignerWorkspaceInfo;
import com.fr.design.env.LocalDesignerWorkspaceInfo;
import com.fr.design.env.RemoteDesignerWorkspaceInfo;
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;
@ -59,9 +59,9 @@ public class EnvListPane extends JListControlPane {
@Override @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",
LocalEnvConfig.class, LocalEnvPane.class); LocalDesignerWorkspaceInfo.class, LocalEnvPane.class);
NameableCreator remote = new NameObjectCreator(Inter.getLocText("Env-Remote_Server"), "com/fr/design/images/data/bind/distanceconnect.png", NameableCreator remote = new NameObjectCreator(Inter.getLocText("Env-Remote_Server"), "com/fr/design/images/data/bind/distanceconnect.png",
RemoteEnvConfig.class, RemoteEnvPane2.class); RemoteDesignerWorkspaceInfo.class, RemoteEnvPane.class);
return new NameableCreator[]{local, remote}; return new NameableCreator[]{local, remote};
} }
@ -81,7 +81,7 @@ public class EnvListPane extends JListControlPane {
List<NameObject> nameObjectList = new ArrayList<>(); List<NameObject> nameObjectList = new ArrayList<>();
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.getWorkspaceInfo(name)));
} }
this.populate(nameObjectList.toArray(new NameObject[0])); this.populate(nameObjectList.toArray(new NameObject[0]));
@ -104,8 +104,13 @@ public class EnvListPane extends JListControlPane {
Nameable[] res = this.update(); Nameable[] res = this.update();
for (Nameable re : res) { for (Nameable re : res) {
NameObject nameObject = (NameObject) re; NameObject nameObject = (NameObject) re;
mgr.putEnv(nameObject.getName(), (EnvConfig) nameObject.getObject()); mgr.putEnv(nameObject.getName(), (DesignerWorkspaceInfo) nameObject.getObject());
} }
return this.getSelectedName(); return this.getSelectedName();
} }
@Override
protected boolean filterNameableCreator(NameableCreator creator) {
return false;
}
} }

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

@ -1,7 +1,7 @@
package com.fr.env; package com.fr.env;
import com.fr.core.env.impl.LocalEnvConfig;
import com.fr.design.beans.BasicBeanPane; import com.fr.design.beans.BasicBeanPane;
import com.fr.design.env.LocalDesignerWorkspaceInfo;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itextarea.UITextArea; import com.fr.design.gui.itextarea.UITextArea;
import com.fr.design.gui.itextfield.UITextField; import com.fr.design.gui.itextfield.UITextField;
@ -21,7 +21,7 @@ import java.io.File;
/** /**
* @author yaohwu * @author yaohwu
*/ */
public class LocalEnvPane extends BasicBeanPane<LocalEnvConfig> { public class LocalEnvPane extends BasicBeanPane<LocalDesignerWorkspaceInfo> {
private UITextField pathTextField; private UITextField pathTextField;
private JFileTree localEnvTree; private JFileTree localEnvTree;
@ -70,9 +70,9 @@ public class LocalEnvPane extends BasicBeanPane<LocalEnvConfig> {
} }
@Override @Override
public LocalEnvConfig updateBean() { public LocalDesignerWorkspaceInfo updateBean() {
String path = pathTextField.getText(); String path = pathTextField.getText();
return new LocalEnvConfig(path); return LocalDesignerWorkspaceInfo.create(StringUtils.EMPTY, path);
} }
public String getPath() { public String getPath() {
@ -80,7 +80,7 @@ public class LocalEnvPane extends BasicBeanPane<LocalEnvConfig> {
} }
@Override @Override
public void populateBean(LocalEnvConfig ob) { public void populateBean(LocalDesignerWorkspaceInfo ob) {
if (StringUtils.isBlank(ob.getPath())) { if (StringUtils.isBlank(ob.getPath())) {
return; return;
} }

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

File diff suppressed because it is too large Load Diff

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

@ -1,12 +1,9 @@
package com.fr.env; package com.fr.env;
import com.fr.base.FRContext;
import com.fr.core.env.resource.EnvConfigUtils;
import com.fr.design.env.RemoteEnvConfig;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.beans.BasicBeanPane; import com.fr.design.beans.BasicBeanPane;
import com.fr.design.border.UITitledBorder; import com.fr.design.border.UITitledBorder;
import com.fr.design.dialog.InformationWarnPane; import com.fr.design.env.RemoteDesignerWorkspaceInfo;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
@ -15,18 +12,21 @@ import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayoutHelper; import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.scrollruler.ModLineBorder; import com.fr.design.scrollruler.ModLineBorder;
import com.fr.general.ComparatorUtils;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.stable.ProductConstants;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.third.guava.base.Strings;
import com.fr.workspace.WorkContext;
import com.fr.workspace.connect.WorkspaceConnection;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.JDialog;
import javax.swing.JFileChooser; import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.JTextPane; import javax.swing.JTextPane;
import javax.swing.SwingConstants; import javax.swing.SwingConstants;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
import javax.swing.SwingWorker;
import javax.swing.ToolTipManager; import javax.swing.ToolTipManager;
import javax.swing.UIManager; import javax.swing.UIManager;
import javax.swing.border.EmptyBorder; import javax.swing.border.EmptyBorder;
@ -35,6 +35,7 @@ import javax.swing.event.DocumentListener;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Color; import java.awt.Color;
import java.awt.Component; import java.awt.Component;
import java.awt.Dialog;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.FlowLayout; import java.awt.FlowLayout;
import java.awt.Toolkit; import java.awt.Toolkit;
@ -43,18 +44,28 @@ import java.awt.event.ActionListener;
import java.awt.event.KeyEvent; import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.File; import java.io.File;
import java.util.concurrent.ExecutionException;
import static com.fr.design.layout.TableLayout.FILL; import static com.fr.design.layout.TableLayout.FILL;
import static com.fr.design.layout.TableLayout.PREFERRED; import static com.fr.design.layout.TableLayout.PREFERRED;
import static com.fr.third.guava.base.Optional.fromNullable;
/** /**
* @author yaohwu * @author yaohwu
*/ */
public class RemoteEnvPane extends BasicBeanPane<RemoteEnvConfig> { public class RemoteEnvPane extends BasicBeanPane<RemoteDesignerWorkspaceInfo> {
private static final Color TIPS_FONT_COLOR = new Color(0x8f8f92); private static final Color TIPS_FONT_COLOR = new Color(0x8f8f92);
private JDialog dialog;
private UILabel message = new UILabel();
private UIButton okButton = new UIButton(Inter.getLocText("OK"));
private UIButton cancelButton = new UIButton(Inter.getLocText("Cancel"));
;
/** /**
* 是否启用 https 勾选框 * 是否启用 https 勾选框
*/ */
@ -194,7 +205,7 @@ public class RemoteEnvPane extends BasicBeanPane<RemoteEnvConfig> {
// 服务器地址地址 // 服务器地址地址
JPanel configPanel = new JPanel(new BorderLayout()); final JPanel configPanel = new JPanel(new BorderLayout());
configPanel.setBorder( configPanel.setBorder(
BorderFactory.createCompoundBorder( BorderFactory.createCompoundBorder(
new EmptyBorder(15, 0, 0, 0), new EmptyBorder(15, 0, 0, 0),
@ -236,9 +247,7 @@ public class RemoteEnvPane extends BasicBeanPane<RemoteEnvConfig> {
testConnectionButton.addActionListener(new ActionListener() { testConnectionButton.addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent ev) { public void actionPerformed(ActionEvent ev) {
if (testConnection()) { tryConnectRemoteEnv();
JOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(RemoteEnvPane.this), Inter.getLocText("Datasource-Connection_successfully"));
}
} }
}); });
testPanel.add(testConnectionButton); testPanel.add(testConnectionButton);
@ -253,36 +262,37 @@ public class RemoteEnvPane extends BasicBeanPane<RemoteEnvConfig> {
} }
@Override @Override
public void populateBean(RemoteEnvConfig ob) { public void populateBean(RemoteDesignerWorkspaceInfo ob) {
WorkspaceConnection connection = ob.getConnection();
if (StringUtils.isEmpty(ob.getPath())) { if (connection != null) {
remoteEnvURL = RemoteEnvURL.createDefaultURL(); this.remoteEnvURL = Strings.isNullOrEmpty(connection.getUrl())
} else { ? RemoteEnvURL.createDefaultURL()
remoteEnvURL = new RemoteEnvURL(ob.getPath()); : new RemoteEnvURL(connection.getUrl());
String username = fromNullable(connection.getUserName()).or(StringUtils.EMPTY);
String pwd = fromNullable(connection.getPassword()).or(StringUtils.EMPTY);
this.usernameInput.setText(username);
this.passwordInput.setText(pwd);
} }
fillRemoteEnvURLField(); fillRemoteEnvURLField();
fillIndividualField(); fillIndividualField();
httpsCheckbox.setSelected(remoteEnvURL.getHttps()); httpsCheckbox.setSelected(this.remoteEnvURL.getHttps());
DesignerEnvManager.getEnvManager().setHttps(remoteEnvURL.getHttps()); DesignerEnvManager.getEnvManager().setHttps(this.remoteEnvURL.getHttps());
fileChooserButton.setEnabled(remoteEnvURL.getHttps()); fileChooserButton.setEnabled(this.remoteEnvURL.getHttps());
updateHttpsConfigPanel(); updateHttpsConfigPanel();
String username = EnvConfigUtils.getUsername(ob);
String pwd = EnvConfigUtils.getPassword(ob);
this.usernameInput.setText(username == null ? StringUtils.EMPTY : pwd);
this.passwordInput.setText(ob.getPassword() == null ? StringUtils.EMPTY : ob.getPassword());
} }
@Override @Override
public RemoteEnvConfig updateBean() { public RemoteDesignerWorkspaceInfo updateBean() {
WorkspaceConnection connection = new WorkspaceConnection(
String path = remoteEnvURL.getURL(); this.remoteEnvURL.getURL(),
String user = this.usernameInput.getText(); this.usernameInput.getText(),
String password = new String(this.passwordInput.getPassword()); new String(this.passwordInput.getPassword()));
return null;
//return new RemoteEnvConfig(path, user, password); return RemoteDesignerWorkspaceInfo.create(connection);
} }
@Override @Override
@ -460,51 +470,79 @@ public class RemoteEnvPane extends BasicBeanPane<RemoteEnvConfig> {
return inputPanel; return inputPanel;
} }
private void tryConnectRemoteEnv() {
final SwingWorker<Boolean, Void> worker = new SwingWorker<Boolean, Void>() {
@Override
protected Boolean doInBackground() throws Exception {
private void setHttpsParas() { final RemoteDesignerWorkspaceInfo remoteEnv = updateBean();
System.setProperty("javax.net.ssl.trustStore", this.certPathInput.getText()); return WorkContext.getConnector().testConnection(remoteEnv.getConnection());
System.setProperty("javax.net.ssl.trustStorePassword", new String(this.certSecretKeyInput.getPassword()));
DesignerEnvManager manager = DesignerEnvManager.getEnvManager();
manager.setCertificatePath(this.certPathInput.getText());
manager.setCertificatePass(new String(this.certSecretKeyInput.getPassword()));
manager.setHttps(this.httpsCheckbox.isSelected());
} }
private boolean testConnection() { @Override
String url = remoteEnvURL.getURL(); protected void done() {
//RemoteEnv env = new RemoteEnv(url, usernameInput.getText(), new String(passwordInput.getPassword())); okButton.setEnabled(true);
RemoteEnv env = null;
boolean connect = false;
try { try {
if (StringUtils.isNotEmpty(url)) { if (get()) {
if (remoteEnvURL.getHttps()) { message.setText(Inter.getLocText("Fine-Designer_Basic_Remote_Connect_Successful"));
setHttpsParas(); } else {
} message.setText(Inter.getLocText("Fine-Designer_Basic_Remote_Connect_Failed"));
connect = env.testConnectionWithOutRegisteServer(this);
}
} catch (Exception e) {
JOptionPane.showMessageDialog(
this,
Inter.getLocText("Datasource-Connection_failed"),
UIManager.getString("OptionPane.messageDialogTitle", this.getLocale()),
JOptionPane.ERROR_MESSAGE
);
FRContext.getLogger().error(e.getMessage(), e);
} }
if (connect) { } catch (InterruptedException | ExecutionException e) {
try { message.setText(Inter.getLocText("Fine-Designer_Basic_Remote_Connect_Failed"));
String remoteVersion = env.getDesignerVersion(); }
if (StringUtils.isBlank(remoteVersion) || ComparatorUtils.compare(remoteVersion, ProductConstants.DESIGNER_VERSION) < 0) { }
String info = Inter.getLocText("Server-version-tip") + "。"; };
String moreInfo = Inter.getLocText("Server-version-tip-moreInfo") + "。"; worker.execute();
new InformationWarnPane(info, moreInfo, Inter.getLocText("Tooltips")).show(); initMessageDialog();
return false; okButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
dialog.dispose();
} }
} catch (Exception e) { });
FRContext.getLogger().error(e.getMessage(), e); cancelButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
dialog.dispose();
worker.cancel(true);
} }
});
dialog.addWindowListener(new WindowAdapter() {
public void windowClosed(WindowEvent e) {
worker.cancel(true);
} }
return connect; });
dialog.setVisible(true);
dialog.dispose();
}
private void initMessageDialog() {
message.setText(Inter.getLocText("Fine-Designer_Basic_Remote_Env_Try") + "...");
message.setBorder(BorderFactory.createEmptyBorder(8, 5, 0, 0));
okButton.setEnabled(false);
dialog = new JDialog((Dialog) SwingUtilities.getWindowAncestor(RemoteEnvPane.this), Inter.getLocText("Datasource-Test_Connection"), true);
dialog.setSize(new Dimension(268, 118));
okButton.setEnabled(false);
JPanel jp = new JPanel();
JPanel upPane = new JPanel();
JPanel downPane = new JPanel();
UILabel uiLabel = new UILabel(UIManager.getIcon("OptionPane.informationIcon"));
upPane.setLayout(new FlowLayout(FlowLayout.LEFT, 10, 10));
upPane.add(uiLabel);
upPane.add(message);
downPane.setLayout(new FlowLayout(FlowLayout.CENTER, 6, 0));
downPane.add(okButton);
downPane.add(cancelButton);
jp.setLayout(new BoxLayout(jp, BoxLayout.Y_AXIS));
jp.add(upPane);
jp.add(downPane);
dialog.add(jp);
dialog.setResizable(false);
dialog.setLocationRelativeTo(SwingUtilities.getWindowAncestor(RemoteEnvPane.this));
} }
/** /**

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

@ -1,185 +1,185 @@
package com.fr.env; //package com.fr.env;
//
import com.fr.design.env.RemoteEnvConfig; //import com.fr.design.beans.BasicBeanPane;
import com.fr.design.beans.BasicBeanPane; //import com.fr.design.border.UITitledBorder;
import com.fr.design.border.UITitledBorder; //import com.fr.design.env.DesignerWorkspaceInfo;
import com.fr.design.gui.ibutton.UIButton; //import com.fr.design.env.DesignerWorkspaceType;
import com.fr.design.gui.ilable.UILabel; //import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ipasswordfield.UIPassWordField; //import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itextfield.UIIntNumberField; //import com.fr.design.gui.ipasswordfield.UIPassWordField;
import com.fr.design.gui.itextfield.UITextField; //import com.fr.design.gui.itextfield.UIIntNumberField;
import com.fr.design.layout.TableLayout; //import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.layout.TableLayoutHelper; //import com.fr.design.layout.TableLayout;
import com.fr.design.utils.gui.GUICoreUtils; //import com.fr.design.layout.TableLayoutHelper;
import com.fr.general.Inter; //import com.fr.design.utils.gui.GUICoreUtils;
//import com.fr.general.Inter;
import javax.swing.*; //import com.fr.workspace.WorkContext;
import javax.swing.border.EmptyBorder; //import com.fr.workspace.connect.WorkspaceConnection;
import java.awt.*; //
import java.awt.event.ActionEvent; //import javax.swing.*;
import java.awt.event.ActionListener; //import javax.swing.border.EmptyBorder;
import java.awt.event.WindowAdapter; //import java.awt.*;
import java.awt.event.WindowEvent; //import java.awt.event.ActionEvent;
//import java.awt.event.ActionListener;
/** //import java.awt.event.WindowAdapter;
* 远程环境设置界面暂时命名为2待做完功能直接替代掉老的RemoteEnvPane //import java.awt.event.WindowEvent;
*/ //
public class RemoteEnvPane2 extends BasicBeanPane<RemoteEnvConfig> { ///**
// * 远程环境设置界面,暂时命名为2,待做完功能直接替代掉老的RemoteEnvPane
private UITextField hostTextField; // */
private UIIntNumberField portTextField; //public class RemoteEnvPane2 extends BasicBeanPane<DesignerWorkspaceInfo> {
private UITextField usernameTextField; //
private UIPassWordField passwordTextField; // private UITextField urlTextField;
private JDialog dialog; // private UITextField usernameTextField;
private UILabel message; // private UIPassWordField passwordTextField;
private UIButton okButton; // private JDialog dialog;
private UIButton cancelButton; // private UILabel message;
// private UIButton okButton;
public RemoteEnvPane2() { // private UIButton cancelButton;
initComponents(); //
} // public RemoteEnvPane2() {
// initComponents();
private void initComponents() { // }
setLayout(new BorderLayout()); //
// private void initComponents() {
JPanel contentPanel = new JPanel(new BorderLayout()); // setLayout(new BorderLayout());
add(contentPanel, BorderLayout.CENTER); //
// JPanel contentPanel = new JPanel(new BorderLayout());
contentPanel.setBorder( // add(contentPanel, BorderLayout.CENTER);
BorderFactory.createCompoundBorder( //
new EmptyBorder(6, 0, 0, 0), // contentPanel.setBorder(
UITitledBorder.createBorderWithTitle(Inter.getLocText("Fine-Designer_Basic_Remote_Env_Config"))) // BorderFactory.createCompoundBorder(
); // new EmptyBorder(6, 0, 0, 0),
// UITitledBorder.createBorderWithTitle(Inter.getLocText("Fine-Designer_Basic_Remote_Env_Config")))
double p = TableLayout.PREFERRED; // );
double f = TableLayout.FILL; //
double[] rowSize = new double[]{p, p, p, p, p}; // double p = TableLayout.PREFERRED;
double[] columnSize = new double[]{p, f}; // double f = TableLayout.FILL;
UIButton testConnectionButton = new UIButton(Inter.getLocText("Fine-Designer_Basic_Remote_Env_Try")); // double[] rowSize = new double[]{p, p, p, p};
hostTextField = new UITextField(); // double[] columnSize = new double[]{p, f};
hostTextField.setPlaceholder("192.168.100.200"); // UIButton testConnectionButton = new UIButton(Inter.getLocText("Fine-Designer_Basic_Remote_Env_Try"));
portTextField = new UIIntNumberField(); // urlTextField = new UITextField();
portTextField.setPlaceholder("39999"); // urlTextField.setPlaceholder("http://192.168.100.200/webroot/decision");
JPanel valuePane = TableLayoutHelper.createTableLayoutPane( // JPanel valuePane = TableLayoutHelper.createTableLayoutPane(
new Component[][]{ // new Component[][]{
{new UILabel(Inter.getLocText("Fine-Designer_Basic_Remote_Env_Host") + ":", SwingConstants.RIGHT), hostTextField}, // {new UILabel(Inter.getLocText("Fine-Designer_Basic_Remote_Env_Host") + ":", SwingConstants.RIGHT), urlTextField},
{new UILabel(Inter.getLocText("Fine-Designer_Basic_Remote_Env_Port") + ":", SwingConstants.RIGHT),portTextField}, // {new UILabel(Inter.getLocText("Fine-Designer_Basic_Remote_Env_User") + ":", SwingConstants.RIGHT), usernameTextField = new UITextField()},
{new UILabel(Inter.getLocText("Fine-Designer_Basic_Remote_Env_User") + ":", SwingConstants.RIGHT), usernameTextField = new UITextField()}, // {new UILabel(Inter.getLocText("Fine-Designer_Basic_Remote_Env_Password") + ":", SwingConstants.RIGHT), passwordTextField = new UIPassWordField()},
{new UILabel(Inter.getLocText("Fine-Designer_Basic_Remote_Env_Password") + ":", SwingConstants.RIGHT), passwordTextField = new UIPassWordField()}, // {null, GUICoreUtils.createFlowPane(testConnectionButton, FlowLayout.LEFT)}
{null, GUICoreUtils.createFlowPane(testConnectionButton, FlowLayout.LEFT)} // },
}, // rowSize, columnSize
rowSize, columnSize // );
); // testConnectionButton.addActionListener(new ActionListener() {
testConnectionButton.addActionListener(new ActionListener() { // @Override
@Override // public void actionPerformed(ActionEvent e) {
public void actionPerformed(ActionEvent e) { // tryConnectRemoteEnv();
tryConnectRemoteEnv(); // }
} // });
}); // contentPanel.add(valuePane, BorderLayout.CENTER);
contentPanel.add(valuePane, BorderLayout.CENTER); //
// message = new UILabel();
message = new UILabel(); // okButton = new UIButton(Inter.getLocText("OK"));
okButton = new UIButton(Inter.getLocText("OK")); // cancelButton = new UIButton(Inter.getLocText("Cancel"));
cancelButton = new UIButton(Inter.getLocText("Cancel")); // }
} //
// private void tryConnectRemoteEnv() {
private void tryConnectRemoteEnv() { // final SwingWorker<Void, Void> worker = new SwingWorker<Void, Void>() {
final SwingWorker<Void, Void> worker = new SwingWorker<Void, Void>() { //
// @Override
@Override // protected Void doInBackground() throws Exception {
protected Void doInBackground() throws Exception { //
final RemoteEnv remoteEnv = new RemoteEnv(updateBean()); // final DesignerWorkspaceInfo remoteEnv = updateBean();
remoteEnv.connectOnce(); // WorkContext.getConnector().testConnection(remoteEnv.getConnection());
return null; // return null;
} // }
//
@Override // @Override
protected void done() { // protected void done() {
okButton.setEnabled(true); // okButton.setEnabled(true);
try { // try {
get(); // get();
message.setText(Inter.getLocText("Fine-Designer_Basic_Remote_Connect_Successful")); // message.setText(Inter.getLocText("Fine-Designer_Basic_Remote_Connect_Successful"));
} catch (Exception e) { // } catch (Exception e) {
message.setText(Inter.getLocText("Fine-Designer_Basic_Remote_Connect_Failed")); // message.setText(Inter.getLocText("Fine-Designer_Basic_Remote_Connect_Failed"));
} // }
} // }
}; // };
worker.execute(); // worker.execute();
initMessageDialog(); // initMessageDialog();
okButton.addActionListener(new ActionListener() { // okButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { // public void actionPerformed(ActionEvent e) {
dialog.dispose(); // dialog.dispose();
} // }
}); // });
cancelButton.addActionListener(new ActionListener() { // cancelButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { // public void actionPerformed(ActionEvent e) {
dialog.dispose(); // dialog.dispose();
worker.cancel(true); // worker.cancel(true);
} // }
}); // });
//
dialog.addWindowListener(new WindowAdapter() { // dialog.addWindowListener(new WindowAdapter() {
public void windowClosed(WindowEvent e) { // public void windowClosed(WindowEvent e) {
worker.cancel(true); // worker.cancel(true);
} // }
}); // });
//
dialog.setVisible(true); // dialog.setVisible(true);
dialog.dispose(); // dialog.dispose();
} // }
//
private void initMessageDialog() { // private void initMessageDialog() {
message.setText(Inter.getLocText("Fine-Designer_Basic_Remote_Env_Try") + "..."); // message.setText(Inter.getLocText("Fine-Designer_Basic_Remote_Env_Try") + "...");
message.setBorder(BorderFactory.createEmptyBorder(8, 5, 0, 0)); // message.setBorder(BorderFactory.createEmptyBorder(8, 5, 0, 0));
okButton.setEnabled(false); // okButton.setEnabled(false);
//
dialog = new JDialog((Dialog) SwingUtilities.getWindowAncestor(RemoteEnvPane2.this), Inter.getLocText("Datasource-Test_Connection"), true); // dialog = new JDialog((Dialog) SwingUtilities.getWindowAncestor(RemoteEnvPane2.this), Inter.getLocText("Datasource-Test_Connection"), true);
//
dialog.setSize(new Dimension(268, 118)); // dialog.setSize(new Dimension(268, 118));
okButton.setEnabled(false); // okButton.setEnabled(false);
JPanel jp = new JPanel(); // JPanel jp = new JPanel();
JPanel upPane = new JPanel(); // JPanel upPane = new JPanel();
JPanel downPane = new JPanel(); // JPanel downPane = new JPanel();
UILabel uiLabel = new UILabel(UIManager.getIcon("OptionPane.informationIcon")); // UILabel uiLabel = new UILabel(UIManager.getIcon("OptionPane.informationIcon"));
upPane.setLayout(new FlowLayout(FlowLayout.LEFT, 10, 10)); // upPane.setLayout(new FlowLayout(FlowLayout.LEFT, 10, 10));
upPane.add(uiLabel); // upPane.add(uiLabel);
upPane.add(message); // upPane.add(message);
downPane.setLayout(new FlowLayout(FlowLayout.CENTER, 6, 0)); // downPane.setLayout(new FlowLayout(FlowLayout.CENTER, 6, 0));
downPane.add(okButton); // downPane.add(okButton);
downPane.add(cancelButton); // downPane.add(cancelButton);
jp.setLayout(new BoxLayout(jp, BoxLayout.Y_AXIS)); // jp.setLayout(new BoxLayout(jp, BoxLayout.Y_AXIS));
jp.add(upPane); // jp.add(upPane);
jp.add(downPane); // jp.add(downPane);
dialog.add(jp); // dialog.add(jp);
dialog.setResizable(false); // dialog.setResizable(false);
dialog.setLocationRelativeTo(SwingUtilities.getWindowAncestor(RemoteEnvPane2.this)); // dialog.setLocationRelativeTo(SwingUtilities.getWindowAncestor(RemoteEnvPane2.this));
} // }
//
@Override // @Override
protected String title4PopupWindow() { // protected String title4PopupWindow() {
return "RemoteEnv"; // return "RemoteEnv";
} // }
//
@Override // @Override
public void populateBean(RemoteEnvConfig config) { // public void populateBean(DesignerWorkspaceInfo config) {
if (config == null) { // if (config == null) {
return; // return;
} // }
hostTextField.setText(config.getHost()); // WorkspaceConnection connection = config.getConnection();
if (config.getPort() != 0) { // if (connection != null) {
portTextField.setValue(config.getPort()); // urlTextField.setText(connection.getUrl());
} // usernameTextField.setText(connection.getUserName());
usernameTextField.setText(config.getUsername()); // passwordTextField.setText(connection.getPassword());
passwordTextField.setText(config.getPassword()); // }
} // }
//
@Override // @Override
public RemoteEnvConfig updateBean() { // public DesignerWorkspaceInfo updateBean() {
RemoteEnvConfig config = new RemoteEnvConfig(); //
config.setHost(hostTextField.getText()); // DesignerWorkspaceInfo config = new DesignerWorkspaceInfo();
config.setPort((int) portTextField.getValue()); // WorkspaceConnection connection = new WorkspaceConnection(urlTextField.getText(), usernameTextField.getText(), passwordTextField.getText());
config.setUsername(usernameTextField.getText()); // config.setConnection(connection);
config.setPassword(passwordTextField.getText()); // config.setType(DesignerWorkspaceType.Remote);
return config; // return config;
} // }
} //}

334
designer-base/src/com/fr/env/RemoteEnvUtils.java vendored

@ -1,167 +1,167 @@
package com.fr.env; //package com.fr.env;
//
import com.fr.base.EnvException; //import com.fr.base.EnvException;
import com.fr.base.FRContext; //import com.fr.base.FRContext;
import com.fr.report.DesignAuthority; //import com.fr.report.DesignAuthority;
import com.fr.report.util.AuthorityXMLUtils; //import com.fr.report.util.AuthorityXMLUtils;
import com.fr.stable.EncodeConstants; //import com.fr.stable.EncodeConstants;
import com.fr.third.org.apache.commons.io.IOUtils; //import com.fr.third.org.apache.commons.io.IOUtils;
import com.fr.third.org.apache.http.HttpResponse; //import com.fr.third.org.apache.http.HttpResponse;
import com.fr.third.org.apache.http.HttpStatus; //import com.fr.third.org.apache.http.HttpStatus;
import com.fr.third.org.apache.http.client.ClientProtocolException; //import com.fr.third.org.apache.http.client.ClientProtocolException;
import com.fr.third.org.apache.http.client.ResponseHandler; //import com.fr.third.org.apache.http.client.ResponseHandler;
import com.fr.third.org.apache.http.client.methods.HttpUriRequest; //import com.fr.third.org.apache.http.client.methods.HttpUriRequest;
import com.fr.third.org.apache.http.client.methods.RequestBuilder; //import com.fr.third.org.apache.http.client.methods.RequestBuilder;
import com.fr.third.org.apache.http.entity.ContentType; //import com.fr.third.org.apache.http.entity.ContentType;
import com.fr.third.org.apache.http.entity.InputStreamEntity; //import com.fr.third.org.apache.http.entity.InputStreamEntity;
import com.fr.third.org.apache.http.impl.client.CloseableHttpClient; //import com.fr.third.org.apache.http.impl.client.CloseableHttpClient;
import com.fr.third.org.apache.http.impl.client.HttpClients; //import com.fr.third.org.apache.http.impl.client.HttpClients;
//
import java.io.ByteArrayInputStream; //import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream; //import java.io.ByteArrayOutputStream;
import java.io.IOException; //import java.io.IOException;
import java.io.InputStream; //import java.io.InputStream;
import java.net.URLEncoder; //import java.net.URLEncoder;
import java.util.Map; //import java.util.Map;
//
public class RemoteEnvUtils { //public class RemoteEnvUtils {
//
private RemoteEnvUtils() { // private RemoteEnvUtils() {
} // }
//
private static ResponseHandler<InputStream> responseHandler = new ResponseHandler<InputStream>() { // private static ResponseHandler<InputStream> responseHandler = new ResponseHandler<InputStream>() {
@Override // @Override
public InputStream handleResponse(HttpResponse response) throws IOException { // public InputStream handleResponse(HttpResponse response) throws IOException {
int statusCode = response.getStatusLine().getStatusCode(); // int statusCode = response.getStatusLine().getStatusCode();
if (statusCode != HttpStatus.SC_OK) { // if (statusCode != HttpStatus.SC_OK) {
throw new ClientProtocolException("Method failed: " + response.getStatusLine().toString()); // throw new ClientProtocolException("Method failed: " + response.getStatusLine().toString());
} // }
InputStream in = response.getEntity().getContent(); // InputStream in = response.getEntity().getContent();
if (in == null) { // if (in == null) {
return null; // return null;
} // }
// 读取并返回 // // 读取并返回
ByteArrayOutputStream out = new ByteArrayOutputStream(); // ByteArrayOutputStream out = new ByteArrayOutputStream();
IOUtils.copy(in, out); // IOUtils.copy(in, out);
return new ByteArrayInputStream(out.toByteArray()); // return new ByteArrayInputStream(out.toByteArray());
} // }
}; // };
//
public static InputStream simulateRPCByHttpPost(byte[] bytes, Map<String, String> parameters, boolean isSignIn, RemoteEnv env) throws EnvException { // public static InputStream simulateRPCByHttpPost(byte[] bytes, Map<String, String> parameters, boolean isSignIn, RemoteEnv env) throws EnvException {
String path = env.getPath(); // String path = env.getPath();
RequestBuilder builder = RequestBuilder.post(path); // RequestBuilder builder = RequestBuilder.post(path);
//
InputStream inputStream = null; // InputStream inputStream = null;
//
for (Map.Entry<String, String> entry : parameters.entrySet()) { // for (Map.Entry<String, String> entry : parameters.entrySet()) {
builder.addParameter(entry.getKey(), entry.getValue()); // builder.addParameter(entry.getKey(), entry.getValue());
} // }
if (!isSignIn) { // if (!isSignIn) {
builder.addParameter("id", env.getUserID()); // builder.addParameter("id", env.getUserID());
} // }
InputStreamEntity reqEntity = new InputStreamEntity(new ByteArrayInputStream(bytes)); // InputStreamEntity reqEntity = new InputStreamEntity(new ByteArrayInputStream(bytes));
//
try (CloseableHttpClient httpClient = HttpClients.createSystem()) { // try (CloseableHttpClient httpClient = HttpClients.createSystem()) {
HttpUriRequest request = builder // HttpUriRequest request = builder
.setEntity(reqEntity) // .setEntity(reqEntity)
.build(); // .build();
inputStream = httpClient.execute(request, responseHandler); // inputStream = httpClient.execute(request, responseHandler);
} catch (IOException e) { // } catch (IOException e) {
FRContext.getLogger().error(e.getMessage()); // FRContext.getLogger().error(e.getMessage());
} // }
return inputStream; // return inputStream;
} // }
//
public static InputStream simulateRPCByHttpPost(Map<String, String> parameters, boolean isSignIn, RemoteEnv env) throws EnvException { // public static InputStream simulateRPCByHttpPost(Map<String, String> parameters, boolean isSignIn, RemoteEnv env) throws EnvException {
String path = env.getPath(); // String path = env.getPath();
RequestBuilder builder = RequestBuilder.post(path); // RequestBuilder builder = RequestBuilder.post(path);
//
InputStream inputStream = null; // InputStream inputStream = null;
//
for (Map.Entry<String, String> entry : parameters.entrySet()) { // for (Map.Entry<String, String> entry : parameters.entrySet()) {
builder.addParameter(entry.getKey(), entry.getValue()); // builder.addParameter(entry.getKey(), entry.getValue());
} // }
if (!isSignIn) { // if (!isSignIn) {
builder.addParameter("id", env.getUserID()); // builder.addParameter("id", env.getUserID());
} // }
//
try (CloseableHttpClient httpClient = HttpClients.createSystem()) { // try (CloseableHttpClient httpClient = HttpClients.createSystem()) {
HttpUriRequest request = builder // HttpUriRequest request = builder
.build(); // .build();
inputStream = httpClient.execute(request, responseHandler); // inputStream = httpClient.execute(request, responseHandler);
} catch (IOException e) { // } catch (IOException e) {
FRContext.getLogger().error(e.getMessage()); // FRContext.getLogger().error(e.getMessage());
} // }
return inputStream; // return inputStream;
} // }
//
public static InputStream simulateRPCByHttpGet(Map<String, String> parameters, boolean isSignIn, RemoteEnv env) throws EnvException { // public static InputStream simulateRPCByHttpGet(Map<String, String> parameters, boolean isSignIn, RemoteEnv env) throws EnvException {
String path = env.getPath(); // String path = env.getPath();
RequestBuilder builder = RequestBuilder.get(path); // RequestBuilder builder = RequestBuilder.get(path);
//
InputStream inputStream = null; // InputStream inputStream = null;
//
for (Map.Entry<String, String> entry : parameters.entrySet()) { // for (Map.Entry<String, String> entry : parameters.entrySet()) {
builder.addParameter(entry.getKey(), entry.getValue()); // builder.addParameter(entry.getKey(), entry.getValue());
} // }
if (!isSignIn) { // if (!isSignIn) {
builder.addParameter("id", env.getUserID()); // builder.addParameter("id", env.getUserID());
} // }
try (CloseableHttpClient httpClient = HttpClients.createSystem()) { // try (CloseableHttpClient httpClient = HttpClients.createSystem()) {
HttpUriRequest request = builder.build(); // HttpUriRequest request = builder.build();
inputStream = httpClient.execute(request, responseHandler); // inputStream = httpClient.execute(request, responseHandler);
//
} catch (IOException e) { // } catch (IOException e) {
FRContext.getLogger().error(e.getMessage()); // FRContext.getLogger().error(e.getMessage());
} // }
return inputStream; // return inputStream;
} // }
//
//
public static InputStream updateAuthorities(DesignAuthority[] authorities, RemoteEnv env) { // public static InputStream updateAuthorities(DesignAuthority[] authorities, RemoteEnv env) {
String path = env.getPath(); // String path = env.getPath();
// 远程设计临时用户id // // 远程设计临时用户id
String userID = env.getUserID(); // String userID = env.getUserID();
InputStream inputStream = null; // InputStream inputStream = null;
//
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); // ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
AuthorityXMLUtils.writeDesignAuthoritiesXML(authorities, outputStream); // AuthorityXMLUtils.writeDesignAuthoritiesXML(authorities, outputStream);
InputStreamEntity reqEntity = new InputStreamEntity(new ByteArrayInputStream(outputStream.toByteArray()), ContentType.TEXT_XML); // InputStreamEntity reqEntity = new InputStreamEntity(new ByteArrayInputStream(outputStream.toByteArray()), ContentType.TEXT_XML);
//
try (CloseableHttpClient httpClient = HttpClients.createSystem()) { // try (CloseableHttpClient httpClient = HttpClients.createSystem()) {
HttpUriRequest request = RequestBuilder.post(path) // HttpUriRequest request = RequestBuilder.post(path)
.addParameter("id", userID) // .addParameter("id", userID)
.addParameter("op", "remote_design_authority") // .addParameter("op", "remote_design_authority")
.addParameter("cmd", "update_authorities") // .addParameter("cmd", "update_authorities")
.setEntity(reqEntity) // .setEntity(reqEntity)
.build(); // .build();
inputStream = httpClient.execute(request, responseHandler); // inputStream = httpClient.execute(request, responseHandler);
} catch (IOException e) { // } catch (IOException e) {
FRContext.getLogger().error(e.getMessage()); // FRContext.getLogger().error(e.getMessage());
} // }
//
return inputStream; // return inputStream;
//
} // }
//
public static InputStream getAuthorities(RemoteEnv env) throws EnvException { // public static InputStream getAuthorities(RemoteEnv env) throws EnvException {
String path = env.getPath(); // String path = env.getPath();
// 远程设计临时用户id // // 远程设计临时用户id
String userID = env.getUserID(); // String userID = env.getUserID();
InputStream inputStream = null; // InputStream inputStream = null;
//
try (CloseableHttpClient httpClient = HttpClients.createSystem();) { // try (CloseableHttpClient httpClient = HttpClients.createSystem();) {
HttpUriRequest request = RequestBuilder.get(path) // HttpUriRequest request = RequestBuilder.get(path)
.addParameter("id", userID) // .addParameter("id", userID)
.addParameter("op", "remote_design_authority") // .addParameter("op", "remote_design_authority")
.addParameter("cmd", "get_authorities") // .addParameter("cmd", "get_authorities")
.build(); // .build();
inputStream = httpClient.execute(request, responseHandler); // inputStream = httpClient.execute(request, responseHandler);
} catch (IOException e) { // } catch (IOException e) {
FRContext.getLogger().error(e.getMessage()); // FRContext.getLogger().error(e.getMessage());
} // }
return inputStream; // return inputStream;
} // }
//
//
} //}

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

@ -1,46 +0,0 @@
package com.fr.env;
import com.fr.base.Env;
import com.fr.base.FRContext;
import com.fr.core.env.EnvConfig;
import com.fr.core.env.EnvContext;
import com.fr.core.env.EnvEvent;
import com.fr.design.mainframe.DesignerContext;
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.Inter;
import com.fr.stable.AssistUtils;
import javax.swing.*;
public class SignIn {
static {
EventDispatcher.listen(EnvEvent.CONNECTION_ERROR, new Listener<Null>() {
@Override
public void on(Event event, Null param) {
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Inter.getLocText("Datasource-Connection_failed"));
}
});
}
/**
* 注册入环境
*
* @param selectedEnv 选择的环境
* @throws Exception 异常
*/
public static void signIn(EnvConfig selectedEnv) throws Exception {
Env env = FRContext.getCurrentEnv();
if (env != null && AssistUtils.equals(env.getEnvConfig(), selectedEnv)) {
env.disconnect();
}
//DesignUtils.switchToEnv(selectedEnv);
}
}

20
designer-base/src/com/fr/file/FILEChooserPane.java

@ -3,7 +3,7 @@ package com.fr.file;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.base.extension.FileExtension; import com.fr.base.extension.FileExtension;
import com.fr.dav.LocalEnv; import com.fr.file.filetree.LocalFileNodes;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.actions.UpdateAction; import com.fr.design.actions.UpdateAction;
import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.BasicPane;
@ -545,10 +545,10 @@ public class FILEChooserPane extends BasicPane {
return; return;
} }
if (editing == null || !editing.isChartBook()) { if (editing == null || !editing.isChartBook()) {
String[] fileSuffix_local = LocalEnv.FILE_TYPE; String[] fileSuffix_local = LocalFileNodes.FILE_TYPE;
EnumSet<FileExtension> fileExtensions = EnumSet.of(FileExtension.CPT, FileExtension.CPTX, FileExtension.FRM, FileExtension.FRMX, FileExtension.CHT); EnumSet<FileExtension> fileExtensions = EnumSet.of(FileExtension.CPT, FileExtension.CPTX, FileExtension.FRM, FileExtension.FRMX, FileExtension.CHT);
if (type == JFileChooser.OPEN_DIALOG) { if (type == JFileChooser.OPEN_DIALOG) {
if (FRContext.getCurrentEnv().isSupportLocalFileOperate()) { //本地连接 if (FRContext.getFileNodes().isSupportLocalFileOperate()) { //本地连接
this.addChooseFILEFilter(new ChooseFileFilter(fileSuffix_local, appName + Inter.getLocText(new String[]{"FR-App-Report_Template", "FR-App-All_File"}))); this.addChooseFILEFilter(new ChooseFileFilter(fileSuffix_local, appName + Inter.getLocText(new String[]{"FR-App-Report_Template", "FR-App-All_File"})));
} else { } else {
this.addChooseFILEFilter(new ChooseFileFilter(fileExtensions, appName + Inter.getLocText(new String[]{"FR-App-Report_Template", "FR-App-All_File"}))); this.addChooseFILEFilter(new ChooseFileFilter(fileExtensions, appName + Inter.getLocText(new String[]{"FR-App-Report_Template", "FR-App-All_File"})));
@ -569,7 +569,7 @@ public class FILEChooserPane extends BasicPane {
} }
// 添加 xls 文件类型过滤 kt // 添加 xls 文件类型过滤 kt
if (FRContext.getCurrentEnv().isSupportLocalFileOperate()) { //本地连接 if (FRContext.getFileNodes().isSupportLocalFileOperate()) { //本地连接
this.addChooseFILEFilter(new ChooseFileFilter(FileExtension.XLS, Inter.getLocText("Import-Excel_Source"))); this.addChooseFILEFilter(new ChooseFileFilter(FileExtension.XLS, Inter.getLocText("Import-Excel_Source")));
this.addChooseFILEFilter(new ChooseFileFilter(FileExtension.XLSX, Inter.getLocText("Import-Excel2007_Source"))); this.addChooseFILEFilter(new ChooseFileFilter(FileExtension.XLSX, Inter.getLocText("Import-Excel2007_Source")));
} }
@ -592,7 +592,7 @@ public class FILEChooserPane extends BasicPane {
for (FILEFilter aFilterList : filterList) { for (FILEFilter aFilterList : filterList) {
defaultComboBoxModel.addElement(aFilterList); defaultComboBoxModel.addElement(aFilterList);
} }
if (FRContext.getCurrentEnv().isSupportLocalFileOperate()) { //本地连接 if (FRContext.getFileNodes().isSupportLocalFileOperate()) { //本地连接
if (!showWebReport) { if (!showWebReport) {
defaultComboBoxModel.addElement(Inter.getLocText("FR-Utils-App_AllFiles") + "(*.*)"); defaultComboBoxModel.addElement(Inter.getLocText("FR-Utils-App_AllFiles") + "(*.*)");
} }
@ -686,7 +686,7 @@ public class FILEChooserPane extends BasicPane {
boolean access = false; boolean access = false;
try { try {
access = FRContext.getCurrentEnv().getOrganizationOperator().canAccess(selectedFile.getPath()); access = FRContext.getOrganizationOperator().canAccess(selectedFile.getPath());
} catch (Exception e) { } catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
} }
@ -786,10 +786,10 @@ public class FILEChooserPane extends BasicPane {
} }
if (FILEChooserPane.this.showWebReport) { if (FILEChooserPane.this.showWebReport) {
// webReportFILE = new FileFILE(new // webReportFILE = new FileFILE(new
// File(FRContext.getCurrentEnv().getWebReportPath())); // File(FRContext.getCommonOperator().getWebReportPath()));
webReportFILE = new FileNodeFILE(FRContext.getCurrentEnv().getWebReportPath()); webReportFILE = new FileNodeFILE(FRContext.getCommonOperator().getWebReportPath());
// String webReportPath = // String webReportPath =
// FRContext.getCurrentEnv().getWebReportPath(); // FRContext.getCommonOperator().getWebReportPath();
// String webReportParentPath = new // String webReportParentPath = new
// File(webReportPath).getParent(); // File(webReportPath).getParent();
// webReportFILE = new FileNodeFILE(new FileNode("WebReport", // webReportFILE = new FileNodeFILE(new FileNode("WebReport",
@ -1404,7 +1404,7 @@ public class FILEChooserPane extends BasicPane {
boolean access = false; boolean access = false;
try { try {
access = FRContext.getCurrentEnv().getOrganizationOperator().canAccess(currentDirectory.getPath()); access = FRContext.getOrganizationOperator().canAccess(currentDirectory.getPath());
} catch (Exception e) { } catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
} }

8
designer-base/src/com/fr/file/FILEFactory.java

@ -2,6 +2,7 @@ package com.fr.file;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.file.filetree.FileNode; import com.fr.file.filetree.FileNode;
import com.fr.workspace.WorkContext;
public class FILEFactory { public class FILEFactory {
public static final String MEM_PREFIX = "mem://"; public static final String MEM_PREFIX = "mem://";
@ -18,7 +19,8 @@ public class FILEFactory {
* 也有可能就是一个普通的路径d:/foo/bar * 也有可能就是一个普通的路径d:/foo/bar
*/ */
public static FILE createFILE(String path) { public static FILE createFILE(String path) {
String envPath = FRContext.getCurrentEnv().getPath().replaceAll("/", "\\\\");
String envPath = WorkContext.getCurrent().getPath().replaceAll("/", "\\\\");
if (path == null) { if (path == null) {
return null; return null;
} else if (path.startsWith(MEM_PREFIX)) { } else if (path.startsWith(MEM_PREFIX)) {
@ -29,7 +31,7 @@ public class FILEFactory {
return new FileNodeFILE(new FileNode(path.substring(envPath.length() + 1), false)); return new FileNodeFILE(new FileNode(path.substring(envPath.length() + 1), false));
} else if (path.startsWith(WEBREPORT_PREFIX)) { } else if (path.startsWith(WEBREPORT_PREFIX)) {
return new FileNodeFILE(new FileNode(path.substring(WEBREPORT_PREFIX.length()), false), return new FileNodeFILE(new FileNode(path.substring(WEBREPORT_PREFIX.length()), false),
FRContext.getCurrentEnv().getWebReportPath()); FRContext.getCommonOperator().getWebReportPath());
} else if (path.startsWith(FILE_PREFIX)) { } else if (path.startsWith(FILE_PREFIX)) {
return new FileFILE(new java.io.File(path.substring(FILE_PREFIX.length()))); return new FileFILE(new java.io.File(path.substring(FILE_PREFIX.length())));
} else { } else {
@ -46,7 +48,7 @@ public class FILEFactory {
return new FileNodeFILE(new FileNode(path.substring(ENV_PREFIX.length()), true)); return new FileNodeFILE(new FileNode(path.substring(ENV_PREFIX.length()), true));
} else if (path.startsWith(WEBREPORT_PREFIX)) { } else if (path.startsWith(WEBREPORT_PREFIX)) {
return new FileNodeFILE(new FileNode(path.substring(WEBREPORT_PREFIX.length()), true), return new FileNodeFILE(new FileNode(path.substring(WEBREPORT_PREFIX.length()), true),
FRContext.getCurrentEnv().getWebReportPath()); FRContext.getCommonOperator().getWebReportPath());
} else if (path.startsWith(FILE_PREFIX)) { } else if (path.startsWith(FILE_PREFIX)) {
return new FileFILE(new java.io.File(path.substring(FILE_PREFIX.length()))); return new FileFILE(new java.io.File(path.substring(FILE_PREFIX.length())));
} else { } else {

30
designer-base/src/com/fr/file/FileNodeFILE.java

@ -12,9 +12,9 @@ import com.fr.log.FineLoggerFactory;
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;
import com.fr.workspace.WorkContext;
import javax.swing.*; import javax.swing.*;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
@ -34,15 +34,13 @@ public class FileNodeFILE implements FILE {
parentDir = fn.getParent(); parentDir = fn.getParent();
} }
this.node = new FileNode(StableUtils.pathJoin(new String[]{ this.node = new FileNode(StableUtils.pathJoin(parentDir, name), isDir);
parentDir, name this.envPath = WorkContext.getCurrent().getPath();
}), isDir);
this.envPath = FRContext.getCurrentEnv().getPath();
} }
public FileNodeFILE(FileNode node) { public FileNodeFILE(FileNode node) {
this.node = node; this.node = node;
this.envPath = FRContext.getCurrentEnv().getPath(); this.envPath = WorkContext.getCurrent().getPath();
} }
public FileNodeFILE(String envPath) { public FileNodeFILE(String envPath) {
@ -61,7 +59,7 @@ public class FileNodeFILE implements FILE {
* @return 返回后缀 * @return 返回后缀
*/ */
public String prefix() { public String prefix() {
if (ComparatorUtils.equals(getEnvPath(), FRContext.getCurrentEnv().getWebReportPath())) { if (ComparatorUtils.equals(getEnvPath(), FRContext.getCommonOperator().getWebReportPath())) {
return FILEFactory.WEBREPORT_PREFIX; return FILEFactory.WEBREPORT_PREFIX;
} }
return FILEFactory.ENV_PREFIX; return FILEFactory.ENV_PREFIX;
@ -181,7 +179,7 @@ public class FileNodeFILE implements FILE {
*/ */
private FileNode[] listFile(String rootFilePath) { private FileNode[] listFile(String rootFilePath) {
try { try {
return FRContext.getCurrentEnv().getFileOperator().list(rootFilePath); return FRContext.getFileNodes().list(rootFilePath);
} catch (Exception e) { } catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
} }
@ -200,7 +198,7 @@ public class FileNodeFILE implements FILE {
} }
try { try {
return FRContext.getCurrentEnv().getFileOperator().createFolder(StableUtils.pathJoin(node.getEnvPath(), name)); return WorkContext.getWorkResource().createFile(StableUtils.pathJoin(node.getEnvPath(), name));
} catch (Exception e) { } catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
return false; return false;
@ -218,7 +216,7 @@ public class FileNodeFILE implements FILE {
} }
try { try {
return FRContext.getCurrentEnv().fileLocked(node.getEnvPath()); return FRContext.getCommonOperator().fileLocked(node.getEnvPath());
} catch (Exception e) { } catch (Exception e) {
FRContext.getLogger().error(e.getMessage(), e); FRContext.getLogger().error(e.getMessage(), e);
return false; return false;
@ -240,7 +238,7 @@ public class FileNodeFILE implements FILE {
} }
try { try {
return FRContext.getCurrentEnv().getFileOperator().isExists(node.getEnvPath()); return WorkContext.getWorkResource().exist(node.getEnvPath());
} catch (Exception e) { } catch (Exception e) {
FRContext.getLogger().error(e.getMessage(), e); FRContext.getLogger().error(e.getMessage(), e);
return false; return false;
@ -253,7 +251,7 @@ public class FileNodeFILE implements FILE {
* @return 是报表当前环境返回true * @return 是报表当前环境返回true
*/ */
public boolean isCurrentEnv() { public boolean isCurrentEnv() {
return ComparatorUtils.equals(FRContext.getCurrentEnv().getPath(), envPath); return ComparatorUtils.equals(WorkContext.getCurrent().getPath(), envPath);
} }
/** /**
@ -267,7 +265,7 @@ public class FileNodeFILE implements FILE {
} }
try { try {
return FRContext.getCurrentEnv().getFileOperator().createFile(node.getEnvPath()); return WorkContext.getWorkResource().createFile(node.getEnvPath());
} catch (Exception e) { } catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
return false; return false;
@ -291,7 +289,7 @@ public class FileNodeFILE implements FILE {
return null; return null;
} }
InputStream in = new ByteArrayInputStream(FRContext.getCurrentEnv().getFileOperator().read(StableUtils.pathJoin(ProjectConstants.REPORTLETS_NAME, envPath.substring(ProjectConstants.REPORTLETS_NAME.length() + 1)))); InputStream in = new ByteArrayInputStream(WorkContext.getWorkResource().readFully(StableUtils.pathJoin(ProjectConstants.REPORTLETS_NAME, envPath.substring(ProjectConstants.REPORTLETS_NAME.length() + 1))));
return envPath.endsWith(".cpt") || envPath.endsWith(".frm") return envPath.endsWith(".cpt") || envPath.endsWith(".frm")
? XMLEncryptUtils.decodeInputStream(in) : in; ? XMLEncryptUtils.decodeInputStream(in) : in;
@ -313,7 +311,7 @@ public class FileNodeFILE implements FILE {
if (!envPath.startsWith(ProjectConstants.REPORTLETS_NAME)) { if (!envPath.startsWith(ProjectConstants.REPORTLETS_NAME)) {
return null; return null;
} }
return FRContext.getCurrentEnv().writeBean( return FRContext.getCommonOperator().writeBean(
envPath.substring(ProjectConstants.REPORTLETS_NAME.length() + 1), envPath.substring(ProjectConstants.REPORTLETS_NAME.length() + 1),
ProjectConstants.REPORTLETS_NAME ProjectConstants.REPORTLETS_NAME
); );
@ -335,7 +333,7 @@ public class FileNodeFILE implements FILE {
return; return;
} }
FRContext.getCurrentEnv().unlockTemplate( FRContext.getCommonOperator().unlockTemplate(
envPath.substring(ProjectConstants.REPORTLETS_NAME.length() + 1)); envPath.substring(ProjectConstants.REPORTLETS_NAME.length() + 1));
} }

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

@ -2,17 +2,15 @@ package com.fr.start;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.base.ServerConfig; import com.fr.base.ServerConfig;
import com.fr.base.env.EnvUpdater;
import com.fr.design.DesignModelAdapter; import com.fr.design.DesignModelAdapter;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.data.datapane.TableDataTreePane; import com.fr.design.data.datapane.TableDataTreePane;
import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.BasicPane;
import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.env.EnvGenerator; import com.fr.design.env.DesignerWorkspaceGenerator;
import com.fr.design.file.TemplateTreePane; import com.fr.design.file.TemplateTreePane;
import com.fr.design.gui.itextarea.UITextArea; import com.fr.design.gui.itextarea.UITextArea;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.env.RemoteEnv;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.GeneralContext; import com.fr.general.GeneralContext;
import com.fr.general.Inter; import com.fr.general.Inter;
@ -22,6 +20,7 @@ import com.fr.stable.ProductConstants;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.start.server.FineEmbedServer; import com.fr.start.server.FineEmbedServer;
import com.fr.workspace.WorkContext;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
@ -37,8 +36,9 @@ public class ServerStarter {
*/ */
public static void browserDemoURL() { public static void browserDemoURL() {
if (FRContext.getCurrentEnv() instanceof RemoteEnv) { if (!WorkContext.getCurrent().isLocal()) {
browser(FRContext.getCurrentEnv().getPath()); //有问题,这里拿不到远程的http端口
browser(WorkContext.getCurrent().getPath());
return; return;
} }
if (ComparatorUtils.equals(StableUtils.getInstallHome(), ".")) {//august:供代码使用 if (ComparatorUtils.equals(StableUtils.getInstallHome(), ".")) {//august:供代码使用
@ -54,7 +54,7 @@ public class ServerStarter {
@Override @Override
public void doOk() { public void doOk() {
try { try {
EnvUpdater.updateEnv(EnvGenerator.generate(DesignerEnvManager.getEnvManager().getDefaultEnv())); WorkContext.switchTo(DesignerWorkspaceGenerator.generate(DesignerEnvManager.getEnvManager().getDefaultConfig()));
TemplateTreePane.getInstance().refreshDockingView(); TemplateTreePane.getInstance().refreshDockingView();
TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter()); TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter());
} catch (Exception e) { } catch (Exception e) {

6
designer-base/src/com/fr/start/server/FineEmbedServerActivator.java

@ -2,13 +2,13 @@ package com.fr.start.server;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.event.EventDispatcher;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.module.Activator; import com.fr.module.Activator;
import com.fr.module.ModuleRole; import com.fr.module.ModuleRole;
import com.fr.startup.FineWebApplicationInitializer; import com.fr.startup.FineWebApplicationInitializer;
import com.fr.third.springframework.web.SpringServletContainerInitializer; import com.fr.third.springframework.web.SpringServletContainerInitializer;
import com.fr.third.springframework.web.context.support.AnnotationConfigWebApplicationContext; import com.fr.third.springframework.web.context.support.AnnotationConfigWebApplicationContext;
import com.fr.workspace.WorkContext;
import org.apache.catalina.Context; import org.apache.catalina.Context;
import org.apache.catalina.LifecycleException; import org.apache.catalina.LifecycleException;
import org.apache.catalina.Wrapper; import org.apache.catalina.Wrapper;
@ -55,8 +55,8 @@ public class FineEmbedServerActivator extends Activator {
tomcat = new Tomcat(); tomcat = new Tomcat();
tomcat.setPort(DesignerEnvManager.getEnvManager().getEmbedServerPort()); tomcat.setPort(DesignerEnvManager.getEnvManager().getEmbedServerPort());
String docBase = new File(FRContext.getCurrentEnv().getPath()).getParent(); String docBase = new File(WorkContext.getCurrent().getPath()).getParent();
String appName = "/" + FRContext.getCurrentEnv().getAppName(); String appName = "/" + FRContext.getCommonOperator().getAppName();
Context context = tomcat.addContext(appName, docBase); Context context = tomcat.addContext(appName, docBase);
addDefaultServlet(context); addDefaultServlet(context);
//覆盖tomcat的WebAppClassLoader //覆盖tomcat的WebAppClassLoader

11
designer-chart/src/com/fr/design/chart/series/PlotSeries/MapGroupExtensionPane.java

@ -22,12 +22,13 @@ import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.DesignerFrame; import com.fr.design.mainframe.DesignerFrame;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.CoreConstants; import com.fr.stable.CoreConstants;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.stable.SvgProvider; import com.fr.stable.SvgProvider;
import com.fr.workspace.WorkContext;
import javax.swing.*; import javax.swing.*;
import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionEvent;
@ -340,12 +341,12 @@ public class MapGroupExtensionPane extends BasicPane implements UIObserver {
return; return;
} }
try{//提醒名字已存在 try{//提醒名字已存在
if(FRContext.getCurrentEnv().getFileOperator().isExists(StableUtils.pathJoin( if (WorkContext.getWorkResource().exist(StableUtils.pathJoin(
MapSvgXMLHelper.relativeDefaultMapPath(),newName+SvgProvider.EXTENSION))){ MapSvgXMLHelper.relativeDefaultMapPath(),newName+SvgProvider.EXTENSION))){
showRenameWaring(newName); showRenameWaring(newName);
return; return;
} }
if(FRContext.getCurrentEnv().getFileOperator().isExists(StableUtils.pathJoin( if (WorkContext.getWorkResource().exist(StableUtils.pathJoin(
MapSvgXMLHelper.relativeCustomMapPath(), newName + SvgProvider.EXTENSION))){ MapSvgXMLHelper.relativeCustomMapPath(), newName + SvgProvider.EXTENSION))){
showRenameWaring(newName); showRenameWaring(newName);
return; return;
@ -361,9 +362,9 @@ public class MapGroupExtensionPane extends BasicPane implements UIObserver {
groupExtensionPane.setValueAtCurrentSelectIndex(newName); groupExtensionPane.setValueAtCurrentSelectIndex(newName);
fireStateChange(); fireStateChange();
saveMapInfo(newName); saveMapInfo(newName);
FRContext.getCurrentEnv().getFileOperator().delete( WorkContext.getWorkResource().delete(
StableUtils.pathJoin(MapSvgXMLHelper.relativeDefaultMapPath(),oldName+SvgProvider.EXTENSION)); StableUtils.pathJoin(MapSvgXMLHelper.relativeDefaultMapPath(),oldName+SvgProvider.EXTENSION));
FRContext.getCurrentEnv().getFileOperator().delete( WorkContext.getWorkResource().delete(
StableUtils.pathJoin(MapSvgXMLHelper.relativeCustomMapPath(),oldName+SvgProvider.EXTENSION)); StableUtils.pathJoin(MapSvgXMLHelper.relativeCustomMapPath(),oldName+SvgProvider.EXTENSION));
refresh(); refresh();
}catch (Exception exp){ }catch (Exception exp){

18
designer-chart/src/com/fr/van/chart/DownloadOnlineSourcesHelper.java

@ -1,6 +1,5 @@
package com.fr.van.chart; package com.fr.van.chart;
import com.fr.base.FRContext;
import com.fr.chart.base.ChartConstants; import com.fr.chart.base.ChartConstants;
import com.fr.design.RestartHelper; import com.fr.design.RestartHelper;
import com.fr.design.extra.PluginConstants; import com.fr.design.extra.PluginConstants;
@ -12,16 +11,10 @@ import com.fr.general.SiteCenter;
import com.fr.general.http.HttpClient; import com.fr.general.http.HttpClient;
import com.fr.plugin.chart.DownloadSourcesEvent; import com.fr.plugin.chart.DownloadSourcesEvent;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
import com.fr.workspace.WorkContext;
import javax.swing.ImageIcon; import javax.swing.*;
import javax.swing.JDialog; import java.awt.*;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JProgressBar;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Rectangle;
import java.awt.event.WindowAdapter; import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent; import java.awt.event.WindowEvent;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
@ -70,7 +63,8 @@ public class DownloadOnlineSourcesHelper implements DownloadSourcesEvent {
} }
public void addSiteInfo(String siteKind, String localDir, double megaBits) { public void addSiteInfo(String siteKind, String localDir, double megaBits) {
if (new File(StableUtils.pathJoin(FRContext.getCurrentEnv().getPath(), localDir)).exists()) {
if (new File(StableUtils.pathJoin(WorkContext.getCurrent().getPath(), localDir)).exists()) {
//本地有这个资源,不下载 //本地有这个资源,不下载
return; return;
} }
@ -145,7 +139,7 @@ public class DownloadOnlineSourcesHelper implements DownloadSourcesEvent {
if (result) { if (result) {
//安装文件 //安装文件
IOUtils.unZipFilesGBK(temp, StableUtils.pathJoin(FRContext.getCurrentEnv().getPath(), siteInfo.localDir)); IOUtils.unZipFilesGBK(temp, StableUtils.pathJoin(WorkContext.getCurrent().getPath(), siteInfo.localDir));
} }
} else { } else {
result = false; result = false;

6
designer-chart/src/com/fr/van/chart/map/server/ChartMapEditorAction.java

@ -1,7 +1,5 @@
package com.fr.van.chart.map.server; package com.fr.van.chart.map.server;
import com.fr.base.Env;
import com.fr.base.FRContext;
import com.fr.base.ServerConfig; import com.fr.base.ServerConfig;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.actions.UpdateAction; import com.fr.design.actions.UpdateAction;
@ -9,6 +7,7 @@ import com.fr.general.GeneralContext;
import com.fr.general.IOUtils; import com.fr.general.IOUtils;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.start.ServerStarter; import com.fr.start.ServerStarter;
import com.fr.workspace.WorkContext;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
@ -26,8 +25,7 @@ public class ChartMapEditorAction extends UpdateAction {
int port = DesignerEnvManager.getEnvManager().getEmbedServerPort(); int port = DesignerEnvManager.getEnvManager().getEmbedServerPort();
String web = GeneralContext.getCurrentAppNameOfEnv(); String web = GeneralContext.getCurrentAppNameOfEnv();
String serverlet = ServerConfig.getInstance().getReportServletName(); String serverlet = ServerConfig.getInstance().getReportServletName();
Env env = FRContext.getCurrentEnv(); ServerStarter.browserURLWithLocalEnv(WorkContext.getCurrent().isLocal() ? String.format("http://localhost:%d/%s/%s?op=map", port, web, serverlet) : WorkContext.getCurrent().getPath() + "?op=map");
ServerStarter.browserURLWithLocalEnv(env.isLocalEnv() ? String.format("http://localhost:%d/%s/%s?op=map", port, web, serverlet) : env.getPath() + "?op=map");
} }
} }

2
designer-form/src/com/fr/design/parameter/FormParameterReader.java

@ -17,7 +17,7 @@ public class FormParameterReader extends AbstractParameterReader {
public Parameter[] readParameterFromPath(String tplPath) { public Parameter[] readParameterFromPath(String tplPath) {
if (accept(tplPath, ".frm", ".form")) { if (accept(tplPath, ".frm", ".form")) {
try { try {
Form form = FormIO.readForm(FRContext.getCurrentEnv(), tplPath); Form form = FormIO.readForm(tplPath);
return form.getParameters(); return form.getParameters();
} catch (Exception e1) { } catch (Exception e1) {
FRContext.getLogger().error(e1.getMessage(), e1); FRContext.getLogger().error(e1.getMessage(), e1);

2
designer-realize/src/com/fr/design/actions/server/StyleManagerPane.java

@ -37,7 +37,7 @@ public class StyleManagerPane extends BasicPane {
public void populate(ServerPreferenceConfig configManager) { public void populate(ServerPreferenceConfig configManager) {
//todo 原来界面上显示的xml路径 //todo 原来界面上显示的xml路径
// this.StyleTextField.setText(FRContext.getCurrentEnv().getPath() + File.separator + // this.StyleTextField.setText(WorkContext.getCurrent().getPath() + File.separator +
// ProjectConstants.RESOURCES_NAME + // ProjectConstants.RESOURCES_NAME +
// File.separator + configManager.fileName()); // File.separator + configManager.fileName());
this.styleArrayPane.populate(configManager); this.styleArrayPane.populate(configManager);

3
designer-realize/src/com/fr/design/mainframe/AuthorityToolBarPane.java

@ -23,6 +23,7 @@ import com.fr.report.web.ToolBarManager;
import com.fr.report.web.WebContent; import com.fr.report.web.WebContent;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
import com.fr.web.attr.ReportWebAttr; import com.fr.web.attr.ReportWebAttr;
import com.fr.workspace.WorkContext;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
@ -182,7 +183,7 @@ public class AuthorityToolBarPane<T extends WebContent> extends BasicBeanPane<Re
private void checkToolBarPaneEnable() { private void checkToolBarPaneEnable() {
List<ToolBarButton> toolBarButtons = toolBarPane.getToolBarButtons(); List<ToolBarButton> toolBarButtons = toolBarPane.getToolBarButtons();
boolean isnotEnable = ComparatorUtils.equals(title.getText(), Inter.getLocText(new String[]{"Server", "ReportServerP-Toolbar", "Choose_Role"})) boolean isnotEnable = ComparatorUtils.equals(title.getText(), Inter.getLocText(new String[]{"Server", "ReportServerP-Toolbar", "Choose_Role"}))
&& !FRContext.getCurrentEnv().isRoot(); && !WorkContext.getCurrent().isRoot();
for (ToolBarButton button : toolBarButtons) { for (ToolBarButton button : toolBarButtons) {
button.setEnabled(!isnotEnable); button.setEnabled(!isnotEnable);
} }

6
designer-realize/src/com/fr/design/mainframe/JWorkBook.java

@ -62,7 +62,6 @@ import com.fr.design.selection.QuickEditor;
import com.fr.design.write.submit.DBManipulationPane; import com.fr.design.write.submit.DBManipulationPane;
import com.fr.design.write.submit.SmartInsertDBManipulationInWidgetEventPane; import com.fr.design.write.submit.SmartInsertDBManipulationInWidgetEventPane;
import com.fr.design.write.submit.SmartInsertDBManipulationPane; import com.fr.design.write.submit.SmartInsertDBManipulationPane;
import com.fr.env.RemoteEnv;
import com.fr.file.FILE; import com.fr.file.FILE;
import com.fr.file.FileNodeFILE; import com.fr.file.FileNodeFILE;
import com.fr.file.filetree.FileNode; import com.fr.file.filetree.FileNode;
@ -93,6 +92,7 @@ import com.fr.stable.StringUtils;
import com.fr.stable.module.Module; import com.fr.stable.module.Module;
import com.fr.stable.project.ProjectConstants; import com.fr.stable.project.ProjectConstants;
import com.fr.web.controller.ViewRequestConstants; import com.fr.web.controller.ViewRequestConstants;
import com.fr.workspace.WorkContext;
import javax.swing.*; import javax.swing.*;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
@ -634,7 +634,7 @@ public class JWorkBook extends JTemplate<WorkBook, WorkBookUndoState> {
public ShortCut[] shortcut4FileMenu() { public ShortCut[] shortcut4FileMenu() {
return (ShortCut[]) ArrayUtils.addAll( return (ShortCut[]) ArrayUtils.addAll(
super.shortcut4FileMenu(), super.shortcut4FileMenu(),
BaseUtils.isAuthorityEditing() || (FRContext.getCurrentEnv() instanceof RemoteEnv) ? new ShortCut[0] : new ShortCut[]{this.createWorkBookExportMenu()} BaseUtils.isAuthorityEditing() || (!WorkContext.getCurrent().isLocal()) ? new ShortCut[0] : new ShortCut[]{this.createWorkBookExportMenu()}
); );
} }
@ -1098,7 +1098,7 @@ public class JWorkBook extends JTemplate<WorkBook, WorkBookUndoState> {
java.util.Map<String, Object> parameterMap = inputParameters(tpl); java.util.Map<String, Object> parameterMap = inputParameters(tpl);
try { try {
String fullPath = StableUtils.pathJoin(FRContext.getCurrentEnv().getPath(), newFile.getPath()); String fullPath = StableUtils.pathJoin(WorkContext.getCurrent().getPath(), newFile.getPath());
FileOutputStream fileOutputStream = new FileOutputStream(fullPath); FileOutputStream fileOutputStream = new FileOutputStream(fullPath);
EmbeddedTableDataExporter exporter = new EmbeddedTableDataExporter(); EmbeddedTableDataExporter exporter = new EmbeddedTableDataExporter();
exporter.export(fileOutputStream, (WorkBook) tpl, parameterMap); exporter.export(fileOutputStream, (WorkBook) tpl, parameterMap);

8
designer-realize/src/com/fr/design/mainframe/alphafine/cell/model/PluginModel.java

@ -1,14 +1,13 @@
package com.fr.design.mainframe.alphafine.cell.model; package com.fr.design.mainframe.alphafine.cell.model;
import com.fr.base.FRContext;
import com.fr.design.extra.WebViewDlgHelper; import com.fr.design.extra.WebViewDlgHelper;
import com.fr.design.mainframe.alphafine.AlphaFineConstants; import com.fr.design.mainframe.alphafine.AlphaFineConstants;
import com.fr.design.mainframe.alphafine.CellType; import com.fr.design.mainframe.alphafine.CellType;
import com.fr.env.RemoteEnv;
import com.fr.log.FineLoggerFactory;
import com.fr.json.JSONException; import com.fr.json.JSONException;
import com.fr.json.JSONObject; import com.fr.json.JSONObject;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.workspace.WorkContext;
/** /**
* Created by XiaXiang on 2017/4/20. * Created by XiaXiang on 2017/4/20.
@ -106,7 +105,8 @@ public class PluginModel extends AlphaCellModel {
@Override @Override
public void doAction() { public void doAction() {
if (StringUtils.isBlank(this.pluginId) || FRContext.getCurrentEnv() instanceof RemoteEnv) {
if (StringUtils.isBlank(this.pluginId) || !WorkContext.getCurrent().isLocal()) {
return; return;
} }
WebViewDlgHelper.showPluginInStore(getName(), "[" + ModelToJson().optString("result") + "]"); WebViewDlgHelper.showPluginInStore(getName(), "[" + ModelToJson().optString("result") + "]");

7
designer-realize/src/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java

@ -1,7 +1,6 @@
package com.fr.design.mainframe.alphafine.component; package com.fr.design.mainframe.alphafine.component;
import com.bulenkov.iconloader.IconLoader; import com.bulenkov.iconloader.IconLoader;
import com.fr.base.FRContext;
import com.fr.config.MarketConfig; import com.fr.config.MarketConfig;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.actions.help.alphafine.AlphaFineConfigManager; import com.fr.design.actions.help.alphafine.AlphaFineConfigManager;
@ -32,13 +31,13 @@ import com.fr.design.mainframe.alphafine.search.manager.impl.RecommendSearchMana
import com.fr.form.main.Form; import com.fr.form.main.Form;
import com.fr.form.main.FormIO; import com.fr.form.main.FormIO;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.general.http.HttpClient; import com.fr.general.http.HttpClient;
import com.fr.io.TemplateWorkBookIO; import com.fr.io.TemplateWorkBookIO;
import com.fr.io.exporter.ImageExporter; import com.fr.io.exporter.ImageExporter;
import com.fr.json.JSONException; import com.fr.json.JSONException;
import com.fr.json.JSONObject; import com.fr.json.JSONObject;
import com.fr.log.FineLoggerFactory;
import com.fr.main.impl.WorkBook; import com.fr.main.impl.WorkBook;
import com.fr.stable.CodeUtils; import com.fr.stable.CodeUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
@ -507,7 +506,7 @@ public class AlphaFineDialog extends UIDialog {
protected BufferedImage doInBackground() { protected BufferedImage doInBackground() {
Form form = null; Form form = null;
try { try {
form = FormIO.readForm(FRContext.getCurrentEnv(), fileName); form = FormIO.readForm(fileName);
} catch (Exception e) { } catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage()); FineLoggerFactory.getLogger().error(e.getMessage());
} }
@ -539,7 +538,7 @@ public class AlphaFineDialog extends UIDialog {
protected BufferedImage doInBackground() { protected BufferedImage doInBackground() {
WorkBook workBook = null; WorkBook workBook = null;
try { try {
workBook = (WorkBook) TemplateWorkBookIO.readTemplateWorkBook(FRContext.getCurrentEnv(), fileName); workBook = (WorkBook) TemplateWorkBookIO.readTemplateWorkBook(fileName);
} catch (Exception e) { } catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage()); FineLoggerFactory.getLogger().error(e.getMessage());
} }

31
designer-realize/src/com/fr/design/mainframe/alphafine/search/manager/impl/FileSearchManager.java

@ -1,6 +1,5 @@
package com.fr.design.mainframe.alphafine.search.manager.impl; package com.fr.design.mainframe.alphafine.search.manager.impl;
import com.fr.base.Env;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.mainframe.alphafine.AlphaFineConstants; import com.fr.design.mainframe.alphafine.AlphaFineConstants;
@ -18,6 +17,7 @@ import com.fr.log.FineLoggerFactory;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.stable.project.ProjectConstants; import com.fr.stable.project.ProjectConstants;
import com.fr.workspace.WorkContext;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
@ -80,13 +80,12 @@ public class FileSearchManager implements AlphaFineSearchProvider {
lessModelList.add(new MoreModel(Inter.getLocText("FR-Designer_Templates"))); lessModelList.add(new MoreModel(Inter.getLocText("FR-Designer_Templates")));
return lessModelList; return lessModelList;
} }
Env env = FRContext.getCurrentEnv();
fileNodes = new ArrayList<>(); fileNodes = new ArrayList<>();
fileNodes = listTpl(env, ProjectConstants.REPORTLETS_NAME, true); fileNodes = listTpl(ProjectConstants.REPORTLETS_NAME, true);
AlphaFineHelper.checkCancel(); AlphaFineHelper.checkCancel();
isContainCpt = true; isContainCpt = true;
isContainFrm = true; isContainFrm = true;
doSearch(this.searchText, true, env); doSearch(this.searchText, true);
if (stopSearch) { if (stopSearch) {
lessModelList.add(0, new MoreModel(Inter.getLocText("FR-Designer_Templates"), Inter.getLocText("FR-Designer_AlphaFine_ShowAll"), true, CellType.FILE)); lessModelList.add(0, new MoreModel(Inter.getLocText("FR-Designer_Templates"), Inter.getLocText("FR-Designer_AlphaFine_ShowAll"), true, CellType.FILE));
lessModelList.addAll(filterModelList.subList(0, AlphaFineConstants.SHOW_SIZE)); lessModelList.addAll(filterModelList.subList(0, AlphaFineConstants.SHOW_SIZE));
@ -108,21 +107,20 @@ public class FileSearchManager implements AlphaFineSearchProvider {
} }
this.filterModelList = new SearchResult(); this.filterModelList = new SearchResult();
this.moreModelList = new SearchResult(); this.moreModelList = new SearchResult();
Env env = FRContext.getCurrentEnv();
AlphaFineHelper.checkCancel(); AlphaFineHelper.checkCancel();
isContainCpt = true; isContainCpt = true;
isContainFrm = true; isContainFrm = true;
doSearch(this.searchText, false, env); doSearch(this.searchText, false);
moreModelList.addAll(filterModelList.subList(AlphaFineConstants.SHOW_SIZE, filterModelList.size())); moreModelList.addAll(filterModelList.subList(AlphaFineConstants.SHOW_SIZE, filterModelList.size()));
return moreModelList; return moreModelList;
} }
private void doSearch(String searchText, boolean needMore, Env env) { private void doSearch(String searchText, boolean needMore) {
for (FileNode node : fileNodes) { for (FileNode node : fileNodes) {
boolean isAlreadyContain = false; boolean isAlreadyContain = false;
isAlreadyContain = searchFile(searchText, node, isAlreadyContain, needMore); isAlreadyContain = searchFile(searchText, node, isAlreadyContain, needMore);
if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isContainFileContent() && node.getLock() == null) { if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isContainFileContent() && node.getLock() == null) {
searchFileContent(env, searchText, node, isAlreadyContain, needMore); searchFileContent(searchText, node, isAlreadyContain, needMore);
} }
if (filterModelList.size() > AlphaFineConstants.SHOW_SIZE && stopSearch) { if (filterModelList.size() > AlphaFineConstants.SHOW_SIZE && stopSearch) {
return; return;
@ -149,9 +147,9 @@ public class FileSearchManager implements AlphaFineSearchProvider {
* @param node * @param node
* @param isAlreadyContain * @param isAlreadyContain
*/ */
private void searchFileContent(Env env, String searchText, FileNode node, boolean isAlreadyContain, boolean needMore) { private void searchFileContent(String searchText, FileNode node, boolean isAlreadyContain, boolean needMore) {
try { try {
InputStream inputStream = new ByteArrayInputStream(env.getFileOperator().read(StableUtils.pathJoin(ProjectConstants.REPORTLETS_NAME, node.getEnvPath().substring(ProjectConstants.REPORTLETS_NAME.length() + 1)))); InputStream inputStream = new ByteArrayInputStream(WorkContext.getWorkResource().readFully(StableUtils.pathJoin(ProjectConstants.REPORTLETS_NAME, node.getEnvPath().substring(ProjectConstants.REPORTLETS_NAME.length() + 1))));
InputStreamReader isr = new InputStreamReader(inputStream, "UTF-8"); InputStreamReader isr = new InputStreamReader(inputStream, "UTF-8");
BufferedReader reader = new BufferedReader(isr); BufferedReader reader = new BufferedReader(isr);
String line; String line;
@ -209,15 +207,14 @@ public class FileSearchManager implements AlphaFineSearchProvider {
/** /**
* 获取工作目录下所有符合要求的模板 * 获取工作目录下所有符合要求的模板
* *
* @param env
* @param rootFilePath * @param rootFilePath
* @param recurse * @param recurse
* @return * @return
*/ */
private List<FileNode> listTpl(Env env, String rootFilePath, boolean recurse) { private List<FileNode> listTpl(String rootFilePath, boolean recurse) {
List<FileNode> fileNodeList = new ArrayList<FileNode>(); List<FileNode> fileNodeList = new ArrayList<FileNode>();
try { try {
listAll(env, rootFilePath, fileNodeList, recurse); listAll(rootFilePath, fileNodeList, recurse);
} catch (Exception e) { } catch (Exception e) {
FRContext.getLogger().error("file search error: " + e.getMessage(), e); FRContext.getLogger().error("file search error: " + e.getMessage(), e);
} }
@ -227,19 +224,19 @@ public class FileSearchManager implements AlphaFineSearchProvider {
/** /**
* 获取当前工作目录下所有模板 * 获取当前工作目录下所有模板
* *
* @param env
* @param rootFilePath * @param rootFilePath
* @param nodeList * @param nodeList
* @param recurse * @param recurse
* @throws Exception * @throws Exception
*/ */
private void listAll(Env env, String rootFilePath, List<FileNode> nodeList, boolean recurse) throws Exception { private void listAll(String rootFilePath, List<FileNode> nodeList, boolean recurse) throws Exception {
FileNode[] fns = env.getFileOperator().list(rootFilePath);
FileNode[] fns = FRContext.getFileNodes().list(rootFilePath);
for (int i = 0; i < fns.length; i++) { for (int i = 0; i < fns.length; i++) {
FileNode fileNode = fns[i]; FileNode fileNode = fns[i];
if (fileNode.isDirectory()) { if (fileNode.isDirectory()) {
if (recurse) { if (recurse) {
listAll(env, rootFilePath + File.separator + fns[i].getName(), nodeList, true); listAll(rootFilePath + File.separator + fns[i].getName(), nodeList, true);
} else { } else {
nodeList.add(fns[i]); nodeList.add(fns[i]);
} }

4
designer-realize/src/com/fr/design/mainframe/errorinfo/ErrorInfoLogAppender.java

@ -1,6 +1,5 @@
package com.fr.design.mainframe.errorinfo; package com.fr.design.mainframe.errorinfo;
import com.fr.base.FRContext;
import com.fr.base.io.IOFile; import com.fr.base.io.IOFile;
import com.fr.base.io.XMLReadHelper; import com.fr.base.io.XMLReadHelper;
import com.fr.config.MarketConfig; import com.fr.config.MarketConfig;
@ -18,6 +17,7 @@ import com.fr.third.apache.log4j.Level;
import com.fr.third.apache.log4j.spi.LoggingEvent; import com.fr.third.apache.log4j.spi.LoggingEvent;
import com.fr.web.core.SessionDealWith; import com.fr.web.core.SessionDealWith;
import com.fr.web.core.SessionIDInfor; import com.fr.web.core.SessionIDInfor;
import com.fr.workspace.WorkContext;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.InputStream; import java.io.InputStream;
@ -134,7 +134,7 @@ public class ErrorInfoLogAppender extends AppenderSkeleton {
} }
}; };
try { try {
file.readStream(new ByteArrayInputStream(FRContext.getCurrentEnv().getFileOperator().read(StableUtils.pathJoin(ProjectConstants.REPORTLETS_NAME, bookPath)))); file.readStream(new ByteArrayInputStream(WorkContext.getWorkResource().readFully(StableUtils.pathJoin(ProjectConstants.REPORTLETS_NAME, bookPath))));
return file.getTemplateID(); return file.getTemplateID();
} catch (Exception ignore) { } catch (Exception ignore) {
} }

2
designer-realize/src/com/fr/design/parameter/WorkBookParameterReader.java

@ -17,7 +17,7 @@ public class WorkBookParameterReader extends AbstractParameterReader {
public Parameter[] readParameterFromPath(String tplPath) { public Parameter[] readParameterFromPath(String tplPath) {
if (accept(tplPath, ".cpt")) { if (accept(tplPath, ".cpt")) {
try { try {
TemplateWorkBook template = TemplateWorkBookIO.readTemplateWorkBook(FRContext.getCurrentEnv(), tplPath); TemplateWorkBook template = TemplateWorkBookIO.readTemplateWorkBook(tplPath);
return template.getParameters(); return template.getParameters();
} catch (Exception e1) { } catch (Exception e1) {
FRContext.getLogger().error(e1.getMessage(), e1); FRContext.getLogger().error(e1.getMessage(), e1);

20
designer-realize/src/com/fr/design/report/freeze/RepeatAndFreezeSettingPane.java

@ -1,13 +1,5 @@
package com.fr.design.report.freeze; package com.fr.design.report.freeze;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.BasicPane;
import com.fr.design.extra.WebViewDlgHelper; import com.fr.design.extra.WebViewDlgHelper;
@ -15,12 +7,19 @@ import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.ilable.ActionLabel; import com.fr.design.gui.ilable.ActionLabel;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.env.RemoteEnv;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.page.ReportPageAttrProvider; import com.fr.page.ReportPageAttrProvider;
import com.fr.stable.ColumnRow; import com.fr.stable.ColumnRow;
import com.fr.stable.FT; import com.fr.stable.FT;
import com.fr.stable.bridge.StableFactory; import com.fr.stable.bridge.StableFactory;
import com.fr.workspace.WorkContext;
import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
/** /**
* Sets Report Page Attributes * Sets Report Page Attributes
@ -244,7 +243,8 @@ public class RepeatAndFreezeSettingPane extends BasicPane {
} }
private boolean shouldShowTip() { private boolean shouldShowTip() {
return !(FRContext.getCurrentEnv() instanceof RemoteEnv) && FRContext.isChineseEnv();
return WorkContext.getCurrent().isLocal() && FRContext.isChineseEnv();
} }
protected void initWriteListener() { protected void initWriteListener() {

16
designer-realize/src/com/fr/design/report/share/ShareButton.java

@ -23,11 +23,21 @@ import com.fr.general.SiteCenter;
import com.fr.io.exporter.ImageExporter; import com.fr.io.exporter.ImageExporter;
import com.fr.main.TemplateWorkBook; import com.fr.main.TemplateWorkBook;
import com.fr.main.workbook.ResultWorkBook; import com.fr.main.workbook.ResultWorkBook;
import com.fr.stable.*; import com.fr.stable.ActorConstants;
import com.fr.stable.ActorFactory;
import com.fr.stable.ArrayUtils;
import com.fr.stable.Nameable;
import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils;
import com.fr.stable.project.ProjectConstants; import com.fr.stable.project.ProjectConstants;
import com.fr.workspace.WorkContext;
import java.awt.*; import java.awt.*;
import java.awt.event.*; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
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.FileOutputStream; import java.io.FileOutputStream;
import java.net.URI; import java.net.URI;
@ -84,7 +94,7 @@ public class ShareButton extends UIButton{
//获取默认导出图片位置 //获取默认导出图片位置
private String getImagePath(JTemplate<?, ?> jt){ private String getImagePath(JTemplate<?, ?> jt){
FILE file = jt.getEditingFILE(); FILE file = jt.getEditingFILE();
String envPath = FRContext.getCurrentEnv().getPath(); String envPath = WorkContext.getCurrent().getPath();
String folderPath = file.getParent().getPath(); String folderPath = file.getParent().getPath();
String imageName = file.getName().replaceAll(ProjectConstants.CPT_SUFFIX, StringUtils.EMPTY) + ".png"; String imageName = file.getName().replaceAll(ProjectConstants.CPT_SUFFIX, StringUtils.EMPTY) + ".png";

2
designer-realize/src/com/fr/design/webattr/EditReportServerParameterPane.java

@ -81,7 +81,7 @@ public class EditReportServerParameterPane extends LoadingBasicPane {
public void populate(ServerPreferenceConfig reportServerPreferenceConfig) { public void populate(ServerPreferenceConfig reportServerPreferenceConfig) {
//todo 原来界面上显示的xml路径 //todo 原来界面上显示的xml路径
// this.configFileTextField.setText(FRContext.getCurrentEnv().getPath() + File.separator + // this.configFileTextField.setText(WorkContext.getCurrent().getPath() + File.separator +
// ProjectConstants.RESOURCES_NAME + // ProjectConstants.RESOURCES_NAME +
// File.separator + reportServerPreferenceConfig.fileName()); // File.separator + reportServerPreferenceConfig.fileName());

2
designer-realize/src/com/fr/design/webattr/WidgetManagerPane.java

@ -42,7 +42,7 @@ public class WidgetManagerPane extends LoadingBasicPane {
public void populate(WidgetInfoConfig widgetManager) { public void populate(WidgetInfoConfig widgetManager) {
//todo 原来界面上显示的xml路径 //todo 原来界面上显示的xml路径
// this.widgetTextField.setText(FRContext.getCurrentEnv().getPath() + File.separator + // this.widgetTextField.setText(WorkContext.getCurrent().getPath() + File.separator +
// ProjectConstants.RESOURCES_NAME + // ProjectConstants.RESOURCES_NAME +
// File.separator + widgetManager.fileName()); // File.separator + widgetManager.fileName());
this.widgetConfigPane.populate(widgetManager); this.widgetConfigPane.populate(widgetManager);

23
designer-realize/src/com/fr/start/Designer.java

@ -1,9 +1,7 @@
package com.fr.start; package com.fr.start;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.base.Env;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.dav.LocalEnv;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.actions.core.ActionFactory; import com.fr.design.actions.core.ActionFactory;
import com.fr.design.actions.file.WebPreviewUtils; import com.fr.design.actions.file.WebPreviewUtils;
@ -56,15 +54,11 @@ import com.fr.start.jni.SplashMac;
import com.fr.start.module.StartupArgs; import com.fr.start.module.StartupArgs;
import com.fr.start.preload.ImagePreLoader; import com.fr.start.preload.ImagePreLoader;
import com.fr.start.server.ServerTray; import com.fr.start.server.ServerTray;
import com.fr.workspace.WorkContext;
import javax.swing.JComponent; import javax.swing.*;
import javax.swing.JPanel;
import javax.swing.border.MatteBorder; import javax.swing.border.MatteBorder;
import java.awt.Component; import java.awt.*;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.io.File; import java.io.File;
@ -104,7 +98,7 @@ public class Designer extends BaseDesigner {
//传递启动参数 //传递启动参数
designerRoot.setSingleton(StartupArgs.class, new StartupArgs(args)); designerRoot.setSingleton(StartupArgs.class, new StartupArgs(args));
designerRoot.start(); designerRoot.start();
if (FRContext.getCurrentEnv() instanceof LocalEnv) { if (WorkContext.getCurrent().isLocal()) {
//初始化一下serverTray //初始化一下serverTray
ServerTray.init(); ServerTray.init();
} }
@ -183,14 +177,14 @@ public class Designer extends BaseDesigner {
protected MenuDef createServerMenuDef(ToolBarMenuDockPlus plus) { protected MenuDef createServerMenuDef(ToolBarMenuDockPlus plus) {
MenuDef menuDef = super.createServerMenuDef(plus); MenuDef menuDef = super.createServerMenuDef(plus);
if (FRContext.getCurrentEnv() == null) { if (WorkContext.getCurrent() == null) {
return menuDef; return menuDef;
} }
if (!BaseUtils.isAuthorityEditing()) { if (!BaseUtils.isAuthorityEditing()) {
menuDef.addShortCut(SeparatorDef.DEFAULT); menuDef.addShortCut(SeparatorDef.DEFAULT);
if (FRContext.getCurrentEnv().isRoot()) { if (WorkContext.getCurrent().isRoot()) {
menuDef.addShortCut(new ServerConfigManagerAction(), new StyleListAction(), new WidgetManagerAction()); menuDef.addShortCut(new ServerConfigManagerAction(), new StyleListAction(), new WidgetManagerAction());
if (ActionFactory.getChartPreStyleAction() != null) { if (ActionFactory.getChartPreStyleAction() != null) {
menuDef.addShortCut(ActionFactory.getChartPreStyleAction()); menuDef.addShortCut(ActionFactory.getChartPreStyleAction());
@ -533,11 +527,6 @@ public class Designer extends BaseDesigner {
InformationCollector collector = InformationCollector.getInstance(); InformationCollector collector = InformationCollector.getInstance();
collector.collectStopTime(); collector.collectStopTime();
collector.saveXMLFile(); collector.saveXMLFile();
Env currentEnv = FRContext.getCurrentEnv();
if (currentEnv == null) {
return;
}
currentEnv.doWhenServerShutDown();
} }
} }

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

@ -1,10 +1,10 @@
package com.fr.start; package com.fr.start;
import com.fr.base.Env;
import com.fr.base.env.EnvUpdater;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.env.EnvGenerator; import com.fr.design.env.DesignerWorkspaceGenerator;
import com.fr.design.mainframe.TemplatePane; import com.fr.design.mainframe.TemplatePane;
import com.fr.workspace.WorkContext;
import com.fr.workspace.Workspace;
/** /**
* Created by juhaoyu on 2018/1/31. * Created by juhaoyu on 2018/1/31.
@ -13,14 +13,17 @@ import com.fr.design.mainframe.TemplatePane;
public class EnvSwitcher { public class EnvSwitcher {
public void switch2LastEnv() { public void switch2LastEnv() {
try { try {
String current = DesignerEnvManager.getEnvManager().getCurEnvName(); String current = DesignerEnvManager.getEnvManager().getCurEnvName();
Env env = EnvGenerator.generate(DesignerEnvManager.getEnvManager().getEnv(current)); Workspace workspace = DesignerWorkspaceGenerator.generate(DesignerEnvManager.getEnvManager().getWorkspaceInfo(current));
EnvUpdater.updateEnv(env); if (workspace == null) {
} catch (Exception e) { TemplatePane.getInstance().dealEvnExceptionWhenStartDesigner();
} else {
WorkContext.switchTo(workspace);
}
} catch (Throwable e) {
TemplatePane.getInstance().dealEvnExceptionWhenStartDesigner(); TemplatePane.getInstance().dealEvnExceptionWhenStartDesigner();
} }
} }
} }

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

@ -1,234 +0,0 @@
package com.fr.start.module;
import com.fr.base.Env;
import com.fr.base.ModifiedTable;
import com.fr.base.Parameter;
import com.fr.base.StoreProcedureParameter;
import com.fr.base.TableData;
import com.fr.base.env.EnvUpdater;
import com.fr.base.env.serializer.OldSerializerAdapter;
import com.fr.base.env.serializer.ProcedureDataModelSerializer;
import com.fr.core.env.EnvConfig;
import com.fr.core.env.EnvEvent;
import com.fr.core.env.proxy.EnvProxy;
import com.fr.data.core.db.TableProcedure;
import com.fr.data.impl.Connection;
import com.fr.data.impl.storeproc.ProcedureDataModel;
import com.fr.data.impl.storeproc.StoreProcedure;
import com.fr.dav.DavXMLUtils;
import com.fr.design.DesignerEnvManager;
import com.fr.design.env.EnvGenerator;
import com.fr.event.Event;
import com.fr.event.EventDispatcher;
import com.fr.event.Listener;
import com.fr.file.filetree.FileNode;
import com.fr.general.ComparatorUtils;
import com.fr.module.Activator;
import com.fr.start.EnvSwitcher;
import com.fr.start.ServerStarter;
import java.io.InputStream;
import java.io.OutputStream;
/**
* Created by juhaoyu on 2018/1/8.
* 设计器启动时的环境相关模块activator
*/
public class DesignerEnvProvider extends Activator {
@Override
public void start() {
String[] args = getModule().upFindSingleton(StartupArgs.class).get();
if (args != null) {
for (String arg : args) {
if (ComparatorUtils.equals(arg, "demo")) {
DesignerEnvManager.getEnvManager().setCurrentEnv2Default();
ServerStarter.browserDemoURL();
break;
}
}
}
initDesignerEnv();
getRoot().setSingleton(EnvSwitcher.class, new EnvSwitcher());
//设置好环境即可,具体跟环境有关的模块会自动调用
getRoot().getSingleton(EnvSwitcher.class).switch2LastEnv();
}
private void initDesignerEnv() {
addSerializers();
EventDispatcher.listen(EnvEvent.BEFORE_SIGN_IN, new Listener<EnvConfig>() {
@Override
public void on(Event event, EnvConfig envConfig) {
Env env = EnvGenerator.generate(envConfig);
EnvUpdater.updateEnv(env);
}
});
}
private void addSerializers() {
EnvProxy.addSerializer(ProcedureDataModel[].class, new ProcedureDataModelSerializer());
EnvProxy.addSerializer(ModifiedTable.class, new OldSerializerAdapter<ModifiedTable>(
new OldSerializerAdapter.OldSerializer<ModifiedTable>() {
@Override
public void serializer(ModifiedTable obj, OutputStream out) throws Exception {
DavXMLUtils.writeXMLModifiedTables(obj, out);
}
},
new OldSerializerAdapter.OldDeserializer<ModifiedTable>() {
@Override
public ModifiedTable deserializer(InputStream in) throws Exception {
return DavXMLUtils.readXMLModifiedTables(in);
}
}
));
EnvProxy.addSerializer(com.fr.data.impl.Connection.class, new OldSerializerAdapter<com.fr.data.impl.Connection>(
new OldSerializerAdapter.OldSerializer<Connection>() {
@Override
public void serializer(Connection obj, OutputStream out) {
DavXMLUtils.writeXMLFileDatabaseConnection(obj, out);
}
},
new OldSerializerAdapter.OldDeserializer<Connection>() {
@Override
public Connection deserializer(InputStream in) throws Exception {
return DavXMLUtils.readXMLDatabaseConnection(in);
}
}
));
EnvProxy.addSerializer(FileNode[].class, new OldSerializerAdapter<FileNode[]>(
new OldSerializerAdapter.OldSerializer<FileNode[]>() {
@Override
public void serializer(FileNode[] obj, OutputStream out) {
DavXMLUtils.writeXMLFileNodes(obj, out);
}
},
new OldSerializerAdapter.OldDeserializer<FileNode[]>() {
@Override
public FileNode[] deserializer(InputStream in) {
return DavXMLUtils.readXMLFileNodes(in);
}
}
));
EnvProxy.addSerializer(TableProcedure[].class, new OldSerializerAdapter<TableProcedure[]>(
new OldSerializerAdapter.OldSerializer<TableProcedure[]>() {
@Override
public void serializer(TableProcedure[] obj, OutputStream out) {
DavXMLUtils.writeXMLFileSQLTable(obj, out);
}
},
new OldSerializerAdapter.OldDeserializer<TableProcedure[]>() {
@Override
public TableProcedure[] deserializer(InputStream in) throws Exception {
return DavXMLUtils.readXMLSQLTables(in);
}
}
));
EnvProxy.addSerializer(TableData.class, new OldSerializerAdapter<TableData>(
new OldSerializerAdapter.OldSerializer<TableData>() {
@Override
public void serializer(TableData obj, OutputStream out) {
DavXMLUtils.writeXMLFileTableData(obj, out);
}
},
new OldSerializerAdapter.OldDeserializer<TableData>() {
@Override
public TableData deserializer(InputStream in) throws Exception {
return DavXMLUtils.readXMLTableData(in);
}
}
));
EnvProxy.addSerializer(Parameter[].class, new OldSerializerAdapter<Parameter[]>(
new OldSerializerAdapter.OldSerializer<Parameter[]>() {
@Override
public void serializer(Parameter[] obj, OutputStream out) {
DavXMLUtils.writeXMLFileParameters(obj, out);
}
},
new OldSerializerAdapter.OldDeserializer<Parameter[]>() {
@Override
public Parameter[] deserializer(InputStream in) throws Exception {
return DavXMLUtils.readXMLParameters(in);
}
}
));
EnvProxy.addSerializer(StoreProcedure.class, new OldSerializerAdapter<StoreProcedure>(
new OldSerializerAdapter.OldSerializer<StoreProcedure>() {
@Override
public void serializer(StoreProcedure obj, OutputStream out) {
DavXMLUtils.writeXMLFileStoreProcedure(obj, out);
}
},
new OldSerializerAdapter.OldDeserializer<StoreProcedure>() {
@Override
public StoreProcedure deserializer(InputStream in) throws Exception {
return DavXMLUtils.readXMLStoreProcedure(in);
}
}
));
EnvProxy.addSerializer(StoreProcedureParameter[].class, new OldSerializerAdapter<StoreProcedureParameter[]>(
new OldSerializerAdapter.OldSerializer<StoreProcedureParameter[]>() {
@Override
public void serializer(StoreProcedureParameter[] obj, OutputStream out) {
DavXMLUtils.writeXMLFileParameters(obj, out);
}
},
new OldSerializerAdapter.OldDeserializer<StoreProcedureParameter[]>() {
@Override
public StoreProcedureParameter[] deserializer(InputStream in) throws Exception {
return DavXMLUtils.readXMLStoreProcedureParameters(in);
}
}
));
}
@Override
public void stop() {
//清空模块
getRoot().removeSingleton(EnvSwitcher.class);
}
}

14
designer-realize/src/com/fr/start/module/DesignerStartup.java

@ -1,7 +1,5 @@
package com.fr.start.module; package com.fr.start.module;
import com.fr.core.env.EnvConfig;
import com.fr.core.env.EnvEvent;
import com.fr.event.Event; import com.fr.event.Event;
import com.fr.event.Listener; import com.fr.event.Listener;
import com.fr.module.Activator; import com.fr.module.Activator;
@ -9,6 +7,8 @@ import com.fr.start.Designer;
import com.fr.start.EnvSwitcher; import com.fr.start.EnvSwitcher;
import com.fr.start.SplashContext; import com.fr.start.SplashContext;
import com.fr.startup.activators.BasicActivator; import com.fr.startup.activators.BasicActivator;
import com.fr.workspace.Workspace;
import com.fr.workspace.WorkspaceEvent;
/** /**
* Created by juhaoyu on 2018/1/8. * Created by juhaoyu on 2018/1/8.
@ -23,7 +23,7 @@ public class DesignerStartup extends Activator {
String[] args = getModule().upFindSingleton(StartupArgs.class).get(); String[] args = getModule().upFindSingleton(StartupArgs.class).get();
Designer designer = new Designer(args); Designer designer = new Designer(args);
//启动env //启动env
startSub(DesignerEnvProvider.class); startSub(DesignerWorkspaceProvider.class);
startSub(EnvBasedModule.class); startSub(EnvBasedModule.class);
getRoot().getSingleton(EnvSwitcher.class).switch2LastEnv(); getRoot().getSingleton(EnvSwitcher.class).switch2LastEnv();
registerEnvListener(); registerEnvListener();
@ -39,18 +39,18 @@ public class DesignerStartup extends Activator {
*/ */
private void registerEnvListener() { private void registerEnvListener() {
listenEvent(EnvEvent.BEFORE_SIGN_OUT, new Listener<EnvConfig>() { listenEvent(WorkspaceEvent.BeforeSwitch, new Listener<Workspace>() {
@Override @Override
public void on(Event event, EnvConfig param) { public void on(Event event, Workspace param) {
getSub(EnvBasedModule.class).stop(); getSub(EnvBasedModule.class).stop();
} }
}); });
listenEvent(EnvEvent.AFTER_SIGN_IN, new Listener<EnvConfig>() { listenEvent(WorkspaceEvent.AfterSwitch, new Listener<Workspace>() {
@Override @Override
public void on(Event event, EnvConfig param) { public void on(Event event, Workspace param) {
getSub(EnvBasedModule.class).start(); getSub(EnvBasedModule.class).start();
} }

41
designer-realize/src/com/fr/start/module/DesignerWorkspaceProvider.java

@ -0,0 +1,41 @@
package com.fr.start.module;
import com.fr.design.DesignerEnvManager;
import com.fr.general.ComparatorUtils;
import com.fr.module.Activator;
import com.fr.start.EnvSwitcher;
import com.fr.start.ServerStarter;
/**
* Created by juhaoyu on 2018/1/8.
* 设计器启动时的环境相关模块activator
*/
public class DesignerWorkspaceProvider extends Activator {
@Override
public void start() {
String[] args = getModule().upFindSingleton(StartupArgs.class).get();
if (args != null) {
for (String arg : args) {
if (ComparatorUtils.equals(arg, "demo")) {
DesignerEnvManager.getEnvManager().setCurrentEnv2Default();
ServerStarter.browserDemoURL();
break;
}
}
}
getRoot().setSingleton(EnvSwitcher.class, new EnvSwitcher());
//设置好环境即可,具体跟环境有关的模块会自动调用
getRoot().getSingleton(EnvSwitcher.class).switch2LastEnv();
}
@Override
public void stop() {
//清空模块
getRoot().removeSingleton(EnvSwitcher.class);
}
}
Loading…
Cancel
Save