|
|
@ -1,14 +1,13 @@ |
|
|
|
package com.fr.design.actions.file; |
|
|
|
package com.fr.design.actions.file; |
|
|
|
|
|
|
|
|
|
|
|
import com.fr.base.BaseUtils; |
|
|
|
import com.fr.base.BaseUtils; |
|
|
|
import com.fr.base.Env; |
|
|
|
import com.fr.base.env.resource.LocalEnvConfig; |
|
|
|
import com.fr.base.FRContext; |
|
|
|
import com.fr.base.env.resource.RemoteEnvConfig; |
|
|
|
import com.fr.dav.LocalEnv; |
|
|
|
import com.fr.core.env.EnvConfig; |
|
|
|
import com.fr.design.DesignerEnvManager; |
|
|
|
import com.fr.design.DesignerEnvManager; |
|
|
|
import com.fr.design.actions.UpdateAction; |
|
|
|
import com.fr.design.actions.UpdateAction; |
|
|
|
import com.fr.design.data.DesignTableDataManager; |
|
|
|
import com.fr.design.data.DesignTableDataManager; |
|
|
|
import com.fr.design.data.tabledata.ResponseDataSourceChange; |
|
|
|
import com.fr.design.data.tabledata.ResponseDataSourceChange; |
|
|
|
import com.fr.design.dialog.InformationWarnPane; |
|
|
|
|
|
|
|
import com.fr.design.file.HistoryTemplateListPane; |
|
|
|
import com.fr.design.file.HistoryTemplateListPane; |
|
|
|
import com.fr.design.mainframe.DesignerContext; |
|
|
|
import com.fr.design.mainframe.DesignerContext; |
|
|
|
import com.fr.design.mainframe.JTemplate; |
|
|
|
import com.fr.design.mainframe.JTemplate; |
|
|
@ -18,21 +17,17 @@ import com.fr.design.menu.MenuDef; |
|
|
|
import com.fr.design.menu.SeparatorDef; |
|
|
|
import com.fr.design.menu.SeparatorDef; |
|
|
|
import com.fr.env.RemoteEnv; |
|
|
|
import com.fr.env.RemoteEnv; |
|
|
|
import com.fr.env.SignIn; |
|
|
|
import com.fr.env.SignIn; |
|
|
|
import com.fr.general.ComparatorUtils; |
|
|
|
|
|
|
|
import com.fr.general.GeneralContext; |
|
|
|
import com.fr.general.GeneralContext; |
|
|
|
import com.fr.general.Inter; |
|
|
|
import com.fr.general.Inter; |
|
|
|
import com.fr.log.FineLoggerFactory; |
|
|
|
import com.fr.log.FineLoggerFactory; |
|
|
|
import com.fr.stable.EnvChangedListener; |
|
|
|
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.awt.event.ActionEvent; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.Iterator; |
|
|
|
import java.util.Iterator; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class SwitchExistEnv extends MenuDef { |
|
|
|
public class SwitchExistEnv extends MenuDef { |
|
|
|
|
|
|
|
|
|
|
|
public SwitchExistEnv() { |
|
|
|
public SwitchExistEnv() { |
|
|
@ -41,18 +36,20 @@ public class SwitchExistEnv extends MenuDef { |
|
|
|
this.setHasScrollSubMenu(true); |
|
|
|
this.setHasScrollSubMenu(true); |
|
|
|
initMenuDef(); |
|
|
|
initMenuDef(); |
|
|
|
JTemplate<?, ?> t = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); |
|
|
|
JTemplate<?, ?> t = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); |
|
|
|
if(t != null) { |
|
|
|
if (t != null) { |
|
|
|
GeneralContext.addEnvWillChangedListener(t.getFullPathName(), new EnvChangedListener() { |
|
|
|
GeneralContext.addEnvWillChangedListener( |
|
|
|
public void envChanged() { |
|
|
|
t.getFullPathName(), |
|
|
|
SwitchExistEnv.this.clearShortCuts(); |
|
|
|
new EnvChangedListener() { |
|
|
|
initMenuDef(); |
|
|
|
public void envChanged() { |
|
|
|
} |
|
|
|
SwitchExistEnv.this.clearShortCuts(); |
|
|
|
}); |
|
|
|
initMenuDef(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void initMenuDef() { |
|
|
|
private void initMenuDef() { |
|
|
|
//ButtonGroup group = new ButtonGroup();
|
|
|
|
// ButtonGroup group = new ButtonGroup();
|
|
|
|
Iterator<String> nameIt = DesignerEnvManager.getEnvManager().getEnvNameIterator(); |
|
|
|
Iterator<String> nameIt = DesignerEnvManager.getEnvManager().getEnvNameIterator(); |
|
|
|
while (nameIt.hasNext()) { |
|
|
|
while (nameIt.hasNext()) { |
|
|
|
String name = nameIt.next(); |
|
|
|
String name = nameIt.next(); |
|
|
@ -65,15 +62,14 @@ public class SwitchExistEnv extends MenuDef { |
|
|
|
|
|
|
|
|
|
|
|
public static class GetExistEnvAction extends UpdateAction implements ResponseDataSourceChange { |
|
|
|
public static class GetExistEnvAction extends UpdateAction implements ResponseDataSourceChange { |
|
|
|
public GetExistEnvAction() { |
|
|
|
public GetExistEnvAction() { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public GetExistEnvAction(String envName) { |
|
|
|
public GetExistEnvAction(String envName) { |
|
|
|
this.setName(envName); |
|
|
|
this.setName(envName); |
|
|
|
Env env = DesignerEnvManager.getEnvManager().getEnv(envName); |
|
|
|
EnvConfig env = DesignerEnvManager.getEnvManager().getEnv(envName); |
|
|
|
if (env instanceof LocalEnv) { |
|
|
|
if (env instanceof LocalEnvConfig) { |
|
|
|
this.setSmallIcon(BaseUtils.readIcon("com/fr/design/images/data/bind/localconnect.png")); |
|
|
|
this.setSmallIcon(BaseUtils.readIcon("com/fr/design/images/data/bind/localconnect.png")); |
|
|
|
} else if (env instanceof RemoteEnv) { |
|
|
|
} else if (env instanceof RemoteEnvConfig) { |
|
|
|
this.setSmallIcon(BaseUtils.readIcon("com/fr/design/images/data/bind/distanceconnect.png")); |
|
|
|
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) { |
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
DesignerEnvManager envManager = DesignerEnvManager.getEnvManager(); |
|
|
|
DesignerEnvManager envManager = DesignerEnvManager.getEnvManager(); |
|
|
|
Env selectedEnv = envManager.getEnv(this.getName()); |
|
|
|
EnvConfig selectedEnv = envManager.getEnv(this.getName()); |
|
|
|
try { |
|
|
|
try { |
|
|
|
if (selectedEnv instanceof RemoteEnv && !((RemoteEnv) selectedEnv).testServerConnection()) { |
|
|
|
if (selectedEnv instanceof RemoteEnv && !((RemoteEnv) selectedEnv).testServerConnection()) { |
|
|
|
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Inter.getLocText(new String[]{"M-SwitchWorkspace", "Failed"})); |
|
|
|
JOptionPane.showMessageDialog( |
|
|
|
return; |
|
|
|
DesignerContext.getDesignerFrame(), |
|
|
|
} |
|
|
|
Inter.getLocText(new String[]{"M-SwitchWorkspace", "Failed"})); |
|
|
|
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(); |
|
|
|
|
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
SignIn.signIn(selectedEnv); |
|
|
|
SignIn.signIn(selectedEnv); |
|
|
|
HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().refreshToolArea(); |
|
|
|
HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().refreshToolArea(); |
|
|
|
fireDSChanged(); |
|
|
|
fireDSChanged(); |
|
|
|
} catch (Exception em) { |
|
|
|
} catch (Exception em) { |
|
|
|
FRContext.getLogger().error(em.getMessage(), em); |
|
|
|
FineLoggerFactory.getLogger().error(em.getMessage(), em); |
|
|
|
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Inter.getLocText(new String[]{"M-SwitchWorkspace", "Failed"})); |
|
|
|
JOptionPane.showMessageDialog( |
|
|
|
|
|
|
|
DesignerContext.getDesignerFrame(), |
|
|
|
|
|
|
|
Inter.getLocText(new String[]{"M-SwitchWorkspace", "Failed"})); |
|
|
|
TemplatePane.getInstance().editItems(); |
|
|
|
TemplatePane.getInstance().editItems(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|