Browse Source

Merge branch 'release/10.0' of https://code.fineres.com/scm/~henry.wang/design into release/10.0

zheng-1641779399395
Henry.Wang 3 years ago
parent
commit
e7cdfce436
  1. 2
      designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java
  2. 1
      designer-base/src/main/java/com/fr/design/data/datapane/connect/JDBCDefPane.java
  3. 20
      designer-base/src/main/java/com/fr/design/env/DesignerWorkspaceInfoContext.java
  4. 25
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypePane.java
  5. 1
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/ChartImagePane.java
  6. 10
      designer-form/src/main/java/com/fr/design/designer/creator/XWParameterLayout.java
  7. 27
      designer-form/src/main/java/com/fr/design/mainframe/FormSelectionUtils.java
  8. 10
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/OnlineWidgetRepoPane.java
  9. 131
      designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java
  10. 2
      designer-realize/src/main/java/com/fr/design/report/PageSetupPane.java

2
designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java

@ -8,6 +8,7 @@ import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.env.DesignerWorkspaceGenerator;
import com.fr.design.env.DesignerWorkspaceInfo;
import com.fr.design.env.DesignerWorkspaceInfoContext;
import com.fr.design.env.DesignerWorkspaceType;
import com.fr.design.env.RemoteDesignerWorkspaceInfo;
import com.fr.design.env.RemoteWorkspace;
@ -105,6 +106,7 @@ public class EnvChangeEntrance {
private boolean switch2Env(final String envName, PopTipStrategy strategy) {
DesignerEnvManager envManager = DesignerEnvManager.getEnvManager();
DesignerWorkspaceInfo selectedEnv = envManager.getWorkspaceInfo(envName);
DesignerWorkspaceInfoContext.setWorkspaceInfo(selectedEnv);
WorkspaceConnectionInfo connectionInfo = selectedEnv.getConnection();
try {

1
designer-base/src/main/java/com/fr/design/data/datapane/connect/JDBCDefPane.java

@ -511,7 +511,6 @@ public class JDBCDefPane extends JPanel {
this.dbtypeComboBox.setSelectedItem(OTHER_DB);
}
}
this.jdbcDatabase.setIdentity(jdbcDatabase.getIdentity());
// jdbcDatabase.getDriverSource() 只会是空或者是有值,但是为了保险起见,还是应该做个处理
String driverSource = jdbcDatabase.getDriverSource();
if (driverSource == null) {

20
designer-base/src/main/java/com/fr/design/env/DesignerWorkspaceInfoContext.java vendored

@ -0,0 +1,20 @@
package com.fr.design.env;
/**
*
* @author hades
* @version 10.0
* Created by hades on 2021/8/24
*/
public class DesignerWorkspaceInfoContext {
private static DesignerWorkspaceInfo workspaceInfo;
public static DesignerWorkspaceInfo getWorkspaceInfo() {
return workspaceInfo;
}
public static void setWorkspaceInfo(DesignerWorkspaceInfo workspaceInfo) {
DesignerWorkspaceInfoContext.workspaceInfo = workspaceInfo;
}
}

25
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypePane.java

@ -25,17 +25,19 @@ import com.fr.stable.AssistUtils;
import com.fr.stable.StringUtils;
import javax.swing.JPanel;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
/**
* 图表 属性表, 类型选择 界面.
@ -99,6 +101,19 @@ public class ChartTypePane extends AbstractChartAttrPane {
buttonPane.setEditingChartPane(chartTypeComBox);
buttonPane.addMouseListener(new MouseAdapter() {
@Override
public void mouseReleased(MouseEvent e) {
buttonPane.requestFocus();
}
});
chartTypeComBox.addMouseListener(new MouseAdapter() {
@Override
public void mouseReleased(MouseEvent e) {
content.requestFocus();
}
});
return content;
}

1
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/ChartImagePane.java

@ -72,6 +72,7 @@ public class ChartImagePane extends ChartSelectDemoPane {
}else{
this.isDoubleClicked = false;
}
this.requestFocus();
super.mouseClicked(e);
}

10
designer-form/src/main/java/com/fr/design/designer/creator/XWParameterLayout.java

@ -103,6 +103,16 @@ public class XWParameterLayout extends XWAbsoluteLayout {
return false;
}
@Override
public boolean canEnterIntoAbsolutePane() {
return false;
}
@Override
public boolean canEnterIntoAdaptPane() {
return false;
}
/**
* 该组件是否可以拖拽(表单中参数面板和自适应布局不可以拖拽)
* @return 是则返回true

27
designer-form/src/main/java/com/fr/design/mainframe/FormSelectionUtils.java

@ -10,6 +10,7 @@ import com.fr.design.designer.creator.XCreatorUtils;
import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.creator.XWAbsoluteLayout;
import com.fr.design.designer.creator.XWFitLayout;
import com.fr.design.designer.creator.XWParameterLayout;
import com.fr.design.designer.creator.XWScaleLayout;
import com.fr.design.designer.creator.XWTitleLayout;
import com.fr.design.designer.creator.cardlayout.XWTabFitLayout;
@ -60,6 +61,11 @@ public class FormSelectionUtils {
*/
public static void paste2Container(FormDesigner designer, XLayoutContainer parent,
FormSelection clipboard, int x, int y) {
clipboard = filterFormSelection(clipboard, parent);
if (clipboard.isEmpty()) {
Toolkit.getDefaultToolkit().beep();
return;
}
LayoutAdapter adapter = parent.getLayoutAdapter();
if (parent instanceof XWAbsoluteLayout) {
//绝对布局
@ -77,6 +83,27 @@ public class FormSelectionUtils {
Toolkit.getDefaultToolkit().beep();
}
private static FormSelection filterFormSelection(FormSelection clipboard, XLayoutContainer parent) {
FormSelection newSelection = new FormSelection();
for (XCreator xCreator : clipboard.getSelectedCreators()) {
if (parent.acceptType(XWParameterLayout.class)) {
if (xCreator.canEnterIntoParaPane()) {
newSelection.addSelectedCreator(xCreator);
}
} else if (parent.acceptType(XWAbsoluteLayout.class)) {
if (xCreator.canEnterIntoAbsolutePane()) {
newSelection.addSelectedCreator(xCreator);
}
} else if (parent.acceptType(XWFitLayout.class)) {
if (xCreator.canEnterIntoAdaptPane()) {
newSelection.addSelectedCreator(xCreator);
}
}
}
return newSelection;
}
private static boolean isExtraContainer(XLayoutContainer parent) {
if (parent != null) {
Set<FormWidgetOptionProvider> set = ExtraDesignClassManager.getInstance().getArray(FormWidgetOptionProvider.XML_TAG);

10
designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/OnlineWidgetRepoPane.java

@ -14,6 +14,7 @@ import com.fr.stable.StringUtils;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
import javax.swing.SwingWorker;
import java.awt.BorderLayout;
@ -164,9 +165,14 @@ public class OnlineWidgetRepoPane extends BasicPane {
tipLabel1.setForeground(Color.decode("#8F8F92"));
UILabel tipLabel2 = tipLabel(Toolkit.i18nText("Fine-Design_Share_Internet_Connect_Failed_Tip2"));
tipLabel2.setForeground(Color.decode("#8F8F92"));
UILabel tipLabel3 = tipLabel(MARKET_URL);
tipLabel3.setForeground(Color.decode("#8F8F92"));
JTextField tipLabel3 = new JTextField(MARKET_URL);
tipLabel3.setHorizontalAlignment(JTextField.CENTER);
tipLabel3.setPreferredSize(new Dimension(240, 20));
tipLabel3.setEditable(false);
tipLabel3.setForeground(Color.decode("#8F8F92"));
tipLabel3.setBackground(null);
tipLabel3.setBorder(null);
UILabel emptyLabel = tipLabel(StringUtils.EMPTY);
panel.add(uiLabel);

131
designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java

@ -5,29 +5,40 @@ import com.fr.decision.webservice.utils.DecisionServiceConstants;
import com.fr.design.DesignerEnvManager;
import com.fr.design.EnvChangeEntrance;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.env.DesignerWorkspaceInfo;
import com.fr.design.env.DesignerWorkspaceInfoContext;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.loghandler.DesignerLogger;
import com.fr.design.ui.util.UIUtil;
import com.fr.event.Event;
import com.fr.event.EventDispatcher;
import com.fr.event.Listener;
import com.fr.general.ComparatorUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.report.RemoteDesignConstants;
import com.fr.serialization.SerializerHelper;
import com.fr.stable.ArrayUtils;
import com.fr.stable.StringUtils;
import com.fr.third.apache.log4j.spi.LoggingEvent;
import com.fr.third.org.apache.http.conn.ssl.NoopHostnameVerifier;
import com.fr.third.org.apache.http.conn.ssl.TrustSelfSignedStrategy;
import com.fr.third.org.apache.http.ssl.SSLContexts;
import com.fr.web.WebSocketConfig;
import com.fr.web.socketio.WebSocketProtocol;
import com.fr.workspace.WorkContext;
import com.fr.workspace.Workspace;
import com.fr.workspace.WorkspaceEvent;
import com.fr.workspace.base.WorkspaceConstants;
import com.fr.workspace.connect.WorkspaceConnection;
import com.fr.workspace.connect.WorkspaceConnectionInfo;
import com.fr.workspace.server.socket.SocketInfoOperator;
import io.socket.client.IO;
import io.socket.client.Socket;
import io.socket.emitter.Emitter;
import java.io.File;
import java.io.FileInputStream;
import java.security.KeyStore;
import java.util.Arrays;
import javax.net.ssl.SSLContext;
import javax.swing.*;
import java.io.IOException;
import java.net.URI;
@ -37,26 +48,14 @@ import java.util.TimerTask;
public class DesignerSocketIO {
static {
EventDispatcher.listen(WorkspaceEvent.LostConnect, new Listener<Workspace>() {
@Override
public void on(Event event, Workspace param) {
// 远程设计websocket不支持wss 所以断开无法提醒
// 使用远程设计的心跳断开来提醒断开
if (DesignerEnvManager.getEnvManager().isHttps()) {
showConnectionLostDialog();
}
}
});
}
enum Status {
Connected,
Disconnected,
Disconnecting
}
private static final String HTTPS = "https";
private static final String HTTP = "http";
private static Socket socket = null;
private static Status status = Status.Disconnected;
private static Timer disConnectHintTimer = null;
@ -65,6 +64,8 @@ public class DesignerSocketIO {
private static String[] uri;
//维护一个关于uri列表的计数器
private static int count;
// 当前webSocket选择的协议
private static String currentProtocol;
public static void close() {
@ -95,7 +96,7 @@ public class DesignerSocketIO {
//根据uri和计数器建立连接,并注册监听
try {
if (count < uri.length) {
socket = IO.socket(new URI(uri[count]));
socket = IO.socket(new URI(uri[count]), createOptions());
socket.on(WorkspaceConstants.WS_LOGRECORD, printLog);
socket.on(WorkspaceConstants.CONFIG_MODIFY, modifyConfig);
socket.on(Socket.EVENT_CONNECT_ERROR, failRetry);
@ -112,15 +113,58 @@ public class DesignerSocketIO {
}
}
private static IO.Options createOptions() {
IO.Options options = new IO.Options();
try {
if (ComparatorUtils.equals(currentProtocol, HTTPS)) {
options.sslContext = getSSLContext();
options.hostnameVerifier = NoopHostnameVerifier.INSTANCE;
options.secure = true;
}
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
return options;
}
private static SSLContext getSSLContext() throws Exception {
WorkspaceConnectionInfo connection = getConnectionInfo();
String certPath = connection.getCertPath();
String certSecretKey = connection.getCertSecretKey();
if (StringUtils.isBlank(certPath) || StringUtils.isBlank(certSecretKey)) {
return SSLContexts.createDefault();
}
KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType());
try (FileInputStream keystore = new FileInputStream(new File(certPath))) {
trustStore.load(keystore, certSecretKey.toCharArray());
}
return SSLContexts.custom()
.loadTrustMaterial(trustStore, new TrustSelfSignedStrategy())
.build();
}
private static WorkspaceConnectionInfo getConnectionInfo() {
if (DesignerWorkspaceInfoContext.getWorkspaceInfo() == null) {
String currentName = DesignerEnvManager.getEnvManager().getCurEnvName();
DesignerWorkspaceInfo info = DesignerEnvManager.getEnvManager().getWorkspaceInfo(currentName);
return info.getConnection();
} else {
return DesignerWorkspaceInfoContext.getWorkspaceInfo().getConnection();
}
}
private static String[] getSocketUri() throws IOException {
Workspace current = WorkContext.getCurrent();
URL url = new URL(current.getPath());
Integer[] ports = current.get(SocketInfoOperator.class).getPort();
WorkspaceConnection connection = current.getConnection();
// 服务器配置https webSocket可能是wss也可能是ws webSocket的协议可以单独配置
WebSocketProtocol webSocketProtocol = WebSocketConfig.getInstance().getProtocol();
currentProtocol = webSocketProtocol == WebSocketProtocol.PLAIN ? HTTP : HTTPS;
String[] result = new String[ports.length];
for (int i = 0; i < ports.length; i++) {
result[i] = String.format("%s://%s:%s%s?%s=%s&%s=%s",
url.getProtocol(),
currentProtocol,
url.getHost(),
ports[i],
WorkspaceConstants.WS_NAMESPACE,
@ -129,6 +173,7 @@ public class DesignerSocketIO {
RemoteDesignConstants.USER_LOCK_ID,
connection.getId());
}
FineLoggerFactory.getLogger().error("Available ports: {}, current Protocol: {}", Arrays.toString(ports), currentProtocol);
return result;
}
@ -136,7 +181,7 @@ public class DesignerSocketIO {
private static final Emitter.Listener failRetry = new Emitter.Listener() {
@Override
public void call(Object... args) {
FineLoggerFactory.getLogger().warn("failed args: {}", Arrays.toString(args));
printLog(args, PrintEventLogImpl.WARN, "failed args: {}");
status = Status.Disconnecting;
socket.close();
count++;
@ -183,7 +228,7 @@ public class DesignerSocketIO {
* todo 远程心跳断开不一定 socket 断开 和远程紧密相关的业务都绑定在心跳上切换成心跳断开之后进行提醒
* socket 只用推日志和通知配置变更
*/
FineLoggerFactory.getLogger().error("disConnected args: {}", Arrays.toString(objects));
printLog(objects, PrintEventLogImpl.ERROR, "disConnected args: {}");
if (status != Status.Disconnecting) {
showConnectionLostDialog();
}
@ -199,7 +244,7 @@ public class DesignerSocketIO {
private static void showConnectionLostDialog() {
try {
UIUtil.invokeAndWaitIfNeeded(new Runnable() {
UIUtil.invokeLaterIfNeeded(new Runnable() {
@Override
public void run() {
FineJOptionPane.showMessageDialog(
@ -226,4 +271,46 @@ public class DesignerSocketIO {
}
};
private static void printLog(Object[] objects, PrintEventLog printEventLog, String prefix) {
for (Object object : objects) {
if (object instanceof Throwable) {
Throwable throwable = (Throwable) object;
printEventLog.printThrowable(throwable);
} else {
printEventLog.print(prefix, object);
}
}
}
interface PrintEventLog {
void printThrowable(Throwable throwable);
void print(String s, Object ...object);
}
enum PrintEventLogImpl implements PrintEventLog {
ERROR {
@Override
public void printThrowable(Throwable throwable) {
FineLoggerFactory.getLogger().error(throwable.getMessage(), throwable);
}
@Override
public void print(String s, Object... object) {
FineLoggerFactory.getLogger().error(s, object);
}
},
WARN {
@Override
public void printThrowable(Throwable throwable) {
FineLoggerFactory.getLogger().warn(throwable.getMessage(), throwable);
}
@Override
public void print(String s, Object... object) {
FineLoggerFactory.getLogger().warn(s, object);
}
};
}
}

2
designer-realize/src/main/java/com/fr/design/report/PageSetupPane.java

@ -779,7 +779,7 @@ public class PageSetupPane extends BasicPane {
//使用科学计数法显示长度的时候,限制纵向显示长度为9位
if (h_str.contains(E)) {
String str1 = h_str.substring(h_str.indexOf(E));
String str2 = h_str.substring(0, 9 - str1.length());
String str2 = h_str.substring(0, Math.min(h_str.length(), 9) - str1.length());
h_str = str2 + str1;
} else if (h_str.indexOf(CoreConstants.DOT) > 0) {
h_str = h_str.substring(0, h_str.indexOf(CoreConstants.DOT) + 2);

Loading…
Cancel
Save