|
|
|
@ -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() { |
|
|
|
@ -42,7 +37,9 @@ public class SwitchExistEnv extends MenuDef {
|
|
|
|
|
initMenuDef(); |
|
|
|
|
JTemplate<?, ?> t = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); |
|
|
|
|
if (t != null) { |
|
|
|
|
GeneralContext.addEnvWillChangedListener(t.getFullPathName(), new EnvChangedListener() { |
|
|
|
|
GeneralContext.addEnvWillChangedListener( |
|
|
|
|
t.getFullPathName(), |
|
|
|
|
new EnvChangedListener() { |
|
|
|
|
public void envChanged() { |
|
|
|
|
SwitchExistEnv.this.clearShortCuts(); |
|
|
|
|
initMenuDef(); |
|
|
|
@ -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,26 +97,22 @@ 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(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|