Browse Source

无JIRA任务 读取资源文件

master
richie 7 years ago
parent
commit
20d7b397a6
  1. 31
      designer-base/src/com/fr/design/actions/file/SwitchExistEnv.java
  2. 16
      designer-base/src/com/fr/design/env/RemoteEnvConfig.java
  3. 5
      designer-base/src/com/fr/design/gui/itree/filetree/TemplateFileTree.java
  4. 56
      designer-base/src/com/fr/design/mainframe/TemplatePane.java
  5. 29
      designer-base/src/com/fr/design/utils/DesignUtils.java
  6. 6
      designer-base/src/com/fr/env/RemoteEnv.java
  7. 2
      designer-base/src/com/fr/env/SignIn.java

31
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();
}
});
}
}
}

16
designer-base/src/com/fr/design/env/RemoteEnvConfig.java vendored

@ -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

5
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);
}
/*

56
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();

29
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<String> 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里面的面板

6
designer-base/src/com/fr/env/RemoteEnv.java vendored

@ -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<RemoteEnvConfig> 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;

2
designer-base/src/com/fr/env/SignIn.java vendored

@ -41,6 +41,6 @@ public class SignIn {
if (env != null && AssistUtils.equals(env.getEnvConfig(), selectedEnv)) {
env.disconnect();
}
DesignUtils.switchToEnv(selectedEnv);
//DesignUtils.switchToEnv(selectedEnv);
}
}
Loading…
Cancel
Save