Browse Source

Merge pull request #87 in DESIGN/design from ~HZZZ/design61:feature/10.0 to feature/10.0

* commit '5d0ff4b4f69aff35354879e454c48ceeb09bb0a6':
  env
  env
  env
  merge
master
superman 7 years ago
parent
commit
1d4df31825
  1. 17
      designer-base/src/com/fr/design/mainframe/DesignerFrame.java
  2. 7
      designer-base/src/com/fr/design/mainframe/loghandler/DesignerLogHandler.java
  3. 9
      designer-base/src/com/fr/design/mainframe/loghandler/socketio/DesignerSocketIO.java
  4. 27
      designer-base/src/com/fr/design/utils/DesignUtils.java
  5. 8
      designer-base/src/com/fr/env/RemoteEnv.java
  6. 27
      designer-base/src/com/fr/env/SignIn.java
  7. 26
      designer-realize/src/com/fr/start/module/DesignerEnvProvider.java

17
designer-base/src/com/fr/design/mainframe/DesignerFrame.java

@ -7,6 +7,7 @@ import com.fr.base.BaseUtils;
import com.fr.base.Env;
import com.fr.base.FRContext;
import com.fr.core.env.EnvConfig;
import com.fr.core.env.EnvContext;
import com.fr.core.env.resource.EnvConfigUtils;
import com.fr.design.DesignModelAdapter;
import com.fr.design.DesignState;
@ -317,7 +318,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
public void on(PluginEvent event) {
refreshNorthEastPane(northEastPane, ad);
DesignUtils.refreshDesignerFrame(FRContext.getCurrentEnv());
DesignUtils.refreshDesignerFrame();
}
}, new PluginFilter() {
@ -682,10 +683,8 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
/**
* 报表运行环境改变时,需要刷新某些面板
*
* @param env 环境
*/
public void refreshEnv(Env env) {
public void refreshEnv() {
this.setTitle();
DesignerFrameFileDealerPane.getInstance().refreshDockingView();
@ -965,14 +964,8 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
DesignerEnvManager.getEnvManager().saveXMLFile();
Env currentEnv = FRContext.getCurrentEnv();
try {
EventDispatcher.fire(BEFORE_SIGN_OUT);
currentEnv.signOut();
EventDispatcher.fire(AFTER_SIGN_OUT);
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
EnvContext.signOut();
this.setVisible(false);
this.dispose();

7
designer-base/src/com/fr/design/mainframe/loghandler/DesignerLogHandler.java

@ -1,7 +1,6 @@
package com.fr.design.mainframe.loghandler;
import com.fr.base.BaseUtils;
import com.fr.base.ServerConfig;
import com.fr.base.FRContext;
import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.imenu.UIMenuItem;
@ -38,9 +37,9 @@ import java.util.logging.LogRecord;
import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER;
public class DesignerLogHandler {
protected static final int INFO_INT = com.fr.third.apache.log4j.Level.INFO.toInt();
protected static final int ERROR_INT = com.fr.third.apache.log4j.Level.ERROR.toInt();
protected static final int WARN_INT = com.fr.third.apache.log4j.Level.WARN.toInt();
protected static final int INFO_INT = Level.INFO.intValue();
protected static final int ERROR_INT = Level.SEVERE.intValue();
protected static final int WARN_INT = Level.WARNING.intValue();
private static final int GAP_X = -150;
private static final int INFO_GAP_Y = -60;
private static final int ERRO_GAP_Y = -40;

9
designer-base/src/com/fr/design/mainframe/loghandler/socketio/DesignerSocketIO.java

@ -10,7 +10,6 @@ import com.fr.design.mainframe.loghandler.DesignerLogHandler;
import com.fr.event.Event;
import com.fr.event.EventDispatcher;
import com.fr.event.Listener;
import com.fr.event.Null;
import com.fr.general.LogRecordTime;
import com.fr.general.LogUtils;
import com.fr.log.FineLoggerFactory;
@ -43,18 +42,18 @@ public class DesignerSocketIO {
};
static {
EventDispatcher.listen(EnvEvent.AFTER_SIGN_OUT, new Listener<Null>() {
EventDispatcher.listen(EnvEvent.AFTER_SIGN_OUT, new Listener<EnvConfig>() {
@Override
public void on(Event event, Null param) {
public void on(Event event, EnvConfig param) {
if (socketIO.isPresent()) {
socketIO.get().close();
socketIO = Optional.absent();
}
}
});
EventDispatcher.listen(EnvEvent.AFTER_SIGN_IN, new Listener<Null>() {
EventDispatcher.listen(EnvEvent.AFTER_SIGN_IN, new Listener<EnvConfig>() {
@Override
public void on(Event event, Null param) {
public void on(Event event, EnvConfig param) {
updateSocket();
}
});

27
designer-base/src/com/fr/design/utils/DesignUtils.java

@ -1,13 +1,14 @@
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.remote.RemoteDeziConstants;
import com.fr.core.env.EnvConfig;
import com.fr.core.env.EnvContext;
import com.fr.dav.DavXMLUtils;
import com.fr.design.DesignerEnvManager;
import com.fr.design.ExtraDesignClassManager;
@ -30,8 +31,11 @@ import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils;
import com.fr.start.ServerStarter;
import javax.swing.*;
import java.awt.*;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import java.awt.Desktop;
import java.awt.Font;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.ByteArrayInputStream;
@ -183,20 +187,16 @@ public class DesignUtils {
});
}
/**
* 当前的报表运行环境切换到env
*
* @param env 需要切换去的环境
*/
public static void switchToEnv(Env env) {
public static void switchToEnv(EnvConfig env) {
if (env == null) {
return;
}
Env oldEnv = FRContext.getCurrentEnv();
String oldEnvPath = oldEnv == null ? null : oldEnv.getPath();
// 看一下这个env在DesignerEnvManager里面有没有对应的,有的话就setCurrentEnvName
DesignerEnvManager envManager = DesignerEnvManager.getEnvManager();
java.util.Iterator<String> nameIt = envManager.getEnvNameIterator();
@ -207,14 +207,11 @@ public class DesignUtils {
break;
}
}
// 更新CurrentEnv于FRContext & DesignerEnvManager
FRContext.setCurrentEnv(env);
refreshDesignerFrame(env);
EnvContext.signIn(env);
refreshDesignerFrame();
}
public static void refreshDesignerFrame(Env env) {
final Env run_env = env;
public static void refreshDesignerFrame() {
// 刷新DesignerFrame里面的面板
SwingUtilities.invokeLater(new Runnable() {
@ -223,7 +220,7 @@ public class DesignUtils {
if (DesignerContext.getDesignerFrame() == null) {
return;
}
DesignerContext.getDesignerFrame().refreshEnv(run_env);
DesignerContext.getDesignerFrame().refreshEnv();
DesignerContext.getDesignerFrame().repaint();// kunsnat: 切换环境后 刷新下 报表. 比如图表某些风格改变.
}
});

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

@ -41,6 +41,7 @@ import com.fr.stable.SvgProvider;
import com.fr.stable.file.XMLFileManagerProvider;
import com.fr.stable.project.ProjectConstants;
import com.fr.stable.xml.XMLTools;
import com.fr.third.guava.base.Strings;
import com.fr.third.guava.collect.ImmutableMap;
import com.fr.web.ResourceConstants;
@ -75,6 +76,7 @@ import static com.fr.third.guava.base.Preconditions.checkArgument;
* @author null
*/
public class RemoteEnv extends AbstractEnv implements DesignAuthorityConfigurable {
private static final String CERT_KEY = "javax.net.ssl.trustStore";
private static final String PWD_KEY = "javax.net.ssl.trustStorePassword";
private static final String HTTPS_PREFIX = "https:";
@ -138,7 +140,6 @@ public class RemoteEnv extends AbstractEnv implements DesignAuthorityConfigurabl
}
/**
* nameValuePairs,这个参数要接着this.path,拼成一个URL,否则服务器端req.getParameter是无法得到的
*
@ -214,7 +215,7 @@ public class RemoteEnv extends AbstractEnv implements DesignAuthorityConfigurabl
EnvConstants.USERNAME, getUser(),
EnvConstants.PWD, getPassword());
String res = HttpToolbox.post(url, params, headers);
if (res == null) {
if (Strings.isNullOrEmpty(res)) {
if (needMessage) {
JOptionPane.showMessageDialog(component, Inter.getLocText("Datasource-Connection_failed"));
}
@ -237,7 +238,7 @@ public class RemoteEnv extends AbstractEnv implements DesignAuthorityConfigurabl
return false;
} else {
if (needMessage) {
JOptionPane.showMessageDialog(component, Inter.getLocText(new String[]{"Datasource-Connection_failed", "Version-does-not-support"}, new String[]{",", "!"}));
JOptionPane.showMessageDialog(component, Inter.getLocText("Datasource-Connection_failed"));
} else {
FineLoggerFactory.getLogger().info(Inter.getLocText(new String[]{"Datasource-Connection_failed", "Version-does-not-support"}, new String[]{",", "!"}));
}
@ -818,7 +819,6 @@ public class RemoteEnv extends AbstractEnv implements DesignAuthorityConfigurabl
}
/**
* 获取当前env的build文件路径
*/

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

@ -1,13 +1,11 @@
package com.fr.env;
import com.fr.base.FRContext;
import com.fr.core.env.EnvConfig;
import com.fr.core.env.EnvContext;
import com.fr.core.env.EnvEvent;
import com.fr.core.env.resource.EnvConfigUtils;
import com.fr.core.env.resource.RemoteEnvConfig;
import com.fr.dav.LocalEnv;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.DesignerFrame;
import com.fr.design.utils.DesignUtils;
import com.fr.event.Event;
import com.fr.event.EventDispatcher;
@ -17,7 +15,6 @@ import com.fr.general.ComparatorUtils;
import com.fr.general.Inter;
import javax.swing.JOptionPane;
import javax.swing.UIManager;
public class SignIn {
@ -26,20 +23,14 @@ public class SignIn {
EventDispatcher.listen(EnvEvent.CONNECTION_ERROR, new Listener<Null>() {
@Override
public void on(Event event, Null param) {
if (JOptionPane.showConfirmDialog(null, Inter.getLocText("FR-Remote_Connect2Server_Again"), UIManager.getString("OptionPane.titleText"), JOptionPane.YES_NO_OPTION)
== JOptionPane.OK_OPTION) {
try {
EnvContext.signIn(EnvContext.currentEnv());
} catch (Exception e) {
FRContext.getLogger().error(e.getMessage());
}
}
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Inter.getLocText("Datasource-Connection_failed"));
}
});
}
/**
* 注册入环境
*
* @param selectedEnv 选择的环境
* @throws Exception 异常
*/
@ -47,15 +38,7 @@ public class SignIn {
if (EnvContext.currentEnv() != null && !ComparatorUtils.equals(EnvContext.currentEnv(), selectedEnv)) {
EnvContext.signOut();
}
EnvContext.signIn(selectedEnv);
DesignUtils.switchToEnv(trans(selectedEnv));
}
private static com.fr.base.Env trans(EnvConfig env) {
if (env instanceof RemoteEnvConfig) {
return new RemoteEnv(env.getPath(), EnvConfigUtils.getUsername(env), EnvConfigUtils.getPassword(env));
} else {
return new LocalEnv();
}
DesignUtils.switchToEnv(selectedEnv);
}
}

26
designer-realize/src/com/fr/start/module/DesignerEnvProvider.java

@ -1,20 +1,29 @@
package com.fr.start.module;
import com.fr.base.FRContext;
import com.fr.base.ModifiedTable;
import com.fr.base.Parameter;
import com.fr.base.StoreProcedureParameter;
import com.fr.base.TableData;
import com.fr.base.env.serializer.OldSerializerAdapter;
import com.fr.base.env.serializer.ProcedureDataModelSerializer;
import com.fr.base.env.user.RemoteUserCenter;
import com.fr.core.env.operator.user.UserCenter;
import com.fr.core.env.EnvConfig;
import com.fr.core.env.EnvEvent;
import com.fr.core.env.proxy.EnvProxy;
import com.fr.core.env.resource.EnvConfigUtils;
import com.fr.core.env.resource.LocalEnvConfig;
import com.fr.core.env.resource.RemoteEnvConfig;
import com.fr.data.core.db.TableProcedure;
import com.fr.data.impl.Connection;
import com.fr.data.impl.storeproc.ProcedureDataModel;
import com.fr.data.impl.storeproc.StoreProcedure;
import com.fr.dav.DavXMLUtils;
import com.fr.dav.LocalEnv;
import com.fr.design.DesignerEnvManager;
import com.fr.env.RemoteEnv;
import com.fr.event.Event;
import com.fr.event.EventDispatcher;
import com.fr.event.Listener;
import com.fr.file.filetree.FileNode;
import com.fr.general.ComparatorUtils;
import com.fr.module.Activator;
@ -51,9 +60,18 @@ public class DesignerEnvProvider extends Activator {
}
private void initDesignerEnv() {
addSerializers();
EnvProxy.addRemoteService(UserCenter.class, new RemoteUserCenter());
EventDispatcher.listen(EnvEvent.BEFORE_SIGN_IN, new Listener<EnvConfig>() {
@Override
public void on(Event event, EnvConfig envConfig) {
if (envConfig instanceof RemoteEnvConfig) {
RemoteEnv remoteEnv = new RemoteEnv(envConfig.getPath(), EnvConfigUtils.getUsername(envConfig), EnvConfigUtils.getPassword(envConfig));
FRContext.setCurrentEnv(remoteEnv);
} else if (envConfig instanceof LocalEnvConfig) {
FRContext.setCurrentEnv(new LocalEnv());
}
}
});
}

Loading…
Cancel
Save