diff --git a/designer-base/src/main/java/com/fr/design/actions/server/GlobalTableDataAction.java b/designer-base/src/main/java/com/fr/design/actions/server/GlobalTableDataAction.java index 3778e49d7c..71487b5649 100644 --- a/designer-base/src/main/java/com/fr/design/actions/server/GlobalTableDataAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/server/GlobalTableDataAction.java @@ -8,7 +8,8 @@ import com.fr.design.DesignModelAdapter; import com.fr.design.actions.UpdateAction; import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.datapane.TableDataTreePane; -import com.fr.workspace.server.repository.tabledata.TableDataBeanHelper; +import com.fr.design.data.datapane.preview.ConnectionInfoBeanHelper; +import com.fr.design.data.datapane.preview.TableDataBeanHelper; import com.fr.design.data.tabledata.ResponseDataSourceChange; import com.fr.design.data.tabledata.tabledatapane.TableDataManagerPane; import com.fr.design.dialog.BasicDialog; @@ -24,10 +25,8 @@ import com.fr.esd.event.DSMapping; import com.fr.esd.event.DsNameTarget; import com.fr.esd.event.StrategyEventsNotifier; -import com.fr.file.TableDataConfig; import com.fr.report.LockItem; import com.fr.security.encryption.transmission.TransmissionEncryptionManager; -import com.fr.workspace.server.entity.connection.ConnectionBean; import com.fr.workspace.server.repository.connection.ConnectionRepository; import com.fr.workspace.server.repository.tabledata.TableDataRepository; @@ -85,11 +84,7 @@ public class GlobalTableDataAction extends UpdateAction implements ResponseDataS // 锁定成功,执行后续操作 final DesignerFrame designerFrame = DesignerContext.getDesignerFrame(); final List beans = TableDataRepository.getInstance().getAllTableData(); - final List connectionInfoBeans = ConnectionRepository.getInstance().getAll(); - final Map connectionMap = new HashMap<>(); - for (ConnectionBean bean : connectionInfoBeans) { - connectionMap.put(bean.getName(), bean.getConnection()); - } + final Map connectionMap = ConnectionInfoBeanHelper.createConnectionMap(ConnectionRepository.getInstance().getAll()); final Map tableDataMap = new HashMap<>(); try { TransmissionEncryptionManager.setTransEncryptionLevel(1); diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/TableDataPaneListPane.java b/designer-base/src/main/java/com/fr/design/data/datapane/TableDataPaneListPane.java index f6d4ce7658..f5fe0edf89 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/TableDataPaneListPane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/TableDataPaneListPane.java @@ -10,7 +10,7 @@ import com.fr.decision.webservice.bean.dataset.ServerDataSetBean; import com.fr.design.data.BasicTableDataUtils; import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.MapCompareUtils; -import com.fr.workspace.server.repository.tabledata.TableDataBeanHelper; +import com.fr.design.data.datapane.preview.TableDataBeanHelper; import com.fr.design.dialog.FineJOptionPane; import com.fr.design.gui.controlpane.JListControlPane; import com.fr.design.gui.controlpane.NameableCreator; diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/TableDataTree.java b/designer-base/src/main/java/com/fr/design/data/datapane/TableDataTree.java index ca7cb38b4b..b1877fa75e 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/TableDataTree.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/TableDataTree.java @@ -64,11 +64,11 @@ public class TableDataTree extends UserObjectRefreshJTree { } else if (nameObject.getObject() instanceof Integer) { int num = (Integer) nameObject.getObject(); if (num == TableDataSourceOP.SERVER_TABLE_DATA) { - this.setIcon(IconUtils.readIcon(IconPathConstants.STD_SHOW_ICON_PATH)); + this.setIcon(new LazyIcon("server_database")); } else if (num == TableDataSourceOP.STORE_PRECEDURE_DATA) { - this.setIcon(IconUtils.readIcon(IconPathConstants.SP_SHOW_ICON_PATH)); + this.setIcon(new LazyIcon("store_procedure")); } else { - this.setIcon(IconUtils.readIcon(IconPathConstants.DS_QUERY_ICON_PATH)); + this.setIcon(new LazyIcon("database")); } } else { this.setIcon(new LazyIcon("store_procedure")); diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/TreeTableDataComboBox.java b/designer-base/src/main/java/com/fr/design/data/datapane/TreeTableDataComboBox.java index b0f9a12551..a19de0d602 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/TreeTableDataComboBox.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/TreeTableDataComboBox.java @@ -6,7 +6,8 @@ import com.fr.data.impl.Connection; import com.fr.data.impl.RecursionTableData; import com.fr.decision.webservice.bean.dataset.ServerDataSetBean; import com.fr.design.data.DesignTableDataManager; -import com.fr.workspace.server.repository.tabledata.TableDataBeanHelper; +import com.fr.design.data.datapane.preview.ConnectionInfoBeanHelper; +import com.fr.design.data.datapane.preview.TableDataBeanHelper; import com.fr.design.data.tabledata.wrapper.ServerTableDataWrapper; import com.fr.design.data.tabledata.wrapper.TableDataWrapper; import com.fr.design.data.tabledata.wrapper.TemplateTableDataWrapper; @@ -14,7 +15,6 @@ import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.icombobox.UIComboBoxRenderer; import com.fr.security.encryption.transmission.TransmissionEncryptionManager; import com.fr.stable.StringUtils; -import com.fr.workspace.server.entity.connection.ConnectionBean; import com.fr.workspace.server.repository.connection.ConnectionRepository; import com.fr.workspace.server.repository.tabledata.TableDataRepository; @@ -71,11 +71,7 @@ public class TreeTableDataComboBox extends UIComboBox { // 全局数据集 List beans = TableDataRepository.getInstance().getAllTableData(); Map map = new HashMap<>(); - final List connectionInfoBeans = ConnectionRepository.getInstance().getAll(); - final Map connectionMap = new HashMap<>(); - for (ConnectionBean bean : connectionInfoBeans) { - connectionMap.put(bean.getName(), bean.getConnection()); - } + final Map connectionMap = ConnectionInfoBeanHelper.createConnectionMap(ConnectionRepository.getInstance().getAll()); try { TransmissionEncryptionManager.setTransEncryptionLevel(1); for (ServerDataSetBean bean : beans) { diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionComboBoxPanel.java b/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionComboBoxPanel.java index 4be579742a..2376872a0f 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionComboBoxPanel.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionComboBoxPanel.java @@ -7,6 +7,7 @@ import com.fr.data.impl.AbstractDatabaseConnection; import com.fr.data.impl.Connection; import com.fr.data.impl.NameDatabaseConnection; import com.fr.design.DesignerEnvManager; +import com.fr.design.data.datapane.preview.ConnectionInfoBeanHelper; import com.fr.design.editlock.ConnectionLockChangeChecker; import com.fr.design.editlock.EditLockUtils; import com.fr.design.gui.ibutton.UIButton; @@ -28,6 +29,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; import java.util.List; +import java.util.Map; /** * 选择数据连接的下拉框 @@ -89,13 +91,13 @@ public class ConnectionComboBoxPanel extends ItemEditableComboBoxPanel { if (noAuthConnections == null) { return nameList.iterator(); } - List beans = ConnectionRepository.getInstance().getAll(); - for (ConnectionBean bean : beans) { - String conName = bean.getName(); + final Map connectionMap = ConnectionInfoBeanHelper.createConnectionMap(ConnectionRepository.getInstance().getAll()); + for (Map.Entry connectionEntry : connectionMap.entrySet()) { + String conName = connectionEntry.getKey(); if (noAuthConnections.contains(conName)) { continue; } - filterConnection(bean.getConnection(), conName, nameList); + filterConnection(connectionEntry.getValue(), conName, nameList); } return nameList.iterator(); } diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionListPane.java b/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionListPane.java index 3dd4a62318..baa1f74059 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionListPane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionListPane.java @@ -190,11 +190,11 @@ public class ConnectionListPane extends JListControlPane implements ConnectionSh public void populate(Map connectionMap) { List nameObjectList = new ArrayList(); populatedConnectionsSnapshot.clear(); - List beans = ConnectionRepository.getInstance().getAll(); - for (com.fr.workspace.server.entity.connection.ConnectionBean entry : beans) { - nameObjectList.add(new NameObject(entry.getName(), entry.getConnection())); + final Map map = ConnectionInfoBeanHelper.createConnectionMap(ConnectionRepository.getInstance().getAll()); + for (Map.Entry entry : map.entrySet()) { + nameObjectList.add(new NameObject(entry.getKey(), entry.getValue())); try { - populatedConnectionsSnapshot.put(entry.getName(), (Connection) entry.getConnection().clone()); + populatedConnectionsSnapshot.put(entry.getKey(), (Connection) entry.getValue().clone()); } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); } @@ -365,11 +365,7 @@ public class ConnectionListPane extends JListControlPane implements ConnectionSh } public static void showDialog(Window parent) { - List beans = ConnectionRepository.getInstance().getAll(); - Map connectionMap = new HashMap<>(); - for (ConnectionBean bean : beans) { - connectionMap.put(bean.getName(), bean.getConnection()); - } + final Map connectionMap = ConnectionInfoBeanHelper.createConnectionMap(ConnectionRepository.getInstance().getAll()); final ConnectionManagerPane connectionManagerPane = new ConnectionManagerPane() { @Override public void complete() { diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/connect/LocalConnectionSource.java b/designer-base/src/main/java/com/fr/design/data/datapane/connect/LocalConnectionSource.java index 54f4c3c048..bfad0a1850 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/connect/LocalConnectionSource.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/connect/LocalConnectionSource.java @@ -1,16 +1,21 @@ package com.fr.design.data.datapane.connect; +import com.fanruan.config.impl.data.ConnectionConfigProviderFactory; import com.fr.data.driver.DriverClassNotFoundException; import com.fr.data.impl.Connection; import com.fr.decision.webservice.bean.datasource.ConnectionInfoBean; import com.fr.decision.webservice.exception.general.DriverNotFoundException; import com.fr.decision.webservice.v10.datasource.connection.processor.impl.ConnectionProcessorFactory; +import com.fr.design.data.datapane.preview.ConnectionInfoBeanHelper; import com.fr.design.i18n.Toolkit; import com.fr.log.FineLoggerFactory; import com.fr.security.encryption.transmission.TransmissionEncryptionManager; import com.fr.workspace.engine.exception.DriverUnExistException; import com.fr.workspace.server.repository.connection.BaseConnectionSource; import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; /** * 本地Connection资源操作 @@ -21,6 +26,20 @@ import java.sql.SQLException; */ public class LocalConnectionSource extends BaseConnectionSource { + @Override + public ConnectionInfoBean[] getAll(){ + Map map = ConnectionConfigProviderFactory.getConfigProvider().getConnections(); + List beans = new ArrayList<>(); + for (String name : map.keySet()) { + try { + beans.add(ConnectionInfoBeanHelper.createConnectionInfoBean(name, map.get(name))); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + } + return beans.toArray(new ConnectionInfoBean[0]); + } + @Override public void testConnection(ConnectionInfoBean database) throws Exception { try { diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/connect/SslPane.java b/designer-base/src/main/java/com/fr/design/data/datapane/connect/SslPane.java index 10cd4e5e2f..62e6666acd 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/connect/SslPane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/connect/SslPane.java @@ -146,7 +146,7 @@ public class SslPane extends BasicPane { @Override public void actionPerformed(ActionEvent e) { - FILEChooserPane fileChooser = FILEChooserPane.getInstanceWithDesignatePath(SslUtils.PREFIX, new ChooseFileFilter(true), SslUtils.CERTIFICATES); + FILEChooserPane fileChooser = FILEChooserPane.getFileCAChoosePane(new ChooseFileFilter(true)); int type = fileChooser.showOpenDialog(SslPane.this, StringUtils.EMPTY); if (type == FILEChooserPane.OK_OPTION) { final FILE file = fileChooser.getSelectedFILE(); diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/preview/ConnectionInfoBeanHelper.java b/designer-base/src/main/java/com/fr/design/data/datapane/preview/ConnectionInfoBeanHelper.java index b2f8aad61b..6ad25c57c6 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/preview/ConnectionInfoBeanHelper.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/preview/ConnectionInfoBeanHelper.java @@ -3,6 +3,7 @@ package com.fr.design.data.datapane.preview; import com.fr.data.auth.AuthenticationType; import com.fr.data.auth.kerberos.KerberosAuthentication; import com.fr.data.auth.kerberos.KerberosUtils; +import com.fr.data.core.db.dialect.DialectFactory; import com.fr.data.impl.Connection; import com.fr.data.impl.JDBCDatabaseConnection; import com.fr.data.impl.NameDatabaseConnection; @@ -10,7 +11,9 @@ import com.fr.data.pool.DBCPConnectionPoolAttr; import com.fr.data.security.ssh.BaseSsh; import com.fr.data.security.ssh.SshType; import com.fr.data.security.ssh.impl.KeyVerifySsh; +import com.fr.data.security.ssh.impl.NormalSsh; import com.fr.data.security.ssl.BaseSsl; +import com.fr.data.security.ssl.Ssl; import com.fr.data.security.ssl.SslType; import com.fr.data.security.ssl.impl.NormalSsl; import com.fr.decision.privilege.TransmissionTool; @@ -19,11 +22,21 @@ import com.fr.decision.webservice.bean.datasource.JDBCConnectionBean; import com.fr.decision.webservice.utils.DecisionServiceConstants; import com.fr.decision.webservice.v10.datasource.connection.processor.impl.ConnectionProcessorFactory; import com.fr.decision.webservice.v10.datasource.connection.processor.impl.JDBCConnectionProcessor; +import com.fr.log.FineLoggerFactory; +import com.fr.module.tool.ActivatorToolBox; import com.fr.security.encryption.transmission.TransmissionEncryptionManager; +import com.fr.stable.Constants; import com.fr.stable.StringUtils; +import com.fr.third.fasterxml.jackson.core.JsonProcessingException; import com.fr.third.fasterxml.jackson.databind.ObjectMapper; +import com.fr.third.springframework.beans.BeanUtils; import com.fr.workspace.server.repository.WorkplaceConstants; import com.fr.workspace.server.repository.connection.ConnectionRepository; +import com.fr.workspace.server.repository.tabledata.DataEncryptionHelper; + +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; /** * 数据连接传输工具类 @@ -34,6 +47,36 @@ import com.fr.workspace.server.repository.connection.ConnectionRepository; */ public class ConnectionInfoBeanHelper { private static ObjectMapper objectMapper = new ObjectMapper(); + private static final Map FETCH_SIZE_MAP = ActivatorToolBox.sandbox(new HashMap()); + private static final int ORACLE_DEFAULT_FETCH_SIZE = 128; + private static final int DB2_DEFAULT_FETCH_SIZE = 50; + private static final int POSTGRE_DEFAULT_FETCH_SIZE = 10000; + + static { + FETCH_SIZE_MAP.put("oracle", ORACLE_DEFAULT_FETCH_SIZE); + FETCH_SIZE_MAP.put("ibm-db2", DB2_DEFAULT_FETCH_SIZE); + FETCH_SIZE_MAP.put("postgresql", POSTGRE_DEFAULT_FETCH_SIZE); + } + + + /** + * 获取连接Map + */ + public static Map createConnectionMap(ConnectionInfoBean[] beans) { + Map ans = new HashMap<>(); + for (ConnectionInfoBean infoBean : beans) { + try { + if (JDBCConnectionProcessor.KEY.acceptConnectionTypes().contains(infoBean.getConnectionType())) { + ans.put(infoBean.getConnectionName(), createJDBCConnection(infoBean)); + } else { + ans.put(infoBean.getConnectionName(), ConnectionProcessorFactory.createConnection(infoBean, true)); + } + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + } + return ans; + } /** * 创建数据连接Bean,可自定义是否携带密码 @@ -137,4 +180,101 @@ public class ConnectionInfoBeanHelper { return TransmissionEncryptionManager.getInstance().getEncryption(WorkplaceConstants.getEncryptionMode()).encrypt(password, WorkplaceConstants.getEncryptionKey()); } + + private static Connection createJDBCConnection(ConnectionInfoBean connectionInfoBean) throws Exception { + String name = connectionInfoBean.getConnectionName(); + if (StringUtils.isNotEmpty(connectionInfoBean.getConnectionId())) { + name = connectionInfoBean.getConnectionId(); + } + JDBCDatabaseConnection connection = new JDBCDatabaseConnection(); + JDBCConnectionBean bean = objectMapper.readValue(connectionInfoBean.getConnectionData(), JDBCConnectionBean.class); + if (StringUtils.isNotEmpty(name)) { + bean.setConnectionName(name); + } + DBCPConnectionPoolAttr connectionPoolAttr = new DBCPConnectionPoolAttr(); + BeanUtils.copyProperties(bean.getConnectionPoolAttr(), connectionPoolAttr); + connectionPoolAttr.setValidationQuery(DataEncryptionHelper.decrypt(connectionPoolAttr.getValidationQuery())); + connectionPoolAttr.setMinEvictableIdleTimeMillis(bean.getConnectionPoolAttr().getMinEvictableIdleTimeMillis() * Constants.MILLS_PER_SECOND); + connectionPoolAttr.setMaxEvictableIdleTimeMillis((long) bean.getConnectionPoolAttr().getMaxEvictableIdleTimeMillis() * Constants.MILLS_PER_SECOND); + connection.setDatabase(bean.getDatabase()); + connection.setSchema(bean.getSchema()); + connection.setDriver(bean.getDriver()); + connection.setURL(bean.getUrl()); + connection.setOriginalCharsetName(StringUtils.isEmpty(bean.getOriginalCharsetName()) ? null : bean.getOriginalCharsetName()); + connection.setNewCharsetName(StringUtils.isEmpty(bean.getNewCharsetName()) ? null : bean.getNewCharsetName()); + connection.setCreator(bean.getCreator()); + connection.setDriverSource(bean.getDriverSource()); + connection.setDbcpAttr(connectionPoolAttr); + if (StringUtils.isNotEmpty(bean.getAuthType())) { + connection.setAuthentication(new KerberosAuthentication(bean.getPrincipal(), bean.getKeyPath(), bean.isUseJaas())); + } + connection.setUser(bean.getUser()); + TransmissionEncryptionManager.getInstance().setCurrentEncryptionMode(WorkplaceConstants.getDecryptionMode()); + connection.setPassword(DataEncryptionHelper.decrypt(bean.getPassword())); + connection.setProperties(bean.getProperties()); + + setFetchSize(bean, connection); + + if (bean.getIdentity() != null) { + connection.setIdentity(bean.getIdentity()); + } + BaseSsh baseSsh; + String sshType = bean.getSshType(); + if (SshType.KEY.toString().equals(sshType)) { + baseSsh = new KeyVerifySsh(); + ((KeyVerifySsh) baseSsh).setPrivateKeyPath(bean.getSshPrivateKeyPath()); + } else { + baseSsh = new NormalSsh(); + } + baseSsh.setIp(bean.getSshIp()); + baseSsh.setUsingSsh(bean.isUsingSsh()); + baseSsh.setPort(bean.getSshPort()); + baseSsh.setUser(bean.getSshUser()); + baseSsh.setRedirectIp(bean.getRedirectIp()); + baseSsh.setRedirectPort(bean.getRedirectPort()); + baseSsh.setSecret(DataEncryptionHelper.decrypt(bean.getSshSecret())); + baseSsh.setKeepAlive(bean.getSshKeepAlive()); + baseSsh.setTimeOut(bean.getSshTimeOut()); + connection.setSsh(baseSsh); + connection.setSsl(createSsl(bean)); + return connection; + } + + private static Ssl createSsl(JDBCConnectionBean bean) { + //目前只有NormalSsl + BaseSsl baseSsl = new NormalSsl(); + if (SslType.NORMAL.toString().equals(bean.getSslType())) { + ((NormalSsl) baseSsl).setVerifyCa(bean.isVerifyCa()); + ((NormalSsl) baseSsl).setCipher(bean.getSslCipher()); + } + baseSsl.setUsingSsl(bean.isUsingSsl()); + baseSsl.setClientCertificate(bean.getSslClientCertificate()); + baseSsl.setClientPrivateKey(bean.getSslClientPrivateKey()); + baseSsl.setCaCertificate(bean.getCaCertificate()); + return baseSsl; + } + + /** + * 前端客户设置了一个fetchSize: + * 1. 如果是合法值(>0),就使用 + * 2. 如果是非法值(<=0): + * 2.1 如果我们对这种数据库有默认的fetchSize,就用默认的 + * 2.2 如果没有默认值,就不进行任何设置 + * @param bean bean + * @param connection connection + */ + private static void setFetchSize(JDBCConnectionBean bean, Connection connection) { + + int connectionBeanFetchSize = bean.getFetchSize(); + String connectionBeanDatabaseName = bean.getDatabase(); + if (DialectFactory.isValidFetchSize(connectionBeanFetchSize)) { + connection.setFetchSize(connectionBeanFetchSize); + } else if (FETCH_SIZE_MAP.containsKey(connectionBeanDatabaseName)) { + Optional.ofNullable(FETCH_SIZE_MAP.get(connectionBeanDatabaseName)).ifPresent(connection::setFetchSize); + } + FineLoggerFactory.getLogger().info("[Connection] fetchSize set to {} for connection {}", connection.getFetchSize(), bean.getConnectionName()); + + } + + } diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/preview/TableDataBeanHelper.java b/designer-base/src/main/java/com/fr/design/data/datapane/preview/TableDataBeanHelper.java new file mode 100644 index 0000000000..68f2584153 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/data/datapane/preview/TableDataBeanHelper.java @@ -0,0 +1,198 @@ +package com.fr.design.data.datapane.preview; + +import com.fr.base.DataSetProcessors; +import com.fr.base.Parameter; +import com.fr.base.ParameterHelper; +import com.fr.base.ParameterTypeHandler; +import com.fr.base.StoreProcedureParameter; +import com.fr.base.TableData; +import com.fr.data.impl.Connection; +import com.fr.data.impl.DBTableData; +import com.fr.data.impl.NameDatabaseConnection; +import com.fr.data.impl.storeproc.StoreProcedure; +import com.fr.decision.fun.UniversalServerTableDataProvider; +import com.fr.decision.webservice.bean.dataset.ParameterBean; +import com.fr.decision.webservice.bean.dataset.ParameterExternal; +import com.fr.decision.webservice.bean.dataset.SQLDataSetBean; +import com.fr.decision.webservice.bean.dataset.ServerDataSetBean; +import com.fr.decision.webservice.bean.dataset.StoreProcedureBean; +import com.fr.decision.webservice.v10.datasource.dataset.processor.impl.SQLDataSetProcessor; +import com.fr.decision.webservice.v10.datasource.dataset.processor.impl.StoreProcedureProcessor; +import com.fr.general.GeneralUtils; +import com.fr.general.sql.SqlUtils; +import com.fr.json.JSONObject; +import com.fr.log.FineLoggerFactory; +import com.fr.script.Calculator; +import com.fr.security.encryption.transmission.TransmissionEncryptionManager; +import com.fr.stable.ParameterProvider; +import com.fr.stable.StringUtils; +import com.fr.workspace.server.repository.connection.ConnectionRepository; +import com.fr.workspace.server.repository.tabledata.DataEncryptionHelper; +import com.fr.workspace.server.repository.tabledata.TableDataRepository; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 数据集bean工具类 + * + * @author Destiny.Lin + * @since 11.0 + * Created on 2024/8/9 + */ +public class TableDataBeanHelper { + + /** + * 获取服务器数据集 + */ + public static Map getServerTableDatas() { + final List beans = TableDataRepository.getInstance().getAllTableData(); + final Map connectionMap = ConnectionInfoBeanHelper.createConnectionMap(ConnectionRepository.getInstance().getAll()); + final Map tableDataMap = new HashMap<>(); + try { + TransmissionEncryptionManager.setTransEncryptionLevel(1); + for (ServerDataSetBean bean : beans) { + tableDataMap.put(bean.getDatasetName() , TableDataBeanHelper.getTableDataSet(connectionMap, bean.getDatasetType(), bean.getDatasetData())); + } + } catch (Exception e) { + throw new RuntimeException(e); + } finally { + TransmissionEncryptionManager.removeTransEncryptionLevel(); + } + return tableDataMap; + } + + /** + * 根据序列化数据生成tabledata + */ + public static TableData getTableDataSet(Map connectionMap, String type, String tableDataSetData) throws Exception { + if (DataSetProcessors.getProcessors().containsKey(type)) { + if (StringUtils.equals(SQLDataSetProcessor.TYPE, type)) { + return deserialize4SQL(connectionMap, null, new JSONObject(tableDataSetData)); + } else if (StringUtils.equals(StoreProcedureProcessor.TYPE, type)) { + return deserialize4Procedure(connectionMap, null, new JSONObject(tableDataSetData)); + } else { + UniversalServerTableDataProvider processor = DataSetProcessors.getProcessors().get(type); + return (TableData) processor.deserialize(null, new JSONObject(tableDataSetData)); + } + + } + return null; + } + + private static TableData deserialize4Procedure(Map connectionMap, DBTableData oldDataSet, JSONObject object) { + StoreProcedure storeProcedure = new StoreProcedure(); + StoreProcedureBean bean = object.mapTo(StoreProcedureBean.class); + storeProcedure.setShare(bean.isShare()); + storeProcedure.setMaxMemRowCount(bean.getMaxMemRowCount()); + storeProcedure.setQuery(bean.getQuery()); + if (StringUtils.isNotEmpty(bean.getDatabase())) { + Connection connection = connectionMap.get(bean.getDatabase()); + if (connection != null) { + storeProcedure.setDatabaseConnection(new NameDatabaseConnection(bean.getDatabase())); + } else { + FineLoggerFactory.getLogger().info("not find conn by {}", bean.getDatabase()); + } + } + Parameter[] parameters = new Parameter[bean.getParameters().size()]; + for (int i = 0; i < parameters.length; i++) { + ParameterBean parameterBean = bean.getParameters().get(i); + parameters[i] = (Parameter) ParameterTypeHandler.getInstance().parseParameter(parameterBean, new Parameter(parameterBean.getName())); + } + List externals = bean.getStoreProcedureParameterBeanList(); + StoreProcedureParameter[] procedureParameters = new StoreProcedureParameter[bean.getParameters().size()]; + for (int i = 0; i < procedureParameters.length; i++) { + StoreProcedureParameter storeProcedureParameter = new StoreProcedureParameter(); + storeProcedureParameter.setName(parameters[i].getName()); + storeProcedureParameter.setValue(parameters[i].getValue()); + storeProcedureParameter.setSchema(externals.get(i).getSchema()); + storeProcedureParameter.setType(externals.get(i).getTypeInt()); + procedureParameters[i] = storeProcedureParameter; + } + storeProcedure.setParameters(procedureParameters); + return storeProcedure; + } + + + /** + * 获取服务器数据集传输的bean + */ + public static ServerDataSetBean getServerDataSetBean(String name, TableData tableData) { + for (UniversalServerTableDataProvider processor : DataSetProcessors.getProcessors().values()) { + if (SQLDataSetProcessor.KEY.classForTableData() == tableData.getClass()) { + return serialize4SQL(name, tableData); + } else if (processor.classForTableData() == tableData.getClass()) { + ServerDataSetBean bean = new ServerDataSetBean(); + try { + bean.setDatasetData(processor.serialize(tableData).toString()); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + bean.setDatasetData(StringUtils.EMPTY); + } + bean.setDatasetName(name); + bean.setDatasetId(name); + bean.setDatasetType(processor.nameForTableData()); + return bean; + } + } + return new ServerDataSetBean(name); + } + + private static ServerDataSetBean serialize4SQL(String name, TableData tableData) { + ServerDataSetBean bean = new ServerDataSetBean(); + try { + bean.setDatasetData(serialize4SQL0((DBTableData) tableData).toString()); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + bean.setDatasetData(StringUtils.EMPTY); + } + bean.setDatasetName(name); + bean.setDatasetId(name); + bean.setDatasetType(SQLDataSetProcessor.KEY.nameForTableData()); + return bean; + } + + private static Object serialize4SQL0(DBTableData dataSet) { + SQLDataSetBean bean = new SQLDataSetBean(); + if (dataSet.getDatabase() instanceof NameDatabaseConnection) { + bean.setDatabase(((NameDatabaseConnection) dataSet.getDatabase()).getName()); + } + bean.setQuery(DataEncryptionHelper.encrypt(dataSet.getQuery())); + List parameterBeans = new ArrayList<>(); + ParameterProvider[] parameters = dataSet.getParameters(Calculator.createCalculator()); + for (ParameterProvider parameter : parameters) { + parameterBeans.add(new ParameterBean(parameter.getValue().getClass().getSimpleName(), parameter.getName(), GeneralUtils.objectToString(parameter.getValue()))); + } + bean.setParameters(parameterBeans); + return JSONObject.mapFrom(bean); + } + + + private static TableData deserialize4SQL(Map connectionMap, DBTableData oldDataSet, JSONObject object) { + DBTableData tableData = new DBTableData(); + SQLDataSetBean bean = object.mapTo(SQLDataSetBean.class); + tableData.setQuery(DataEncryptionHelper.decrypt(bean.getQuery())); + Connection connection = connectionMap.get(bean.getDatabase()); + if (connection != null) { + tableData.setDatabase(new NameDatabaseConnection(bean.getDatabase())); + } else { + FineLoggerFactory.getLogger().info("not find conn by {}", bean.getDatabase()); + } + String sql = SqlUtils.clearSqlComments(DataEncryptionHelper.decrypt(bean.getQuery())); + Parameter[] parameters = new Parameter[bean.getParameters().size()]; + for (int i = 0; i < parameters.length; i++) { + ParameterBean parameterBean = bean.getParameters().get(i); + parameters[i] = (Parameter) ParameterTypeHandler.getInstance().parseParameter(parameterBean, new Parameter(parameterBean.getName())); + } + tableData.setParameters(ParameterHelper.analyzeAndUnionSameParameters(new String[]{sql}, parameters)); + if (oldDataSet != null) { + tableData.setMaxMemRowCount(oldDataSet.getMaxMemRowCount()); + tableData.setPageQuerySql(oldDataSet.getPageQuerySql()); + tableData.setShare(oldDataSet.isShare()); + tableData.setDataQueryProcessor(oldDataSet.getDataQueryProcessor()); + } + return tableData; + } +} diff --git a/designer-base/src/main/java/com/fr/design/data/tabledata/LocalTableDataSource.java b/designer-base/src/main/java/com/fr/design/data/tabledata/LocalTableDataSource.java index 12a8a0c0ef..25acc3da90 100644 --- a/designer-base/src/main/java/com/fr/design/data/tabledata/LocalTableDataSource.java +++ b/designer-base/src/main/java/com/fr/design/data/tabledata/LocalTableDataSource.java @@ -1,13 +1,21 @@ package com.fr.design.data.tabledata; +import com.fanruan.config.impl.data.ConnectionConfigProviderFactory; import com.fanruan.config.impl.data.TableDataConfigProviderFactory; +import com.fr.base.TableData; import com.fr.decision.webservice.bean.dataset.FileDataSetBean; +import com.fr.decision.webservice.bean.dataset.ServerDataSetBean; import com.fr.decision.webservice.bean.entry.FileNodeBean; import com.fr.decision.webservice.v10.datasource.dataset.processor.impl.FileProcessor; +import com.fr.decision.webservice.v10.file.FileNodeService; +import com.fr.design.data.datapane.preview.TableDataBeanHelper; import com.fr.log.FineLoggerFactory; +import com.fr.stable.CommonUtils; import com.fr.stable.StringUtils; +import com.fr.stable.project.ProjectConstants; import com.fr.workspace.server.repository.tabledata.BaseTableDataSource; +import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Set; @@ -61,4 +69,39 @@ public class LocalTableDataSource extends BaseTableDataSource { return false; } } + + @Override + public List getCertificatesFile(String keyword) throws Exception { + String pPath = CommonUtils.pathJoin(ProjectConstants.RESOURCES_NAME, ProjectConstants.CERTIFICATES_DIRECTORY); + return FileNodeService.getInstance().getAllRecursiveFileNodes(pPath, ProjectConstants.RESOURCES_NAME, keyword); + } + + + @Override + public List getAllTableData() { + + List beans = new ArrayList<>(); + TableData[] tableDatas = TableDataConfigProviderFactory.getInstance().getTableDatas().values().toArray(new TableData[0]); + for (TableData data : tableDatas) { + beans.add(TableDataBeanHelper.getServerDataSetBean(data.getName(), data)); + } + return beans; + } + + + @Override + public void add(ServerDataSetBean bean) throws Exception { + TableDataConfigProviderFactory.getInstance().addTableData(bean.getDatasetName(), TableDataBeanHelper.getTableDataSet(ConnectionConfigProviderFactory.getConfigProvider().getConnections(), bean.getDatasetType(), bean.getDatasetData())); + } + + @Override + public void delete(ServerDataSetBean bean) throws Exception { + TableDataConfigProviderFactory.getInstance().removeTableData(bean.getDatasetName()); + } + + @Override + public void update(ServerDataSetBean bean) throws Exception { + TableDataConfigProviderFactory.getInstance().updateTableData(bean.getDatasetName(), TableDataBeanHelper.getTableDataSet(ConnectionConfigProviderFactory.getConfigProvider().getConnections(), bean.getDatasetType(), bean.getDatasetData())); + } + } diff --git a/designer-base/src/main/java/com/fr/design/data/tabledata/wrapper/ServerTableDataWrapper.java b/designer-base/src/main/java/com/fr/design/data/tabledata/wrapper/ServerTableDataWrapper.java index fb02f1a3f8..4a07d9ab91 100644 --- a/designer-base/src/main/java/com/fr/design/data/tabledata/wrapper/ServerTableDataWrapper.java +++ b/designer-base/src/main/java/com/fr/design/data/tabledata/wrapper/ServerTableDataWrapper.java @@ -6,6 +6,8 @@ import com.fr.base.svg.SVGLoader; import com.fr.data.impl.ClassTableData; import com.fr.data.impl.DBTableData; import com.fr.data.impl.EmbeddedTableData; +import com.fr.data.impl.FileTableData; +import com.fr.data.impl.MultiTDTableData; import com.fr.data.impl.RecursionTableData; import com.fr.data.impl.storeproc.StoreProcedure; import com.fr.design.icon.WarningIcon; @@ -25,13 +27,10 @@ public final class ServerTableDataWrapper extends AbstractTableDataWrapper { @Override public Icon getIcon() { if (tabledata instanceof DBTableData) { - if (StringUtils.isBlank(((DBTableData) tabledata).getQuery())) { - return new LazyIcon("server_database_warning"); - } - else { - return new LazyIcon("server_database"); - } - } else if (tabledata instanceof ClassTableData) { + return getDBTableDataIcon(); + } + + if (tabledata instanceof ClassTableData) { return new LazyIcon("class_table_data"); } else if (tabledata instanceof EmbeddedTableData) { return new LazyIcon("data_table"); @@ -39,10 +38,23 @@ public final class ServerTableDataWrapper extends AbstractTableDataWrapper { return new LazyIcon("tree"); } else if (tabledata instanceof StoreProcedure) { return new LazyIcon("store_procedure"); - } + } else if (tabledata instanceof FileTableData) { + return new LazyIcon("file"); + } else if (tabledata instanceof MultiTDTableData) { + return new LazyIcon("multi"); + } return new LazyIcon("server_database"); } + private Icon getDBTableDataIcon() { + if (StringUtils.isBlank(((DBTableData) tabledata).getQuery())) { + return new LazyIcon("server_database_warning"); + } + else { + return new LazyIcon("server_database"); + } + } + /** * 是否异常 * @return diff --git a/designer-base/src/main/java/com/fr/design/data/tabledata/wrapper/TableDataFactory.java b/designer-base/src/main/java/com/fr/design/data/tabledata/wrapper/TableDataFactory.java index 6d87a2c1bc..2b419f90a6 100644 --- a/designer-base/src/main/java/com/fr/design/data/tabledata/wrapper/TableDataFactory.java +++ b/designer-base/src/main/java/com/fr/design/data/tabledata/wrapper/TableDataFactory.java @@ -15,6 +15,7 @@ import com.fr.data.impl.storeproc.StoreProcedure; import com.fr.datacenters.tabledata.DCTableData; import com.fr.decision.webservice.bean.dataset.ServerDataSetBean; import com.fr.design.data.datapane.TableDataNameObjectCreator; +import com.fr.design.data.datapane.preview.ConnectionInfoBeanHelper; import com.fr.design.data.tabledata.datacenter.DCTableDataPane; import com.fr.design.data.tabledata.tabledatapane.AbstractTableDataPane; import com.fr.design.data.tabledata.tabledatapane.ClassTableDataPane; @@ -29,9 +30,8 @@ import com.fr.general.ComparatorUtils; import com.fr.log.FineLoggerFactory; import com.fr.stable.ArrayUtils; import com.fr.stable.StringUtils; -import com.fr.workspace.server.entity.connection.ConnectionBean; import com.fr.workspace.server.repository.connection.ConnectionRepository; -import com.fr.workspace.server.repository.tabledata.TableDataBeanHelper; +import com.fr.design.data.datapane.preview.TableDataBeanHelper; import com.fr.workspace.server.repository.tabledata.TableDataRepository; import javax.swing.Icon; @@ -205,11 +205,7 @@ public abstract class TableDataFactory { clearAll(); try { List beans = TableDataRepository.getInstance().getAllTableData(); - final List connectionInfoBeans = ConnectionRepository.getInstance().getAll(); - final Map connectionMap = new HashMap<>(); - for (ConnectionBean bean : connectionInfoBeans) { - connectionMap.put(bean.getName(), bean.getConnection()); - } + final Map connectionMap = ConnectionInfoBeanHelper.createConnectionMap(ConnectionRepository.getInstance().getAll()); Map tableDataMap = new HashMap<>(); for (ServerDataSetBean bean : beans) { tableDataMap.put(bean.getDatasetName(), TableDataBeanHelper.getTableDataSet(connectionMap, bean.getDatasetType(), bean.getDatasetData())); @@ -233,11 +229,7 @@ public abstract class TableDataFactory { Map tableDataMap = new HashMap<>(); try { List beans = TableDataRepository.getInstance().getAllTableData(); - final List connectionInfoBeans = ConnectionRepository.getInstance().getAll(); - final Map connectionMap = new HashMap<>(); - for (ConnectionBean bean : connectionInfoBeans) { - connectionMap.put(bean.getName(), bean.getConnection()); - } + final Map connectionMap = ConnectionInfoBeanHelper.createConnectionMap(ConnectionRepository.getInstance().getAll()); for (ServerDataSetBean bean : beans) { tableDataMap.put(bean.getDatasetName(), TableDataBeanHelper.getTableDataSet(connectionMap, bean.getDatasetType(), bean.getDatasetData())); } diff --git a/designer-base/src/main/java/com/fr/design/gui/controlpane/JListControlPane.java b/designer-base/src/main/java/com/fr/design/gui/controlpane/JListControlPane.java index 7a1094ab17..a4b80242a9 100644 --- a/designer-base/src/main/java/com/fr/design/gui/controlpane/JListControlPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/controlpane/JListControlPane.java @@ -30,6 +30,7 @@ import javax.swing.JPopupMenu; import javax.swing.ListCellRenderer; import javax.swing.ListSelectionModel; import javax.swing.SwingUtilities; +import javax.swing.UIManager; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; import java.awt.BorderLayout; @@ -381,7 +382,7 @@ public abstract class JListControlPane extends JControlPane implements ListContr @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { - setPreferredSize(new Dimension(list.getWidth(), FineUIScale.scale(24))); + setPreferredSize(new Dimension(list.getWidth(), FineUIScale.scale(UIManager.getInt("List.cellRender.height")))); if (value instanceof ListModelElement) { ListModelElement element = ((ListModelElement) value); Nameable nameable = element.wrapper; diff --git a/designer-base/src/main/java/com/fr/design/gui/date/UIDayLabel.java b/designer-base/src/main/java/com/fr/design/gui/date/UIDayLabel.java index c4c8afc1d1..f7accce9e9 100644 --- a/designer-base/src/main/java/com/fr/design/gui/date/UIDayLabel.java +++ b/designer-base/src/main/java/com/fr/design/gui/date/UIDayLabel.java @@ -29,7 +29,7 @@ public class UIDayLabel extends UILabel { public UIDayLabel(Date date, boolean isSmallLabel) { setHorizontalAlignment(UILabel.CENTER); - setFont(DesignUtils.getDefaultGUIFont()); + setFont(DesignUtils.getDefaultGUIFont().applySize(scale(12))); this.date = date; setPreferredSize(scale(new Dimension(30, 18))); if (isSmallLabel) { diff --git a/designer-base/src/main/java/com/fr/design/gui/ilist/JNameEdList.java b/designer-base/src/main/java/com/fr/design/gui/ilist/JNameEdList.java index 4c9135e151..7029fac1f8 100644 --- a/designer-base/src/main/java/com/fr/design/gui/ilist/JNameEdList.java +++ b/designer-base/src/main/java/com/fr/design/gui/ilist/JNameEdList.java @@ -22,10 +22,10 @@ import java.util.Vector; public class JNameEdList extends UIList implements CellEditorListener { /** - * 原值为20,设计器图标由png替换为svg之后JNameEdList的icon大小为16x16 + * 原值为20,设计器图标由png替换为svg之后JNameEdList的icon大小为24x24 * 重命名是会出现左侧一部分带有背景色的渲染 */ - private static final int ICON_WIDTH = 16; + private static final int ICON_WIDTH = 24; private boolean editable = true; // kunsnat: 是否强制ListName是数字 (int型) @@ -240,7 +240,7 @@ public class JNameEdList extends UIList implements CellEditorListener { return false; } Rectangle rect = this.getCellBounds(index, index); - // alex:所有的JNameEdList都有Icon,空出前面20 * 20的位置就是放的Icon + // alex:所有的JNameEdList都有Icon,空出前面24 * 24的位置就是放的Icon rect.setRect(createRect(rect, getIconWidth())); editorComp.setBounds(rect); diff --git a/designer-base/src/main/java/com/fr/design/gui/itree/filetree/EnvFileTree.java b/designer-base/src/main/java/com/fr/design/gui/itree/filetree/EnvFileTree.java index 0d11eb491f..1a14821d00 100644 --- a/designer-base/src/main/java/com/fr/design/gui/itree/filetree/EnvFileTree.java +++ b/designer-base/src/main/java/com/fr/design/gui/itree/filetree/EnvFileTree.java @@ -77,7 +77,7 @@ public class EnvFileTree extends RefreshableJTree { } this.setIcon(FileTreeIcon.getIconWithExpandAttr(node, expanded)); } else { - this.setIcon(FileTreeIcon.getFolderHalfImageIcon()); + this.setIcon(FileTreeIcon.getFolderHalfImageIcon(expanded)); } this.setText(name); } else if (userObj == PENDING) { diff --git a/designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileTreeIcon.java b/designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileTreeIcon.java index ca26e435aa..92de91aa1e 100644 --- a/designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileTreeIcon.java +++ b/designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileTreeIcon.java @@ -49,9 +49,10 @@ public class FileTreeIcon { public static final Icon FRM_FILE_LOCK_ICON = new LazyIcon("frm_locked"); public static final Icon FVS_FILE_LOCK_ICON = new LazyIcon("fvs_locked"); - // TODO: 以下Icon视觉暂未提供,需提供后替换 + public static final Icon FOLDER_HALF_IMAGE_ICON = new LazyIcon("folder_half_authority"); + public static final Icon FOLDER_HALF_IMAGE_ICON_OPEN = new LazyIcon("folder_half_authority_open"); + public static final Icon BLANK_IMAGE_ICON = BaseUtils.readIcon("/com/fr/design/images/gui/blank.gif"); - public static final Icon FOLDER_HALF_IMAGE_ICON = IconUtils.readIcon("/com/fr/design/standard/fileicon/folder_half_authority.svg"); public static final Icon CPTX_LOCKED_ICON = IconUtils.readIcon("/com/fr/design/standard/fileicon/cptx_icon_locked.svg"); public static final LockIcon FOLDER_LOCK_ICON = @@ -130,7 +131,17 @@ public class FileTreeIcon { } public static Icon getFolderHalfImageIcon() { - return FOLDER_HALF_IMAGE_ICON; + return getFolderHalfImageIcon(false); + } + + /** + * 获取文件夹有部分权限时的图标 + * + * @param isExpand 文件夹是否已打开 + * @return 图标 + */ + public static Icon getFolderHalfImageIcon(boolean isExpand) { + return isExpand ? FOLDER_HALF_IMAGE_ICON_OPEN : FOLDER_HALF_IMAGE_ICON; } /** diff --git a/designer-base/src/main/java/com/fr/design/i18n/DesignSizeI18nManager.java b/designer-base/src/main/java/com/fr/design/i18n/DesignSizeI18nManager.java index 1dd2306b89..8b0e8739cf 100644 --- a/designer-base/src/main/java/com/fr/design/i18n/DesignSizeI18nManager.java +++ b/designer-base/src/main/java/com/fr/design/i18n/DesignSizeI18nManager.java @@ -1,5 +1,6 @@ package com.fr.design.i18n; +import com.fine.theme.utils.FineUIScale; import com.fr.design.dialog.BasicDialog; import com.fr.general.GeneralContext; import com.fr.locale.LocaleManager; @@ -52,6 +53,6 @@ public class DesignSizeI18nManager { if (arr.length < SPLIT_LENGTH) { return BasicDialog.DEFAULT; } - return new Dimension(Integer.parseInt(arr[WIDTH_INDEX]), Integer.parseInt(arr[HEIGHT_INDEX])); + return FineUIScale.scale(new Dimension(Integer.parseInt(arr[WIDTH_INDEX]), Integer.parseInt(arr[HEIGHT_INDEX]))); } } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java index a4239bc64c..1417bd548a 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java @@ -107,6 +107,8 @@ import java.util.Set; import java.util.UUID; import java.util.concurrent.CopyOnWriteArrayList; +import static com.fine.theme.utils.FineUIScale.scale; + public class DesignerFrame extends JFrame implements JTemplateActionListener, TargetModifiedListener { private static final String DESIGNER_FRAME_NAME = "designer_frame"; @@ -115,7 +117,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta private static final long serialVersionUID = -8732559571067484460L; - private static final int MENU_HEIGHT = 26; + private static final int MENU_HEIGHT = scale(26); private static final Integer SECOND_LAYER = 100; @@ -578,8 +580,8 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta closeButton.setBorder(null); int x = contentWidth - EastRegionContainerPane.getInstance().getContainerWidth() - closeMode.getIconWidth() / 2; int y = MENU_HEIGHT - closeMode.getIconHeight() / 2; - closeButton.setBounds(x, y, UIConstants.CLOSE_AUTHORITY_HEIGHT_AND_WIDTH, - UIConstants.CLOSE_AUTHORITY_HEIGHT_AND_WIDTH); + closeButton.setBounds(x, y, scale(UIConstants.CLOSE_AUTHORITY_HEIGHT_AND_WIDTH), + scale(UIConstants.CLOSE_AUTHORITY_HEIGHT_AND_WIDTH)); } /** diff --git a/designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/GradientBackgroundQuickPane.java b/designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/GradientBackgroundQuickPane.java index 176cd9b8c5..9751200c05 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/GradientBackgroundQuickPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/GradientBackgroundQuickPane.java @@ -91,7 +91,6 @@ public class GradientBackgroundQuickPane extends BackgroundQuickPane { */ @Override public void registerChangeListener(final UIObserverListener listener) { - gradientBar.addChangeListener(new ChangeListenerImpl(listener)); directionPane.addChangeListener(new ChangeListenerImpl(listener)); } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/check/CheckButton.java b/designer-base/src/main/java/com/fr/design/mainframe/check/CheckButton.java index dc502dcdf4..09170352fd 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/check/CheckButton.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/check/CheckButton.java @@ -1,6 +1,7 @@ package com.fr.design.mainframe.check; import com.fine.theme.icon.LazyIcon; +import com.formdev.flatlaf.util.ScaledEmptyBorder; import com.fr.base.BaseUtils; import com.fr.design.dialog.FineJOptionPane; import com.fr.design.gui.ibutton.UIButton; @@ -24,7 +25,7 @@ import javax.swing.JDialog; import javax.swing.JPanel; import javax.swing.SwingUtilities; import javax.swing.SwingWorker; -import java.awt.FlowLayout; +import java.awt.BorderLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.WindowAdapter; @@ -32,6 +33,10 @@ import java.awt.event.WindowEvent; import java.util.Set; import java.util.concurrent.ExecutionException; +import static com.fine.swing.ui.layout.Layouts.cell; +import static com.fine.swing.ui.layout.Layouts.column; +import static com.fine.swing.ui.layout.Layouts.flex; +import static com.fine.swing.ui.layout.Layouts.row; import static com.fr.design.dialog.FineJOptionPane.showConfirmDialog; import static javax.swing.JOptionPane.OK_CANCEL_OPTION; import static javax.swing.JOptionPane.OK_OPTION; @@ -73,7 +78,7 @@ public class CheckButton extends UIButton { } if (set.isEmpty()) { okButton.setEnabled(true); - imageLabel.setIcon(BaseUtils.readIcon("com/fr/design/images/correct.png")); + imageLabel.setIcon(new LazyIcon("success", 20)); message.setText("" + Toolkit.i18nText("Fine_Designer_Check_Font_Success") + ""); } else { if (dialog != null) { @@ -172,7 +177,7 @@ public class CheckButton extends UIButton { @Override public Void callHandler(RPCInvokerExceptionInfo rpcInvokerExceptionInfo) { - imageLabel.setIcon(BaseUtils.readIcon("com/fr/design/images/error.png")); + imageLabel.setIcon(new LazyIcon("error", 20)); message.setText("" + Toolkit.i18nText("Fine_Designer_Check_Font_Upgrade") + ""); okButton.setEnabled(true); return null; @@ -198,16 +203,16 @@ public class CheckButton extends UIButton { dialog.setSize(DesignSizeI18nManager.getInstance().i18nDimension(this.getClass().getName())); JPanel jp = new JPanel(); JPanel upPane = new JPanel(); - JPanel downPane = new JPanel(); - imageLabel = new UILabel(IOUtils.readIcon("com/fr/design/images/waiting.png")); - upPane.setLayout(new FlowLayout(FlowLayout.LEFT, 10, 10)); - upPane.add(imageLabel); - upPane.add(message); - downPane.setLayout(new FlowLayout(FlowLayout.CENTER, 6, 0)); - downPane.add(okButton); - jp.setLayout(new BoxLayout(jp, BoxLayout.Y_AXIS)); - jp.add(upPane); - jp.add(downPane); + JPanel downPane = new JPanel(new BorderLayout()); + imageLabel = new UILabel(new LazyIcon("waiting", 20)); + upPane.add(row(10, + column(cell(imageLabel),flex()), cell(message) + ).getComponent()); + downPane.add(okButton, BorderLayout.EAST); + jp.setLayout(new BorderLayout()); + jp.add(column(flex(), cell(upPane), flex()).getComponent()); + jp.add(downPane, BorderLayout.SOUTH); + jp.setBorder(new ScaledEmptyBorder(10, 10, 10,10)); dialog.add(jp); dialog.setResizable(false); dialog.setLocationRelativeTo(SwingUtilities.getWindowAncestor(this)); diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/CellStyleListEditPane.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/CellStyleListEditPane.java index 5e569afbf5..c50e15d29c 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/CellStyleListEditPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/CellStyleListEditPane.java @@ -46,6 +46,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import static com.fine.theme.utils.FineUIScale.scale; import static com.fr.design.i18n.Toolkit.i18nText; /** @@ -127,8 +128,8 @@ public class CellStyleListEditPane extends JListControlPane { this.setCreators(this.createNameableCreators()); initCardPane(); JPanel leftPane = getLeftPane(); - leftPane.setPreferredSize(new Dimension(90, 0)); - cardPane.setPreferredSize(new Dimension(270, 0)); + leftPane.setPreferredSize(new Dimension(scale(90), super.getPreferredSize().height)); + cardPane.setPreferredSize(new Dimension(scale(270), super.getPreferredSize().height)); JPanel mainSplitPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); mainSplitPane.add(leftPane, BorderLayout.WEST); mainSplitPane.add(cardPane, BorderLayout.CENTER); @@ -292,7 +293,7 @@ public class CellStyleListEditPane extends JListControlPane { Component component = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); if (component instanceof NameableListCellRenderer) { ((NameableListCellRenderer) component).setIcon(null); - ((NameableListCellRenderer) component).setBorder(BorderFactory.createEmptyBorder(0, 4, 0, 0)); + ((NameableListCellRenderer) component).setBorder(new ScaledEmptyBorder(0, 4, 0, 0)); } return component; } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/cell/CellStyleEditPane.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/cell/CellStyleEditPane.java index 9865321987..84213f6c32 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/cell/CellStyleEditPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/cell/CellStyleEditPane.java @@ -1,5 +1,6 @@ package com.fr.design.mainframe.theme.edit.cell; +import com.formdev.flatlaf.util.ScaledEmptyBorder; import com.fr.base.CellBorderStyle; import com.fr.base.Style; import com.fr.base.theme.settings.ThemedCellStyle; @@ -24,6 +25,7 @@ import java.awt.Dimension; import java.util.ArrayList; import java.util.List; +import static com.fine.theme.utils.FineUIScale.scale; import static com.fr.design.i18n.Toolkit.i18nText; @@ -129,14 +131,14 @@ public class CellStyleEditPane extends MultiTabPane { @Override protected void initLayout() { this.setLayout(new BorderLayout(0, 10)); - this.setBorder(BorderFactory.createEmptyBorder(0, 4, 0, 4)); + this.setBorder(new ScaledEmptyBorder(0, 4, 0, 4)); JPanel previewPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); previewArea = new CellRectangleStylePreviewPane(true); - previewArea.setPreferredSize(new Dimension(207, 48)); + previewArea.setPreferredSize(scale(new Dimension(207, 48))); previewPane.setBorder(BorderFactory.createCompoundBorder( BorderUtils.createTitleBorder(i18nText("Fine-Design_Basic_Preview")), - BorderFactory.createEmptyBorder(4, 4, 4, 4))); + new ScaledEmptyBorder(4, 4, 4, 4))); previewPane.add(previewArea, BorderLayout.NORTH); this.add(previewPane, BorderLayout.NORTH); diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/chart/AbstractChartStylePane.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/chart/AbstractChartStylePane.java index 547b5c1d25..9625edb642 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/chart/AbstractChartStylePane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/chart/AbstractChartStylePane.java @@ -1,5 +1,6 @@ package com.fr.design.mainframe.theme.edit.chart; +import com.fine.theme.utils.FineLayoutBuilder; import com.fine.theme.utils.FineUIScale; import com.formdev.flatlaf.util.ScaledEmptyBorder; import com.fr.base.theme.settings.ThemedChartStyle; @@ -31,11 +32,8 @@ public abstract class AbstractChartStylePane extends BasicPane { protected void initPane() { this.setLayout(FRGUIPaneFactory.createBorderLayout()); - double labelWidth = 90; - double totalWidth = 190; - double p = TableLayout.PREFERRED; - double[] columnSize = {labelWidth, totalWidth}; - JPanel gapTableLayoutPane = TableLayoutHelper.createGapTableLayoutPane(getComponent(), getRows(p), columnSize, 5, LayoutConstants.VGAP_LARGE); + + JPanel gapTableLayoutPane = FineLayoutBuilder.compatibleTableLayout(10, getComponent(), new double[]{1.2, 3}); gapTableLayoutPane.setBorder(new ScaledEmptyBorder(0, 10, 0, 0)); UIScrollPane rightTopPane = new UIScrollPane(gapTableLayoutPane); rightTopPane.setBorder(BorderFactory.createEmptyBorder()); diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/chart/ChartFontPane.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/chart/ChartFontPane.java index 150bbe24e0..f6124fd4ba 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/chart/ChartFontPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/chart/ChartFontPane.java @@ -1,6 +1,8 @@ package com.fr.design.mainframe.theme.edit.chart; import com.fine.theme.icon.LazyIcon; +import com.fine.theme.utils.FineLayoutBuilder; +import com.fine.theme.utils.FineUIUtils; import com.fr.base.FRContext; import com.fr.design.constants.LayoutConstants; import com.fr.design.dialog.BasicPane; @@ -9,6 +11,7 @@ import com.fr.design.gui.ibutton.UIColorButton; import com.fr.design.gui.ibutton.UIToggleButton; import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.itable.FineUITable; import com.fr.design.i18n.Toolkit; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; @@ -24,6 +27,9 @@ import java.awt.Component; import java.awt.FlowLayout; import java.awt.Font; +import static com.fine.swing.ui.layout.Layouts.cell; +import static com.fine.swing.ui.layout.Layouts.row; + /** * @author Bjorn * @version 10.0 @@ -67,8 +73,8 @@ public class ChartFontPane extends BasicPane { Component[] components = new Component[]{ fontSizeComboBox, fontColor, italic, bold }; - JPanel buttonPane = new JPanel(); - buttonPane.add(GUICoreUtils.createFlowPane(components, FlowLayout.LEFT, LayoutConstants.HGAP_LARGE)); + JPanel buttonPane = new JPanel(new BorderLayout()); + buttonPane.add(row(4, cell(fontSizeComboBox), cell(fontColor), cell(italic), cell(bold)).getComponent()); this.setLayout(new BorderLayout()); this.add(getContentPane(buttonPane), BorderLayout.CENTER); @@ -77,11 +83,7 @@ public class ChartFontPane extends BasicPane { } protected JPanel getContentPane(JPanel buttonPane) { - double labelWidth = 90; - double totalWidth = 190; - double p = TableLayout.PREFERRED; - double[] rows = {p, p, p}; - double[] columnSize = {labelWidth, totalWidth}; + UILabel text = new UILabel(getUILabelText(), SwingConstants.LEFT); text.setToolTipText(getUILabelText()); Component[][] components = { @@ -90,7 +92,7 @@ public class ChartFontPane extends BasicPane { new Component[]{null, buttonPane} }; - return TableLayoutHelper.createGapTableLayoutPane(components, rows, columnSize, 5, 10); + return FineLayoutBuilder.compatibleTableLayout(10, components, new double[]{1.2, 3}); } public String getUILabelText() { diff --git a/designer-base/src/main/java/com/fr/design/present/dict/DatabaseDictPane.java b/designer-base/src/main/java/com/fr/design/present/dict/DatabaseDictPane.java index 5c157a7cd9..2c1f46a4a1 100644 --- a/designer-base/src/main/java/com/fr/design/present/dict/DatabaseDictPane.java +++ b/designer-base/src/main/java/com/fr/design/present/dict/DatabaseDictPane.java @@ -6,6 +6,7 @@ import com.fr.base.TableData; import com.fr.data.core.DataCoreUtils; import com.fr.data.core.db.DBUtils; import com.fr.data.core.db.dialect.Dialect; +import com.fr.data.impl.Connection; import com.fr.data.impl.DatabaseDictionary; import com.fr.data.impl.NameDatabaseConnection; import com.fr.design.beans.FurtherBasicBeanPane; @@ -25,6 +26,7 @@ import com.fr.design.event.UIObserverListener; import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.ilable.UILabel; import com.fr.stable.StringUtils; +import com.fr.workspace.server.repository.connection.ConnectionRepository; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; @@ -176,8 +178,9 @@ public class DatabaseDictPane extends FurtherBasicBeanPane i if (StringUtils.isBlank(para.getDatabaseName())) { dbDict.setDatabaseConnection(null); } else { - database = DBUtils.checkDBConnection(para.getDatabaseName()); - if (database != null) { + Connection connection = ConnectionRepository.getInstance().getByName(para.getDatabaseName()).getConnection(); + if (connection != null) { + database = new NameDatabaseConnection(para.getDatabaseName()); dbDict.setDatabaseConnection(database); } } diff --git a/designer-base/src/main/java/com/fr/file/FILEChooserPane.java b/designer-base/src/main/java/com/fr/file/FILEChooserPane.java index 9d21751c28..2cf1016c48 100644 --- a/designer-base/src/main/java/com/fr/file/FILEChooserPane.java +++ b/designer-base/src/main/java/com/fr/file/FILEChooserPane.java @@ -252,6 +252,21 @@ public class FILEChooserPane extends BasicPane { return chooserPane; } + /** + * 获取CA证书的文件选择面板 + */ + public static FILEChooserPane getFileCAChoosePane(FILEFilter filter) { + FILEChooserPane chooserPane = new FILEChooserPane(); + chooserPane.showEnv = true; + chooserPane.showLoc = false; + chooserPane.showWebReport = false; + // 替换掉 PlaceListModel + chooserPane.setFileCAPlaceListModel(); + chooserPane.removeAllFilter(); + chooserPane.addChooseFILEFilter(filter, 0); + return chooserPane; + } + /** * @param showEnv @@ -1128,6 +1143,13 @@ public class FILEChooserPane extends BasicPane { setPlaceListModel(new FileDataPlaceListModel(type)); } + protected void setFileCAPlaceListModel() { + if (placesList == null) { + return; + } + setPlaceListModel(new FileCAPlaceListModel()); + } + /* * 选中文件 */ @@ -1362,6 +1384,7 @@ public class FILEChooserPane extends BasicPane { private class FileDataPlaceListModel extends AbstractPlaceListModel { private FileDataFILE envFILE; + private String type; FileDataPlaceListModel(String type) { envFILE = new FileDataFILE(new FileNode(StableUtils.pathJoin(ProjectConstants.ASSETS_NAME, FileDataFILE.FILE_DATASET_NAME), true), false, StableUtils.pathJoin(ProjectConstants.ASSETS_NAME, FileDataFILE.FILE_DATASET_NAME)) { @@ -1371,6 +1394,45 @@ public class FILEChooserPane extends BasicPane { } }; envFILE.setType(type); + FileDataPlaceListModel.this.setType(type); + } + + @Override + public FILE getElementAt(int index) { + return envFILE; + } + + @Override + public int getSize() { + return 1 + filesOfSystem.size(); + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + @Override + protected void setCD(FILE lastDirectory) { + super.setCD(lastDirectory); + if (lastDirectory instanceof FileDataFILE) { + ((FileDataFILE)lastDirectory).setType(type); + } + } + } + + private class FileCAPlaceListModel extends AbstractPlaceListModel { + private FileCAFILE envFILE; + FileCAPlaceListModel() { + envFILE = new FileCAFILE(new FileNode(StableUtils.pathJoin(ProjectConstants.RESOURCES_NAME, ProjectConstants.CERTIFICATES_DIRECTORY), true), false, StableUtils.pathJoin(ProjectConstants.RESOURCES_NAME, ProjectConstants.CERTIFICATES_DIRECTORY)) { + @Override + public String getName() { + return getEnvProjectName(); + } + }; } @Override @@ -1385,6 +1447,7 @@ public class FILEChooserPane extends BasicPane { } + private class MultiLocalEnvPlaceListModel extends AbstractPlaceListModel { private static final long serialVersionUID = 6300018896958532154L; @@ -1596,7 +1659,7 @@ public class FILEChooserPane extends BasicPane { this.buttonList.add(createBlankButton((new SetDirectoryAction(btn_text + '/', // alex:dir.prefix不和btn_path一起参与pathJoin,因为btn_path是否以/打头在unix,linux // OS中意义很不一样 - FILEFactory.createFolder(dir.prefix() + StableUtils.pathJoin(btn_path, "/")), !needTopPath)))); + FILEFactory.createFolder(dir, dir.prefix() + StableUtils.pathJoin(btn_path, "/")), !needTopPath)))); } maxPathIndex = calculateMaxPathIndex(); diff --git a/designer-base/src/main/java/com/fr/file/FILEFactory.java b/designer-base/src/main/java/com/fr/file/FILEFactory.java index 4d5fe6548d..3e7113f35a 100644 --- a/designer-base/src/main/java/com/fr/file/FILEFactory.java +++ b/designer-base/src/main/java/com/fr/file/FILEFactory.java @@ -9,6 +9,7 @@ public class FILEFactory { public static final String FILE_PREFIX = "file://"; public static final String ENV_PREFIX = "env://"; public static final String FILE_DATA_PREFIX = "filedata://"; + public static final String FILE_CA_PREFIX = "ca://"; public static final String WEBREPORT_PREFIX = "webreport://"; public static final String SEPARATOR = "/"; @@ -38,12 +39,22 @@ public class FILEFactory { return new FileFILE(new java.io.File(path.substring(FILE_PREFIX.length()))); } else if (path.startsWith(FILE_DATA_PREFIX)) { return new FileDataFILE(new FileNode(path.substring(FILE_DATA_PREFIX.length()), false), false, path.substring(FILE_DATA_PREFIX.length())); + } else if (path.startsWith(FILE_CA_PREFIX)) { + return new FileCAFILE(new FileNode(path.substring(FILE_CA_PREFIX.length()), false), false, path.substring(FILE_CA_PREFIX.length())); } else { return new FileNodeFILE(new FileNode(path, WorkContext.getWorkResource().isDirectory(path))); } } public static FILE createFolder(String path) { + return createFolder(null, path); + } + + + /** + * 传递依据的基础文件并创建文件夹 + */ + public static FILE createFolder(FILE origin, String path) { if (path == null) { return null; } else if (path.startsWith(MEM_PREFIX)) { @@ -57,8 +68,15 @@ public class FILEFactory { } else if (path.startsWith(FILE_PREFIX)) { return new FileFILE(new java.io.File(path.substring(FILE_PREFIX.length()))); } else if (path.startsWith(FILE_DATA_PREFIX)) { - return new FileDataFILE(new FileNode(path.substring(FILE_DATA_PREFIX.length()), true), false, path.substring(FILE_DATA_PREFIX.length())); - } else { + FileDataFILE file = new FileDataFILE(new FileNode(path.substring(FILE_DATA_PREFIX.length()), true), false, path.substring(FILE_DATA_PREFIX.length())); + if (origin instanceof FileDataFILE) { + file.setType(((FileDataFILE) origin).getType()); + } + return file; + } else if (path.startsWith(FILE_CA_PREFIX)) { + return new FileCAFILE(new FileNode(path.substring(FILE_CA_PREFIX.length()), true), false, path.substring(FILE_CA_PREFIX.length())); + } + else { return new FileNodeFILE(new FileNode(path, WorkContext.getWorkResource().isDirectory(path))); } } diff --git a/designer-base/src/main/java/com/fr/file/FileCAFILE.java b/designer-base/src/main/java/com/fr/file/FileCAFILE.java new file mode 100644 index 0000000000..2ecf3c39b0 --- /dev/null +++ b/designer-base/src/main/java/com/fr/file/FileCAFILE.java @@ -0,0 +1,167 @@ +package com.fr.file; + +import com.fr.decision.webservice.bean.entry.FileNodeBean; +import com.fr.file.filetree.FileNode; +import com.fr.general.ComparatorUtils; +import com.fr.log.FineLoggerFactory; +import com.fr.stable.CoreConstants; +import com.fr.stable.StableUtils; +import com.fr.stable.StringUtils; +import com.fr.stable.project.ProjectConstants; +import com.fr.workspace.server.repository.tabledata.TableDataRepository; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * CA证书文件相关 + * + * @author Destiny.Lin + * @since 11.0 + * Created on 2024/9/8 + */ +public class FileCAFILE extends FileNodeFILE{ + public static final String ROOT = ProjectConstants.CERTIFICATES_DIRECTORY; + private List children = new ArrayList<>(); + private boolean builded = false; + private String id = StringUtils.EMPTY; + + public FileCAFILE(FileNode node) { + super(node); + } + + public FileCAFILE(FileNode node, boolean builded, String id) { + super(node); + this.builded = builded; + this.id = id; + } + + /** + * 添加子 + */ + private void addChild(FileCAFILE file) { + children.add(file); + } + + public List getChildren() { + return children; + } + + public void setChildren(List children) { + this.children = children; + } + + public boolean isBuilded() { + return builded; + } + + public void setBuilded(boolean builded) { + this.builded = builded; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + @Override + public FILE[] listFiles() { + + if (ComparatorUtils.equals(node, null)) { + node = new FileNode(CoreConstants.SEPARATOR, true); + } + if (!node.isDirectory()) { + return new FILE[]{this}; + } + try { + FileCAFILE root = null; + if (!this.builded) { + root = buildTree(); + FileCAFILE dataFILE = root.getFileCAFILE(this.id); + this.setChildren(dataFILE.getChildren()); + this.builded = true; + } + return this.getChildren().toArray(new FILE[0]); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + return new FILE[0]; + } + } + + private List getBeans() { + try { + return TableDataRepository.getInstance().getCertificatesFile(StringUtils.EMPTY); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + /** + * 递归获取指定id的文件 + */ + public FileCAFILE getFileCAFILE(String id) { + if (StringUtils.equals(this.id, id) || StringUtils.equals(StableUtils.pathJoin(this.id, StringUtils.EMPTY), id)) { + return this; + } + for (FileCAFILE file : getChildren()) { + return file.getFileCAFILE(id); + } + return null; + } + + private FileCAFILE buildTree() { + List beans = getBeans(); + Map tree = new HashMap<>(); + FileCAFILE root = null; + // id , 父 + for (FileNodeBean bean : beans) { + FileNode fileNode = new FileNode(); + fileNode.setEnvPath(bean.getPath()); + fileNode.setDirectory(bean.getIsParent()); + tree.putIfAbsent(bean.getId(), new FileCAFILE(fileNode, true, bean.getId())); + if (StringUtils.isEmpty(bean.getpId())) { + root = tree.get(bean.getId()); + } else { + tree.putIfAbsent(bean.getpId(), createParent(bean.getpId(), beans)); + FileCAFILE file = tree.get(bean.getpId()); + if (file != null) { + file.addChild(tree.get(bean.getId())); + } + } + } + for (Map.Entry entry : tree.entrySet()) { + if (entry.getKey().endsWith(ROOT)) { + root = entry.getValue(); + root.setId(StableUtils.pathJoin(ProjectConstants.RESOURCES_NAME, ProjectConstants.CERTIFICATES_DIRECTORY)); + break; + } + } + return root; + } + + private FileCAFILE createParent(String s, List beans) { + for (FileNodeBean bean : beans) { + if (StringUtils.equals(bean.getId(), s)) { + FileNode fileNode = new FileNode(); + fileNode.setEnvPath(bean.getPath()); + fileNode.setDirectory(bean.getIsParent()); + return new FileCAFILE(fileNode, true, bean.getId()); + } + } + FileNode fileNode = new FileNode(); + fileNode.setEnvPath(s); + fileNode.setDirectory(true); + return new FileCAFILE(fileNode, true, ROOT); + } + + @Override + public String prefix() { + return FILEFactory.FILE_CA_PREFIX; + } + +} diff --git a/designer-base/src/main/java/com/fr/file/FileDataFILE.java b/designer-base/src/main/java/com/fr/file/FileDataFILE.java index 434faeee03..11fba58b6a 100644 --- a/designer-base/src/main/java/com/fr/file/FileDataFILE.java +++ b/designer-base/src/main/java/com/fr/file/FileDataFILE.java @@ -42,6 +42,13 @@ public class FileDataFILE extends FileNodeFILE{ this.id = id; } + public FileDataFILE(FileNode node, boolean builded, String id, String type) { + super(node); + this.builded = builded; + this.id = id; + this.type = type; + } + private void addChild(FileDataFILE file) { children.add(file); } @@ -127,7 +134,7 @@ public class FileDataFILE extends FileNodeFILE{ FileNode fileNode = new FileNode(); fileNode.setEnvPath(bean.getPath()); fileNode.setDirectory(bean.getIsParent()); - tree.putIfAbsent(bean.getId(), new FileDataFILE(fileNode, true, bean.getId())); + tree.putIfAbsent(bean.getId(), new FileDataFILE(fileNode, true, bean.getId(), type)); if (StringUtils.isEmpty(bean.getpId())) { root = tree.get(bean.getId()); } else { @@ -147,7 +154,7 @@ public class FileDataFILE extends FileNodeFILE{ FileNode fileNode = new FileNode(); fileNode.setEnvPath(bean.getPath()); fileNode.setDirectory(bean.getIsParent()); - return new FileDataFILE(fileNode, true, bean.getId()); + return new FileDataFILE(fileNode, true, bean.getId(), type); } } return null; diff --git a/designer-base/src/main/resources/com/fine/theme/icon/filetree/folder_half_authority.svg b/designer-base/src/main/resources/com/fine/theme/icon/filetree/folder_half_authority.svg new file mode 100644 index 0000000000..438cd6c89b --- /dev/null +++ b/designer-base/src/main/resources/com/fine/theme/icon/filetree/folder_half_authority.svg @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/designer-base/src/main/resources/com/fine/theme/icon/filetree/folder_half_authority_open.svg b/designer-base/src/main/resources/com/fine/theme/icon/filetree/folder_half_authority_open.svg new file mode 100644 index 0000000000..c919f1a181 --- /dev/null +++ b/designer-base/src/main/resources/com/fine/theme/icon/filetree/folder_half_authority_open.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/designer-base/src/main/resources/com/fine/theme/icon/tip/waiting.svg b/designer-base/src/main/resources/com/fine/theme/icon/tip/waiting.svg new file mode 100644 index 0000000000..d28bde3384 --- /dev/null +++ b/designer-base/src/main/resources/com/fine/theme/icon/tip/waiting.svg @@ -0,0 +1,4 @@ + + + + diff --git a/designer-base/src/main/resources/com/fine/theme/light/ui/fine_light.icon.json b/designer-base/src/main/resources/com/fine/theme/light/ui/fine_light.icon.json index aaa6df6d59..97a5bc70d7 100644 --- a/designer-base/src/main/resources/com/fine/theme/light/ui/fine_light.icon.json +++ b/designer-base/src/main/resources/com/fine/theme/light/ui/fine_light.icon.json @@ -439,6 +439,7 @@ "top": "border/top.svg", "all":"border/all.svg", "error":"tip/error.svg", + "waiting":"tip/waiting.svg", "information":"tip/information.svg", "new_information":"tip/new_information.svg", "success":"tip/success.svg", @@ -448,7 +449,9 @@ "layout_left": "layout/layout_left.svg", "layout_right": "layout/layout_right.svg", "layout_top_right": "layout/layout_top_right.svg", - "theme_edit": "theme_edit.svg" + "theme_edit": "theme_edit.svg", + "folder_half_authority" : "filetree/folder_half_authority.svg", + "folder_half_authority_open" : "filetree/folder_half_authority_open.svg" } } diff --git a/designer-base/src/main/resources/com/fine/theme/light/ui/laf/FineLightLaf.properties b/designer-base/src/main/resources/com/fine/theme/light/ui/laf/FineLightLaf.properties index e9b966dcd7..5b3fbc9c06 100644 --- a/designer-base/src/main/resources/com/fine/theme/light/ui/laf/FineLightLaf.properties +++ b/designer-base/src/main/resources/com/fine/theme/light/ui/laf/FineLightLaf.properties @@ -450,6 +450,7 @@ List.showCellFocusIndicator = false List.cellRender.background = #FFF List.cellRender.button.width = 28 List.cellRender.button.height = 24 +List.cellRender.height = 24 List.wrapper.text.fontColor = #0a1c3877 #---- Menu ---- diff --git a/designer-base/src/main/resources/com/fr/design/i18n/dimension_zh.properties b/designer-base/src/main/resources/com/fr/design/i18n/dimension_zh.properties index bc6f1a8810..1e30edaf4e 100644 --- a/designer-base/src/main/resources/com/fr/design/i18n/dimension_zh.properties +++ b/designer-base/src/main/resources/com/fr/design/i18n/dimension_zh.properties @@ -1,5 +1,5 @@ # \u9ED8\u8BA4\u4E3A\u7C7B\u7684\u5168\u9650\u5B9A\u540D\uFF08\u53EF\u81EA\u5B9A\u4E49key\uFF09= width * height -com.fr.design.mainframe.check.CheckButton=250*118 +com.fr.design.mainframe.check.CheckButton=360*160 com.fr.design.mainframe.check.CheckFontInfoDialog.collapse=360*185 com.fr.design.mainframe.check.CheckFontInfoDialog.messageWithLink=325*31 com.fr.design.mainframe.check.CheckFontInfoDialog.unfold=360*280 diff --git a/designer-chart/src/main/java/com/fr/design/chart/series/SeriesCondition/impl/ChartHyperRelateFloatLinkPane.java b/designer-chart/src/main/java/com/fr/design/chart/series/SeriesCondition/impl/ChartHyperRelateFloatLinkPane.java index e1b5a40612..8846dc0cc3 100644 --- a/designer-chart/src/main/java/com/fr/design/chart/series/SeriesCondition/impl/ChartHyperRelateFloatLinkPane.java +++ b/designer-chart/src/main/java/com/fr/design/chart/series/SeriesCondition/impl/ChartHyperRelateFloatLinkPane.java @@ -74,7 +74,7 @@ public class ChartHyperRelateFloatLinkPane extends AbstractHyperLinkPane { } protected JPanel getContentPane () { - double p = TableLayout.PREFERRED; - double f = TableLayout.FILL; - double[] row = {p, p, p, p, p}; - double[] col = {p, f}; - - return TableLayoutHelper.createTableLayoutPane(getComponent(), row, col); + return FineLayoutBuilder.compatibleTableLayout(10, getComponent(), new double[]{1.2, 3}); } protected Component[][] getComponent () { return new Component[][]{ - new Component[]{null, null}, new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Min_Diameter")), minDiameter}, new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Max_Diameter")), maxDiameter}, new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Shadow")), shadow}, diff --git a/designer-chart/src/main/java/com/fr/van/chart/column/VanChartColumnSeriesPane.java b/designer-chart/src/main/java/com/fr/van/chart/column/VanChartColumnSeriesPane.java index 57176c256c..7822cb3443 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/column/VanChartColumnSeriesPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/column/VanChartColumnSeriesPane.java @@ -79,7 +79,7 @@ public class VanChartColumnSeriesPane extends VanChartAbstractPlotSeriesPane { isFixedWidth.addActionListener(e -> checkColumnWidth()); isFillWithImage.addActionListener(e -> checkImagePane()); - return new UIExpandablePane(Toolkit.i18nText("Fine-Design_Chart_Filled_With_Image"), borderPane); + return new UIExpandablePane(Toolkit.i18nText("Fine-Design_Chart_Filled_With_Image"), borderPane, true); } private void checkAll() { diff --git a/designer-chart/src/main/java/com/fr/van/chart/column/VanChartCustomStackAndAxisConditionPane.java b/designer-chart/src/main/java/com/fr/van/chart/column/VanChartCustomStackAndAxisConditionPane.java index 86766676b4..6ff6f35b67 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/column/VanChartCustomStackAndAxisConditionPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/column/VanChartCustomStackAndAxisConditionPane.java @@ -1,29 +1,26 @@ package com.fr.van.chart.column; +import com.fine.theme.utils.FineLayoutBuilder; +import com.fine.theme.utils.FineUIUtils; +import com.formdev.flatlaf.util.ScaledEmptyBorder; import com.fr.chart.chartglyph.ConditionAttr; import com.fr.data.condition.AbstractCondition; import com.fr.data.condition.ListCondition; import com.fr.design.beans.BasicBeanPane; import com.fr.design.condition.LiteConditionPane; import com.fr.design.gui.ibutton.UIButtonGroup; -import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.ilable.UILabel; import com.fr.design.layout.FRGUIPaneFactory; -import com.fr.design.layout.TableLayout; -import com.fr.design.layout.TableLayoutHelper; -import com.fr.design.utils.gui.GUICoreUtils; import com.fr.plugin.chart.base.AttrSeriesStackAndAxis; import com.fr.van.chart.designer.style.series.VanChartSeriesConditionPane; -import javax.swing.BorderFactory; -import javax.swing.BoxLayout; import javax.swing.JPanel; -import javax.swing.ScrollPaneConstants; +import java.awt.BorderLayout; import java.awt.Component; -import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; + /** * 堆积和坐标轴设置 */ @@ -42,36 +39,26 @@ public class VanChartCustomStackAndAxisConditionPane extends BasicBeanPane(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_YES"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_NO")}); isPercentStacked = new UIButtonGroup(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_YES"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_NO")}); - double p = TableLayout.PREFERRED; - double[] columnSize = {p, p}; - double[] rowSize = {p, p, p, p}; - return TableLayoutHelper.createTableLayoutPane(getDeployComponents(), rowSize, columnSize); + return FineLayoutBuilder.compatibleTableLayout(10, getDeployComponents(), new double[]{1.2, 3}); } protected Component[][] getDeployComponents() { diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartAreaSeriesFillColorPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartAreaSeriesFillColorPane.java index 241798bef3..7d4ad238f6 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartAreaSeriesFillColorPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartAreaSeriesFillColorPane.java @@ -1,14 +1,14 @@ package com.fr.van.chart.designer.component; +import com.fine.theme.utils.FineLayoutBuilder; import com.fr.design.dialog.BasicPane; import com.fr.design.gui.frpane.UINumberDragPane; import com.fr.design.gui.frpane.UINumberDragPaneWithPercent; import com.fr.design.gui.ilable.UILabel; -import com.fr.design.layout.TableLayout; +import com.fr.design.layout.FRGUIPaneFactory; import com.fr.plugin.chart.VanChartAttrHelper; import com.fr.plugin.chart.base.AttrAreaSeriesFillColorBackground; -import com.fr.van.chart.designer.TableLayout4VanChartHelper; import com.fr.van.chart.designer.component.background.VanChartMarkerBackgroundPane; import javax.swing.JPanel; @@ -24,14 +24,9 @@ public class VanChartAreaSeriesFillColorPane extends BasicPane { private UINumberDragPane transparent; public VanChartAreaSeriesFillColorPane() { - double p = TableLayout.PREFERRED; - double f = TableLayout.FILL; - double[] row = {p,p}; - double[] col = {f}; fillColorPane = new VanChartMarkerBackgroundPane(){ protected Component[][] getPaneComponents() { return new Component[][]{ - new Component[]{null, null}, new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Fill_Color")), typeComboBox}, new Component[]{null, centerPane}, }; @@ -39,9 +34,10 @@ public class VanChartAreaSeriesFillColorPane extends BasicPane { }; transparent = new UINumberDragPaneWithPercent(0, 100); - JPanel transparentPane = TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Alpha"), transparent); + JPanel transparentPane = FineLayoutBuilder.createHorizontalLayout(0, new double[]{1.2, 3}, + new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Alpha")), transparent); - this.setLayout(new BorderLayout()); + this.setLayout(FRGUIPaneFactory.createScaledBorderLayout(0, 10)); this.add(fillColorPane, BorderLayout.NORTH); this.add(transparentPane, BorderLayout.CENTER); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartBaseAxisPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartBaseAxisPane.java index 1c02408a3f..54445cceab 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartBaseAxisPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartBaseAxisPane.java @@ -38,7 +38,6 @@ import com.fr.stable.Constants; import com.fr.stable.CoreConstants; import com.fr.stable.StableUtils; import com.fr.van.chart.config.DefaultStyleHelper4Van; -import com.fr.van.chart.designer.TableLayout4VanChartHelper; import com.fr.van.chart.designer.component.VanChartHtmlLabelPane; import com.fr.van.chart.designer.style.VanChartStylePane; import com.fr.van.chart.designer.style.axis.component.VanChartCategoryStylePaneWithCheckBox; @@ -372,19 +371,15 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane { maxProportion = new UINumberDragPaneWithPercent(0, 100, 1); axisLimitSize = new UIButtonGroup(new String[]{Toolkit.i18nText("Fine-Design_Chart_Limit"), Toolkit.i18nText("Fine-Design_Chart_Not_Limit")}); - JPanel limitSizePane = TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Chart_Area_Size"), axisLimitSize); - maxProportionPane = TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Chart_Max_Proportion"), maxProportion, TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH); - maxProportionPane.setBorder(BorderFactory.createEmptyBorder(0, 12, 0, 0)); - JPanel panel = new JPanel(new BorderLayout()); - panel.add(limitSizePane, BorderLayout.NORTH); - panel.add(maxProportionPane, BorderLayout.CENTER); + JPanel limitSizePane = FineLayoutBuilder.createHorizontalLayout(10, new double[]{1.2, 3}, + new UILabel(Toolkit.i18nText("Fine-Design_Chart_Area_Size")), axisLimitSize); + maxProportionPane = FineLayoutBuilder.createHorizontalLayout(10, new double[]{1.2, 3}, + new UILabel(Toolkit.i18nText("Fine-Design_Chart_Max_Proportion")), maxProportion); + JPanel panel = column(10, + cell(limitSizePane), cell(maxProportionPane) + ).getComponent(); - axisLimitSize.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - checkMaxProPortionUse(); - } - }); + axisLimitSize.addActionListener(e -> checkMaxProPortionUse()); return new UIExpandablePane(Toolkit.i18nText("Fine-Design_Chart_Display_Strategy"), panel, true); diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/component/VanChartAxisButtonPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/component/VanChartAxisButtonPane.java index 1664b21ecf..368c9bfddf 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/component/VanChartAxisButtonPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/component/VanChartAxisButtonPane.java @@ -10,6 +10,7 @@ import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIToggleButton; import com.fr.design.gui.imenu.UIMenuItem; import com.fr.design.gui.imenu.UIPopupMenu; +import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.general.ComparatorUtils; import com.fr.plugin.chart.VanChartAttrHelper; @@ -56,7 +57,7 @@ public class VanChartAxisButtonPane extends BasicBeanPane { public VanChartAxisButtonPane(VanChartAxisPane vanChartAxisPane) { this.parent = vanChartAxisPane; - this.setLayout(new BorderLayout()); + this.setLayout(FRGUIPaneFactory.createScaledBorderLayout(10, 0)); addButton = new AddButton(new LazyIcon("add_popup")); JPanel eastPane = new JPanel(new BorderLayout()); diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/background/VanChartAlertValuePane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/background/VanChartAlertValuePane.java index e4ceae7fa9..62afe15d2e 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/background/VanChartAlertValuePane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/background/VanChartAlertValuePane.java @@ -1,5 +1,8 @@ package com.fr.van.chart.designer.style.background; +import com.fine.swing.ui.layout.Column; +import com.fine.theme.utils.FineLayoutBuilder; +import com.fine.theme.utils.FineUIUtils; import com.fr.base.BaseFormula; import com.fr.base.Utils; import com.fr.chart.base.AttrColor; @@ -14,12 +17,8 @@ import com.fr.design.gui.ispinner.UISpinner; import com.fr.design.gui.ispinner.chart.UISpinnerWithPx; import com.fr.design.gui.style.FRFontPane; import com.fr.design.i18n.Toolkit; -import com.fr.design.layout.FRGUIPaneFactory; -import com.fr.design.layout.TableLayout; -import com.fr.design.layout.TableLayoutHelper; import com.fr.design.style.color.ColorSelectBox; import com.fr.design.utils.DesignUtils; -import com.fr.design.utils.gui.GUICoreUtils; import com.fr.general.FRFont; import com.fr.general.GeneralUtils; import com.fr.plugin.chart.VanChartAttrHelper; @@ -29,10 +28,10 @@ import com.fr.stable.Constants; import com.fr.stable.StableUtils; import com.fr.van.chart.designer.component.LineTypeComboBox; -import javax.swing.BoxLayout; import javax.swing.JPanel; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; +import java.awt.BorderLayout; import java.awt.Color; import java.awt.Component; import java.awt.Dimension; @@ -108,26 +107,24 @@ public class VanChartAlertValuePane extends BasicBeanPane { private void doLayoutPane() { this.removeAll(); - this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); + this.setLayout(new BorderLayout()); + Column column = new Column(); + column.setSpacing(10); + this.add(column, BorderLayout.CENTER); + //警戒线设置 - JPanel top = FRGUIPaneFactory.createBorderLayout_L_Pane(); - this.add(top); - top.setBorder(GUICoreUtils.createTitledBorder(Toolkit.i18nText("Fine-Design_Chart_Alert_Set") + ":", null)); - top.add(createTopPane()); + Component top = FineUIUtils.wrapComponentWithTitle(createTopPane(), Toolkit.i18nText("Fine-Design_Chart_Alert_Set")); + column.add(top); + //提示文字 - JPanel bottom = FRGUIPaneFactory.createBorderLayout_L_Pane(); - this.add(bottom); - bottom.setBorder(GUICoreUtils.createTitledBorder(Toolkit.i18nText("Fine-Design_Chart_Alert_Text") + ":", null)); - bottom.add(createBottomPane()); + Component bottom = FineUIUtils.wrapComponentWithTitle(createBottomPane(), Toolkit.i18nText("Fine-Design_Chart_Alert_Text")); + column.add(bottom); } protected JPanel createTopPane() { - double p = TableLayout.PREFERRED; - double[] columnSize = {p, p}; - double[] rowSize = {p, p, p, p, p}; Component[][] components = getTopPaneComponents(); - return TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); + return FineLayoutBuilder.compatibleTableLayout(10, components, new double[]{1.2, 3}); } protected Component[][] getTopPaneComponents() { @@ -141,10 +138,6 @@ public class VanChartAlertValuePane extends BasicBeanPane { } private JPanel createBottomPane() { - alertTextPosition.setSelectedIndex(0); - double p = TableLayout.PREFERRED; - double[] columnSize = {p, p}; - double[] rowSize = {p, p, p, p, p}; Component[][] components = new Component[][]{ new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Layout_Position")), alertTextPosition}, new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Content")), alertText}, @@ -153,7 +146,7 @@ public class VanChartAlertValuePane extends BasicBeanPane { new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Color")), fontColor}, }; - return TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); + return FineLayoutBuilder.compatibleTableLayout(10, components, new double[]{1.2, 3}); } private void checkPositionPane() { diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/background/VanChartAreaBackgroundPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/background/VanChartAreaBackgroundPane.java index 9c332c3e5e..70049a4422 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/background/VanChartAreaBackgroundPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/background/VanChartAreaBackgroundPane.java @@ -1,12 +1,14 @@ package com.fr.van.chart.designer.style.background; import com.fine.theme.utils.FineLayoutBuilder; +import com.formdev.flatlaf.util.ScaledEmptyBorder; import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.Plot; import com.fr.design.foldablepane.UIExpandablePane; import com.fr.design.gui.frpane.AbstractAttrNoScrollPane; import com.fr.design.gui.ilable.UILabel; import com.fr.design.i18n.Toolkit; +import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.chart.PaneTitleConstants; import com.fr.design.mainframe.chart.mode.ChartEditContext; import com.fr.van.chart.designer.AbstractVanChartScrollPane; @@ -15,7 +17,6 @@ import com.fr.van.chart.designer.component.background.VanChartBackgroundPaneWith import com.fr.van.chart.designer.component.border.VanChartBorderWithRadiusPane; import com.fr.van.chart.designer.style.background.radar.VanChartRadarAxisAreaPane; -import javax.swing.BorderFactory; import javax.swing.JPanel; import java.awt.BorderLayout; import java.awt.Color; @@ -44,7 +45,7 @@ public class VanChartAreaBackgroundPane extends AbstractVanChartScrollPane" + Toolkit.i18nText("Fine-Design_Chart_Background_Tooltip") + ""); tooltipLabel.setForeground(Color.gray); - tooltipLabel.setBorder(BorderFactory.createEmptyBorder(0, 10, 5, 10)); contentPane.add(tooltipLabel, BorderLayout.NORTH); tooltipLabel.setVisible(false); } @@ -87,7 +87,8 @@ public class VanChartAreaBackgroundPane extends AbstractVanChartScrollPane { checkCardPane(); } }); - JPanel intervalPane = new JPanel(new BorderLayout(0, 6)); + JPanel intervalPane = new JPanel(FRGUIPaneFactory.createScaledBorderLayout(0, 10)); JPanel panel1 = FineLayoutBuilder.createHorizontalLayout(0, new double[]{1.2, 3}, new UILabel(Toolkit.i18nText("Fine-Design_Chart_Interval_Background")), isDefaultIntervalBackground); intervalPane.add(panel1, BorderLayout.NORTH); diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/background/VanChartCustomIntervalBackgroundPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/background/VanChartCustomIntervalBackgroundPane.java index 42fcdad8eb..f561ce2626 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/background/VanChartCustomIntervalBackgroundPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/background/VanChartCustomIntervalBackgroundPane.java @@ -1,5 +1,7 @@ package com.fr.van.chart.designer.style.background; +import com.fine.theme.utils.FineLayoutBuilder; +import com.fine.theme.utils.FineUIUtils; import com.fr.base.BaseFormula; import com.fr.base.Utils; import com.fr.design.beans.BasicBeanPane; @@ -9,19 +11,14 @@ import com.fr.design.gui.frpane.UINumberDragPane; import com.fr.design.gui.frpane.UINumberDragPaneWithPercent; import com.fr.design.gui.ibutton.UIButtonGroup; import com.fr.design.gui.ilable.UILabel; -import com.fr.design.layout.FRGUIPaneFactory; -import com.fr.design.layout.TableLayout; -import com.fr.design.layout.TableLayoutHelper; import com.fr.design.style.color.ColorSelectBox; -import com.fr.design.utils.gui.GUICoreUtils; import com.fr.plugin.chart.VanChartAttrHelper; import com.fr.plugin.chart.attr.axis.VanChartCustomIntervalBackground; import com.fr.van.chart.designer.TableLayout4VanChartHelper; -import javax.swing.BoxLayout; import javax.swing.JPanel; +import java.awt.BorderLayout; import java.awt.Component; -import java.awt.Dimension; /** * 自定义间隔背景设置 @@ -38,25 +35,17 @@ public class VanChartCustomIntervalBackgroundPane extends BasicBeanPane { } JPanel mapDataTreePanel = new JPanel(new BorderLayout()); - mapDataTreePanel.add(mapDataTree); + UIScrollPane treeScrollPane = new UIScrollPane(mapDataTree); + treeScrollPane.setBorder(FineBorderFactory.createWrappedRoundBorder()); + mapDataTreePanel.add(treeScrollPane, BorderLayout.CENTER); Component[][] components = new Component[][]{ new Component[]{new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Layer_Tree"), mapDataTreePanel, true)}, @@ -78,28 +78,23 @@ public class DrillMapLayerPane extends BasicScrollPane { } private JPanel createLayerDetailPane() { - double p = TableLayout.PREFERRED; - double f = TableLayout.FILL; - double[] columnSize = {f, p, p}; - double[] rowSize = new double[depth + 1]; detailComps = new Component[depth + 1][3]; - rowSize[0] = p; detailComps[0] = new Component[]{ new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Descriptor")), new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Zoom_Layer")), + null, new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Layer_Map_Type")) }; for (int i = 0; i < depth; i++) { - rowSize[i + 1] = p; int d = i + 1; UILabel label = new UILabel(String.format("%s%d%s", com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Index_Article"), d, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Index_Layer"))); UIComboBox level = new UIComboBox(MapStatusPane.ZOOM_LEVELS); level.setEnabled(i != 0); UIComboBox type = new UIComboBox(TEMP.get(oldMapType)); - detailComps[i + 1] = new Component[]{label, level, type}; + detailComps[i + 1] = new Component[]{label, level, null, type}; } - return TableLayoutHelper.createGapTableLayoutPane(detailComps, rowSize, columnSize, 5, 6); + return FineLayoutBuilder.compatibleTableLayout(10, detailComps, new double[]{1.2, 1.4, 0.2, 1.4}); } /** diff --git a/designer-chart/src/main/java/com/fr/van/chart/drillmap/designer/data/comp/MapDataTree.java b/designer-chart/src/main/java/com/fr/van/chart/drillmap/designer/data/comp/MapDataTree.java index 5ebfea2320..1ce78b7e70 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/drillmap/designer/data/comp/MapDataTree.java +++ b/designer-chart/src/main/java/com/fr/van/chart/drillmap/designer/data/comp/MapDataTree.java @@ -1,7 +1,6 @@ package com.fr.van.chart.drillmap.designer.data.comp; import com.fine.theme.icon.LazyIcon; -import com.fr.design.border.FineBorderFactory; import com.fr.general.ComparatorUtils; import com.fr.plugin.chart.map.designer.type.GEOJSONTreeHelper; import com.fr.plugin.chart.map.server.ChartGEOJSONHelper; @@ -35,7 +34,6 @@ public class MapDataTree extends JTree { this.setShowsRootHandles(true); this.setInvokesStopCellEditing(true); this.setCellRenderer(treeCellRenderer); - setBorder(FineBorderFactory.createWrappedRoundBorder()); setStyle(this, PURE_TREE); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/funnel/designer/style/VanChartFunnelSeriesPane.java b/designer-chart/src/main/java/com/fr/van/chart/funnel/designer/style/VanChartFunnelSeriesPane.java index 5d8c896072..f08d81a636 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/funnel/designer/style/VanChartFunnelSeriesPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/funnel/designer/style/VanChartFunnelSeriesPane.java @@ -1,15 +1,14 @@ package com.fr.van.chart.funnel.designer.style; +import com.fine.theme.utils.FineLayoutBuilder; import com.fr.chart.chartattr.Plot; +import com.fr.design.foldablepane.UIExpandablePane; import com.fr.design.gui.ibutton.UIButtonGroup; import com.fr.design.gui.ilable.UILabel; import com.fr.design.i18n.Toolkit; -import com.fr.design.layout.TableLayout; -import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.chart.gui.ChartStylePane; import com.fr.plugin.chart.funnel.FunnelSortType; import com.fr.plugin.chart.funnel.VanChartFunnelPlot; -import com.fr.van.chart.designer.TableLayout4VanChartHelper; import com.fr.van.chart.designer.style.series.VanChartAbstractPlotSeriesPane; import javax.swing.JPanel; @@ -27,16 +26,12 @@ public class VanChartFunnelSeriesPane extends VanChartAbstractPlotSeriesPane { } protected JPanel getContentInPlotType() { - double p = TableLayout.PREFERRED; - double f = TableLayout.FILL; - double[] columnSize = {f}; - double[] rowSize = {p,p,p,p,p,p,p,p,p,p}; Component[][] components = new Component[][]{ new Component[]{createFunnelStylePane()}, new Component[]{createBorderPane()}, }; - contentPane = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); + contentPane = FineLayoutBuilder.compatibleTableLayout(0, components, new double[]{1}); return contentPane; } @@ -57,20 +52,14 @@ public class VanChartFunnelSeriesPane extends VanChartAbstractPlotSeriesPane { Toolkit.i18nText("Fine-Design_Chart_Origin_Sort") }); - double p = TableLayout.PREFERRED; - double f = TableLayout.FILL; - double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; - double[] columnSize = {f, e}; - double[] rowSize = {p,p,p}; Component[][] components = new Component[][]{ - new Component[]{null, null}, new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Continuity")), useSameSlantAngle}, new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Sort")), sort}, }; - JPanel panel = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); + JPanel panel = FineLayoutBuilder.compatibleTableLayout(10, components, new double[]{1.2, 3}); - return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Style_Name"), panel); + return new UIExpandablePane(Toolkit.i18nText("Fine-Design_Chart_Style_Name"), panel, true); } public void populateBean(Plot plot) { diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/VanChartMapSeriesPane.java b/designer-chart/src/main/java/com/fr/van/chart/map/VanChartMapSeriesPane.java index ad553d7b9c..b31055edca 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/map/VanChartMapSeriesPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/map/VanChartMapSeriesPane.java @@ -11,6 +11,7 @@ import com.fr.design.gui.ibutton.UIButtonGroup; import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.ilable.UILabel; import com.fr.design.i18n.Toolkit; +import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.chart.gui.ChartStylePane; import com.fr.design.style.color.ColorSelectBox; import com.fr.design.utils.gui.GUICoreUtils; @@ -273,7 +274,7 @@ public class VanChartMapSeriesPane extends VanChartColorValueSeriesPane { //获取颜色面板 private JPanel getColorPane(MapType paneType) { - JPanel panel = new JPanel(new BorderLayout()); + JPanel panel = new JPanel(FRGUIPaneFactory.createScaledBorderLayout(0, 10)); stylePane = createStylePane(); mapType = ((VanChartMapPlot) plot).getAllLayersMapType(); if (mapType != MapType.CUSTOM && mapType != MapType.DRILL_CUSTOM) { diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/designer/style/label/VanChartMapLabelContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/map/designer/style/label/VanChartMapLabelContentPane.java index 1afffc8964..0b7716faa2 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/map/designer/style/label/VanChartMapLabelContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/map/designer/style/label/VanChartMapLabelContentPane.java @@ -1,10 +1,11 @@ package com.fr.van.chart.map.designer.style.label; +import com.fine.theme.utils.FineLayoutBuilder; import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.ilable.UILabel; import com.fr.design.i18n.Toolkit; import com.fr.design.jxbrowser.JxUIPane; -import com.fr.design.layout.TableLayout; +import com.fr.design.layout.FRGUIPaneFactory; import com.fr.plugin.chart.base.AttrTooltipContent; import com.fr.plugin.chart.base.format.AttrTooltipAreaNameFormat; import com.fr.plugin.chart.base.format.AttrTooltipFormat; @@ -13,7 +14,6 @@ import com.fr.plugin.chart.base.format.AttrTooltipPercentFormat; import com.fr.plugin.chart.base.format.AttrTooltipSeriesFormat; import com.fr.plugin.chart.base.format.AttrTooltipValueFormat; import com.fr.plugin.chart.type.TextAlign; -import com.fr.van.chart.designer.TableLayout4VanChartHelper; import com.fr.van.chart.designer.component.VanChartLabelContentPane; import com.fr.van.chart.designer.component.format.MapAreaNameFormatPaneWithCheckBox; import com.fr.van.chart.designer.component.format.PercentFormatPaneWithCheckBox; @@ -67,18 +67,12 @@ public class VanChartMapLabelContentPane extends VanChartLabelContentPane { protected JPanel getLabelContentPane(JPanel contentPane) { showAllSeries = new UICheckBox(Toolkit.i18nText("Fine-Design_Chart_Show_All_Series")); - double f = TableLayout.FILL; - double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; - double[] columnSize = {f, e}; - double p = TableLayout.PREFERRED; - double[] row = {p, p}; Component[][] components = { - new Component[]{null, null}, new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Display_Strategy")), showAllSeries} }; - checkPane = TableLayout4VanChartHelper.createGapTableLayoutPane(components, row, columnSize); + checkPane = FineLayoutBuilder.compatibleTableLayout(0, components, new double[]{1.2, 3}); - JPanel panel = new JPanel(new BorderLayout()); + JPanel panel = new JPanel(FRGUIPaneFactory.createScaledBorderLayout(0, 10)); panel.add(contentPane, BorderLayout.CENTER); panel.add(checkPane, BorderLayout.SOUTH); return createTableLayoutPaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Content"), panel); diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/designer/type/WMSLayerPane.java b/designer-chart/src/main/java/com/fr/van/chart/map/designer/type/WMSLayerPane.java index 218dd02294..cac695bf17 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/map/designer/type/WMSLayerPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/map/designer/type/WMSLayerPane.java @@ -1,6 +1,7 @@ package com.fr.van.chart.map.designer.type; +import com.fine.theme.utils.FineLayoutBuilder; import com.fr.design.dialog.FineJOptionPane; import com.fr.design.event.UIObserver; import com.fr.design.event.UIObserverListener; @@ -9,11 +10,10 @@ import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itextarea.UITextArea; import com.fr.design.i18n.Toolkit; +import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayout; -import com.fr.design.layout.TableLayoutHelper; import com.fr.plugin.chart.base.GisLayer; import com.fr.plugin.chart.map.layer.WMSLayer; -import com.fr.van.chart.designer.TableLayout4VanChartHelper; import javax.swing.JPanel; import javax.swing.SwingConstants; @@ -55,24 +55,19 @@ public class WMSLayerPane extends JPanel implements UIObserver { public WMSLayerPane() { - final double p = TableLayout.PREFERRED; - double[] rowSize = {p}; - double[] COLUMN_SIZE = {TableLayout4VanChartHelper.DESCRIPTION_AREA_WIDTH, 84, 44}; - wmsUrl = new UITextArea(); connectButton = new UIButton(Toolkit.i18nText("Fine-Design_Chart_Connect_WMP")); Component[][] comps = new Component[][]{ - new Component[]{new UILabel("url"), wmsUrl, connectButton} + new Component[]{new UILabel("url"), wmsUrl, null, connectButton} }; - JPanel northPane = TableLayout4VanChartHelper.createGapTableLayoutPane(comps, rowSize, COLUMN_SIZE); - northPane.setBorder(TableLayout4VanChartHelper.SECOND_EDIT_AREA_BORDER); + JPanel northPane = FineLayoutBuilder.compatibleTableLayout(10, comps, new double[]{1.2, 1.4, 0.2, 1.4}); wmsLayerPane = new JPanel(new BorderLayout()); resetWMSLayerPane(new ArrayList<>()); - this.setLayout(new BorderLayout(0, 6)); + this.setLayout(FRGUIPaneFactory.createScaledBorderLayout(0, 10)); this.add(northPane, BorderLayout.NORTH); this.add(wmsLayerPane, BorderLayout.CENTER); addListener(); @@ -136,7 +131,7 @@ public class WMSLayerPane extends JPanel implements UIObserver { wmsLayerCheckBoxs.add(checkBox); } - wmsLayerPane.add(TableLayoutHelper.createCommonTableLayoutPane(comps, rowSize, COLUMN_SIZE, 0), BorderLayout.CENTER); + wmsLayerPane.add(FineLayoutBuilder.compatibleTableLayout(10, comps, new double[]{1.2, 3}), BorderLayout.CENTER); updateUI(); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/multilayer/style/VanChartMultiPieSeriesPane.java b/designer-chart/src/main/java/com/fr/van/chart/multilayer/style/VanChartMultiPieSeriesPane.java index 6c1575cfdf..dd3923bc9d 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/multilayer/style/VanChartMultiPieSeriesPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/multilayer/style/VanChartMultiPieSeriesPane.java @@ -1,15 +1,15 @@ package com.fr.van.chart.multilayer.style; +import com.fine.theme.utils.FineLayoutBuilder; import com.fr.chart.chartattr.Plot; +import com.fr.design.foldablepane.UIExpandablePane; import com.fr.design.gui.frpane.UINumberDragPaneWithPercent; import com.fr.design.gui.ibutton.UIButtonGroup; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ispinner.UISpinner; import com.fr.design.layout.TableLayout; -import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.chart.gui.ChartStylePane; import com.fr.plugin.chart.multilayer.VanChartMultiPiePlot; -import com.fr.van.chart.designer.TableLayout4VanChartHelper; import com.fr.van.chart.designer.component.VanChartBeautyPane; import com.fr.van.chart.pie.VanChartPieSeriesPane; @@ -39,7 +39,7 @@ public class VanChartMultiPieSeriesPane extends VanChartPieSeriesPane { new Component[]{createBorderPane()}, }; - return TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); + return FineLayoutBuilder.compatibleTableLayout(10, components, new double[]{1}); } protected JPanel createSeriesStylePane(double[] row, double[] col) { @@ -54,7 +54,6 @@ public class VanChartMultiPieSeriesPane extends VanChartPieSeriesPane { com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Close")}); Component[][] components = new Component[][]{ - new Component[]{null,null}, new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Gradual_Level") ),gradualLevel}, new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Start_Angle") ),startAngle}, new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_End_Angle")),endAngle}, @@ -63,8 +62,8 @@ public class VanChartMultiPieSeriesPane extends VanChartPieSeriesPane { new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Rotation")),supportRotation} }; - JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(components, row, col); - return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Widget_Style"), panel); + JPanel panel = FineLayoutBuilder.compatibleTableLayout(10, components, new double[]{1.2, 3}); + return new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Widget_Style"), panel, true); } protected void populatePieAttr() { diff --git a/designer-chart/src/main/java/com/fr/van/chart/pie/VanChartPieSeriesPane.java b/designer-chart/src/main/java/com/fr/van/chart/pie/VanChartPieSeriesPane.java index 52f865356d..f17cb9bcde 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/pie/VanChartPieSeriesPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/pie/VanChartPieSeriesPane.java @@ -1,6 +1,7 @@ package com.fr.van.chart.pie; +import com.fine.theme.utils.FineLayoutBuilder; import com.fr.chart.chartattr.Plot; import com.fr.design.foldablepane.UIExpandablePane; import com.fr.design.gui.frpane.UINumberDragPane; @@ -9,7 +10,6 @@ import com.fr.design.gui.ibutton.UIButtonGroup; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ispinner.UISpinner; import com.fr.design.layout.TableLayout; -import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.chart.gui.ChartStylePane; import com.fr.design.i18n.Toolkit; @@ -48,7 +48,7 @@ public class VanChartPieSeriesPane extends VanChartAbstractPlotSeriesPane { new Component[]{createBorderPane()}, }; - return TableLayoutHelper.createTableLayoutPane(components,rowSize,columnSize); + return FineLayoutBuilder.compatibleTableLayout(10, components, new double[]{1}); } @@ -60,7 +60,6 @@ public class VanChartPieSeriesPane extends VanChartAbstractPlotSeriesPane { Component[][] components = new Component[][]{ - new Component[]{null,null}, new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Start_Angle")),startAngle}, new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_End_Angle")),endAngle}, new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Inner_Radius")),innerRadius}, @@ -69,7 +68,7 @@ public class VanChartPieSeriesPane extends VanChartAbstractPlotSeriesPane { }; - JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(components, row, col); + JPanel panel = FineLayoutBuilder.compatibleTableLayout(10, components, new double[]{1.2, 3}); return new UIExpandablePane(Toolkit.i18nText("Fine-Design_Chart_Widget_Style"), panel, true); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/radar/VanChartRadarSeriesPane.java b/designer-chart/src/main/java/com/fr/van/chart/radar/VanChartRadarSeriesPane.java index 1026b99367..ffe75a7d58 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/radar/VanChartRadarSeriesPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/radar/VanChartRadarSeriesPane.java @@ -1,15 +1,15 @@ package com.fr.van.chart.radar; +import com.fine.theme.utils.FineLayoutBuilder; import com.fr.chart.chartattr.Plot; +import com.fr.design.foldablepane.UIExpandablePane; +import com.fr.design.gui.ilable.UILabel; import com.fr.design.i18n.Toolkit; import com.fr.design.gui.ibutton.UIButtonGroup; -import com.fr.design.layout.TableLayout; -import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.chart.gui.ChartStylePane; import com.fr.plugin.chart.radar.VanChartRadarPlot; import com.fr.plugin.chart.type.RadarType; -import com.fr.van.chart.designer.TableLayout4VanChartHelper; import com.fr.van.chart.designer.component.VanChartLineTypePane; import com.fr.van.chart.designer.component.VanChartLineWidthPane; import com.fr.van.chart.designer.style.series.VanChartAbstractPlotSeriesPane; @@ -32,12 +32,8 @@ public class VanChartRadarSeriesPane extends VanChartAbstractPlotSeriesPane { } protected JPanel getContentInPlotType(){ - double p = TableLayout.PREFERRED; - double f = TableLayout.FILL; - double[] row = {p,p,p,p,p,p,p}; - double[] col = {f}; - contentPane = TableLayoutHelper.createTableLayoutPane(getPaneComponents(), row, col); + contentPane = FineLayoutBuilder.compatibleTableLayout(10, getPaneComponents(), new double[]{1}); return contentPane; } @@ -67,8 +63,9 @@ public class VanChartRadarSeriesPane extends VanChartAbstractPlotSeriesPane { private JPanel createRadarTypePane() { radarType = new UIButtonGroup(new String[]{Toolkit.i18nText("Fine-Design_Chart_Circle"), Toolkit.i18nText("Fine-Design_Chart_Polygonal")}, new String[]{RadarType.CIRCLE.getType(), RadarType.POLYGON.getType()}); - JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Chart_Shape"), radarType); - return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Style_Present"), panel); + JPanel panel = FineLayoutBuilder.createHorizontalLayout(0, new double[]{1.2, 3}, + new UILabel(Toolkit.i18nText("Fine-Design_Chart_Shape")), radarType); + return new UIExpandablePane(Toolkit.i18nText("Fine-Design_Chart_Style_Present"), panel, true); } protected VanChartLineTypePane getLineTypePane() { diff --git a/designer-chart/src/main/java/com/fr/van/chart/range/component/GradualIntervalConfigPane.java b/designer-chart/src/main/java/com/fr/van/chart/range/component/GradualIntervalConfigPane.java index f1cdc5b62e..5fdf0d5a0f 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/range/component/GradualIntervalConfigPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/range/component/GradualIntervalConfigPane.java @@ -1,11 +1,10 @@ package com.fr.van.chart.range.component; +import com.fine.theme.utils.FineLayoutBuilder; import com.fr.design.gui.frpane.UINumberDragPane; import com.fr.design.gui.ilable.BoldFontTextLabel; -import com.fr.design.layout.TableLayout; import com.fr.design.mainframe.chart.gui.ColorSelectBoxWithOutTransparent; import com.fr.plugin.chart.range.GradualIntervalConfig; -import com.fr.van.chart.designer.TableLayout4VanChartHelper; import com.fr.van.chart.designer.style.axis.component.MinMaxValuePaneWithOutTick; import javax.swing.JPanel; @@ -51,16 +50,10 @@ public class GradualIntervalConfigPane extends JPanel { legendGradientBar = createLegendGradientBar(); - double p = TableLayout.PREFERRED; - double f = TableLayout.FILL; - double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; - double[] col = new double[]{f, e}; - double[] row = new double[]{p, p, p, p}; - Component[][] components = getPaneComponents(minMaxValuePane, colorSelectBox, numberDragPane, legendGradientBar); //控件承载面板 - JPanel contentPane = TableLayout4VanChartHelper.createGapTableLayoutPane(components, row, col); + JPanel contentPane = FineLayoutBuilder.compatibleTableLayout(10, components, new double[]{1.2, 3}); this.setLayout(new BorderLayout()); this.add(contentPane, BorderLayout.CENTER); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/range/component/LegendLabelFormatPane.java b/designer-chart/src/main/java/com/fr/van/chart/range/component/LegendLabelFormatPane.java index eec9225f58..478d7d13d1 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/range/component/LegendLabelFormatPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/range/component/LegendLabelFormatPane.java @@ -1,12 +1,12 @@ package com.fr.van.chart.range.component; +import com.fine.theme.utils.FineLayoutBuilder; import com.fr.chart.base.LegendLabelFormat; +import com.fr.design.foldablepane.UIExpandablePane; import com.fr.design.gui.ibutton.UIButtonGroup; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.style.FormatPane; -import com.fr.design.layout.TableLayout; -import com.fr.van.chart.designer.TableLayout4VanChartHelper; import com.fr.van.chart.designer.component.VanChartHtmlLabelPaneWithOutWidthAndHeight; import com.fr.van.chart.designer.component.format.FormatPaneWithOutFont; import com.fr.van.chart.designer.style.VanChartStylePane; @@ -47,7 +47,6 @@ public class LegendLabelFormatPane extends JPanel { } }; htmlLabelPane = new VanChartHtmlLabelPaneWithOutWidthAndHeight(); - htmlLabelPane.setBorder(BorderFactory.createEmptyBorder(0, (int) TableLayout4VanChartHelper.DESCRIPTION_AREA_WIDTH + TableLayout4VanChartHelper.COMPONENT_INTERVAL, 0, 0)); centerPane = new JPanel(new CardLayout()) { @Override @@ -63,17 +62,11 @@ public class LegendLabelFormatPane extends JPanel { centerPane.add(htmlLabelPane, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Custom")); - double p = TableLayout.PREFERRED; - double f = TableLayout.FILL; - double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; - double[] columnSize = {f, e}; - double[] rowSize = {p, p, p}; Component[][] components = new Component[][]{ - new Component[]{null, null}, new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Label_Format"), SwingConstants.LEFT), labelFormatStyle}, new Component[]{centerPane, null}, }; - JPanel contentPane = TableLayout4VanChartHelper.createGapTableLayoutPane(components, rowSize, columnSize); + JPanel contentPane = FineLayoutBuilder.compatibleTableLayout(10, components, new double[]{1.2, 3}); labelFormatStyle.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { @@ -82,7 +75,7 @@ public class LegendLabelFormatPane extends JPanel { }); labelFormatStyle.setSelectedIndex(0); - JPanel panel = TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Use_Format"), contentPane); + JPanel panel = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Use_Format"), contentPane, true); this.setLayout(new BorderLayout()); this.add(panel, BorderLayout.CENTER); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/treemap/style/VanChartTreeMapSeriesPane.java b/designer-chart/src/main/java/com/fr/van/chart/treemap/style/VanChartTreeMapSeriesPane.java index db8bfa94b1..7998a088e7 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/treemap/style/VanChartTreeMapSeriesPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/treemap/style/VanChartTreeMapSeriesPane.java @@ -1,11 +1,13 @@ package com.fr.van.chart.treemap.style; +import com.fine.theme.utils.FineLayoutBuilder; import com.fr.chart.chartattr.Plot; +import com.fr.design.foldablepane.UIExpandablePane; import com.fr.design.gui.ibutton.UIButtonGroup; +import com.fr.design.gui.ilable.UILabel; import com.fr.design.mainframe.chart.gui.ChartStylePane; import com.fr.plugin.chart.treemap.VanChartTreeMapPlot; -import com.fr.van.chart.designer.TableLayout4VanChartHelper; import com.fr.van.chart.multilayer.style.VanChartMultiPieSeriesPane; import javax.swing.JPanel; @@ -22,8 +24,9 @@ public class VanChartTreeMapSeriesPane extends VanChartMultiPieSeriesPane { protected JPanel createSeriesStylePane(double[] row, double[] col) { supportDrill = new UIButtonGroup(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Open"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Close")}); - JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Drill"), supportDrill); - return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Widget_Style"), panel); + JPanel panel = FineLayoutBuilder.createHorizontalLayout(0, new double[]{1.2, 3}, + new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Drill")), supportDrill); + return new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Widget_Style"), panel, true); } protected void populatePieAttr() { diff --git a/designer-realize/src/main/java/com/fanruan/data/ConnectionConfigWrapper.java b/designer-realize/src/main/java/com/fanruan/data/ConnectionConfigWrapper.java index 8c4a9e7b6b..8dd3ea86e5 100644 --- a/designer-realize/src/main/java/com/fanruan/data/ConnectionConfigWrapper.java +++ b/designer-realize/src/main/java/com/fanruan/data/ConnectionConfigWrapper.java @@ -7,6 +7,8 @@ import com.fr.file.ConnectionConfig; import com.fr.log.FineLoggerFactory; import com.fr.transaction.Configurations; import com.fr.transaction.WorkerAdaptor; +import com.fr.workspace.WorkContext; +import com.fr.workspace.server.repository.connection.ConnectionRepository; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -106,7 +108,7 @@ public class ConnectionConfigWrapper implements ConnectionConfigProvider, Connec @Override public @Nullable Connection getConnection(@NotNull String connectionName) { - Connection connection = ConnectionConfig.getInstance().getConnection(connectionName); + Connection connection = WorkContext.getCurrent().isLocal() ? ConnectionConfig.getInstance().getConnection(connectionName) : ConnectionRepository.getInstance().getByName(connectionName).getConnection(); if (connection != null) { connection.setConnectionName(connectionName); } diff --git a/designer-realize/src/main/java/com/fanruan/fs/DesignFileRepository.java b/designer-realize/src/main/java/com/fanruan/fs/DesignFileRepository.java index 07c68918fa..7947989a0a 100644 --- a/designer-realize/src/main/java/com/fanruan/fs/DesignFileRepository.java +++ b/designer-realize/src/main/java/com/fanruan/fs/DesignFileRepository.java @@ -7,6 +7,9 @@ import com.fr.stable.project.ProjectConstants; import com.fr.workspace.server.entity.resource.ResourceBean; import com.fr.workspace.server.repository.resource.PublicResourceRepository; +import java.io.ByteArrayInputStream; +import java.io.InputStream; + /** * DesignFileRepository @@ -31,4 +34,9 @@ public class DesignFileRepository extends LocalFileRepository { public FineFileEntry[] listEntry(String dir) { return PublicResourceRepository.getInstance().listEntry(new ResourceBean(dir)); } + + @Override + public InputStream openStream(String path) { + return new ByteArrayInputStream(PublicResourceRepository.getInstance().openStream(path)); + } } diff --git a/designer-realize/src/main/java/com/fr/design/cell/editor/BiasTextPainterCellEditor.java b/designer-realize/src/main/java/com/fr/design/cell/editor/BiasTextPainterCellEditor.java index 1a578638c8..57f29e2c71 100644 --- a/designer-realize/src/main/java/com/fr/design/cell/editor/BiasTextPainterCellEditor.java +++ b/designer-realize/src/main/java/com/fr/design/cell/editor/BiasTextPainterCellEditor.java @@ -4,8 +4,8 @@ package com.fr.design.cell.editor; import com.fine.swing.ui.layout.Layouts; -import com.fine.theme.light.ui.FineRoundBorder; import com.fine.theme.utils.FineUIScale; +import com.fr.design.border.FineBorderFactory; import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.gui.ibutton.UIRadioButton; @@ -84,7 +84,7 @@ public class BiasTextPainterCellEditor extends AbstractCellEditor { Window parentWindow = SwingUtilities.getWindowAncestor(grid); this.biasTextPainterPane = new BiasTextPainterPane(); - Dimension wrapDimension = FineUIScale.scale(new Dimension(360, 172)); + Dimension wrapDimension = FineUIScale.scale(new Dimension(360, 212)); this.biasTextPainterPane.populate(biasTextPainter); return this.biasTextPainterPane.showWindowWithCustomSize(parentWindow, new DialogActionAdapter() { @@ -113,7 +113,7 @@ public class BiasTextPainterCellEditor extends AbstractCellEditor { formulaTextArea = new UITextArea(); JScrollPane scrollPane = new JScrollPane(formulaTextArea); - scrollPane.setBorder(new FineRoundBorder()); + scrollPane.setBorder(FineBorderFactory.createWrappedRoundBorder()); formulaTextArea.setBorder(null); String leftToLowerText = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Slope_Line_Upper_Left_To_Lower_Right"); @@ -130,8 +130,8 @@ public class BiasTextPainterCellEditor extends AbstractCellEditor { group.add(choice2); add(Layouts.column(10, - Layouts.cell(formulaLabel).weight(0.1), Layouts.cell(scrollPane).weight(0.12), - Layouts.row(5, Layouts.cell(choice1).weight(1), Layouts.cell(choice2).weight(1)).weight(0.12)).getComponent()); + Layouts.cell(formulaLabel), Layouts.cell(scrollPane).weight(1), + Layouts.row(5, Layouts.cell(choice1).weight(1), Layouts.cell(choice2).weight(1))).getComponent()); } @Override