From 20d7b397a669155720bdade84e1db6fca190d38c Mon Sep 17 00:00:00 2001 From: richie Date: Fri, 8 Jun 2018 12:22:24 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=A0JIRA=E4=BB=BB=E5=8A=A1=20=E8=AF=BB?= =?UTF-8?q?=E5=8F=96=E8=B5=84=E6=BA=90=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/actions/file/SwitchExistEnv.java | 31 +++++----- .../com/fr/design/env/RemoteEnvConfig.java | 16 ++++-- .../gui/itree/filetree/TemplateFileTree.java | 5 +- .../com/fr/design/mainframe/TemplatePane.java | 56 ++++++++----------- .../src/com/fr/design/utils/DesignUtils.java | 29 ---------- designer-base/src/com/fr/env/RemoteEnv.java | 6 ++ designer-base/src/com/fr/env/SignIn.java | 2 +- 7 files changed, 60 insertions(+), 85 deletions(-) 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 decc72daac..c956670576 100644 --- a/designer-base/src/com/fr/design/actions/file/SwitchExistEnv.java +++ b/designer-base/src/com/fr/design/actions/file/SwitchExistEnv.java @@ -1,6 +1,7 @@ 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; @@ -17,6 +18,7 @@ import com.fr.design.mainframe.TemplatePane; 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; @@ -98,24 +100,25 @@ public class SwitchExistEnv extends MenuDef { */ public void actionPerformed(ActionEvent e) { DesignerEnvManager envManager = DesignerEnvManager.getEnvManager(); - EnvConfig selectedEnv = envManager.getEnv(this.getName()); - try { - if (selectedEnv instanceof RemoteEnv && !((RemoteEnv) selectedEnv).testServerConnection()) { + final String envName = getName(); + EnvConfig selectedEnv = envManager.getEnv(envName); + EnvUpdater.updateEnv(EnvGenerator.generate(selectedEnv), new Callback() { + @Override + public void success() { + DesignerEnvManager.getEnvManager().setCurEnvName(envName); + DesignUtils.refreshDesignerFrame(); + HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().refreshToolArea(); + fireDSChanged(); + } + + @Override + public void fail() { + TemplatePane.getInstance().editItems(); JOptionPane.showMessageDialog( DesignerContext.getDesignerFrame(), Inter.getLocText(new String[]{"M-SwitchWorkspace", "Failed"})); - return; } - EnvUpdater.updateEnv(EnvGenerator.generate(selectedEnv)); - HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().refreshToolArea(); - fireDSChanged(); - } catch (Exception em) { - FineLoggerFactory.getLogger().error(em.getMessage(), em); - JOptionPane.showMessageDialog( - DesignerContext.getDesignerFrame(), - Inter.getLocText(new String[]{"M-SwitchWorkspace", "Failed"})); - TemplatePane.getInstance().editItems(); - } + }); } } } diff --git a/designer-base/src/com/fr/design/env/RemoteEnvConfig.java b/designer-base/src/com/fr/design/env/RemoteEnvConfig.java index 5f6b763dfa..fc701d8ca7 100644 --- a/designer-base/src/com/fr/design/env/RemoteEnvConfig.java +++ b/designer-base/src/com/fr/design/env/RemoteEnvConfig.java @@ -69,7 +69,7 @@ public class RemoteEnvConfig extends AbstractEnvConfig { @Override public String getDescription(String name) { - return username + "@" + name + "[" + Inter.getLocText("") + "]"; + return username + "@" + name + "[" + Inter.getLocText("Fine-Designer_Basic_Remote_Env") + "]"; } @Override @@ -85,6 +85,11 @@ public class RemoteEnvConfig extends AbstractEnvConfig { 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); } } } @@ -94,14 +99,13 @@ public class RemoteEnvConfig extends AbstractEnvConfig { super.writeXML(writer); writer.startTAG("Attr") .attr("host", host) - .attr("port", port) - .attr("username", username); + .attr("port", port); + writer.end(); + writer.startTAG("Username").textNode(username).end(); if (StringUtils.isNotEmpty(password)) { - writer.attr("password", SecurityToolbox.encrypt(password)); + writer.startTAG("Password").textNode(SecurityToolbox.encrypt(password)).end(); } - writer.end(); - } @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 650712bb0f..32c95f672f 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,10 +1,12 @@ package com.fr.design.gui.itree.filetree; import com.fr.base.Env; +import com.fr.base.FRContext; 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; @@ -102,8 +104,7 @@ public class TemplateFileTree extends EnvFileTree { } public FileNode[] listFile(String path) throws Exception { - String extra = EnvProxy.get(FileOperator.class).readExtraResourcePath(path); - return EnvProxy.get(FileOperator.class).list(extra, path); + return FRContext.getCurrentEnv().getFileOperator().list("reportlets", path); } /* diff --git a/designer-base/src/com/fr/design/mainframe/TemplatePane.java b/designer-base/src/com/fr/design/mainframe/TemplatePane.java index 79904a90ee..5c539cd9bf 100644 --- a/designer-base/src/com/fr/design/mainframe/TemplatePane.java +++ b/designer-base/src/com/fr/design/mainframe/TemplatePane.java @@ -1,41 +1,34 @@ 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.dav.LocalEnv; +import com.fr.core.env.impl.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.RemoteEnvConfig; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.file.TemplateTreePane; 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 javax.swing.BorderFactory; -import javax.swing.Icon; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.SwingUtilities; -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Cursor; -import java.awt.Dimension; -import java.awt.GradientPaint; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.Point; +import javax.swing.*; +import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseEvent; @@ -122,27 +115,23 @@ public class TemplatePane extends JPanel implements MouseListener { } private boolean envListOkAction(EnvListPane envListPane) { - String selectedName = envListPane.updateEnvManager(); + final String selectedName = envListPane.updateEnvManager(); DesignerEnvManager envManager = DesignerEnvManager.getEnvManager(); EnvConfig selectedEnv = envManager.getEnv(selectedName); GeneralContext.fireEnvWillChangeListener(); try { - //如果是远程的还要先测试下,如果失败就不切换 - if (selectedEnv instanceof RemoteEnv) { - if (!((RemoteEnv) selectedEnv).testServerConnection()) { + EnvUpdater.updateEnv(EnvGenerator.generate(selectedEnv), new Callback() { + @Override + public void fail() { JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Inter.getLocText(new String[]{"M-SwitchWorkspace", "Failed"})); - return false; - } else { - String remoteVersion = getDesignerVersion(selectedEnv); - if (StringUtils.isBlank(remoteVersion) || ComparatorUtils.compare(remoteVersion, ProductConstants.DESIGNER_VERSION) < 0) { - String infor = Inter.getLocText("Server-version-tip"); - String moreInfo = Inter.getLocText("Server-version-tip-moreInfo"); - new InformationWarnPane(infor, moreInfo, Inter.getLocText("Tooltips")).show(); - return false; - } } - } - EnvUpdater.updateEnv(EnvGenerator.generate(selectedEnv)); + + @Override + public void success() { + DesignerEnvManager.getEnvManager().setCurEnvName(selectedName); + DesignUtils.refreshDesignerFrame(); + } + }); JTemplate template = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); if (template != null) { template.refreshToolArea(); @@ -186,11 +175,12 @@ public class TemplatePane extends JPanel implements MouseListener { } private void setJLabel(String name) { - if (DesignerEnvManager.getEnvManager().getEnv(name) instanceof LocalEnv) { - envLabel.setIcon(BaseUtils.readIcon("com/fr/design/images/data/bind/localconnect.png")); + EnvConfig config = DesignerEnvManager.getEnvManager().getEnv(name); + if (config instanceof LocalEnvConfig) { + envLabel.setIcon(IOUtils.readIcon("com/fr/design/images/data/bind/localconnect.png")); - } else if (DesignerEnvManager.getEnvManager().getEnv(name) instanceof RemoteEnv) { - envLabel.setIcon(BaseUtils.readIcon("com/fr/design/images/data/bind/distanceconnect.png")); + } else if (config instanceof RemoteEnvConfig) { + envLabel.setIcon(IOUtils.readIcon("com/fr/design/images/data/bind/distanceconnect.png")); } envLabel.setText(name); envLabel.repaint(); diff --git a/designer-base/src/com/fr/design/utils/DesignUtils.java b/designer-base/src/com/fr/design/utils/DesignUtils.java index 889e52dd61..60b010b4c4 100644 --- a/designer-base/src/com/fr/design/utils/DesignUtils.java +++ b/designer-base/src/com/fr/design/utils/DesignUtils.java @@ -1,19 +1,15 @@ package com.fr.design.utils; import com.fr.base.BaseUtils; -import com.fr.base.Env; import com.fr.base.EnvException; import com.fr.base.FRContext; import com.fr.base.FeedBackInfo; import com.fr.base.ServerConfig; import com.fr.base.Utils; -import com.fr.base.env.EnvUpdater; import com.fr.base.remote.RemoteDeziConstants; -import com.fr.core.env.EnvConfig; import com.fr.dav.DavXMLUtils; import com.fr.design.DesignerEnvManager; import com.fr.design.ExtraDesignClassManager; -import com.fr.design.env.EnvGenerator; import com.fr.design.fun.DesignerEnvProcessor; import com.fr.design.gui.UILookAndFeel; import com.fr.design.mainframe.DesignerContext; @@ -186,31 +182,6 @@ public class DesignUtils { }); } - /** - * 当前的报表运行环境切换到env - * - * @param config 需要切换去的环境 - */ - public static void switchToEnv(EnvConfig config) { - if (config == null) { - return; - } - - // 看一下这个env在DesignerEnvManager里面有没有对应的,有的话就setCurrentEnvName - DesignerEnvManager envManager = DesignerEnvManager.getEnvManager(); - java.util.Iterator nameIt = envManager.getEnvNameIterator(); - while (nameIt.hasNext()) { - String name = nameIt.next(); - if (ComparatorUtils.equals(envManager.getEnv(name), config)) { - envManager.setCurEnvName(name); - break; - } - } - Env env = EnvGenerator.generate(config); - EnvUpdater.updateEnv(env); - refreshDesignerFrame(); - } - public static void refreshDesignerFrame() { // 刷新DesignerFrame里面的面板 diff --git a/designer-base/src/com/fr/env/RemoteEnv.java b/designer-base/src/com/fr/env/RemoteEnv.java index 07e9274ed9..eae3d57149 100644 --- a/designer-base/src/com/fr/env/RemoteEnv.java +++ b/designer-base/src/com/fr/env/RemoteEnv.java @@ -2,6 +2,7 @@ package com.fr.env; import com.fr.base.EnvException; import com.fr.base.TableData; +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.remote.RemoteDeziConstants; @@ -124,6 +125,11 @@ public class RemoteEnv extends AbstractEnv implements DesignAut return MessageSendExecutor.getInstance().execute(FileOperator.class); } + @Override + public CommonOperator getCommonOperator() throws Exception { + return MessageSendExecutor.getInstance().execute(CommonOperator.class); + } + @Override public RemoteEnvConfig getEnvConfig() { return config; diff --git a/designer-base/src/com/fr/env/SignIn.java b/designer-base/src/com/fr/env/SignIn.java index c93338b23d..bca04d2484 100644 --- a/designer-base/src/com/fr/env/SignIn.java +++ b/designer-base/src/com/fr/env/SignIn.java @@ -41,6 +41,6 @@ public class SignIn { if (env != null && AssistUtils.equals(env.getEnvConfig(), selectedEnv)) { env.disconnect(); } - DesignUtils.switchToEnv(selectedEnv); + //DesignUtils.switchToEnv(selectedEnv); } } \ No newline at end of file