From 7fb2911df8e9ee17dee53888855c7131695e596c Mon Sep 17 00:00:00 2001 From: hzzz Date: Thu, 31 May 2018 19:34:21 +0800 Subject: [PATCH] fix --- .../design/actions/file/SwitchExistEnv.java | 60 ++++++++----------- .../loghandler/DesignerLogHandler.java | 5 ++ 2 files changed, 31 insertions(+), 34 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 d58c6cc7f..278dfe5cc 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,13 @@ package com.fr.design.actions.file; import com.fr.base.BaseUtils; -import com.fr.base.Env; -import com.fr.base.FRContext; -import com.fr.dav.LocalEnv; +import com.fr.base.env.resource.LocalEnvConfig; +import com.fr.base.env.resource.RemoteEnvConfig; +import com.fr.core.env.EnvConfig; 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.dialog.InformationWarnPane; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.JTemplate; @@ -18,21 +17,17 @@ import com.fr.design.menu.MenuDef; import com.fr.design.menu.SeparatorDef; import com.fr.env.RemoteEnv; import com.fr.env.SignIn; -import com.fr.general.ComparatorUtils; import com.fr.general.GeneralContext; import com.fr.general.Inter; import com.fr.log.FineLoggerFactory; import com.fr.stable.EnvChangedListener; -import com.fr.stable.ProductConstants; -import com.fr.stable.StringUtils; -import javax.swing.*; +import javax.swing.JOptionPane; import java.awt.event.ActionEvent; import java.util.HashMap; import java.util.Iterator; import java.util.Map; - public class SwitchExistEnv extends MenuDef { public SwitchExistEnv() { @@ -41,18 +36,20 @@ public class SwitchExistEnv extends MenuDef { this.setHasScrollSubMenu(true); initMenuDef(); JTemplate t = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); - if(t != null) { - GeneralContext.addEnvWillChangedListener(t.getFullPathName(), new EnvChangedListener() { - public void envChanged() { - SwitchExistEnv.this.clearShortCuts(); - initMenuDef(); - } - }); + if (t != null) { + GeneralContext.addEnvWillChangedListener( + t.getFullPathName(), + new EnvChangedListener() { + public void envChanged() { + SwitchExistEnv.this.clearShortCuts(); + initMenuDef(); + } + }); } } private void initMenuDef() { - //ButtonGroup group = new ButtonGroup(); + // ButtonGroup group = new ButtonGroup(); Iterator nameIt = DesignerEnvManager.getEnvManager().getEnvNameIterator(); while (nameIt.hasNext()) { String name = nameIt.next(); @@ -65,15 +62,14 @@ public class SwitchExistEnv extends MenuDef { public static class GetExistEnvAction extends UpdateAction implements ResponseDataSourceChange { public GetExistEnvAction() { - } public GetExistEnvAction(String envName) { this.setName(envName); - Env env = DesignerEnvManager.getEnvManager().getEnv(envName); - if (env instanceof LocalEnv) { + 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 RemoteEnv) { + } else if (env instanceof RemoteEnvConfig) { this.setSmallIcon(BaseUtils.readIcon("com/fr/design/images/data/bind/distanceconnect.png")); } } @@ -101,28 +97,24 @@ public class SwitchExistEnv extends MenuDef { */ public void actionPerformed(ActionEvent e) { DesignerEnvManager envManager = DesignerEnvManager.getEnvManager(); - Env selectedEnv = envManager.getEnv(this.getName()); + EnvConfig selectedEnv = envManager.getEnv(this.getName()); try { if (selectedEnv instanceof RemoteEnv && !((RemoteEnv) selectedEnv).testServerConnection()) { - JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Inter.getLocText(new String[]{"M-SwitchWorkspace", "Failed"})); - return; - } - String remoteVersion = selectedEnv.getDesignerVersion(); - if (StringUtils.isBlank(remoteVersion) || ComparatorUtils.compare(remoteVersion, ProductConstants.DESIGNER_VERSION) < 0) { - String infor = Inter.getLocText("Server-version-tip"); - String moreInfo = Inter.getLocText("Server-version-tip-moreInfo"); - FineLoggerFactory.getLogger().error(infor); - new InformationWarnPane(infor, moreInfo, Inter.getLocText("Tooltips")).show(); + JOptionPane.showMessageDialog( + DesignerContext.getDesignerFrame(), + Inter.getLocText(new String[]{"M-SwitchWorkspace", "Failed"})); return; } SignIn.signIn(selectedEnv); HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().refreshToolArea(); fireDSChanged(); } catch (Exception em) { - FRContext.getLogger().error(em.getMessage(), em); - JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Inter.getLocText(new String[]{"M-SwitchWorkspace", "Failed"})); + FineLoggerFactory.getLogger().error(em.getMessage(), em); + JOptionPane.showMessageDialog( + DesignerContext.getDesignerFrame(), + Inter.getLocText(new String[]{"M-SwitchWorkspace", "Failed"})); TemplatePane.getInstance().editItems(); } } } -} \ No newline at end of file +} diff --git a/designer-base/src/com/fr/design/mainframe/loghandler/DesignerLogHandler.java b/designer-base/src/com/fr/design/mainframe/loghandler/DesignerLogHandler.java index ebc69aef5..846583538 100644 --- a/designer-base/src/com/fr/design/mainframe/loghandler/DesignerLogHandler.java +++ b/designer-base/src/com/fr/design/mainframe/loghandler/DesignerLogHandler.java @@ -9,6 +9,7 @@ import com.fr.design.layout.FRGUIPaneFactory; import com.fr.general.ComparatorUtils; import com.fr.general.GeneralContext; import com.fr.general.Inter; +import com.fr.general.LogRecordTime; import com.fr.general.log.Log4jConfig; import com.fr.log.FineLoggerFactory; import com.fr.log.LogHandler; @@ -341,4 +342,8 @@ public class DesignerLogHandler { }; } + + public void printRemoteLog(LogRecordTime logRecordTime) { + logHandlerArea.printStackTrace(logRecordTime); + } } \ No newline at end of file