From c11fbc6ab83da0c6b6ad2e8d000ae6abebe98600 Mon Sep 17 00:00:00 2001 From: vito Date: Tue, 20 Aug 2024 19:17:51 +0800 Subject: [PATCH 1/5] =?UTF-8?q?REPORT-131407=20=E4=BF=AE=E5=A4=8D=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E4=B8=AD=E5=BF=83=E5=BC=B9=E7=AA=97=E6=A0=87=E9=A2=98?= =?UTF-8?q?=E7=BC=BA=E5=A4=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/data/tabledata/datacenter/DatacentersPane.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/designer-base/src/main/java/com/fr/design/data/tabledata/datacenter/DatacentersPane.java b/designer-base/src/main/java/com/fr/design/data/tabledata/datacenter/DatacentersPane.java index e8a539f115..5dd0489097 100644 --- a/designer-base/src/main/java/com/fr/design/data/tabledata/datacenter/DatacentersPane.java +++ b/designer-base/src/main/java/com/fr/design/data/tabledata/datacenter/DatacentersPane.java @@ -7,6 +7,7 @@ import com.fr.datacenters.tabledata.bean.DCTableDataBean; import com.fr.design.data.tabledata.tabledatapane.AbstractTableDataPane; import com.fr.design.dialog.DialogActionListener; import com.fr.design.dialog.UIDialog; +import com.fr.design.i18n.Toolkit; import com.fr.design.jxbrowser.JxEngine; import com.fr.design.jxbrowser.JxUIPane; import com.fr.json.revise.EmbedJson; @@ -125,6 +126,6 @@ public class DatacentersPane extends AbstractTableDataPane { @Override protected String title4PopupWindow() { - return ""; + return Toolkit.i18nText("Fine-Design_Report_Add_TableData"); } } From 9d2c8f2783ba4f227d26e68a34cf5f6a843989a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Levy=2EXie-=E8=A7=A3=E5=AE=89=E6=A3=AE?= Date: Tue, 20 Aug 2024 20:34:17 +0800 Subject: [PATCH 2/5] =?UTF-8?q?REPORT-113994=20=E3=80=90NewUI=E3=80=91?= =?UTF-8?q?=E5=9B=BE=E8=A1=A8=E9=81=97=E7=95=99=E9=97=AE=E9=A2=98=E5=A4=84?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gui/icombobox/UIComboBoxRenderer.java | 16 +++++++-- .../table/SeriesNameUseFieldNamePane.java | 7 ++-- .../table/BoxPlotTableDataContentPane.java | 36 +++++++------------ .../BoxPlotTableResultDataSeriesPane.java | 22 ++---------- .../table/BoxPlotTableSeriesTypeUsePane.java | 22 ++---------- .../chart/designer/other/AutoRefreshPane.java | 23 +++++++++--- .../label/VanChartPlotLabelDetailPane.java | 20 ++++++----- 7 files changed, 63 insertions(+), 83 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/gui/icombobox/UIComboBoxRenderer.java b/designer-base/src/main/java/com/fr/design/gui/icombobox/UIComboBoxRenderer.java index f0bf7b1a4e..9e9d3d1f25 100644 --- a/designer-base/src/main/java/com/fr/design/gui/icombobox/UIComboBoxRenderer.java +++ b/designer-base/src/main/java/com/fr/design/gui/icombobox/UIComboBoxRenderer.java @@ -1,10 +1,13 @@ package com.fr.design.gui.icombobox; -import java.awt.Dimension; +import java.awt.*; -import javax.swing.DefaultListCellRenderer; +import javax.swing.*; import com.fine.theme.utils.FineUIScale; +import com.fine.theme.utils.FineUIUtils; +import com.formdev.flatlaf.util.ScaledEmptyBorder; +import com.fr.design.constants.UIConstants; /** * @@ -19,6 +22,15 @@ public class UIComboBoxRenderer extends DefaultListCellRenderer { super(); } + @Override + public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { + JLabel renderer =(JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); + renderer.setBorder(new ScaledEmptyBorder(FineUIUtils.getUIInsets( + "ComboBox.renderInset", "ComboBox.padding" + ))); + return renderer; + } + @Override public Dimension getPreferredSize() { return new Dimension(super.getPreferredSize().width, FineUIScale.scale(24)); diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/SeriesNameUseFieldNamePane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/SeriesNameUseFieldNamePane.java index ec63cda9b9..8e87202b42 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/SeriesNameUseFieldNamePane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/SeriesNameUseFieldNamePane.java @@ -1,5 +1,6 @@ package com.fr.design.mainframe.chart.gui.data.table; +import com.fine.theme.utils.FineLayoutBuilder; import com.fr.base.Utils; import com.fr.base.chart.chartdata.TopDefinitionProvider; import com.fr.chart.chartattr.ChartCollection; @@ -92,12 +93,8 @@ public class SeriesNameUseFieldNamePane extends FurtherBasicBeanPane { initTooltipSet(); - JPanel jPanel = new JPanel(); + JPanel jPanel = new JPanel(new BorderLayout()); jPanel.add(autoTooltip, BorderLayout.CENTER); jPanel.add(tooltipSet, BorderLayout.EAST); @@ -85,7 +90,7 @@ public class AutoRefreshPane extends BasicBeanPane { Component[][] components = initComponent(jPanel); - JPanel panel1 = FineLayoutBuilder.compatibleTableLayout(10, components, new double[]{1.2, 1.2, 1.2, 0.6}); + JPanel panel1 = FineLayoutBuilder.compatibleTableLayout(10, components, new double[]{1.2, 3}); contentPane = new JPanel(new BorderLayout()); contentPane.add(panel1, BorderLayout.CENTER); @@ -97,10 +102,18 @@ public class AutoRefreshPane extends BasicBeanPane { protected Component[][] initComponent(JPanel autoTooltipPane){ + Column toolTipPane = column(10, + row( + cell(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Time_Interval"))), + flex(), + cell(autoRefreshTime), + cell(new UILabel(" " + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Time_Seconds"))) + ), + cell(autoTooltipPane) + ).getComponent(); + return new Component[][]{ - new Component[]{null, new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Time_Interval")), - autoRefreshTime, new UILabel(" " + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Time_Seconds"))}, - new Component[]{null, autoTooltip, null, tooltipSet}, + new Component[]{null, toolTipPane} }; } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPlotLabelDetailPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPlotLabelDetailPane.java index deb4779e4b..fc69b85f25 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPlotLabelDetailPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPlotLabelDetailPane.java @@ -1,5 +1,6 @@ package com.fr.van.chart.designer.style.label; +import com.fine.swing.ui.layout.Column; import com.fine.theme.utils.FineLayoutBuilder; import com.fine.theme.utils.FineUIScale; import com.fr.chart.chartattr.Plot; @@ -230,16 +231,17 @@ public class VanChartPlotLabelDetailPane extends BasicPane { return new JPanel(); } - autoAdjust = new UIButtonGroup(new String[]{Toolkit.i18nText("Fine-Design_Chart_On"), Toolkit.i18nText("Fine-Design_Chart_Off")}, new Boolean[]{true, false}); + autoAdjust = new UIButtonGroup<>(new String[]{Toolkit.i18nText("Fine-Design_Chart_On"), Toolkit.i18nText("Fine-Design_Chart_Off")}, new Boolean[]{true, false}); - JPanel panel = new JPanel(new BorderLayout()); + Column column = new Column(); + column.setSpacing(10); positionPane = new JPanel(); checkPositionPane(title); - panel.add(positionPane, BorderLayout.NORTH); + column.add(positionPane); if (hasLabelOrientationPane()) { - panel.add(createLabelOrientationPane(), BorderLayout.CENTER); + column.add(createLabelOrientationPane()); } if (plot.isSupportLeadLine()) { @@ -250,14 +252,14 @@ public class VanChartPlotLabelDetailPane extends BasicPane { double[] row = new double[]{TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED}; double[] col = new double[]{TableLayout.FILL, TableLayout4VanChartHelper.EDIT_AREA_WIDTH}; getLabelPositionPane(comps, row, col); - panel.add(getLabelPositionPane(comps, row, col), BorderLayout.SOUTH); + column.add(getLabelPositionPane(comps, row, col)); initPositionListener(); } else if (PlotFactory.plotAutoAdjustLabelPosition(plot)) { - panel.add(FineLayoutBuilder.createHorizontalLayout(0, new double[]{1.2, 3}, - new UILabel(Toolkit.i18nText("Fine-Design_Chart_Auto_Adjust")), autoAdjust), BorderLayout.SOUTH); + column.add(FineLayoutBuilder.createHorizontalLayout(0, new double[]{1.2, 3}, + new UILabel(Toolkit.i18nText("Fine-Design_Chart_Auto_Adjust")), autoAdjust)); } - return getLabelLayoutPane(panel, Toolkit.i18nText("Fine-Design_Form_Attr_Layout")); + return getLabelLayoutPane(column, Toolkit.i18nText("Fine-Design_Form_Attr_Layout")); } protected JPanel getLabelLayoutPane(JPanel panel, String title) { @@ -318,7 +320,7 @@ public class VanChartPlotLabelDetailPane extends BasicPane { } protected JPanel getLabelPositionPane(Component[][] comps, double[] row, double[] col) { - return TableLayoutHelper.createTableLayoutPane(comps, row, col); + return FineLayoutBuilder.compatibleTableLayout(10, comps, new double[]{1.2, 3}); } protected void initPositionListener() { From ef7a775a108521bbdda0d6f3213a3a772c7f41d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Levy=2EXie-=E8=A7=A3=E5=AE=89=E6=A3=AE?= Date: Tue, 20 Aug 2024 20:35:10 +0800 Subject: [PATCH 3/5] =?UTF-8?q?REPORT-130846=E3=80=90NewUI=E3=80=91ComboBo?= =?UTF-8?q?x=E8=BE=B9=E8=B7=9D=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/fr/design/gui/ispinner/UISpinner.java | 5 +++-- .../com/fine/theme/light/ui/laf/FineLightLaf.properties | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/gui/ispinner/UISpinner.java b/designer-base/src/main/java/com/fr/design/gui/ispinner/UISpinner.java index b47d162a27..f6b75b7c4f 100644 --- a/designer-base/src/main/java/com/fr/design/gui/ispinner/UISpinner.java +++ b/designer-base/src/main/java/com/fr/design/gui/ispinner/UISpinner.java @@ -2,6 +2,7 @@ package com.fr.design.gui.ispinner; import com.fine.theme.icon.LazyIcon; import com.fine.theme.utils.FineUIUtils; +import com.formdev.flatlaf.util.ScaledEmptyBorder; import com.fr.design.event.GlobalNameListener; import com.fr.design.event.GlobalNameObserver; import com.fr.design.event.HoverAware; @@ -284,8 +285,8 @@ public class UISpinner extends JPanel implements UIObserver, GlobalNameObserver, textField = initNumberField(); textField.setMaxValue(maxValue); textField.setMinValue(minValue); - Insets insets = FineUIUtils.getAndScaleUIInsets("InputTextField.borderInsets", defaultInsets); - textField.setBorder(BorderFactory.createEmptyBorder(insets.top, insets.left, insets.bottom, insets.right)); + Insets insets = FineUIUtils.getUIInsets("InputTextField.borderInsets", defaultInsets); + textField.setBorder(new ScaledEmptyBorder(insets.top, insets.left, insets.bottom, insets.right)); textField.setOpaque(false); setValue(value); 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 f31bda6cf5..9c0ee9c9f8 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 @@ -319,6 +319,7 @@ ComboBox.selectionArc = 0 ComboBox.borderCornerRadius = 3 ComboBox.comboHeight = 24 ComboBox.selectBox.button.height = 22 +ComboBox.renderInset = 0,6,0,6 #---- Component ---- From 7222a35bd99eea89ab593332f0718e1f0421b269 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Levy=2EXie-=E8=A7=A3=E5=AE=89=E6=A3=AE?= Date: Tue, 20 Aug 2024 20:37:46 +0800 Subject: [PATCH 4/5] =?UTF-8?q?REPORT-130846=E3=80=90NewUI=E3=80=91ComboBo?= =?UTF-8?q?x=E8=BE=B9=E8=B7=9D=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/gui/icombobox/UIComboBoxRenderer.java | 8 +++++--- .../com/fr/van/chart/designer/other/AutoRefreshPane.java | 7 ++++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/gui/icombobox/UIComboBoxRenderer.java b/designer-base/src/main/java/com/fr/design/gui/icombobox/UIComboBoxRenderer.java index 9e9d3d1f25..0b8b4fe592 100644 --- a/designer-base/src/main/java/com/fr/design/gui/icombobox/UIComboBoxRenderer.java +++ b/designer-base/src/main/java/com/fr/design/gui/icombobox/UIComboBoxRenderer.java @@ -1,13 +1,15 @@ package com.fr.design.gui.icombobox; -import java.awt.*; +import java.awt.Component; +import java.awt.Dimension; -import javax.swing.*; +import javax.swing.DefaultListCellRenderer; +import javax.swing.JLabel; +import javax.swing.JList; import com.fine.theme.utils.FineUIScale; import com.fine.theme.utils.FineUIUtils; import com.formdev.flatlaf.util.ScaledEmptyBorder; -import com.fr.design.constants.UIConstants; /** * diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/other/AutoRefreshPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/other/AutoRefreshPane.java index 4ccdb5bbf1..2f94ab42f7 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/other/AutoRefreshPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/other/AutoRefreshPane.java @@ -1,7 +1,6 @@ package com.fr.van.chart.designer.other; import com.fine.swing.ui.layout.Column; -import com.fine.swing.ui.layout.Row; import com.fine.theme.icon.LazyIcon; import com.fine.theme.utils.FineLayoutBuilder; import com.fine.theme.utils.FineUIConstants; @@ -14,7 +13,6 @@ import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ispinner.UISpinner; -import com.fr.design.i18n.Toolkit; import com.fr.plugin.chart.attr.plot.VanChartPlot; import com.fr.plugin.chart.base.RefreshMoreLabel; import com.fr.plugin.chart.vanchart.VanChart; @@ -30,7 +28,10 @@ import java.awt.Component; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import static com.fine.swing.ui.layout.Layouts.*; +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; /** From 70b5a8415aa0f9f347094d4657ef316c8c54775d Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Wed, 21 Aug 2024 14:28:54 +0800 Subject: [PATCH 5/5] =?UTF-8?q?REPORT-130599=20=E3=80=90FBP=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=BA=90=E3=80=91FR=E8=AE=BE=E8=AE=A1=E5=99=A8?= =?UTF-8?q?=E8=BF=9C=E7=A8=8B66=E7=8E=AF=E5=A2=83=EF=BC=8C=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E6=96=87=E4=BB=B6=E6=95=B0=E6=8D=AE=E9=9B=86=E9=80=89?= =?UTF-8?q?=E6=8B=A9=E6=9C=AC=E5=9C=B0=E6=96=87=E4=BB=B6=EF=BC=8C=E9=A2=84?= =?UTF-8?q?=E8=A7=88=E6=AD=A3=E5=B8=B8=E4=BD=86=E6=B7=BB=E5=8A=A0=E5=A4=B1?= =?UTF-8?q?=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/tabledata/LocalTableDataSource.java | 52 ++++++ .../tabledatapane/FileTableDataPane.java | 2 +- .../java/com/fr/file/FILEChooserPane.java | 45 ++++- .../main/java/com/fr/file/FILEFactory.java | 5 + .../main/java/com/fr/file/FileDataFILE.java | 169 ++++++++++++++++++ .../main/java/com/fr/file/FileNodeFILE.java | 4 +- .../function/DesignDatasourceComponent.java | 3 + 7 files changed, 276 insertions(+), 4 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/design/data/tabledata/LocalTableDataSource.java create mode 100644 designer-base/src/main/java/com/fr/file/FileDataFILE.java 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 new file mode 100644 index 0000000000..bcb717e81a --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/data/tabledata/LocalTableDataSource.java @@ -0,0 +1,52 @@ +package com.fr.design.data.tabledata; + +import com.fanruan.config.impl.data.TableDataConfigProviderFactory; +import com.fr.decision.webservice.bean.entry.FileNodeBean; +import com.fr.decision.webservice.v10.datasource.dataset.processor.impl.FileProcessor; +import com.fr.stable.StringUtils; +import com.fr.workspace.server.repository.tabledata.BaseTableDataSource; + +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +/** + * LocalTableDataSource + * + * @author Destiny.Lin + * @since 11.0 + * Created on 2024/5/29 + */ +public class LocalTableDataSource extends BaseTableDataSource { + @Override + public Set getAllNames(String username) { + Set authServerDataSetNames = new HashSet<>(); + for (String authServerDataSetName : TableDataConfigProviderFactory.getInstance().getTableDatas().keySet()) { + authServerDataSetNames.add(authServerDataSetName); + } + return authServerDataSetNames; + } + + @Override + public boolean lock(String str) { + // 本地默认锁定成功,让其执行后续动作 + return true; + } + + @Override + public boolean unlock(String str) { + // 本地默认解锁成功 + return true; + } + + @Override + public boolean isLock(String str) { + // 本地默认未锁定 + return false; + } + + @Override + public List getFileList(String fileType) { + return FileProcessor.KEY.getFileList(fileType, StringUtils.EMPTY); + } +} diff --git a/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/FileTableDataPane.java b/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/FileTableDataPane.java index 447bb82e50..3ad4c40678 100644 --- a/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/FileTableDataPane.java +++ b/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/FileTableDataPane.java @@ -448,7 +448,7 @@ public class FileTableDataPane extends AbstractTableDataPane { @Override public void actionPerformed(ActionEvent e) { - FILEChooserPane fileChooser = FILEChooserPane.getInstance(true, false, new ChooseFileFilter(getFileSuffix())); + FILEChooserPane fileChooser = FILEChooserPane.getFileDataChoosePane(new ChooseFileFilter(getFileSuffix())); if (fileChooser.showOpenDialog(FileTableDataPane.this) == FILEChooserPane.OK_OPTION) { final FILE file = fileChooser.getSelectedFILE(); if (file == null) {// 选择的文件不能是 null 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 79b8033c42..9d21751c28 100644 --- a/designer-base/src/main/java/com/fr/file/FILEChooserPane.java +++ b/designer-base/src/main/java/com/fr/file/FILEChooserPane.java @@ -8,7 +8,6 @@ import com.fine.theme.utils.FineUIStyle; import com.formdev.flatlaf.ui.FlatUIUtils; import com.formdev.flatlaf.util.ScaledEmptyBorder; import com.fr.base.BaseUtils; -import com.fr.base.FRContext; import com.fr.base.extension.FileExtension; import com.fr.design.DesignerEnvManager; import com.fr.design.ExtraDesignClassManager; @@ -241,6 +240,18 @@ public class FILEChooserPane extends BasicPane { return INSTANCE; } + public static FILEChooserPane getFileDataChoosePane(FILEFilter filter) { + FILEChooserPane chooserPane = new FILEChooserPane(); + chooserPane.showEnv = true; + chooserPane.showLoc = false; + chooserPane.showWebReport = false; + // 替换掉 PlaceListModel + chooserPane.setFileDataPlaceListModel(FileDataFILE.parseType(filter)); + chooserPane.removeAllFilter(); + chooserPane.addChooseFILEFilter(filter, 0); + return chooserPane; + } + /** * @param showEnv @@ -1110,6 +1121,13 @@ public class FILEChooserPane extends BasicPane { setPlaceListModel(new MultiLocalEnvPlaceListModel()); } + protected void setFileDataPlaceListModel(String type) { + if (placesList == null) { + return; + } + setPlaceListModel(new FileDataPlaceListModel(type)); + } + /* * 选中文件 */ @@ -1342,6 +1360,31 @@ public class FILEChooserPane extends BasicPane { } + private class FileDataPlaceListModel extends AbstractPlaceListModel { + private FileDataFILE envFILE; + + 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)) { + @Override + public String getName() { + return getEnvProjectName(); + } + }; + envFILE.setType(type); + } + + @Override + public FILE getElementAt(int index) { + return envFILE; + } + + @Override + public int getSize() { + return 1 + filesOfSystem.size(); + } + + } + private class MultiLocalEnvPlaceListModel extends AbstractPlaceListModel { private static final long serialVersionUID = 6300018896958532154L; 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 d558483784..4d5fe6548d 100644 --- a/designer-base/src/main/java/com/fr/file/FILEFactory.java +++ b/designer-base/src/main/java/com/fr/file/FILEFactory.java @@ -8,6 +8,7 @@ public class FILEFactory { public static final String MEM_PREFIX = "mem://"; 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 WEBREPORT_PREFIX = "webreport://"; public static final String SEPARATOR = "/"; @@ -35,6 +36,8 @@ public class FILEFactory { FileNodeFILE.webRootPath); } 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()), false), false, path.substring(FILE_DATA_PREFIX.length())); } else { return new FileNodeFILE(new FileNode(path, WorkContext.getWorkResource().isDirectory(path))); } @@ -53,6 +56,8 @@ public class FILEFactory { FileNodeFILE.webRootPath); } 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 { return new FileNodeFILE(new FileNode(path, WorkContext.getWorkResource().isDirectory(path))); } diff --git a/designer-base/src/main/java/com/fr/file/FileDataFILE.java b/designer-base/src/main/java/com/fr/file/FileDataFILE.java new file mode 100644 index 0000000000..434faeee03 --- /dev/null +++ b/designer-base/src/main/java/com/fr/file/FileDataFILE.java @@ -0,0 +1,169 @@ +package com.fr.file; + +import com.fr.decision.webservice.bean.entry.FileNodeBean; +import com.fr.file.filetree.FileNode; +import com.fr.file.filter.FILEFilter; +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.workspace.server.repository.tabledata.TableDataRepository; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * FileDataFILE + * + * @author Destiny.Lin + * @since 11.0 + * Created on 2024/8/20 + */ +public class FileDataFILE extends FileNodeFILE{ + public static final String FILE_DATASET_NAME = "file_dataset"; + public static final String TXT = "txt"; + public static final String XML = "xml"; + public static final String EXCEL = "excel"; + private List children = new ArrayList<>(); + private boolean builded = false; + private String id = StringUtils.EMPTY; + private String type = "txt"; + + public FileDataFILE(FileNode node) { + super(node); + } + + public FileDataFILE(FileNode node, boolean builded, String id) { + super(node); + this.builded = builded; + this.id = id; + } + + private void addChild(FileDataFILE 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; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + @Override + public FILE[] listFiles() { + + if (ComparatorUtils.equals(node, null)) { + node = new FileNode(CoreConstants.SEPARATOR, true); + } + if (!node.isDirectory()) { + return new FILE[]{this}; + } + try { + FileDataFILE root = null; + if (!this.builded) { + root = buildTree(); + FileDataFILE dataFILE = root.getFileDataFILE(this.id); + this.setChildren(dataFILE.getChildren()); + this.setType(dataFILE.getType()); + this.builded = true; + } + return this.getChildren().toArray(new FILE[0]); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + return new FILE[0]; + } + } + + @Override + public String prefix() { + return FILEFactory.FILE_DATA_PREFIX; + } + + public FileDataFILE getFileDataFILE(String id) { + if (StringUtils.equals(this.id, id) || StringUtils.equals(StableUtils.pathJoin(this.id, StringUtils.EMPTY), id)) { + return this; + } + for (FileDataFILE file : getChildren()) { + return file.getFileDataFILE(id); + } + return null; + } + + private FileDataFILE buildTree() { + List beans = TableDataRepository.getInstance().getFileList(type); + Map tree = new HashMap<>(); + FileDataFILE root = null; + // id , 父 + for (FileNodeBean bean : beans) { + FileNode fileNode = new FileNode(); + fileNode.setEnvPath(bean.getPath()); + fileNode.setDirectory(bean.getIsParent()); + tree.putIfAbsent(bean.getId(), new FileDataFILE(fileNode, true, bean.getId())); + if (StringUtils.isEmpty(bean.getpId())) { + root = tree.get(bean.getId()); + } else { + tree.putIfAbsent(bean.getpId(), createParent(bean.getpId(), beans)); + FileDataFILE file = tree.get(bean.getpId()); + if (file != null) { + file.addChild(tree.get(bean.getId())); + } + } + } + return root; + } + + private FileDataFILE 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 FileDataFILE(fileNode, true, bean.getId()); + } + } + return null; + } + + + /** + * 获取类型 + */ + public static String parseType(FILEFilter filter) { + if (filter.getDescription().contains("xls")) { + return EXCEL; + } else if (filter.getDescription().contains("xml")) { + return XML; + } else { + return TXT; + } + } +} diff --git a/designer-base/src/main/java/com/fr/file/FileNodeFILE.java b/designer-base/src/main/java/com/fr/file/FileNodeFILE.java index 8d3a7068b7..72570935a9 100644 --- a/designer-base/src/main/java/com/fr/file/FileNodeFILE.java +++ b/designer-base/src/main/java/com/fr/file/FileNodeFILE.java @@ -49,10 +49,10 @@ public class FileNodeFILE implements FILE { } - private FileNode node; + protected FileNode node; //记录下FILE对应的运行环境,每次创建都设置下当前的运行环境 - private String envPath; + protected String envPath; /** * 是否有全部权限 diff --git a/designer-realize/src/main/java/com/fanruan/boot/env/function/DesignDatasourceComponent.java b/designer-realize/src/main/java/com/fanruan/boot/env/function/DesignDatasourceComponent.java index 89588c6430..c098989c22 100644 --- a/designer-realize/src/main/java/com/fanruan/boot/env/function/DesignDatasourceComponent.java +++ b/designer-realize/src/main/java/com/fanruan/boot/env/function/DesignDatasourceComponent.java @@ -28,9 +28,11 @@ import com.fr.decision.webservice.v10.datasource.connection.processor.impl.JDYCo import com.fr.decision.webservice.v10.datasource.connection.processor.impl.JNDIConnectionProcessor; import com.fr.decision.webservice.v10.datasource.dataset.processor.impl.DataSetProcessorFactory; import com.fr.design.data.datapane.connect.LocalConnectionSource; +import com.fr.design.data.tabledata.LocalTableDataSource; import com.fr.file.TableDataConfigWrapper; import com.fr.workspace.server.repository.connection.ConnectionWriterShell; import com.fr.workspace.server.repository.connection.LocalConnectionShell; +import com.fr.workspace.server.repository.tabledata.LocalTableDataShell; /** @@ -57,6 +59,7 @@ public class DesignDatasourceComponent extends DatasourceComponent { ConnectionProcessorFactory.register(JDYConnectionProcessor.KEY); DataSetProcessorFactory.init(); Carina.getApplicationContext().singleton(LocalConnectionShell.class).set(new LocalConnectionSource()); + Carina.getApplicationContext().singleton(LocalTableDataShell.class).set(new LocalTableDataSource()); } /**