From a48c9ab91c1a8350aa72add1912ea3f77772fe8c Mon Sep 17 00:00:00 2001 From: ju Date: Thu, 14 Jun 2018 21:44:40 +0800 Subject: [PATCH 01/20] =?UTF-8?q?REPORT-8790=20=E6=94=B9=E5=8A=A8=E5=A4=AA?= =?UTF-8?q?=E5=A4=9A=E4=BA=86=EF=BC=8C=E5=85=88commit=E4=B8=80=E6=AC=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/com/fr/design/DesignerEnvManager.java | 23 +++---- .../design/actions/file/SwitchExistEnv.java | 14 ++--- .../env/DesignerWorkspaceGenerator.java | 29 +++++++++ .../src/com/fr/design/env/EnvGenerator.java | 22 ------- .../com/fr/design/env/RemoteEnvConfig.java | 7 ++- .../com/fr/design/env/RemoteWorkspace.java | 61 +++++++++++++++++++ .../design/file/HistoryTemplateListPane.java | 4 +- .../com/fr/design/file/TemplateTreePane.java | 4 +- .../fr/design/mainframe/DesignerFrame.java | 26 ++------ .../com/fr/design/mainframe/TemplatePane.java | 18 ++---- .../loghandler/socketio/DesignerSocketIO.java | 6 +- designer-base/src/com/fr/env/EnvListPane.java | 4 +- .../src/com/fr/env/LocalEnvPane.java | 2 +- designer-base/src/com/fr/env/RemoteEnv.java | 30 +-------- .../src/com/fr/env/RemoteEnvPane.java | 1 - designer-base/src/com/fr/env/SignIn.java | 46 -------------- .../src/com/fr/start/ServerStarter.java | 6 +- .../src/com/fr/start/EnvSwitcher.java | 10 +-- .../fr/start/module/DesignerEnvProvider.java | 15 ----- .../com/fr/start/module/DesignerStartup.java | 2 +- 20 files changed, 145 insertions(+), 185 deletions(-) create mode 100644 designer-base/src/com/fr/design/env/DesignerWorkspaceGenerator.java delete mode 100644 designer-base/src/com/fr/design/env/EnvGenerator.java create mode 100644 designer-base/src/com/fr/design/env/RemoteWorkspace.java delete mode 100644 designer-base/src/com/fr/env/SignIn.java diff --git a/designer-base/src/com/fr/design/DesignerEnvManager.java b/designer-base/src/com/fr/design/DesignerEnvManager.java index 956871424d..54564ced18 100644 --- a/designer-base/src/com/fr/design/DesignerEnvManager.java +++ b/designer-base/src/com/fr/design/DesignerEnvManager.java @@ -6,12 +6,11 @@ package com.fr.design; import com.fr.base.BaseXMLUtils; import com.fr.base.FRContext; 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.base.env.EnvConfig; +import com.fr.base.env.LocalEnvConfig; import com.fr.design.actions.help.alphafine.AlphaFineConfigManager; import com.fr.design.constants.UIConstants; -import com.fr.design.env.EnvGenerator; +import com.fr.design.env.DesignerWorkspaceGenerator; import com.fr.file.FILEFactory; import com.fr.general.ComparatorUtils; import com.fr.general.FRLogFormatter; @@ -33,6 +32,7 @@ import com.fr.stable.xml.XMLReadable; import com.fr.stable.xml.XMLTools; import com.fr.stable.xml.XMLWriter; import com.fr.stable.xml.XMLableReader; +import com.fr.workspace.WorkContext; import javax.swing.*; import javax.swing.SwingWorker.StateValue; @@ -194,7 +194,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { if (installHome != null) { String name = Inter.getLocText("FR-Engine_DEFAULT"); String envPath = StableUtils.pathJoin(new String[]{installHome, ProjectConstants.WEBAPP_NAME, ProjectConstants.WEBINF_NAME}); - designerEnvManager.putEnv(name, new LocalEnvConfig(envPath)); + designerEnvManager.putEnv(name, new LocalEnvConfig(envPath, name)); designerEnvManager.setCurEnvName(name); } } @@ -482,7 +482,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { /** * 返回默认环境 */ - public EnvConfig getDefaultEnv() { + public EnvConfig getDefaultConfig() { String installHome = StableUtils.getInstallHome(); String defaultenvPath = StableUtils.pathJoin(installHome, ProjectConstants.WEBAPP_NAME, ProjectConstants.WEBINF_NAME); defaultenvPath = new File(defaultenvPath).getPath(); @@ -494,8 +494,9 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { return env; } } - EnvConfig newDefaultEnv = new LocalEnvConfig(defaultenvPath); - this.putEnv(Inter.getLocText(new String[]{"Default", "Utils-Report_Runtime_Env"}), newDefaultEnv); + String name = Inter.getLocText(new String[]{"Default", "Utils-Report_Runtime_Env"}); + EnvConfig newDefaultEnv = new LocalEnvConfig(defaultenvPath, name); + this.putEnv(name, newDefaultEnv); return newDefaultEnv; } @@ -526,7 +527,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { if (isCurrentEnvDefault()) { return; } - EnvUpdater.updateEnv(EnvGenerator.generate(getDefaultEnv())); + WorkContext.switchTo(DesignerWorkspaceGenerator.generate(getDefaultConfig())); } /** @@ -1416,9 +1417,9 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { if ((tmpVal = reader.getAttrAsString("webinfLocation", null)) != null) { // marks:兼容6.1的 // marks:设置默认的目录. - EnvConfig reportServer = new LocalEnvConfig(tmpVal); - String curReportServerName = Inter.getLocText("Server-Embedded_Server"); + EnvConfig reportServer = new LocalEnvConfig(tmpVal,curReportServerName); + this.putEnv(curReportServerName, reportServer); this.setCurEnvName(curReportServerName); } diff --git a/designer-base/src/com/fr/design/actions/file/SwitchExistEnv.java b/designer-base/src/com/fr/design/actions/file/SwitchExistEnv.java index c956670576..f21fb69910 100644 --- a/designer-base/src/com/fr/design/actions/file/SwitchExistEnv.java +++ b/designer-base/src/com/fr/design/actions/file/SwitchExistEnv.java @@ -1,15 +1,13 @@ package com.fr.design.actions.file; 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.base.env.EnvConfig; +import com.fr.base.env.LocalEnvConfig; import com.fr.design.DesignerEnvManager; import com.fr.design.actions.UpdateAction; import com.fr.design.data.DesignTableDataManager; 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.file.HistoryTemplateListPane; import com.fr.design.mainframe.DesignerContext; @@ -19,11 +17,11 @@ import com.fr.design.menu.KeySetUtils; import com.fr.design.menu.MenuDef; import com.fr.design.menu.SeparatorDef; import com.fr.design.utils.DesignUtils; -import com.fr.env.RemoteEnv; import com.fr.general.GeneralContext; import com.fr.general.Inter; -import com.fr.log.FineLoggerFactory; import com.fr.stable.EnvChangedListener; +import com.fr.workspace.WorkContext; +import com.fr.workspace.WorkContextCallback; import javax.swing.*; import java.awt.event.ActionEvent; @@ -102,7 +100,7 @@ public class SwitchExistEnv extends MenuDef { DesignerEnvManager envManager = DesignerEnvManager.getEnvManager(); final String envName = getName(); EnvConfig selectedEnv = envManager.getEnv(envName); - EnvUpdater.updateEnv(EnvGenerator.generate(selectedEnv), new Callback() { + WorkContext.switchTo(DesignerWorkspaceGenerator.generate(selectedEnv), new WorkContextCallback() { @Override public void success() { DesignerEnvManager.getEnvManager().setCurEnvName(envName); diff --git a/designer-base/src/com/fr/design/env/DesignerWorkspaceGenerator.java b/designer-base/src/com/fr/design/env/DesignerWorkspaceGenerator.java new file mode 100644 index 0000000000..1197b9cb55 --- /dev/null +++ b/designer-base/src/com/fr/design/env/DesignerWorkspaceGenerator.java @@ -0,0 +1,29 @@ +package com.fr.design.env; + +import com.fr.base.Env; +import com.fr.base.env.EnvConfig; +import com.fr.base.env.LocalEnvConfig; +import com.fr.env.RemoteEnv; +import com.fr.workspace.WorkContext; +import com.fr.workspace.Workspace; +import com.fr.workspace.connect.WorkspaceClient; +import com.fr.workspace.connect.WorkspaceConnection; + +/** + * 根据配置生成运行环境 + */ +public class DesignerWorkspaceGenerator { + + public static Workspace generate(EnvConfig config) { + + Workspace workspace = null; + if (config instanceof LocalEnvConfig) { + workspace = WorkContext.getFactory().build(config.getPath()); + } else if (config instanceof RemoteEnvConfig) { + RemoteEnvConfig remoteConfig = (RemoteEnvConfig) config; + WorkspaceClient client = WorkContext.getConnector().connect(new WorkspaceConnection(remoteConfig.getHost(), remoteConfig.getPort(), remoteConfig.getUsername(), remoteConfig.getPassword())); + workspace = new RemoteWorkspace(client, remoteConfig.getHost() + ":" + remoteConfig.getPort(), remoteConfig.getPassword()); + } + return workspace; + } +} diff --git a/designer-base/src/com/fr/design/env/EnvGenerator.java b/designer-base/src/com/fr/design/env/EnvGenerator.java deleted file mode 100644 index c56ab92956..0000000000 --- a/designer-base/src/com/fr/design/env/EnvGenerator.java +++ /dev/null @@ -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; - } -} diff --git a/designer-base/src/com/fr/design/env/RemoteEnvConfig.java b/designer-base/src/com/fr/design/env/RemoteEnvConfig.java index fc701d8ca7..280149484a 100644 --- a/designer-base/src/com/fr/design/env/RemoteEnvConfig.java +++ b/designer-base/src/com/fr/design/env/RemoteEnvConfig.java @@ -1,6 +1,6 @@ package com.fr.design.env; -import com.fr.core.env.impl.AbstractEnvConfig; +import com.fr.base.env.AbstractEnvConfig; import com.fr.general.Inter; import com.fr.security.SecurityToolbox; import com.fr.stable.AssistUtils; @@ -20,10 +20,13 @@ public class RemoteEnvConfig extends AbstractEnvConfig { private String password; public RemoteEnvConfig() { - + + super(name); } public RemoteEnvConfig(String host, int port, String username, String password) { + + super(name); this.host = host; this.port = port; this.username = username; diff --git a/designer-base/src/com/fr/design/env/RemoteWorkspace.java b/designer-base/src/com/fr/design/env/RemoteWorkspace.java new file mode 100644 index 0000000000..487f2c0493 --- /dev/null +++ b/designer-base/src/com/fr/design/env/RemoteWorkspace.java @@ -0,0 +1,61 @@ +package com.fr.design.env; + +import com.fr.general.Inter; +import com.fr.workspace.Workspace; +import com.fr.workspace.connect.WorkspaceClient; + +/** + * Created by juhaoyu on 2018/6/14. + * 远程工作目录 + */ +public class RemoteWorkspace implements Workspace { + + private final WorkspaceClient client; + + private final String address; + + private final String userName; + + public RemoteWorkspace(WorkspaceClient client, String address, String userName) { + + this.client = client; + this.address = address; + this.userName = userName; + } + + @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 T get(Class type) { + + return client.getPool().get(type); + } +} diff --git a/designer-base/src/com/fr/design/file/HistoryTemplateListPane.java b/designer-base/src/com/fr/design/file/HistoryTemplateListPane.java index daa851c668..2c2137384e 100644 --- a/designer-base/src/com/fr/design/file/HistoryTemplateListPane.java +++ b/designer-base/src/com/fr/design/file/HistoryTemplateListPane.java @@ -3,7 +3,6 @@ package com.fr.design.file; import com.fr.base.Env; import com.fr.base.FRContext; import com.fr.base.chart.chartdata.CallbackEvent; -import com.fr.dav.LocalEnv; import com.fr.design.DesignModelAdapter; import com.fr.design.DesignerEnvManager; import com.fr.design.constants.UIConstants; @@ -25,6 +24,7 @@ import com.fr.log.FineLoggerFactory; import com.fr.stable.Constants; import com.fr.stable.StableUtils; import com.fr.stable.project.ProjectConstants; +import com.fr.workspace.WorkContext; import javax.swing.*; import javax.swing.event.ListSelectionEvent; @@ -368,7 +368,7 @@ public class HistoryTemplateListPane extends JPanel implements FileOperations, C FileNode fileNode = new FileNode(((JTemplate) list.getSelectedValue()).getEditingFILE().getPath(), false); Env env = FRContext.getCurrentEnv(); if (env.isLocalEnv()) { - IOUtils.openWindowsFolder(StableUtils.pathJoin(env.getEnvConfig().getPath(), fileNode.getEnvPath())); + IOUtils.openWindowsFolder(StableUtils.pathJoin(WorkContext.getCurrent().getPath(), fileNode.getEnvPath())); } } diff --git a/designer-base/src/com/fr/design/file/TemplateTreePane.java b/designer-base/src/com/fr/design/file/TemplateTreePane.java index a095595cf8..6d5063fd67 100644 --- a/designer-base/src/com/fr/design/file/TemplateTreePane.java +++ b/designer-base/src/com/fr/design/file/TemplateTreePane.java @@ -6,7 +6,6 @@ package com.fr.design.file; import com.fr.base.Env; import com.fr.base.FRContext; import com.fr.base.io.FileAssistUtils; -import com.fr.dav.LocalEnv; import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.itree.filetree.TemplateFileTree; import com.fr.design.layout.FRGUIPaneFactory; @@ -23,6 +22,7 @@ import com.fr.stable.CoreConstants; import com.fr.stable.ProductConstants; import com.fr.stable.StableUtils; import com.fr.stable.project.ProjectConstants; +import com.fr.workspace.WorkContext; import javax.swing.*; import javax.swing.tree.DefaultMutableTreeNode; @@ -147,7 +147,7 @@ public class TemplateTreePane extends JPanel implements FileOperations { try { Desktop.getDesktop().open(new File(filePath)); } catch (Exception e) { - IOUtils.openWindowsFolder(StableUtils.pathJoin(localEnv.getEnvConfig().getPath(), fn.getEnvPath())); + IOUtils.openWindowsFolder(StableUtils.pathJoin(WorkContext.getCurrent().getPath(), fn.getEnvPath())); } } diff --git a/designer-base/src/com/fr/design/mainframe/DesignerFrame.java b/designer-base/src/com/fr/design/mainframe/DesignerFrame.java index 470f4c32d6..4968dc0690 100644 --- a/designer-base/src/com/fr/design/mainframe/DesignerFrame.java +++ b/designer-base/src/com/fr/design/mainframe/DesignerFrame.java @@ -5,8 +5,7 @@ package com.fr.design.mainframe; 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.base.env.EnvConfig; import com.fr.design.DesignModelAdapter; import com.fr.design.DesignState; import com.fr.design.DesignerEnvManager; @@ -54,24 +53,11 @@ import com.fr.stable.ProductConstants; import com.fr.stable.StableUtils; import com.fr.stable.image4j.codec.ico.ICODecoder; import com.fr.stable.project.ProjectConstants; +import com.fr.workspace.WorkContext; -import javax.swing.Icon; -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.*; import javax.swing.border.MatteBorder; -import java.awt.BorderLayout; -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.*; import java.awt.datatransfer.DataFlavor; import java.awt.datatransfer.Transferable; import java.awt.dnd.DnDConstants; @@ -992,8 +978,8 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta EastRegionContainerPane.getInstance().getContainerWidth()); DesignerEnvManager.getEnvManager().saveXMLFile(); - - EnvUpdater.disconnect(); + + WorkContext.switchTo(null); this.setVisible(false); this.dispose(); diff --git a/designer-base/src/com/fr/design/mainframe/TemplatePane.java b/designer-base/src/com/fr/design/mainframe/TemplatePane.java index 5c539cd9bf..a6d5a16eef 100644 --- a/designer-base/src/com/fr/design/mainframe/TemplatePane.java +++ b/designer-base/src/com/fr/design/mainframe/TemplatePane.java @@ -1,16 +1,13 @@ package com.fr.design.mainframe; 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.base.env.EnvConfig; +import com.fr.base.env.LocalEnvConfig; import com.fr.design.DesignModelAdapter; import com.fr.design.DesignerEnvManager; import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.DialogActionAdapter; -import com.fr.design.dialog.InformationWarnPane; -import com.fr.design.env.EnvGenerator; +import com.fr.design.env.DesignerWorkspaceGenerator; import com.fr.design.env.RemoteEnvConfig; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.file.TemplateTreePane; @@ -18,14 +15,12 @@ import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ilable.UILabel; import com.fr.design.utils.DesignUtils; import com.fr.env.EnvListPane; -import com.fr.env.RemoteEnv; -import com.fr.general.ComparatorUtils; import com.fr.general.GeneralContext; import com.fr.general.IOUtils; import com.fr.general.Inter; import com.fr.stable.EnvChangedListener; -import com.fr.stable.ProductConstants; -import com.fr.stable.StringUtils; +import com.fr.workspace.WorkContext; +import com.fr.workspace.WorkContextCallback; import javax.swing.*; import java.awt.*; @@ -120,7 +115,7 @@ public class TemplatePane extends JPanel implements MouseListener { EnvConfig selectedEnv = envManager.getEnv(selectedName); GeneralContext.fireEnvWillChangeListener(); try { - EnvUpdater.updateEnv(EnvGenerator.generate(selectedEnv), new Callback() { + WorkContext.switchTo(DesignerWorkspaceGenerator.generate(selectedEnv), new WorkContextCallback() { @Override public void fail() { JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Inter.getLocText(new String[]{"M-SwitchWorkspace", "Failed"})); @@ -128,7 +123,6 @@ public class TemplatePane extends JPanel implements MouseListener { @Override public void success() { - DesignerEnvManager.getEnvManager().setCurEnvName(selectedName); DesignUtils.refreshDesignerFrame(); } }); diff --git a/designer-base/src/com/fr/design/mainframe/loghandler/socketio/DesignerSocketIO.java b/designer-base/src/com/fr/design/mainframe/loghandler/socketio/DesignerSocketIO.java index 957d9f83ac..bcf9e2ae03 100644 --- a/designer-base/src/com/fr/design/mainframe/loghandler/socketio/DesignerSocketIO.java +++ b/designer-base/src/com/fr/design/mainframe/loghandler/socketio/DesignerSocketIO.java @@ -2,13 +2,10 @@ 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.base.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; @@ -27,7 +24,6 @@ import io.socket.emitter.Emitter; import java.io.ByteArrayInputStream; import java.net.URI; -import java.net.URL; public class DesignerSocketIO { diff --git a/designer-base/src/com/fr/env/EnvListPane.java b/designer-base/src/com/fr/env/EnvListPane.java index 6146b5d5d5..652b11d084 100644 --- a/designer-base/src/com/fr/env/EnvListPane.java +++ b/designer-base/src/com/fr/env/EnvListPane.java @@ -1,7 +1,7 @@ package com.fr.env; -import com.fr.core.env.EnvConfig; -import com.fr.core.env.impl.LocalEnvConfig; +import com.fr.base.env.EnvConfig; +import com.fr.base.env.LocalEnvConfig; import com.fr.design.env.RemoteEnvConfig; import com.fr.design.DesignerEnvManager; import com.fr.design.gui.controlpane.JListControlPane; diff --git a/designer-base/src/com/fr/env/LocalEnvPane.java b/designer-base/src/com/fr/env/LocalEnvPane.java index d5dce6a1a3..993a72b139 100644 --- a/designer-base/src/com/fr/env/LocalEnvPane.java +++ b/designer-base/src/com/fr/env/LocalEnvPane.java @@ -1,6 +1,6 @@ package com.fr.env; -import com.fr.core.env.impl.LocalEnvConfig; +import com.fr.base.env.LocalEnvConfig; import com.fr.design.beans.BasicBeanPane; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itextarea.UITextArea; diff --git a/designer-base/src/com/fr/env/RemoteEnv.java b/designer-base/src/com/fr/env/RemoteEnv.java index 6517efce18..084962a03b 100644 --- a/designer-base/src/com/fr/env/RemoteEnv.java +++ b/designer-base/src/com/fr/env/RemoteEnv.java @@ -6,9 +6,6 @@ import com.fr.base.operator.connect.ConnectOperator; import com.fr.base.operator.file.FileOperator; import com.fr.base.operator.org.OrganizationOperator; import com.fr.base.remote.RemoteDeziConstants; -import com.fr.common.rpc.RemoteCallServerConfig; -import com.fr.common.rpc.netty.MessageSendExecutor; -import com.fr.common.rpc.netty.RemoteCallClient; import com.fr.core.env.EnvConstants; import com.fr.core.env.EnvContext; import com.fr.data.impl.storeproc.StoreProcedure; @@ -20,7 +17,6 @@ import com.fr.design.mainframe.DesignerContext; import com.fr.file.CacheManager; import com.fr.general.CommonIOUtils; import com.fr.general.ComparatorUtils; -import com.fr.general.EnvProxyFactory; import com.fr.general.IOUtils; import com.fr.general.Inter; import com.fr.general.http.HttpToolbox; @@ -42,6 +38,9 @@ import com.fr.stable.project.ProjectConstants; import com.fr.third.guava.base.Strings; import com.fr.third.guava.collect.ImmutableMap; import com.fr.web.ResourceConstants; +import com.fr.workspace.engine.server.rpc.RemoteCallServerConfig; +import com.fr.workspace.engine.server.rpc.netty.MessageSendExecutor; +import com.fr.workspace.engine.server.rpc.netty.RemoteCallClient; import javax.swing.*; import javax.xml.transform.Source; @@ -109,24 +108,6 @@ public class RemoteEnv extends AbstractEnv implements DesignAut return true; } - @Override - public EnvProxyFactory getProxyFactory() { - - return new EnvProxyFactory() { - - @Override - public T get(Class clazz, T obj) { - - assert clazz != null; - try { - return MessageSendExecutor.getInstance().execute(clazz); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - }; - } - @Override public FileOperator getFileOperator() throws Exception { @@ -143,11 +124,6 @@ public class RemoteEnv extends AbstractEnv implements DesignAut return MessageSendExecutor.getInstance().execute(OrganizationOperator.class); } - @Override - public RemoteEnvConfig getEnvConfig() { - return config; - } - @Override public String getPath() { return config.getPath(); diff --git a/designer-base/src/com/fr/env/RemoteEnvPane.java b/designer-base/src/com/fr/env/RemoteEnvPane.java index 6028dc6eee..12571369f3 100644 --- a/designer-base/src/com/fr/env/RemoteEnvPane.java +++ b/designer-base/src/com/fr/env/RemoteEnvPane.java @@ -1,7 +1,6 @@ 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.beans.BasicBeanPane; diff --git a/designer-base/src/com/fr/env/SignIn.java b/designer-base/src/com/fr/env/SignIn.java deleted file mode 100644 index bca04d2484..0000000000 --- a/designer-base/src/com/fr/env/SignIn.java +++ /dev/null @@ -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() { - @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); - } -} \ No newline at end of file diff --git a/designer-base/src/com/fr/start/ServerStarter.java b/designer-base/src/com/fr/start/ServerStarter.java index 1dc8cf8f14..3c6c1f22a2 100644 --- a/designer-base/src/com/fr/start/ServerStarter.java +++ b/designer-base/src/com/fr/start/ServerStarter.java @@ -2,13 +2,12 @@ package com.fr.start; import com.fr.base.FRContext; import com.fr.base.ServerConfig; -import com.fr.base.env.EnvUpdater; import com.fr.design.DesignModelAdapter; import com.fr.design.DesignerEnvManager; import com.fr.design.data.datapane.TableDataTreePane; import com.fr.design.dialog.BasicPane; 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.gui.itextarea.UITextArea; import com.fr.design.mainframe.DesignerContext; @@ -22,6 +21,7 @@ import com.fr.stable.ProductConstants; import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; import com.fr.start.server.FineEmbedServer; +import com.fr.workspace.WorkContext; import javax.swing.*; import java.awt.*; @@ -54,7 +54,7 @@ public class ServerStarter { @Override public void doOk() { try { - EnvUpdater.updateEnv(EnvGenerator.generate(DesignerEnvManager.getEnvManager().getDefaultEnv())); + WorkContext.switchTo(DesignerWorkspaceGenerator.generate(DesignerEnvManager.getEnvManager().getDefaultConfig())); TemplateTreePane.getInstance().refreshDockingView(); TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter()); } catch (Exception e) { diff --git a/designer-realize/src/com/fr/start/EnvSwitcher.java b/designer-realize/src/com/fr/start/EnvSwitcher.java index 5dffc028ab..6fbffcc5a6 100644 --- a/designer-realize/src/com/fr/start/EnvSwitcher.java +++ b/designer-realize/src/com/fr/start/EnvSwitcher.java @@ -1,10 +1,10 @@ package com.fr.start; -import com.fr.base.Env; -import com.fr.base.env.EnvUpdater; 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.workspace.WorkContext; +import com.fr.workspace.Workspace; /** * Created by juhaoyu on 2018/1/31. @@ -16,8 +16,8 @@ public class EnvSwitcher { try { String current = DesignerEnvManager.getEnvManager().getCurEnvName(); - Env env = EnvGenerator.generate(DesignerEnvManager.getEnvManager().getEnv(current)); - EnvUpdater.updateEnv(env); + Workspace workspace = DesignerWorkspaceGenerator.generate(DesignerEnvManager.getEnvManager().getEnv(current)); + WorkContext.switchTo(workspace); } catch (Exception e) { TemplatePane.getInstance().dealEvnExceptionWhenStartDesigner(); } diff --git a/designer-realize/src/com/fr/start/module/DesignerEnvProvider.java b/designer-realize/src/com/fr/start/module/DesignerEnvProvider.java index 0615d7774a..827ee73cb3 100644 --- a/designer-realize/src/com/fr/start/module/DesignerEnvProvider.java +++ b/designer-realize/src/com/fr/start/module/DesignerEnvProvider.java @@ -1,15 +1,11 @@ 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; @@ -17,10 +13,6 @@ 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; @@ -58,13 +50,6 @@ public class DesignerEnvProvider extends Activator { private void initDesignerEnv() { addSerializers(); - EventDispatcher.listen(EnvEvent.BEFORE_SIGN_IN, new Listener() { - @Override - public void on(Event event, EnvConfig envConfig) { - Env env = EnvGenerator.generate(envConfig); - EnvUpdater.updateEnv(env); - } - }); } private void addSerializers() { diff --git a/designer-realize/src/com/fr/start/module/DesignerStartup.java b/designer-realize/src/com/fr/start/module/DesignerStartup.java index eb1cc85d72..f5c3959e08 100644 --- a/designer-realize/src/com/fr/start/module/DesignerStartup.java +++ b/designer-realize/src/com/fr/start/module/DesignerStartup.java @@ -1,6 +1,6 @@ package com.fr.start.module; -import com.fr.core.env.EnvConfig; +import com.fr.base.env.EnvConfig; import com.fr.core.env.EnvEvent; import com.fr.event.Event; import com.fr.event.Listener; From 74b5a1bcfbf41aae3cc1731f2be4a7114d03567a Mon Sep 17 00:00:00 2001 From: ju Date: Fri, 15 Jun 2018 09:57:39 +0800 Subject: [PATCH 02/20] =?UTF-8?q?REPORT-8790=20=E6=94=B9=E5=8A=A8=E5=A4=AA?= =?UTF-8?q?=E5=A4=9A=E4=BA=86=EF=BC=8C=E5=85=88commit=E4=B8=80=E6=AC=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/com/fr/design/formula/JavaEditorPane.java | 5 +++-- .../fr/design/gui/itree/filetree/TemplateFileTree.java | 3 --- .../src/com/fr/design/remote/ui/UserManagerPane.java | 3 --- designer-base/src/com/fr/file/FileNodeFILE.java | 10 +++++----- 4 files changed, 8 insertions(+), 13 deletions(-) diff --git a/designer-base/src/com/fr/design/formula/JavaEditorPane.java b/designer-base/src/com/fr/design/formula/JavaEditorPane.java index 946eb58c19..2a5836f0ff 100644 --- a/designer-base/src/com/fr/design/formula/JavaEditorPane.java +++ b/designer-base/src/com/fr/design/formula/JavaEditorPane.java @@ -16,6 +16,7 @@ import com.fr.stable.JavaCompileInfo; import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; import com.fr.stable.project.ProjectConstants; +import com.fr.workspace.WorkContext; import javax.swing.*; import java.awt.*; @@ -113,7 +114,7 @@ public class JavaEditorPane extends BasicPane { private InputStream getJavaSourceInputStream() { String javaPath = getJavaPath(); 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) { FRContext.getLogger().error(e.getMessage(), e); } @@ -156,7 +157,7 @@ public class JavaEditorPane extends BasicPane { return; } 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"}) + "!"); fireSaveActionListener(); } catch (Exception e) { diff --git a/designer-base/src/com/fr/design/gui/itree/filetree/TemplateFileTree.java b/designer-base/src/com/fr/design/gui/itree/filetree/TemplateFileTree.java index 31325dd0f1..26b9095d81 100644 --- a/designer-base/src/com/fr/design/gui/itree/filetree/TemplateFileTree.java +++ b/designer-base/src/com/fr/design/gui/itree/filetree/TemplateFileTree.java @@ -3,11 +3,8 @@ package com.fr.design.gui.itree.filetree; import com.fr.base.Env; import com.fr.base.FRContext; 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.file.filetree.FileNode; -import com.fr.general.web.ParameterConstants; import com.fr.log.FineLoggerFactory; import com.fr.stable.ArrayUtils; import com.fr.stable.StableUtils; diff --git a/designer-base/src/com/fr/design/remote/ui/UserManagerPane.java b/designer-base/src/com/fr/design/remote/ui/UserManagerPane.java index 2c568583a9..ab53eeaa33 100644 --- a/designer-base/src/com/fr/design/remote/ui/UserManagerPane.java +++ b/designer-base/src/com/fr/design/remote/ui/UserManagerPane.java @@ -1,8 +1,5 @@ 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.dialog.BasicPane; import com.fr.design.gui.ibutton.UIButton; diff --git a/designer-base/src/com/fr/file/FileNodeFILE.java b/designer-base/src/com/fr/file/FileNodeFILE.java index 9105b20418..21b7963789 100644 --- a/designer-base/src/com/fr/file/FileNodeFILE.java +++ b/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.StableUtils; import com.fr.stable.project.ProjectConstants; +import com.fr.workspace.WorkContext; import javax.swing.*; - import java.io.ByteArrayInputStream; import java.io.InputStream; import java.io.OutputStream; @@ -200,7 +200,7 @@ public class FileNodeFILE implements FILE { } try { - return FRContext.getCurrentEnv().getFileOperator().createFolder(StableUtils.pathJoin(node.getEnvPath(), name)); + return WorkContext.getWorkResource().create(StableUtils.pathJoin(node.getEnvPath(), name)); } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); return false; @@ -267,7 +267,7 @@ public class FileNodeFILE implements FILE { } try { - return FRContext.getCurrentEnv().getFileOperator().createFile(node.getEnvPath()); + return WorkContext.getWorkResource().create(node.getEnvPath()); } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); return false; @@ -290,8 +290,8 @@ public class FileNodeFILE implements FILE { if (!envPath.startsWith(ProjectConstants.REPORTLETS_NAME)) { 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") ? XMLEncryptUtils.decodeInputStream(in) : in; From 9ae0f14ca432bd52bf30a286102d97d74aacec07 Mon Sep 17 00:00:00 2001 From: ju Date: Fri, 15 Jun 2018 12:06:28 +0800 Subject: [PATCH 03/20] f --- .../src/com/fr/design/DesignerEnvManager.java | 51 +- .../fr/design/actions/file/LocalePane.java | 5 +- .../design/actions/file/SwitchExistEnv.java | 19 +- .../env/DesignerWorkspaceGenerator.java | 27 +- .../fr/design/env/DesignerWorkspaceInfo.java | 104 ++ .../fr/design/env/DesignerWorkspaceType.java | 10 + .../com/fr/design/env/RemoteEnvConfig.java | 137 -- .../com/fr/design/env/RemoteWorkspace.java | 7 +- .../fr/design/mainframe/DesignerFrame.java | 2 +- .../com/fr/design/mainframe/JTemplate.java | 3 +- .../com/fr/design/mainframe/TemplatePane.java | 25 +- .../loghandler/socketio/DesignerSocketIO.java | 34 +- .../templateinfo/TemplateInfoCollector.java | 7 +- .../RemoteDesignAuthorityManagerAction.java | 70 +- .../src/com/fr/design/utils/DesignUtils.java | 1 - designer-base/src/com/fr/env/EnvListPane.java | 12 +- .../src/com/fr/env/LocalEnvPane.java | 10 +- designer-base/src/com/fr/env/RemoteEnv.java | 1521 ++++++++--------- .../src/com/fr/env/RemoteEnvPane.java | 35 +- .../src/com/fr/file/FileNodeFILE.java | 2 +- .../PlotSeries/MapGroupExtensionPane.java | 11 +- .../manager/impl/FileSearchManager.java | 3 +- .../errorinfo/ErrorInfoLogAppender.java | 4 +- .../src/com/fr/start/EnvSwitcher.java | 2 +- 24 files changed, 1033 insertions(+), 1069 deletions(-) create mode 100644 designer-base/src/com/fr/design/env/DesignerWorkspaceInfo.java create mode 100644 designer-base/src/com/fr/design/env/DesignerWorkspaceType.java delete mode 100644 designer-base/src/com/fr/design/env/RemoteEnvConfig.java diff --git a/designer-base/src/com/fr/design/DesignerEnvManager.java b/designer-base/src/com/fr/design/DesignerEnvManager.java index 54564ced18..564ba9a497 100644 --- a/designer-base/src/com/fr/design/DesignerEnvManager.java +++ b/designer-base/src/com/fr/design/DesignerEnvManager.java @@ -6,11 +6,10 @@ package com.fr.design; import com.fr.base.BaseXMLUtils; import com.fr.base.FRContext; import com.fr.base.Utils; -import com.fr.base.env.EnvConfig; -import com.fr.base.env.LocalEnvConfig; import com.fr.design.actions.help.alphafine.AlphaFineConfigManager; import com.fr.design.constants.UIConstants; import com.fr.design.env.DesignerWorkspaceGenerator; +import com.fr.design.env.DesignerWorkspaceInfo; import com.fr.file.FILEFactory; import com.fr.general.ComparatorUtils; import com.fr.general.FRLogFormatter; @@ -73,7 +72,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { private boolean showPaintToolBar = true; private int maxNumberOrPreviewRow = 200; // name和Env的键值对 - private Map nameEnvMap = new ListMap<>(); + private Map nameEnvMap = new ListMap<>(); // marks: 当前报表服务器名字 private String curEnvName = null; private boolean showProjectPane = true; @@ -194,7 +193,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { if (installHome != null) { String name = Inter.getLocText("FR-Engine_DEFAULT"); String envPath = StableUtils.pathJoin(new String[]{installHome, ProjectConstants.WEBAPP_NAME, ProjectConstants.WEBINF_NAME}); - designerEnvManager.putEnv(name, new LocalEnvConfig(envPath, name)); + designerEnvManager.putEnv(name, DesignerWorkspaceInfo.createLocal(name, envPath)); designerEnvManager.setCurEnvName(name); } } @@ -327,7 +326,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { FRContext.getLogger().error(e.getMessage(), e); } // 清空前一个版本中的工作目录和最近打开 - nameEnvMap = new ListMap(); + nameEnvMap = new ListMap(); recentOpenedFilePathList = new ArrayList(); curEnvName = null; designerEnvManager.saveXMLFile(); @@ -474,28 +473,29 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { * @return 是默认则返回true */ 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}); - return ComparatorUtils.equals(new File(defaultEnvPath).getPath(), currentEnv.getPath()); + return ComparatorUtils.equals(new File(defaultEnvPath).getPath(), current.getPath()); } /** * 返回默认环境 */ - public EnvConfig getDefaultConfig() { + public DesignerWorkspaceInfo getDefaultConfig() { String installHome = StableUtils.getInstallHome(); String defaultenvPath = StableUtils.pathJoin(installHome, ProjectConstants.WEBAPP_NAME, ProjectConstants.WEBINF_NAME); defaultenvPath = new File(defaultenvPath).getPath(); - Iterator> entryIt = nameEnvMap.entrySet().iterator(); + Iterator> entryIt = nameEnvMap.entrySet().iterator(); while (entryIt.hasNext()) { - Entry entry = entryIt.next(); - EnvConfig env = entry.getValue(); + Entry entry = entryIt.next(); + DesignerWorkspaceInfo env = entry.getValue(); if (ComparatorUtils.equals(defaultenvPath, env.getPath())) { return env; } } String name = Inter.getLocText(new String[]{"Default", "Utils-Report_Runtime_Env"}); - EnvConfig newDefaultEnv = new LocalEnvConfig(defaultenvPath, name); + DesignerWorkspaceInfo newDefaultEnv = DesignerWorkspaceInfo.createLocal(name, defaultenvPath); this.putEnv(name, newDefaultEnv); return newDefaultEnv; } @@ -508,10 +508,10 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { String defaultenvPath = StableUtils.pathJoin(new String[]{installHome, ProjectConstants.WEBAPP_NAME, ProjectConstants.WEBINF_NAME}); defaultenvPath = new File(defaultenvPath).getPath(); if (nameEnvMap.size() >= 0) { - Iterator> entryIt = nameEnvMap.entrySet().iterator(); + Iterator> entryIt = nameEnvMap.entrySet().iterator(); while (entryIt.hasNext()) { - Entry entry = entryIt.next(); - EnvConfig env = entry.getValue(); + Entry entry = entryIt.next(); + DesignerWorkspaceInfo env = entry.getValue(); if (ComparatorUtils.equals(defaultenvPath, env.getPath())) { return entry.getKey(); } @@ -694,7 +694,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { /** * 根据名称返回环境 */ - public EnvConfig getEnv(String name) { + public DesignerWorkspaceInfo getWorkspaceInfo(String name) { return this.nameEnvMap.get(name); } @@ -702,10 +702,11 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { * 记录名称 和对应的环境 * * @param name 名称 - * @param env 对应的环境 + * @param info 对应的环境信息 */ - public void putEnv(String name, EnvConfig env) { - this.nameEnvMap.put(name, env); + public void putEnv(String name, DesignerWorkspaceInfo info) { + + this.nameEnvMap.put(name, info); } /** @@ -1418,7 +1419,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { // marks:兼容6.1的 // marks:设置默认的目录. String curReportServerName = Inter.getLocText("Server-Embedded_Server"); - EnvConfig reportServer = new LocalEnvConfig(tmpVal,curReportServerName); + DesignerWorkspaceInfo reportServer = DesignerWorkspaceInfo.createLocal(curReportServerName, tmpVal); this.putEnv(curReportServerName, reportServer); this.setCurEnvName(curReportServerName); @@ -1471,8 +1472,8 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { public void readXML(XMLableReader reader) { if (reader.isChildNode()) { String tagName = reader.getTagName(); - if (EnvConfig.XML_TAG.equals(tagName)) { - EnvConfig envConfig = (EnvConfig) GeneralXMLTools.readXMLable(reader); + if (DesignerWorkspaceInfo.XML_TAG.equals(tagName)) { + DesignerWorkspaceInfo envConfig = (DesignerWorkspaceInfo) GeneralXMLTools.readXMLable(reader); putEnv(name, envConfig); } } @@ -1595,10 +1596,10 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { if (this.curEnvName != null) { writer.attr("currentEnv", this.curEnvName); } - for (Entry entry : nameEnvMap.entrySet()) { + for (Entry entry : nameEnvMap.entrySet()) { writer.startTAG("EnvConfigElement").attr("name", entry.getKey()); - EnvConfig envConfig = entry.getValue(); - GeneralXMLTools.writeXMLable(writer, envConfig, EnvConfig.XML_TAG); + DesignerWorkspaceInfo envConfig = entry.getValue(); + GeneralXMLTools.writeXMLable(writer, envConfig, DesignerWorkspaceInfo.XML_TAG); writer.end(); } writer.end(); diff --git a/designer-base/src/com/fr/design/actions/file/LocalePane.java b/designer-base/src/com/fr/design/actions/file/LocalePane.java index 898f263709..20573d34c1 100644 --- a/designer-base/src/com/fr/design/actions/file/LocalePane.java +++ b/designer-base/src/com/fr/design/actions/file/LocalePane.java @@ -13,11 +13,11 @@ import com.fr.design.gui.itextfield.UITextField; import com.fr.file.filetree.FileNode; import com.fr.general.GeneralUtils; import com.fr.general.Inter; -import com.fr.log.FineLoggerFactory; import com.fr.stable.ArrayUtils; import com.fr.stable.StableUtils; import com.fr.stable.bridge.StableFactory; import com.fr.stable.project.ProjectConstants; +import com.fr.workspace.WorkContext; import javax.swing.*; import javax.swing.event.DocumentEvent; @@ -27,7 +27,6 @@ import javax.swing.table.TableRowSorter; import java.awt.*; import java.io.ByteArrayInputStream; import java.io.InputStream; -import java.io.OutputStream; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; @@ -196,7 +195,7 @@ public class LocalePane extends BasicPane { for (FileNode fileNode : fileNodes) { String fileName = fileNode.getName(); 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.load(in); keys.addAll(properties.stringPropertyNames()); diff --git a/designer-base/src/com/fr/design/actions/file/SwitchExistEnv.java b/designer-base/src/com/fr/design/actions/file/SwitchExistEnv.java index f21fb69910..2ca235b3be 100644 --- a/designer-base/src/com/fr/design/actions/file/SwitchExistEnv.java +++ b/designer-base/src/com/fr/design/actions/file/SwitchExistEnv.java @@ -1,14 +1,12 @@ package com.fr.design.actions.file; import com.fr.base.BaseUtils; -import com.fr.base.env.EnvConfig; -import com.fr.base.env.LocalEnvConfig; import com.fr.design.DesignerEnvManager; import com.fr.design.actions.UpdateAction; import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.tabledata.ResponseDataSourceChange; 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.mainframe.DesignerContext; import com.fr.design.mainframe.JTemplate; @@ -67,11 +65,16 @@ public class SwitchExistEnv extends MenuDef { public GetExistEnvAction(String envName) { this.setName(envName); - EnvConfig env = DesignerEnvManager.getEnvManager().getEnv(envName); - if (env instanceof LocalEnvConfig) { - this.setSmallIcon(BaseUtils.readIcon("com/fr/design/images/data/bind/localconnect.png")); - } else if (env instanceof RemoteEnvConfig) { + DesignerWorkspaceInfo env = DesignerEnvManager.getEnvManager().getWorkspaceInfo(envName); + switch (env.getType()) + { + case Local:{ + this.setSmallIcon(BaseUtils.readIcon("com/fr/design/images/data/bind/localconnect.png")); + break; + }case Remote:{ this.setSmallIcon(BaseUtils.readIcon("com/fr/design/images/data/bind/distanceconnect.png")); + break; + } } } @@ -99,7 +102,7 @@ public class SwitchExistEnv extends MenuDef { public void actionPerformed(ActionEvent e) { DesignerEnvManager envManager = DesignerEnvManager.getEnvManager(); final String envName = getName(); - EnvConfig selectedEnv = envManager.getEnv(envName); + DesignerWorkspaceInfo selectedEnv = envManager.getWorkspaceInfo(envName); WorkContext.switchTo(DesignerWorkspaceGenerator.generate(selectedEnv), new WorkContextCallback() { @Override public void success() { diff --git a/designer-base/src/com/fr/design/env/DesignerWorkspaceGenerator.java b/designer-base/src/com/fr/design/env/DesignerWorkspaceGenerator.java index 1197b9cb55..b666b0f63f 100644 --- a/designer-base/src/com/fr/design/env/DesignerWorkspaceGenerator.java +++ b/designer-base/src/com/fr/design/env/DesignerWorkspaceGenerator.java @@ -1,28 +1,31 @@ package com.fr.design.env; -import com.fr.base.Env; -import com.fr.base.env.EnvConfig; -import com.fr.base.env.LocalEnvConfig; -import com.fr.env.RemoteEnv; import com.fr.workspace.WorkContext; import com.fr.workspace.Workspace; import com.fr.workspace.connect.WorkspaceClient; -import com.fr.workspace.connect.WorkspaceConnection; /** * 根据配置生成运行环境 */ public class DesignerWorkspaceGenerator { - public static Workspace generate(EnvConfig config) { + public static Workspace generate(DesignerWorkspaceInfo config) { + + if (config == null || config.getType() == null) { + return null; + } Workspace workspace = null; - if (config instanceof LocalEnvConfig) { - workspace = WorkContext.getFactory().build(config.getPath()); - } else if (config instanceof RemoteEnvConfig) { - RemoteEnvConfig remoteConfig = (RemoteEnvConfig) config; - WorkspaceClient client = WorkContext.getConnector().connect(new WorkspaceConnection(remoteConfig.getHost(), remoteConfig.getPort(), remoteConfig.getUsername(), remoteConfig.getPassword())); - workspace = new RemoteWorkspace(client, remoteConfig.getHost() + ":" + remoteConfig.getPort(), remoteConfig.getPassword()); + 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; } diff --git a/designer-base/src/com/fr/design/env/DesignerWorkspaceInfo.java b/designer-base/src/com/fr/design/env/DesignerWorkspaceInfo.java new file mode 100644 index 0000000000..6854e007ed --- /dev/null +++ b/designer-base/src/com/fr/design/env/DesignerWorkspaceInfo.java @@ -0,0 +1,104 @@ +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.XMLable; +import com.fr.stable.xml.XMLableReader; +import com.fr.workspace.connect.WorkspaceConnection; + +/** + * Created by juhaoyu on 2018/6/15. + */ +public class DesignerWorkspaceInfo implements XMLable { + + private static final int DEFAULT_RPC_PORT = 39999; + + public static final String XML_TAG = "DesignerWorkspace"; + + private DesignerWorkspaceType type; + + private String name; + + private String path; + + private WorkspaceConnection connection; + + public static DesignerWorkspaceInfo createLocal(String name, String path) { + + DesignerWorkspaceInfo info = new DesignerWorkspaceInfo(); + info.connection = null; + info.name = name; + info.path = path; + info.type = DesignerWorkspaceType.Local; + return info; + } + + public void setName(String name) { + + this.name = name; + } + + public DesignerWorkspaceType getType() { + + return type; + } + + public String getName() { + + return name; + } + + public String getPath() { + + return path; + } + + public WorkspaceConnection getConnection() { + + return connection; + } + + @Override + public void readXML(XMLableReader reader) { + + if (reader.isAttr()) { + this.name = reader.getAttrAsString("name", StringUtils.EMPTY); + this.type = DesignerWorkspaceType.valueOf(reader.getAttrAsString("name", "Local")); + this.path = reader.getAttrAsString("path", StringUtils.EMPTY); + } + if (reader.isChildNode()) { + String tagName = reader.getTagName(); + if ("Connection".equals(tagName)) { + String ip = reader.getAttrAsString("ip", StringUtils.EMPTY); + int port = reader.getAttrAsInt("port", DEFAULT_RPC_PORT); + String username = reader.getAttrAsString("username", StringUtils.EMPTY); + //密码解密 + String password = SecurityToolbox.decrypt(reader.getAttrAsString("password", StringUtils.EMPTY)); + this.connection = new WorkspaceConnection(ip, port, username, password); + } + } + } + + @Override + public void writeXML(XMLPrintWriter writer) { + + writer.attr("name", name); + writer.attr("path", path); + writer.attr("type", type.toString()); + if (this.connection != null) { + writer.startTAG("Connection"); + writer.attr("ip", connection.getIp()); + writer.attr("port", connection.getPort()); + writer.attr("username", connection.getUserName()); + writer.attr("password", SecurityToolbox.encrypt(connection.getPassword())); + writer.end(); + } + } + + @Override + public Object clone() throws CloneNotSupportedException { + + return null; + } +} diff --git a/designer-base/src/com/fr/design/env/DesignerWorkspaceType.java b/designer-base/src/com/fr/design/env/DesignerWorkspaceType.java new file mode 100644 index 0000000000..a59c5debea --- /dev/null +++ b/designer-base/src/com/fr/design/env/DesignerWorkspaceType.java @@ -0,0 +1,10 @@ +package com.fr.design.env; + +/** + * Created by juhaoyu on 2018/6/15. + * 设计器使用的workspace类型 + */ +public enum DesignerWorkspaceType { + Local, + Remote +} diff --git a/designer-base/src/com/fr/design/env/RemoteEnvConfig.java b/designer-base/src/com/fr/design/env/RemoteEnvConfig.java deleted file mode 100644 index 280149484a..0000000000 --- a/designer-base/src/com/fr/design/env/RemoteEnvConfig.java +++ /dev/null @@ -1,137 +0,0 @@ -package com.fr.design.env; - -import com.fr.base.env.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() { - - super(name); - } - - public RemoteEnvConfig(String host, int port, String username, String password) { - - super(name); - 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; - } -} diff --git a/designer-base/src/com/fr/design/env/RemoteWorkspace.java b/designer-base/src/com/fr/design/env/RemoteWorkspace.java index 487f2c0493..33bb1b4bca 100644 --- a/designer-base/src/com/fr/design/env/RemoteWorkspace.java +++ b/designer-base/src/com/fr/design/env/RemoteWorkspace.java @@ -3,6 +3,7 @@ package com.fr.design.env; import com.fr.general.Inter; import com.fr.workspace.Workspace; import com.fr.workspace.connect.WorkspaceClient; +import com.fr.workspace.connect.WorkspaceConnection; /** * Created by juhaoyu on 2018/6/14. @@ -16,11 +17,11 @@ public class RemoteWorkspace implements Workspace { private final String userName; - public RemoteWorkspace(WorkspaceClient client, String address, String userName) { + RemoteWorkspace(WorkspaceClient client, WorkspaceConnection connection) { this.client = client; - this.address = address; - this.userName = userName; + this.address = connection.getIp() + ":" + connection.getPort(); + this.userName = connection.getUserName(); } @Override diff --git a/designer-base/src/com/fr/design/mainframe/DesignerFrame.java b/designer-base/src/com/fr/design/mainframe/DesignerFrame.java index 4968dc0690..46ffed17bd 100644 --- a/designer-base/src/com/fr/design/mainframe/DesignerFrame.java +++ b/designer-base/src/com/fr/design/mainframe/DesignerFrame.java @@ -650,7 +650,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta defaultTitleSB.append(" "); // james:标识登录的用户和登录的ENV String envName = DesignerEnvManager.getEnvManager().getCurEnvName(); - EnvConfig env = DesignerEnvManager.getEnvManager().getEnv(envName); + EnvConfig env = DesignerEnvManager.getEnvManager().getWorkspaceInfo(envName); if (env != null) { defaultTitleSB.append(env.getDescription(envName)); if (editingTemplate != null) { diff --git a/designer-base/src/com/fr/design/mainframe/JTemplate.java b/designer-base/src/com/fr/design/mainframe/JTemplate.java index 62ed475db0..8ab0c47562 100644 --- a/designer-base/src/com/fr/design/mainframe/JTemplate.java +++ b/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.core.UUID; import com.fr.stable.project.ProjectConstants; +import com.fr.workspace.WorkContext; import javax.swing.*; import javax.swing.tree.DefaultMutableTreeNode; @@ -657,7 +658,7 @@ public abstract class JTemplate> try { ByteArrayOutputStream out = new ByteArrayOutputStream(); this.getTarget().export(out); - FRContext.getCurrentEnv().getFileOperator().write(out.toByteArray(), editingFILE.getPath()); + WorkContext.getWorkResource().write(editingFILE.getPath(), out.toByteArray()); } catch (Exception e) { FRContext.getLogger().error(e.getMessage(), e); JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), e.getMessage(), "Save Error", JOptionPane.ERROR_MESSAGE); diff --git a/designer-base/src/com/fr/design/mainframe/TemplatePane.java b/designer-base/src/com/fr/design/mainframe/TemplatePane.java index a6d5a16eef..5a917ce2cd 100644 --- a/designer-base/src/com/fr/design/mainframe/TemplatePane.java +++ b/designer-base/src/com/fr/design/mainframe/TemplatePane.java @@ -1,14 +1,12 @@ package com.fr.design.mainframe; import com.fr.base.BaseUtils; -import com.fr.base.env.EnvConfig; -import com.fr.base.env.LocalEnvConfig; import com.fr.design.DesignModelAdapter; import com.fr.design.DesignerEnvManager; import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.DialogActionAdapter; 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.TemplateTreePane; import com.fr.design.gui.ibutton.UIButton; @@ -112,7 +110,7 @@ public class TemplatePane extends JPanel implements MouseListener { private boolean envListOkAction(EnvListPane envListPane) { final String selectedName = envListPane.updateEnvManager(); DesignerEnvManager envManager = DesignerEnvManager.getEnvManager(); - EnvConfig selectedEnv = envManager.getEnv(selectedName); + DesignerWorkspaceInfo selectedEnv = envManager.getWorkspaceInfo(selectedName); GeneralContext.fireEnvWillChangeListener(); try { WorkContext.switchTo(DesignerWorkspaceGenerator.generate(selectedEnv), new WorkContextCallback() { @@ -143,7 +141,7 @@ public class TemplatePane extends JPanel implements MouseListener { return true; } - private String getDesignerVersion(EnvConfig selectedEnv) { + private String getDesignerVersion(DesignerWorkspaceInfo selectedEnv) { // return selectedEnv.getDesignerVersion(); throw new UnsupportedOperationException("unsupport now"); } @@ -169,12 +167,17 @@ public class TemplatePane extends JPanel implements MouseListener { } 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) { - envLabel.setIcon(IOUtils.readIcon("com/fr/design/images/data/bind/distanceconnect.png")); + + DesignerWorkspaceInfo config = DesignerEnvManager.getEnvManager().getWorkspaceInfo(name); + 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")); + break; + } } envLabel.setText(name); envLabel.repaint(); diff --git a/designer-base/src/com/fr/design/mainframe/loghandler/socketio/DesignerSocketIO.java b/designer-base/src/com/fr/design/mainframe/loghandler/socketio/DesignerSocketIO.java index bcf9e2ae03..f64f0dff3b 100644 --- a/designer-base/src/com/fr/design/mainframe/loghandler/socketio/DesignerSocketIO.java +++ b/designer-base/src/com/fr/design/mainframe/loghandler/socketio/DesignerSocketIO.java @@ -2,10 +2,6 @@ package com.fr.design.mainframe.loghandler.socketio; import com.fr.base.Env; import com.fr.base.FRContext; -import com.fr.base.env.EnvConfig; -import com.fr.core.env.EnvConstants; -import com.fr.core.env.EnvContext; -import com.fr.core.env.EnvEvent; import com.fr.decision.webservice.utils.DecisionServiceConstants; import com.fr.design.env.RemoteEnvConfig; import com.fr.design.mainframe.loghandler.DesignerLogHandler; @@ -18,6 +14,8 @@ import com.fr.general.LogUtils; import com.fr.log.FineLoggerFactory; import com.fr.third.guava.base.Optional; import com.fr.web.WebSocketConfig; +import com.fr.workspace.Workspace; +import com.fr.workspace.WorkspaceEvent; import io.socket.client.IO; import io.socket.client.Socket; import io.socket.emitter.Emitter; @@ -44,18 +42,18 @@ public class DesignerSocketIO { }; static { - EventDispatcher.listen(EnvEvent.AFTER_SIGN_OUT, new Listener() { + EventDispatcher.listen(WorkspaceEvent.BeforeSwitch, new Listener() { @Override - public void on(Event event, EnvConfig param) { + public void on(Event event, Workspace param) { if (socketIO.isPresent()) { socketIO.get().close(); socketIO = Optional.absent(); } } }); - EventDispatcher.listen(EnvEvent.AFTER_SIGN_IN, new Listener() { + EventDispatcher.listen(WorkspaceEvent.AfterSwitch, new Listener() { @Override - public void on(Event event, EnvConfig param) { + public void on(Event event, Workspace param) { updateSocket(); } }); @@ -71,16 +69,16 @@ public class DesignerSocketIO { return; } try { - RemoteEnvConfig config = ((RemoteEnv)env).getEnvConfig(); - String uri = String.format("http://%s:%s%s?%s=%s", - config.getHost(), - WebSocketConfig.getInstance().getPort(), - EnvConstants.WS_NAMESPACE, - DecisionServiceConstants.WEB_SOCKET_TOKEN_NAME, - EnvContext.currentToken()); - - socketIO = Optional.of(IO.socket(new URI(uri))); - socketIO.get().on(EnvConstants.WS_LOGRECORD, printLog); +// RemoteEnvConfig config = ((RemoteEnv)env).getEnvConfig(); +// String uri = String.format("http://%s:%s%s?%s=%s", +// config.getHost(), +// WebSocketConfig.getInstance().getPort(), +// EnvConstants.WS_NAMESPACE, +// DecisionServiceConstants.WEB_SOCKET_TOKEN_NAME, +// EnvContext.currentToken()); +// +// socketIO = Optional.of(IO.socket(new URI(uri))); +// socketIO.get().on(EnvConstants.WS_LOGRECORD, printLog); // socketIO.get().on(EnvConstants.CONFIG, new Emitter.Listener() { // @Override // public void call(Object... objects) { diff --git a/designer-base/src/com/fr/design/mainframe/templateinfo/TemplateInfoCollector.java b/designer-base/src/com/fr/design/mainframe/templateinfo/TemplateInfoCollector.java index d4450b43ed..be286226cb 100644 --- a/designer-base/src/com/fr/design/mainframe/templateinfo/TemplateInfoCollector.java +++ b/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.JTemplate; import com.fr.design.mainframe.SiteCenterToken; -import com.fr.env.RemoteEnv; import com.fr.general.ComparatorUtils; -import com.fr.log.FineLoggerFactory; import com.fr.general.GeneralUtils; import com.fr.general.IOUtils; import com.fr.general.SiteCenter; import com.fr.general.http.HttpClient; import com.fr.json.JSONObject; +import com.fr.log.FineLoggerFactory; import com.fr.stable.EncodeConstants; import com.fr.stable.ProductConstants; 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.XMLableReader; import com.fr.third.javax.xml.stream.XMLStreamException; +import com.fr.workspace.WorkContext; import java.io.ByteArrayInputStream; import java.io.File; @@ -167,7 +167,8 @@ public class TemplateInfoCollector implements Serializable, } private boolean shouldCollectInfo() { - if (FRContext.getCurrentEnv() instanceof RemoteEnv) { // 远程设计不收集数据 + //只收集本地环境的 + if (!WorkContext.getCurrent().isLocal()) { return false; } return DesignerEnvManager.getEnvManager().isJoinProductImprove() && FRContext.isChineseEnv(); diff --git a/designer-base/src/com/fr/design/remote/action/RemoteDesignAuthorityManagerAction.java b/designer-base/src/com/fr/design/remote/action/RemoteDesignAuthorityManagerAction.java index 8d22b77a44..302e838fa7 100644 --- a/designer-base/src/com/fr/design/remote/action/RemoteDesignAuthorityManagerAction.java +++ b/designer-base/src/com/fr/design/remote/action/RemoteDesignAuthorityManagerAction.java @@ -1,17 +1,11 @@ package com.fr.design.remote.action; 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.dialog.BasicDialog; -import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.mainframe.DesignerContext; import com.fr.design.remote.ui.AuthorityManagerPane; -import com.fr.env.operator.authority.AuthorityOperator; import com.fr.general.Inter; -import com.fr.log.FineLoggerFactory; -import com.fr.report.DesignAuthority; import java.awt.event.ActionEvent; @@ -34,38 +28,38 @@ public class RemoteDesignAuthorityManagerAction extends UpdateAction { BasicDialog dialog = managerPane.showWindow(DesignerContext.getDesignerFrame()); - if (!FRContext.getCurrentEnv().isLocalEnv()) { - try { - // 远程设计获取全部设计成员的权限列表 - DesignAuthority[] authorities = EnvProxy.get(AuthorityOperator.class).getAuthorities(); - if (authorities != null && authorities.length != 0) { - managerPane.populate(authorities); - } - } catch (Exception exception) { - FineLoggerFactory.getLogger().error(exception.getMessage(), exception); - } - } - - dialog.addDialogActionListener(new DialogActionAdapter() { - @Override - public void doOk() { - DesignAuthority[] authorities = managerPane.update(); - if (!FRContext.getCurrentEnv().isLocalEnv()) { - boolean success = false; - try { - success = EnvProxy.get(AuthorityOperator.class).updateAuthorities(authorities); - } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); - } - FRContext.getLogger().info("update remote design authority: " + success); - } - } - - @Override - public void doCancel() { - super.doCancel(); - } - }); +// if (!FRContext.getCurrentEnv().isLocalEnv()) { +// try { +// // 远程设计获取全部设计成员的权限列表 +// DesignAuthority[] authorities = EnvProxy.get(AuthorityOperator.class).getAuthorities(); +// if (authorities != null && authorities.length != 0) { +// managerPane.populate(authorities); +// } +// } catch (Exception exception) { +// FineLoggerFactory.getLogger().error(exception.getMessage(), exception); +// } +// } +// +// dialog.addDialogActionListener(new DialogActionAdapter() { +// @Override +// public void doOk() { +// DesignAuthority[] authorities = managerPane.update(); +// if (!FRContext.getCurrentEnv().isLocalEnv()) { +// boolean success = false; +// try { +// success = EnvProxy.get(AuthorityOperator.class).updateAuthorities(authorities); +// } catch (Exception e) { +// FineLoggerFactory.getLogger().error(e.getMessage(), e); +// } +// FRContext.getLogger().info("update remote design authority: " + success); +// } +// } +// +// @Override +// public void doCancel() { +// super.doCancel(); +// } +// }); dialog.setModal(true); dialog.setVisible(true); } diff --git a/designer-base/src/com/fr/design/utils/DesignUtils.java b/designer-base/src/com/fr/design/utils/DesignUtils.java index 60b010b4c4..1cf12cb547 100644 --- a/designer-base/src/com/fr/design/utils/DesignUtils.java +++ b/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.gui.UILookAndFeel; import com.fr.design.mainframe.DesignerContext; -import com.fr.env.RemoteEnv; import com.fr.file.FileFILE; import com.fr.general.ComparatorUtils; import com.fr.general.FRFont; diff --git a/designer-base/src/com/fr/env/EnvListPane.java b/designer-base/src/com/fr/env/EnvListPane.java index 652b11d084..f0d390f620 100644 --- a/designer-base/src/com/fr/env/EnvListPane.java +++ b/designer-base/src/com/fr/env/EnvListPane.java @@ -1,9 +1,7 @@ package com.fr.env; -import com.fr.base.env.EnvConfig; -import com.fr.base.env.LocalEnvConfig; -import com.fr.design.env.RemoteEnvConfig; import com.fr.design.DesignerEnvManager; +import com.fr.design.env.DesignerWorkspaceInfo; import com.fr.design.gui.controlpane.JListControlPane; import com.fr.design.gui.controlpane.NameObjectCreator; import com.fr.design.gui.controlpane.NameableCreator; @@ -59,9 +57,9 @@ public class EnvListPane extends JListControlPane { @Override public NameableCreator[] createNameableCreators() { NameableCreator local = new NameObjectCreator(Inter.getLocText("Env-Local_Directory"), "com/fr/design/images/data/bind/localconnect.png", - LocalEnvConfig.class, LocalEnvPane.class); + DesignerWorkspaceInfo.class, LocalEnvPane.class); NameableCreator remote = new NameObjectCreator(Inter.getLocText("Env-Remote_Server"), "com/fr/design/images/data/bind/distanceconnect.png", - RemoteEnvConfig.class, RemoteEnvPane2.class); + DesignerWorkspaceInfo.class, RemoteEnvPane2.class); return new NameableCreator[]{local, remote}; } @@ -81,7 +79,7 @@ public class EnvListPane extends JListControlPane { List nameObjectList = new ArrayList<>(); while (nameIt.hasNext()) { 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])); @@ -104,7 +102,7 @@ public class EnvListPane extends JListControlPane { Nameable[] res = this.update(); for (Nameable re : res) { NameObject nameObject = (NameObject) re; - mgr.putEnv(nameObject.getName(), (EnvConfig) nameObject.getObject()); + mgr.putEnv(nameObject.getName(), (DesignerWorkspaceInfo) nameObject.getObject()); } return this.getSelectedName(); } diff --git a/designer-base/src/com/fr/env/LocalEnvPane.java b/designer-base/src/com/fr/env/LocalEnvPane.java index 993a72b139..c518f1dbec 100644 --- a/designer-base/src/com/fr/env/LocalEnvPane.java +++ b/designer-base/src/com/fr/env/LocalEnvPane.java @@ -1,7 +1,7 @@ package com.fr.env; -import com.fr.base.env.LocalEnvConfig; import com.fr.design.beans.BasicBeanPane; +import com.fr.design.env.DesignerWorkspaceInfo; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itextarea.UITextArea; import com.fr.design.gui.itextfield.UITextField; @@ -21,7 +21,7 @@ import java.io.File; /** * @author yaohwu */ -public class LocalEnvPane extends BasicBeanPane { +public class LocalEnvPane extends BasicBeanPane { private UITextField pathTextField; private JFileTree localEnvTree; @@ -70,9 +70,9 @@ public class LocalEnvPane extends BasicBeanPane { } @Override - public LocalEnvConfig updateBean() { + public DesignerWorkspaceInfo updateBean() { String path = pathTextField.getText(); - return new LocalEnvConfig(path); + return DesignerWorkspaceInfo.createLocal(StringUtils.EMPTY, path); } public String getPath() { @@ -80,7 +80,7 @@ public class LocalEnvPane extends BasicBeanPane { } @Override - public void populateBean(LocalEnvConfig ob) { + public void populateBean(DesignerWorkspaceInfo ob) { if (StringUtils.isBlank(ob.getPath())) { return; } diff --git a/designer-base/src/com/fr/env/RemoteEnv.java b/designer-base/src/com/fr/env/RemoteEnv.java index 084962a03b..1d8aa0de8d 100644 --- a/designer-base/src/com/fr/env/RemoteEnv.java +++ b/designer-base/src/com/fr/env/RemoteEnv.java @@ -1,762 +1,759 @@ -package com.fr.env; - -import com.fr.base.EnvException; -import com.fr.base.operator.common.CommonOperator; -import com.fr.base.operator.connect.ConnectOperator; -import com.fr.base.operator.file.FileOperator; -import com.fr.base.operator.org.OrganizationOperator; -import com.fr.base.remote.RemoteDeziConstants; -import com.fr.core.env.EnvConstants; -import com.fr.core.env.EnvContext; -import com.fr.data.impl.storeproc.StoreProcedure; -import com.fr.dav.AbstractEnv; -import com.fr.dav.DavXMLUtils; -import com.fr.design.DesignerEnvManager; -import com.fr.design.env.RemoteEnvConfig; -import com.fr.design.mainframe.DesignerContext; -import com.fr.file.CacheManager; -import com.fr.general.CommonIOUtils; -import com.fr.general.ComparatorUtils; -import com.fr.general.IOUtils; -import com.fr.general.Inter; -import com.fr.general.http.HttpToolbox; -import com.fr.io.utils.ResourceIOUtils; -import com.fr.json.JSONArray; -import com.fr.json.JSONObject; -import com.fr.log.FineLoggerFactory; -import com.fr.report.DesignAuthority; -import com.fr.report.util.AuthorityXMLUtils; -import com.fr.share.ShareConstants; -import com.fr.stable.ArrayUtils; -import com.fr.stable.EncodeConstants; -import com.fr.stable.Filter; -import com.fr.stable.ProductConstants; -import com.fr.stable.StableUtils; -import com.fr.stable.StringUtils; -import com.fr.stable.SvgProvider; -import com.fr.stable.project.ProjectConstants; -import com.fr.third.guava.base.Strings; -import com.fr.third.guava.collect.ImmutableMap; -import com.fr.web.ResourceConstants; -import com.fr.workspace.engine.server.rpc.RemoteCallServerConfig; -import com.fr.workspace.engine.server.rpc.netty.MessageSendExecutor; -import com.fr.workspace.engine.server.rpc.netty.RemoteCallClient; - -import javax.swing.*; -import javax.xml.transform.Source; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerConfigurationException; -import javax.xml.transform.TransformerException; -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.dom.DOMSource; -import javax.xml.transform.stream.StreamResult; -import java.awt.*; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.OutputStreamWriter; -import java.io.UnsupportedEncodingException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map; - -import static com.fr.third.guava.base.Preconditions.checkArgument; - -/** - * @author null - */ -public class RemoteEnv extends AbstractEnv implements DesignAuthorityConfigurable { - - private static final String CERT_KEY = "javax.net.ssl.trustStore"; - private static final String PWD_KEY = "javax.net.ssl.trustStorePassword"; - private static final String HTTPS_PREFIX = "https:"; - private final static String[] FILE_TYPE = {"cptx", "cpt", "frm", "form", "cht", "chart"}; - private String buildFilePath; - private RemoteEnvConfig config; - - public RemoteEnv(RemoteEnvConfig config) { - this.config = config; - } - - @Override - public void connect() throws Exception { - RemoteCallClient.getInstance().load(config.getHost(), config.getPort(), RemoteCallServerConfig.getInstance().getSerializeProtocol()); - } - - @Override - public void connectOnce() throws Exception { - RemoteCallClient.getInstance().loadOnce(config.getHost(), config.getPort(), RemoteCallServerConfig.getInstance().getSerializeProtocol(), 10 * 1000); - ConnectOperator operator = RemoteCallClient.getInstance().execute(ConnectOperator.class); - boolean result = false; - try { - result = operator.connect(config.getUsername(), config.getPassword()); - } catch (Exception ignore) { - - } - if (!result) { - throw new Exception("Cannot connect to the remote server!"); - } - } - - @Override - public boolean disconnect() { - MessageSendExecutor.getInstance().stop(); - return true; - } - - @Override - public FileOperator getFileOperator() throws Exception { - - return MessageSendExecutor.getInstance().execute(FileOperator.class); - } - - @Override - public CommonOperator getCommonOperator() throws Exception { - return MessageSendExecutor.getInstance().execute(CommonOperator.class); - } - - @Override - public OrganizationOperator getOrganizationOperator() throws Exception { - return MessageSendExecutor.getInstance().execute(OrganizationOperator.class); - } - - @Override - public String getPath() { - return config.getPath(); - } - - @Override - public String getUser() { - return config.getUsername(); - } - - public String getPassword() { - return config.getPassword(); - } - - @Override - public String getUserID() { - return EnvContext.currentToken(); - } - - @Override - public boolean isLocalEnv() { - return false; - } - - /** - * execute method之后,取返回的 InputStream - */ - private InputStream filterInputStream(InputStream in) throws Exception { - if (in == null) { - return null; - } - ByteArrayOutputStream out = new ByteArrayOutputStream(); - try { - IOUtils.copyBinaryTo(in, out); - // 看一下传过来的byte[]是不是DesignProcessor.INVALID,如果是的话,就抛Exception - byte[] bytes = out.toByteArray(); - // carl:格式一致传中文 - String message = new String(bytes, EncodeConstants.ENCODING_UTF_8); - if (ComparatorUtils.equals(message, RemoteDeziConstants.NO_SUCH_RESOURCE)) { - return null; - } else if (ComparatorUtils.equals(message, RemoteDeziConstants.INVALID_USER)) { - throw new EnvException(RemoteDeziConstants.INVALID_USER); - } else if (ComparatorUtils.equals(message, RemoteDeziConstants.FILE_LOCKED)) { - JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Remote_File_is_Locked")); - return null; - } - return new ByteArrayInputStream(bytes); - } finally { - synchronized (this) { - in.close(); - out.close(); - } - } - } - - - /** - * nameValuePairs,这个参数要接着this.path,拼成一个URL,否则服务器端req.getParameter是无法得到的 - * - * @param bytes 数据 - * @return 是否成功提交 - * @throws Exception 异常 - */ - private boolean postBytes2Server(byte[] bytes, HashMap para) throws Exception { - filterInputStream(RemoteEnvUtils.simulateRPCByHttpPost(bytes, para, false, this)); - return true; - } - - /** - * 把InputStream转成一段String - * - * @param in InputStream输入流 - * @return 转换后的字符串 - */ - private static String stream2String(InputStream in) { - if (in == null) { - return null; - } - String result = null; - try { - result = CommonIOUtils.inputStream2String(in, EncodeConstants.ENCODING_UTF_8); - } catch (UnsupportedEncodingException e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); - } - return result; - } - - /** - * 测试连接服务器 - * - * @return 测试连接成功返回true - * @throws Exception 异常 - */ - private boolean testServerConnection() throws Exception { - return testConnection(true, true, DesignerContext.getDesignerFrame()); - } - - /** - * 测试当前配置是否正确 - * - * @return 链接是否成功 - * @throws Exception 异常 - */ - @Override - public boolean testServerConnectionWithOutShowMessagePane() throws Exception { - return testConnection(false, true, DesignerContext.getDesignerFrame()); - } - - /** - * 主要用于在环境配置面板中的测试连接按钮时,不要注册进远程环境 - * - * @param messageParentPane 弹框的依赖的面板 - * @return 是否测试连接成功 - * @throws Exception 异常 - */ - public boolean testConnectionWithOutRegisteServer(Component messageParentPane) throws Exception { - return testConnection(true, false, messageParentPane); - } - - - private boolean testConnection(boolean needMessage, boolean isRegisteServer, Component parentComponent) throws Exception { - checkArgument(parentComponent instanceof Component, "parentComponent should be a java.awt.component"); - Component component = parentComponent; - String url = String.format("%s/connection", EnvConstants.toDecisionPath(getPath())); - ImmutableMap params = ImmutableMap.of( - "version", (Object) ProductConstants.DESIGNER_VERSION - ); - ImmutableMap headers = ImmutableMap.of( - EnvConstants.USERNAME, getUser(), - EnvConstants.PWD, getPassword()); - String res = HttpToolbox.post(url, params, headers); - if (Strings.isNullOrEmpty(res)) { - if (needMessage) { - JOptionPane.showMessageDialog(component, Inter.getLocText("Datasource-Connection_failed")); - } - return false; - } else if (ComparatorUtils.equals(res, "true")) { - return true; - } else { - if (ComparatorUtils.equals(res, EnvConstants.AUTH_ERROR)) { - JOptionPane.showMessageDialog(component, - Inter.getLocText(new String[]{"Datasource-Connection_failed", "Registration-User_Name", "Password", "Error"}, new String[]{",", "", "", "!"}) - , Inter.getLocText("FR-Server-All_Error"), JOptionPane.ERROR_MESSAGE); - return false; - } else { - if (ComparatorUtils.equals(res, EnvConstants.WAR_ERROR)) { - if (needMessage) { - JOptionPane.showMessageDialog(component, Inter.getLocText(new String[]{"Datasource-Connection_failed", "NS-war-remote"}, new String[]{",", "!"})); - } else { - FineLoggerFactory.getLogger().info(Inter.getLocText(new String[]{"Datasource-Connection_failed", "NS-war-remote"}, new String[]{",", "!"})); - } - return false; - } else { - if (needMessage) { - JOptionPane.showMessageDialog(component, Inter.getLocText("Datasource-Connection_failed")); - } else { - FineLoggerFactory.getLogger().info(Inter.getLocText(new String[]{"Datasource-Connection_failed", "Version-does-not-support"}, new String[]{",", "!"})); - } - return false; - } - } - } - } - - - private void refreshHttpSProperty() { - if (getPath().startsWith(HTTPS_PREFIX) && System.getProperty(CERT_KEY) == null) { - DesignerEnvManager envManager = DesignerEnvManager.getEnvManager(); - System.setProperty(CERT_KEY, envManager.getCertificatePath()); - System.setProperty(PWD_KEY, envManager.getCertificatePass()); - } - } - - - /** - * 心跳访问,用来更新当前用户的访问时间 - * - * @throws Exception e - */ - - public class Bytes2ServerOutputStream extends OutputStream { - private ByteArrayOutputStream out = new ByteArrayOutputStream(); - private HashMap nameValuePairs; - - public Bytes2ServerOutputStream(HashMap nameValuePairs) { - this.nameValuePairs = nameValuePairs; - } - - public HashMap getNameValuePairs() { - return nameValuePairs; - } - - public ByteArrayOutputStream getOut() { - return out; - } - - public OutputStream getZipOutputStream() throws Exception { - return IOUtils.toZipOut(out); - } - - /** - * post ro Server 提交到服务器 - * - * @return 是否提交成功 - */ - public boolean post2Server() { - try { - return postBytes2Server(out.toByteArray(), nameValuePairs); - } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); - return false; - } - } - - /** - * 刷新数出流,并提交 - * - * @throws IOException e - */ - @Override - public void flush() throws IOException { - super.flush(); - post2Server(); - } - - /** - * 将指定字节写入输入流数组 - * - * @param b 写入的字节 - */ - @Override - public void write(int b) { - out.write(b); - - } - } - - @Override - public boolean updateAuthorities(DesignAuthority[] authorities) { - refreshHttpSProperty(); - String res = null; - try { - InputStream inputStream = RemoteEnvUtils.updateAuthorities(authorities, this); - inputStream = filterInputStream(inputStream); - res = IOUtils.inputStream2String(inputStream, EncodeConstants.ENCODING_UTF_8); - } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage()); - } - return StringUtils.isNotEmpty(res) && Boolean.valueOf(res); - } - - @Override - public DesignAuthority[] getAuthorities() { - refreshHttpSProperty(); - DesignAuthority[] authorities = new DesignAuthority[0]; - try { - InputStream inputStream = RemoteEnvUtils.getAuthorities(this); - inputStream = filterInputStream(inputStream); - authorities = AuthorityXMLUtils.readDesignAuthoritiesXML(inputStream); - return authorities; - } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage()); - } - return authorities; - } - - /** - * 远程设计器设计时,假如开了权限就不可预览了。这边放一个全局的map来开后门 - * - * @param key 键值 - * @param value 值 - * @return 如果写入成功,返回true - * @throws Exception e - */ - public boolean writePrivilegeMap(String key, String value) throws Exception { - refreshHttpSProperty(); - HashMap para = new HashMap<>(); - para.put("op", "fr_remote_design"); - para.put("cmd", "write_privilege_map"); - para.put("current_user", getUser()); - para.put("current_password", getPassword()); - para.put("key", key); - para.put("value", value); - - //jim :加上user,远程设计点击预览时传递用户角色信息 - InputStream input = filterInputStream( - RemoteEnvUtils.simulateRPCByHttpGet(para, false, this) - ); - - if (input == null) { - return false; - } - - return Boolean.valueOf(IOUtils.inputStream2String(input, EncodeConstants.ENCODING_UTF_8)); - } - - - /** - * nameValuePairs,这个参数要接着this.path,拼成一个URL,否则服务器端req.getParameter是无法得到的 - * - * @param bytes 数据 - * @param para 参数 - * @return 从服务器端得到InputStream - * @throws Exception 异常 - */ - public InputStream postBytes2ServerB(byte[] bytes, HashMap para) throws Exception { - refreshHttpSProperty(); - return filterInputStream(RemoteEnvUtils.simulateRPCByHttpPost(bytes, para, false, this)); - } - - - /** - * 读取路径下的svg文件 - * - * @param path 制定路径,是基于报表目录下resource文件夹路径 - * @return 读到的文件 - */ - @Override - public String[] readPathSvgFiles(String path) { - refreshHttpSProperty(); - String cataloguePath = StableUtils.pathJoin(CacheManager.getProviderInstance().getCacheDirectory().getPath(), SvgProvider.SERVER, path); - - ArrayList fileArray = new ArrayList<>(); - try { - HashMap para = new HashMap<>(); - para.put("op", "fr_remote_design"); - para.put("cmd", "design_read_svgfile"); - para.put("resourcePath", path); - para.put("current_uid", this.getUserID()); - para.put("currentUsername", this.getUser()); - - InputStream input = filterInputStream( - RemoteEnvUtils.simulateRPCByHttpGet(para, false, this) - ); - JSONArray ja = new JSONArray(stream2String(input)); - for (int i = 0; i < ja.length(); i++) { - JSONObject jsonObject = (JSONObject) ja.get(i); - String svgFileName = (String) jsonObject.get("svgfileName"); - String svgFileContent = (String) jsonObject.get("svgfileContent"); - - String file = StableUtils.pathJoin(cataloguePath, svgFileName); - InputStream in = new ByteArrayInputStream(svgFileContent.getBytes(EncodeConstants.ENCODING_UTF_8)); - ResourceIOUtils.write(file, in); - fileArray.add(file); - } - } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage()); - } - - return fileArray.toArray(new String[0]); - } - - - /** - * 写svg文件 - * - * @param svgFile svg文件 - * @return 是否写入成功 - * @throws Exception 异常 - */ - @Override - public boolean writeSvgFile(SvgProvider svgFile) throws Exception { - testServerConnection(); - - HashMap para = new HashMap<>(); - para.put("op", "svgrelate"); - para.put("cmd", "design_save_svg"); - para.put("filePath", svgFile.getFilePath()); - para.put("current_uid", this.getUserID()); - para.put("currentUsername", this.getUser()); - - // 通过ByteArrayOutputStream将svg写成字节流 - Bytes2ServerOutputStream out = new Bytes2ServerOutputStream(para); - OutputStreamWriter outWriter = new OutputStreamWriter(out, "UTF-8"); - StreamResult result = new StreamResult(outWriter); - - Source source = new DOMSource(svgFile.getSvgDocument()); - try { - Transformer xformer = TransformerFactory.newInstance().newTransformer(); - try { - xformer.transform(source, result); - } catch (TransformerException ex) { - FineLoggerFactory.getLogger().error(ex.getMessage()); - } - - } catch (TransformerConfigurationException ex) { - FineLoggerFactory.getLogger().error(ex.getMessage()); - return false; - } - - try { - String res = stream2String(filterInputStream( - RemoteEnvUtils.simulateRPCByHttpPost(out.getOut().toByteArray(), out.nameValuePairs, false, this) - )); - if (StringUtils.isNotEmpty(res)) { - JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Already_exist") + res); - return false; - } - } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage()); - return false; - } - - return true; - } - - /** - * 写文件 - * - * @param beanPath 文件名 - * @param prefix 当前Env下得工程分类,如reportlets,lib等 - * @return OutputStream 输出流 - */ - @Override - public OutputStream writeBean(String beanPath, String prefix) { - HashMap para = new HashMap<>(); - para.put("op", "fs_remote_design"); - para.put("cmd", "design_save_report"); - para.put(RemoteDeziConstants.PREFXI, prefix); - para.put(RemoteDeziConstants.TEMPLATE_PATH, beanPath); - - return new Bytes2ServerOutputStream(para); - } - - /** - * 返回模板文件路径 - */ - @Override - public String getWebReportPath() { - - return StableUtils.pathJoin(getPath(), getAppName()); - } - - public String[] getProcedureColumns(StoreProcedure storeProcedure, Map parameterMap) throws Exception { - refreshHttpSProperty(); - String[] columns; - HashMap para = new HashMap<>(); - para.put("op", "fr_remote_design"); - para.put("cmd", "list_sp"); - try { - InputStream input = filterInputStream( - RemoteEnvUtils.simulateRPCByHttpGet(para, false, this) - ); - - if (input == null) { - return ArrayUtils.EMPTY_STRING_ARRAY; - } - - columns = DavXMLUtils.readXMLSPColumns(input); - return columns; - } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage()); - } - - return new String[0]; - } - - public String[] getProcedureColumns(String name) throws Exception { - refreshHttpSProperty(); - String[] columns; - HashMap para = new HashMap<>(); - para.put("op", "fr_remote_design"); - para.put("cmd", "list_sp_columns_name"); - para.put("name", name); - try { - InputStream input = filterInputStream( - RemoteEnvUtils.simulateRPCByHttpGet(para, false, this) - ); - if (input == null) { - return ArrayUtils.EMPTY_STRING_ARRAY; - } - columns = DavXMLUtils.readXMLSPColumns(input); - return columns; - } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage()); - } - return new String[0]; - - } - - @Override - public String[] getSupportedTypes() { - return FILE_TYPE; - } - - /** - * 获取当前env的build文件路径 - */ - @Override - public String getBuildFilePath() { - return StringUtils.isEmpty(buildFilePath) ? ResourceConstants.BUILD_PATH : buildFilePath; - } - - /** - * 设置当前env的build文件路径 - */ - @Override - public void setBuildFilePath(String buildFilePath) { - this.buildFilePath = buildFilePath; - } - - @Override - public String[] loadREUFile() { - refreshHttpSProperty(); - ResourceIOUtils.delete(StableUtils.pathJoin( - CacheManager.getProviderInstance().getCacheDirectory().getAbsolutePath(), - ShareConstants.DIR_SHARE_CACHE)); - - String zipFilePath = null; - try { - HashMap para = new HashMap<>(); - para.put("op", "fr_remote_design"); - para.put("cmd", "design_read_reufile"); - para.put("current_uid", this.getUserID()); - para.put("currentUsername", this.getUser()); - - //拿到服务端传过来的整个共享文件夹的压缩文件的文件流 - InputStream input = RemoteEnvUtils.simulateRPCByHttpGet(para, false, this); - - zipFilePath = StableUtils.pathJoin(CacheManager.getProviderInstance().getCacheDirectory().getAbsolutePath(), "share.zip"); - String cacheDir = StableUtils.pathJoin(CacheManager.getProviderInstance().getCacheDirectory().getAbsolutePath(), ShareConstants.DIR_SHARE_CACHE); - - ResourceIOUtils.write(zipFilePath, input); - ResourceIOUtils.unzip(zipFilePath, cacheDir, EncodeConstants.ENCODING_GBK); - - - return ResourceIOUtils.listWithFullPath(cacheDir, new Filter() { - @Override - public boolean accept(String s) { - return s.endsWith(ProjectConstants.REU); - } - }); - - } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage()); - } finally { - - if (zipFilePath != null) { - ResourceIOUtils.delete(zipFilePath); - } - } - - return new String[0]; - } - - @Override - public boolean installREUFile(File reuFile) { - refreshHttpSProperty(); - if (reuFile == null) { - return false; - } - File tempFile = new File(CacheManager.getProviderInstance().getCacheDirectory(), "temp_remote"); - IOUtils.unzip(reuFile, tempFile.getAbsolutePath()); - String shareXMLName = StableUtils.pathJoin(tempFile.getAbsolutePath(), ShareConstants.NAME_XML_MODULE); - String helpXMLName = StableUtils.pathJoin(tempFile.getAbsolutePath(), ShareConstants.NAME_XML_HELP); - try { - HashMap para = new HashMap<>(); - para.put("op", "fr_remote_design"); - para.put("cmd", "design_install_reufile"); - para.put("current_uid", this.getUserID()); - para.put("currentUsername", this.getUser()); - para.put("reuFileName", reuFile.getName()); - - InputStream input = filterInputStream( - RemoteEnvUtils.simulateRPCByHttpPost( - IOUtils.inputStream2Bytes( - new FileInputStream(new File(shareXMLName)) - ) - , para, - false, - this) - ); - para.put("isComplete", "true"); - InputStream input1 = filterInputStream(RemoteEnvUtils.simulateRPCByHttpPost( - IOUtils.inputStream2Bytes( - new FileInputStream(new File(helpXMLName)) - ) - , para, - false, - this)); - return ComparatorUtils.equals(stream2String(input), "true") && ComparatorUtils.equals(stream2String(input1), "true"); - } catch (Exception e) { - return false; - } - } - - @Override - public boolean removeREUFilesByName(String fileName) { - refreshHttpSProperty(); - if (StringUtils.isEmpty(fileName)) { - return true; - } - try { - HashMap para = new HashMap<>(); - para.put("op", "fr_remote_design"); - para.put("cmd", "design_remove_reufile"); - para.put("current_uid", this.getUserID()); - para.put("currentUsername", this.getUser()); - para.put("reuFileName", fileName); - - InputStream input = filterInputStream( - RemoteEnvUtils.simulateRPCByHttpGet(para, false, this) - ); - return ComparatorUtils.equals(stream2String(input), "true"); - } catch (Exception e) { - return false; - } - } - - @Override - public String getSharePath() { - refreshHttpSProperty(); - try { - HashMap para = new HashMap<>(); - para.put("op", "fr_remote_design"); - para.put("cmd", "design_get_share_path"); - para.put("current_uid", this.getUserID()); - para.put("currentUsername", this.getUser()); - - InputStream input = filterInputStream( - RemoteEnvUtils.simulateRPCByHttpGet(para, false, this) - ); - return stream2String(input); - } catch (Exception e) { - return StringUtils.EMPTY; - } - } - - - @Override - public boolean hasPluginServiceStarted(String key) { - - return true; - } - -} \ No newline at end of file +//package com.fr.env; +// +//import com.fr.base.EnvException; +//import com.fr.base.operator.common.CommonOperator; +//import com.fr.base.operator.connect.ConnectOperator; +//import com.fr.base.operator.file.FileOperator; +//import com.fr.base.operator.org.OrganizationOperator; +//import com.fr.base.remote.RemoteDeziConstants; +//import com.fr.data.impl.storeproc.StoreProcedure; +//import com.fr.dav.AbstractEnv; +//import com.fr.dav.DavXMLUtils; +//import com.fr.design.DesignerEnvManager; +//import com.fr.design.mainframe.DesignerContext; +//import com.fr.file.CacheManager; +//import com.fr.general.CommonIOUtils; +//import com.fr.general.ComparatorUtils; +//import com.fr.general.IOUtils; +//import com.fr.general.Inter; +//import com.fr.general.http.HttpToolbox; +//import com.fr.io.utils.ResourceIOUtils; +//import com.fr.json.JSONArray; +//import com.fr.json.JSONObject; +//import com.fr.log.FineLoggerFactory; +//import com.fr.report.DesignAuthority; +//import com.fr.report.util.AuthorityXMLUtils; +//import com.fr.share.ShareConstants; +//import com.fr.stable.ArrayUtils; +//import com.fr.stable.EncodeConstants; +//import com.fr.stable.Filter; +//import com.fr.stable.ProductConstants; +//import com.fr.stable.StableUtils; +//import com.fr.stable.StringUtils; +//import com.fr.stable.SvgProvider; +//import com.fr.stable.project.ProjectConstants; +//import com.fr.third.guava.base.Strings; +//import com.fr.third.guava.collect.ImmutableMap; +//import com.fr.web.ResourceConstants; +//import com.fr.workspace.engine.server.rpc.RemoteCallServerConfig; +//import com.fr.workspace.engine.server.rpc.netty.MessageSendExecutor; +//import com.fr.workspace.engine.server.rpc.netty.RemoteCallClient; +// +//import javax.swing.*; +//import javax.xml.transform.Source; +//import javax.xml.transform.Transformer; +//import javax.xml.transform.TransformerConfigurationException; +//import javax.xml.transform.TransformerException; +//import javax.xml.transform.TransformerFactory; +//import javax.xml.transform.dom.DOMSource; +//import javax.xml.transform.stream.StreamResult; +//import java.awt.*; +//import java.io.ByteArrayInputStream; +//import java.io.ByteArrayOutputStream; +//import java.io.File; +//import java.io.FileInputStream; +//import java.io.IOException; +//import java.io.InputStream; +//import java.io.OutputStream; +//import java.io.OutputStreamWriter; +//import java.io.UnsupportedEncodingException; +//import java.util.ArrayList; +//import java.util.HashMap; +//import java.util.Map; +// +//import static com.fr.third.guava.base.Preconditions.checkArgument; +// +///** +// * @author null +// */ +//public class RemoteEnv extends AbstractEnv implements DesignAuthorityConfigurable { +// +// private static final String CERT_KEY = "javax.net.ssl.trustStore"; +// private static final String PWD_KEY = "javax.net.ssl.trustStorePassword"; +// private static final String HTTPS_PREFIX = "https:"; +// private final static String[] FILE_TYPE = {"cptx", "cpt", "frm", "form", "cht", "chart"}; +// private String buildFilePath; +// private RemoteEnvConfig config; +// +// public RemoteEnv(RemoteEnvConfig config) { +// this.config = config; +// } +// +// @Override +// public void connect() throws Exception { +// RemoteCallClient.getInstance().load(config.getHost(), config.getPort(), RemoteCallServerConfig.getInstance().getSerializeProtocol()); +// } +// +// @Override +// public void connectOnce() throws Exception { +// RemoteCallClient.getInstance().loadOnce(config.getHost(), config.getPort(), RemoteCallServerConfig.getInstance().getSerializeProtocol(), 10 * 1000); +// ConnectOperator operator = RemoteCallClient.getInstance().execute(ConnectOperator.class); +// boolean result = false; +// try { +// result = operator.connect(config.getUsername(), config.getPassword()); +// } catch (Exception ignore) { +// +// } +// if (!result) { +// throw new Exception("Cannot connect to the remote server!"); +// } +// } +// +// @Override +// public boolean disconnect() { +// MessageSendExecutor.getInstance().stop(); +// return true; +// } +// +// @Override +// public FileOperator getFileOperator() throws Exception { +// +// return MessageSendExecutor.getInstance().execute(FileOperator.class); +// } +// +// @Override +// public CommonOperator getCommonOperator() throws Exception { +// return MessageSendExecutor.getInstance().execute(CommonOperator.class); +// } +// +// @Override +// public OrganizationOperator getOrganizationOperator() throws Exception { +// return MessageSendExecutor.getInstance().execute(OrganizationOperator.class); +// } +// +// @Override +// public String getPath() { +// return config.getPath(); +// } +// +// @Override +// public String getUser() { +// return config.getUsername(); +// } +// +// public String getPassword() { +// return config.getPassword(); +// } +// +// @Override +// public String getUserID() { +// return EnvContext.currentToken(); +// } +// +// @Override +// public boolean isLocalEnv() { +// return false; +// } +// +// /** +// * execute method之后,取返回的 InputStream +// */ +// private InputStream filterInputStream(InputStream in) throws Exception { +// if (in == null) { +// return null; +// } +// ByteArrayOutputStream out = new ByteArrayOutputStream(); +// try { +// IOUtils.copyBinaryTo(in, out); +// // 看一下传过来的byte[]是不是DesignProcessor.INVALID,如果是的话,就抛Exception +// byte[] bytes = out.toByteArray(); +// // carl:格式一致传中文 +// String message = new String(bytes, EncodeConstants.ENCODING_UTF_8); +// if (ComparatorUtils.equals(message, RemoteDeziConstants.NO_SUCH_RESOURCE)) { +// return null; +// } else if (ComparatorUtils.equals(message, RemoteDeziConstants.INVALID_USER)) { +// throw new EnvException(RemoteDeziConstants.INVALID_USER); +// } else if (ComparatorUtils.equals(message, RemoteDeziConstants.FILE_LOCKED)) { +// JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Remote_File_is_Locked")); +// return null; +// } +// return new ByteArrayInputStream(bytes); +// } finally { +// synchronized (this) { +// in.close(); +// out.close(); +// } +// } +// } +// +// +// /** +// * nameValuePairs,这个参数要接着this.path,拼成一个URL,否则服务器端req.getParameter是无法得到的 +// * +// * @param bytes 数据 +// * @return 是否成功提交 +// * @throws Exception 异常 +// */ +// private boolean postBytes2Server(byte[] bytes, HashMap para) throws Exception { +// filterInputStream(RemoteEnvUtils.simulateRPCByHttpPost(bytes, para, false, this)); +// return true; +// } +// +// /** +// * 把InputStream转成一段String +// * +// * @param in InputStream输入流 +// * @return 转换后的字符串 +// */ +// private static String stream2String(InputStream in) { +// if (in == null) { +// return null; +// } +// String result = null; +// try { +// result = CommonIOUtils.inputStream2String(in, EncodeConstants.ENCODING_UTF_8); +// } catch (UnsupportedEncodingException e) { +// FineLoggerFactory.getLogger().error(e.getMessage(), e); +// } +// return result; +// } +// +// /** +// * 测试连接服务器 +// * +// * @return 测试连接成功返回true +// * @throws Exception 异常 +// */ +// private boolean testServerConnection() throws Exception { +// return testConnection(true, true, DesignerContext.getDesignerFrame()); +// } +// +// /** +// * 测试当前配置是否正确 +// * +// * @return 链接是否成功 +// * @throws Exception 异常 +// */ +// @Override +// public boolean testServerConnectionWithOutShowMessagePane() throws Exception { +// return testConnection(false, true, DesignerContext.getDesignerFrame()); +// } +// +// /** +// * 主要用于在环境配置面板中的测试连接按钮时,不要注册进远程环境 +// * +// * @param messageParentPane 弹框的依赖的面板 +// * @return 是否测试连接成功 +// * @throws Exception 异常 +// */ +// public boolean testConnectionWithOutRegisteServer(Component messageParentPane) throws Exception { +// return testConnection(true, false, messageParentPane); +// } +// +// +// private boolean testConnection(boolean needMessage, boolean isRegisteServer, Component parentComponent) throws Exception { +// checkArgument(parentComponent instanceof Component, "parentComponent should be a java.awt.component"); +// Component component = parentComponent; +// String url = String.format("%s/connection", EnvConstants.toDecisionPath(getPath())); +// ImmutableMap params = ImmutableMap.of( +// "version", (Object) ProductConstants.DESIGNER_VERSION +// ); +// ImmutableMap headers = ImmutableMap.of( +// EnvConstants.USERNAME, getUser(), +// EnvConstants.PWD, getPassword()); +// String res = HttpToolbox.post(url, params, headers); +// if (Strings.isNullOrEmpty(res)) { +// if (needMessage) { +// JOptionPane.showMessageDialog(component, Inter.getLocText("Datasource-Connection_failed")); +// } +// return false; +// } else if (ComparatorUtils.equals(res, "true")) { +// return true; +// } else { +// if (ComparatorUtils.equals(res, EnvConstants.AUTH_ERROR)) { +// JOptionPane.showMessageDialog(component, +// Inter.getLocText(new String[]{"Datasource-Connection_failed", "Registration-User_Name", "Password", "Error"}, new String[]{",", "", "", "!"}) +// , Inter.getLocText("FR-Server-All_Error"), JOptionPane.ERROR_MESSAGE); +// return false; +// } else { +// if (ComparatorUtils.equals(res, EnvConstants.WAR_ERROR)) { +// if (needMessage) { +// JOptionPane.showMessageDialog(component, Inter.getLocText(new String[]{"Datasource-Connection_failed", "NS-war-remote"}, new String[]{",", "!"})); +// } else { +// FineLoggerFactory.getLogger().info(Inter.getLocText(new String[]{"Datasource-Connection_failed", "NS-war-remote"}, new String[]{",", "!"})); +// } +// return false; +// } else { +// if (needMessage) { +// JOptionPane.showMessageDialog(component, Inter.getLocText("Datasource-Connection_failed")); +// } else { +// FineLoggerFactory.getLogger().info(Inter.getLocText(new String[]{"Datasource-Connection_failed", "Version-does-not-support"}, new String[]{",", "!"})); +// } +// return false; +// } +// } +// } +// } +// +// +// private void refreshHttpSProperty() { +// if (getPath().startsWith(HTTPS_PREFIX) && System.getProperty(CERT_KEY) == null) { +// DesignerEnvManager envManager = DesignerEnvManager.getEnvManager(); +// System.setProperty(CERT_KEY, envManager.getCertificatePath()); +// System.setProperty(PWD_KEY, envManager.getCertificatePass()); +// } +// } +// +// +// /** +// * 心跳访问,用来更新当前用户的访问时间 +// * +// * @throws Exception e +// */ +// +// public class Bytes2ServerOutputStream extends OutputStream { +// private ByteArrayOutputStream out = new ByteArrayOutputStream(); +// private HashMap nameValuePairs; +// +// public Bytes2ServerOutputStream(HashMap nameValuePairs) { +// this.nameValuePairs = nameValuePairs; +// } +// +// public HashMap getNameValuePairs() { +// return nameValuePairs; +// } +// +// public ByteArrayOutputStream getOut() { +// return out; +// } +// +// public OutputStream getZipOutputStream() throws Exception { +// return IOUtils.toZipOut(out); +// } +// +// /** +// * post ro Server 提交到服务器 +// * +// * @return 是否提交成功 +// */ +// public boolean post2Server() { +// try { +// return postBytes2Server(out.toByteArray(), nameValuePairs); +// } catch (Exception e) { +// FineLoggerFactory.getLogger().error(e.getMessage(), e); +// return false; +// } +// } +// +// /** +// * 刷新数出流,并提交 +// * +// * @throws IOException e +// */ +// @Override +// public void flush() throws IOException { +// super.flush(); +// post2Server(); +// } +// +// /** +// * 将指定字节写入输入流数组 +// * +// * @param b 写入的字节 +// */ +// @Override +// public void write(int b) { +// out.write(b); +// +// } +// } +// +// @Override +// public boolean updateAuthorities(DesignAuthority[] authorities) { +// refreshHttpSProperty(); +// String res = null; +// try { +// InputStream inputStream = RemoteEnvUtils.updateAuthorities(authorities, this); +// inputStream = filterInputStream(inputStream); +// res = IOUtils.inputStream2String(inputStream, EncodeConstants.ENCODING_UTF_8); +// } catch (Exception e) { +// FineLoggerFactory.getLogger().error(e.getMessage()); +// } +// return StringUtils.isNotEmpty(res) && Boolean.valueOf(res); +// } +// +// @Override +// public DesignAuthority[] getAuthorities() { +// refreshHttpSProperty(); +// DesignAuthority[] authorities = new DesignAuthority[0]; +// try { +// InputStream inputStream = RemoteEnvUtils.getAuthorities(this); +// inputStream = filterInputStream(inputStream); +// authorities = AuthorityXMLUtils.readDesignAuthoritiesXML(inputStream); +// return authorities; +// } catch (Exception e) { +// FineLoggerFactory.getLogger().error(e.getMessage()); +// } +// return authorities; +// } +// +// /** +// * 远程设计器设计时,假如开了权限就不可预览了。这边放一个全局的map来开后门 +// * +// * @param key 键值 +// * @param value 值 +// * @return 如果写入成功,返回true +// * @throws Exception e +// */ +// public boolean writePrivilegeMap(String key, String value) throws Exception { +// refreshHttpSProperty(); +// HashMap para = new HashMap<>(); +// para.put("op", "fr_remote_design"); +// para.put("cmd", "write_privilege_map"); +// para.put("current_user", getUser()); +// para.put("current_password", getPassword()); +// para.put("key", key); +// para.put("value", value); +// +// //jim :加上user,远程设计点击预览时传递用户角色信息 +// InputStream input = filterInputStream( +// RemoteEnvUtils.simulateRPCByHttpGet(para, false, this) +// ); +// +// if (input == null) { +// return false; +// } +// +// return Boolean.valueOf(IOUtils.inputStream2String(input, EncodeConstants.ENCODING_UTF_8)); +// } +// +// +// /** +// * nameValuePairs,这个参数要接着this.path,拼成一个URL,否则服务器端req.getParameter是无法得到的 +// * +// * @param bytes 数据 +// * @param para 参数 +// * @return 从服务器端得到InputStream +// * @throws Exception 异常 +// */ +// public InputStream postBytes2ServerB(byte[] bytes, HashMap para) throws Exception { +// refreshHttpSProperty(); +// return filterInputStream(RemoteEnvUtils.simulateRPCByHttpPost(bytes, para, false, this)); +// } +// +// +// /** +// * 读取路径下的svg文件 +// * +// * @param path 制定路径,是基于报表目录下resource文件夹路径 +// * @return 读到的文件 +// */ +// @Override +// public String[] readPathSvgFiles(String path) { +// refreshHttpSProperty(); +// String cataloguePath = StableUtils.pathJoin(CacheManager.getProviderInstance().getCacheDirectory().getPath(), SvgProvider.SERVER, path); +// +// ArrayList fileArray = new ArrayList<>(); +// try { +// HashMap para = new HashMap<>(); +// para.put("op", "fr_remote_design"); +// para.put("cmd", "design_read_svgfile"); +// para.put("resourcePath", path); +// para.put("current_uid", this.getUserID()); +// para.put("currentUsername", this.getUser()); +// +// InputStream input = filterInputStream( +// RemoteEnvUtils.simulateRPCByHttpGet(para, false, this) +// ); +// JSONArray ja = new JSONArray(stream2String(input)); +// for (int i = 0; i < ja.length(); i++) { +// JSONObject jsonObject = (JSONObject) ja.get(i); +// String svgFileName = (String) jsonObject.get("svgfileName"); +// String svgFileContent = (String) jsonObject.get("svgfileContent"); +// +// String file = StableUtils.pathJoin(cataloguePath, svgFileName); +// InputStream in = new ByteArrayInputStream(svgFileContent.getBytes(EncodeConstants.ENCODING_UTF_8)); +// ResourceIOUtils.write(file, in); +// fileArray.add(file); +// } +// } catch (Exception e) { +// FineLoggerFactory.getLogger().error(e.getMessage()); +// } +// +// return fileArray.toArray(new String[0]); +// } +// +// +// /** +// * 写svg文件 +// * +// * @param svgFile svg文件 +// * @return 是否写入成功 +// * @throws Exception 异常 +// */ +// @Override +// public boolean writeSvgFile(SvgProvider svgFile) throws Exception { +// testServerConnection(); +// +// HashMap para = new HashMap<>(); +// para.put("op", "svgrelate"); +// para.put("cmd", "design_save_svg"); +// para.put("filePath", svgFile.getFilePath()); +// para.put("current_uid", this.getUserID()); +// para.put("currentUsername", this.getUser()); +// +// // 通过ByteArrayOutputStream将svg写成字节流 +// Bytes2ServerOutputStream out = new Bytes2ServerOutputStream(para); +// OutputStreamWriter outWriter = new OutputStreamWriter(out, "UTF-8"); +// StreamResult result = new StreamResult(outWriter); +// +// Source source = new DOMSource(svgFile.getSvgDocument()); +// try { +// Transformer xformer = TransformerFactory.newInstance().newTransformer(); +// try { +// xformer.transform(source, result); +// } catch (TransformerException ex) { +// FineLoggerFactory.getLogger().error(ex.getMessage()); +// } +// +// } catch (TransformerConfigurationException ex) { +// FineLoggerFactory.getLogger().error(ex.getMessage()); +// return false; +// } +// +// try { +// String res = stream2String(filterInputStream( +// RemoteEnvUtils.simulateRPCByHttpPost(out.getOut().toByteArray(), out.nameValuePairs, false, this) +// )); +// if (StringUtils.isNotEmpty(res)) { +// JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Already_exist") + res); +// return false; +// } +// } catch (Exception e) { +// FineLoggerFactory.getLogger().error(e.getMessage()); +// return false; +// } +// +// return true; +// } +// +// /** +// * 写文件 +// * +// * @param beanPath 文件名 +// * @param prefix 当前Env下得工程分类,如reportlets,lib等 +// * @return OutputStream 输出流 +// */ +// @Override +// public OutputStream writeBean(String beanPath, String prefix) { +// HashMap para = new HashMap<>(); +// para.put("op", "fs_remote_design"); +// para.put("cmd", "design_save_report"); +// para.put(RemoteDeziConstants.PREFXI, prefix); +// para.put(RemoteDeziConstants.TEMPLATE_PATH, beanPath); +// +// return new Bytes2ServerOutputStream(para); +// } +// +// /** +// * 返回模板文件路径 +// */ +// @Override +// public String getWebReportPath() { +// +// return StableUtils.pathJoin(getPath(), getAppName()); +// } +// +// public String[] getProcedureColumns(StoreProcedure storeProcedure, Map parameterMap) throws Exception { +// refreshHttpSProperty(); +// String[] columns; +// HashMap para = new HashMap<>(); +// para.put("op", "fr_remote_design"); +// para.put("cmd", "list_sp"); +// try { +// InputStream input = filterInputStream( +// RemoteEnvUtils.simulateRPCByHttpGet(para, false, this) +// ); +// +// if (input == null) { +// return ArrayUtils.EMPTY_STRING_ARRAY; +// } +// +// columns = DavXMLUtils.readXMLSPColumns(input); +// return columns; +// } catch (Exception e) { +// FineLoggerFactory.getLogger().error(e.getMessage()); +// } +// +// return new String[0]; +// } +// +// public String[] getProcedureColumns(String name) throws Exception { +// refreshHttpSProperty(); +// String[] columns; +// HashMap para = new HashMap<>(); +// para.put("op", "fr_remote_design"); +// para.put("cmd", "list_sp_columns_name"); +// para.put("name", name); +// try { +// InputStream input = filterInputStream( +// RemoteEnvUtils.simulateRPCByHttpGet(para, false, this) +// ); +// if (input == null) { +// return ArrayUtils.EMPTY_STRING_ARRAY; +// } +// columns = DavXMLUtils.readXMLSPColumns(input); +// return columns; +// } catch (Exception e) { +// FineLoggerFactory.getLogger().error(e.getMessage()); +// } +// return new String[0]; +// +// } +// +// @Override +// public String[] getSupportedTypes() { +// return FILE_TYPE; +// } +// +// /** +// * 获取当前env的build文件路径 +// */ +// @Override +// public String getBuildFilePath() { +// return StringUtils.isEmpty(buildFilePath) ? ResourceConstants.BUILD_PATH : buildFilePath; +// } +// +// /** +// * 设置当前env的build文件路径 +// */ +// @Override +// public void setBuildFilePath(String buildFilePath) { +// this.buildFilePath = buildFilePath; +// } +// +// @Override +// public String[] loadREUFile() { +// refreshHttpSProperty(); +// ResourceIOUtils.delete(StableUtils.pathJoin( +// CacheManager.getProviderInstance().getCacheDirectory().getAbsolutePath(), +// ShareConstants.DIR_SHARE_CACHE)); +// +// String zipFilePath = null; +// try { +// HashMap para = new HashMap<>(); +// para.put("op", "fr_remote_design"); +// para.put("cmd", "design_read_reufile"); +// para.put("current_uid", this.getUserID()); +// para.put("currentUsername", this.getUser()); +// +// //拿到服务端传过来的整个共享文件夹的压缩文件的文件流 +// InputStream input = RemoteEnvUtils.simulateRPCByHttpGet(para, false, this); +// +// zipFilePath = StableUtils.pathJoin(CacheManager.getProviderInstance().getCacheDirectory().getAbsolutePath(), "share.zip"); +// String cacheDir = StableUtils.pathJoin(CacheManager.getProviderInstance().getCacheDirectory().getAbsolutePath(), ShareConstants.DIR_SHARE_CACHE); +// +// ResourceIOUtils.write(zipFilePath, input); +// ResourceIOUtils.unzip(zipFilePath, cacheDir, EncodeConstants.ENCODING_GBK); +// +// +// return ResourceIOUtils.listWithFullPath(cacheDir, new Filter() { +// @Override +// public boolean accept(String s) { +// return s.endsWith(ProjectConstants.REU); +// } +// }); +// +// } catch (Exception e) { +// FineLoggerFactory.getLogger().error(e.getMessage()); +// } finally { +// +// if (zipFilePath != null) { +// ResourceIOUtils.delete(zipFilePath); +// } +// } +// +// return new String[0]; +// } +// +// @Override +// public boolean installREUFile(File reuFile) { +// refreshHttpSProperty(); +// if (reuFile == null) { +// return false; +// } +// File tempFile = new File(CacheManager.getProviderInstance().getCacheDirectory(), "temp_remote"); +// IOUtils.unzip(reuFile, tempFile.getAbsolutePath()); +// String shareXMLName = StableUtils.pathJoin(tempFile.getAbsolutePath(), ShareConstants.NAME_XML_MODULE); +// String helpXMLName = StableUtils.pathJoin(tempFile.getAbsolutePath(), ShareConstants.NAME_XML_HELP); +// try { +// HashMap para = new HashMap<>(); +// para.put("op", "fr_remote_design"); +// para.put("cmd", "design_install_reufile"); +// para.put("current_uid", this.getUserID()); +// para.put("currentUsername", this.getUser()); +// para.put("reuFileName", reuFile.getName()); +// +// InputStream input = filterInputStream( +// RemoteEnvUtils.simulateRPCByHttpPost( +// IOUtils.inputStream2Bytes( +// new FileInputStream(new File(shareXMLName)) +// ) +// , para, +// false, +// this) +// ); +// para.put("isComplete", "true"); +// InputStream input1 = filterInputStream(RemoteEnvUtils.simulateRPCByHttpPost( +// IOUtils.inputStream2Bytes( +// new FileInputStream(new File(helpXMLName)) +// ) +// , para, +// false, +// this)); +// return ComparatorUtils.equals(stream2String(input), "true") && ComparatorUtils.equals(stream2String(input1), "true"); +// } catch (Exception e) { +// return false; +// } +// } +// +// @Override +// public boolean removeREUFilesByName(String fileName) { +// refreshHttpSProperty(); +// if (StringUtils.isEmpty(fileName)) { +// return true; +// } +// try { +// HashMap para = new HashMap<>(); +// para.put("op", "fr_remote_design"); +// para.put("cmd", "design_remove_reufile"); +// para.put("current_uid", this.getUserID()); +// para.put("currentUsername", this.getUser()); +// para.put("reuFileName", fileName); +// +// InputStream input = filterInputStream( +// RemoteEnvUtils.simulateRPCByHttpGet(para, false, this) +// ); +// return ComparatorUtils.equals(stream2String(input), "true"); +// } catch (Exception e) { +// return false; +// } +// } +// +// @Override +// public String getSharePath() { +// refreshHttpSProperty(); +// try { +// HashMap para = new HashMap<>(); +// para.put("op", "fr_remote_design"); +// para.put("cmd", "design_get_share_path"); +// para.put("current_uid", this.getUserID()); +// para.put("currentUsername", this.getUser()); +// +// InputStream input = filterInputStream( +// RemoteEnvUtils.simulateRPCByHttpGet(para, false, this) +// ); +// return stream2String(input); +// } catch (Exception e) { +// return StringUtils.EMPTY; +// } +// } +// +// +// @Override +// public boolean hasPluginServiceStarted(String key) { +// +// return true; +// } +// +//} \ No newline at end of file diff --git a/designer-base/src/com/fr/env/RemoteEnvPane.java b/designer-base/src/com/fr/env/RemoteEnvPane.java index 12571369f3..c6c26d6a23 100644 --- a/designer-base/src/com/fr/env/RemoteEnvPane.java +++ b/designer-base/src/com/fr/env/RemoteEnvPane.java @@ -1,11 +1,11 @@ package com.fr.env; import com.fr.base.FRContext; -import com.fr.design.env.RemoteEnvConfig; import com.fr.design.DesignerEnvManager; import com.fr.design.beans.BasicBeanPane; import com.fr.design.border.UITitledBorder; import com.fr.design.dialog.InformationWarnPane; +import com.fr.design.env.DesignerWorkspaceInfo; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.ilable.UILabel; @@ -19,24 +19,11 @@ import com.fr.general.Inter; import com.fr.stable.ProductConstants; import com.fr.stable.StringUtils; -import javax.swing.BorderFactory; -import javax.swing.JFileChooser; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JTextPane; -import javax.swing.SwingConstants; -import javax.swing.SwingUtilities; -import javax.swing.ToolTipManager; -import javax.swing.UIManager; +import javax.swing.*; import javax.swing.border.EmptyBorder; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Component; -import java.awt.Dimension; -import java.awt.FlowLayout; -import java.awt.Toolkit; +import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyEvent; @@ -50,7 +37,7 @@ import static com.fr.design.layout.TableLayout.PREFERRED; /** * @author yaohwu */ -public class RemoteEnvPane extends BasicBeanPane { +public class RemoteEnvPane extends BasicBeanPane { private static final Color TIPS_FONT_COLOR = new Color(0x8f8f92); @@ -252,7 +239,7 @@ public class RemoteEnvPane extends BasicBeanPane { } @Override - public void populateBean(RemoteEnvConfig ob) { + public void populateBean(DesignerWorkspaceInfo ob) { if (StringUtils.isEmpty(ob.getPath())) { remoteEnvURL = RemoteEnvURL.createDefaultURL(); @@ -266,21 +253,21 @@ public class RemoteEnvPane extends BasicBeanPane { DesignerEnvManager.getEnvManager().setHttps(remoteEnvURL.getHttps()); fileChooserButton.setEnabled(remoteEnvURL.getHttps()); updateHttpsConfigPanel(); - - String username = EnvConfigUtils.getUsername(ob); - String pwd = EnvConfigUtils.getPassword(ob); + + String username = ob.getConnection().getUserName(); + String pwd = ob.getConnection().getPassword(); this.usernameInput.setText(username == null ? StringUtils.EMPTY : pwd); - this.passwordInput.setText(ob.getPassword() == null ? StringUtils.EMPTY : ob.getPassword()); + this.passwordInput.setText(pwd == null ? StringUtils.EMPTY : "******"); } @Override - public RemoteEnvConfig updateBean() { + public DesignerWorkspaceInfo updateBean() { String path = remoteEnvURL.getURL(); String user = this.usernameInput.getText(); String password = new String(this.passwordInput.getPassword()); +// return DesignerWorkspaceInfo.createRemote(); return null; - //return new RemoteEnvConfig(path, user, password); } diff --git a/designer-base/src/com/fr/file/FileNodeFILE.java b/designer-base/src/com/fr/file/FileNodeFILE.java index 21b7963789..7fead4ce08 100644 --- a/designer-base/src/com/fr/file/FileNodeFILE.java +++ b/designer-base/src/com/fr/file/FileNodeFILE.java @@ -240,7 +240,7 @@ public class FileNodeFILE implements FILE { } try { - return FRContext.getCurrentEnv().getFileOperator().isExists(node.getEnvPath()); + return WorkContext.getWorkResource().exist(node.getEnvPath()); } catch (Exception e) { FRContext.getLogger().error(e.getMessage(), e); return false; diff --git a/designer-chart/src/com/fr/design/chart/series/PlotSeries/MapGroupExtensionPane.java b/designer-chart/src/com/fr/design/chart/series/PlotSeries/MapGroupExtensionPane.java index 409131847c..6c054361fa 100644 --- a/designer-chart/src/com/fr/design/chart/series/PlotSeries/MapGroupExtensionPane.java +++ b/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.DesignerFrame; import com.fr.general.ComparatorUtils; -import com.fr.log.FineLoggerFactory; import com.fr.general.Inter; +import com.fr.log.FineLoggerFactory; import com.fr.stable.CoreConstants; import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; import com.fr.stable.SvgProvider; +import com.fr.workspace.WorkContext; import javax.swing.*; import javax.swing.event.ListSelectionEvent; @@ -340,12 +341,12 @@ public class MapGroupExtensionPane extends BasicPane implements UIObserver { return; } try{//提醒名字已存在 - if(FRContext.getCurrentEnv().getFileOperator().isExists(StableUtils.pathJoin( + if (WorkContext.getWorkResource().exist(StableUtils.pathJoin( MapSvgXMLHelper.relativeDefaultMapPath(),newName+SvgProvider.EXTENSION))){ showRenameWaring(newName); return; } - if(FRContext.getCurrentEnv().getFileOperator().isExists(StableUtils.pathJoin( + if (WorkContext.getWorkResource().exist(StableUtils.pathJoin( MapSvgXMLHelper.relativeCustomMapPath(), newName + SvgProvider.EXTENSION))){ showRenameWaring(newName); return; @@ -361,9 +362,9 @@ public class MapGroupExtensionPane extends BasicPane implements UIObserver { groupExtensionPane.setValueAtCurrentSelectIndex(newName); fireStateChange(); saveMapInfo(newName); - FRContext.getCurrentEnv().getFileOperator().delete( + WorkContext.getWorkResource().delete( StableUtils.pathJoin(MapSvgXMLHelper.relativeDefaultMapPath(),oldName+SvgProvider.EXTENSION)); - FRContext.getCurrentEnv().getFileOperator().delete( + WorkContext.getWorkResource().delete( StableUtils.pathJoin(MapSvgXMLHelper.relativeCustomMapPath(),oldName+SvgProvider.EXTENSION)); refresh(); }catch (Exception exp){ diff --git a/designer-realize/src/com/fr/design/mainframe/alphafine/search/manager/impl/FileSearchManager.java b/designer-realize/src/com/fr/design/mainframe/alphafine/search/manager/impl/FileSearchManager.java index 0df9529ca4..e1deba46a8 100644 --- a/designer-realize/src/com/fr/design/mainframe/alphafine/search/manager/impl/FileSearchManager.java +++ b/designer-realize/src/com/fr/design/mainframe/alphafine/search/manager/impl/FileSearchManager.java @@ -18,6 +18,7 @@ import com.fr.log.FineLoggerFactory; import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; import com.fr.stable.project.ProjectConstants; +import com.fr.workspace.WorkContext; import java.io.BufferedReader; import java.io.ByteArrayInputStream; @@ -151,7 +152,7 @@ public class FileSearchManager implements AlphaFineSearchProvider { */ private void searchFileContent(Env env, String searchText, FileNode node, boolean isAlreadyContain, boolean needMore) { 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"); BufferedReader reader = new BufferedReader(isr); String line; diff --git a/designer-realize/src/com/fr/design/mainframe/errorinfo/ErrorInfoLogAppender.java b/designer-realize/src/com/fr/design/mainframe/errorinfo/ErrorInfoLogAppender.java index 66fb704d9c..51bba7487c 100644 --- a/designer-realize/src/com/fr/design/mainframe/errorinfo/ErrorInfoLogAppender.java +++ b/designer-realize/src/com/fr/design/mainframe/errorinfo/ErrorInfoLogAppender.java @@ -1,6 +1,5 @@ package com.fr.design.mainframe.errorinfo; -import com.fr.base.FRContext; import com.fr.base.io.IOFile; import com.fr.base.io.XMLReadHelper; 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.web.core.SessionDealWith; import com.fr.web.core.SessionIDInfor; +import com.fr.workspace.WorkContext; import java.io.ByteArrayInputStream; import java.io.InputStream; @@ -134,7 +134,7 @@ public class ErrorInfoLogAppender extends AppenderSkeleton { } }; 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(); } catch (Exception ignore) { } diff --git a/designer-realize/src/com/fr/start/EnvSwitcher.java b/designer-realize/src/com/fr/start/EnvSwitcher.java index 6fbffcc5a6..8e31225013 100644 --- a/designer-realize/src/com/fr/start/EnvSwitcher.java +++ b/designer-realize/src/com/fr/start/EnvSwitcher.java @@ -16,7 +16,7 @@ public class EnvSwitcher { try { String current = DesignerEnvManager.getEnvManager().getCurEnvName(); - Workspace workspace = DesignerWorkspaceGenerator.generate(DesignerEnvManager.getEnvManager().getEnv(current)); + Workspace workspace = DesignerWorkspaceGenerator.generate(DesignerEnvManager.getEnvManager().getWorkspaceInfo(current)); WorkContext.switchTo(workspace); } catch (Exception e) { TemplatePane.getInstance().dealEvnExceptionWhenStartDesigner(); From 285c8d764cdc1b5614c2be1954fb364683af83d1 Mon Sep 17 00:00:00 2001 From: ju Date: Fri, 15 Jun 2018 14:38:08 +0800 Subject: [PATCH 04/20] f --- .../src/com/fr/design/DesignState.java | 9 +- .../datapane/preview/PreviewTableModel.java | 12 +- .../wrapper/StoreProcedureNameWrapper.java | 4 +- .../fr/design/env/DesignerWorkspaceInfo.java | 15 + .../fr/design/mainframe/DesignerFrame.java | 6 +- .../loghandler/socketio/DesignerSocketIO.java | 3 - .../mainframe/toolbar/ToolBarMenuDock.java | 21 +- .../fr/design/remote/ui/UserManagerPane.java | 4 +- .../src/com/fr/design/utils/DesignUtils.java | 8 +- .../src/com/fr/env/RemoteEnvPane.java | 7 +- .../src/com/fr/env/RemoteEnvPane2.java | 39 +- .../src/com/fr/env/RemoteEnvUtils.java | 334 +++++++++--------- .../src/com/fr/start/ServerStarter.java | 6 +- .../com/fr/design/mainframe/JWorkBook.java | 4 +- .../alphafine/cell/model/PluginModel.java | 8 +- .../freeze/RepeatAndFreezeSettingPane.java | 20 +- .../fr/start/module/DesignerEnvProvider.java | 322 ++++++++--------- .../com/fr/start/module/DesignerStartup.java | 14 +- 18 files changed, 414 insertions(+), 422 deletions(-) diff --git a/designer-base/src/com/fr/design/DesignState.java b/designer-base/src/com/fr/design/DesignState.java index 832a2e63d0..4bc3de847a 100644 --- a/designer-base/src/com/fr/design/DesignState.java +++ b/designer-base/src/com/fr/design/DesignState.java @@ -1,10 +1,8 @@ package com.fr.design; 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.env.RemoteEnv; +import com.fr.workspace.WorkContext; /** * Created by IntelliJ IDEA. @@ -41,11 +39,10 @@ public class DesignState { public DesignState(ToolBarMenuDockPlus plus) { designState = plus.getMenuState(); - Env env = FRContext.getCurrentEnv(); - if (env != null && env instanceof RemoteEnv) { + if (WorkContext.getCurrent().isLocal()) { designState += REMOTE; } - isRoot = env != null && env.isRoot(); +// isRoot = env != null && env.isRoot(); isAuthority = BaseUtils.isAuthorityEditing(); } diff --git a/designer-base/src/com/fr/design/data/datapane/preview/PreviewTableModel.java b/designer-base/src/com/fr/design/data/datapane/preview/PreviewTableModel.java index 551638ffd8..8ffe37659f 100644 --- a/designer-base/src/com/fr/design/data/datapane/preview/PreviewTableModel.java +++ b/designer-base/src/com/fr/design/data/datapane/preview/PreviewTableModel.java @@ -1,18 +1,18 @@ package com.fr.design.data.datapane.preview; -import javax.swing.table.AbstractTableModel; - import com.fr.base.FRContext; +import com.fr.cache.list.IntList; import com.fr.data.AbstractDataModel; import com.fr.data.impl.EmbeddedTableData.EmbeddedTDDataModel; 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.data.DataModel; import com.fr.general.data.TableDataException; -import com.fr.cache.list.IntList; import com.fr.stable.StringUtils; -import com.fr.design.utils.DesignUtils; +import com.fr.workspace.WorkContext; + +import javax.swing.table.AbstractTableModel; /** * 这个TableModel主要是预览数据的. 字段TableData必须转化为内置的 @@ -188,7 +188,7 @@ public class PreviewTableModel extends AbstractTableModel { s = "?"; } else if (o instanceof 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); if (Number.class.isAssignableFrom(clzz)) { s = Inter.getLocText("FR-Designer_Number");//bigdecimal diff --git a/designer-base/src/com/fr/design/data/tabledata/wrapper/StoreProcedureNameWrapper.java b/designer-base/src/com/fr/design/data/tabledata/wrapper/StoreProcedureNameWrapper.java index 29037fad2c..26b58cd351 100644 --- a/designer-base/src/com/fr/design/data/tabledata/wrapper/StoreProcedureNameWrapper.java +++ b/designer-base/src/com/fr/design/data/tabledata/wrapper/StoreProcedureNameWrapper.java @@ -9,8 +9,8 @@ import com.fr.data.impl.storeproc.StoreProcedure; import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.datapane.preview.PreviewTablePane; import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode; -import com.fr.env.RemoteEnv; import com.fr.log.FineLoggerFactory; +import com.fr.workspace.WorkContext; import javax.swing.*; import java.util.ArrayList; @@ -95,7 +95,7 @@ public final class StoreProcedureNameWrapper implements TableDataWrapper { } columnNameList = new ArrayList(); Env env = FRContext.getCurrentEnv(); - if (env instanceof RemoteEnv) { + if (!WorkContext.getCurrent().isLocal()) { try { createStore(false); columnNameList = Arrays.asList(procedureDataModel.getColumnName()); diff --git a/designer-base/src/com/fr/design/env/DesignerWorkspaceInfo.java b/designer-base/src/com/fr/design/env/DesignerWorkspaceInfo.java index 6854e007ed..c230602bd2 100644 --- a/designer-base/src/com/fr/design/env/DesignerWorkspaceInfo.java +++ b/designer-base/src/com/fr/design/env/DesignerWorkspaceInfo.java @@ -59,6 +59,21 @@ public class DesignerWorkspaceInfo implements XMLable { return connection; } + public void setType(DesignerWorkspaceType type) { + + this.type = type; + } + + public void setPath(String path) { + + this.path = path; + } + + public void setConnection(WorkspaceConnection connection) { + + this.connection = connection; + } + @Override public void readXML(XMLableReader reader) { diff --git a/designer-base/src/com/fr/design/mainframe/DesignerFrame.java b/designer-base/src/com/fr/design/mainframe/DesignerFrame.java index 46ffed17bd..402603f9b5 100644 --- a/designer-base/src/com/fr/design/mainframe/DesignerFrame.java +++ b/designer-base/src/com/fr/design/mainframe/DesignerFrame.java @@ -5,7 +5,6 @@ package com.fr.design.mainframe; import com.fr.base.BaseUtils; import com.fr.base.FRContext; -import com.fr.base.env.EnvConfig; import com.fr.design.DesignModelAdapter; import com.fr.design.DesignState; import com.fr.design.DesignerEnvManager; @@ -14,6 +13,7 @@ import com.fr.design.actions.core.ActionFactory; import com.fr.design.constants.UIConstants; import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.datapane.TableDataTreePane; +import com.fr.design.env.DesignerWorkspaceInfo; import com.fr.design.event.DesignerOpenedListener; import com.fr.design.event.TargetModifiedEvent; import com.fr.design.event.TargetModifiedListener; @@ -650,9 +650,9 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta defaultTitleSB.append(" "); // james:标识登录的用户和登录的ENV String envName = DesignerEnvManager.getEnvManager().getCurEnvName(); - EnvConfig env = DesignerEnvManager.getEnvManager().getWorkspaceInfo(envName); + DesignerWorkspaceInfo env = DesignerEnvManager.getEnvManager().getWorkspaceInfo(envName); if (env != null) { - defaultTitleSB.append(env.getDescription(envName)); +// defaultTitleSB.append(env.getDescription(envName)); if (editingTemplate != null) { String path = editingTemplate.getEditingFILE().getPath(); if (!editingTemplate.getEditingFILE().exists()) { diff --git a/designer-base/src/com/fr/design/mainframe/loghandler/socketio/DesignerSocketIO.java b/designer-base/src/com/fr/design/mainframe/loghandler/socketio/DesignerSocketIO.java index f64f0dff3b..9051b0ac7e 100644 --- a/designer-base/src/com/fr/design/mainframe/loghandler/socketio/DesignerSocketIO.java +++ b/designer-base/src/com/fr/design/mainframe/loghandler/socketio/DesignerSocketIO.java @@ -2,10 +2,7 @@ package com.fr.design.mainframe.loghandler.socketio; import com.fr.base.Env; import com.fr.base.FRContext; -import com.fr.decision.webservice.utils.DecisionServiceConstants; -import com.fr.design.env.RemoteEnvConfig; import com.fr.design.mainframe.loghandler.DesignerLogHandler; -import com.fr.env.RemoteEnv; import com.fr.event.Event; import com.fr.event.EventDispatcher; import com.fr.event.Listener; diff --git a/designer-base/src/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java b/designer-base/src/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java index 21f7c3386a..35278c8ccf 100644 --- a/designer-base/src/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java +++ b/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.remote.action.RemoteDesignAuthorityManagerAction; import com.fr.design.utils.ThemeUtils; -import com.fr.env.RemoteEnv; import com.fr.general.ComparatorUtils; import com.fr.general.GeneralContext; import com.fr.general.Inter; @@ -60,19 +59,10 @@ import com.fr.plugin.observer.PluginEventListener; import com.fr.plugin.observer.PluginEventType; import com.fr.stable.ArrayUtils; import com.fr.stable.StringUtils; +import com.fr.workspace.WorkContext; -import javax.swing.Icon; -import javax.swing.JComponent; -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 javax.swing.*; +import java.awt.*; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -447,8 +437,9 @@ public abstract class ToolBarMenuDock { return FRContext.getCurrentEnv() != null && !FRContext.getCurrentEnv().isLocalEnv() && FRContext.getCurrentEnv().isRoot(); } - protected boolean shouldShowPlugin() { - return !(FRContext.getCurrentEnv() instanceof RemoteEnv) && FRContext.isChineseEnv(); + private boolean shouldShowPlugin() { + + return !(WorkContext.getCurrent().isLocal()) && FRContext.isChineseEnv(); } /** diff --git a/designer-base/src/com/fr/design/remote/ui/UserManagerPane.java b/designer-base/src/com/fr/design/remote/ui/UserManagerPane.java index ab53eeaa33..c247b109d4 100644 --- a/designer-base/src/com/fr/design/remote/ui/UserManagerPane.java +++ b/designer-base/src/com/fr/design/remote/ui/UserManagerPane.java @@ -278,8 +278,8 @@ public class UserManagerPane extends BasicPane { @Override protected List doInBackground() { addingMembers.clear(); - String username = EnvConfigUtils.getUsername(EnvContext.currentEnv()); - addingMembers.addAll(EnvProxy.get(DecisionOperator.class).getMembers(username, keyword)); +// String username = EnvConfigUtils.getUsername(EnvContext.currentEnv()); +// addingMembers.addAll(EnvProxy.get(DecisionOperator.class).getMembers(username, keyword)); return addingMembers; } diff --git a/designer-base/src/com/fr/design/utils/DesignUtils.java b/designer-base/src/com/fr/design/utils/DesignUtils.java index 1cf12cb547..499f369371 100644 --- a/designer-base/src/com/fr/design/utils/DesignUtils.java +++ b/designer-base/src/com/fr/design/utils/DesignUtils.java @@ -27,6 +27,7 @@ import com.fr.stable.EncodeConstants; import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; import com.fr.start.ServerStarter; +import com.fr.workspace.WorkContext; import javax.swing.*; import java.awt.*; @@ -298,12 +299,13 @@ public class DesignUtils { } } String postfixOfUri = (segs.length > 0 ? "?" + StableUtils.join(segs, "&") : StringUtils.EMPTY); - - if (FRContext.getCurrentEnv() instanceof RemoteEnv) { + + if (!WorkContext.getCurrent().isLocal()) { try { if (Utils.isEmbeddedParameter(postfixOfUri)) { String time = Calendar.getInstance().getTime().toString().replaceAll(" ", ""); - boolean isUserPrivilege = ((RemoteEnv) FRContext.getCurrentEnv()).writePrivilegeMap(time, postfixOfUri); +// boolean isUserPrivilege = FRContext.getCurrentEnv()).writePrivilegeMap(time, postfixOfUri); + boolean isUserPrivilege = false; postfixOfUri = isUserPrivilege ? postfixOfUri + "&fr_check_url=" + time + "&id=" + FRContext.getCurrentEnv().getUserID() : postfixOfUri; } // 加参数给远程设计校验权限。 diff --git a/designer-base/src/com/fr/env/RemoteEnvPane.java b/designer-base/src/com/fr/env/RemoteEnvPane.java index c6c26d6a23..24fabb8dd5 100644 --- a/designer-base/src/com/fr/env/RemoteEnvPane.java +++ b/designer-base/src/com/fr/env/RemoteEnvPane.java @@ -257,7 +257,7 @@ public class RemoteEnvPane extends BasicBeanPane { String username = ob.getConnection().getUserName(); String pwd = ob.getConnection().getPassword(); this.usernameInput.setText(username == null ? StringUtils.EMPTY : pwd); - this.passwordInput.setText(pwd == null ? StringUtils.EMPTY : "******"); + this.passwordInput.setText(pwd == null ? StringUtils.EMPTY : pwd); } @Override @@ -459,14 +459,13 @@ public class RemoteEnvPane extends BasicBeanPane { private boolean testConnection() { String url = remoteEnvURL.getURL(); //RemoteEnv env = new RemoteEnv(url, usernameInput.getText(), new String(passwordInput.getPassword())); - RemoteEnv env = null; boolean connect = false; try { if (StringUtils.isNotEmpty(url)) { if (remoteEnvURL.getHttps()) { setHttpsParas(); } - connect = env.testConnectionWithOutRegisteServer(this); +// connect = env.testConnectionWithOutRegisteServer(this); } } catch (Exception e) { JOptionPane.showMessageDialog( @@ -479,7 +478,7 @@ public class RemoteEnvPane extends BasicBeanPane { } if (connect) { try { - String remoteVersion = env.getDesignerVersion(); + String remoteVersion = ""; 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") + "。"; diff --git a/designer-base/src/com/fr/env/RemoteEnvPane2.java b/designer-base/src/com/fr/env/RemoteEnvPane2.java index 6263969e0e..3b5ff423c8 100644 --- a/designer-base/src/com/fr/env/RemoteEnvPane2.java +++ b/designer-base/src/com/fr/env/RemoteEnvPane2.java @@ -1,8 +1,9 @@ package com.fr.env; -import com.fr.design.env.RemoteEnvConfig; import com.fr.design.beans.BasicBeanPane; import com.fr.design.border.UITitledBorder; +import com.fr.design.env.DesignerWorkspaceInfo; +import com.fr.design.env.DesignerWorkspaceType; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ipasswordfield.UIPassWordField; @@ -12,6 +13,8 @@ import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.general.Inter; +import com.fr.workspace.WorkContext; +import com.fr.workspace.connect.WorkspaceConnection; import javax.swing.*; import javax.swing.border.EmptyBorder; @@ -24,7 +27,7 @@ import java.awt.event.WindowEvent; /** * 远程环境设置界面,暂时命名为2,待做完功能直接替代掉老的RemoteEnvPane */ -public class RemoteEnvPane2 extends BasicBeanPane { +public class RemoteEnvPane2 extends BasicBeanPane { private UITextField hostTextField; private UIIntNumberField portTextField; @@ -88,8 +91,9 @@ public class RemoteEnvPane2 extends BasicBeanPane { @Override protected Void doInBackground() throws Exception { - final RemoteEnv remoteEnv = new RemoteEnv(updateBean()); - remoteEnv.connectOnce(); + + final DesignerWorkspaceInfo remoteEnv = updateBean(); + WorkContext.getConnector().testConnection(remoteEnv.getConnection()); return null; } @@ -161,25 +165,28 @@ public class RemoteEnvPane2 extends BasicBeanPane { } @Override - public void populateBean(RemoteEnvConfig config) { + public void populateBean(DesignerWorkspaceInfo config) { if (config == null) { return; } - hostTextField.setText(config.getHost()); - if (config.getPort() != 0) { - portTextField.setValue(config.getPort()); + WorkspaceConnection connection = config.getConnection(); + if (connection != null) { + hostTextField.setText(connection.getIp()); + if (connection.getPort() != 0) { + portTextField.setValue(connection.getPort()); + } + usernameTextField.setText(connection.getUserName()); + passwordTextField.setText(connection.getPassword()); } - usernameTextField.setText(config.getUsername()); - passwordTextField.setText(config.getPassword()); } @Override - public RemoteEnvConfig updateBean() { - RemoteEnvConfig config = new RemoteEnvConfig(); - config.setHost(hostTextField.getText()); - config.setPort((int) portTextField.getValue()); - config.setUsername(usernameTextField.getText()); - config.setPassword(passwordTextField.getText()); + public DesignerWorkspaceInfo updateBean() { + + DesignerWorkspaceInfo config = new DesignerWorkspaceInfo(); + WorkspaceConnection connection = new WorkspaceConnection(hostTextField.getText(), (int) portTextField.getValue(), usernameTextField.getText(), passwordTextField.getText()); + config.setConnection(connection); + config.setType(DesignerWorkspaceType.Remote); return config; } } diff --git a/designer-base/src/com/fr/env/RemoteEnvUtils.java b/designer-base/src/com/fr/env/RemoteEnvUtils.java index cf6b2d657e..13d251010c 100644 --- a/designer-base/src/com/fr/env/RemoteEnvUtils.java +++ b/designer-base/src/com/fr/env/RemoteEnvUtils.java @@ -1,167 +1,167 @@ -package com.fr.env; - -import com.fr.base.EnvException; -import com.fr.base.FRContext; -import com.fr.report.DesignAuthority; -import com.fr.report.util.AuthorityXMLUtils; -import com.fr.stable.EncodeConstants; -import com.fr.third.org.apache.commons.io.IOUtils; -import com.fr.third.org.apache.http.HttpResponse; -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.ResponseHandler; -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.entity.ContentType; -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.HttpClients; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.net.URLEncoder; -import java.util.Map; - -public class RemoteEnvUtils { - - private RemoteEnvUtils() { - } - - private static ResponseHandler responseHandler = new ResponseHandler() { - @Override - public InputStream handleResponse(HttpResponse response) throws IOException { - int statusCode = response.getStatusLine().getStatusCode(); - if (statusCode != HttpStatus.SC_OK) { - throw new ClientProtocolException("Method failed: " + response.getStatusLine().toString()); - } - InputStream in = response.getEntity().getContent(); - if (in == null) { - return null; - } - // 读取并返回 - ByteArrayOutputStream out = new ByteArrayOutputStream(); - IOUtils.copy(in, out); - return new ByteArrayInputStream(out.toByteArray()); - } - }; - - public static InputStream simulateRPCByHttpPost(byte[] bytes, Map parameters, boolean isSignIn, RemoteEnv env) throws EnvException { - String path = env.getPath(); - RequestBuilder builder = RequestBuilder.post(path); - - InputStream inputStream = null; - - for (Map.Entry entry : parameters.entrySet()) { - builder.addParameter(entry.getKey(), entry.getValue()); - } - if (!isSignIn) { - builder.addParameter("id", env.getUserID()); - } - InputStreamEntity reqEntity = new InputStreamEntity(new ByteArrayInputStream(bytes)); - - try (CloseableHttpClient httpClient = HttpClients.createSystem()) { - HttpUriRequest request = builder - .setEntity(reqEntity) - .build(); - inputStream = httpClient.execute(request, responseHandler); - } catch (IOException e) { - FRContext.getLogger().error(e.getMessage()); - } - return inputStream; - } - - public static InputStream simulateRPCByHttpPost(Map parameters, boolean isSignIn, RemoteEnv env) throws EnvException { - String path = env.getPath(); - RequestBuilder builder = RequestBuilder.post(path); - - InputStream inputStream = null; - - for (Map.Entry entry : parameters.entrySet()) { - builder.addParameter(entry.getKey(), entry.getValue()); - } - if (!isSignIn) { - builder.addParameter("id", env.getUserID()); - } - - try (CloseableHttpClient httpClient = HttpClients.createSystem()) { - HttpUriRequest request = builder - .build(); - inputStream = httpClient.execute(request, responseHandler); - } catch (IOException e) { - FRContext.getLogger().error(e.getMessage()); - } - return inputStream; - } - - public static InputStream simulateRPCByHttpGet(Map parameters, boolean isSignIn, RemoteEnv env) throws EnvException { - String path = env.getPath(); - RequestBuilder builder = RequestBuilder.get(path); - - InputStream inputStream = null; - - for (Map.Entry entry : parameters.entrySet()) { - builder.addParameter(entry.getKey(), entry.getValue()); - } - if (!isSignIn) { - builder.addParameter("id", env.getUserID()); - } - try (CloseableHttpClient httpClient = HttpClients.createSystem()) { - HttpUriRequest request = builder.build(); - inputStream = httpClient.execute(request, responseHandler); - - } catch (IOException e) { - FRContext.getLogger().error(e.getMessage()); - } - return inputStream; - } - - - public static InputStream updateAuthorities(DesignAuthority[] authorities, RemoteEnv env) { - String path = env.getPath(); - // 远程设计临时用户id - String userID = env.getUserID(); - InputStream inputStream = null; - - ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); - AuthorityXMLUtils.writeDesignAuthoritiesXML(authorities, outputStream); - InputStreamEntity reqEntity = new InputStreamEntity(new ByteArrayInputStream(outputStream.toByteArray()), ContentType.TEXT_XML); - - try (CloseableHttpClient httpClient = HttpClients.createSystem()) { - HttpUriRequest request = RequestBuilder.post(path) - .addParameter("id", userID) - .addParameter("op", "remote_design_authority") - .addParameter("cmd", "update_authorities") - .setEntity(reqEntity) - .build(); - inputStream = httpClient.execute(request, responseHandler); - } catch (IOException e) { - FRContext.getLogger().error(e.getMessage()); - } - - return inputStream; - - } - - public static InputStream getAuthorities(RemoteEnv env) throws EnvException { - String path = env.getPath(); - // 远程设计临时用户id - String userID = env.getUserID(); - InputStream inputStream = null; - - try (CloseableHttpClient httpClient = HttpClients.createSystem();) { - HttpUriRequest request = RequestBuilder.get(path) - .addParameter("id", userID) - .addParameter("op", "remote_design_authority") - .addParameter("cmd", "get_authorities") - .build(); - inputStream = httpClient.execute(request, responseHandler); - } catch (IOException e) { - FRContext.getLogger().error(e.getMessage()); - } - return inputStream; - } - - -} +//package com.fr.env; +// +//import com.fr.base.EnvException; +//import com.fr.base.FRContext; +//import com.fr.report.DesignAuthority; +//import com.fr.report.util.AuthorityXMLUtils; +//import com.fr.stable.EncodeConstants; +//import com.fr.third.org.apache.commons.io.IOUtils; +//import com.fr.third.org.apache.http.HttpResponse; +//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.ResponseHandler; +//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.entity.ContentType; +//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.HttpClients; +// +//import java.io.ByteArrayInputStream; +//import java.io.ByteArrayOutputStream; +//import java.io.IOException; +//import java.io.InputStream; +//import java.net.URLEncoder; +//import java.util.Map; +// +//public class RemoteEnvUtils { +// +// private RemoteEnvUtils() { +// } +// +// private static ResponseHandler responseHandler = new ResponseHandler() { +// @Override +// public InputStream handleResponse(HttpResponse response) throws IOException { +// int statusCode = response.getStatusLine().getStatusCode(); +// if (statusCode != HttpStatus.SC_OK) { +// throw new ClientProtocolException("Method failed: " + response.getStatusLine().toString()); +// } +// InputStream in = response.getEntity().getContent(); +// if (in == null) { +// return null; +// } +// // 读取并返回 +// ByteArrayOutputStream out = new ByteArrayOutputStream(); +// IOUtils.copy(in, out); +// return new ByteArrayInputStream(out.toByteArray()); +// } +// }; +// +// public static InputStream simulateRPCByHttpPost(byte[] bytes, Map parameters, boolean isSignIn, RemoteEnv env) throws EnvException { +// String path = env.getPath(); +// RequestBuilder builder = RequestBuilder.post(path); +// +// InputStream inputStream = null; +// +// for (Map.Entry entry : parameters.entrySet()) { +// builder.addParameter(entry.getKey(), entry.getValue()); +// } +// if (!isSignIn) { +// builder.addParameter("id", env.getUserID()); +// } +// InputStreamEntity reqEntity = new InputStreamEntity(new ByteArrayInputStream(bytes)); +// +// try (CloseableHttpClient httpClient = HttpClients.createSystem()) { +// HttpUriRequest request = builder +// .setEntity(reqEntity) +// .build(); +// inputStream = httpClient.execute(request, responseHandler); +// } catch (IOException e) { +// FRContext.getLogger().error(e.getMessage()); +// } +// return inputStream; +// } +// +// public static InputStream simulateRPCByHttpPost(Map parameters, boolean isSignIn, RemoteEnv env) throws EnvException { +// String path = env.getPath(); +// RequestBuilder builder = RequestBuilder.post(path); +// +// InputStream inputStream = null; +// +// for (Map.Entry entry : parameters.entrySet()) { +// builder.addParameter(entry.getKey(), entry.getValue()); +// } +// if (!isSignIn) { +// builder.addParameter("id", env.getUserID()); +// } +// +// try (CloseableHttpClient httpClient = HttpClients.createSystem()) { +// HttpUriRequest request = builder +// .build(); +// inputStream = httpClient.execute(request, responseHandler); +// } catch (IOException e) { +// FRContext.getLogger().error(e.getMessage()); +// } +// return inputStream; +// } +// +// public static InputStream simulateRPCByHttpGet(Map parameters, boolean isSignIn, RemoteEnv env) throws EnvException { +// String path = env.getPath(); +// RequestBuilder builder = RequestBuilder.get(path); +// +// InputStream inputStream = null; +// +// for (Map.Entry entry : parameters.entrySet()) { +// builder.addParameter(entry.getKey(), entry.getValue()); +// } +// if (!isSignIn) { +// builder.addParameter("id", env.getUserID()); +// } +// try (CloseableHttpClient httpClient = HttpClients.createSystem()) { +// HttpUriRequest request = builder.build(); +// inputStream = httpClient.execute(request, responseHandler); +// +// } catch (IOException e) { +// FRContext.getLogger().error(e.getMessage()); +// } +// return inputStream; +// } +// +// +// public static InputStream updateAuthorities(DesignAuthority[] authorities, RemoteEnv env) { +// String path = env.getPath(); +// // 远程设计临时用户id +// String userID = env.getUserID(); +// InputStream inputStream = null; +// +// ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); +// AuthorityXMLUtils.writeDesignAuthoritiesXML(authorities, outputStream); +// InputStreamEntity reqEntity = new InputStreamEntity(new ByteArrayInputStream(outputStream.toByteArray()), ContentType.TEXT_XML); +// +// try (CloseableHttpClient httpClient = HttpClients.createSystem()) { +// HttpUriRequest request = RequestBuilder.post(path) +// .addParameter("id", userID) +// .addParameter("op", "remote_design_authority") +// .addParameter("cmd", "update_authorities") +// .setEntity(reqEntity) +// .build(); +// inputStream = httpClient.execute(request, responseHandler); +// } catch (IOException e) { +// FRContext.getLogger().error(e.getMessage()); +// } +// +// return inputStream; +// +// } +// +// public static InputStream getAuthorities(RemoteEnv env) throws EnvException { +// String path = env.getPath(); +// // 远程设计临时用户id +// String userID = env.getUserID(); +// InputStream inputStream = null; +// +// try (CloseableHttpClient httpClient = HttpClients.createSystem();) { +// HttpUriRequest request = RequestBuilder.get(path) +// .addParameter("id", userID) +// .addParameter("op", "remote_design_authority") +// .addParameter("cmd", "get_authorities") +// .build(); +// inputStream = httpClient.execute(request, responseHandler); +// } catch (IOException e) { +// FRContext.getLogger().error(e.getMessage()); +// } +// return inputStream; +// } +// +// +//} diff --git a/designer-base/src/com/fr/start/ServerStarter.java b/designer-base/src/com/fr/start/ServerStarter.java index 3c6c1f22a2..5d8f39e3a3 100644 --- a/designer-base/src/com/fr/start/ServerStarter.java +++ b/designer-base/src/com/fr/start/ServerStarter.java @@ -11,7 +11,6 @@ import com.fr.design.env.DesignerWorkspaceGenerator; import com.fr.design.file.TemplateTreePane; import com.fr.design.gui.itextarea.UITextArea; import com.fr.design.mainframe.DesignerContext; -import com.fr.env.RemoteEnv; import com.fr.general.ComparatorUtils; import com.fr.general.GeneralContext; import com.fr.general.Inter; @@ -37,8 +36,9 @@ public class ServerStarter { */ public static void browserDemoURL() { - if (FRContext.getCurrentEnv() instanceof RemoteEnv) { - browser(FRContext.getCurrentEnv().getPath()); + if (!WorkContext.getCurrent().isLocal()) { + //有问题,这里拿不到远程的http端口 + browser(WorkContext.getCurrent().getPath()); return; } if (ComparatorUtils.equals(StableUtils.getInstallHome(), ".")) {//august:供代码使用 diff --git a/designer-realize/src/com/fr/design/mainframe/JWorkBook.java b/designer-realize/src/com/fr/design/mainframe/JWorkBook.java index bb75eda532..f3eeabf5ef 100644 --- a/designer-realize/src/com/fr/design/mainframe/JWorkBook.java +++ b/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.SmartInsertDBManipulationInWidgetEventPane; import com.fr.design.write.submit.SmartInsertDBManipulationPane; -import com.fr.env.RemoteEnv; import com.fr.file.FILE; import com.fr.file.FileNodeFILE; 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.project.ProjectConstants; import com.fr.web.controller.ViewRequestConstants; +import com.fr.workspace.WorkContext; import javax.swing.*; import java.awt.event.ActionEvent; @@ -634,7 +634,7 @@ public class JWorkBook extends JTemplate { public ShortCut[] shortcut4FileMenu() { return (ShortCut[]) ArrayUtils.addAll( 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()} ); } diff --git a/designer-realize/src/com/fr/design/mainframe/alphafine/cell/model/PluginModel.java b/designer-realize/src/com/fr/design/mainframe/alphafine/cell/model/PluginModel.java index f8782c10a7..8416afdec9 100644 --- a/designer-realize/src/com/fr/design/mainframe/alphafine/cell/model/PluginModel.java +++ b/designer-realize/src/com/fr/design/mainframe/alphafine/cell/model/PluginModel.java @@ -1,14 +1,13 @@ package com.fr.design.mainframe.alphafine.cell.model; -import com.fr.base.FRContext; import com.fr.design.extra.WebViewDlgHelper; import com.fr.design.mainframe.alphafine.AlphaFineConstants; 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.JSONObject; +import com.fr.log.FineLoggerFactory; import com.fr.stable.StringUtils; +import com.fr.workspace.WorkContext; /** * Created by XiaXiang on 2017/4/20. @@ -106,7 +105,8 @@ public class PluginModel extends AlphaCellModel { @Override public void doAction() { - if (StringUtils.isBlank(this.pluginId) || FRContext.getCurrentEnv() instanceof RemoteEnv) { + + if (StringUtils.isBlank(this.pluginId) || !WorkContext.getCurrent().isLocal()) { return; } WebViewDlgHelper.showPluginInStore(getName(), "[" + ModelToJson().optString("result") + "]"); diff --git a/designer-realize/src/com/fr/design/report/freeze/RepeatAndFreezeSettingPane.java b/designer-realize/src/com/fr/design/report/freeze/RepeatAndFreezeSettingPane.java index 7358546e9b..7c76e61df1 100644 --- a/designer-realize/src/com/fr/design/report/freeze/RepeatAndFreezeSettingPane.java +++ b/designer-realize/src/com/fr/design/report/freeze/RepeatAndFreezeSettingPane.java @@ -1,13 +1,5 @@ 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.design.dialog.BasicPane; 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.UILabel; import com.fr.design.layout.FRGUIPaneFactory; -import com.fr.env.RemoteEnv; import com.fr.general.Inter; import com.fr.page.ReportPageAttrProvider; import com.fr.stable.ColumnRow; import com.fr.stable.FT; 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 @@ -244,7 +243,8 @@ public class RepeatAndFreezeSettingPane extends BasicPane { } private boolean shouldShowTip() { - return !(FRContext.getCurrentEnv() instanceof RemoteEnv) && FRContext.isChineseEnv(); + + return WorkContext.getCurrent().isLocal() && FRContext.isChineseEnv(); } protected void initWriteListener() { diff --git a/designer-realize/src/com/fr/start/module/DesignerEnvProvider.java b/designer-realize/src/com/fr/start/module/DesignerEnvProvider.java index 827ee73cb3..e8f5c482b8 100644 --- a/designer-realize/src/com/fr/start/module/DesignerEnvProvider.java +++ b/designer-realize/src/com/fr/start/module/DesignerEnvProvider.java @@ -1,27 +1,11 @@ package com.fr.start.module; -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.serializer.OldSerializerAdapter; -import com.fr.base.env.serializer.ProcedureDataModelSerializer; -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.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 @@ -54,159 +38,159 @@ public class DesignerEnvProvider extends Activator { private void addSerializers() { - EnvProxy.addSerializer(ProcedureDataModel[].class, new ProcedureDataModelSerializer()); - - EnvProxy.addSerializer(ModifiedTable.class, new OldSerializerAdapter( - new OldSerializerAdapter.OldSerializer() { - - @Override - public void serializer(ModifiedTable obj, OutputStream out) throws Exception { - - DavXMLUtils.writeXMLModifiedTables(obj, out); - } - }, - new OldSerializerAdapter.OldDeserializer() { - - @Override - public ModifiedTable deserializer(InputStream in) throws Exception { - - return DavXMLUtils.readXMLModifiedTables(in); - } - } - )); - - EnvProxy.addSerializer(com.fr.data.impl.Connection.class, new OldSerializerAdapter( - new OldSerializerAdapter.OldSerializer() { - - @Override - public void serializer(Connection obj, OutputStream out) { - - DavXMLUtils.writeXMLFileDatabaseConnection(obj, out); - } - }, - new OldSerializerAdapter.OldDeserializer() { - - @Override - public Connection deserializer(InputStream in) throws Exception { - - return DavXMLUtils.readXMLDatabaseConnection(in); - } - } - )); - - EnvProxy.addSerializer(FileNode[].class, new OldSerializerAdapter( - new OldSerializerAdapter.OldSerializer() { - - @Override - public void serializer(FileNode[] obj, OutputStream out) { - - DavXMLUtils.writeXMLFileNodes(obj, out); - } - }, - new OldSerializerAdapter.OldDeserializer() { - - @Override - public FileNode[] deserializer(InputStream in) { - - return DavXMLUtils.readXMLFileNodes(in); - } - } - )); - - EnvProxy.addSerializer(TableProcedure[].class, new OldSerializerAdapter( - new OldSerializerAdapter.OldSerializer() { - - @Override - public void serializer(TableProcedure[] obj, OutputStream out) { - - DavXMLUtils.writeXMLFileSQLTable(obj, out); - } - }, - new OldSerializerAdapter.OldDeserializer() { - - @Override - public TableProcedure[] deserializer(InputStream in) throws Exception { - - return DavXMLUtils.readXMLSQLTables(in); - } - } - )); - - EnvProxy.addSerializer(TableData.class, new OldSerializerAdapter( - new OldSerializerAdapter.OldSerializer() { - - @Override - public void serializer(TableData obj, OutputStream out) { - - DavXMLUtils.writeXMLFileTableData(obj, out); - } - }, - new OldSerializerAdapter.OldDeserializer() { - - @Override - public TableData deserializer(InputStream in) throws Exception { - - return DavXMLUtils.readXMLTableData(in); - } - } - )); - - EnvProxy.addSerializer(Parameter[].class, new OldSerializerAdapter( - new OldSerializerAdapter.OldSerializer() { - - @Override - public void serializer(Parameter[] obj, OutputStream out) { - - DavXMLUtils.writeXMLFileParameters(obj, out); - } - }, - new OldSerializerAdapter.OldDeserializer() { - - @Override - public Parameter[] deserializer(InputStream in) throws Exception { - - return DavXMLUtils.readXMLParameters(in); - } - } - )); - - EnvProxy.addSerializer(StoreProcedure.class, new OldSerializerAdapter( - new OldSerializerAdapter.OldSerializer() { - - @Override - public void serializer(StoreProcedure obj, OutputStream out) { - - DavXMLUtils.writeXMLFileStoreProcedure(obj, out); - } - }, - new OldSerializerAdapter.OldDeserializer() { - - @Override - public StoreProcedure deserializer(InputStream in) throws Exception { - - return DavXMLUtils.readXMLStoreProcedure(in); - } - } - )); - - EnvProxy.addSerializer(StoreProcedureParameter[].class, new OldSerializerAdapter( - new OldSerializerAdapter.OldSerializer() { - - @Override - public void serializer(StoreProcedureParameter[] obj, OutputStream out) { - - DavXMLUtils.writeXMLFileParameters(obj, out); - } - }, - new OldSerializerAdapter.OldDeserializer() { - - @Override - public StoreProcedureParameter[] deserializer(InputStream in) throws Exception { - - return DavXMLUtils.readXMLStoreProcedureParameters(in); - } - } - )); +// EnvProxy.addSerializer(ProcedureDataModel[].class, new ProcedureDataModelSerializer()); +// +// EnvProxy.addSerializer(ModifiedTable.class, new OldSerializerAdapter( +// new OldSerializerAdapter.OldSerializer() { +// +// @Override +// public void serializer(ModifiedTable obj, OutputStream out) throws Exception { +// +// DavXMLUtils.writeXMLModifiedTables(obj, out); +// } +// }, +// new OldSerializerAdapter.OldDeserializer() { +// +// @Override +// public ModifiedTable deserializer(InputStream in) throws Exception { +// +// return DavXMLUtils.readXMLModifiedTables(in); +// } +// } +// )); +// +// EnvProxy.addSerializer(com.fr.data.impl.Connection.class, new OldSerializerAdapter( +// new OldSerializerAdapter.OldSerializer() { +// +// @Override +// public void serializer(Connection obj, OutputStream out) { +// +// DavXMLUtils.writeXMLFileDatabaseConnection(obj, out); +// } +// }, +// new OldSerializerAdapter.OldDeserializer() { +// +// @Override +// public Connection deserializer(InputStream in) throws Exception { +// +// return DavXMLUtils.readXMLDatabaseConnection(in); +// } +// } +// )); +// +// EnvProxy.addSerializer(FileNode[].class, new OldSerializerAdapter( +// new OldSerializerAdapter.OldSerializer() { +// +// @Override +// public void serializer(FileNode[] obj, OutputStream out) { +// +// DavXMLUtils.writeXMLFileNodes(obj, out); +// } +// }, +// new OldSerializerAdapter.OldDeserializer() { +// +// @Override +// public FileNode[] deserializer(InputStream in) { +// +// return DavXMLUtils.readXMLFileNodes(in); +// } +// } +// )); +// +// EnvProxy.addSerializer(TableProcedure[].class, new OldSerializerAdapter( +// new OldSerializerAdapter.OldSerializer() { +// +// @Override +// public void serializer(TableProcedure[] obj, OutputStream out) { +// +// DavXMLUtils.writeXMLFileSQLTable(obj, out); +// } +// }, +// new OldSerializerAdapter.OldDeserializer() { +// +// @Override +// public TableProcedure[] deserializer(InputStream in) throws Exception { +// +// return DavXMLUtils.readXMLSQLTables(in); +// } +// } +// )); +// +// EnvProxy.addSerializer(TableData.class, new OldSerializerAdapter( +// new OldSerializerAdapter.OldSerializer() { +// +// @Override +// public void serializer(TableData obj, OutputStream out) { +// +// DavXMLUtils.writeXMLFileTableData(obj, out); +// } +// }, +// new OldSerializerAdapter.OldDeserializer() { +// +// @Override +// public TableData deserializer(InputStream in) throws Exception { +// +// return DavXMLUtils.readXMLTableData(in); +// } +// } +// )); +// +// EnvProxy.addSerializer(Parameter[].class, new OldSerializerAdapter( +// new OldSerializerAdapter.OldSerializer() { +// +// @Override +// public void serializer(Parameter[] obj, OutputStream out) { +// +// DavXMLUtils.writeXMLFileParameters(obj, out); +// } +// }, +// new OldSerializerAdapter.OldDeserializer() { +// +// @Override +// public Parameter[] deserializer(InputStream in) throws Exception { +// +// return DavXMLUtils.readXMLParameters(in); +// } +// } +// )); +// +// EnvProxy.addSerializer(StoreProcedure.class, new OldSerializerAdapter( +// new OldSerializerAdapter.OldSerializer() { +// +// @Override +// public void serializer(StoreProcedure obj, OutputStream out) { +// +// DavXMLUtils.writeXMLFileStoreProcedure(obj, out); +// } +// }, +// new OldSerializerAdapter.OldDeserializer() { +// +// @Override +// public StoreProcedure deserializer(InputStream in) throws Exception { +// +// return DavXMLUtils.readXMLStoreProcedure(in); +// } +// } +// )); +// +// EnvProxy.addSerializer(StoreProcedureParameter[].class, new OldSerializerAdapter( +// new OldSerializerAdapter.OldSerializer() { +// +// @Override +// public void serializer(StoreProcedureParameter[] obj, OutputStream out) { +// +// DavXMLUtils.writeXMLFileParameters(obj, out); +// } +// }, +// new OldSerializerAdapter.OldDeserializer() { +// +// @Override +// public StoreProcedureParameter[] deserializer(InputStream in) throws Exception { +// +// return DavXMLUtils.readXMLStoreProcedureParameters(in); +// } +// } +// )); } @Override diff --git a/designer-realize/src/com/fr/start/module/DesignerStartup.java b/designer-realize/src/com/fr/start/module/DesignerStartup.java index f5c3959e08..3de4805b04 100644 --- a/designer-realize/src/com/fr/start/module/DesignerStartup.java +++ b/designer-realize/src/com/fr/start/module/DesignerStartup.java @@ -1,7 +1,5 @@ package com.fr.start.module; -import com.fr.base.env.EnvConfig; -import com.fr.core.env.EnvEvent; import com.fr.event.Event; import com.fr.event.Listener; import com.fr.module.Activator; @@ -9,6 +7,8 @@ import com.fr.start.Designer; import com.fr.start.EnvSwitcher; import com.fr.start.SplashContext; import com.fr.startup.activators.BasicActivator; +import com.fr.workspace.Workspace; +import com.fr.workspace.WorkspaceEvent; /** * Created by juhaoyu on 2018/1/8. @@ -38,19 +38,19 @@ public class DesignerStartup extends Activator { * 切换环境时,重新启动所有相关模块 */ private void registerEnvListener() { - - listenEvent(EnvEvent.BEFORE_SIGN_OUT, new Listener() { + + listenEvent(WorkspaceEvent.BeforeSwitch, new Listener() { @Override - public void on(Event event, EnvConfig param) { + public void on(Event event, Workspace param) { getSub(EnvBasedModule.class).stop(); } }); - listenEvent(EnvEvent.AFTER_SIGN_IN, new Listener() { + listenEvent(WorkspaceEvent.AfterSwitch, new Listener() { @Override - public void on(Event event, EnvConfig param) { + public void on(Event event, Workspace param) { getSub(EnvBasedModule.class).start(); } From 63bc6e2fea9465cc900ce5d84ac534fef40d091f Mon Sep 17 00:00:00 2001 From: ju Date: Fri, 15 Jun 2018 16:48:08 +0800 Subject: [PATCH 05/20] f --- .../fr/design/actions/file/LocalePane.java | 10 +++--- .../fr/design/data/datapane/ChoosePane.java | 4 +-- .../tabledatapane/ClassNameSelectPane.java | 16 ++++------ .../wrapper/StoreProcedureNameWrapper.java | 2 -- .../design/file/HistoryTemplateListPane.java | 4 +-- .../com/fr/design/file/TemplateTreePane.java | 6 ++-- .../com/fr/design/formula/JavaEditorPane.java | 5 ++- .../gui/itree/filetree/EnvFileTree.java | 7 ++--- .../itree/filetree/FileNodeComparator.java | 18 +++++------ .../gui/itree/filetree/FileTreeIcon.java | 14 ++++----- .../gui/itree/filetree/ReportletPane.java | 31 ++++++++----------- .../gui/itree/filetree/TemplateFileTree.java | 5 ++- .../fr/design/mainframe/DesignerFrame.java | 2 +- .../com/fr/design/mainframe/JTemplate.java | 4 +-- .../loghandler/socketio/DesignerSocketIO.java | 10 ++---- .../mainframe/toolbar/ToolBarMenuDock.java | 3 +- .../design/remote/ui/AuthorityEditorPane.java | 7 ++--- .../design/roleAuthority/RoleDataWrapper.java | 2 +- .../com/fr/design/widget/IconDefinePane.java | 8 ++--- .../src/com/fr/file/FILEChooserPane.java | 8 ++--- .../src/com/fr/file/FileNodeFILE.java | 2 +- .../map/server/ChartMapEditorAction.java | 6 ++-- .../design/parameter/FormParameterReader.java | 2 +- .../alphafine/component/AlphaFineDialog.java | 7 ++--- .../manager/impl/FileSearchManager.java | 30 ++++++++---------- .../parameter/WorkBookParameterReader.java | 2 +- .../src/com/fr/start/Designer.java | 10 ++---- 27 files changed, 90 insertions(+), 135 deletions(-) diff --git a/designer-base/src/com/fr/design/actions/file/LocalePane.java b/designer-base/src/com/fr/design/actions/file/LocalePane.java index 20573d34c1..b17e66e738 100644 --- a/designer-base/src/com/fr/design/actions/file/LocalePane.java +++ b/designer-base/src/com/fr/design/actions/file/LocalePane.java @@ -4,13 +4,13 @@ package com.fr.design.actions.file; -import com.fr.base.Env; import com.fr.base.FRContext; import com.fr.design.dialog.BasicPane; import com.fr.design.gui.frpane.UITabbedPane; import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.itextfield.UITextField; import com.fr.file.filetree.FileNode; +import com.fr.general.Env; import com.fr.general.GeneralUtils; import com.fr.general.Inter; import com.fr.stable.ArrayUtils; @@ -180,11 +180,8 @@ public class LocalePane extends BasicPane { } private void initCustomProperties() throws Exception { - Env env = FRContext.getCurrentEnv(); - if (env == null) { - return; - } - FileNode[] fileNodes = env.getFileOperator().list(ProjectConstants.LOCALE_NAME); + + FileNode[] fileNodes = FRContext.getFileOperator().list(ProjectConstants.LOCALE_NAME); if (ArrayUtils.getLength(fileNodes) == 0) { return; } @@ -220,6 +217,7 @@ public class LocalePane extends BasicPane { * */ public void save() { + Env env = FRContext.getCurrentEnv(); if (env == null) { return; diff --git a/designer-base/src/com/fr/design/data/datapane/ChoosePane.java b/designer-base/src/com/fr/design/data/datapane/ChoosePane.java index 8db0957339..6fd557fa0f 100644 --- a/designer-base/src/com/fr/design/data/datapane/ChoosePane.java +++ b/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.DBTableData; import com.fr.data.operator.DataOperator; -import com.fr.dav.LocalEnv; import com.fr.design.DesignerEnvManager; import com.fr.design.beans.BasicBeanPane; import com.fr.design.data.DesignTableDataManager; @@ -37,6 +36,7 @@ import com.fr.general.ComparatorUtils; import com.fr.general.Inter; import com.fr.log.FineLoggerFactory; import com.fr.stable.StringUtils; +import com.fr.workspace.WorkContext; import javax.swing.*; import javax.swing.event.ChangeEvent; @@ -463,7 +463,7 @@ public class ChoosePane extends BasicBeanPane implements Refresha // 显示Table数据. TableData tableData = null; - if (FRContext.getCurrentEnv() instanceof LocalEnv) { + if (WorkContext.getCurrent().isLocal()) { tableData = new DBTableData(database, DataCoreUtils.createSelectSQL(paras.getSchemaName(), paras.getTableName(), DialectFactory.getDialectByName(paras.getDatabaseName()))); } else { diff --git a/designer-base/src/com/fr/design/data/tabledata/tabledatapane/ClassNameSelectPane.java b/designer-base/src/com/fr/design/data/tabledata/tabledatapane/ClassNameSelectPane.java index 1eed1bb428..876c956a79 100644 --- a/designer-base/src/com/fr/design/data/tabledata/tabledatapane/ClassNameSelectPane.java +++ b/designer-base/src/com/fr/design/data/tabledata/tabledatapane/ClassNameSelectPane.java @@ -1,19 +1,15 @@ package com.fr.design.data.tabledata.tabledatapane; -import java.awt.BorderLayout; - -import javax.swing.BorderFactory; +import com.fr.design.dialog.BasicPane; 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.layout.FRGUIPaneFactory; -import com.fr.design.dialog.BasicPane; import com.fr.general.Inter; +import javax.swing.*; +import javax.swing.tree.TreeSelectionModel; +import java.awt.*; + public class ClassNameSelectPane extends BasicPane { private ClassFileTree classFileTree; @@ -27,7 +23,7 @@ public class ClassNameSelectPane extends BasicPane { Inter.getLocText("Function-Choose_Function_Class") + ":")); classFileTree = new ClassFileTree(); - classFileTree.refreshEnv(FRContext.getCurrentEnv()); + classFileTree.refreshEnv(); classFileTree.getSelectionModel().setSelectionMode( TreeSelectionModel.SINGLE_TREE_SELECTION); this.add(new JScrollPane(classFileTree), BorderLayout.CENTER); diff --git a/designer-base/src/com/fr/design/data/tabledata/wrapper/StoreProcedureNameWrapper.java b/designer-base/src/com/fr/design/data/tabledata/wrapper/StoreProcedureNameWrapper.java index 26b58cd351..9e52524c19 100644 --- a/designer-base/src/com/fr/design/data/tabledata/wrapper/StoreProcedureNameWrapper.java +++ b/designer-base/src/com/fr/design/data/tabledata/wrapper/StoreProcedureNameWrapper.java @@ -1,7 +1,6 @@ package com.fr.design.data.tabledata.wrapper; import com.fr.base.BaseUtils; -import com.fr.base.Env; import com.fr.base.FRContext; import com.fr.base.TableData; import com.fr.data.impl.storeproc.ProcedureDataModel; @@ -94,7 +93,6 @@ public final class StoreProcedureNameWrapper implements TableDataWrapper { return columnNameList; } columnNameList = new ArrayList(); - Env env = FRContext.getCurrentEnv(); if (!WorkContext.getCurrent().isLocal()) { try { createStore(false); diff --git a/designer-base/src/com/fr/design/file/HistoryTemplateListPane.java b/designer-base/src/com/fr/design/file/HistoryTemplateListPane.java index 2c2137384e..3fc3f1d72b 100644 --- a/designer-base/src/com/fr/design/file/HistoryTemplateListPane.java +++ b/designer-base/src/com/fr/design/file/HistoryTemplateListPane.java @@ -1,6 +1,5 @@ package com.fr.design.file; -import com.fr.base.Env; import com.fr.base.FRContext; import com.fr.base.chart.chartdata.CallbackEvent; import com.fr.design.DesignModelAdapter; @@ -366,8 +365,7 @@ public class HistoryTemplateListPane extends JPanel implements FileOperations, C */ public void openContainerFolder() { FileNode fileNode = new FileNode(((JTemplate) list.getSelectedValue()).getEditingFILE().getPath(), false); - Env env = FRContext.getCurrentEnv(); - if (env.isLocalEnv()) { + if (WorkContext.getCurrent().isLocal()) { IOUtils.openWindowsFolder(StableUtils.pathJoin(WorkContext.getCurrent().getPath(), fileNode.getEnvPath())); } } diff --git a/designer-base/src/com/fr/design/file/TemplateTreePane.java b/designer-base/src/com/fr/design/file/TemplateTreePane.java index 6d5063fd67..78905c32ac 100644 --- a/designer-base/src/com/fr/design/file/TemplateTreePane.java +++ b/designer-base/src/com/fr/design/file/TemplateTreePane.java @@ -3,7 +3,6 @@ */ package com.fr.design.file; -import com.fr.base.Env; import com.fr.base.FRContext; import com.fr.base.io.FileAssistUtils; import com.fr.design.gui.icontainer.UIScrollPane; @@ -100,7 +99,7 @@ public class TemplateTreePane extends JPanel implements FileOperations { */ public void refreshDockingView() { reportletsTree.setFileNodeFilter(new IOFileNodeFilter(FRContext.getCurrentEnv().getSupportedTypes())); - reportletsTree.refreshEnv(FRContext.getCurrentEnv()); + reportletsTree.refreshEnv(); } /* @@ -141,8 +140,7 @@ public class TemplateTreePane extends JPanel implements FileOperations { */ public void openContainerFolder() { FileNode fn = TemplateTreePane.this.reportletsTree.getSelectedFileNode(); - Env localEnv = FRContext.getCurrentEnv(); - String filePath = StableUtils.pathJoin(localEnv.getPath(), fn.getEnvPath()); + String filePath = StableUtils.pathJoin(WorkContext.getCurrent().getPath(), fn.getEnvPath()); filePath = filePath.substring(0, filePath.lastIndexOf(CoreConstants.SEPARATOR)); try { Desktop.getDesktop().open(new File(filePath)); diff --git a/designer-base/src/com/fr/design/formula/JavaEditorPane.java b/designer-base/src/com/fr/design/formula/JavaEditorPane.java index 2a5836f0ff..9c8fab0f07 100644 --- a/designer-base/src/com/fr/design/formula/JavaEditorPane.java +++ b/designer-base/src/com/fr/design/formula/JavaEditorPane.java @@ -1,6 +1,5 @@ package com.fr.design.formula; -import com.fr.base.Env; import com.fr.base.FRContext; import com.fr.design.dialog.BasicPane; import com.fr.design.gui.ibutton.UIButton; @@ -176,8 +175,8 @@ public class JavaEditorPane extends BasicPane { @Override protected JavaCompileInfo doInBackground() throws Exception { - Env env = FRContext.getCurrentEnv(); - return env.getCommonOperator().compile(javaText.getText()); + + return FRContext.getCommonOperator().compile(javaText.getText()); } public void done() { diff --git a/designer-base/src/com/fr/design/gui/itree/filetree/EnvFileTree.java b/designer-base/src/com/fr/design/gui/itree/filetree/EnvFileTree.java index c7a6f4c825..0eae91deec 100644 --- a/designer-base/src/com/fr/design/gui/itree/filetree/EnvFileTree.java +++ b/designer-base/src/com/fr/design/gui/itree/filetree/EnvFileTree.java @@ -1,6 +1,5 @@ package com.fr.design.gui.itree.filetree; -import com.fr.base.Env; import com.fr.base.FRContext; import com.fr.design.constants.UIConstants; import com.fr.design.gui.ilable.UILabel; @@ -28,7 +27,6 @@ import java.util.Arrays; public class EnvFileTree extends RefreshableJTree { protected FileNodeFilter filter; - protected Env env; protected String treeRootPath = ""; protected String[] subPathes; @@ -191,7 +189,7 @@ public class EnvFileTree extends RefreshableJTree { FileNode[] res_fns = null; try { - res_fns = env == null ? new FileNode[0] : env.getFileOperator().list(filePath); + res_fns = FRContext.getCurrentEnv() == null ? new FileNode[0] : FRContext.getFileOperator().list(filePath); } catch (Exception e) { FRContext.getLogger().error(e.getMessage(), e); } @@ -239,8 +237,7 @@ public class EnvFileTree extends RefreshableJTree { /* * 改变Env后,根据构造函数时设置的RootPathes,重新加载 */ - public void refreshEnv(Env env) { - this.env = env; + public void refreshEnv() { DefaultTreeModel m_model = (DefaultTreeModel) this.getModel(); ExpandMutableTreeNode rootTreeNode = (ExpandMutableTreeNode) m_model.getRoot(); diff --git a/designer-base/src/com/fr/design/gui/itree/filetree/FileNodeComparator.java b/designer-base/src/com/fr/design/gui/itree/filetree/FileNodeComparator.java index a6608b6b54..2be0865023 100644 --- a/designer-base/src/com/fr/design/gui/itree/filetree/FileNodeComparator.java +++ b/designer-base/src/com/fr/design/gui/itree/filetree/FileNodeComparator.java @@ -1,9 +1,9 @@ package com.fr.design.gui.itree.filetree; -import java.util.Comparator; - -import com.fr.dav.LocalEnv; import com.fr.file.filetree.FileNode; +import com.fr.general.adaptor.WorkspaceAdaptor; + +import java.util.Comparator; /** * FileTreeNode compare... @@ -26,8 +26,6 @@ public class FileNodeComparator implements Comparator { * v1 is equal to v2, or < 0 if v1 is less than v2. * It must handle null values for the comparison values. * - * @param v1 comparison value. - * @param v2 comparison value. * @return < 0, 0, or > 0 for v1v2. */ public int compare(FileNode nameNode1, FileNode nameNode2) { @@ -60,14 +58,14 @@ public class FileNodeComparator implements Comparator { */ private int groupByFileType(FileNode nameNode1, FileNode nameNode2, int i) { - if(i< LocalEnv.FILE_TYPE.length){ - if(nameNode1.isFileType(LocalEnv.FILE_TYPE[i])) - if(nameNode2.isFileType(LocalEnv.FILE_TYPE[i])) + + if (i < WorkspaceAdaptor.FILE_TYPE.length) { + if (nameNode1.isFileType(WorkspaceAdaptor.FILE_TYPE[i])) + if (nameNode2.isFileType(WorkspaceAdaptor.FILE_TYPE[i])) return nameNode1.getName().toLowerCase().compareTo(nameNode2.getName().toLowerCase()); else return-1; - else - if(nameNode2.isFileType(LocalEnv.FILE_TYPE[i])) + else if (nameNode2.isFileType(WorkspaceAdaptor.FILE_TYPE[i])) return 1; else{ return groupByFileType(nameNode1, nameNode2, i+1); diff --git a/designer-base/src/com/fr/design/gui/itree/filetree/FileTreeIcon.java b/designer-base/src/com/fr/design/gui/itree/filetree/FileTreeIcon.java index 83f31067fb..b6ea37817a 100644 --- a/designer-base/src/com/fr/design/gui/itree/filetree/FileTreeIcon.java +++ b/designer-base/src/com/fr/design/gui/itree/filetree/FileTreeIcon.java @@ -1,17 +1,15 @@ 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.FRContext; -import com.fr.dav.LocalEnv; import com.fr.design.icon.LockIcon; import com.fr.file.filetree.FileNode; 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 { private FileTreeIcon() {} @@ -118,7 +116,7 @@ public class FileTreeIcon { public static Icon getIcon(FileNode node, boolean isShowLock) { String path = StableUtils.pathJoin(new String[]{FRContext.getCurrentEnv().getPath(), node.getEnvPath()}); - if (FRContext.getCurrentEnv() instanceof LocalEnv) { + if (WorkContext.getCurrent().isLocal()) { File ff = new File(path); if (ff.exists()) { if(node.isDirectory()){ diff --git a/designer-base/src/com/fr/design/gui/itree/filetree/ReportletPane.java b/designer-base/src/com/fr/design/gui/itree/filetree/ReportletPane.java index b98b8e200b..6259667e4f 100644 --- a/designer-base/src/com/fr/design/gui/itree/filetree/ReportletPane.java +++ b/designer-base/src/com/fr/design/gui/itree/filetree/ReportletPane.java @@ -1,23 +1,18 @@ 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.design.dialog.BasicPane; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.itextarea.UITextArea; 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.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 { private TemplateFileTree templateReportletTree; @@ -60,8 +55,8 @@ public class ReportletPane extends BasicPane { cardPane.add(t_panel = new JScrollPane(templateReportletTree), "TEMPLATE"); classReportletTree = new ClassFileTree(); cardPane.add(c_panel = new JScrollPane(classReportletTree), "CLASS"); - - this.refreshEnv(FRContext.getCurrentEnv()); + + this.refreshEnv(); } /* @@ -92,11 +87,11 @@ public class ReportletPane extends BasicPane { /** * 刷新Env - * @param env 环境 */ - public void refreshEnv(Env env) { - this.templateReportletTree.refreshEnv(env); - this.classReportletTree.refreshEnv(env); + public void refreshEnv() { + + this.templateReportletTree.refreshEnv(); + this.classReportletTree.refreshEnv(); } @Override diff --git a/designer-base/src/com/fr/design/gui/itree/filetree/TemplateFileTree.java b/designer-base/src/com/fr/design/gui/itree/filetree/TemplateFileTree.java index 26b9095d81..451a381eca 100644 --- a/designer-base/src/com/fr/design/gui/itree/filetree/TemplateFileTree.java +++ b/designer-base/src/com/fr/design/gui/itree/filetree/TemplateFileTree.java @@ -1,6 +1,5 @@ package com.fr.design.gui.itree.filetree; -import com.fr.base.Env; import com.fr.base.FRContext; import com.fr.base.extension.FileExtension; import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode; @@ -102,7 +101,7 @@ public class TemplateFileTree extends EnvFileTree { } public FileNode[] listFile(String path) throws Exception { - return FRContext.getCurrentEnv().getFileOperator().list( + return FRContext.getFileOperator().list( path, new FileExtension[]{FileExtension.CPT, FileExtension.FRM, FileExtension.CPTX, FileExtension.FRMX}); } @@ -110,7 +109,7 @@ public class TemplateFileTree extends EnvFileTree { /* * 改变Env后,根据构造函数时设置的RootPaths,重新加载 */ - public void refreshEnv(Env env) { + public void refreshEnv() { DefaultTreeModel defaultTreeModel = (DefaultTreeModel) this.getModel(); ExpandMutableTreeNode rootTreeNode = (ExpandMutableTreeNode) defaultTreeModel.getRoot(); diff --git a/designer-base/src/com/fr/design/mainframe/DesignerFrame.java b/designer-base/src/com/fr/design/mainframe/DesignerFrame.java index 402603f9b5..7719d06a4a 100644 --- a/designer-base/src/com/fr/design/mainframe/DesignerFrame.java +++ b/designer-base/src/com/fr/design/mainframe/DesignerFrame.java @@ -652,7 +652,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta String envName = DesignerEnvManager.getEnvManager().getCurEnvName(); DesignerWorkspaceInfo env = DesignerEnvManager.getEnvManager().getWorkspaceInfo(envName); if (env != null) { -// defaultTitleSB.append(env.getDescription(envName)); + defaultTitleSB.append(WorkContext.getCurrent().getDescription()); if (editingTemplate != null) { String path = editingTemplate.getEditingFILE().getPath(); if (!editingTemplate.getEditingFILE().exists()) { diff --git a/designer-base/src/com/fr/design/mainframe/JTemplate.java b/designer-base/src/com/fr/design/mainframe/JTemplate.java index 8ab0c47562..f39775ba42 100644 --- a/designer-base/src/com/fr/design/mainframe/JTemplate.java +++ b/designer-base/src/com/fr/design/mainframe/JTemplate.java @@ -544,7 +544,7 @@ public abstract class JTemplate> boolean access = false; try { - access = FRContext.getCurrentEnv().getOrganizationOperator().canAccess(this.getEditingFILE().getPath()); + access = FRContext.getOrganizationOperator().canAccess(this.getEditingFILE().getPath()); } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); } @@ -594,7 +594,7 @@ public abstract class JTemplate> if (isOkOperation(chooseResult)) { boolean access = false; try { - access = FRContext.getCurrentEnv().getOrganizationOperator().canAccess(fileChooser.getSelectedFILE().getPath()); + access = FRContext.getOrganizationOperator().canAccess(fileChooser.getSelectedFILE().getPath()); } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); } diff --git a/designer-base/src/com/fr/design/mainframe/loghandler/socketio/DesignerSocketIO.java b/designer-base/src/com/fr/design/mainframe/loghandler/socketio/DesignerSocketIO.java index 9051b0ac7e..c98eee7d5a 100644 --- a/designer-base/src/com/fr/design/mainframe/loghandler/socketio/DesignerSocketIO.java +++ b/designer-base/src/com/fr/design/mainframe/loghandler/socketio/DesignerSocketIO.java @@ -1,7 +1,5 @@ package com.fr.design.mainframe.loghandler.socketio; -import com.fr.base.Env; -import com.fr.base.FRContext; import com.fr.design.mainframe.loghandler.DesignerLogHandler; import com.fr.event.Event; import com.fr.event.EventDispatcher; @@ -10,15 +8,13 @@ import com.fr.general.LogRecordTime; import com.fr.general.LogUtils; import com.fr.log.FineLoggerFactory; import com.fr.third.guava.base.Optional; -import com.fr.web.WebSocketConfig; +import com.fr.workspace.WorkContext; import com.fr.workspace.Workspace; import com.fr.workspace.WorkspaceEvent; -import io.socket.client.IO; import io.socket.client.Socket; import io.socket.emitter.Emitter; import java.io.ByteArrayInputStream; -import java.net.URI; public class DesignerSocketIO { @@ -61,8 +57,8 @@ public class DesignerSocketIO { } private static void updateSocket() { - Env env = FRContext.getCurrentEnv(); - if (env.isLocalEnv()) { + + if (WorkContext.getCurrent().isLocal()) { return; } try { diff --git a/designer-base/src/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java b/designer-base/src/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java index 35278c8ccf..45c0e1e6d3 100644 --- a/designer-base/src/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java +++ b/designer-base/src/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java @@ -434,7 +434,8 @@ public abstract class ToolBarMenuDock { } private boolean shouldShowRemotePermission() { - return FRContext.getCurrentEnv() != null && !FRContext.getCurrentEnv().isLocalEnv() && FRContext.getCurrentEnv().isRoot(); + + return WorkContext.getCurrent() != null && !WorkContext.getCurrent().isLocal() && FRContext.getCurrentEnv().isRoot(); } private boolean shouldShowPlugin() { diff --git a/designer-base/src/com/fr/design/remote/ui/AuthorityEditorPane.java b/designer-base/src/com/fr/design/remote/ui/AuthorityEditorPane.java index bb9c9cc406..f43b5e881d 100644 --- a/designer-base/src/com/fr/design/remote/ui/AuthorityEditorPane.java +++ b/designer-base/src/com/fr/design/remote/ui/AuthorityEditorPane.java @@ -1,6 +1,5 @@ package com.fr.design.remote.ui; -import com.fr.base.FRContext; import com.fr.design.beans.BasicBeanPane; import com.fr.design.border.UITitledBorder; import com.fr.design.gui.icontainer.UIScrollPane; @@ -13,10 +12,10 @@ import com.fr.general.Inter; import com.fr.report.DesignAuthority; import com.fr.stable.CoreConstants; -import javax.swing.BorderFactory; +import javax.swing.*; import javax.swing.border.EmptyBorder; import javax.swing.tree.TreePath; -import java.awt.BorderLayout; +import java.awt.*; import java.util.ArrayList; import java.util.List; @@ -40,7 +39,7 @@ public class AuthorityEditorPane extends BasicBeanPane { tree.setDigIn(true); tree.setFileNodeFilter(filter); this.add(new UIScrollPane(tree), BorderLayout.CENTER); - tree.refreshEnv(FRContext.getCurrentEnv()); + tree.refreshEnv(); } diff --git a/designer-base/src/com/fr/design/roleAuthority/RoleDataWrapper.java b/designer-base/src/com/fr/design/roleAuthority/RoleDataWrapper.java index 253f6d8c27..f5c3dda231 100644 --- a/designer-base/src/com/fr/design/roleAuthority/RoleDataWrapper.java +++ b/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; /** * 将权限细粒度的角色数据包装一下,区分报表平台管理角色和数据决策系统角色 *

* Author : daisy * Date: 13-8-30 * Time: 下午3:42 */ public class RoleDataWrapper implements ChildrenNodesLoader { private List rolelist = new ArrayList(); 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 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; } } \ No newline at end of file +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; /** * 将权限细粒度的角色数据包装一下,区分报表平台管理角色和数据决策系统角色 *

* Author : daisy * Date: 13-8-30 * Time: 下午3:42 */ public class RoleDataWrapper implements ChildrenNodesLoader { private List rolelist = new ArrayList(); 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 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; } } \ No newline at end of file diff --git a/designer-base/src/com/fr/design/widget/IconDefinePane.java b/designer-base/src/com/fr/design/widget/IconDefinePane.java index f441d1c60a..6bcc649a4a 100644 --- a/designer-base/src/com/fr/design/widget/IconDefinePane.java +++ b/designer-base/src/com/fr/design/widget/IconDefinePane.java @@ -1,15 +1,13 @@ package com.fr.design.widget; -import com.fr.base.Env; -import com.fr.base.FRContext; +import com.fr.design.dialog.BasicDialog; +import com.fr.design.dialog.BasicPane; +import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ilable.UILabel; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.DesignerContext; 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.general.Inter; diff --git a/designer-base/src/com/fr/file/FILEChooserPane.java b/designer-base/src/com/fr/file/FILEChooserPane.java index d5e6d8e559..24e191bc0c 100644 --- a/designer-base/src/com/fr/file/FILEChooserPane.java +++ b/designer-base/src/com/fr/file/FILEChooserPane.java @@ -3,7 +3,6 @@ package com.fr.file; import com.fr.base.BaseUtils; import com.fr.base.FRContext; import com.fr.base.extension.FileExtension; -import com.fr.dav.LocalEnv; import com.fr.design.DesignerEnvManager; import com.fr.design.actions.UpdateAction; import com.fr.design.dialog.BasicPane; @@ -26,6 +25,7 @@ import com.fr.file.filter.FILEFilter; import com.fr.general.ComparatorUtils; import com.fr.general.GeneralContext; import com.fr.general.Inter; +import com.fr.general.adaptor.WorkspaceAdaptor; import com.fr.log.FineLoggerFactory; import com.fr.stable.CoreConstants; import com.fr.stable.OperatingSystem; @@ -545,7 +545,7 @@ public class FILEChooserPane extends BasicPane { return; } if (editing == null || !editing.isChartBook()) { - String[] fileSuffix_local = LocalEnv.FILE_TYPE; + String[] fileSuffix_local = WorkspaceAdaptor.FILE_TYPE; EnumSet fileExtensions = EnumSet.of(FileExtension.CPT, FileExtension.CPTX, FileExtension.FRM, FileExtension.FRMX, FileExtension.CHT); if (type == JFileChooser.OPEN_DIALOG) { if (FRContext.getCurrentEnv().isSupportLocalFileOperate()) { //本地连接 @@ -686,7 +686,7 @@ public class FILEChooserPane extends BasicPane { boolean access = false; try { - access = FRContext.getCurrentEnv().getOrganizationOperator().canAccess(selectedFile.getPath()); + access = FRContext.getOrganizationOperator().canAccess(selectedFile.getPath()); } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); } @@ -1404,7 +1404,7 @@ public class FILEChooserPane extends BasicPane { boolean access = false; try { - access = FRContext.getCurrentEnv().getOrganizationOperator().canAccess(currentDirectory.getPath()); + access = FRContext.getOrganizationOperator().canAccess(currentDirectory.getPath()); } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); } diff --git a/designer-base/src/com/fr/file/FileNodeFILE.java b/designer-base/src/com/fr/file/FileNodeFILE.java index 7fead4ce08..984e88ec6a 100644 --- a/designer-base/src/com/fr/file/FileNodeFILE.java +++ b/designer-base/src/com/fr/file/FileNodeFILE.java @@ -181,7 +181,7 @@ public class FileNodeFILE implements FILE { */ private FileNode[] listFile(String rootFilePath) { try { - return FRContext.getCurrentEnv().getFileOperator().list(rootFilePath); + return FRContext.getFileOperator().list(rootFilePath); } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); } diff --git a/designer-chart/src/com/fr/van/chart/map/server/ChartMapEditorAction.java b/designer-chart/src/com/fr/van/chart/map/server/ChartMapEditorAction.java index fb0ef83728..381006aa24 100644 --- a/designer-chart/src/com/fr/van/chart/map/server/ChartMapEditorAction.java +++ b/designer-chart/src/com/fr/van/chart/map/server/ChartMapEditorAction.java @@ -1,7 +1,5 @@ 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.design.DesignerEnvManager; import com.fr.design.actions.UpdateAction; @@ -9,6 +7,7 @@ import com.fr.general.GeneralContext; import com.fr.general.IOUtils; import com.fr.general.Inter; import com.fr.start.ServerStarter; +import com.fr.workspace.WorkContext; import java.awt.event.ActionEvent; @@ -26,8 +25,7 @@ public class ChartMapEditorAction extends UpdateAction { int port = DesignerEnvManager.getEnvManager().getEmbedServerPort(); String web = GeneralContext.getCurrentAppNameOfEnv(); String serverlet = ServerConfig.getInstance().getReportServletName(); - Env env = FRContext.getCurrentEnv(); - ServerStarter.browserURLWithLocalEnv(env.isLocalEnv() ? String.format("http://localhost:%d/%s/%s?op=map", port, web, serverlet) : env.getPath() + "?op=map"); + ServerStarter.browserURLWithLocalEnv(WorkContext.getCurrent().isLocal() ? String.format("http://localhost:%d/%s/%s?op=map", port, web, serverlet) : WorkContext.getCurrent().getPath() + "?op=map"); } } diff --git a/designer-form/src/com/fr/design/parameter/FormParameterReader.java b/designer-form/src/com/fr/design/parameter/FormParameterReader.java index 6c60a97cb9..dbceb3ee34 100644 --- a/designer-form/src/com/fr/design/parameter/FormParameterReader.java +++ b/designer-form/src/com/fr/design/parameter/FormParameterReader.java @@ -17,7 +17,7 @@ public class FormParameterReader extends AbstractParameterReader { public Parameter[] readParameterFromPath(String tplPath) { if (accept(tplPath, ".frm", ".form")) { try { - Form form = FormIO.readForm(FRContext.getCurrentEnv(), tplPath); + Form form = FormIO.readForm(tplPath); return form.getParameters(); } catch (Exception e1) { FRContext.getLogger().error(e1.getMessage(), e1); diff --git a/designer-realize/src/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java b/designer-realize/src/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java index 33dd2893e9..67be7e1d6f 100644 --- a/designer-realize/src/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java +++ b/designer-realize/src/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java @@ -1,7 +1,6 @@ package com.fr.design.mainframe.alphafine.component; import com.bulenkov.iconloader.IconLoader; -import com.fr.base.FRContext; import com.fr.config.MarketConfig; import com.fr.design.DesignerEnvManager; 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.FormIO; import com.fr.general.ComparatorUtils; -import com.fr.log.FineLoggerFactory; import com.fr.general.Inter; import com.fr.general.http.HttpClient; import com.fr.io.TemplateWorkBookIO; import com.fr.io.exporter.ImageExporter; import com.fr.json.JSONException; import com.fr.json.JSONObject; +import com.fr.log.FineLoggerFactory; import com.fr.main.impl.WorkBook; import com.fr.stable.CodeUtils; import com.fr.stable.StringUtils; @@ -507,7 +506,7 @@ public class AlphaFineDialog extends UIDialog { protected BufferedImage doInBackground() { Form form = null; try { - form = FormIO.readForm(FRContext.getCurrentEnv(), fileName); + form = FormIO.readForm(fileName); } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage()); } @@ -539,7 +538,7 @@ public class AlphaFineDialog extends UIDialog { protected BufferedImage doInBackground() { WorkBook workBook = null; try { - workBook = (WorkBook) TemplateWorkBookIO.readTemplateWorkBook(FRContext.getCurrentEnv(), fileName); + workBook = (WorkBook) TemplateWorkBookIO.readTemplateWorkBook(fileName); } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage()); } diff --git a/designer-realize/src/com/fr/design/mainframe/alphafine/search/manager/impl/FileSearchManager.java b/designer-realize/src/com/fr/design/mainframe/alphafine/search/manager/impl/FileSearchManager.java index e1deba46a8..2bbbb36bb7 100644 --- a/designer-realize/src/com/fr/design/mainframe/alphafine/search/manager/impl/FileSearchManager.java +++ b/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; -import com.fr.base.Env; import com.fr.base.FRContext; import com.fr.design.DesignerEnvManager; import com.fr.design.mainframe.alphafine.AlphaFineConstants; @@ -81,13 +80,12 @@ public class FileSearchManager implements AlphaFineSearchProvider { lessModelList.add(new MoreModel(Inter.getLocText("FR-Designer_Templates"))); return lessModelList; } - Env env = FRContext.getCurrentEnv(); fileNodes = new ArrayList<>(); - fileNodes = listTpl(env, ProjectConstants.REPORTLETS_NAME, true); + fileNodes = listTpl(ProjectConstants.REPORTLETS_NAME, true); AlphaFineHelper.checkCancel(); isContainCpt = true; isContainFrm = true; - doSearch(this.searchText, true, env); + doSearch(this.searchText, true); if (stopSearch) { 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)); @@ -109,21 +107,20 @@ public class FileSearchManager implements AlphaFineSearchProvider { } this.filterModelList = new SearchResult(); this.moreModelList = new SearchResult(); - Env env = FRContext.getCurrentEnv(); AlphaFineHelper.checkCancel(); isContainCpt = true; isContainFrm = true; - doSearch(this.searchText, false, env); + doSearch(this.searchText, false); moreModelList.addAll(filterModelList.subList(AlphaFineConstants.SHOW_SIZE, filterModelList.size())); return moreModelList; } - - private void doSearch(String searchText, boolean needMore, Env env) { + + private void doSearch(String searchText, boolean needMore) { for (FileNode node : fileNodes) { boolean isAlreadyContain = false; isAlreadyContain = searchFile(searchText, node, isAlreadyContain, needMore); 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) { return; @@ -150,7 +147,7 @@ public class FileSearchManager implements AlphaFineSearchProvider { * @param node * @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 { 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"); @@ -210,15 +207,14 @@ public class FileSearchManager implements AlphaFineSearchProvider { /** * 获取工作目录下所有符合要求的模板 * - * @param env * @param rootFilePath * @param recurse * @return */ - private List listTpl(Env env, String rootFilePath, boolean recurse) { + private List listTpl(String rootFilePath, boolean recurse) { List fileNodeList = new ArrayList(); try { - listAll(env, rootFilePath, fileNodeList, recurse); + listAll(rootFilePath, fileNodeList, recurse); } catch (Exception e) { FRContext.getLogger().error("file search error: " + e.getMessage(), e); } @@ -228,19 +224,19 @@ public class FileSearchManager implements AlphaFineSearchProvider { /** * 获取当前工作目录下所有模板 * - * @param env * @param rootFilePath * @param nodeList * @param recurse * @throws Exception */ - private void listAll(Env env, String rootFilePath, List nodeList, boolean recurse) throws Exception { - FileNode[] fns = env.getFileOperator().list(rootFilePath); + private void listAll(String rootFilePath, List nodeList, boolean recurse) throws Exception { + + FileNode[] fns = FRContext.getFileOperator().list(rootFilePath); for (int i = 0; i < fns.length; i++) { FileNode fileNode = fns[i]; if (fileNode.isDirectory()) { if (recurse) { - listAll(env, rootFilePath + File.separator + fns[i].getName(), nodeList, true); + listAll(rootFilePath + File.separator + fns[i].getName(), nodeList, true); } else { nodeList.add(fns[i]); } diff --git a/designer-realize/src/com/fr/design/parameter/WorkBookParameterReader.java b/designer-realize/src/com/fr/design/parameter/WorkBookParameterReader.java index ae676f44fd..c678f3156c 100644 --- a/designer-realize/src/com/fr/design/parameter/WorkBookParameterReader.java +++ b/designer-realize/src/com/fr/design/parameter/WorkBookParameterReader.java @@ -17,7 +17,7 @@ public class WorkBookParameterReader extends AbstractParameterReader { public Parameter[] readParameterFromPath(String tplPath) { if (accept(tplPath, ".cpt")) { try { - TemplateWorkBook template = TemplateWorkBookIO.readTemplateWorkBook(FRContext.getCurrentEnv(), tplPath); + TemplateWorkBook template = TemplateWorkBookIO.readTemplateWorkBook(tplPath); return template.getParameters(); } catch (Exception e1) { FRContext.getLogger().error(e1.getMessage(), e1); diff --git a/designer-realize/src/com/fr/start/Designer.java b/designer-realize/src/com/fr/start/Designer.java index d3a9d6306b..348c04d7ce 100644 --- a/designer-realize/src/com/fr/start/Designer.java +++ b/designer-realize/src/com/fr/start/Designer.java @@ -1,9 +1,7 @@ package com.fr.start; import com.fr.base.BaseUtils; -import com.fr.base.Env; import com.fr.base.FRContext; -import com.fr.dav.LocalEnv; import com.fr.design.DesignerEnvManager; import com.fr.design.actions.core.ActionFactory; import com.fr.design.actions.file.WebPreviewUtils; @@ -56,6 +54,7 @@ import com.fr.start.jni.SplashMac; import com.fr.start.module.StartupArgs; import com.fr.start.preload.ImagePreLoader; import com.fr.start.server.ServerTray; +import com.fr.workspace.WorkContext; import javax.swing.JComponent; import javax.swing.JPanel; @@ -104,7 +103,7 @@ public class Designer extends BaseDesigner { //传递启动参数 designerRoot.setSingleton(StartupArgs.class, new StartupArgs(args)); designerRoot.start(); - if (FRContext.getCurrentEnv() instanceof LocalEnv) { + if (WorkContext.getCurrent().isLocal()) { //初始化一下serverTray ServerTray.init(); } @@ -533,11 +532,6 @@ public class Designer extends BaseDesigner { InformationCollector collector = InformationCollector.getInstance(); collector.collectStopTime(); collector.saveXMLFile(); - Env currentEnv = FRContext.getCurrentEnv(); - if (currentEnv == null) { - return; - } - currentEnv.doWhenServerShutDown(); } } From cc1cccf1a225197afda08eadb671cae1a981488e Mon Sep 17 00:00:00 2001 From: hzzz Date: Fri, 15 Jun 2018 21:49:38 +0800 Subject: [PATCH 06/20] auth --- .../com/fr/design/env/RemoteWorkspace.java | 45 ++++++++++++------- 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/designer-base/src/com/fr/design/env/RemoteWorkspace.java b/designer-base/src/com/fr/design/env/RemoteWorkspace.java index 33bb1b4bca..fa732cb10b 100644 --- a/designer-base/src/com/fr/design/env/RemoteWorkspace.java +++ b/designer-base/src/com/fr/design/env/RemoteWorkspace.java @@ -1,62 +1,73 @@ package com.fr.design.env; import com.fr.general.Inter; +import com.fr.report.util.RemoteDesignAuthenticateUtils; import com.fr.workspace.Workspace; import com.fr.workspace.connect.WorkspaceClient; import com.fr.workspace.connect.WorkspaceConnection; +import com.fr.workspace.engine.WorkspaceServerContext; /** * 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.getIp() + ":" + connection.getPort(); 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 RemoteDesignAuthenticateUtils.isRoot(WorkspaceServerContext.currentUsername()); + } catch (Exception e) { + return false; + } + } + @Override public T get(Class type) { - + return client.getPool().get(type); } } From 2395ebd51fc0a707e366fd366405ab1432a41ef3 Mon Sep 17 00:00:00 2001 From: ju Date: Sun, 17 Jun 2018 12:30:32 +0800 Subject: [PATCH 07/20] f --- .../fr/design/env/DesignerWorkspaceInfo.java | 8 +- .../com/fr/design/env/RemoteWorkspace.java | 4 +- designer-base/src/com/fr/env/EnvListPane.java | 2 +- .../src/com/fr/env/RemoteEnvPane.java | 189 +++++---- .../src/com/fr/env/RemoteEnvPane2.java | 377 +++++++++--------- 5 files changed, 309 insertions(+), 271 deletions(-) diff --git a/designer-base/src/com/fr/design/env/DesignerWorkspaceInfo.java b/designer-base/src/com/fr/design/env/DesignerWorkspaceInfo.java index c230602bd2..75a2dfab02 100644 --- a/designer-base/src/com/fr/design/env/DesignerWorkspaceInfo.java +++ b/designer-base/src/com/fr/design/env/DesignerWorkspaceInfo.java @@ -85,12 +85,11 @@ public class DesignerWorkspaceInfo implements XMLable { if (reader.isChildNode()) { String tagName = reader.getTagName(); if ("Connection".equals(tagName)) { - String ip = reader.getAttrAsString("ip", StringUtils.EMPTY); - int port = reader.getAttrAsInt("port", DEFAULT_RPC_PORT); + String url = reader.getAttrAsString("url", StringUtils.EMPTY); String username = reader.getAttrAsString("username", StringUtils.EMPTY); //密码解密 String password = SecurityToolbox.decrypt(reader.getAttrAsString("password", StringUtils.EMPTY)); - this.connection = new WorkspaceConnection(ip, port, username, password); + this.connection = new WorkspaceConnection(url, username, password); } } } @@ -103,8 +102,7 @@ public class DesignerWorkspaceInfo implements XMLable { writer.attr("type", type.toString()); if (this.connection != null) { writer.startTAG("Connection"); - writer.attr("ip", connection.getIp()); - writer.attr("port", connection.getPort()); + writer.attr("url", connection.getUrl()); writer.attr("username", connection.getUserName()); writer.attr("password", SecurityToolbox.encrypt(connection.getPassword())); writer.end(); diff --git a/designer-base/src/com/fr/design/env/RemoteWorkspace.java b/designer-base/src/com/fr/design/env/RemoteWorkspace.java index fa732cb10b..12e13f7384 100644 --- a/designer-base/src/com/fr/design/env/RemoteWorkspace.java +++ b/designer-base/src/com/fr/design/env/RemoteWorkspace.java @@ -5,7 +5,7 @@ import com.fr.report.util.RemoteDesignAuthenticateUtils; import com.fr.workspace.Workspace; import com.fr.workspace.connect.WorkspaceClient; import com.fr.workspace.connect.WorkspaceConnection; -import com.fr.workspace.engine.WorkspaceServerContext; +import com.fr.workspace.server.WorkspaceServerContext; /** * Created by juhaoyu on 2018/6/14. @@ -22,7 +22,7 @@ public class RemoteWorkspace implements Workspace { RemoteWorkspace(WorkspaceClient client, WorkspaceConnection connection) { this.client = client; - this.address = connection.getIp() + ":" + connection.getPort(); + this.address = connection.getUrl(); this.userName = connection.getUserName(); } diff --git a/designer-base/src/com/fr/env/EnvListPane.java b/designer-base/src/com/fr/env/EnvListPane.java index f0d390f620..f93b7da554 100644 --- a/designer-base/src/com/fr/env/EnvListPane.java +++ b/designer-base/src/com/fr/env/EnvListPane.java @@ -59,7 +59,7 @@ public class EnvListPane extends JListControlPane { NameableCreator local = new NameObjectCreator(Inter.getLocText("Env-Local_Directory"), "com/fr/design/images/data/bind/localconnect.png", DesignerWorkspaceInfo.class, LocalEnvPane.class); NameableCreator remote = new NameObjectCreator(Inter.getLocText("Env-Remote_Server"), "com/fr/design/images/data/bind/distanceconnect.png", - DesignerWorkspaceInfo.class, RemoteEnvPane2.class); + DesignerWorkspaceInfo.class, RemoteEnvPane.class); return new NameableCreator[]{local, remote}; } diff --git a/designer-base/src/com/fr/env/RemoteEnvPane.java b/designer-base/src/com/fr/env/RemoteEnvPane.java index 24fabb8dd5..a52308a71a 100644 --- a/designer-base/src/com/fr/env/RemoteEnvPane.java +++ b/designer-base/src/com/fr/env/RemoteEnvPane.java @@ -1,11 +1,10 @@ package com.fr.env; -import com.fr.base.FRContext; import com.fr.design.DesignerEnvManager; import com.fr.design.beans.BasicBeanPane; import com.fr.design.border.UITitledBorder; -import com.fr.design.dialog.InformationWarnPane; import com.fr.design.env.DesignerWorkspaceInfo; +import com.fr.design.env.DesignerWorkspaceType; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.ilable.UILabel; @@ -14,25 +13,45 @@ import com.fr.design.gui.itextfield.UITextField; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.scrollruler.ModLineBorder; -import com.fr.general.ComparatorUtils; import com.fr.general.Inter; -import com.fr.stable.ProductConstants; import com.fr.stable.StringUtils; - -import javax.swing.*; +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.BoxLayout; +import javax.swing.JDialog; +import javax.swing.JFileChooser; +import javax.swing.JPanel; +import javax.swing.JTextPane; +import javax.swing.SwingConstants; +import javax.swing.SwingUtilities; +import javax.swing.SwingWorker; +import javax.swing.ToolTipManager; +import javax.swing.UIManager; import javax.swing.border.EmptyBorder; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; -import java.awt.*; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dialog; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Toolkit; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyEvent; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; import java.io.File; import static com.fr.design.layout.TableLayout.FILL; import static com.fr.design.layout.TableLayout.PREFERRED; +import static com.fr.third.guava.base.Optional.fromNullable; /** * @author yaohwu @@ -41,6 +60,11 @@ public class RemoteEnvPane extends BasicBeanPane { private static final Color TIPS_FONT_COLOR = new Color(0x8f8f92); + private JDialog dialog; + private UILabel message; + private UIButton okButton; + private UIButton cancelButton; + /** * 是否启用 https 勾选框 */ @@ -180,7 +204,7 @@ public class RemoteEnvPane extends BasicBeanPane { // 服务器地址地址 - JPanel configPanel = new JPanel(new BorderLayout()); + final JPanel configPanel = new JPanel(new BorderLayout()); configPanel.setBorder( BorderFactory.createCompoundBorder( new EmptyBorder(15, 0, 0, 0), @@ -222,9 +246,7 @@ public class RemoteEnvPane extends BasicBeanPane { testConnectionButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ev) { - if (testConnection()) { - JOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(RemoteEnvPane.this), Inter.getLocText("Datasource-Connection_successfully")); - } + tryConnectRemoteEnv(); } }); testPanel.add(testConnectionButton); @@ -240,35 +262,33 @@ public class RemoteEnvPane extends BasicBeanPane { @Override public void populateBean(DesignerWorkspaceInfo ob) { - - if (StringUtils.isEmpty(ob.getPath())) { - remoteEnvURL = RemoteEnvURL.createDefaultURL(); - } else { - remoteEnvURL = new RemoteEnvURL(ob.getPath()); - } + WorkspaceConnection connection = ob.getConnection(); + this.remoteEnvURL = Strings.isNullOrEmpty(connection.getUrl()) + ? RemoteEnvURL.createDefaultURL() + : new RemoteEnvURL(connection.getUrl()); fillRemoteEnvURLField(); fillIndividualField(); - httpsCheckbox.setSelected(remoteEnvURL.getHttps()); + httpsCheckbox.setSelected(this.remoteEnvURL.getHttps()); - DesignerEnvManager.getEnvManager().setHttps(remoteEnvURL.getHttps()); - fileChooserButton.setEnabled(remoteEnvURL.getHttps()); + DesignerEnvManager.getEnvManager().setHttps(this.remoteEnvURL.getHttps()); + fileChooserButton.setEnabled(this.remoteEnvURL.getHttps()); updateHttpsConfigPanel(); - - String username = ob.getConnection().getUserName(); - String pwd = ob.getConnection().getPassword(); - this.usernameInput.setText(username == null ? StringUtils.EMPTY : pwd); - this.passwordInput.setText(pwd == null ? StringUtils.EMPTY : pwd); + + this.usernameInput.setText(fromNullable(connection.getUserName()).or(StringUtils.EMPTY)); + this.passwordInput.setText(fromNullable(connection.getPassword()).or(StringUtils.EMPTY)); } @Override public DesignerWorkspaceInfo updateBean() { - - String path = remoteEnvURL.getURL(); - String user = this.usernameInput.getText(); - String password = new String(this.passwordInput.getPassword()); -// return DesignerWorkspaceInfo.createRemote(); - return null; - //return new RemoteEnvConfig(path, user, password); + WorkspaceConnection connection = new WorkspaceConnection( + this.remoteEnvURL.getURL(), + this.usernameInput.getText(), + new String(this.passwordInput.getPassword())); + + DesignerWorkspaceInfo config = new DesignerWorkspaceInfo(); + config.setConnection(connection); + config.setType(DesignerWorkspaceType.Remote); + return config; } @Override @@ -446,50 +466,77 @@ public class RemoteEnvPane extends BasicBeanPane { return inputPanel; } + private void tryConnectRemoteEnv() { + final SwingWorker worker = new SwingWorker() { - private void setHttpsParas() { - System.setProperty("javax.net.ssl.trustStore", this.certPathInput.getText()); - 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()); - } + @Override + protected Void doInBackground() throws Exception { - private boolean testConnection() { - String url = remoteEnvURL.getURL(); - //RemoteEnv env = new RemoteEnv(url, usernameInput.getText(), new String(passwordInput.getPassword())); - boolean connect = false; - try { - if (StringUtils.isNotEmpty(url)) { - if (remoteEnvURL.getHttps()) { - setHttpsParas(); - } -// connect = env.testConnectionWithOutRegisteServer(this); + final DesignerWorkspaceInfo remoteEnv = updateBean(); + WorkContext.getConnector().testConnection(remoteEnv.getConnection()); + return null; } - } 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) { - try { - String remoteVersion = ""; - 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") + "。"; - new InformationWarnPane(info, moreInfo, Inter.getLocText("Tooltips")).show(); - return false; + + @Override + protected void done() { + okButton.setEnabled(true); + try { + get(); + message.setText(Inter.getLocText("Fine-Designer_Basic_Remote_Connect_Successful")); + } catch (Exception e) { + message.setText(Inter.getLocText("Fine-Designer_Basic_Remote_Connect_Failed")); } - } catch (Exception e) { - FRContext.getLogger().error(e.getMessage(), e); } - } - return connect; + }; + worker.execute(); + initMessageDialog(); + okButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + dialog.dispose(); + } + }); + 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); + } + }); + + 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)); } /** diff --git a/designer-base/src/com/fr/env/RemoteEnvPane2.java b/designer-base/src/com/fr/env/RemoteEnvPane2.java index 3b5ff423c8..5f6928ec2c 100644 --- a/designer-base/src/com/fr/env/RemoteEnvPane2.java +++ b/designer-base/src/com/fr/env/RemoteEnvPane2.java @@ -1,192 +1,185 @@ -package com.fr.env; - -import com.fr.design.beans.BasicBeanPane; -import com.fr.design.border.UITitledBorder; -import com.fr.design.env.DesignerWorkspaceInfo; -import com.fr.design.env.DesignerWorkspaceType; -import com.fr.design.gui.ibutton.UIButton; -import com.fr.design.gui.ilable.UILabel; -import com.fr.design.gui.ipasswordfield.UIPassWordField; -import com.fr.design.gui.itextfield.UIIntNumberField; -import com.fr.design.gui.itextfield.UITextField; -import com.fr.design.layout.TableLayout; -import com.fr.design.layout.TableLayoutHelper; -import com.fr.design.utils.gui.GUICoreUtils; -import com.fr.general.Inter; -import com.fr.workspace.WorkContext; -import com.fr.workspace.connect.WorkspaceConnection; - -import javax.swing.*; -import javax.swing.border.EmptyBorder; -import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; - -/** - * 远程环境设置界面,暂时命名为2,待做完功能直接替代掉老的RemoteEnvPane - */ -public class RemoteEnvPane2 extends BasicBeanPane { - - private UITextField hostTextField; - private UIIntNumberField portTextField; - private UITextField usernameTextField; - private UIPassWordField passwordTextField; - private JDialog dialog; - private UILabel message; - private UIButton okButton; - private UIButton cancelButton; - - public RemoteEnvPane2() { - initComponents(); - } - - private void initComponents() { - setLayout(new BorderLayout()); - - JPanel contentPanel = new JPanel(new BorderLayout()); - add(contentPanel, BorderLayout.CENTER); - - contentPanel.setBorder( - 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[] columnSize = new double[]{p, f}; - UIButton testConnectionButton = new UIButton(Inter.getLocText("Fine-Designer_Basic_Remote_Env_Try")); - hostTextField = new UITextField(); - hostTextField.setPlaceholder("192.168.100.200"); - portTextField = new UIIntNumberField(); - portTextField.setPlaceholder("39999"); - JPanel valuePane = TableLayoutHelper.createTableLayoutPane( - new Component[][]{ - {new UILabel(Inter.getLocText("Fine-Designer_Basic_Remote_Env_Host") + ":", SwingConstants.RIGHT), hostTextField}, - {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_Password") + ":", SwingConstants.RIGHT), passwordTextField = new UIPassWordField()}, - {null, GUICoreUtils.createFlowPane(testConnectionButton, FlowLayout.LEFT)} - }, - rowSize, columnSize - ); - testConnectionButton.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - tryConnectRemoteEnv(); - } - }); - contentPanel.add(valuePane, BorderLayout.CENTER); - - message = new UILabel(); - okButton = new UIButton(Inter.getLocText("OK")); - cancelButton = new UIButton(Inter.getLocText("Cancel")); - } - - private void tryConnectRemoteEnv() { - final SwingWorker worker = new SwingWorker() { - - @Override - protected Void doInBackground() throws Exception { - - final DesignerWorkspaceInfo remoteEnv = updateBean(); - WorkContext.getConnector().testConnection(remoteEnv.getConnection()); - return null; - } - - @Override - protected void done() { - okButton.setEnabled(true); - try { - get(); - message.setText(Inter.getLocText("Fine-Designer_Basic_Remote_Connect_Successful")); - } catch (Exception e) { - message.setText(Inter.getLocText("Fine-Designer_Basic_Remote_Connect_Failed")); - } - } - }; - worker.execute(); - initMessageDialog(); - okButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - dialog.dispose(); - } - }); - 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); - } - }); - - 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(RemoteEnvPane2.this), Inter.getLocText("Datasource-Test_Connection"), true); - - dialog.setSize(new Dimension(268, 118)); - okButton.setEnabled(false); - JPanel jp = new JPanel(); - JPanel upPane = new JPanel(); - JPanel downPane = new JPanel(); - UILabel uiLabel = new UILabel(UIManager.getIcon("OptionPane.informationIcon")); - upPane.setLayout(new FlowLayout(FlowLayout.LEFT, 10, 10)); - upPane.add(uiLabel); - upPane.add(message); - downPane.setLayout(new FlowLayout(FlowLayout.CENTER, 6, 0)); - downPane.add(okButton); - downPane.add(cancelButton); - jp.setLayout(new BoxLayout(jp, BoxLayout.Y_AXIS)); - jp.add(upPane); - jp.add(downPane); - dialog.add(jp); - dialog.setResizable(false); - dialog.setLocationRelativeTo(SwingUtilities.getWindowAncestor(RemoteEnvPane2.this)); - } - - @Override - protected String title4PopupWindow() { - return "RemoteEnv"; - } - - @Override - public void populateBean(DesignerWorkspaceInfo config) { - if (config == null) { - return; - } - WorkspaceConnection connection = config.getConnection(); - if (connection != null) { - hostTextField.setText(connection.getIp()); - if (connection.getPort() != 0) { - portTextField.setValue(connection.getPort()); - } - usernameTextField.setText(connection.getUserName()); - passwordTextField.setText(connection.getPassword()); - } - } - - @Override - public DesignerWorkspaceInfo updateBean() { - - DesignerWorkspaceInfo config = new DesignerWorkspaceInfo(); - WorkspaceConnection connection = new WorkspaceConnection(hostTextField.getText(), (int) portTextField.getValue(), usernameTextField.getText(), passwordTextField.getText()); - config.setConnection(connection); - config.setType(DesignerWorkspaceType.Remote); - return config; - } -} +//package com.fr.env; +// +//import com.fr.design.beans.BasicBeanPane; +//import com.fr.design.border.UITitledBorder; +//import com.fr.design.env.DesignerWorkspaceInfo; +//import com.fr.design.env.DesignerWorkspaceType; +//import com.fr.design.gui.ibutton.UIButton; +//import com.fr.design.gui.ilable.UILabel; +//import com.fr.design.gui.ipasswordfield.UIPassWordField; +//import com.fr.design.gui.itextfield.UIIntNumberField; +//import com.fr.design.gui.itextfield.UITextField; +//import com.fr.design.layout.TableLayout; +//import com.fr.design.layout.TableLayoutHelper; +//import com.fr.design.utils.gui.GUICoreUtils; +//import com.fr.general.Inter; +//import com.fr.workspace.WorkContext; +//import com.fr.workspace.connect.WorkspaceConnection; +// +//import javax.swing.*; +//import javax.swing.border.EmptyBorder; +//import java.awt.*; +//import java.awt.event.ActionEvent; +//import java.awt.event.ActionListener; +//import java.awt.event.WindowAdapter; +//import java.awt.event.WindowEvent; +// +///** +// * 远程环境设置界面,暂时命名为2,待做完功能直接替代掉老的RemoteEnvPane +// */ +//public class RemoteEnvPane2 extends BasicBeanPane { +// +// private UITextField urlTextField; +// private UITextField usernameTextField; +// private UIPassWordField passwordTextField; +// private JDialog dialog; +// private UILabel message; +// private UIButton okButton; +// private UIButton cancelButton; +// +// public RemoteEnvPane2() { +// initComponents(); +// } +// +// private void initComponents() { +// setLayout(new BorderLayout()); +// +// JPanel contentPanel = new JPanel(new BorderLayout()); +// add(contentPanel, BorderLayout.CENTER); +// +// contentPanel.setBorder( +// 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}; +// double[] columnSize = new double[]{p, f}; +// UIButton testConnectionButton = new UIButton(Inter.getLocText("Fine-Designer_Basic_Remote_Env_Try")); +// urlTextField = new UITextField(); +// urlTextField.setPlaceholder("http://192.168.100.200/webroot/decision"); +// JPanel valuePane = TableLayoutHelper.createTableLayoutPane( +// new Component[][]{ +// {new UILabel(Inter.getLocText("Fine-Designer_Basic_Remote_Env_Host") + ":", SwingConstants.RIGHT), urlTextField}, +// {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()}, +// {null, GUICoreUtils.createFlowPane(testConnectionButton, FlowLayout.LEFT)} +// }, +// rowSize, columnSize +// ); +// testConnectionButton.addActionListener(new ActionListener() { +// @Override +// public void actionPerformed(ActionEvent e) { +// tryConnectRemoteEnv(); +// } +// }); +// contentPanel.add(valuePane, BorderLayout.CENTER); +// +// message = new UILabel(); +// okButton = new UIButton(Inter.getLocText("OK")); +// cancelButton = new UIButton(Inter.getLocText("Cancel")); +// } +// +// private void tryConnectRemoteEnv() { +// final SwingWorker worker = new SwingWorker() { +// +// @Override +// protected Void doInBackground() throws Exception { +// +// final DesignerWorkspaceInfo remoteEnv = updateBean(); +// WorkContext.getConnector().testConnection(remoteEnv.getConnection()); +// return null; +// } +// +// @Override +// protected void done() { +// okButton.setEnabled(true); +// try { +// get(); +// message.setText(Inter.getLocText("Fine-Designer_Basic_Remote_Connect_Successful")); +// } catch (Exception e) { +// message.setText(Inter.getLocText("Fine-Designer_Basic_Remote_Connect_Failed")); +// } +// } +// }; +// worker.execute(); +// initMessageDialog(); +// okButton.addActionListener(new ActionListener() { +// public void actionPerformed(ActionEvent e) { +// dialog.dispose(); +// } +// }); +// 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); +// } +// }); +// +// 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(RemoteEnvPane2.this), Inter.getLocText("Datasource-Test_Connection"), true); +// +// dialog.setSize(new Dimension(268, 118)); +// okButton.setEnabled(false); +// JPanel jp = new JPanel(); +// JPanel upPane = new JPanel(); +// JPanel downPane = new JPanel(); +// UILabel uiLabel = new UILabel(UIManager.getIcon("OptionPane.informationIcon")); +// upPane.setLayout(new FlowLayout(FlowLayout.LEFT, 10, 10)); +// upPane.add(uiLabel); +// upPane.add(message); +// downPane.setLayout(new FlowLayout(FlowLayout.CENTER, 6, 0)); +// downPane.add(okButton); +// downPane.add(cancelButton); +// jp.setLayout(new BoxLayout(jp, BoxLayout.Y_AXIS)); +// jp.add(upPane); +// jp.add(downPane); +// dialog.add(jp); +// dialog.setResizable(false); +// dialog.setLocationRelativeTo(SwingUtilities.getWindowAncestor(RemoteEnvPane2.this)); +// } +// +// @Override +// protected String title4PopupWindow() { +// return "RemoteEnv"; +// } +// +// @Override +// public void populateBean(DesignerWorkspaceInfo config) { +// if (config == null) { +// return; +// } +// WorkspaceConnection connection = config.getConnection(); +// if (connection != null) { +// urlTextField.setText(connection.getUrl()); +// usernameTextField.setText(connection.getUserName()); +// passwordTextField.setText(connection.getPassword()); +// } +// } +// +// @Override +// public DesignerWorkspaceInfo updateBean() { +// +// DesignerWorkspaceInfo config = new DesignerWorkspaceInfo(); +// WorkspaceConnection connection = new WorkspaceConnection(urlTextField.getText(), usernameTextField.getText(), passwordTextField.getText()); +// config.setConnection(connection); +// config.setType(DesignerWorkspaceType.Remote); +// return config; +// } +//} From a33416fb4c0323d7599f7c40e009244a4e1cf7b9 Mon Sep 17 00:00:00 2001 From: ju Date: Sun, 17 Jun 2018 13:35:01 +0800 Subject: [PATCH 08/20] f --- .../src/com/fr/design/DesignState.java | 6 +- .../src/com/fr/design/DesignerEnvManager.java | 2 +- .../fr/design/mainframe/DesignerFrame.java | 10 +- .../com/fr/design/mainframe/TemplatePane.java | 121 ++++++++++++------ .../src/com/fr/file/FileNodeFILE.java | 4 +- .../src/com/fr/start/EnvSwitcher.java | 15 ++- 6 files changed, 105 insertions(+), 53 deletions(-) diff --git a/designer-base/src/com/fr/design/DesignState.java b/designer-base/src/com/fr/design/DesignState.java index 4bc3de847a..fc7130aa26 100644 --- a/designer-base/src/com/fr/design/DesignState.java +++ b/designer-base/src/com/fr/design/DesignState.java @@ -39,9 +39,9 @@ public class DesignState { public DesignState(ToolBarMenuDockPlus plus) { designState = plus.getMenuState(); - if (WorkContext.getCurrent().isLocal()) { - designState += REMOTE; - } +// if (WorkContext.getCurrent().isLocal()) { +// designState += REMOTE; +// } // isRoot = env != null && env.isRoot(); isAuthority = BaseUtils.isAuthorityEditing(); } diff --git a/designer-base/src/com/fr/design/DesignerEnvManager.java b/designer-base/src/com/fr/design/DesignerEnvManager.java index 564ba9a497..33c3df8bb0 100644 --- a/designer-base/src/com/fr/design/DesignerEnvManager.java +++ b/designer-base/src/com/fr/design/DesignerEnvManager.java @@ -190,7 +190,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { return; } String installHome = StableUtils.getInstallHome(); - if (installHome != null) { + if (installHome != null && !".".equals(installHome)) { String name = Inter.getLocText("FR-Engine_DEFAULT"); String envPath = StableUtils.pathJoin(new String[]{installHome, ProjectConstants.WEBAPP_NAME, ProjectConstants.WEBINF_NAME}); designerEnvManager.putEnv(name, DesignerWorkspaceInfo.createLocal(name, envPath)); diff --git a/designer-base/src/com/fr/design/mainframe/DesignerFrame.java b/designer-base/src/com/fr/design/mainframe/DesignerFrame.java index 7719d06a4a..fb2678bebc 100644 --- a/designer-base/src/com/fr/design/mainframe/DesignerFrame.java +++ b/designer-base/src/com/fr/design/mainframe/DesignerFrame.java @@ -13,7 +13,6 @@ import com.fr.design.actions.core.ActionFactory; import com.fr.design.constants.UIConstants; import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.datapane.TableDataTreePane; -import com.fr.design.env.DesignerWorkspaceInfo; import com.fr.design.event.DesignerOpenedListener; import com.fr.design.event.TargetModifiedEvent; import com.fr.design.event.TargetModifiedListener; @@ -54,6 +53,7 @@ import com.fr.stable.StableUtils; import com.fr.stable.image4j.codec.ico.ICODecoder; import com.fr.stable.project.ProjectConstants; import com.fr.workspace.WorkContext; +import com.fr.workspace.Workspace; import javax.swing.*; import javax.swing.border.MatteBorder; @@ -650,15 +650,15 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta defaultTitleSB.append(" "); // james:标识登录的用户和登录的ENV String envName = DesignerEnvManager.getEnvManager().getCurEnvName(); - DesignerWorkspaceInfo env = DesignerEnvManager.getEnvManager().getWorkspaceInfo(envName); - if (env != null) { - defaultTitleSB.append(WorkContext.getCurrent().getDescription()); + Workspace workspace = WorkContext.getCurrent(); + if (workspace != null) { + defaultTitleSB.append(workspace.getDescription()); if (editingTemplate != null) { String path = editingTemplate.getEditingFILE().getPath(); if (!editingTemplate.getEditingFILE().exists()) { path = FILEFactory.MEM_PREFIX + path; } else if (path.startsWith(ProjectConstants.REPORTLETS_NAME)) { - path = env.getPath() + File.separator + path; + path = workspace.getPath() + File.separator + path; } defaultTitleSB.append(" " + path); } diff --git a/designer-base/src/com/fr/design/mainframe/TemplatePane.java b/designer-base/src/com/fr/design/mainframe/TemplatePane.java index 5a917ce2cd..14084a9fd2 100644 --- a/designer-base/src/com/fr/design/mainframe/TemplatePane.java +++ b/designer-base/src/com/fr/design/mainframe/TemplatePane.java @@ -29,49 +29,63 @@ import java.awt.event.MouseListener; //TODO: august TemplatePane和TemplateTreePane最好合并成一个类 public class TemplatePane extends JPanel implements MouseListener { + private static final long NUM = 1L; + private static int NUM200 = 200; - + public static TemplatePane getInstance() { + return HOLDER.singleton; } - + private static class HOLDER { + private static TemplatePane singleton = new TemplatePane(); } - + private static final long serialVersionUID = 2108412478281713143L; + public static final int HEIGHT = 23;// 最好和日志的高度统一 用同一个变量 + private static javax.swing.Icon leftIcon = BaseUtils.readIcon("/com/fr/design/images/docking/left.png"); - ; + private static javax.swing.Icon rightIcon = BaseUtils.readIcon("/com/fr/design/images/docking/right.png"); - ; + private boolean isExpanded = false; + private UIButton editButton; + private UILabel envLabel; - + private TemplatePane() { + super(); this.initComponents(); this.setFocusable(true); this.addMouseListener(this); isExpanded = DesignerEnvManager.getEnvManager().isTemplateTreePaneExpanded(); - // TemplateTreePane.getInstance().setVisible(isExpanded); + TemplateTreePane.getInstance().setVisible(isExpanded); TemplateTreePane.getInstance().setVisible(true); } - + private void initComponents() { + GeneralContext.addEnvChangedListener(new EnvChangedListener() { + public void envChanged() { + setJLabel(DesignerEnvManager.getEnvManager().getCurEnvName()); } }); this.setLayout(new BorderLayout(25, 0)); editButton = new UIButton(BaseUtils.readIcon("/com/fr/design/images/control/control-center2.png")) { + private static final long serialVersionUID = NUM; - + @Override public Point getToolTipLocation(MouseEvent event) { + return new Point(25, 2); } }; @@ -83,7 +97,9 @@ public class TemplatePane extends JPanel implements MouseListener { this.add(new UILabel(" "), BorderLayout.WEST); this.add(editButton, BorderLayout.EAST); editButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent evt) { + editItems(); } }); @@ -92,35 +108,41 @@ public class TemplatePane extends JPanel implements MouseListener { setJLabel(DesignerEnvManager.getEnvManager().getCurEnvName()); this.add(envLabel, BorderLayout.CENTER); } - + /** * 是否可扩展 * * @return 同上 */ public boolean IsExpanded() { + return this.isExpanded; } - + public void setExpand(boolean b) { + this.isExpanded = b; this.repaint(); } - + private boolean envListOkAction(EnvListPane envListPane) { + final String selectedName = envListPane.updateEnvManager(); DesignerEnvManager envManager = DesignerEnvManager.getEnvManager(); DesignerWorkspaceInfo selectedEnv = envManager.getWorkspaceInfo(selectedName); GeneralContext.fireEnvWillChangeListener(); try { WorkContext.switchTo(DesignerWorkspaceGenerator.generate(selectedEnv), new WorkContextCallback() { + @Override public void fail() { + JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Inter.getLocText(new String[]{"M-SwitchWorkspace", "Failed"})); } - + @Override public void success() { + DesignUtils.refreshDesignerFrame(); } }); @@ -140,61 +162,71 @@ public class TemplatePane extends JPanel implements MouseListener { } return true; } - + private String getDesignerVersion(DesignerWorkspaceInfo selectedEnv) { // return selectedEnv.getDesignerVersion(); throw new UnsupportedOperationException("unsupport now"); } - + /** * 编辑items */ public void editItems() { + final EnvListPane envListPane = new EnvListPane(); final BasicDialog envListDialog = envListPane.showWindow(SwingUtilities.getWindowAncestor(DesignerContext.getDesignerFrame())); - + envListPane.populateEnvManager(envLabel.getText()); envListDialog.addDialogActionListener(new DialogActionAdapter() { + public void doOk() { + envListOkAction(envListPane); } - + public void doCancel() { + envListDialog.setVisible(false); } }); envListDialog.setVisible(true); } - - private void setJLabel(String name) { + private void setJLabel(String name) { + DesignerWorkspaceInfo config = DesignerEnvManager.getEnvManager().getWorkspaceInfo(name); - 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")); - break; + 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")); + break; + } } } + envLabel.setText(name); envLabel.repaint(); } - + @Override public Dimension getPreferredSize() { + return new Dimension(250, HEIGHT); } - + @Override public void paintComponent(Graphics g) { + super.paintComponent(g); paintBackgroundIcon(g); } - + private void paintBackgroundIcon(Graphics g) { + int w = this.getWidth(); int h = this.getHeight(); Graphics2D g2d = (Graphics2D) g; @@ -209,9 +241,9 @@ public class TemplatePane extends JPanel implements MouseListener { g2d.drawLine(w - 1, 2, w - 1, h - 1); Icon icon = !isExpanded ? leftIcon : rightIcon; icon.paintIcon(this, g2d, 4, 4); - + } - + /** * 鼠标点击 * @@ -219,8 +251,9 @@ public class TemplatePane extends JPanel implements MouseListener { */ @Override public void mouseClicked(MouseEvent e) { + } - + /** * 鼠标按下 * @@ -228,6 +261,7 @@ public class TemplatePane extends JPanel implements MouseListener { */ @Override public void mousePressed(MouseEvent e) { + if (e.getX() < NUM200) { isExpanded = !isExpanded; TemplateTreePane.getInstance().setVisible(isExpanded); @@ -235,7 +269,7 @@ public class TemplatePane extends JPanel implements MouseListener { DesignerEnvManager.getEnvManager().setTemplateTreePaneExpanded(isExpanded); } } - + /** * 鼠标放开 * @@ -243,8 +277,9 @@ public class TemplatePane extends JPanel implements MouseListener { */ @Override public void mouseReleased(MouseEvent e) { + } - + /** * 鼠标进入 * @@ -252,8 +287,9 @@ public class TemplatePane extends JPanel implements MouseListener { */ @Override public void mouseEntered(MouseEvent e) { + } - + /** * 鼠标离开 * @@ -261,28 +297,33 @@ public class TemplatePane extends JPanel implements MouseListener { */ @Override public void mouseExited(MouseEvent e) { + } - + /** * 处理异常 */ public void dealEvnExceptionWhenStartDesigner() { + final EnvListPane envListPane = new EnvListPane(); envListPane.populateEnvManager(envLabel.getText()); BasicDialog envListDialog = envListPane.showWindow(SwingUtilities.getWindowAncestor(DesignerContext.getDesignerFrame())); envListDialog.addDialogActionListener(new DialogActionAdapter() { + public void doOk() { + if (!envListOkAction(envListPane)) { System.exit(0); } - + } - + public void doCancel() { + System.exit(0); } }); envListDialog.setVisible(true); } - + } \ No newline at end of file diff --git a/designer-base/src/com/fr/file/FileNodeFILE.java b/designer-base/src/com/fr/file/FileNodeFILE.java index 984e88ec6a..421e7b2a70 100644 --- a/designer-base/src/com/fr/file/FileNodeFILE.java +++ b/designer-base/src/com/fr/file/FileNodeFILE.java @@ -200,7 +200,7 @@ public class FileNodeFILE implements FILE { } try { - return WorkContext.getWorkResource().create(StableUtils.pathJoin(node.getEnvPath(), name)); + return WorkContext.getWorkResource().createFile(StableUtils.pathJoin(node.getEnvPath(), name)); } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); return false; @@ -267,7 +267,7 @@ public class FileNodeFILE implements FILE { } try { - return WorkContext.getWorkResource().create(node.getEnvPath()); + return WorkContext.getWorkResource().createFile(node.getEnvPath()); } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); return false; diff --git a/designer-realize/src/com/fr/start/EnvSwitcher.java b/designer-realize/src/com/fr/start/EnvSwitcher.java index 8e31225013..f96216e32e 100644 --- a/designer-realize/src/com/fr/start/EnvSwitcher.java +++ b/designer-realize/src/com/fr/start/EnvSwitcher.java @@ -13,14 +13,25 @@ import com.fr.workspace.Workspace; public class EnvSwitcher { public void switch2LastEnv() { - try { + String current = DesignerEnvManager.getEnvManager().getCurEnvName(); Workspace workspace = DesignerWorkspaceGenerator.generate(DesignerEnvManager.getEnvManager().getWorkspaceInfo(current)); + if (workspace == null) { + TemplatePane.getInstance().dealEvnExceptionWhenStartDesigner(); + } WorkContext.switchTo(workspace); - } catch (Exception e) { + } catch (Throwable e) { TemplatePane.getInstance().dealEvnExceptionWhenStartDesigner(); } } + /** + * 找不到默认的工作空间时,让用户手动选择一个 + */ + private Workspace chooseWorkspace() { + + return null; + } + } From 63b215df84e6f8c938ff93bb557a61597640d586 Mon Sep 17 00:00:00 2001 From: ju Date: Sun, 17 Jun 2018 15:32:36 +0800 Subject: [PATCH 09/20] f --- .../src/com/fr/design/DesignerEnvManager.java | 5 +- .../fr/design/actions/file/LocalePane.java | 32 ++++---- .../alphafine/AlphaFineConfigManager.java | 2 +- .../design/data/BasicTableDataTreePane.java | 3 +- .../connect/ConnectionComboBoxPanel.java | 3 +- .../connect/ConnectionManagerPane.java | 2 +- .../tabledatapane/ProcedureManagerPane.java | 2 +- .../tabledatapane/TableDataManagerPane.java | 2 +- .../com/fr/design/extra/WebViewDlgHelper.java | 4 +- .../com/fr/design/file/TemplateTreePane.java | 2 +- .../design/formula/FunctionManagerPane.java | 6 +- .../gui/itree/filetree/EnvFileTree.java | 3 +- .../itree/filetree/FileNodeComparator.java | 10 +-- .../gui/itree/filetree/FileTreeIcon.java | 2 +- .../fr/design/mainframe/DesignerFrame.java | 4 +- .../DesignerFrameFileDealerPane.java | 2 +- .../com/fr/design/mainframe/JTemplate.java | 2 +- .../mainframe/toolbar/ToolBarMenuDock.java | 4 +- .../parameter/ParameterManagerPane.java | 2 +- .../RemoteDesignAuthorityManagerAction.java | 74 ++++++++++--------- .../src/com/fr/design/utils/DesignUtils.java | 8 +- .../src/com/fr/file/FILEChooserPane.java | 16 ++-- .../src/com/fr/file/FILEFactory.java | 8 +- .../src/com/fr/file/FileNodeFILE.java | 14 ++-- .../server/FineEmbedServerActivator.java | 6 +- .../chart/DownloadOnlineSourcesHelper.java | 18 ++--- .../actions/server/StyleManagerPane.java | 2 +- .../mainframe/AuthorityToolBarPane.java | 3 +- .../com/fr/design/mainframe/JWorkBook.java | 2 +- .../fr/design/report/share/ShareButton.java | 16 +++- .../EditReportServerParameterPane.java | 2 +- .../fr/design/webattr/WidgetManagerPane.java | 2 +- .../src/com/fr/start/Designer.java | 15 ++-- 33 files changed, 146 insertions(+), 132 deletions(-) diff --git a/designer-base/src/com/fr/design/DesignerEnvManager.java b/designer-base/src/com/fr/design/DesignerEnvManager.java index 33c3df8bb0..6ca4cdd4fa 100644 --- a/designer-base/src/com/fr/design/DesignerEnvManager.java +++ b/designer-base/src/com/fr/design/DesignerEnvManager.java @@ -190,9 +190,10 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { return; } String installHome = StableUtils.getInstallHome(); - if (installHome != null && !".".equals(installHome)) { + if (installHome != null) { String name = Inter.getLocText("FR-Engine_DEFAULT"); - String envPath = StableUtils.pathJoin(new String[]{installHome, ProjectConstants.WEBAPP_NAME, ProjectConstants.WEBINF_NAME}); +// String envPath = StableUtils.pathJoin(new String[]{installHome, ProjectConstants.WEBAPP_NAME, ProjectConstants.WEBINF_NAME}); + String envPath = "/Users/juhaoyu/finereport/finereport-maven/env/webroot/WEB-INF"; designerEnvManager.putEnv(name, DesignerWorkspaceInfo.createLocal(name, envPath)); designerEnvManager.setCurEnvName(name); } diff --git a/designer-base/src/com/fr/design/actions/file/LocalePane.java b/designer-base/src/com/fr/design/actions/file/LocalePane.java index b17e66e738..dee28c6c1c 100644 --- a/designer-base/src/com/fr/design/actions/file/LocalePane.java +++ b/designer-base/src/com/fr/design/actions/file/LocalePane.java @@ -10,9 +10,9 @@ import com.fr.design.gui.frpane.UITabbedPane; import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.itextfield.UITextField; import com.fr.file.filetree.FileNode; -import com.fr.general.Env; import com.fr.general.GeneralUtils; import com.fr.general.Inter; +import com.fr.log.FineLoggerFactory; import com.fr.stable.ArrayUtils; import com.fr.stable.StableUtils; import com.fr.stable.bridge.StableFactory; @@ -27,6 +27,7 @@ import javax.swing.table.TableRowSorter; import java.awt.*; import java.io.ByteArrayInputStream; import java.io.InputStream; +import java.io.OutputStream; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; @@ -205,8 +206,8 @@ public class LocalePane extends BasicPane { for (String key : sortKeys) { Vector vector = new Vector(); vector.add(key); - for (int i = 0; i < list.size(); i ++) { - vector.add(list.get(i).getProperty(key)); + for (Properties aList : list) { + vector.add(aList.getProperty(key)); } customTableModel.addRow(vector); } @@ -218,8 +219,7 @@ public class LocalePane extends BasicPane { */ public void save() { - Env env = FRContext.getCurrentEnv(); - if (env == null) { + if (WorkContext.getCurrent() == null) { return; } if (customTable.getCellEditor() == null) { @@ -232,17 +232,17 @@ public class LocalePane extends BasicPane { for (int j = 0, rowCount = customTableModel.getRowCount(); j < rowCount; j ++) { properties.setProperty(GeneralUtils.objectToString(customTableModel.getValueAt(j, 0)), GeneralUtils.objectToString(customTableModel.getValueAt(j, i))); } - -// OutputStream out = null; -// try { -// out = env.writeBean(PREFIX + fileName + ".properties", ProjectConstants.LOCALE_NAME); -// properties.store(out, null); -// -// out.flush(); -// out.close(); -// } catch (Exception e) { -// FineLoggerFactory.getLogger().info(e.getMessage()); -// } + + OutputStream out = null; + try { + out = FRContext.getCommonOperator().writeBean(PREFIX + fileName + ".properties", ProjectConstants.LOCALE_NAME); + properties.store(out, null); + + out.flush(); + out.close(); + } catch (Exception e) { + FineLoggerFactory.getLogger().info(e.getMessage()); + } } } diff --git a/designer-base/src/com/fr/design/actions/help/alphafine/AlphaFineConfigManager.java b/designer-base/src/com/fr/design/actions/help/alphafine/AlphaFineConfigManager.java index 1e2308f37c..7c591019a5 100644 --- a/designer-base/src/com/fr/design/actions/help/alphafine/AlphaFineConfigManager.java +++ b/designer-base/src/com/fr/design/actions/help/alphafine/AlphaFineConfigManager.java @@ -75,7 +75,7 @@ public class AlphaFineConfigManager implements XMLable { public static boolean isALPHALicAvailable() { - return FRContext.getCurrentEnv() != null && VT4FR.AlphaFine.isSupport(); + return FRContext.getCommonOperator() != null && VT4FR.AlphaFine.isSupport(); } @Override diff --git a/designer-base/src/com/fr/design/data/BasicTableDataTreePane.java b/designer-base/src/com/fr/design/data/BasicTableDataTreePane.java index 92f02d5f4f..94b142f32e 100644 --- a/designer-base/src/com/fr/design/data/BasicTableDataTreePane.java +++ b/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.NameObject; import com.fr.stable.StringUtils; +import com.fr.workspace.WorkContext; import javax.swing.*; 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) { // august:BUG 9344 addMenuDef.setEnabled(true); - connectionTableAction.setEnabled(FRContext.getCurrentEnv() != null && FRContext.getCurrentEnv().isRoot()); + connectionTableAction.setEnabled(WorkContext.getCurrent() != null && WorkContext.getCurrent().isRoot()); if (op == null || op.interceptButtonEnabled()) { addMenuDef.setEnabled(false); editAction.setEnabled(false); diff --git a/designer-base/src/com/fr/design/data/datapane/connect/ConnectionComboBoxPanel.java b/designer-base/src/com/fr/design/data/datapane/connect/ConnectionComboBoxPanel.java index d83efece57..9976bd94d6 100644 --- a/designer-base/src/com/fr/design/data/datapane/connect/ConnectionComboBoxPanel.java +++ b/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.transaction.Configurations; import com.fr.transaction.Worker; +import com.fr.workspace.WorkContext; import javax.swing.*; import java.awt.event.ItemEvent; @@ -127,7 +128,7 @@ public class ConnectionComboBoxPanel extends ItemEditableComboBoxPanel { * @param connection 数据库链接 */ public void populate(Connection connection) { - editButton.setEnabled(FRContext.getCurrentEnv().isRoot()); + editButton.setEnabled(WorkContext.getCurrent().isRoot()); if (connection instanceof NameDatabaseConnection) { this.setSelectedItem(((NameDatabaseConnection) connection).getName()); } else { diff --git a/designer-base/src/com/fr/design/data/datapane/connect/ConnectionManagerPane.java b/designer-base/src/com/fr/design/data/datapane/connect/ConnectionManagerPane.java index aa0980ad58..11ca921b7a 100644 --- a/designer-base/src/com/fr/design/data/datapane/connect/ConnectionManagerPane.java +++ b/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) { -// 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()); this.connectionListPane.populate(datasourceManager); } diff --git a/designer-base/src/com/fr/design/data/tabledata/tabledatapane/ProcedureManagerPane.java b/designer-base/src/com/fr/design/data/tabledata/tabledatapane/ProcedureManagerPane.java index e178b63b42..2a43766fb7 100644 --- a/designer-base/src/com/fr/design/data/tabledata/tabledatapane/ProcedureManagerPane.java +++ b/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) { //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()); this.procedureListPane.populate(procedureConfig); } diff --git a/designer-base/src/com/fr/design/data/tabledata/tabledatapane/TableDataManagerPane.java b/designer-base/src/com/fr/design/data/tabledata/tabledatapane/TableDataManagerPane.java index 76eeeb0048..654d592a7c 100644 --- a/designer-base/src/com/fr/design/data/tabledata/tabledatapane/TableDataManagerPane.java +++ b/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) { //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()); this.tableDataPane.populate(tableDataConfig); } diff --git a/designer-base/src/com/fr/design/extra/WebViewDlgHelper.java b/designer-base/src/com/fr/design/extra/WebViewDlgHelper.java index d63e2075e9..e17f2a41ff 100644 --- a/designer-base/src/com/fr/design/extra/WebViewDlgHelper.java +++ b/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 SHOP_SCRIPTS = "shop_scripts"; 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 ENV_VERSION = "ENV_VERSION"; @@ -52,7 +52,7 @@ public class WebViewDlgHelper { GeneralContext.addEnvChangedListener(new EnvChangedListener() { @Override public void envChanged() { - installHome = FRContext.getCurrentEnv().getWebReportPath(); + installHome = FRContext.getCommonOperator().getWebReportPath(); } }); } diff --git a/designer-base/src/com/fr/design/file/TemplateTreePane.java b/designer-base/src/com/fr/design/file/TemplateTreePane.java index 78905c32ac..948ef528ce 100644 --- a/designer-base/src/com/fr/design/file/TemplateTreePane.java +++ b/designer-base/src/com/fr/design/file/TemplateTreePane.java @@ -98,7 +98,7 @@ public class TemplateTreePane extends JPanel implements FileOperations { * 刷新 */ public void refreshDockingView() { - reportletsTree.setFileNodeFilter(new IOFileNodeFilter(FRContext.getCurrentEnv().getSupportedTypes())); + reportletsTree.setFileNodeFilter(new IOFileNodeFilter(FRContext.getFileOperator().getSupportedTypes())); reportletsTree.refreshEnv(); } diff --git a/designer-base/src/com/fr/design/formula/FunctionManagerPane.java b/designer-base/src/com/fr/design/formula/FunctionManagerPane.java index 3557591901..295917a3aa 100644 --- a/designer-base/src/com/fr/design/formula/FunctionManagerPane.java +++ b/designer-base/src/com/fr/design/formula/FunctionManagerPane.java @@ -1,6 +1,5 @@ package com.fr.design.formula; -import com.fr.base.FRContext; import com.fr.design.beans.BasicBeanPane; import com.fr.design.data.tabledata.tabledatapane.ClassNameSelectPane; import com.fr.design.dialog.BasicDialog; @@ -22,6 +21,7 @@ import com.fr.general.NameObject; import com.fr.stable.Nameable; import com.fr.stable.project.ProjectConstants; import com.fr.stable.script.FunctionDef; +import com.fr.workspace.WorkContext; import javax.swing.*; import java.awt.*; @@ -64,7 +64,7 @@ public class FunctionManagerPane extends BasicPane { */ public void populate(FunctionConfig functionManager) { //todo 原来界面上显示的xml路径 -// this.functionTextField.setText(FRContext.getCurrentEnv().getPath() + File.separator +// this.functionTextField.setText(WorkContext.getCurrent().getPath() + File.separator // + ProjectConstants.RESOURCES_NAME // + File.separator + functionManager.fileName()); @@ -162,7 +162,7 @@ public class FunctionManagerPane extends BasicPane { northPane.add(descriptionArea); 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)); JPanel descriptionPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); //Description Pane diff --git a/designer-base/src/com/fr/design/gui/itree/filetree/EnvFileTree.java b/designer-base/src/com/fr/design/gui/itree/filetree/EnvFileTree.java index 0eae91deec..d73191e738 100644 --- a/designer-base/src/com/fr/design/gui/itree/filetree/EnvFileTree.java +++ b/designer-base/src/com/fr/design/gui/itree/filetree/EnvFileTree.java @@ -11,6 +11,7 @@ import com.fr.general.ComparatorUtils; import com.fr.general.Inter; import com.fr.stable.CoreConstants; import com.fr.stable.StableUtils; +import com.fr.workspace.WorkContext; import javax.swing.*; import javax.swing.tree.DefaultTreeCellRenderer; @@ -189,7 +190,7 @@ public class EnvFileTree extends RefreshableJTree { FileNode[] res_fns = null; try { - res_fns = FRContext.getCurrentEnv() == null ? new FileNode[0] : FRContext.getFileOperator().list(filePath); + res_fns = WorkContext.getCurrent() == null ? new FileNode[0] : FRContext.getFileOperator().list(filePath); } catch (Exception e) { FRContext.getLogger().error(e.getMessage(), e); } diff --git a/designer-base/src/com/fr/design/gui/itree/filetree/FileNodeComparator.java b/designer-base/src/com/fr/design/gui/itree/filetree/FileNodeComparator.java index 2be0865023..092374ac37 100644 --- a/designer-base/src/com/fr/design/gui/itree/filetree/FileNodeComparator.java +++ b/designer-base/src/com/fr/design/gui/itree/filetree/FileNodeComparator.java @@ -1,7 +1,7 @@ package com.fr.design.gui.itree.filetree; +import com.fr.base.operator.file.LocalFileOperator; import com.fr.file.filetree.FileNode; -import com.fr.general.adaptor.WorkspaceAdaptor; import java.util.Comparator; @@ -59,13 +59,13 @@ public class FileNodeComparator implements Comparator { private int groupByFileType(FileNode nameNode1, FileNode nameNode2, int i) { - if (i < WorkspaceAdaptor.FILE_TYPE.length) { - if (nameNode1.isFileType(WorkspaceAdaptor.FILE_TYPE[i])) - if (nameNode2.isFileType(WorkspaceAdaptor.FILE_TYPE[i])) + if (i < LocalFileOperator.FILE_TYPE.length) { + if (nameNode1.isFileType(LocalFileOperator.FILE_TYPE[i])) + if (nameNode2.isFileType(LocalFileOperator.FILE_TYPE[i])) return nameNode1.getName().toLowerCase().compareTo(nameNode2.getName().toLowerCase()); else return-1; - else if (nameNode2.isFileType(WorkspaceAdaptor.FILE_TYPE[i])) + else if (nameNode2.isFileType(LocalFileOperator.FILE_TYPE[i])) return 1; else{ return groupByFileType(nameNode1, nameNode2, i+1); diff --git a/designer-base/src/com/fr/design/gui/itree/filetree/FileTreeIcon.java b/designer-base/src/com/fr/design/gui/itree/filetree/FileTreeIcon.java index b6ea37817a..3d459ceccd 100644 --- a/designer-base/src/com/fr/design/gui/itree/filetree/FileTreeIcon.java +++ b/designer-base/src/com/fr/design/gui/itree/filetree/FileTreeIcon.java @@ -115,7 +115,7 @@ public class FileTreeIcon { } 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 (WorkContext.getCurrent().isLocal()) { File ff = new File(path); if (ff.exists()) { diff --git a/designer-base/src/com/fr/design/mainframe/DesignerFrame.java b/designer-base/src/com/fr/design/mainframe/DesignerFrame.java index fb2678bebc..5e141310f5 100644 --- a/designer-base/src/com/fr/design/mainframe/DesignerFrame.java +++ b/designer-base/src/com/fr/design/mainframe/DesignerFrame.java @@ -837,8 +837,8 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta public void openTemplate(FILE tplFile) { // 测试连接,如果连接失败,则提示 try { - if (FRContext.getCurrentEnv() != null - && !FRContext.getCurrentEnv().testServerConnectionWithOutShowMessagePane()) { + if (FRContext.getCommonOperator() != null + && !FRContext.getCommonOperator().testServerConnectionWithOutShowMessagePane()) { JOptionPane.showMessageDialog( DesignerContext.getDesignerFrame(), Inter.getLocText(new String[]{"FR-Chart-Server_disconnected", "FR-Server-Design_template_unopened"}, new String[]{ diff --git a/designer-base/src/com/fr/design/mainframe/DesignerFrameFileDealerPane.java b/designer-base/src/com/fr/design/mainframe/DesignerFrameFileDealerPane.java index 6755965bbb..3bdc66923e 100644 --- a/designer-base/src/com/fr/design/mainframe/DesignerFrameFileDealerPane.java +++ b/designer-base/src/com/fr/design/mainframe/DesignerFrameFileDealerPane.java @@ -265,7 +265,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt @Override public void stateChange() { //当前环境为远程环境时 - if (FRContext.getCurrentEnv() != null) { + if (FRContext.getCommonOperator() != null) { //当前环境为本地环境时 if (selectedOperation.getSelectedTemplatePath() != null) { openReportAction.setEnabled(true); diff --git a/designer-base/src/com/fr/design/mainframe/JTemplate.java b/designer-base/src/com/fr/design/mainframe/JTemplate.java index f39775ba42..eccaddeaa8 100644 --- a/designer-base/src/com/fr/design/mainframe/JTemplate.java +++ b/designer-base/src/com/fr/design/mainframe/JTemplate.java @@ -525,7 +525,7 @@ public abstract class JTemplate> } //检查一下连接是否成功 try { - if (FRContext.getCurrentEnv() != null && !FRContext.getCurrentEnv().testServerConnectionWithOutShowMessagePane()) { + if (FRContext.getCommonOperator() != null && !FRContext.getCommonOperator().testServerConnectionWithOutShowMessagePane()) { //连接不成功,提示 JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Inter.getLocText(new String[]{"server_disconnected", "template_unsaved"}, new String[]{",", "!"}) diff --git a/designer-base/src/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java b/designer-base/src/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java index 45c0e1e6d3..11f61beb2a 100644 --- a/designer-base/src/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java +++ b/designer-base/src/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java @@ -217,7 +217,7 @@ public abstract class ToolBarMenuDock { menuList.addAll(Arrays.asList(menuDefs)); // 添加服务器菜单 - if (FRContext.getCurrentEnv() != null && FRContext.getCurrentEnv().isRoot()) { + if (WorkContext.getCurrent() != null && WorkContext.getCurrent().isRoot()) { menuList.add(createServerMenuDef(plus)); } @@ -435,7 +435,7 @@ public abstract class ToolBarMenuDock { private boolean shouldShowRemotePermission() { - return WorkContext.getCurrent() != null && !WorkContext.getCurrent().isLocal() && FRContext.getCurrentEnv().isRoot(); + return WorkContext.getCurrent() != null && !WorkContext.getCurrent().isLocal() && WorkContext.getCurrent().isRoot(); } private boolean shouldShowPlugin() { diff --git a/designer-base/src/com/fr/design/parameter/ParameterManagerPane.java b/designer-base/src/com/fr/design/parameter/ParameterManagerPane.java index 91a994de45..cd68f78cd6 100644 --- a/designer-base/src/com/fr/design/parameter/ParameterManagerPane.java +++ b/designer-base/src/com/fr/design/parameter/ParameterManagerPane.java @@ -39,7 +39,7 @@ public class ParameterManagerPane extends BasicPane { public void populate(Parameter[] parameters) { //todo 原来界面上显示的xml路径 -// this.parameterTextField.setText(FRContext.getCurrentEnv().getPath() + File.separator + +// this.parameterTextField.setText(WorkContext.getCurrent().getPath() + File.separator + // ProjectConstants.RESOURCES_NAME + // File.separator + configManager.fileName()); this.parameterArrayPane.populate(parameters); diff --git a/designer-base/src/com/fr/design/remote/action/RemoteDesignAuthorityManagerAction.java b/designer-base/src/com/fr/design/remote/action/RemoteDesignAuthorityManagerAction.java index 302e838fa7..e8cb2a207e 100644 --- a/designer-base/src/com/fr/design/remote/action/RemoteDesignAuthorityManagerAction.java +++ b/designer-base/src/com/fr/design/remote/action/RemoteDesignAuthorityManagerAction.java @@ -3,9 +3,14 @@ package com.fr.design.remote.action; import com.fr.base.BaseUtils; import com.fr.design.actions.UpdateAction; import com.fr.design.dialog.BasicDialog; +import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.mainframe.DesignerContext; import com.fr.design.remote.ui.AuthorityManagerPane; +import com.fr.env.operator.authority.AuthorityOperator; import com.fr.general.Inter; +import com.fr.log.FineLoggerFactory; +import com.fr.report.DesignAuthority; +import com.fr.workspace.WorkContext; import java.awt.event.ActionEvent; @@ -27,39 +32,42 @@ public class RemoteDesignAuthorityManagerAction extends UpdateAction { final AuthorityManagerPane managerPane = new AuthorityManagerPane(); BasicDialog dialog = managerPane.showWindow(DesignerContext.getDesignerFrame()); - -// if (!FRContext.getCurrentEnv().isLocalEnv()) { -// try { -// // 远程设计获取全部设计成员的权限列表 -// DesignAuthority[] authorities = EnvProxy.get(AuthorityOperator.class).getAuthorities(); -// if (authorities != null && authorities.length != 0) { -// managerPane.populate(authorities); -// } -// } catch (Exception exception) { -// FineLoggerFactory.getLogger().error(exception.getMessage(), exception); -// } -// } -// -// dialog.addDialogActionListener(new DialogActionAdapter() { -// @Override -// public void doOk() { -// DesignAuthority[] authorities = managerPane.update(); -// if (!FRContext.getCurrentEnv().isLocalEnv()) { -// boolean success = false; -// try { -// success = EnvProxy.get(AuthorityOperator.class).updateAuthorities(authorities); -// } catch (Exception e) { -// FineLoggerFactory.getLogger().error(e.getMessage(), e); -// } -// FRContext.getLogger().info("update remote design authority: " + success); -// } -// } -// -// @Override -// public void doCancel() { -// super.doCancel(); -// } -// }); + + if (!WorkContext.getCurrent().isLocal()) { + try { + // 远程设计获取全部设计成员的权限列表 + DesignAuthority[] authorities = WorkContext.getCurrent().get(AuthorityOperator.class).getAuthorities(); + if (authorities != null && authorities.length != 0) { + managerPane.populate(authorities); + } + } catch (Exception exception) { + FineLoggerFactory.getLogger().error(exception.getMessage(), exception); + } + } + + dialog.addDialogActionListener(new DialogActionAdapter() { + + @Override + public void doOk() { + + DesignAuthority[] authorities = managerPane.update(); + if (!WorkContext.getCurrent().isLocal()) { + boolean success = false; + try { + success = WorkContext.getCurrent().get(AuthorityOperator.class).updateAuthorities(authorities); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + FineLoggerFactory.getLogger().info("update remote design authority: " + success); + } + } + + @Override + public void doCancel() { + + super.doCancel(); + } + }); dialog.setModal(true); dialog.setVisible(true); } diff --git a/designer-base/src/com/fr/design/utils/DesignUtils.java b/designer-base/src/com/fr/design/utils/DesignUtils.java index 499f369371..75802497d8 100644 --- a/designer-base/src/com/fr/design/utils/DesignUtils.java +++ b/designer-base/src/com/fr/design/utils/DesignUtils.java @@ -304,12 +304,12 @@ public class DesignUtils { try { if (Utils.isEmbeddedParameter(postfixOfUri)) { String time = Calendar.getInstance().getTime().toString().replaceAll(" ", ""); -// boolean isUserPrivilege = FRContext.getCurrentEnv()).writePrivilegeMap(time, postfixOfUri); +// boolean isUserPrivilege = FRContext.getCommonOperator()).writePrivilegeMap(time, postfixOfUri); boolean isUserPrivilege = false; - postfixOfUri = isUserPrivilege ? postfixOfUri + "&fr_check_url=" + time + "&id=" + FRContext.getCurrentEnv().getUserID() : postfixOfUri; + postfixOfUri = isUserPrivilege ? postfixOfUri + "&fr_check_url=" + time + "&id=" + FRContext.getCommonOperator().getUserID() : postfixOfUri; } // 加参数给远程设计校验权限。 - String design = JwtUtils.createDefaultJWT(FRContext.getCurrentEnv().getUser()); + String design = JwtUtils.createDefaultJWT(FRContext.getCommonOperator().getUser()); postfixOfUri = postfixOfUri + "&design=" + design; String urlPath = getWebBrowserPath(); @@ -331,7 +331,7 @@ public class DesignUtils { } private static String getWebBrowserPath() { - String urlPath = FRContext.getCurrentEnv().getPath(); + String urlPath = WorkContext.getCurrent().getPath(); DesignerEnvProcessor processor = ExtraDesignClassManager.getInstance().getSingle(DesignerEnvProcessor.XML_TAG); if (processor != null) { //cas访问的时候, url要处理下. diff --git a/designer-base/src/com/fr/file/FILEChooserPane.java b/designer-base/src/com/fr/file/FILEChooserPane.java index 24e191bc0c..c36af8365b 100644 --- a/designer-base/src/com/fr/file/FILEChooserPane.java +++ b/designer-base/src/com/fr/file/FILEChooserPane.java @@ -3,6 +3,7 @@ package com.fr.file; import com.fr.base.BaseUtils; import com.fr.base.FRContext; import com.fr.base.extension.FileExtension; +import com.fr.base.operator.file.LocalFileOperator; import com.fr.design.DesignerEnvManager; import com.fr.design.actions.UpdateAction; import com.fr.design.dialog.BasicPane; @@ -25,7 +26,6 @@ import com.fr.file.filter.FILEFilter; import com.fr.general.ComparatorUtils; import com.fr.general.GeneralContext; import com.fr.general.Inter; -import com.fr.general.adaptor.WorkspaceAdaptor; import com.fr.log.FineLoggerFactory; import com.fr.stable.CoreConstants; import com.fr.stable.OperatingSystem; @@ -545,10 +545,10 @@ public class FILEChooserPane extends BasicPane { return; } if (editing == null || !editing.isChartBook()) { - String[] fileSuffix_local = WorkspaceAdaptor.FILE_TYPE; + String[] fileSuffix_local = LocalFileOperator.FILE_TYPE; EnumSet fileExtensions = EnumSet.of(FileExtension.CPT, FileExtension.CPTX, FileExtension.FRM, FileExtension.FRMX, FileExtension.CHT); if (type == JFileChooser.OPEN_DIALOG) { - if (FRContext.getCurrentEnv().isSupportLocalFileOperate()) { //本地连接 + if (FRContext.getFileOperator().isSupportLocalFileOperate()) { //本地连接 this.addChooseFILEFilter(new ChooseFileFilter(fileSuffix_local, appName + Inter.getLocText(new String[]{"FR-App-Report_Template", "FR-App-All_File"}))); } else { 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 - if (FRContext.getCurrentEnv().isSupportLocalFileOperate()) { //本地连接 + if (FRContext.getFileOperator().isSupportLocalFileOperate()) { //本地连接 this.addChooseFILEFilter(new ChooseFileFilter(FileExtension.XLS, Inter.getLocText("Import-Excel_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) { defaultComboBoxModel.addElement(aFilterList); } - if (FRContext.getCurrentEnv().isSupportLocalFileOperate()) { //本地连接 + if (FRContext.getFileOperator().isSupportLocalFileOperate()) { //本地连接 if (!showWebReport) { defaultComboBoxModel.addElement(Inter.getLocText("FR-Utils-App_AllFiles") + "(*.*)"); } @@ -786,10 +786,10 @@ public class FILEChooserPane extends BasicPane { } if (FILEChooserPane.this.showWebReport) { // webReportFILE = new FileFILE(new - // File(FRContext.getCurrentEnv().getWebReportPath())); - webReportFILE = new FileNodeFILE(FRContext.getCurrentEnv().getWebReportPath()); + // File(FRContext.getCommonOperator().getWebReportPath())); + webReportFILE = new FileNodeFILE(FRContext.getCommonOperator().getWebReportPath()); // String webReportPath = - // FRContext.getCurrentEnv().getWebReportPath(); + // FRContext.getCommonOperator().getWebReportPath(); // String webReportParentPath = new // File(webReportPath).getParent(); // webReportFILE = new FileNodeFILE(new FileNode("WebReport", diff --git a/designer-base/src/com/fr/file/FILEFactory.java b/designer-base/src/com/fr/file/FILEFactory.java index 0fd81de23f..d8e0939b99 100644 --- a/designer-base/src/com/fr/file/FILEFactory.java +++ b/designer-base/src/com/fr/file/FILEFactory.java @@ -2,6 +2,7 @@ package com.fr.file; import com.fr.base.FRContext; import com.fr.file.filetree.FileNode; +import com.fr.workspace.WorkContext; public class FILEFactory { public static final String MEM_PREFIX = "mem://"; @@ -18,7 +19,8 @@ public class FILEFactory { * 也有可能就是一个普通的路径d:/foo/bar */ public static FILE createFILE(String path) { - String envPath = FRContext.getCurrentEnv().getPath().replaceAll("/", "\\\\"); + + String envPath = WorkContext.getCurrent().getPath().replaceAll("/", "\\\\"); if (path == null) { return null; } else if (path.startsWith(MEM_PREFIX)) { @@ -29,7 +31,7 @@ public class FILEFactory { return new FileNodeFILE(new FileNode(path.substring(envPath.length() + 1), false)); } else if (path.startsWith(WEBREPORT_PREFIX)) { return new FileNodeFILE(new FileNode(path.substring(WEBREPORT_PREFIX.length()), false), - FRContext.getCurrentEnv().getWebReportPath()); + FRContext.getCommonOperator().getWebReportPath()); } else if (path.startsWith(FILE_PREFIX)) { return new FileFILE(new java.io.File(path.substring(FILE_PREFIX.length()))); } else { @@ -46,7 +48,7 @@ public class FILEFactory { return new FileNodeFILE(new FileNode(path.substring(ENV_PREFIX.length()), true)); } else if (path.startsWith(WEBREPORT_PREFIX)) { return new FileNodeFILE(new FileNode(path.substring(WEBREPORT_PREFIX.length()), true), - FRContext.getCurrentEnv().getWebReportPath()); + FRContext.getCommonOperator().getWebReportPath()); } else if (path.startsWith(FILE_PREFIX)) { return new FileFILE(new java.io.File(path.substring(FILE_PREFIX.length()))); } else { diff --git a/designer-base/src/com/fr/file/FileNodeFILE.java b/designer-base/src/com/fr/file/FileNodeFILE.java index 421e7b2a70..aab99ab208 100644 --- a/designer-base/src/com/fr/file/FileNodeFILE.java +++ b/designer-base/src/com/fr/file/FileNodeFILE.java @@ -37,12 +37,12 @@ public class FileNodeFILE implements FILE { this.node = new FileNode(StableUtils.pathJoin(new String[]{ parentDir, name }), isDir); - this.envPath = FRContext.getCurrentEnv().getPath(); + this.envPath = WorkContext.getCurrent().getPath(); } public FileNodeFILE(FileNode node) { this.node = node; - this.envPath = FRContext.getCurrentEnv().getPath(); + this.envPath = WorkContext.getCurrent().getPath(); } public FileNodeFILE(String envPath) { @@ -61,7 +61,7 @@ public class FileNodeFILE implements FILE { * @return 返回后缀 */ public String prefix() { - if (ComparatorUtils.equals(getEnvPath(), FRContext.getCurrentEnv().getWebReportPath())) { + if (ComparatorUtils.equals(getEnvPath(), FRContext.getCommonOperator().getWebReportPath())) { return FILEFactory.WEBREPORT_PREFIX; } return FILEFactory.ENV_PREFIX; @@ -218,7 +218,7 @@ public class FileNodeFILE implements FILE { } try { - return FRContext.getCurrentEnv().fileLocked(node.getEnvPath()); + return FRContext.getCommonOperator().fileLocked(node.getEnvPath()); } catch (Exception e) { FRContext.getLogger().error(e.getMessage(), e); return false; @@ -253,7 +253,7 @@ public class FileNodeFILE implements FILE { * @return 是报表当前环境返回true */ public boolean isCurrentEnv() { - return ComparatorUtils.equals(FRContext.getCurrentEnv().getPath(), envPath); + return ComparatorUtils.equals(WorkContext.getCurrent().getPath(), envPath); } /** @@ -313,7 +313,7 @@ public class FileNodeFILE implements FILE { if (!envPath.startsWith(ProjectConstants.REPORTLETS_NAME)) { return null; } - return FRContext.getCurrentEnv().writeBean( + return FRContext.getCommonOperator().writeBean( envPath.substring(ProjectConstants.REPORTLETS_NAME.length() + 1), ProjectConstants.REPORTLETS_NAME ); @@ -335,7 +335,7 @@ public class FileNodeFILE implements FILE { return; } - FRContext.getCurrentEnv().unlockTemplate( + FRContext.getCommonOperator().unlockTemplate( envPath.substring(ProjectConstants.REPORTLETS_NAME.length() + 1)); } diff --git a/designer-base/src/com/fr/start/server/FineEmbedServerActivator.java b/designer-base/src/com/fr/start/server/FineEmbedServerActivator.java index a4f3888337..61fd249cb8 100644 --- a/designer-base/src/com/fr/start/server/FineEmbedServerActivator.java +++ b/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.design.DesignerEnvManager; -import com.fr.event.EventDispatcher; import com.fr.log.FineLoggerFactory; import com.fr.module.Activator; import com.fr.module.ModuleRole; import com.fr.startup.FineWebApplicationInitializer; import com.fr.third.springframework.web.SpringServletContainerInitializer; import com.fr.third.springframework.web.context.support.AnnotationConfigWebApplicationContext; +import com.fr.workspace.WorkContext; import org.apache.catalina.Context; import org.apache.catalina.LifecycleException; import org.apache.catalina.Wrapper; @@ -55,8 +55,8 @@ public class FineEmbedServerActivator extends Activator { tomcat = new Tomcat(); tomcat.setPort(DesignerEnvManager.getEnvManager().getEmbedServerPort()); - String docBase = new File(FRContext.getCurrentEnv().getPath()).getParent(); - String appName = "/" + FRContext.getCurrentEnv().getAppName(); + String docBase = new File(WorkContext.getCurrent().getPath()).getParent(); + String appName = "/" + FRContext.getCommonOperator().getAppName(); Context context = tomcat.addContext(appName, docBase); addDefaultServlet(context); //覆盖tomcat的WebAppClassLoader diff --git a/designer-chart/src/com/fr/van/chart/DownloadOnlineSourcesHelper.java b/designer-chart/src/com/fr/van/chart/DownloadOnlineSourcesHelper.java index 3af59526af..d90fb4d4bd 100644 --- a/designer-chart/src/com/fr/van/chart/DownloadOnlineSourcesHelper.java +++ b/designer-chart/src/com/fr/van/chart/DownloadOnlineSourcesHelper.java @@ -1,6 +1,5 @@ package com.fr.van.chart; -import com.fr.base.FRContext; import com.fr.chart.base.ChartConstants; import com.fr.design.RestartHelper; import com.fr.design.extra.PluginConstants; @@ -12,16 +11,10 @@ import com.fr.general.SiteCenter; import com.fr.general.http.HttpClient; import com.fr.plugin.chart.DownloadSourcesEvent; import com.fr.stable.StableUtils; +import com.fr.workspace.WorkContext; -import javax.swing.ImageIcon; -import javax.swing.JDialog; -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 javax.swing.*; +import java.awt.*; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.awt.image.BufferedImage; @@ -70,7 +63,8 @@ public class DownloadOnlineSourcesHelper implements DownloadSourcesEvent { } 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; } @@ -145,7 +139,7 @@ public class DownloadOnlineSourcesHelper implements DownloadSourcesEvent { if (result) { //安装文件 - IOUtils.unZipFilesGBK(temp, StableUtils.pathJoin(FRContext.getCurrentEnv().getPath(), siteInfo.localDir)); + IOUtils.unZipFilesGBK(temp, StableUtils.pathJoin(WorkContext.getCurrent().getPath(), siteInfo.localDir)); } } else { result = false; diff --git a/designer-realize/src/com/fr/design/actions/server/StyleManagerPane.java b/designer-realize/src/com/fr/design/actions/server/StyleManagerPane.java index 64b2961233..63a031511d 100644 --- a/designer-realize/src/com/fr/design/actions/server/StyleManagerPane.java +++ b/designer-realize/src/com/fr/design/actions/server/StyleManagerPane.java @@ -37,7 +37,7 @@ public class StyleManagerPane extends BasicPane { public void populate(ServerPreferenceConfig configManager) { //todo 原来界面上显示的xml路径 -// this.StyleTextField.setText(FRContext.getCurrentEnv().getPath() + File.separator + +// this.StyleTextField.setText(WorkContext.getCurrent().getPath() + File.separator + // ProjectConstants.RESOURCES_NAME + // File.separator + configManager.fileName()); this.styleArrayPane.populate(configManager); diff --git a/designer-realize/src/com/fr/design/mainframe/AuthorityToolBarPane.java b/designer-realize/src/com/fr/design/mainframe/AuthorityToolBarPane.java index f514f53592..21a30b78db 100644 --- a/designer-realize/src/com/fr/design/mainframe/AuthorityToolBarPane.java +++ b/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.stable.ArrayUtils; import com.fr.web.attr.ReportWebAttr; +import com.fr.workspace.WorkContext; import javax.swing.*; import java.awt.*; @@ -182,7 +183,7 @@ public class AuthorityToolBarPane extends BasicBeanPane toolBarButtons = toolBarPane.getToolBarButtons(); 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) { button.setEnabled(!isnotEnable); } diff --git a/designer-realize/src/com/fr/design/mainframe/JWorkBook.java b/designer-realize/src/com/fr/design/mainframe/JWorkBook.java index f3eeabf5ef..699dce4783 100644 --- a/designer-realize/src/com/fr/design/mainframe/JWorkBook.java +++ b/designer-realize/src/com/fr/design/mainframe/JWorkBook.java @@ -1098,7 +1098,7 @@ public class JWorkBook extends JTemplate { java.util.Map parameterMap = inputParameters(tpl); try { - String fullPath = StableUtils.pathJoin(FRContext.getCurrentEnv().getPath(), newFile.getPath()); + String fullPath = StableUtils.pathJoin(WorkContext.getCurrent().getPath(), newFile.getPath()); FileOutputStream fileOutputStream = new FileOutputStream(fullPath); EmbeddedTableDataExporter exporter = new EmbeddedTableDataExporter(); exporter.export(fileOutputStream, (WorkBook) tpl, parameterMap); diff --git a/designer-realize/src/com/fr/design/report/share/ShareButton.java b/designer-realize/src/com/fr/design/report/share/ShareButton.java index e01598d1a9..40262abbd9 100644 --- a/designer-realize/src/com/fr/design/report/share/ShareButton.java +++ b/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.main.TemplateWorkBook; 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.workspace.WorkContext; 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.FileOutputStream; import java.net.URI; @@ -84,7 +94,7 @@ public class ShareButton extends UIButton{ //获取默认导出图片位置 private String getImagePath(JTemplate jt){ FILE file = jt.getEditingFILE(); - String envPath = FRContext.getCurrentEnv().getPath(); + String envPath = WorkContext.getCurrent().getPath(); String folderPath = file.getParent().getPath(); String imageName = file.getName().replaceAll(ProjectConstants.CPT_SUFFIX, StringUtils.EMPTY) + ".png"; diff --git a/designer-realize/src/com/fr/design/webattr/EditReportServerParameterPane.java b/designer-realize/src/com/fr/design/webattr/EditReportServerParameterPane.java index 00c2c7469d..d3cc042cce 100644 --- a/designer-realize/src/com/fr/design/webattr/EditReportServerParameterPane.java +++ b/designer-realize/src/com/fr/design/webattr/EditReportServerParameterPane.java @@ -81,7 +81,7 @@ public class EditReportServerParameterPane extends LoadingBasicPane { public void populate(ServerPreferenceConfig reportServerPreferenceConfig) { //todo 原来界面上显示的xml路径 -// this.configFileTextField.setText(FRContext.getCurrentEnv().getPath() + File.separator + +// this.configFileTextField.setText(WorkContext.getCurrent().getPath() + File.separator + // ProjectConstants.RESOURCES_NAME + // File.separator + reportServerPreferenceConfig.fileName()); diff --git a/designer-realize/src/com/fr/design/webattr/WidgetManagerPane.java b/designer-realize/src/com/fr/design/webattr/WidgetManagerPane.java index 8c9997eb86..133ddad560 100644 --- a/designer-realize/src/com/fr/design/webattr/WidgetManagerPane.java +++ b/designer-realize/src/com/fr/design/webattr/WidgetManagerPane.java @@ -42,7 +42,7 @@ public class WidgetManagerPane extends LoadingBasicPane { public void populate(WidgetInfoConfig widgetManager) { //todo 原来界面上显示的xml路径 -// this.widgetTextField.setText(FRContext.getCurrentEnv().getPath() + File.separator + +// this.widgetTextField.setText(WorkContext.getCurrent().getPath() + File.separator + // ProjectConstants.RESOURCES_NAME + // File.separator + widgetManager.fileName()); this.widgetConfigPane.populate(widgetManager); diff --git a/designer-realize/src/com/fr/start/Designer.java b/designer-realize/src/com/fr/start/Designer.java index 348c04d7ce..c6b9becbc4 100644 --- a/designer-realize/src/com/fr/start/Designer.java +++ b/designer-realize/src/com/fr/start/Designer.java @@ -56,14 +56,9 @@ import com.fr.start.preload.ImagePreLoader; import com.fr.start.server.ServerTray; import com.fr.workspace.WorkContext; -import javax.swing.JComponent; -import javax.swing.JPanel; +import javax.swing.*; import javax.swing.border.MatteBorder; -import java.awt.Component; -import java.awt.Cursor; -import java.awt.Dimension; -import java.awt.FlowLayout; -import java.awt.Insets; +import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.File; @@ -182,14 +177,14 @@ public class Designer extends BaseDesigner { protected MenuDef createServerMenuDef(ToolBarMenuDockPlus plus) { MenuDef menuDef = super.createServerMenuDef(plus); - if (FRContext.getCurrentEnv() == null) { + if (WorkContext.getCurrent() == null) { return menuDef; } if (!BaseUtils.isAuthorityEditing()) { menuDef.addShortCut(SeparatorDef.DEFAULT); - - if (FRContext.getCurrentEnv().isRoot()) { + + if (WorkContext.getCurrent().isRoot()) { menuDef.addShortCut(new ServerConfigManagerAction(), new StyleListAction(), new WidgetManagerAction()); if (ActionFactory.getChartPreStyleAction() != null) { menuDef.addShortCut(ActionFactory.getChartPreStyleAction()); From f1144aea9227cf47da2a4c4974e5b6766ca10922 Mon Sep 17 00:00:00 2001 From: ju Date: Sun, 17 Jun 2018 15:43:10 +0800 Subject: [PATCH 10/20] f --- designer-base/src/com/fr/design/DesignerEnvManager.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/designer-base/src/com/fr/design/DesignerEnvManager.java b/designer-base/src/com/fr/design/DesignerEnvManager.java index 6ca4cdd4fa..f58fe2e3e3 100644 --- a/designer-base/src/com/fr/design/DesignerEnvManager.java +++ b/designer-base/src/com/fr/design/DesignerEnvManager.java @@ -190,10 +190,9 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { return; } String installHome = StableUtils.getInstallHome(); - if (installHome != null) { + if (installHome != null && !".".equals(installHome)) { String name = Inter.getLocText("FR-Engine_DEFAULT"); -// String envPath = StableUtils.pathJoin(new String[]{installHome, ProjectConstants.WEBAPP_NAME, ProjectConstants.WEBINF_NAME}); - String envPath = "/Users/juhaoyu/finereport/finereport-maven/env/webroot/WEB-INF"; + String envPath = StableUtils.pathJoin(installHome, ProjectConstants.WEBAPP_NAME, ProjectConstants.WEBINF_NAME); designerEnvManager.putEnv(name, DesignerWorkspaceInfo.createLocal(name, envPath)); designerEnvManager.setCurEnvName(name); } From ffd212926ea357641b7de1668dd505be315816e8 Mon Sep 17 00:00:00 2001 From: ju Date: Sun, 17 Jun 2018 15:47:33 +0800 Subject: [PATCH 11/20] f --- designer-base/src/com/fr/design/env/DesignerWorkspaceInfo.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer-base/src/com/fr/design/env/DesignerWorkspaceInfo.java b/designer-base/src/com/fr/design/env/DesignerWorkspaceInfo.java index 75a2dfab02..b13d810416 100644 --- a/designer-base/src/com/fr/design/env/DesignerWorkspaceInfo.java +++ b/designer-base/src/com/fr/design/env/DesignerWorkspaceInfo.java @@ -79,7 +79,7 @@ public class DesignerWorkspaceInfo implements XMLable { if (reader.isAttr()) { this.name = reader.getAttrAsString("name", StringUtils.EMPTY); - this.type = DesignerWorkspaceType.valueOf(reader.getAttrAsString("name", "Local")); + this.type = DesignerWorkspaceType.valueOf(reader.getAttrAsString("type", "Local")); this.path = reader.getAttrAsString("path", StringUtils.EMPTY); } if (reader.isChildNode()) { From f6f88de665174b3f2d32189fae75c4a3f6baa3b6 Mon Sep 17 00:00:00 2001 From: ju Date: Sun, 17 Jun 2018 16:14:57 +0800 Subject: [PATCH 12/20] f --- .../src/com/fr/design/actions/file/LocalePane.java | 2 +- .../src/com/fr/design/file/TemplateTreePane.java | 2 +- .../com/fr/design/gui/itree/filetree/EnvFileTree.java | 2 +- .../design/gui/itree/filetree/FileNodeComparator.java | 10 +++++----- .../fr/design/gui/itree/filetree/TemplateFileTree.java | 2 +- designer-base/src/com/fr/file/FILEChooserPane.java | 10 +++++----- designer-base/src/com/fr/file/FileNodeFILE.java | 2 +- .../search/manager/impl/FileSearchManager.java | 2 +- 8 files changed, 16 insertions(+), 16 deletions(-) diff --git a/designer-base/src/com/fr/design/actions/file/LocalePane.java b/designer-base/src/com/fr/design/actions/file/LocalePane.java index dee28c6c1c..ebe5f1b55a 100644 --- a/designer-base/src/com/fr/design/actions/file/LocalePane.java +++ b/designer-base/src/com/fr/design/actions/file/LocalePane.java @@ -182,7 +182,7 @@ public class LocalePane extends BasicPane { private void initCustomProperties() throws Exception { - FileNode[] fileNodes = FRContext.getFileOperator().list(ProjectConstants.LOCALE_NAME); + FileNode[] fileNodes = FRContext.getFileNodes().list(ProjectConstants.LOCALE_NAME); if (ArrayUtils.getLength(fileNodes) == 0) { return; } diff --git a/designer-base/src/com/fr/design/file/TemplateTreePane.java b/designer-base/src/com/fr/design/file/TemplateTreePane.java index 948ef528ce..0ce0917a68 100644 --- a/designer-base/src/com/fr/design/file/TemplateTreePane.java +++ b/designer-base/src/com/fr/design/file/TemplateTreePane.java @@ -98,7 +98,7 @@ public class TemplateTreePane extends JPanel implements FileOperations { * 刷新 */ public void refreshDockingView() { - reportletsTree.setFileNodeFilter(new IOFileNodeFilter(FRContext.getFileOperator().getSupportedTypes())); + reportletsTree.setFileNodeFilter(new IOFileNodeFilter(FRContext.getFileNodes().getSupportedTypes())); reportletsTree.refreshEnv(); } diff --git a/designer-base/src/com/fr/design/gui/itree/filetree/EnvFileTree.java b/designer-base/src/com/fr/design/gui/itree/filetree/EnvFileTree.java index d73191e738..125c3a4c6b 100644 --- a/designer-base/src/com/fr/design/gui/itree/filetree/EnvFileTree.java +++ b/designer-base/src/com/fr/design/gui/itree/filetree/EnvFileTree.java @@ -190,7 +190,7 @@ public class EnvFileTree extends RefreshableJTree { FileNode[] res_fns = null; try { - res_fns = WorkContext.getCurrent() == null ? new FileNode[0] : FRContext.getFileOperator().list(filePath); + res_fns = WorkContext.getCurrent() == null ? new FileNode[0] : FRContext.getFileNodes().list(filePath); } catch (Exception e) { FRContext.getLogger().error(e.getMessage(), e); } diff --git a/designer-base/src/com/fr/design/gui/itree/filetree/FileNodeComparator.java b/designer-base/src/com/fr/design/gui/itree/filetree/FileNodeComparator.java index 092374ac37..68dbec78cc 100644 --- a/designer-base/src/com/fr/design/gui/itree/filetree/FileNodeComparator.java +++ b/designer-base/src/com/fr/design/gui/itree/filetree/FileNodeComparator.java @@ -1,6 +1,6 @@ package com.fr.design.gui.itree.filetree; -import com.fr.base.operator.file.LocalFileOperator; +import com.fr.file.filetree.LocalFileNodes; import com.fr.file.filetree.FileNode; import java.util.Comparator; @@ -59,13 +59,13 @@ public class FileNodeComparator implements Comparator { private int groupByFileType(FileNode nameNode1, FileNode nameNode2, int i) { - if (i < LocalFileOperator.FILE_TYPE.length) { - if (nameNode1.isFileType(LocalFileOperator.FILE_TYPE[i])) - if (nameNode2.isFileType(LocalFileOperator.FILE_TYPE[i])) + if (i < LocalFileNodes.FILE_TYPE.length) { + if (nameNode1.isFileType(LocalFileNodes.FILE_TYPE[i])) + if (nameNode2.isFileType(LocalFileNodes.FILE_TYPE[i])) return nameNode1.getName().toLowerCase().compareTo(nameNode2.getName().toLowerCase()); else return-1; - else if (nameNode2.isFileType(LocalFileOperator.FILE_TYPE[i])) + else if (nameNode2.isFileType(LocalFileNodes.FILE_TYPE[i])) return 1; else{ return groupByFileType(nameNode1, nameNode2, i+1); diff --git a/designer-base/src/com/fr/design/gui/itree/filetree/TemplateFileTree.java b/designer-base/src/com/fr/design/gui/itree/filetree/TemplateFileTree.java index 451a381eca..aeb3756e60 100644 --- a/designer-base/src/com/fr/design/gui/itree/filetree/TemplateFileTree.java +++ b/designer-base/src/com/fr/design/gui/itree/filetree/TemplateFileTree.java @@ -101,7 +101,7 @@ public class TemplateFileTree extends EnvFileTree { } public FileNode[] listFile(String path) throws Exception { - return FRContext.getFileOperator().list( + return FRContext.getFileNodes().list( path, new FileExtension[]{FileExtension.CPT, FileExtension.FRM, FileExtension.CPTX, FileExtension.FRMX}); } diff --git a/designer-base/src/com/fr/file/FILEChooserPane.java b/designer-base/src/com/fr/file/FILEChooserPane.java index c36af8365b..f33749431f 100644 --- a/designer-base/src/com/fr/file/FILEChooserPane.java +++ b/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.FRContext; import com.fr.base.extension.FileExtension; -import com.fr.base.operator.file.LocalFileOperator; +import com.fr.file.filetree.LocalFileNodes; import com.fr.design.DesignerEnvManager; import com.fr.design.actions.UpdateAction; import com.fr.design.dialog.BasicPane; @@ -545,10 +545,10 @@ public class FILEChooserPane extends BasicPane { return; } if (editing == null || !editing.isChartBook()) { - String[] fileSuffix_local = LocalFileOperator.FILE_TYPE; + String[] fileSuffix_local = LocalFileNodes.FILE_TYPE; EnumSet fileExtensions = EnumSet.of(FileExtension.CPT, FileExtension.CPTX, FileExtension.FRM, FileExtension.FRMX, FileExtension.CHT); if (type == JFileChooser.OPEN_DIALOG) { - if (FRContext.getFileOperator().isSupportLocalFileOperate()) { //本地连接 + if (FRContext.getFileNodes().isSupportLocalFileOperate()) { //本地连接 this.addChooseFILEFilter(new ChooseFileFilter(fileSuffix_local, appName + Inter.getLocText(new String[]{"FR-App-Report_Template", "FR-App-All_File"}))); } else { 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 - if (FRContext.getFileOperator().isSupportLocalFileOperate()) { //本地连接 + if (FRContext.getFileNodes().isSupportLocalFileOperate()) { //本地连接 this.addChooseFILEFilter(new ChooseFileFilter(FileExtension.XLS, Inter.getLocText("Import-Excel_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) { defaultComboBoxModel.addElement(aFilterList); } - if (FRContext.getFileOperator().isSupportLocalFileOperate()) { //本地连接 + if (FRContext.getFileNodes().isSupportLocalFileOperate()) { //本地连接 if (!showWebReport) { defaultComboBoxModel.addElement(Inter.getLocText("FR-Utils-App_AllFiles") + "(*.*)"); } diff --git a/designer-base/src/com/fr/file/FileNodeFILE.java b/designer-base/src/com/fr/file/FileNodeFILE.java index aab99ab208..204152c7d0 100644 --- a/designer-base/src/com/fr/file/FileNodeFILE.java +++ b/designer-base/src/com/fr/file/FileNodeFILE.java @@ -181,7 +181,7 @@ public class FileNodeFILE implements FILE { */ private FileNode[] listFile(String rootFilePath) { try { - return FRContext.getFileOperator().list(rootFilePath); + return FRContext.getFileNodes().list(rootFilePath); } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); } diff --git a/designer-realize/src/com/fr/design/mainframe/alphafine/search/manager/impl/FileSearchManager.java b/designer-realize/src/com/fr/design/mainframe/alphafine/search/manager/impl/FileSearchManager.java index 2bbbb36bb7..82d98f9622 100644 --- a/designer-realize/src/com/fr/design/mainframe/alphafine/search/manager/impl/FileSearchManager.java +++ b/designer-realize/src/com/fr/design/mainframe/alphafine/search/manager/impl/FileSearchManager.java @@ -231,7 +231,7 @@ public class FileSearchManager implements AlphaFineSearchProvider { */ private void listAll(String rootFilePath, List nodeList, boolean recurse) throws Exception { - FileNode[] fns = FRContext.getFileOperator().list(rootFilePath); + FileNode[] fns = FRContext.getFileNodes().list(rootFilePath); for (int i = 0; i < fns.length; i++) { FileNode fileNode = fns[i]; if (fileNode.isDirectory()) { From 2e2c14666ee657477174d54cbe64af0d4fccc9b0 Mon Sep 17 00:00:00 2001 From: ju Date: Sun, 17 Jun 2018 16:30:24 +0800 Subject: [PATCH 13/20] f --- designer-realize/src/com/fr/start/module/DesignerStartup.java | 2 +- ...{DesignerEnvProvider.java => DesignerWorkspaceProvider.java} | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename designer-realize/src/com/fr/start/module/{DesignerEnvProvider.java => DesignerWorkspaceProvider.java} (99%) diff --git a/designer-realize/src/com/fr/start/module/DesignerStartup.java b/designer-realize/src/com/fr/start/module/DesignerStartup.java index 3de4805b04..c5284b5e5e 100644 --- a/designer-realize/src/com/fr/start/module/DesignerStartup.java +++ b/designer-realize/src/com/fr/start/module/DesignerStartup.java @@ -23,7 +23,7 @@ public class DesignerStartup extends Activator { String[] args = getModule().upFindSingleton(StartupArgs.class).get(); Designer designer = new Designer(args); //启动env - startSub(DesignerEnvProvider.class); + startSub(DesignerWorkspaceProvider.class); startSub(EnvBasedModule.class); getRoot().getSingleton(EnvSwitcher.class).switch2LastEnv(); registerEnvListener(); diff --git a/designer-realize/src/com/fr/start/module/DesignerEnvProvider.java b/designer-realize/src/com/fr/start/module/DesignerWorkspaceProvider.java similarity index 99% rename from designer-realize/src/com/fr/start/module/DesignerEnvProvider.java rename to designer-realize/src/com/fr/start/module/DesignerWorkspaceProvider.java index e8f5c482b8..7ad4d91f87 100644 --- a/designer-realize/src/com/fr/start/module/DesignerEnvProvider.java +++ b/designer-realize/src/com/fr/start/module/DesignerWorkspaceProvider.java @@ -10,7 +10,7 @@ import com.fr.start.ServerStarter; * Created by juhaoyu on 2018/1/8. * 设计器启动时的环境相关模块activator */ -public class DesignerEnvProvider extends Activator { +public class DesignerWorkspaceProvider extends Activator { @Override public void start() { From 6f62db46331c7218239c239467b5873b701412f5 Mon Sep 17 00:00:00 2001 From: ju Date: Sun, 17 Jun 2018 17:23:26 +0800 Subject: [PATCH 14/20] f --- .../alphafine/AlphaFineConfigManager.java | 3 +- .../fr/design/mainframe/DesignerFrame.java | 25 +- .../DesignerFrameFileDealerPane.java | 249 ++++++++++-------- .../com/fr/design/mainframe/JTemplate.java | 24 +- .../src/com/fr/design/utils/DesignUtils.java | 12 - 5 files changed, 170 insertions(+), 143 deletions(-) diff --git a/designer-base/src/com/fr/design/actions/help/alphafine/AlphaFineConfigManager.java b/designer-base/src/com/fr/design/actions/help/alphafine/AlphaFineConfigManager.java index 7c591019a5..b1c03c09bc 100644 --- a/designer-base/src/com/fr/design/actions/help/alphafine/AlphaFineConfigManager.java +++ b/designer-base/src/com/fr/design/actions/help/alphafine/AlphaFineConfigManager.java @@ -1,6 +1,5 @@ package com.fr.design.actions.help.alphafine; -import com.fr.base.FRContext; import com.fr.license.function.VT4FR; import com.fr.stable.OperatingSystem; import com.fr.stable.StringUtils; @@ -75,7 +74,7 @@ public class AlphaFineConfigManager implements XMLable { public static boolean isALPHALicAvailable() { - return FRContext.getCommonOperator() != null && VT4FR.AlphaFine.isSupport(); + return VT4FR.AlphaFine.isSupport(); } @Override diff --git a/designer-base/src/com/fr/design/mainframe/DesignerFrame.java b/designer-base/src/com/fr/design/mainframe/DesignerFrame.java index 5e141310f5..23e2596dfd 100644 --- a/designer-base/src/com/fr/design/mainframe/DesignerFrame.java +++ b/designer-base/src/com/fr/design/mainframe/DesignerFrame.java @@ -4,7 +4,6 @@ package com.fr.design.mainframe; import com.fr.base.BaseUtils; -import com.fr.base.FRContext; import com.fr.design.DesignModelAdapter; import com.fr.design.DesignState; import com.fr.design.DesignerEnvManager; @@ -836,18 +835,18 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta */ public void openTemplate(FILE tplFile) { // 测试连接,如果连接失败,则提示 - try { - if (FRContext.getCommonOperator() != null - && !FRContext.getCommonOperator().testServerConnectionWithOutShowMessagePane()) { - JOptionPane.showMessageDialog( - DesignerContext.getDesignerFrame(), - Inter.getLocText(new String[]{"FR-Chart-Server_disconnected", "FR-Server-Design_template_unopened"}, new String[]{ - ",", "!"}), Inter.getLocText("FR-Server-All_Error"), JOptionPane.ERROR_MESSAGE); - return; - } - } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage()); - } +// try { +// if (FRContext.getCommonOperator() != null +// && !FRContext.getCommonOperator().testServerConnectionWithOutShowMessagePane()) { +// JOptionPane.showMessageDialog( +// DesignerContext.getDesignerFrame(), +// Inter.getLocText(new String[]{"FR-Chart-Server_disconnected", "FR-Server-Design_template_unopened"}, new String[]{ +// ",", "!"}), Inter.getLocText("FR-Server-All_Error"), JOptionPane.ERROR_MESSAGE); +// return; +// } +// } catch (Exception e) { +// FineLoggerFactory.getLogger().error(e.getMessage()); +// } // p:判断一下,如何文件为空或者文件不存在,直接返回. if (tplFile == null || !tplFile.exists()) { diff --git a/designer-base/src/com/fr/design/mainframe/DesignerFrameFileDealerPane.java b/designer-base/src/com/fr/design/mainframe/DesignerFrameFileDealerPane.java index 3bdc66923e..c35e7e3591 100644 --- a/designer-base/src/com/fr/design/mainframe/DesignerFrameFileDealerPane.java +++ b/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.project.ProjectConstants; -import javax.swing.BorderFactory; -import javax.swing.Box; -import javax.swing.BoxLayout; -import javax.swing.JDialog; -import javax.swing.JPanel; -import javax.swing.SwingConstants; +import javax.swing.*; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; -import java.awt.BorderLayout; -import java.awt.CardLayout; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.GridLayout; +import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyAdapter; @@ -59,37 +50,48 @@ import java.util.Map; import java.util.Set; public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarStateChangeListener, ResponseDataSourceChange { + private static final String FILE = "file"; + private static DesignerFrameFileDealerPane THIS; - + private CardLayout card; + private JPanel cardPane; - + private FileOperations selectedOperation; + private UIToolbar toolBar; - + private OpenReportAction openReportAction = new OpenReportAction(); + private RefreshTreeAction refreshTreeAction = new RefreshTreeAction(); + private OpenFolderAction openFolderAction = new OpenFolderAction(); + private RenameAction renameAction = new RenameAction(); + private DelFileAction delFileAction = new DelFileAction(); - - + + /** * 刷新 */ public void refresh() { + selectedOperation.refresh(); } - + public static final DesignerFrameFileDealerPane getInstance() { + if (THIS == null) { THIS = new DesignerFrameFileDealerPane(); } return THIS; } - + private DesignerFrameFileDealerPane() { + setLayout(new BorderLayout()); toolBar = ToolBarDef.createJToolBar(); toolBar.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, UIConstants.TOOLBAR_BORDER_COLOR)); @@ -100,22 +102,23 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt parent.setBorder(BorderFactory.createEmptyBorder(3, 0, 4, 0)); tooBarPane.add(parent, BorderLayout.CENTER); tooBarPane.add(new UIMenuHighLight(), BorderLayout.SOUTH); - + add(tooBarPane, BorderLayout.NORTH); cardPane = new JPanel(card = new CardLayout()); cardPane.add(TemplateTreePane.getInstance(), FILE); - + selectedOperation = TemplateTreePane.getInstance(); card.show(cardPane, FILE); - + TemplateTreePane.getInstance().setToobarStateChangeListener(this); - + add(cardPane, BorderLayout.CENTER); stateChange(); } - - + + public final void setCurrentEditingTemplate(JTemplate jt) { + DesignModelAdapter.setCurrentModelAdapter(jt == null ? null : jt.getModel()); fireDSChanged(); TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter()); @@ -125,35 +128,37 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt if (BaseUtils.isAuthorityEditing()) { RolesAlreadyEditedPane.getInstance().refreshDockingView(); } - + jt.setComposite(); jt.refreshToolArea(); jt.fireJTemplateOpened(); jt.requestFocus(); jt.revert(); - + FRContext.getLogger().info("\"" + jt.getEditingFILE().getName() + "\"" + Inter.getLocText("LOG-Has_Been_Openned") + "!"); } - + /** * 刷新菜单 */ public void refreshDockingView() { + ToolBarDef toolbarDef = new ToolBarDef(); toolbarDef.addShortCut(openReportAction, refreshTreeAction); toolbarDef.addShortCut(openFolderAction, renameAction); toolbarDef.addShortCut(delFileAction); Set extraShortCuts = ExtraDesignClassManager.getInstance().getExtraShortCuts(); - for (ShortCut shortCut : extraShortCuts){ + for (ShortCut shortCut : extraShortCuts) { toolbarDef.addShortCut(shortCut); } - + toolbarDef.updateToolBar(toolBar); refreshActions(); } - - + + private void refreshActions() { + openReportAction.setEnabled(false); refreshTreeAction.setEnabled(true); openFolderAction.setEnabled(false); @@ -161,123 +166,134 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt delFileAction.setEnabled(false); this.repaint(); } - + /** * 响应数据集改变 */ public void fireDSChanged() { + fireDSChanged(new HashMap()); } - + /** - * 响应数据集改变 - * @param map 改变名字的数据集 + * 响应数据集改变 + * + * @param map 改变名字的数据集 */ public void fireDSChanged(Map map) { + DesignTableDataManager.fireDSChanged(map); } - - + + /* * Open Report Action */ private class OpenReportAction extends UpdateAction { - + public OpenReportAction() { + this.setName(KeySetUtils.OPEN_TEMPLATE.getMenuKeySetName()); this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/buttonicon/open.png")); } - + @Override public void actionPerformed(ActionEvent evt) { + selectedOperation.openSelectedReport(); } - + } - + private class OpenFolderAction extends UpdateAction { - + public OpenFolderAction() { + this.setName(Inter.getLocText("FR-Designer_Show_in_Containing_Folder")); this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_file/view_folder.png")); } - + @Override public void actionPerformed(ActionEvent evt) { + selectedOperation.openContainerFolder(); } } - + /* * 刷新ReportletsTree */ private class RefreshTreeAction extends UpdateAction { - + public RefreshTreeAction() { + this.setName(Inter.getLocText("FR-Designer_Refresh")); this.setSmallIcon(UIConstants.REFRESH_ICON); } - + @Override public void actionPerformed(ActionEvent evt) { + selectedOperation.refresh(); stateChange(); } } - + /* * 重命名文件 */ private class RenameAction extends UpdateAction { - + public RenameAction() { + this.setName(Inter.getLocText("FR-Designer_Rename")); this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/data/source/rename.png")); } - + @Override public void actionPerformed(ActionEvent evt) { + new RenameDialog(); MutilTempalteTabPane.getInstance().repaint(); } - + } - + /* * 删除指定文件 */ private class DelFileAction extends UpdateAction { - + public DelFileAction() { + this.setName(Inter.getLocText("FR-Designer_Remove")); this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/data/source/delete.png")); } - + @Override public void actionPerformed(ActionEvent evt) { + selectedOperation.deleteFile(); } } - + /** * 按钮状态改变 */ @Override public void stateChange() { - //当前环境为远程环境时 - if (FRContext.getCommonOperator() != null) { - //当前环境为本地环境时 - if (selectedOperation.getSelectedTemplatePath() != null) { - openReportAction.setEnabled(true); - renameAction.setEnabled(true); - delFileAction.setEnabled(true); - } else { - openReportAction.setEnabled(false); - renameAction.setEnabled(false); - delFileAction.setEnabled(false); - } - openFolderAction.setEnabled(containsFolderNums() + seletedTemplateNums() != 0); + + if (selectedOperation.getSelectedTemplatePath() != null) { + openReportAction.setEnabled(true); + renameAction.setEnabled(true); + delFileAction.setEnabled(true); + } else { + openReportAction.setEnabled(false); + renameAction.setEnabled(false); + delFileAction.setEnabled(false); } + openFolderAction.setEnabled(containsFolderNums() + seletedTemplateNums() != 0); + refreshTreeAction.setEnabled(true); if (containsFolderNums() > 0 && (containsFolderNums() + seletedTemplateNums() > 1)) { refreshActions(); @@ -288,21 +304,22 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt renameAction.setEnabled(false); delFileAction.setEnabled(true); } - + } - + /** * 是否包含文件夹 * * @return */ - + private int containsFolderNums() { + TemplateFileTree fileTree = TemplateTreePane.getInstance().getTemplateFileTree(); if (fileTree.getSelectionPaths() == null) { return 0; } - + //选择的包含文件和文件夹的数目 if (fileTree.getSelectionPaths().length == 0) { return 0; @@ -310,45 +327,53 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt //所有的num减去模板的num,得到文件夹的num return fileTree.getSelectionPaths().length - fileTree.getSelectedTemplatePaths().length; } - + /** * 是否选择了多个模板 * * @return */ private int seletedTemplateNums() { + TemplateFileTree fileTree = TemplateTreePane.getInstance().getTemplateFileTree(); if (fileTree.getSelectionPaths() == null) { return 0; } - + return fileTree.getSelectedTemplatePaths().length; } - - + + // js: 重命名对话框,模仿Eclipse的重命名,支持快捷键F2,Enter,ESC private class RenameDialog { - + private UITextField jt; + private String userInput; + private String oldName; + private UILabel hintsLabel; + private UIButton confirmButton; + private JDialog jd; + private String suffix; - + public RenameDialog() { + final String reportPath = selectedOperation.getSelectedTemplatePath(); if (reportPath == null) { return; } - + final FileNodeFILE nodeFile = new FileNodeFILE(new FileNode(StableUtils.pathJoin(ProjectConstants.REPORTLETS_NAME, reportPath), false)); final String path = nodeFile.getPath(); oldName = nodeFile.getName(); suffix = oldName.substring(oldName.lastIndexOf(CoreConstants.DOT), oldName.length()); oldName = oldName.replaceAll(suffix, ""); - + jd = new JDialog(); jd.setLayout(new GridLayout(2, 2)); jd.setModal(true); @@ -359,14 +384,14 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt jt.getDocument().addDocumentListener(getdoDocumentListener()); jt.selectAll(); jt.setPreferredSize(new Dimension(150, 20)); - + JPanel newNamePanel = new JPanel(); newNamePanel.setLayout(new BoxLayout(newNamePanel, BoxLayout.X_AXIS)); newNamePanel.add(Box.createHorizontalGlue()); newNamePanel.add(newNameLabel); newNamePanel.add(Box.createHorizontalStrut(5)); jd.add(newNamePanel); - + JPanel jtPanel = new JPanel(); jtPanel.setLayout(new BoxLayout(jtPanel, BoxLayout.Y_AXIS)); JPanel containJt = new JPanel(new BorderLayout()); @@ -376,42 +401,46 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt jtPanel.add(containJt); jtPanel.add(Box.createVerticalGlue()); jd.add(jtPanel); - + addUITextFieldListener(nodeFile, path); - + hintsLabel = new UILabel(); hintsLabel.setBounds(20, 50, 250, 30); hintsLabel.setMaximumSize(new Dimension(200, 30)); hintsLabel.setHorizontalAlignment(SwingConstants.RIGHT); hintsLabel.setForeground(Color.RED); hintsLabel.setVisible(false); - + confirmButton = new UIButton(Inter.getLocText("FR-Designer_Confirm")); confirmButton.setPreferredSize(new Dimension(80, 25)); confirmButton.setMinimumSize(new Dimension(80, 25)); confirmButton.setMaximumSize(new Dimension(80, 25)); confirmButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + confirmClose(nodeFile, path); } }); - + UIButton cancelButton = new UIButton(Inter.getLocText("FR-Designer_Cancel")); cancelButton.setPreferredSize(new Dimension(80, 25)); cancelButton.setMinimumSize(new Dimension(80, 25)); cancelButton.setMaximumSize(new Dimension(80, 25)); - + cancelButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + jd.dispose(); } }); - + JPanel hintsPanel = new JPanel(); hintsPanel.setLayout(new BorderLayout()); hintsPanel.add(hintsLabel, BorderLayout.EAST); jd.add(hintsLabel); - + JPanel btPanel = new JPanel(new BorderLayout()); btPanel.setLayout(new BoxLayout(btPanel, BoxLayout.X_AXIS)); btPanel.add(Box.createHorizontalGlue()); @@ -420,7 +449,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt btPanel.add(cancelButton); btPanel.add(Box.createHorizontalStrut(20)); jd.add(btPanel); - + jd.setSize(380, 200); jd.setTitle(Inter.getLocText("FR-Designer_Rename")); jd.setResizable(false); @@ -430,22 +459,24 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt GUICoreUtils.centerWindow(jd); jd.setVisible(true); } - + public void confirmClose(FileNodeFILE nodeFile, String path) { + userInput = userInput == null ? oldName : userInput; String oldPath = path.replaceAll("/", "\\\\"); String newPath = path.replace(nodeFile.getName(), userInput + suffix); renameTemplateInMemory(nodeFile, userInput + suffix, oldName + suffix); DesignerEnvManager.getEnvManager().replaceRecentOpenedFilePath(oldPath, newPath.replaceAll("/", "\\\\")); - + //模版重命名 ResourceIOUtils.renameTo(path, newPath); selectedOperation.refresh(); DesignerContext.getDesignerFrame().setTitle(); jd.dispose(); } - + private void renameTemplateInMemory(FILE tplFile, String newName, String oldName) { + JTemplate dPane = getSpecialTemplateByFILE(tplFile); if (dPane == null) { return; @@ -453,20 +484,24 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt FILE renameFile = dPane.getEditingFILE(); renameFile.setPath(renameFile.getPath().replace(oldName, newName)); } - + // 增加enter以及esc快捷键的支持 public void addUITextFieldListener(final FileNodeFILE nodeFile, final String path) { - + jt.addKeyListener(new KeyAdapter() { + public void keyPressed(KeyEvent e) { + if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { jd.dispose(); } } }); - + jt.addKeyListener(new KeyAdapter() { + public void keyPressed(KeyEvent e) { + if (e.getKeyCode() == KeyEvent.VK_ENTER) { if (confirmButton.isEnabled()) { confirmClose(nodeFile, path); @@ -474,30 +509,35 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt } } }); - + } - + // UITextField的输入监听 public DocumentListener getdoDocumentListener() { + DocumentListener dl = new DocumentListener() { - + public void changedUpdate(DocumentEvent e) { + isNameAlreadyExist(); } - + public void insertUpdate(DocumentEvent e) { + isNameAlreadyExist(); } - + public void removeUpdate(DocumentEvent e) { + isNameAlreadyExist(); } }; - + return dl; } - + private void isNameAlreadyExist() { + userInput = jt.getText().trim(); if (selectedOperation.isNameAlreadyExist(userInput, oldName, suffix)) { jt.selectAll(); @@ -511,12 +551,13 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt } } } - + /** * @param tplFile * @return 内存中的template重命名一下 */ private JTemplate getSpecialTemplateByFILE(FILE tplFile) { + HistoryTemplateListPane historyHandle = HistoryTemplateListPane.getInstance(); if (ComparatorUtils.equals(historyHandle.getCurrentEditingTemplate().getEditingFILE(), tplFile)) { return historyHandle.getCurrentEditingTemplate(); @@ -528,5 +569,5 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt } return null; } - + } \ No newline at end of file diff --git a/designer-base/src/com/fr/design/mainframe/JTemplate.java b/designer-base/src/com/fr/design/mainframe/JTemplate.java index eccaddeaa8..33f73ccd91 100644 --- a/designer-base/src/com/fr/design/mainframe/JTemplate.java +++ b/designer-base/src/com/fr/design/mainframe/JTemplate.java @@ -523,18 +523,18 @@ public abstract class JTemplate> if (editingFILE == null) { return false; } - //检查一下连接是否成功 - try { - if (FRContext.getCommonOperator() != null && !FRContext.getCommonOperator().testServerConnectionWithOutShowMessagePane()) { - //连接不成功,提示 - JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), - Inter.getLocText(new String[]{"server_disconnected", "template_unsaved"}, new String[]{",", "!"}) - , Inter.getLocText("FR-Designer_Error"), JOptionPane.ERROR_MESSAGE); - return false; - } - } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage()); - } +// //检查一下连接是否成功 +// try { +// if (FRContext.getCommonOperator() != null && !FRContext.getCommonOperator().testServerConnectionWithOutShowMessagePane()) { +// //连接不成功,提示 +// JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), +// Inter.getLocText(new String[]{"server_disconnected", "template_unsaved"}, new String[]{",", "!"}) +// , Inter.getLocText("FR-Designer_Error"), JOptionPane.ERROR_MESSAGE); +// return false; +// } +// } catch (Exception e) { +// FineLoggerFactory.getLogger().error(e.getMessage()); +// } // 检查一下editingFILE是不是已存在的文件,如果不存在则用saveAs diff --git a/designer-base/src/com/fr/design/utils/DesignUtils.java b/designer-base/src/com/fr/design/utils/DesignUtils.java index 75802497d8..12871b1ede 100644 --- a/designer-base/src/com/fr/design/utils/DesignUtils.java +++ b/designer-base/src/com/fr/design/utils/DesignUtils.java @@ -20,7 +20,6 @@ import com.fr.general.GeneralContext; import com.fr.general.Inter; import com.fr.general.http.HttpClient; import com.fr.log.FineLoggerFactory; -import com.fr.security.JwtUtils; import com.fr.stable.ArrayUtils; import com.fr.stable.CodeUtils; import com.fr.stable.EncodeConstants; @@ -47,7 +46,6 @@ import java.net.ServerSocket; import java.net.Socket; import java.net.URI; import java.net.URLEncoder; -import java.util.Calendar; import java.util.Enumeration; import java.util.Locale; @@ -302,16 +300,6 @@ public class DesignUtils { if (!WorkContext.getCurrent().isLocal()) { try { - if (Utils.isEmbeddedParameter(postfixOfUri)) { - String time = Calendar.getInstance().getTime().toString().replaceAll(" ", ""); -// boolean isUserPrivilege = FRContext.getCommonOperator()).writePrivilegeMap(time, postfixOfUri); - boolean isUserPrivilege = false; - postfixOfUri = isUserPrivilege ? postfixOfUri + "&fr_check_url=" + time + "&id=" + FRContext.getCommonOperator().getUserID() : postfixOfUri; - } - // 加参数给远程设计校验权限。 - String design = JwtUtils.createDefaultJWT(FRContext.getCommonOperator().getUser()); - postfixOfUri = postfixOfUri + "&design=" + design; - String urlPath = getWebBrowserPath(); Desktop.getDesktop().browse(new URI(urlPath + postfixOfUri)); } catch (Exception e) { From a1295a268c533bb3c45581b32a24952964c7bbac Mon Sep 17 00:00:00 2001 From: ju Date: Sun, 17 Jun 2018 17:31:53 +0800 Subject: [PATCH 15/20] f --- .../com/fr/design/mainframe/TemplatePane.java | 5 - .../module/DesignerWorkspaceProvider.java | 162 ------------------ 2 files changed, 167 deletions(-) diff --git a/designer-base/src/com/fr/design/mainframe/TemplatePane.java b/designer-base/src/com/fr/design/mainframe/TemplatePane.java index 14084a9fd2..f312e73c5a 100644 --- a/designer-base/src/com/fr/design/mainframe/TemplatePane.java +++ b/designer-base/src/com/fr/design/mainframe/TemplatePane.java @@ -163,11 +163,6 @@ public class TemplatePane extends JPanel implements MouseListener { return true; } - private String getDesignerVersion(DesignerWorkspaceInfo selectedEnv) { -// return selectedEnv.getDesignerVersion(); - throw new UnsupportedOperationException("unsupport now"); - } - /** * 编辑items */ diff --git a/designer-realize/src/com/fr/start/module/DesignerWorkspaceProvider.java b/designer-realize/src/com/fr/start/module/DesignerWorkspaceProvider.java index 7ad4d91f87..d95e00aed3 100644 --- a/designer-realize/src/com/fr/start/module/DesignerWorkspaceProvider.java +++ b/designer-realize/src/com/fr/start/module/DesignerWorkspaceProvider.java @@ -25,173 +25,11 @@ public class DesignerWorkspaceProvider extends Activator { } } } - initDesignerEnv(); - getRoot().setSingleton(EnvSwitcher.class, new EnvSwitcher()); //设置好环境即可,具体跟环境有关的模块会自动调用 getRoot().getSingleton(EnvSwitcher.class).switch2LastEnv(); } - private void initDesignerEnv() { - addSerializers(); - } - - private void addSerializers() { - -// EnvProxy.addSerializer(ProcedureDataModel[].class, new ProcedureDataModelSerializer()); -// -// EnvProxy.addSerializer(ModifiedTable.class, new OldSerializerAdapter( -// new OldSerializerAdapter.OldSerializer() { -// -// @Override -// public void serializer(ModifiedTable obj, OutputStream out) throws Exception { -// -// DavXMLUtils.writeXMLModifiedTables(obj, out); -// } -// }, -// new OldSerializerAdapter.OldDeserializer() { -// -// @Override -// public ModifiedTable deserializer(InputStream in) throws Exception { -// -// return DavXMLUtils.readXMLModifiedTables(in); -// } -// } -// )); -// -// EnvProxy.addSerializer(com.fr.data.impl.Connection.class, new OldSerializerAdapter( -// new OldSerializerAdapter.OldSerializer() { -// -// @Override -// public void serializer(Connection obj, OutputStream out) { -// -// DavXMLUtils.writeXMLFileDatabaseConnection(obj, out); -// } -// }, -// new OldSerializerAdapter.OldDeserializer() { -// -// @Override -// public Connection deserializer(InputStream in) throws Exception { -// -// return DavXMLUtils.readXMLDatabaseConnection(in); -// } -// } -// )); -// -// EnvProxy.addSerializer(FileNode[].class, new OldSerializerAdapter( -// new OldSerializerAdapter.OldSerializer() { -// -// @Override -// public void serializer(FileNode[] obj, OutputStream out) { -// -// DavXMLUtils.writeXMLFileNodes(obj, out); -// } -// }, -// new OldSerializerAdapter.OldDeserializer() { -// -// @Override -// public FileNode[] deserializer(InputStream in) { -// -// return DavXMLUtils.readXMLFileNodes(in); -// } -// } -// )); -// -// EnvProxy.addSerializer(TableProcedure[].class, new OldSerializerAdapter( -// new OldSerializerAdapter.OldSerializer() { -// -// @Override -// public void serializer(TableProcedure[] obj, OutputStream out) { -// -// DavXMLUtils.writeXMLFileSQLTable(obj, out); -// } -// }, -// new OldSerializerAdapter.OldDeserializer() { -// -// @Override -// public TableProcedure[] deserializer(InputStream in) throws Exception { -// -// return DavXMLUtils.readXMLSQLTables(in); -// } -// } -// )); -// -// EnvProxy.addSerializer(TableData.class, new OldSerializerAdapter( -// new OldSerializerAdapter.OldSerializer() { -// -// @Override -// public void serializer(TableData obj, OutputStream out) { -// -// DavXMLUtils.writeXMLFileTableData(obj, out); -// } -// }, -// new OldSerializerAdapter.OldDeserializer() { -// -// @Override -// public TableData deserializer(InputStream in) throws Exception { -// -// return DavXMLUtils.readXMLTableData(in); -// } -// } -// )); -// -// EnvProxy.addSerializer(Parameter[].class, new OldSerializerAdapter( -// new OldSerializerAdapter.OldSerializer() { -// -// @Override -// public void serializer(Parameter[] obj, OutputStream out) { -// -// DavXMLUtils.writeXMLFileParameters(obj, out); -// } -// }, -// new OldSerializerAdapter.OldDeserializer() { -// -// @Override -// public Parameter[] deserializer(InputStream in) throws Exception { -// -// return DavXMLUtils.readXMLParameters(in); -// } -// } -// )); -// -// EnvProxy.addSerializer(StoreProcedure.class, new OldSerializerAdapter( -// new OldSerializerAdapter.OldSerializer() { -// -// @Override -// public void serializer(StoreProcedure obj, OutputStream out) { -// -// DavXMLUtils.writeXMLFileStoreProcedure(obj, out); -// } -// }, -// new OldSerializerAdapter.OldDeserializer() { -// -// @Override -// public StoreProcedure deserializer(InputStream in) throws Exception { -// -// return DavXMLUtils.readXMLStoreProcedure(in); -// } -// } -// )); -// -// EnvProxy.addSerializer(StoreProcedureParameter[].class, new OldSerializerAdapter( -// new OldSerializerAdapter.OldSerializer() { -// -// @Override -// public void serializer(StoreProcedureParameter[] obj, OutputStream out) { -// -// DavXMLUtils.writeXMLFileParameters(obj, out); -// } -// }, -// new OldSerializerAdapter.OldDeserializer() { -// -// @Override -// public StoreProcedureParameter[] deserializer(InputStream in) throws Exception { -// -// return DavXMLUtils.readXMLStoreProcedureParameters(in); -// } -// } -// )); - } @Override public void stop() { From 2ed28583ef6cd8010f59da78ef5a33a6ca7327d3 Mon Sep 17 00:00:00 2001 From: ju Date: Mon, 18 Jun 2018 01:16:03 +0800 Subject: [PATCH 16/20] f --- .../src/com/fr/design/DesignerEnvManager.java | 24 ++-- .../design/actions/file/SwitchExistEnv.java | 16 +-- .../fr/design/env/DesignerWorkspaceInfo.java | 119 ++---------------- .../env/LocalDesignerWorkspaceInfo.java | 70 +++++++++++ .../env/RemoteDesignerWorkspaceInfo.java | 83 ++++++++++++ .../gui/controlpane/JListControlPane.java | 25 +++- designer-base/src/com/fr/env/EnvListPane.java | 11 +- .../src/com/fr/env/LocalEnvPane.java | 10 +- .../src/com/fr/env/RemoteEnvPane.java | 32 ++--- .../src/com/fr/start/EnvSwitcher.java | 3 +- 10 files changed, 239 insertions(+), 154 deletions(-) create mode 100644 designer-base/src/com/fr/design/env/LocalDesignerWorkspaceInfo.java create mode 100644 designer-base/src/com/fr/design/env/RemoteDesignerWorkspaceInfo.java diff --git a/designer-base/src/com/fr/design/DesignerEnvManager.java b/designer-base/src/com/fr/design/DesignerEnvManager.java index f58fe2e3e3..d8a76b5647 100644 --- a/designer-base/src/com/fr/design/DesignerEnvManager.java +++ b/designer-base/src/com/fr/design/DesignerEnvManager.java @@ -10,6 +10,8 @@ import com.fr.design.actions.help.alphafine.AlphaFineConfigManager; import com.fr.design.constants.UIConstants; import com.fr.design.env.DesignerWorkspaceGenerator; import com.fr.design.env.DesignerWorkspaceInfo; +import com.fr.design.env.LocalDesignerWorkspaceInfo; +import com.fr.design.env.RemoteDesignerWorkspaceInfo; import com.fr.file.FILEFactory; import com.fr.general.ComparatorUtils; import com.fr.general.FRLogFormatter; @@ -33,9 +35,10 @@ import com.fr.stable.xml.XMLWriter; import com.fr.stable.xml.XMLableReader; import com.fr.workspace.WorkContext; -import javax.swing.*; +import javax.swing.SwingWorker; import javax.swing.SwingWorker.StateValue; -import java.awt.*; +import java.awt.Color; +import java.awt.Rectangle; import java.io.File; import java.io.FileOutputStream; import java.io.FileReader; @@ -193,7 +196,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { if (installHome != null && !".".equals(installHome)) { String name = Inter.getLocText("FR-Engine_DEFAULT"); String envPath = StableUtils.pathJoin(installHome, ProjectConstants.WEBAPP_NAME, ProjectConstants.WEBINF_NAME); - designerEnvManager.putEnv(name, DesignerWorkspaceInfo.createLocal(name, envPath)); + designerEnvManager.putEnv(name, LocalDesignerWorkspaceInfo.create(name, envPath)); designerEnvManager.setCurEnvName(name); } } @@ -495,7 +498,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { } } String name = Inter.getLocText(new String[]{"Default", "Utils-Report_Runtime_Env"}); - DesignerWorkspaceInfo newDefaultEnv = DesignerWorkspaceInfo.createLocal(name, defaultenvPath); + LocalDesignerWorkspaceInfo newDefaultEnv = LocalDesignerWorkspaceInfo.create(name, defaultenvPath); this.putEnv(name, newDefaultEnv); return newDefaultEnv; } @@ -702,7 +705,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { * 记录名称 和对应的环境 * * @param name 名称 - * @param info 对应的环境信息 + * @param info 对应的环境信息 */ public void putEnv(String name, DesignerWorkspaceInfo info) { @@ -1419,7 +1422,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { // marks:兼容6.1的 // marks:设置默认的目录. String curReportServerName = Inter.getLocText("Server-Embedded_Server"); - DesignerWorkspaceInfo reportServer = DesignerWorkspaceInfo.createLocal(curReportServerName, tmpVal); + LocalDesignerWorkspaceInfo reportServer = LocalDesignerWorkspaceInfo.create(curReportServerName, tmpVal); this.putEnv(curReportServerName, reportServer); this.setCurEnvName(curReportServerName); @@ -1472,8 +1475,11 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { public void readXML(XMLableReader reader) { if (reader.isChildNode()) { String tagName = reader.getTagName(); - if (DesignerWorkspaceInfo.XML_TAG.equals(tagName)) { - DesignerWorkspaceInfo envConfig = (DesignerWorkspaceInfo) GeneralXMLTools.readXMLable(reader); + if (LocalDesignerWorkspaceInfo.XML_TAG.equals(tagName)) { + LocalDesignerWorkspaceInfo envConfig = (LocalDesignerWorkspaceInfo) GeneralXMLTools.readXMLable(reader); + putEnv(name, envConfig); + } else if (RemoteDesignerWorkspaceInfo.XML_TAG.equals(tagName)) { + RemoteDesignerWorkspaceInfo envConfig = (RemoteDesignerWorkspaceInfo) GeneralXMLTools.readXMLable(reader); putEnv(name, envConfig); } } @@ -1599,7 +1605,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { for (Entry entry : nameEnvMap.entrySet()) { writer.startTAG("EnvConfigElement").attr("name", entry.getKey()); DesignerWorkspaceInfo envConfig = entry.getValue(); - GeneralXMLTools.writeXMLable(writer, envConfig, DesignerWorkspaceInfo.XML_TAG); + GeneralXMLTools.writeXMLable(writer, envConfig, envConfig.XML_TAG); writer.end(); } writer.end(); diff --git a/designer-base/src/com/fr/design/actions/file/SwitchExistEnv.java b/designer-base/src/com/fr/design/actions/file/SwitchExistEnv.java index 2ca235b3be..0db58dc361 100644 --- a/designer-base/src/com/fr/design/actions/file/SwitchExistEnv.java +++ b/designer-base/src/com/fr/design/actions/file/SwitchExistEnv.java @@ -21,7 +21,7 @@ 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.util.HashMap; import java.util.Iterator; @@ -66,15 +66,15 @@ public class SwitchExistEnv extends MenuDef { public GetExistEnvAction(String envName) { this.setName(envName); DesignerWorkspaceInfo env = DesignerEnvManager.getEnvManager().getWorkspaceInfo(envName); - switch (env.getType()) - { - case Local:{ + switch (env.getType()) { + case Local: { this.setSmallIcon(BaseUtils.readIcon("com/fr/design/images/data/bind/localconnect.png")); break; - }case Remote:{ - this.setSmallIcon(BaseUtils.readIcon("com/fr/design/images/data/bind/distanceconnect.png")); - break; - } + } + case Remote: { + this.setSmallIcon(BaseUtils.readIcon("com/fr/design/images/data/bind/distanceconnect.png")); + break; + } } } diff --git a/designer-base/src/com/fr/design/env/DesignerWorkspaceInfo.java b/designer-base/src/com/fr/design/env/DesignerWorkspaceInfo.java index b13d810416..755fb53701 100644 --- a/designer-base/src/com/fr/design/env/DesignerWorkspaceInfo.java +++ b/designer-base/src/com/fr/design/env/DesignerWorkspaceInfo.java @@ -1,117 +1,14 @@ 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.XMLable; -import com.fr.stable.xml.XMLableReader; import com.fr.workspace.connect.WorkspaceConnection; -/** - * Created by juhaoyu on 2018/6/15. - */ -public class DesignerWorkspaceInfo implements XMLable { - - private static final int DEFAULT_RPC_PORT = 39999; - - public static final String XML_TAG = "DesignerWorkspace"; - - private DesignerWorkspaceType type; - - private String name; - - private String path; - - private WorkspaceConnection connection; - - public static DesignerWorkspaceInfo createLocal(String name, String path) { - - DesignerWorkspaceInfo info = new DesignerWorkspaceInfo(); - info.connection = null; - info.name = name; - info.path = path; - info.type = DesignerWorkspaceType.Local; - return info; - } - - public void setName(String name) { - - this.name = name; - } - - public DesignerWorkspaceType getType() { - - return type; - } - - public String getName() { - - return name; - } - - public String getPath() { - - return path; - } - - public WorkspaceConnection getConnection() { - - return connection; - } - - public void setType(DesignerWorkspaceType type) { - - this.type = type; - } - - public void setPath(String path) { - - this.path = path; - } - - public void setConnection(WorkspaceConnection connection) { - - this.connection = connection; - } - - @Override - public void readXML(XMLableReader reader) { - - if (reader.isAttr()) { - this.name = reader.getAttrAsString("name", StringUtils.EMPTY); - this.type = DesignerWorkspaceType.valueOf(reader.getAttrAsString("type", "Local")); - this.path = reader.getAttrAsString("path", 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.decrypt(reader.getAttrAsString("password", StringUtils.EMPTY)); - this.connection = new WorkspaceConnection(url, username, password); - } - } - } - - @Override - public void writeXML(XMLPrintWriter writer) { - - writer.attr("name", name); - writer.attr("path", path); - writer.attr("type", type.toString()); - if (this.connection != null) { - writer.startTAG("Connection"); - writer.attr("url", connection.getUrl()); - writer.attr("username", connection.getUserName()); - writer.attr("password", SecurityToolbox.encrypt(connection.getPassword())); - writer.end(); - } - } - - @Override - public Object clone() throws CloneNotSupportedException { - - return null; - } +public interface DesignerWorkspaceInfo extends XMLable { + DesignerWorkspaceType getType(); + + String getName(); + + String getPath(); + + WorkspaceConnection getConnection(); } diff --git a/designer-base/src/com/fr/design/env/LocalDesignerWorkspaceInfo.java b/designer-base/src/com/fr/design/env/LocalDesignerWorkspaceInfo.java new file mode 100644 index 0000000000..709df5dd70 --- /dev/null +++ b/designer-base/src/com/fr/design/env/LocalDesignerWorkspaceInfo.java @@ -0,0 +1,70 @@ +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 { + + public static final String XML_TAG = "LocalDesignerWorkspaceInfo"; + + 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; + } +} diff --git a/designer-base/src/com/fr/design/env/RemoteDesignerWorkspaceInfo.java b/designer-base/src/com/fr/design/env/RemoteDesignerWorkspaceInfo.java new file mode 100644 index 0000000000..a35ea4e259 --- /dev/null +++ b/designer-base/src/com/fr/design/env/RemoteDesignerWorkspaceInfo.java @@ -0,0 +1,83 @@ +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 { + + public static final String XML_TAG = "RemoteDesignerWorkspaceInfo"; + + 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.decrypt(reader.getAttrAsString("password", StringUtils.EMPTY)); + 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.encrypt(connection.getPassword())); + writer.end(); + } + } + + @Override + public Object clone() throws CloneNotSupportedException { + + return null; + } +} diff --git a/designer-base/src/com/fr/design/gui/controlpane/JListControlPane.java b/designer-base/src/com/fr/design/gui/controlpane/JListControlPane.java index bccff1ad78..02bf0301df 100644 --- a/designer-base/src/com/fr/design/gui/controlpane/JListControlPane.java +++ b/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.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.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.MouseAdapter; import java.awt.event.MouseEvent; @@ -383,7 +393,7 @@ public abstract class JListControlPane extends JControlPane { private void wrapActionListener(NameableCreator[] creators) { for (final NameableCreator creator : creators) { - if (!HyperlinkFilterHelper.whetherAddHyperlink4cell(creator.menuName())) { + if (filterNameableCreator(creator)) { continue; } boolean isTrue = ComparatorUtils.equals(creator.menuName(), Inter.getLocText("Datasource-Stored_Procedure")) || @@ -942,6 +952,7 @@ public abstract class JListControlPane extends JControlPane { } return false; } + /** * 设置选中项 * @@ -951,4 +962,12 @@ public abstract class JListControlPane extends JControlPane { nameableList.setSelectedIndex(index); } + + /** + * 用于在list面板中,过滤某些下拉选项 + * @return true:过滤掉这个creator + */ + protected boolean filterNameableCreator(NameableCreator creator) { + return !HyperlinkFilterHelper.whetherAddHyperlink4cell(creator.menuName()); + } } \ No newline at end of file diff --git a/designer-base/src/com/fr/env/EnvListPane.java b/designer-base/src/com/fr/env/EnvListPane.java index f93b7da554..57fea46de7 100644 --- a/designer-base/src/com/fr/env/EnvListPane.java +++ b/designer-base/src/com/fr/env/EnvListPane.java @@ -2,6 +2,8 @@ package com.fr.env; 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.NameObjectCreator; import com.fr.design.gui.controlpane.NameableCreator; @@ -57,9 +59,9 @@ public class EnvListPane extends JListControlPane { @Override public NameableCreator[] createNameableCreators() { NameableCreator local = new NameObjectCreator(Inter.getLocText("Env-Local_Directory"), "com/fr/design/images/data/bind/localconnect.png", - DesignerWorkspaceInfo.class, LocalEnvPane.class); + LocalDesignerWorkspaceInfo.class, LocalEnvPane.class); NameableCreator remote = new NameObjectCreator(Inter.getLocText("Env-Remote_Server"), "com/fr/design/images/data/bind/distanceconnect.png", - DesignerWorkspaceInfo.class, RemoteEnvPane.class); + RemoteDesignerWorkspaceInfo.class, RemoteEnvPane.class); return new NameableCreator[]{local, remote}; } @@ -106,4 +108,9 @@ public class EnvListPane extends JListControlPane { } return this.getSelectedName(); } + + @Override + protected boolean filterNameableCreator(NameableCreator creator) { + return false; + } } \ No newline at end of file diff --git a/designer-base/src/com/fr/env/LocalEnvPane.java b/designer-base/src/com/fr/env/LocalEnvPane.java index c518f1dbec..6412145038 100644 --- a/designer-base/src/com/fr/env/LocalEnvPane.java +++ b/designer-base/src/com/fr/env/LocalEnvPane.java @@ -1,7 +1,7 @@ package com.fr.env; import com.fr.design.beans.BasicBeanPane; -import com.fr.design.env.DesignerWorkspaceInfo; +import com.fr.design.env.LocalDesignerWorkspaceInfo; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itextarea.UITextArea; import com.fr.design.gui.itextfield.UITextField; @@ -21,7 +21,7 @@ import java.io.File; /** * @author yaohwu */ -public class LocalEnvPane extends BasicBeanPane { +public class LocalEnvPane extends BasicBeanPane { private UITextField pathTextField; private JFileTree localEnvTree; @@ -70,9 +70,9 @@ public class LocalEnvPane extends BasicBeanPane { } @Override - public DesignerWorkspaceInfo updateBean() { + public LocalDesignerWorkspaceInfo updateBean() { String path = pathTextField.getText(); - return DesignerWorkspaceInfo.createLocal(StringUtils.EMPTY, path); + return LocalDesignerWorkspaceInfo.create(StringUtils.EMPTY, path); } public String getPath() { @@ -80,7 +80,7 @@ public class LocalEnvPane extends BasicBeanPane { } @Override - public void populateBean(DesignerWorkspaceInfo ob) { + public void populateBean(LocalDesignerWorkspaceInfo ob) { if (StringUtils.isBlank(ob.getPath())) { return; } diff --git a/designer-base/src/com/fr/env/RemoteEnvPane.java b/designer-base/src/com/fr/env/RemoteEnvPane.java index a52308a71a..5e749e2300 100644 --- a/designer-base/src/com/fr/env/RemoteEnvPane.java +++ b/designer-base/src/com/fr/env/RemoteEnvPane.java @@ -3,8 +3,7 @@ package com.fr.env; import com.fr.design.DesignerEnvManager; import com.fr.design.beans.BasicBeanPane; import com.fr.design.border.UITitledBorder; -import com.fr.design.env.DesignerWorkspaceInfo; -import com.fr.design.env.DesignerWorkspaceType; +import com.fr.design.env.RemoteDesignerWorkspaceInfo; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.ilable.UILabel; @@ -56,7 +55,7 @@ import static com.fr.third.guava.base.Optional.fromNullable; /** * @author yaohwu */ -public class RemoteEnvPane extends BasicBeanPane { +public class RemoteEnvPane extends BasicBeanPane { private static final Color TIPS_FONT_COLOR = new Color(0x8f8f92); @@ -261,11 +260,18 @@ public class RemoteEnvPane extends BasicBeanPane { } @Override - public void populateBean(DesignerWorkspaceInfo ob) { + public void populateBean(RemoteDesignerWorkspaceInfo ob) { WorkspaceConnection connection = ob.getConnection(); - this.remoteEnvURL = Strings.isNullOrEmpty(connection.getUrl()) - ? RemoteEnvURL.createDefaultURL() - : new RemoteEnvURL(connection.getUrl()); + if (connection != null) { + this.remoteEnvURL = Strings.isNullOrEmpty(connection.getUrl()) + ? RemoteEnvURL.createDefaultURL() + : 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(); fillIndividualField(); httpsCheckbox.setSelected(this.remoteEnvURL.getHttps()); @@ -274,21 +280,17 @@ public class RemoteEnvPane extends BasicBeanPane { fileChooserButton.setEnabled(this.remoteEnvURL.getHttps()); updateHttpsConfigPanel(); - this.usernameInput.setText(fromNullable(connection.getUserName()).or(StringUtils.EMPTY)); - this.passwordInput.setText(fromNullable(connection.getPassword()).or(StringUtils.EMPTY)); + } @Override - public DesignerWorkspaceInfo updateBean() { + public RemoteDesignerWorkspaceInfo updateBean() { WorkspaceConnection connection = new WorkspaceConnection( this.remoteEnvURL.getURL(), this.usernameInput.getText(), new String(this.passwordInput.getPassword())); - DesignerWorkspaceInfo config = new DesignerWorkspaceInfo(); - config.setConnection(connection); - config.setType(DesignerWorkspaceType.Remote); - return config; + return RemoteDesignerWorkspaceInfo.create(connection); } @Override @@ -472,7 +474,7 @@ public class RemoteEnvPane extends BasicBeanPane { @Override protected Void doInBackground() throws Exception { - final DesignerWorkspaceInfo remoteEnv = updateBean(); + final RemoteDesignerWorkspaceInfo remoteEnv = updateBean(); WorkContext.getConnector().testConnection(remoteEnv.getConnection()); return null; } diff --git a/designer-realize/src/com/fr/start/EnvSwitcher.java b/designer-realize/src/com/fr/start/EnvSwitcher.java index f96216e32e..ce334bd8e8 100644 --- a/designer-realize/src/com/fr/start/EnvSwitcher.java +++ b/designer-realize/src/com/fr/start/EnvSwitcher.java @@ -19,8 +19,9 @@ public class EnvSwitcher { Workspace workspace = DesignerWorkspaceGenerator.generate(DesignerEnvManager.getEnvManager().getWorkspaceInfo(current)); if (workspace == null) { TemplatePane.getInstance().dealEvnExceptionWhenStartDesigner(); + } else { + WorkContext.switchTo(workspace); } - WorkContext.switchTo(workspace); } catch (Throwable e) { TemplatePane.getInstance().dealEvnExceptionWhenStartDesigner(); } From 5c66b02c7b7b438e535bce2c1ba69cb7e55053a0 Mon Sep 17 00:00:00 2001 From: ju Date: Mon, 18 Jun 2018 14:28:02 +0800 Subject: [PATCH 17/20] f --- .../src/com/fr/design/DesignerEnvManager.java | 12 +++++----- .../env/LocalDesignerWorkspaceInfo.java | 4 +--- .../env/RemoteDesignerWorkspaceInfo.java | 4 +--- .../com/fr/design/mainframe/TemplatePane.java | 2 +- .../src/com/fr/env/RemoteEnvPane.java | 24 +++++++++++-------- .../src/com/fr/start/EnvSwitcher.java | 9 ------- 6 files changed, 23 insertions(+), 32 deletions(-) diff --git a/designer-base/src/com/fr/design/DesignerEnvManager.java b/designer-base/src/com/fr/design/DesignerEnvManager.java index d8a76b5647..30f5507d0d 100644 --- a/designer-base/src/com/fr/design/DesignerEnvManager.java +++ b/designer-base/src/com/fr/design/DesignerEnvManager.java @@ -10,6 +10,7 @@ import com.fr.design.actions.help.alphafine.AlphaFineConfigManager; import com.fr.design.constants.UIConstants; import com.fr.design.env.DesignerWorkspaceGenerator; import com.fr.design.env.DesignerWorkspaceInfo; +import com.fr.design.env.DesignerWorkspaceType; import com.fr.design.env.LocalDesignerWorkspaceInfo; import com.fr.design.env.RemoteDesignerWorkspaceInfo; import com.fr.file.FILEFactory; @@ -35,10 +36,9 @@ import com.fr.stable.xml.XMLWriter; import com.fr.stable.xml.XMLableReader; import com.fr.workspace.WorkContext; -import javax.swing.SwingWorker; +import javax.swing.*; import javax.swing.SwingWorker.StateValue; -import java.awt.Color; -import java.awt.Rectangle; +import java.awt.*; import java.io.File; import java.io.FileOutputStream; import java.io.FileReader; @@ -1475,10 +1475,10 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { public void readXML(XMLableReader reader) { if (reader.isChildNode()) { String tagName = reader.getTagName(); - if (LocalDesignerWorkspaceInfo.XML_TAG.equals(tagName)) { + if (DesignerWorkspaceType.Local.toString().equals(tagName)) { LocalDesignerWorkspaceInfo envConfig = (LocalDesignerWorkspaceInfo) GeneralXMLTools.readXMLable(reader); putEnv(name, envConfig); - } else if (RemoteDesignerWorkspaceInfo.XML_TAG.equals(tagName)) { + } else if (DesignerWorkspaceType.Remote.toString().equals(tagName)) { RemoteDesignerWorkspaceInfo envConfig = (RemoteDesignerWorkspaceInfo) GeneralXMLTools.readXMLable(reader); putEnv(name, envConfig); } @@ -1605,7 +1605,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { for (Entry entry : nameEnvMap.entrySet()) { writer.startTAG("EnvConfigElement").attr("name", entry.getKey()); DesignerWorkspaceInfo envConfig = entry.getValue(); - GeneralXMLTools.writeXMLable(writer, envConfig, envConfig.XML_TAG); + GeneralXMLTools.writeXMLable(writer, envConfig, envConfig.getType().toString()); writer.end(); } writer.end(); diff --git a/designer-base/src/com/fr/design/env/LocalDesignerWorkspaceInfo.java b/designer-base/src/com/fr/design/env/LocalDesignerWorkspaceInfo.java index 709df5dd70..87e556d922 100644 --- a/designer-base/src/com/fr/design/env/LocalDesignerWorkspaceInfo.java +++ b/designer-base/src/com/fr/design/env/LocalDesignerWorkspaceInfo.java @@ -9,9 +9,7 @@ import com.fr.workspace.connect.WorkspaceConnection; * Created by juhaoyu on 2018/6/15. */ public class LocalDesignerWorkspaceInfo implements DesignerWorkspaceInfo { - - public static final String XML_TAG = "LocalDesignerWorkspaceInfo"; - + private String name; private String path; diff --git a/designer-base/src/com/fr/design/env/RemoteDesignerWorkspaceInfo.java b/designer-base/src/com/fr/design/env/RemoteDesignerWorkspaceInfo.java index a35ea4e259..428878dea8 100644 --- a/designer-base/src/com/fr/design/env/RemoteDesignerWorkspaceInfo.java +++ b/designer-base/src/com/fr/design/env/RemoteDesignerWorkspaceInfo.java @@ -7,9 +7,7 @@ import com.fr.stable.xml.XMLableReader; import com.fr.workspace.connect.WorkspaceConnection; public class RemoteDesignerWorkspaceInfo implements DesignerWorkspaceInfo { - - public static final String XML_TAG = "RemoteDesignerWorkspaceInfo"; - + private String name; private WorkspaceConnection connection; diff --git a/designer-base/src/com/fr/design/mainframe/TemplatePane.java b/designer-base/src/com/fr/design/mainframe/TemplatePane.java index f312e73c5a..fc165928b9 100644 --- a/designer-base/src/com/fr/design/mainframe/TemplatePane.java +++ b/designer-base/src/com/fr/design/mainframe/TemplatePane.java @@ -142,7 +142,7 @@ public class TemplatePane extends JPanel implements MouseListener { @Override public void success() { - + DesignerEnvManager.getEnvManager().setCurEnvName(selectedName); DesignUtils.refreshDesignerFrame(); } }); diff --git a/designer-base/src/com/fr/env/RemoteEnvPane.java b/designer-base/src/com/fr/env/RemoteEnvPane.java index 5e749e2300..137db5ff6d 100644 --- a/designer-base/src/com/fr/env/RemoteEnvPane.java +++ b/designer-base/src/com/fr/env/RemoteEnvPane.java @@ -47,6 +47,7 @@ import java.awt.event.MouseEvent; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.io.File; +import java.util.concurrent.ExecutionException; import static com.fr.design.layout.TableLayout.FILL; import static com.fr.design.layout.TableLayout.PREFERRED; @@ -60,9 +61,10 @@ public class RemoteEnvPane extends BasicBeanPane { private static final Color TIPS_FONT_COLOR = new Color(0x8f8f92); private JDialog dialog; - private UILabel message; - private UIButton okButton; - private UIButton cancelButton; + private UILabel message = new UILabel(); + private UIButton okButton = new UIButton(Inter.getLocText("OK")); + private UIButton cancelButton = new UIButton(Inter.getLocText("Cancel")); + ; /** * 是否启用 https 勾选框 @@ -469,23 +471,25 @@ public class RemoteEnvPane extends BasicBeanPane { } private void tryConnectRemoteEnv() { - final SwingWorker worker = new SwingWorker() { + final SwingWorker worker = new SwingWorker() { @Override - protected Void doInBackground() throws Exception { + protected Boolean doInBackground() throws Exception { final RemoteDesignerWorkspaceInfo remoteEnv = updateBean(); - WorkContext.getConnector().testConnection(remoteEnv.getConnection()); - return null; + return WorkContext.getConnector().testConnection(remoteEnv.getConnection()); } @Override protected void done() { okButton.setEnabled(true); try { - get(); - message.setText(Inter.getLocText("Fine-Designer_Basic_Remote_Connect_Successful")); - } catch (Exception e) { + if (get()) { + message.setText(Inter.getLocText("Fine-Designer_Basic_Remote_Connect_Successful")); + } else { + message.setText(Inter.getLocText("Fine-Designer_Basic_Remote_Connect_Failed")); + } + } catch (InterruptedException | ExecutionException e) { message.setText(Inter.getLocText("Fine-Designer_Basic_Remote_Connect_Failed")); } } diff --git a/designer-realize/src/com/fr/start/EnvSwitcher.java b/designer-realize/src/com/fr/start/EnvSwitcher.java index ce334bd8e8..301c38f2de 100644 --- a/designer-realize/src/com/fr/start/EnvSwitcher.java +++ b/designer-realize/src/com/fr/start/EnvSwitcher.java @@ -26,13 +26,4 @@ public class EnvSwitcher { TemplatePane.getInstance().dealEvnExceptionWhenStartDesigner(); } } - - /** - * 找不到默认的工作空间时,让用户手动选择一个 - */ - private Workspace chooseWorkspace() { - - return null; - } - } From d28eceecf6611f710425841dacb809d917bc58b6 Mon Sep 17 00:00:00 2001 From: ju Date: Mon, 18 Jun 2018 17:47:39 +0800 Subject: [PATCH 18/20] f --- .../com/fr/design/env/RemoteDesignerWorkspaceInfo.java | 8 ++++---- designer-base/src/com/fr/design/env/RemoteWorkspace.java | 5 +++-- .../mainframe/loghandler/socketio/DesignerSocketIO.java | 2 +- .../src/com/fr/design/remote/ui/UserManagerPane.java | 5 +++-- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/designer-base/src/com/fr/design/env/RemoteDesignerWorkspaceInfo.java b/designer-base/src/com/fr/design/env/RemoteDesignerWorkspaceInfo.java index 428878dea8..1fc63d8e66 100644 --- a/designer-base/src/com/fr/design/env/RemoteDesignerWorkspaceInfo.java +++ b/designer-base/src/com/fr/design/env/RemoteDesignerWorkspaceInfo.java @@ -54,7 +54,7 @@ public class RemoteDesignerWorkspaceInfo implements DesignerWorkspaceInfo { String url = reader.getAttrAsString("url", StringUtils.EMPTY); String username = reader.getAttrAsString("username", StringUtils.EMPTY); //密码解密 - String password = SecurityToolbox.decrypt(reader.getAttrAsString("password", StringUtils.EMPTY)); + String password = SecurityToolbox.defaultDecrypt(reader.getAttrAsString("password", StringUtils.EMPTY)); this.connection = new WorkspaceConnection(url, username, password); } } @@ -68,14 +68,14 @@ public class RemoteDesignerWorkspaceInfo implements DesignerWorkspaceInfo { writer.startTAG("Connection"); writer.attr("url", connection.getUrl()); writer.attr("username", connection.getUserName()); - writer.attr("password", SecurityToolbox.encrypt(connection.getPassword())); + writer.attr("password", SecurityToolbox.defaultEncrypt(connection.getPassword())); writer.end(); } } - + @Override public Object clone() throws CloneNotSupportedException { - + return null; } } diff --git a/designer-base/src/com/fr/design/env/RemoteWorkspace.java b/designer-base/src/com/fr/design/env/RemoteWorkspace.java index 12e13f7384..9007ac5aa3 100644 --- a/designer-base/src/com/fr/design/env/RemoteWorkspace.java +++ b/designer-base/src/com/fr/design/env/RemoteWorkspace.java @@ -1,11 +1,12 @@ 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; -import com.fr.workspace.server.WorkspaceServerContext; /** * Created by juhaoyu on 2018/6/14. @@ -59,7 +60,7 @@ public class RemoteWorkspace implements Workspace { @Override public boolean isRoot() { try { - return RemoteDesignAuthenticateUtils.isRoot(WorkspaceServerContext.currentUsername()); + return WorkContext.getCurrent().get(DecisionOperator.class).isRoot(WorkContext.getConnector().currentUser()); } catch (Exception e) { return false; } diff --git a/designer-base/src/com/fr/design/mainframe/loghandler/socketio/DesignerSocketIO.java b/designer-base/src/com/fr/design/mainframe/loghandler/socketio/DesignerSocketIO.java index c98eee7d5a..85f9911f20 100644 --- a/designer-base/src/com/fr/design/mainframe/loghandler/socketio/DesignerSocketIO.java +++ b/designer-base/src/com/fr/design/mainframe/loghandler/socketio/DesignerSocketIO.java @@ -84,7 +84,7 @@ public class DesignerSocketIO { // } // } // }); - socketIO.get().connect(); +// socketIO.get().connect(); } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); } diff --git a/designer-base/src/com/fr/design/remote/ui/UserManagerPane.java b/designer-base/src/com/fr/design/remote/ui/UserManagerPane.java index c247b109d4..781f1cfca2 100644 --- a/designer-base/src/com/fr/design/remote/ui/UserManagerPane.java +++ b/designer-base/src/com/fr/design/remote/ui/UserManagerPane.java @@ -18,6 +18,7 @@ import com.fr.env.operator.decision.DecisionOperator; import com.fr.general.Inter; import com.fr.stable.StringUtils; import com.fr.third.guava.collect.ImmutableList; +import com.fr.workspace.WorkContext; import javax.swing.BorderFactory; import javax.swing.DefaultListModel; @@ -278,8 +279,8 @@ public class UserManagerPane extends BasicPane { @Override protected List doInBackground() { addingMembers.clear(); -// String username = EnvConfigUtils.getUsername(EnvContext.currentEnv()); -// addingMembers.addAll(EnvProxy.get(DecisionOperator.class).getMembers(username, keyword)); + String username = WorkContext.getConnector().currentUser(); + addingMembers.addAll(WorkContext.getCurrent().get(DecisionOperator.class).getMembers(username, keyword)); return addingMembers; } From dd04f9bb124bd03b1ff0e3d8591c6538e8856734 Mon Sep 17 00:00:00 2001 From: ju Date: Mon, 18 Jun 2018 19:07:13 +0800 Subject: [PATCH 19/20] fix --- .../src/com/fr/design/env/RemoteDesignerWorkspaceInfo.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer-base/src/com/fr/design/env/RemoteDesignerWorkspaceInfo.java b/designer-base/src/com/fr/design/env/RemoteDesignerWorkspaceInfo.java index 1fc63d8e66..7266cf0d74 100644 --- a/designer-base/src/com/fr/design/env/RemoteDesignerWorkspaceInfo.java +++ b/designer-base/src/com/fr/design/env/RemoteDesignerWorkspaceInfo.java @@ -54,7 +54,7 @@ public class RemoteDesignerWorkspaceInfo implements DesignerWorkspaceInfo { String url = reader.getAttrAsString("url", StringUtils.EMPTY); String username = reader.getAttrAsString("username", StringUtils.EMPTY); //密码解密 - String password = SecurityToolbox.defaultDecrypt(reader.getAttrAsString("password", StringUtils.EMPTY)); + String password = SecurityToolbox.defaultDecrypt(reader.getAttrAsString("password", StringUtils.EMPTY).replaceAll(" ","\r\n")); this.connection = new WorkspaceConnection(url, username, password); } } From 5546bb4461b45793baf34ac4ff000383f7464515 Mon Sep 17 00:00:00 2001 From: ju Date: Mon, 18 Jun 2018 19:07:36 +0800 Subject: [PATCH 20/20] fix --- designer-base/src/com/fr/file/FileNodeFILE.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/designer-base/src/com/fr/file/FileNodeFILE.java b/designer-base/src/com/fr/file/FileNodeFILE.java index 204152c7d0..9511376646 100644 --- a/designer-base/src/com/fr/file/FileNodeFILE.java +++ b/designer-base/src/com/fr/file/FileNodeFILE.java @@ -34,9 +34,7 @@ public class FileNodeFILE implements FILE { parentDir = fn.getParent(); } - this.node = new FileNode(StableUtils.pathJoin(new String[]{ - parentDir, name - }), isDir); + this.node = new FileNode(StableUtils.pathJoin(parentDir, name), isDir); this.envPath = WorkContext.getCurrent().getPath(); }