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. 29
      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. 298
      designer-realize/src/com/fr/start/module/DesignerEnvProvider.java
  8. 12
      designer-realize/src/com/fr/start/module/DesignerModuleActivator.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();
}
});

29
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: 切换环境后 刷新下 报表. 比如图表某些风格改变.
}
});
@ -517,4 +514,4 @@ public class DesignUtils {
}
}
}

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

298
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;
@ -44,181 +53,190 @@ public class DesignerEnvProvider extends Activator {
}
}
initDesignerEnv();
getRoot().setSingleton(EnvSwitcher.class, new EnvSwitcher());
//设置好环境即可,具体跟环境有关的模块会自动调用
getRoot().getSingleton(EnvSwitcher.class).switch2LastEnv();
}
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());
}
}
});
}
private void addSerializers() {
EnvProxy.addSerializer(ProcedureDataModel[].class, new ProcedureDataModelSerializer());
EnvProxy.addSerializer(ModifiedTable.class, new OldSerializerAdapter<ModifiedTable>(
new OldSerializerAdapter.OldSerializer<ModifiedTable>() {
@Override
public void serializer(ModifiedTable obj, OutputStream out) throws Exception {
DavXMLUtils.writeXMLModifiedTables(obj, out);
}
},
new OldSerializerAdapter.OldDeserializer<ModifiedTable>() {
@Override
public ModifiedTable deserializer(InputStream in) throws Exception {
return DavXMLUtils.readXMLModifiedTables(in);
new OldSerializerAdapter.OldSerializer<ModifiedTable>() {
@Override
public void serializer(ModifiedTable obj, OutputStream out) throws Exception {
DavXMLUtils.writeXMLModifiedTables(obj, out);
}
},
new OldSerializerAdapter.OldDeserializer<ModifiedTable>() {
@Override
public ModifiedTable deserializer(InputStream in) throws Exception {
return DavXMLUtils.readXMLModifiedTables(in);
}
}
}
));
EnvProxy.addSerializer(com.fr.data.impl.Connection.class, new OldSerializerAdapter<com.fr.data.impl.Connection>(
new OldSerializerAdapter.OldSerializer<Connection>() {
@Override
public void serializer(Connection obj, OutputStream out) {
DavXMLUtils.writeXMLFileDatabaseConnection(obj, out);
}
},
new OldSerializerAdapter.OldDeserializer<Connection>() {
@Override
public Connection deserializer(InputStream in) throws Exception {
return DavXMLUtils.readXMLDatabaseConnection(in);
new OldSerializerAdapter.OldSerializer<Connection>() {
@Override
public void serializer(Connection obj, OutputStream out) {
DavXMLUtils.writeXMLFileDatabaseConnection(obj, out);
}
},
new OldSerializerAdapter.OldDeserializer<Connection>() {
@Override
public Connection deserializer(InputStream in) throws Exception {
return DavXMLUtils.readXMLDatabaseConnection(in);
}
}
}
));
EnvProxy.addSerializer(FileNode[].class, new OldSerializerAdapter<FileNode[]>(
new OldSerializerAdapter.OldSerializer<FileNode[]>() {
@Override
public void serializer(FileNode[] obj, OutputStream out) {
DavXMLUtils.writeXMLFileNodes(obj, out);
}
},
new OldSerializerAdapter.OldDeserializer<FileNode[]>() {
@Override
public FileNode[] deserializer(InputStream in) {
return DavXMLUtils.readXMLFileNodes(in);
new OldSerializerAdapter.OldSerializer<FileNode[]>() {
@Override
public void serializer(FileNode[] obj, OutputStream out) {
DavXMLUtils.writeXMLFileNodes(obj, out);
}
},
new OldSerializerAdapter.OldDeserializer<FileNode[]>() {
@Override
public FileNode[] deserializer(InputStream in) {
return DavXMLUtils.readXMLFileNodes(in);
}
}
}
));
EnvProxy.addSerializer(TableProcedure[].class, new OldSerializerAdapter<TableProcedure[]>(
new OldSerializerAdapter.OldSerializer<TableProcedure[]>() {
@Override
public void serializer(TableProcedure[] obj, OutputStream out) {
DavXMLUtils.writeXMLFileSQLTable(obj, out);
}
},
new OldSerializerAdapter.OldDeserializer<TableProcedure[]>() {
@Override
public TableProcedure[] deserializer(InputStream in) throws Exception {
return DavXMLUtils.readXMLSQLTables(in);
new OldSerializerAdapter.OldSerializer<TableProcedure[]>() {
@Override
public void serializer(TableProcedure[] obj, OutputStream out) {
DavXMLUtils.writeXMLFileSQLTable(obj, out);
}
},
new OldSerializerAdapter.OldDeserializer<TableProcedure[]>() {
@Override
public TableProcedure[] deserializer(InputStream in) throws Exception {
return DavXMLUtils.readXMLSQLTables(in);
}
}
}
));
EnvProxy.addSerializer(TableData.class, new OldSerializerAdapter<TableData>(
new OldSerializerAdapter.OldSerializer<TableData>() {
@Override
public void serializer(TableData obj, OutputStream out) {
DavXMLUtils.writeXMLFileTableData(obj, out);
}
},
new OldSerializerAdapter.OldDeserializer<TableData>() {
@Override
public TableData deserializer(InputStream in) throws Exception {
return DavXMLUtils.readXMLTableData(in);
new OldSerializerAdapter.OldSerializer<TableData>() {
@Override
public void serializer(TableData obj, OutputStream out) {
DavXMLUtils.writeXMLFileTableData(obj, out);
}
},
new OldSerializerAdapter.OldDeserializer<TableData>() {
@Override
public TableData deserializer(InputStream in) throws Exception {
return DavXMLUtils.readXMLTableData(in);
}
}
}
));
EnvProxy.addSerializer(Parameter[].class, new OldSerializerAdapter<Parameter[]>(
new OldSerializerAdapter.OldSerializer<Parameter[]>() {
@Override
public void serializer(Parameter[] obj, OutputStream out) {
DavXMLUtils.writeXMLFileParameters(obj, out);
}
},
new OldSerializerAdapter.OldDeserializer<Parameter[]>() {
@Override
public Parameter[] deserializer(InputStream in) throws Exception {
return DavXMLUtils.readXMLParameters(in);
new OldSerializerAdapter.OldSerializer<Parameter[]>() {
@Override
public void serializer(Parameter[] obj, OutputStream out) {
DavXMLUtils.writeXMLFileParameters(obj, out);
}
},
new OldSerializerAdapter.OldDeserializer<Parameter[]>() {
@Override
public Parameter[] deserializer(InputStream in) throws Exception {
return DavXMLUtils.readXMLParameters(in);
}
}
}
));
EnvProxy.addSerializer(StoreProcedure.class, new OldSerializerAdapter<StoreProcedure>(
new OldSerializerAdapter.OldSerializer<StoreProcedure>() {
@Override
public void serializer(StoreProcedure obj, OutputStream out) {
DavXMLUtils.writeXMLFileStoreProcedure(obj, out);
}
},
new OldSerializerAdapter.OldDeserializer<StoreProcedure>() {
@Override
public StoreProcedure deserializer(InputStream in) throws Exception {
return DavXMLUtils.readXMLStoreProcedure(in);
new OldSerializerAdapter.OldSerializer<StoreProcedure>() {
@Override
public void serializer(StoreProcedure obj, OutputStream out) {
DavXMLUtils.writeXMLFileStoreProcedure(obj, out);
}
},
new OldSerializerAdapter.OldDeserializer<StoreProcedure>() {
@Override
public StoreProcedure deserializer(InputStream in) throws Exception {
return DavXMLUtils.readXMLStoreProcedure(in);
}
}
}
));
EnvProxy.addSerializer(StoreProcedureParameter[].class, new OldSerializerAdapter<StoreProcedureParameter[]>(
new OldSerializerAdapter.OldSerializer<StoreProcedureParameter[]>() {
@Override
public void serializer(StoreProcedureParameter[] obj, OutputStream out) {
DavXMLUtils.writeXMLFileParameters(obj, out);
}
},
new OldSerializerAdapter.OldDeserializer<StoreProcedureParameter[]>() {
@Override
public StoreProcedureParameter[] deserializer(InputStream in) throws Exception {
return DavXMLUtils.readXMLStoreProcedureParameters(in);
new OldSerializerAdapter.OldSerializer<StoreProcedureParameter[]>() {
@Override
public void serializer(StoreProcedureParameter[] obj, OutputStream out) {
DavXMLUtils.writeXMLFileParameters(obj, out);
}
},
new OldSerializerAdapter.OldDeserializer<StoreProcedureParameter[]>() {
@Override
public StoreProcedureParameter[] deserializer(InputStream in) throws Exception {
return DavXMLUtils.readXMLStoreProcedureParameters(in);
}
}
}
));
}
@Override
public void stop() {
//清空模块
getRoot().removeSingleton(EnvSwitcher.class);
}
}

12
designer-realize/src/com/fr/start/module/DesignerModuleActivator.java

@ -14,25 +14,25 @@ import com.fr.stable.module.ModuleListener;
* 之后慢慢将DesignerModule拆成Activator
*/
public class DesignerModuleActivator extends Activator implements Prepare {
@Override
public void start() {
ModuleContext.registerModuleListener(getModule().upFindSingleton(ModuleListener.class));
ModuleContext.startModule(DesignerModule.class.getName());
ModuleContext.clearModuleListener();
DesignerSocketIO.init();
}
@Override
public void stop() {
}
@Override
public void prepare() {
addMutable(InterMutableKey.Path, "com/fr/design/i18n/main", "com/fr/design/i18n/chart");
}
}

Loading…
Cancel
Save