ju 6 years ago
parent
commit
285c8d764c
  1. 9
      designer-base/src/com/fr/design/DesignState.java
  2. 12
      designer-base/src/com/fr/design/data/datapane/preview/PreviewTableModel.java
  3. 4
      designer-base/src/com/fr/design/data/tabledata/wrapper/StoreProcedureNameWrapper.java
  4. 15
      designer-base/src/com/fr/design/env/DesignerWorkspaceInfo.java
  5. 6
      designer-base/src/com/fr/design/mainframe/DesignerFrame.java
  6. 3
      designer-base/src/com/fr/design/mainframe/loghandler/socketio/DesignerSocketIO.java
  7. 21
      designer-base/src/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java
  8. 4
      designer-base/src/com/fr/design/remote/ui/UserManagerPane.java
  9. 8
      designer-base/src/com/fr/design/utils/DesignUtils.java
  10. 7
      designer-base/src/com/fr/env/RemoteEnvPane.java
  11. 39
      designer-base/src/com/fr/env/RemoteEnvPane2.java
  12. 334
      designer-base/src/com/fr/env/RemoteEnvUtils.java
  13. 6
      designer-base/src/com/fr/start/ServerStarter.java
  14. 4
      designer-realize/src/com/fr/design/mainframe/JWorkBook.java
  15. 8
      designer-realize/src/com/fr/design/mainframe/alphafine/cell/model/PluginModel.java
  16. 20
      designer-realize/src/com/fr/design/report/freeze/RepeatAndFreezeSettingPane.java
  17. 322
      designer-realize/src/com/fr/start/module/DesignerEnvProvider.java
  18. 14
      designer-realize/src/com/fr/start/module/DesignerStartup.java

9
designer-base/src/com/fr/design/DesignState.java

@ -1,10 +1,8 @@
package com.fr.design;
import com.fr.base.BaseUtils;
import com.fr.base.Env;
import com.fr.base.FRContext;
import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus;
import com.fr.env.RemoteEnv;
import com.fr.workspace.WorkContext;
/**
* Created by IntelliJ IDEA.
@ -41,11 +39,10 @@ public class DesignState {
public DesignState(ToolBarMenuDockPlus plus) {
designState = plus.getMenuState();
Env env = FRContext.getCurrentEnv();
if (env != null && env instanceof RemoteEnv) {
if (WorkContext.getCurrent().isLocal()) {
designState += REMOTE;
}
isRoot = env != null && env.isRoot();
// isRoot = env != null && env.isRoot();
isAuthority = BaseUtils.isAuthorityEditing();
}

12
designer-base/src/com/fr/design/data/datapane/preview/PreviewTableModel.java

@ -1,18 +1,18 @@
package com.fr.design.data.datapane.preview;
import javax.swing.table.AbstractTableModel;
import com.fr.base.FRContext;
import com.fr.cache.list.IntList;
import com.fr.data.AbstractDataModel;
import com.fr.data.impl.EmbeddedTableData.EmbeddedTDDataModel;
import com.fr.data.impl.storeproc.ProcedureDataModel;
import com.fr.env.RemoteEnv;
import com.fr.design.utils.DesignUtils;
import com.fr.general.Inter;
import com.fr.general.data.DataModel;
import com.fr.general.data.TableDataException;
import com.fr.cache.list.IntList;
import com.fr.stable.StringUtils;
import com.fr.design.utils.DesignUtils;
import com.fr.workspace.WorkContext;
import javax.swing.table.AbstractTableModel;
/**
* 这个TableModel主要是预览数据的. 字段TableData必须转化为内置的
@ -188,7 +188,7 @@ public class PreviewTableModel extends AbstractTableModel {
s = "?";
} else if (o instanceof String) {
s = Inter.getLocText("FR-Designer_Parameter_String");
if (FRContext.getCurrentEnv() instanceof RemoteEnv && dataModel instanceof EmbeddedTDDataModel) {
if (!WorkContext.getCurrent().isLocal() && dataModel instanceof EmbeddedTDDataModel) {
Class clzz = ((EmbeddedTDDataModel) dataModel).getColumnClass(column);
if (Number.class.isAssignableFrom(clzz)) {
s = Inter.getLocText("FR-Designer_Number");//bigdecimal

4
designer-base/src/com/fr/design/data/tabledata/wrapper/StoreProcedureNameWrapper.java

@ -9,8 +9,8 @@ import com.fr.data.impl.storeproc.StoreProcedure;
import com.fr.design.data.DesignTableDataManager;
import com.fr.design.data.datapane.preview.PreviewTablePane;
import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode;
import com.fr.env.RemoteEnv;
import com.fr.log.FineLoggerFactory;
import com.fr.workspace.WorkContext;
import javax.swing.*;
import java.util.ArrayList;
@ -95,7 +95,7 @@ public final class StoreProcedureNameWrapper implements TableDataWrapper {
}
columnNameList = new ArrayList<String>();
Env env = FRContext.getCurrentEnv();
if (env instanceof RemoteEnv) {
if (!WorkContext.getCurrent().isLocal()) {
try {
createStore(false);
columnNameList = Arrays.asList(procedureDataModel.getColumnName());

15
designer-base/src/com/fr/design/env/DesignerWorkspaceInfo.java vendored

@ -59,6 +59,21 @@ public class DesignerWorkspaceInfo implements XMLable {
return connection;
}
public void setType(DesignerWorkspaceType type) {
this.type = type;
}
public void setPath(String path) {
this.path = path;
}
public void setConnection(WorkspaceConnection connection) {
this.connection = connection;
}
@Override
public void readXML(XMLableReader reader) {

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

@ -5,7 +5,6 @@ package com.fr.design.mainframe;
import com.fr.base.BaseUtils;
import com.fr.base.FRContext;
import com.fr.base.env.EnvConfig;
import com.fr.design.DesignModelAdapter;
import com.fr.design.DesignState;
import com.fr.design.DesignerEnvManager;
@ -14,6 +13,7 @@ import com.fr.design.actions.core.ActionFactory;
import com.fr.design.constants.UIConstants;
import com.fr.design.data.DesignTableDataManager;
import com.fr.design.data.datapane.TableDataTreePane;
import com.fr.design.env.DesignerWorkspaceInfo;
import com.fr.design.event.DesignerOpenedListener;
import com.fr.design.event.TargetModifiedEvent;
import com.fr.design.event.TargetModifiedListener;
@ -650,9 +650,9 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
defaultTitleSB.append(" ");
// james:标识登录的用户和登录的ENV
String envName = DesignerEnvManager.getEnvManager().getCurEnvName();
EnvConfig env = DesignerEnvManager.getEnvManager().getWorkspaceInfo(envName);
DesignerWorkspaceInfo env = DesignerEnvManager.getEnvManager().getWorkspaceInfo(envName);
if (env != null) {
defaultTitleSB.append(env.getDescription(envName));
// defaultTitleSB.append(env.getDescription(envName));
if (editingTemplate != null) {
String path = editingTemplate.getEditingFILE().getPath();
if (!editingTemplate.getEditingFILE().exists()) {

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

@ -2,10 +2,7 @@ package com.fr.design.mainframe.loghandler.socketio;
import com.fr.base.Env;
import com.fr.base.FRContext;
import com.fr.decision.webservice.utils.DecisionServiceConstants;
import com.fr.design.env.RemoteEnvConfig;
import com.fr.design.mainframe.loghandler.DesignerLogHandler;
import com.fr.env.RemoteEnv;
import com.fr.event.Event;
import com.fr.event.EventDispatcher;
import com.fr.event.Listener;

21
designer-base/src/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java

@ -48,7 +48,6 @@ import com.fr.design.menu.ShortCut;
import com.fr.design.menu.ToolBarDef;
import com.fr.design.remote.action.RemoteDesignAuthorityManagerAction;
import com.fr.design.utils.ThemeUtils;
import com.fr.env.RemoteEnv;
import com.fr.general.ComparatorUtils;
import com.fr.general.GeneralContext;
import com.fr.general.Inter;
@ -60,19 +59,10 @@ import com.fr.plugin.observer.PluginEventListener;
import com.fr.plugin.observer.PluginEventType;
import com.fr.stable.ArrayUtils;
import com.fr.stable.StringUtils;
import com.fr.workspace.WorkContext;
import javax.swing.Icon;
import javax.swing.JComponent;
import javax.swing.JMenuBar;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import javax.swing.UIManager;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import javax.swing.*;
import java.awt.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@ -447,8 +437,9 @@ public abstract class ToolBarMenuDock {
return FRContext.getCurrentEnv() != null && !FRContext.getCurrentEnv().isLocalEnv() && FRContext.getCurrentEnv().isRoot();
}
protected boolean shouldShowPlugin() {
return !(FRContext.getCurrentEnv() instanceof RemoteEnv) && FRContext.isChineseEnv();
private boolean shouldShowPlugin() {
return !(WorkContext.getCurrent().isLocal()) && FRContext.isChineseEnv();
}
/**

4
designer-base/src/com/fr/design/remote/ui/UserManagerPane.java

@ -278,8 +278,8 @@ public class UserManagerPane extends BasicPane {
@Override
protected List<RemoteDesignMember> doInBackground() {
addingMembers.clear();
String username = EnvConfigUtils.getUsername(EnvContext.currentEnv());
addingMembers.addAll(EnvProxy.get(DecisionOperator.class).getMembers(username, keyword));
// String username = EnvConfigUtils.getUsername(EnvContext.currentEnv());
// addingMembers.addAll(EnvProxy.get(DecisionOperator.class).getMembers(username, keyword));
return addingMembers;
}

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

@ -27,6 +27,7 @@ import com.fr.stable.EncodeConstants;
import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils;
import com.fr.start.ServerStarter;
import com.fr.workspace.WorkContext;
import javax.swing.*;
import java.awt.*;
@ -298,12 +299,13 @@ public class DesignUtils {
}
}
String postfixOfUri = (segs.length > 0 ? "?" + StableUtils.join(segs, "&") : StringUtils.EMPTY);
if (FRContext.getCurrentEnv() instanceof RemoteEnv) {
if (!WorkContext.getCurrent().isLocal()) {
try {
if (Utils.isEmbeddedParameter(postfixOfUri)) {
String time = Calendar.getInstance().getTime().toString().replaceAll(" ", "");
boolean isUserPrivilege = ((RemoteEnv) FRContext.getCurrentEnv()).writePrivilegeMap(time, postfixOfUri);
// boolean isUserPrivilege = FRContext.getCurrentEnv()).writePrivilegeMap(time, postfixOfUri);
boolean isUserPrivilege = false;
postfixOfUri = isUserPrivilege ? postfixOfUri + "&fr_check_url=" + time + "&id=" + FRContext.getCurrentEnv().getUserID() : postfixOfUri;
}
// 加参数给远程设计校验权限。

7
designer-base/src/com/fr/env/RemoteEnvPane.java vendored

@ -257,7 +257,7 @@ public class RemoteEnvPane extends BasicBeanPane<DesignerWorkspaceInfo> {
String username = ob.getConnection().getUserName();
String pwd = ob.getConnection().getPassword();
this.usernameInput.setText(username == null ? StringUtils.EMPTY : pwd);
this.passwordInput.setText(pwd == null ? StringUtils.EMPTY : "******");
this.passwordInput.setText(pwd == null ? StringUtils.EMPTY : pwd);
}
@Override
@ -459,14 +459,13 @@ public class RemoteEnvPane extends BasicBeanPane<DesignerWorkspaceInfo> {
private boolean testConnection() {
String url = remoteEnvURL.getURL();
//RemoteEnv env = new RemoteEnv(url, usernameInput.getText(), new String(passwordInput.getPassword()));
RemoteEnv env = null;
boolean connect = false;
try {
if (StringUtils.isNotEmpty(url)) {
if (remoteEnvURL.getHttps()) {
setHttpsParas();
}
connect = env.testConnectionWithOutRegisteServer(this);
// connect = env.testConnectionWithOutRegisteServer(this);
}
} catch (Exception e) {
JOptionPane.showMessageDialog(
@ -479,7 +478,7 @@ public class RemoteEnvPane extends BasicBeanPane<DesignerWorkspaceInfo> {
}
if (connect) {
try {
String remoteVersion = env.getDesignerVersion();
String remoteVersion = "";
if (StringUtils.isBlank(remoteVersion) || ComparatorUtils.compare(remoteVersion, ProductConstants.DESIGNER_VERSION) < 0) {
String info = Inter.getLocText("Server-version-tip") + "。";
String moreInfo = Inter.getLocText("Server-version-tip-moreInfo") + "。";

39
designer-base/src/com/fr/env/RemoteEnvPane2.java vendored

@ -1,8 +1,9 @@
package com.fr.env;
import com.fr.design.env.RemoteEnvConfig;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.border.UITitledBorder;
import com.fr.design.env.DesignerWorkspaceInfo;
import com.fr.design.env.DesignerWorkspaceType;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.ipasswordfield.UIPassWordField;
@ -12,6 +13,8 @@ import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.Inter;
import com.fr.workspace.WorkContext;
import com.fr.workspace.connect.WorkspaceConnection;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
@ -24,7 +27,7 @@ import java.awt.event.WindowEvent;
/**
* 远程环境设置界面暂时命名为2待做完功能直接替代掉老的RemoteEnvPane
*/
public class RemoteEnvPane2 extends BasicBeanPane<RemoteEnvConfig> {
public class RemoteEnvPane2 extends BasicBeanPane<DesignerWorkspaceInfo> {
private UITextField hostTextField;
private UIIntNumberField portTextField;
@ -88,8 +91,9 @@ public class RemoteEnvPane2 extends BasicBeanPane<RemoteEnvConfig> {
@Override
protected Void doInBackground() throws Exception {
final RemoteEnv remoteEnv = new RemoteEnv(updateBean());
remoteEnv.connectOnce();
final DesignerWorkspaceInfo remoteEnv = updateBean();
WorkContext.getConnector().testConnection(remoteEnv.getConnection());
return null;
}
@ -161,25 +165,28 @@ public class RemoteEnvPane2 extends BasicBeanPane<RemoteEnvConfig> {
}
@Override
public void populateBean(RemoteEnvConfig config) {
public void populateBean(DesignerWorkspaceInfo config) {
if (config == null) {
return;
}
hostTextField.setText(config.getHost());
if (config.getPort() != 0) {
portTextField.setValue(config.getPort());
WorkspaceConnection connection = config.getConnection();
if (connection != null) {
hostTextField.setText(connection.getIp());
if (connection.getPort() != 0) {
portTextField.setValue(connection.getPort());
}
usernameTextField.setText(connection.getUserName());
passwordTextField.setText(connection.getPassword());
}
usernameTextField.setText(config.getUsername());
passwordTextField.setText(config.getPassword());
}
@Override
public RemoteEnvConfig updateBean() {
RemoteEnvConfig config = new RemoteEnvConfig();
config.setHost(hostTextField.getText());
config.setPort((int) portTextField.getValue());
config.setUsername(usernameTextField.getText());
config.setPassword(passwordTextField.getText());
public DesignerWorkspaceInfo updateBean() {
DesignerWorkspaceInfo config = new DesignerWorkspaceInfo();
WorkspaceConnection connection = new WorkspaceConnection(hostTextField.getText(), (int) portTextField.getValue(), usernameTextField.getText(), passwordTextField.getText());
config.setConnection(connection);
config.setType(DesignerWorkspaceType.Remote);
return config;
}
}

334
designer-base/src/com/fr/env/RemoteEnvUtils.java vendored

@ -1,167 +1,167 @@
package com.fr.env;
import com.fr.base.EnvException;
import com.fr.base.FRContext;
import com.fr.report.DesignAuthority;
import com.fr.report.util.AuthorityXMLUtils;
import com.fr.stable.EncodeConstants;
import com.fr.third.org.apache.commons.io.IOUtils;
import com.fr.third.org.apache.http.HttpResponse;
import com.fr.third.org.apache.http.HttpStatus;
import com.fr.third.org.apache.http.client.ClientProtocolException;
import com.fr.third.org.apache.http.client.ResponseHandler;
import com.fr.third.org.apache.http.client.methods.HttpUriRequest;
import com.fr.third.org.apache.http.client.methods.RequestBuilder;
import com.fr.third.org.apache.http.entity.ContentType;
import com.fr.third.org.apache.http.entity.InputStreamEntity;
import com.fr.third.org.apache.http.impl.client.CloseableHttpClient;
import com.fr.third.org.apache.http.impl.client.HttpClients;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URLEncoder;
import java.util.Map;
public class RemoteEnvUtils {
private RemoteEnvUtils() {
}
private static ResponseHandler<InputStream> responseHandler = new ResponseHandler<InputStream>() {
@Override
public InputStream handleResponse(HttpResponse response) throws IOException {
int statusCode = response.getStatusLine().getStatusCode();
if (statusCode != HttpStatus.SC_OK) {
throw new ClientProtocolException("Method failed: " + response.getStatusLine().toString());
}
InputStream in = response.getEntity().getContent();
if (in == null) {
return null;
}
// 读取并返回
ByteArrayOutputStream out = new ByteArrayOutputStream();
IOUtils.copy(in, out);
return new ByteArrayInputStream(out.toByteArray());
}
};
public static InputStream simulateRPCByHttpPost(byte[] bytes, Map<String, String> parameters, boolean isSignIn, RemoteEnv env) throws EnvException {
String path = env.getPath();
RequestBuilder builder = RequestBuilder.post(path);
InputStream inputStream = null;
for (Map.Entry<String, String> entry : parameters.entrySet()) {
builder.addParameter(entry.getKey(), entry.getValue());
}
if (!isSignIn) {
builder.addParameter("id", env.getUserID());
}
InputStreamEntity reqEntity = new InputStreamEntity(new ByteArrayInputStream(bytes));
try (CloseableHttpClient httpClient = HttpClients.createSystem()) {
HttpUriRequest request = builder
.setEntity(reqEntity)
.build();
inputStream = httpClient.execute(request, responseHandler);
} catch (IOException e) {
FRContext.getLogger().error(e.getMessage());
}
return inputStream;
}
public static InputStream simulateRPCByHttpPost(Map<String, String> parameters, boolean isSignIn, RemoteEnv env) throws EnvException {
String path = env.getPath();
RequestBuilder builder = RequestBuilder.post(path);
InputStream inputStream = null;
for (Map.Entry<String, String> entry : parameters.entrySet()) {
builder.addParameter(entry.getKey(), entry.getValue());
}
if (!isSignIn) {
builder.addParameter("id", env.getUserID());
}
try (CloseableHttpClient httpClient = HttpClients.createSystem()) {
HttpUriRequest request = builder
.build();
inputStream = httpClient.execute(request, responseHandler);
} catch (IOException e) {
FRContext.getLogger().error(e.getMessage());
}
return inputStream;
}
public static InputStream simulateRPCByHttpGet(Map<String, String> parameters, boolean isSignIn, RemoteEnv env) throws EnvException {
String path = env.getPath();
RequestBuilder builder = RequestBuilder.get(path);
InputStream inputStream = null;
for (Map.Entry<String, String> entry : parameters.entrySet()) {
builder.addParameter(entry.getKey(), entry.getValue());
}
if (!isSignIn) {
builder.addParameter("id", env.getUserID());
}
try (CloseableHttpClient httpClient = HttpClients.createSystem()) {
HttpUriRequest request = builder.build();
inputStream = httpClient.execute(request, responseHandler);
} catch (IOException e) {
FRContext.getLogger().error(e.getMessage());
}
return inputStream;
}
public static InputStream updateAuthorities(DesignAuthority[] authorities, RemoteEnv env) {
String path = env.getPath();
// 远程设计临时用户id
String userID = env.getUserID();
InputStream inputStream = null;
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
AuthorityXMLUtils.writeDesignAuthoritiesXML(authorities, outputStream);
InputStreamEntity reqEntity = new InputStreamEntity(new ByteArrayInputStream(outputStream.toByteArray()), ContentType.TEXT_XML);
try (CloseableHttpClient httpClient = HttpClients.createSystem()) {
HttpUriRequest request = RequestBuilder.post(path)
.addParameter("id", userID)
.addParameter("op", "remote_design_authority")
.addParameter("cmd", "update_authorities")
.setEntity(reqEntity)
.build();
inputStream = httpClient.execute(request, responseHandler);
} catch (IOException e) {
FRContext.getLogger().error(e.getMessage());
}
return inputStream;
}
public static InputStream getAuthorities(RemoteEnv env) throws EnvException {
String path = env.getPath();
// 远程设计临时用户id
String userID = env.getUserID();
InputStream inputStream = null;
try (CloseableHttpClient httpClient = HttpClients.createSystem();) {
HttpUriRequest request = RequestBuilder.get(path)
.addParameter("id", userID)
.addParameter("op", "remote_design_authority")
.addParameter("cmd", "get_authorities")
.build();
inputStream = httpClient.execute(request, responseHandler);
} catch (IOException e) {
FRContext.getLogger().error(e.getMessage());
}
return inputStream;
}
}
//package com.fr.env;
//
//import com.fr.base.EnvException;
//import com.fr.base.FRContext;
//import com.fr.report.DesignAuthority;
//import com.fr.report.util.AuthorityXMLUtils;
//import com.fr.stable.EncodeConstants;
//import com.fr.third.org.apache.commons.io.IOUtils;
//import com.fr.third.org.apache.http.HttpResponse;
//import com.fr.third.org.apache.http.HttpStatus;
//import com.fr.third.org.apache.http.client.ClientProtocolException;
//import com.fr.third.org.apache.http.client.ResponseHandler;
//import com.fr.third.org.apache.http.client.methods.HttpUriRequest;
//import com.fr.third.org.apache.http.client.methods.RequestBuilder;
//import com.fr.third.org.apache.http.entity.ContentType;
//import com.fr.third.org.apache.http.entity.InputStreamEntity;
//import com.fr.third.org.apache.http.impl.client.CloseableHttpClient;
//import com.fr.third.org.apache.http.impl.client.HttpClients;
//
//import java.io.ByteArrayInputStream;
//import java.io.ByteArrayOutputStream;
//import java.io.IOException;
//import java.io.InputStream;
//import java.net.URLEncoder;
//import java.util.Map;
//
//public class RemoteEnvUtils {
//
// private RemoteEnvUtils() {
// }
//
// private static ResponseHandler<InputStream> responseHandler = new ResponseHandler<InputStream>() {
// @Override
// public InputStream handleResponse(HttpResponse response) throws IOException {
// int statusCode = response.getStatusLine().getStatusCode();
// if (statusCode != HttpStatus.SC_OK) {
// throw new ClientProtocolException("Method failed: " + response.getStatusLine().toString());
// }
// InputStream in = response.getEntity().getContent();
// if (in == null) {
// return null;
// }
// // 读取并返回
// ByteArrayOutputStream out = new ByteArrayOutputStream();
// IOUtils.copy(in, out);
// return new ByteArrayInputStream(out.toByteArray());
// }
// };
//
// public static InputStream simulateRPCByHttpPost(byte[] bytes, Map<String, String> parameters, boolean isSignIn, RemoteEnv env) throws EnvException {
// String path = env.getPath();
// RequestBuilder builder = RequestBuilder.post(path);
//
// InputStream inputStream = null;
//
// for (Map.Entry<String, String> entry : parameters.entrySet()) {
// builder.addParameter(entry.getKey(), entry.getValue());
// }
// if (!isSignIn) {
// builder.addParameter("id", env.getUserID());
// }
// InputStreamEntity reqEntity = new InputStreamEntity(new ByteArrayInputStream(bytes));
//
// try (CloseableHttpClient httpClient = HttpClients.createSystem()) {
// HttpUriRequest request = builder
// .setEntity(reqEntity)
// .build();
// inputStream = httpClient.execute(request, responseHandler);
// } catch (IOException e) {
// FRContext.getLogger().error(e.getMessage());
// }
// return inputStream;
// }
//
// public static InputStream simulateRPCByHttpPost(Map<String, String> parameters, boolean isSignIn, RemoteEnv env) throws EnvException {
// String path = env.getPath();
// RequestBuilder builder = RequestBuilder.post(path);
//
// InputStream inputStream = null;
//
// for (Map.Entry<String, String> entry : parameters.entrySet()) {
// builder.addParameter(entry.getKey(), entry.getValue());
// }
// if (!isSignIn) {
// builder.addParameter("id", env.getUserID());
// }
//
// try (CloseableHttpClient httpClient = HttpClients.createSystem()) {
// HttpUriRequest request = builder
// .build();
// inputStream = httpClient.execute(request, responseHandler);
// } catch (IOException e) {
// FRContext.getLogger().error(e.getMessage());
// }
// return inputStream;
// }
//
// public static InputStream simulateRPCByHttpGet(Map<String, String> parameters, boolean isSignIn, RemoteEnv env) throws EnvException {
// String path = env.getPath();
// RequestBuilder builder = RequestBuilder.get(path);
//
// InputStream inputStream = null;
//
// for (Map.Entry<String, String> entry : parameters.entrySet()) {
// builder.addParameter(entry.getKey(), entry.getValue());
// }
// if (!isSignIn) {
// builder.addParameter("id", env.getUserID());
// }
// try (CloseableHttpClient httpClient = HttpClients.createSystem()) {
// HttpUriRequest request = builder.build();
// inputStream = httpClient.execute(request, responseHandler);
//
// } catch (IOException e) {
// FRContext.getLogger().error(e.getMessage());
// }
// return inputStream;
// }
//
//
// public static InputStream updateAuthorities(DesignAuthority[] authorities, RemoteEnv env) {
// String path = env.getPath();
// // 远程设计临时用户id
// String userID = env.getUserID();
// InputStream inputStream = null;
//
// ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
// AuthorityXMLUtils.writeDesignAuthoritiesXML(authorities, outputStream);
// InputStreamEntity reqEntity = new InputStreamEntity(new ByteArrayInputStream(outputStream.toByteArray()), ContentType.TEXT_XML);
//
// try (CloseableHttpClient httpClient = HttpClients.createSystem()) {
// HttpUriRequest request = RequestBuilder.post(path)
// .addParameter("id", userID)
// .addParameter("op", "remote_design_authority")
// .addParameter("cmd", "update_authorities")
// .setEntity(reqEntity)
// .build();
// inputStream = httpClient.execute(request, responseHandler);
// } catch (IOException e) {
// FRContext.getLogger().error(e.getMessage());
// }
//
// return inputStream;
//
// }
//
// public static InputStream getAuthorities(RemoteEnv env) throws EnvException {
// String path = env.getPath();
// // 远程设计临时用户id
// String userID = env.getUserID();
// InputStream inputStream = null;
//
// try (CloseableHttpClient httpClient = HttpClients.createSystem();) {
// HttpUriRequest request = RequestBuilder.get(path)
// .addParameter("id", userID)
// .addParameter("op", "remote_design_authority")
// .addParameter("cmd", "get_authorities")
// .build();
// inputStream = httpClient.execute(request, responseHandler);
// } catch (IOException e) {
// FRContext.getLogger().error(e.getMessage());
// }
// return inputStream;
// }
//
//
//}

6
designer-base/src/com/fr/start/ServerStarter.java

@ -11,7 +11,6 @@ import com.fr.design.env.DesignerWorkspaceGenerator;
import com.fr.design.file.TemplateTreePane;
import com.fr.design.gui.itextarea.UITextArea;
import com.fr.design.mainframe.DesignerContext;
import com.fr.env.RemoteEnv;
import com.fr.general.ComparatorUtils;
import com.fr.general.GeneralContext;
import com.fr.general.Inter;
@ -37,8 +36,9 @@ public class ServerStarter {
*/
public static void browserDemoURL() {
if (FRContext.getCurrentEnv() instanceof RemoteEnv) {
browser(FRContext.getCurrentEnv().getPath());
if (!WorkContext.getCurrent().isLocal()) {
//有问题,这里拿不到远程的http端口
browser(WorkContext.getCurrent().getPath());
return;
}
if (ComparatorUtils.equals(StableUtils.getInstallHome(), ".")) {//august:供代码使用

4
designer-realize/src/com/fr/design/mainframe/JWorkBook.java

@ -62,7 +62,6 @@ import com.fr.design.selection.QuickEditor;
import com.fr.design.write.submit.DBManipulationPane;
import com.fr.design.write.submit.SmartInsertDBManipulationInWidgetEventPane;
import com.fr.design.write.submit.SmartInsertDBManipulationPane;
import com.fr.env.RemoteEnv;
import com.fr.file.FILE;
import com.fr.file.FileNodeFILE;
import com.fr.file.filetree.FileNode;
@ -93,6 +92,7 @@ import com.fr.stable.StringUtils;
import com.fr.stable.module.Module;
import com.fr.stable.project.ProjectConstants;
import com.fr.web.controller.ViewRequestConstants;
import com.fr.workspace.WorkContext;
import javax.swing.*;
import java.awt.event.ActionEvent;
@ -634,7 +634,7 @@ public class JWorkBook extends JTemplate<WorkBook, WorkBookUndoState> {
public ShortCut[] shortcut4FileMenu() {
return (ShortCut[]) ArrayUtils.addAll(
super.shortcut4FileMenu(),
BaseUtils.isAuthorityEditing() || (FRContext.getCurrentEnv() instanceof RemoteEnv) ? new ShortCut[0] : new ShortCut[]{this.createWorkBookExportMenu()}
BaseUtils.isAuthorityEditing() || (!WorkContext.getCurrent().isLocal()) ? new ShortCut[0] : new ShortCut[]{this.createWorkBookExportMenu()}
);
}

8
designer-realize/src/com/fr/design/mainframe/alphafine/cell/model/PluginModel.java

@ -1,14 +1,13 @@
package com.fr.design.mainframe.alphafine.cell.model;
import com.fr.base.FRContext;
import com.fr.design.extra.WebViewDlgHelper;
import com.fr.design.mainframe.alphafine.AlphaFineConstants;
import com.fr.design.mainframe.alphafine.CellType;
import com.fr.env.RemoteEnv;
import com.fr.log.FineLoggerFactory;
import com.fr.json.JSONException;
import com.fr.json.JSONObject;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils;
import com.fr.workspace.WorkContext;
/**
* Created by XiaXiang on 2017/4/20.
@ -106,7 +105,8 @@ public class PluginModel extends AlphaCellModel {
@Override
public void doAction() {
if (StringUtils.isBlank(this.pluginId) || FRContext.getCurrentEnv() instanceof RemoteEnv) {
if (StringUtils.isBlank(this.pluginId) || !WorkContext.getCurrent().isLocal()) {
return;
}
WebViewDlgHelper.showPluginInStore(getName(), "[" + ModelToJson().optString("result") + "]");

20
designer-realize/src/com/fr/design/report/freeze/RepeatAndFreezeSettingPane.java

@ -1,13 +1,5 @@
package com.fr.design.report.freeze;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import com.fr.base.FRContext;
import com.fr.design.dialog.BasicPane;
import com.fr.design.extra.WebViewDlgHelper;
@ -15,12 +7,19 @@ import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.ilable.ActionLabel;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.env.RemoteEnv;
import com.fr.general.Inter;
import com.fr.page.ReportPageAttrProvider;
import com.fr.stable.ColumnRow;
import com.fr.stable.FT;
import com.fr.stable.bridge.StableFactory;
import com.fr.workspace.WorkContext;
import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
/**
* Sets Report Page Attributes
@ -244,7 +243,8 @@ public class RepeatAndFreezeSettingPane extends BasicPane {
}
private boolean shouldShowTip() {
return !(FRContext.getCurrentEnv() instanceof RemoteEnv) && FRContext.isChineseEnv();
return WorkContext.getCurrent().isLocal() && FRContext.isChineseEnv();
}
protected void initWriteListener() {

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

@ -1,27 +1,11 @@
package com.fr.start.module;
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.core.env.proxy.EnvProxy;
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.design.DesignerEnvManager;
import com.fr.file.filetree.FileNode;
import com.fr.general.ComparatorUtils;
import com.fr.module.Activator;
import com.fr.start.EnvSwitcher;
import com.fr.start.ServerStarter;
import java.io.InputStream;
import java.io.OutputStream;
/**
* Created by juhaoyu on 2018/1/8.
* 设计器启动时的环境相关模块activator
@ -54,159 +38,159 @@ public class DesignerEnvProvider extends Activator {
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);
}
}
));
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);
}
}
));
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);
}
}
));
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);
}
}
));
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);
}
}
));
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);
}
}
));
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);
}
}
));
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);
}
}
));
// 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);
// }
// }
// ));
//
// 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);
// }
// }
// ));
//
// 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);
// }
// }
// ));
//
// 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);
// }
// }
// ));
//
// 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);
// }
// }
// ));
//
// 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);
// }
// }
// ));
//
// 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);
// }
// }
// ));
//
// 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);
// }
// }
// ));
}
@Override

14
designer-realize/src/com/fr/start/module/DesignerStartup.java

@ -1,7 +1,5 @@
package com.fr.start.module;
import com.fr.base.env.EnvConfig;
import com.fr.core.env.EnvEvent;
import com.fr.event.Event;
import com.fr.event.Listener;
import com.fr.module.Activator;
@ -9,6 +7,8 @@ import com.fr.start.Designer;
import com.fr.start.EnvSwitcher;
import com.fr.start.SplashContext;
import com.fr.startup.activators.BasicActivator;
import com.fr.workspace.Workspace;
import com.fr.workspace.WorkspaceEvent;
/**
* Created by juhaoyu on 2018/1/8.
@ -38,19 +38,19 @@ public class DesignerStartup extends Activator {
* 切换环境时重新启动所有相关模块
*/
private void registerEnvListener() {
listenEvent(EnvEvent.BEFORE_SIGN_OUT, new Listener<EnvConfig>() {
listenEvent(WorkspaceEvent.BeforeSwitch, new Listener<Workspace>() {
@Override
public void on(Event event, EnvConfig param) {
public void on(Event event, Workspace param) {
getSub(EnvBasedModule.class).stop();
}
});
listenEvent(EnvEvent.AFTER_SIGN_IN, new Listener<EnvConfig>() {
listenEvent(WorkspaceEvent.AfterSwitch, new Listener<Workspace>() {
@Override
public void on(Event event, EnvConfig param) {
public void on(Event event, Workspace param) {
getSub(EnvBasedModule.class).start();
}

Loading…
Cancel
Save