Browse Source

Merge remote-tracking branch 'origin/release/11.0' into release/11.0

release/11.0
Maximus 2 years ago
parent
commit
8098bf3c0d
  1. 9
      designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionListPane.java
  2. 4
      designer-base/src/main/java/com/fr/design/file/MultiTemplateTabPane.java
  3. 2
      designer-base/src/main/java/com/fr/design/fun/TemplateThemePaneProvider.java
  4. 24
      designer-base/src/main/java/com/fr/design/gui/controlpane/JControlPane.java
  5. 4
      designer-base/src/main/java/com/fr/design/gui/controlpane/shortcutfactory/ShortCutFactory.java
  6. 25
      designer-chart/src/main/java/com/fr/van/chart/custom/component/VanChartHyperLinkPane.java
  7. 2
      designer-form/src/main/java/com/fr/design/fun/WidgetAdvancedPaneProvider.java
  8. 13
      designer-form/src/main/java/com/fr/design/gui/xpane/FormHyperlinkGroupPane.java
  9. 83
      designer-form/src/main/java/com/fr/design/widget/ui/designer/CheckBoxDefinePane.java
  10. 50
      designer-form/src/main/java/com/fr/design/widget/ui/designer/DateEditorDefinePane.java
  11. 51
      designer-form/src/main/java/com/fr/design/widget/ui/designer/DirectWriteEditorDefinePane.java
  12. 37
      designer-form/src/main/java/com/fr/design/widget/ui/designer/FieldEditorDefinePane.java
  13. 42
      designer-form/src/main/java/com/fr/design/widget/ui/designer/NumberEditorDefinePane.java
  14. 40
      designer-form/src/main/java/com/fr/design/widget/ui/designer/TextFieldEditorDefinePane.java
  15. 43
      designer-form/src/main/java/com/fr/design/widget/ui/designer/btn/ButtonGroupDefinePane.java
  16. 4
      designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java
  17. 28
      designer-realize/src/main/java/com/fr/design/mainframe/ReportHyperlinkGroupPane.java
  18. 49
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java

9
designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionListPane.java

@ -21,8 +21,8 @@ import com.fr.event.EventDispatcher;
import com.fr.file.ConnectionConfig;
import com.fr.file.ConnectionOperator;
import com.fr.general.NameObject;
import com.fr.license.database.BaseDataBaseTypePoint;
import com.fr.license.database.DBTypes;
import com.fr.license.database.DataBaseTypePointManager;
import com.fr.license.exception.DataBaseNotSupportedException;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.ArrayUtils;
@ -279,8 +279,7 @@ public class ConnectionListPane extends JListControlPane implements ConnectionSh
Connection connection = bean.getConnection();
// 仅校验jdbc连接,其他插件数据连接不进行校验
if (connection instanceof JDBCDatabaseConnection) {
BaseDataBaseTypePoint dataBaseTypePoint = BaseDataBaseTypePoint.getDataBaseTypePoint(connection.getDriver(), connection.feature());
DBTypes dataBaseTypePoint = DataBaseTypePointManager.getInstance().getDataBaseTypePoint(connection.getDriver(), connection.feature());
if (connectionIsNotSupported(connection, dataBaseTypePoint)) {
notSupportedConnections.addAll(dataBaseTypePoint.getDataBaseType());
}
@ -296,9 +295,9 @@ public class ConnectionListPane extends JListControlPane implements ConnectionSh
/**
* 校验当前数据连接是否被限制
*/
private static boolean connectionIsNotSupported(Connection connection, BaseDataBaseTypePoint dataBaseTypePoint) {
private static boolean connectionIsNotSupported(Connection connection, DBTypes dataBaseTypePoint) {
return !validateFRDemo(connection.getDriver(), connection.feature()) &&
(dataBaseTypePoint != null && !supportedDatabaseTypes.containsAll(dataBaseTypePoint.getDatabaseType()));
(dataBaseTypePoint != null && !supportedDatabaseTypes.containsAll(dataBaseTypePoint.getDataBaseType()));
}
/**

4
designer-base/src/main/java/com/fr/design/file/MultiTemplateTabPane.java

@ -24,6 +24,7 @@ import com.fr.design.utils.gui.GUIPaintUtils;
import com.fr.design.worker.WorkerManager;
import com.fr.design.worker.save.CallbackSaveWorker;
import com.fr.file.FILE;
import com.fr.file.FileNodeFILE;
import com.fr.general.ComparatorUtils;
import com.fr.general.IOUtils;
import com.fr.log.FineLoggerFactory;
@ -282,7 +283,8 @@ public class MultiTemplateTabPane extends JComponent {
private void locateTemplate(JTemplate<?, ?> template) {
FILE currentTemplate = template.getEditingFILE();
//模板不属于当前环境,跟预览一样先提示保存,再定位模板
if (!currentTemplate.exists()) {
//如果是拖拽进来的模板单单用exist不能判断,这边参考预览的判断逻辑(browserTemplate),补充一下
if (!currentTemplate.exists() || !(currentTemplate instanceof FileNodeFILE)) {
int selVal = showConfirmDialog(
DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Design_Basic_Web_Preview_Message"),

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

@ -20,7 +20,7 @@ public interface TemplateThemePaneProvider<T> extends Mutable {
* 插入tab的位置
*
* @param total 已插入的tab数
* @return 插入位置如果想放到最后则返回-1
* @return 插入位置
*/
int getInsertPosition(int total);

24
designer-base/src/main/java/com/fr/design/gui/controlpane/JControlPane.java

@ -9,10 +9,16 @@ import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.menu.ToolBarDef;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.stable.ArrayUtils;
import com.fr.stable.Filter;
import com.fr.stable.Nameable;
import javax.swing.*;
import java.awt.*;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.JSplitPane;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.util.Arrays;
import java.util.stream.Stream;
/**
* Coder: zack
@ -27,6 +33,8 @@ abstract class JControlPane extends BasicPane implements UnrepeatedNameHelper, S
ShortCut4JControlPane[] shorts;
NameableCreator[] creators;
protected Filter<NameableCreator> creatorsFilter;
private ToolBarDef toolbarDef;
UIToolbar toolBar;
@ -38,6 +46,7 @@ abstract class JControlPane extends BasicPane implements UnrepeatedNameHelper, S
JControlPane() {
this.initShortCutFactory();
this.initCreatorsFilter();
this.initComponentPane();
}
@ -106,6 +115,10 @@ abstract class JControlPane extends BasicPane implements UnrepeatedNameHelper, S
this.checkButtonEnabled();
}
protected void initCreatorsFilter() {
this.creatorsFilter = nameableCreator -> true;
}
protected void initCardPane() {
this.controlUpdatePane = createControlUpdatePane();
@ -183,7 +196,12 @@ abstract class JControlPane extends BasicPane implements UnrepeatedNameHelper, S
}
public NameableCreator[] creators() {
return creators == null ? new NameableCreator[0] : creators;
if (creators == null) {
return new NameableCreator[0];
} else {
Stream<NameableCreator> nameableCreatorStream = Arrays.stream(creators).filter(creator -> creatorsFilter.accept(creator));
return nameableCreatorStream.toArray(NameableCreator[]::new);
}
}
/**

4
designer-base/src/main/java/com/fr/design/gui/controlpane/shortcutfactory/ShortCutFactory.java

@ -142,10 +142,6 @@ public class ShortCutFactory extends AbstractShortCutFactory {
private void wrapActionListener(NameableCreator[] creators) {
for (final NameableCreator creator : creators) {
Filter<Class<? extends JavaScript>> filter = DesignModuleFactory.getHyperlinkGroupType().getFilter();
if (!filter.accept(creator.getHyperlink())) {
continue;
}
boolean isTrue = ComparatorUtils.equals(creator.menuName(), com.fr.design.i18n.Toolkit.i18nText("Datasource-Stored_Procedure")) ||
ComparatorUtils.equals(creator.menuName(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_DS_Relation_TableData")) || ComparatorUtils.equals(creator.menuName(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_DS_Multi_Dimensional_Database"));
if (isTrue) {

25
designer-chart/src/main/java/com/fr/van/chart/custom/component/VanChartHyperLinkPane.java

@ -14,6 +14,7 @@ import com.fr.design.chart.series.SeriesCondition.impl.ChartHyperRelateCellLinkP
import com.fr.design.chart.series.SeriesCondition.impl.ChartHyperRelateFloatLinkPane;
import com.fr.design.chart.series.SeriesCondition.impl.FormHyperlinkPane;
import com.fr.design.designer.TargetComponent;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.fun.HyperlinkProvider;
import com.fr.design.gui.controlpane.NameObjectCreator;
import com.fr.design.gui.controlpane.NameableCreator;
@ -22,7 +23,10 @@ import com.fr.design.hyperlink.ReportletHyperlinkPane;
import com.fr.design.hyperlink.WebHyperlinkPane;
import com.fr.design.javascript.JavaScriptImplPane;
import com.fr.design.javascript.ParameterJavaScriptPane;
import com.fr.design.mainframe.BaseJForm;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.module.DesignModuleFactory;
import com.fr.general.ComparatorUtils;
import com.fr.general.NameObject;
import com.fr.js.EmailJavaScript;
import com.fr.js.FormHyperlinkProvider;
@ -297,5 +301,24 @@ public class VanChartHyperLinkPane extends VanChartUIListControlPane {
}
}
@Override
protected void initCreatorsFilter() {
this.creatorsFilter = nameableCreator -> {
Class<? extends JavaScript> clazz = nameableCreator.getHyperlink();
JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (!JTemplate.isValid(template)) {
return false;
}
Class[] classes = new Class[]{ChartHyperRelateCellLink.class, ChartHyperRelateFloatLink.class};
for (Class aClass : classes) {
if (template.getEditingReportIndex() == BaseJForm.FORM_TAB) {
// 编辑的是决策报表中的图表,那么没有ChartHyperRelateFloatLink 和 ChartHyperRelateCellLink 选项,有FormHyperlink 选项
if (ComparatorUtils.equals(aClass, clazz)) {
return false;
}
}
}
return true;
};
}
}

2
designer-form/src/main/java/com/fr/design/fun/WidgetAdvancedPaneProvider.java

@ -21,7 +21,7 @@ public interface WidgetAdvancedPaneProvider<T> extends Mutable {
* 获取插入的位置
*
* @param total 已插入的面板数
* @return 插入位置如果想放到最后则返回-1
* @return 插入位置
*/
int getInsertPosition(int total);

13
designer-form/src/main/java/com/fr/design/gui/xpane/FormHyperlinkGroupPane.java

@ -1,13 +1,14 @@
package com.fr.design.gui.xpane;
import com.fr.chart.web.ChartHyperRelateFloatLink;
import com.fr.design.form.javascript.FormEmailPane;
import com.fr.design.gui.controlpane.NameObjectCreator;
import com.fr.design.gui.controlpane.NameableCreator;
import com.fr.design.gui.frpane.HyperlinkGroupPane;
import com.fr.design.gui.frpane.HyperlinkGroupPaneActionProvider;
import com.fr.general.ComparatorUtils;
import com.fr.js.EmailJavaScript;
import com.fr.js.JavaScript;
public class FormHyperlinkGroupPane extends HyperlinkGroupPane {
private static FormHyperlinkGroupPane singleton;
@ -23,6 +24,16 @@ public class FormHyperlinkGroupPane extends HyperlinkGroupPane {
return singleton;
}
@Override
protected void initCreatorsFilter() {
this.creatorsFilter = nameableCreator -> {
Class<? extends JavaScript> clazz = nameableCreator.getHyperlink();
// 决策报表没有 ChartHyperRelateFloatLink
return !ComparatorUtils.equals(clazz, ChartHyperRelateFloatLink.class);
};
}
/**
* 生成添加按钮的NameableCreator
* 由于表单报表块的单元格超链和单元格条件属性超链中的emailPane都要用表单的emailPane这里调整下

83
designer-form/src/main/java/com/fr/design/widget/ui/designer/CheckBoxDefinePane.java

@ -1,8 +1,11 @@
package com.fr.design.widget.ui.designer;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.designer.IntervalConstants;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.foldablepane.UIExpandablePane;
import com.fr.design.fun.WidgetAdvancedPaneProvider;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.layout.FRGUIPaneFactory;
@ -11,18 +14,28 @@ import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.widget.ui.designer.component.FontSizeComboPane;
import com.fr.design.widget.ui.designer.component.FormWidgetValuePane;
import com.fr.form.ui.CheckBox;
import com.fr.general.GeneralContext;
import com.fr.plugin.observer.PluginEvent;
import com.fr.plugin.observer.PluginEventListener;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import java.awt.Component;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
public class CheckBoxDefinePane extends AbstractDataModify<CheckBox> {
private UITextField text;
private FontSizeComboPane fontSizePane;
private FormWidgetValuePane formWidgetValuePane;
protected UITextField labelNameTextField;
protected final List<BasicBeanPane<CheckBox>> extraPaneList = new ArrayList<>();
protected JPanel extraPane;
protected static double F = TableLayout.FILL;
protected static double P = TableLayout.PREFERRED;
public CheckBoxDefinePane(XCreator xCreator) {
super(xCreator);
@ -37,16 +50,15 @@ public class CheckBoxDefinePane extends AbstractDataModify<CheckBox> {
UILabel widgetValueLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Estate_Widget_Value"));
widgetValueLabel.setVerticalAlignment(SwingConstants.TOP);
formWidgetValuePane = new FormWidgetValuePane(creator.toData(), false);
double f = TableLayout.FILL;
double p = TableLayout.PREFERRED;
initExtraPane();
Component[][] components = new Component[][]{
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Label_Name")), labelNameTextField},
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Text")), text },
new Component[]{widgetValueLabel, formWidgetValuePane },
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Font_Size")), fontSizePane},
new Component[]{extraPane, null},
};
double[] rowSize = {p, p, p, p, p, p};
double[] columnSize = {p, f};
double[] rowSize = {P, P, P, P, P, P};
double[] columnSize = {P, F};
int[][] rowCount = {{1, 1},{1, 1}, {1, 3},{1, 1}};
JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, IntervalConstants.INTERVAL_W1, IntervalConstants.INTERVAL_L1);
JPanel boundsPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
@ -56,6 +68,59 @@ public class CheckBoxDefinePane extends AbstractDataModify<CheckBox> {
this.add(uiExpandablePane);
}
protected void initExtraPane() {
initPluginListener();
refreshExtraAdvancedPane();
}
protected void refreshExtraAdvancedPane() {
extraPaneList.clear();
boolean containsExtraPane = false;
Set<WidgetAdvancedPaneProvider<CheckBox>> providers = ExtraDesignClassManager.getInstance().getArray(WidgetAdvancedPaneProvider.XML_TAG);
for (WidgetAdvancedPaneProvider<CheckBox> provider : providers) {
if (!provider.accept(creator)) {
continue;
}
insertShortCut(provider.getInsertPosition(extraPaneList.size()), provider.createExtraAdvancedPane());
containsExtraPane = true;
}
if (containsExtraPane) {
extraPane = FRGUIPaneFactory.createYBoxEmptyBorderPane();
for (BasicBeanPane<CheckBox> pane : extraPaneList) {
extraPane.add(pane);
}
} else {
Component[][] components = new Component[][]{
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Font_Size")), fontSizePane}
};
double[] rowSize = {P};
double[] columnSize = {P, F};
int[][] rowCount = {{1, 1}};
extraPane = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, IntervalConstants.INTERVAL_W1, IntervalConstants.INTERVAL_L1);
}
}
protected void initPluginListener() {
GeneralContext.listenPluginRunningChanged(new PluginEventListener() {
@Override
public void on(PluginEvent event) {
refreshExtraAdvancedPane();
}
}, pluginContext -> pluginContext.getRuntime().contain(WidgetAdvancedPaneProvider.XML_TAG));
}
/**
* 插入配置项面板
*
* @param index 插入的位置
* @param pane 配置项面板
*/
protected void insertShortCut(int index, BasicBeanPane<CheckBox> pane) {
int size = extraPaneList.size();
index = Math.min(index, size);
extraPaneList.add(index, pane);
}
@Override
public String title4PopupWindow() {
@ -68,6 +133,9 @@ public class CheckBoxDefinePane extends AbstractDataModify<CheckBox> {
fontSizePane.setValue(check.getFontSize());
formWidgetValuePane.populate(check);
labelNameTextField.setText(check.getLabelName());
for (BasicBeanPane<CheckBox> pane : extraPaneList) {
pane.populateBean(check);
}
}
@Override
@ -77,6 +145,9 @@ public class CheckBoxDefinePane extends AbstractDataModify<CheckBox> {
box.setFontSize(fontSizePane.getValue());
formWidgetValuePane.update(box);
box.setLabelName(labelNameTextField.getText());
for (BasicBeanPane<CheckBox> pane : extraPaneList) {
pane.updateBean(box);
}
return box;
}
}

50
designer-form/src/main/java/com/fr/design/widget/ui/designer/DateEditorDefinePane.java

@ -2,15 +2,17 @@ package com.fr.design.widget.ui.designer;
import com.fr.base.FRContext;
import com.fr.data.core.FormatField;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.border.UIRoundedBorder;
import com.fr.design.constants.UIConstants;
import com.fr.design.designer.IntervalConstants;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.fun.WidgetAdvancedPaneProvider;
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.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.widget.component.DateValuePane;
import com.fr.design.widget.component.UIComboBoxNoArrow;
@ -18,18 +20,23 @@ import com.fr.design.widget.ui.designer.component.FormWidgetValuePane;
import com.fr.design.widget.ui.designer.date.DateFormatCheckManager;
import com.fr.design.widget.ui.designer.date.DateFormatCheckResult;
import com.fr.form.ui.DateEditor;
import com.fr.stable.ArrayUtils;
import javax.swing.*;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import javax.swing.border.TitledBorder;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.*;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Set;
public class DateEditorDefinePane extends DirectWriteEditorDefinePane<DateEditor> {
private UIButtonGroup returnTypeComboBox;
@ -68,8 +75,7 @@ public class DateEditorDefinePane extends DirectWriteEditorDefinePane<DateEditor
JPanel formatHead = createFormatHead();
startDv = new DateValuePane();
endDv = new DateValuePane();
double f = TableLayout.FILL;
double p = TableLayout.PREFERRED;
initExtraPane();
Component[][] components = new Component[][]{
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Label_Name")), labelNameTextField},
new Component[]{widgetValueLabel, formWidgetValuePane},
@ -77,12 +83,12 @@ public class DateEditorDefinePane extends DirectWriteEditorDefinePane<DateEditor
new Component[]{startDateLabel, startDv},
new Component[]{endDateLabel, endDv},
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_WaterMark")), waterMarkDictPane},
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Font_Size")), fontSizePane},
new Component[]{extraPane, null},
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Widget_Date_Selector_Return_Type")), returnTypeComboBox}
};
double[] rowSize = {p, p, p, p, p, p, p, p, p, p};
double[] columnSize = {p, f};
double[] rowSize = {P, P, P, P, P, P, P, P, P, P};
double[] columnSize = {P, F};
int[][] rowCount = {{1, 1}, {1, 3}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}};
JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, IntervalConstants.INTERVAL_L2, IntervalConstants.INTERVAL_L1);
JPanel boundsPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
@ -90,6 +96,32 @@ public class DateEditorDefinePane extends DirectWriteEditorDefinePane<DateEditor
return boundsPane;
}
protected void refreshExtraAdvancedPane() {
extraPaneList.clear();
boolean containsExtraPane = false;
Set<WidgetAdvancedPaneProvider<DateEditor>> providers = ExtraDesignClassManager.getInstance().getArray(WidgetAdvancedPaneProvider.XML_TAG);
for (WidgetAdvancedPaneProvider<DateEditor> provider : providers) {
if (!provider.accept(creator)) {
continue;
}
insertShortCut(provider.getInsertPosition(extraPaneList.size()), provider.createExtraAdvancedPane());
containsExtraPane = true;
}
if (containsExtraPane) {
extraPane = FRGUIPaneFactory.createYBoxEmptyBorderPane();
for (BasicBeanPane<DateEditor> pane : extraPaneList) {
extraPane.add(pane);
}
} else {
Component[][] components = new Component[][]{
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Font_Size")), fontSizePane},
};
double[] rowSize = {P};
double[] columnSize = {P, F};
int[][] rowCount = {{1, 1}};
extraPane = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, IntervalConstants.INTERVAL_W1, IntervalConstants.INTERVAL_L1);
}
}
private JPanel createFormatPane(UIComboBox formatComboBox, UILabel sampleLabel){
JPanel previewPane = FRGUIPaneFactory.createBorderLayout_S_Pane();

51
designer-form/src/main/java/com/fr/design/widget/ui/designer/DirectWriteEditorDefinePane.java

@ -1,19 +1,26 @@
package com.fr.design.widget.ui.designer;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.designer.IntervalConstants;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.fun.WidgetAdvancedPaneProvider;
import com.fr.design.gui.icheckbox.UICheckBox;
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.design.widget.ui.designer.component.FormWidgetValuePane;
import com.fr.form.ui.DirectWriteEditor;
import javax.swing.*;
import java.awt.*;
import javax.swing.BorderFactory;
import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.FlowLayout;
import java.util.Set;
//richer:需要提供能否直接编辑的控件设置面板——下拉框、复选框、时间、日期、下拉树
public abstract class DirectWriteEditorDefinePane<T extends DirectWriteEditor> extends FieldEditorDefinePane<T> {
@ -34,18 +41,17 @@ public abstract class DirectWriteEditorDefinePane<T extends DirectWriteEditor> e
Component[] removeRepeatPane = new Component[]{createRepeatCheckBox(), null};
Component[] dicPane = createDictPane();
Component[] waterMarkComponent = createWaterMarkPane();
double f = TableLayout.FILL;
double p = TableLayout.PREFERRED;
initExtraPane();
Component[][] components = new Component[][]{
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Label_Name")), labelNameTextField},
new Component[]{widgetValueLabel, formWidgetValuePane },
dicPane,
removeRepeatPane,
waterMarkComponent,
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Font_Size")), fontSizePane}
new Component[]{extraPane, null}
};
double[] rowSize = {p, p, p, p, p, p, p, p};
double[] columnSize = {p, f};
double[] rowSize = {P, P, P, P, P, P, P, P};
double[] columnSize = {P, F};
int[][] rowCount = {{1, 1},{1, 3},{1, 1},{1, 1},{1,1},{1,1}};
JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, IntervalConstants.INTERVAL_W1, IntervalConstants.INTERVAL_L1);
// panel.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0));
@ -58,6 +64,33 @@ public abstract class DirectWriteEditorDefinePane<T extends DirectWriteEditor> e
return advancePane;
}
protected void refreshExtraAdvancedPane() {
extraPaneList.clear();
boolean containsExtraPane = false;
Set<WidgetAdvancedPaneProvider<T>> providers = ExtraDesignClassManager.getInstance().getArray(WidgetAdvancedPaneProvider.XML_TAG);
for (WidgetAdvancedPaneProvider<T> provider : providers) {
if (!provider.accept(creator)) {
continue;
}
insertShortCut(provider.getInsertPosition(extraPaneList.size()), provider.createExtraAdvancedPane());
containsExtraPane = true;
}
if (containsExtraPane) {
extraPane = FRGUIPaneFactory.createYBoxEmptyBorderPane();
for (BasicBeanPane<T> pane : extraPaneList) {
extraPane.add(pane);
}
} else {
Component[][] components = new Component[][]{
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Font_Size")), fontSizePane}
};
double[] rowSize = {P};
double[] columnSize = {P, F};
int[][] rowCount = {{1, 1}};
extraPane = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, IntervalConstants.INTERVAL_W1, IntervalConstants.INTERVAL_L1);
}
}
public UICheckBox createRepeatCheckBox(){
return null;
}

37
designer-form/src/main/java/com/fr/design/widget/ui/designer/FieldEditorDefinePane.java

@ -18,6 +18,7 @@ import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.widget.ui.designer.component.FontSizeComboPane;
import com.fr.form.ui.FieldEditor;
@ -34,7 +35,6 @@ import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
public abstract class FieldEditorDefinePane<T extends FieldEditor> extends AbstractDataModify<T> {
protected UICheckBox allowBlankCheckBox;
@ -43,8 +43,11 @@ public abstract class FieldEditorDefinePane<T extends FieldEditor> extends Abstr
protected JPanel validatePane;
protected FontSizeComboPane fontSizePane;
protected UITextField labelNameTextField;
private final List<BasicBeanPane<T>> extraPaneList = new ArrayList<>();
private JPanel extraPane;
protected final List<BasicBeanPane<T>> extraPaneList = new ArrayList<>();
protected JPanel extraPane;
protected static double F = TableLayout.FILL;
protected static double P = TableLayout.PREFERRED;
public FieldEditorDefinePane(XCreator xCreator) {
super(xCreator);
@ -58,11 +61,8 @@ public abstract class FieldEditorDefinePane<T extends FieldEditor> extends Abstr
allowBlankCheckBox.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
fontSizePane = new FontSizeComboPane();
JPanel contentPane = this.setFirstContentPane();
JPanel jPanel = FRGUIPaneFactory.createYBoxEmptyBorderPane();
jPanel.add(contentPane);
extraPane = FRGUIPaneFactory.createYBoxEmptyBorderPane();
jPanel.add(extraPane);
this.initExtraPane();
JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane();
jPanel.add(contentPane, BorderLayout.CENTER);
contentPane.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0));
if (contentPane != null) {
UIExpandablePane uiExpandablePane = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Advanced"), 280, 20, jPanel);
@ -71,24 +71,13 @@ public abstract class FieldEditorDefinePane<T extends FieldEditor> extends Abstr
this.addValidatePane();
}
private void initExtraPane() {
protected void initExtraPane() {
initPluginListener();
refreshExtraAdvancedPane();
}
private void refreshExtraAdvancedPane() {
extraPaneList.clear();
extraPane.removeAll();
Set<WidgetAdvancedPaneProvider<T>> providers = ExtraDesignClassManager.getInstance().getArray(WidgetAdvancedPaneProvider.XML_TAG);
for (WidgetAdvancedPaneProvider<T> provider : providers) {
if (!provider.accept(creator)) {
continue;
}
insertShortCut(provider.getInsertPosition(extraPaneList.size()), provider.createExtraAdvancedPane());
}
for (BasicBeanPane<T> pane : extraPaneList) {
extraPane.add(pane);
}
protected void refreshExtraAdvancedPane() {
// do nothing
}
@Override
@ -196,13 +185,13 @@ public abstract class FieldEditorDefinePane<T extends FieldEditor> extends Abstr
* @param index 插入的位置
* @param pane 配置项面板
*/
private void insertShortCut(int index, BasicBeanPane<T> pane) {
protected void insertShortCut(int index, BasicBeanPane<T> pane) {
int size = extraPaneList.size();
index = Math.min(index, size);
extraPaneList.add(index, pane);
}
private void initPluginListener() {
protected void initPluginListener() {
GeneralContext.listenPluginRunningChanged(new PluginEventListener() {
@Override
public void on(PluginEvent event) {

42
designer-form/src/main/java/com/fr/design/widget/ui/designer/NumberEditorDefinePane.java

@ -1,7 +1,10 @@
package com.fr.design.widget.ui.designer;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.designer.IntervalConstants;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.fun.WidgetAdvancedPaneProvider;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.ispinner.UIBasicSpinner;
import com.fr.design.layout.FRGUIPaneFactory;
@ -11,9 +14,12 @@ import com.fr.design.widget.component.NumberEditorValidatePane;
import com.fr.design.widget.ui.designer.component.FormWidgetValuePane;
import com.fr.form.ui.NumberEditor;
import javax.swing.*;
import java.awt.*;
import javax.swing.JComponent;
import javax.swing.JFormattedTextField;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import java.awt.Component;
import java.util.Set;
public class NumberEditorDefinePane extends FieldEditorDefinePane<NumberEditor> {
public NumberEditorDefinePane(XCreator xCreator){
@ -43,11 +49,12 @@ public class NumberEditorDefinePane extends FieldEditorDefinePane<NumberEditor>
formWidgetValuePane = new FormWidgetValuePane(creator.toData(), false);
double f = TableLayout.FILL;
double p = TableLayout.PREFERRED;
initExtraPane();
Component[][] components = new Component[][]{
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Label_Name")), labelNameTextField},
new Component[]{widgetValueLabel, formWidgetValuePane},
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_WaterMark")), waterMarkDictPane},
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Font_Size")), fontSizePane}
new Component[]{extraPane, null}
};
double[] rowSize = {p, p, p, p, p, p};
double[] columnSize = {p,f};
@ -58,6 +65,33 @@ public class NumberEditorDefinePane extends FieldEditorDefinePane<NumberEditor>
return boundsPane;
}
protected void refreshExtraAdvancedPane() {
extraPaneList.clear();
boolean containsExtraPane = false;
Set<WidgetAdvancedPaneProvider<NumberEditor>> providers = ExtraDesignClassManager.getInstance().getArray(WidgetAdvancedPaneProvider.XML_TAG);
for (WidgetAdvancedPaneProvider<NumberEditor> provider : providers) {
if (!provider.accept(creator)) {
continue;
}
insertShortCut(provider.getInsertPosition(extraPaneList.size()), provider.createExtraAdvancedPane());
containsExtraPane = true;
}
if (containsExtraPane) {
extraPane = FRGUIPaneFactory.createYBoxEmptyBorderPane();
for (BasicBeanPane<NumberEditor> pane : extraPaneList) {
extraPane.add(pane);
}
} else {
Component[][] components = new Component[][]{
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Font_Size")), fontSizePane}
};
double[] rowSize = {P};
double[] columnSize = {P, F};
int[][] rowCount = {{1, 1}};
extraPane = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, IntervalConstants.INTERVAL_W1, IntervalConstants.INTERVAL_L1);
}
}
public JPanel setValidatePane() {
numberEditorValidatePane = new NumberEditorValidatePane();
return numberEditorValidatePane;

40
designer-form/src/main/java/com/fr/design/widget/ui/designer/TextFieldEditorDefinePane.java

@ -1,15 +1,16 @@
package com.fr.design.widget.ui.designer;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.designer.IntervalConstants;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.fun.RegPaneProvider;
import com.fr.design.fun.WidgetAdvancedPaneProvider;
import com.fr.design.gui.frpane.RegFieldPane;
import com.fr.design.gui.frpane.RegPane;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.widget.ui.designer.component.FormWidgetValuePane;
import com.fr.form.ui.TextEditor;
@ -21,6 +22,7 @@ import javax.swing.SwingConstants;
import java.awt.Component;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.util.Set;
public class TextFieldEditorDefinePane extends FieldEditorDefinePane<TextEditor> {
protected RegFieldPane regPane;
@ -63,18 +65,17 @@ public class TextFieldEditorDefinePane extends FieldEditorDefinePane<TextEditor>
});
formWidgetValuePane = new FormWidgetValuePane(creator.toData(), false);
double f = TableLayout.FILL;
double p = TableLayout.PREFERRED;
UILabel widgetValueLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Estate_Widget_Value"), SwingConstants.LEFT);
widgetValueLabel.setVerticalAlignment(SwingConstants.TOP);
initExtraPane();
Component[][] components = new Component[][]{
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Label_Name")), labelNameTextField},
new Component[]{widgetValueLabel, formWidgetValuePane},
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_WaterMark"), SwingConstants.LEFT), waterMarkDictPane},
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Font_Size"), SwingConstants.LEFT), fontSizePane}
new Component[]{extraPane, null}
};
double[] rowSize = {p, p, p, p, p, p};
double[] columnSize = {p, f};
double[] rowSize = {P, P, P, P, P};
double[] columnSize = {P, F};
int[][] rowCount = {{1, 1}, {1, 3}, {1, 1}, {1, 1}};
final JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, IntervalConstants.INTERVAL_W1, IntervalConstants.INTERVAL_L1);
JPanel boundsPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
@ -82,6 +83,33 @@ public class TextFieldEditorDefinePane extends FieldEditorDefinePane<TextEditor>
return boundsPane;
}
protected void refreshExtraAdvancedPane() {
extraPaneList.clear();
boolean containsExtraPane = false;
Set<WidgetAdvancedPaneProvider<TextEditor>> providers = ExtraDesignClassManager.getInstance().getArray(WidgetAdvancedPaneProvider.XML_TAG);
for (WidgetAdvancedPaneProvider<TextEditor> provider : providers) {
if (!provider.accept(creator)) {
continue;
}
insertShortCut(provider.getInsertPosition(extraPaneList.size()), provider.createExtraAdvancedPane());
containsExtraPane = true;
}
if (containsExtraPane) {
extraPane = FRGUIPaneFactory.createYBoxEmptyBorderPane();
for (BasicBeanPane<TextEditor> pane : extraPaneList) {
extraPane.add(pane);
}
} else {
Component[][] components = new Component[][]{
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Font_Size"), SwingConstants.LEFT), fontSizePane}
};
double[] rowSize = {P};
double[] columnSize = {P, F};
int[][] rowCount = {{1, 1}};
extraPane = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, IntervalConstants.INTERVAL_W1, IntervalConstants.INTERVAL_L1);
}
}
public JPanel setValidatePane() {
return regPane;
}

43
designer-form/src/main/java/com/fr/design/widget/ui/designer/btn/ButtonGroupDefinePane.java

@ -1,8 +1,11 @@
package com.fr.design.widget.ui.designer.btn;
import com.fr.data.Dictionary;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.designer.IntervalConstants;
import com.fr.design.designer.creator.*;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.fun.WidgetAdvancedPaneProvider;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout;
@ -13,9 +16,11 @@ import com.fr.design.widget.ui.designer.FieldEditorDefinePane;
import com.fr.design.widget.ui.designer.component.FormWidgetValuePane;
import com.fr.form.ui.ButtonGroup;
import javax.swing.*;
import java.awt.*;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import java.awt.BorderLayout;
import java.awt.Component;
import java.util.Set;
/**
* Created by ibm on 2017/8/5.
@ -40,11 +45,12 @@ public abstract class ButtonGroupDefinePane<T extends ButtonGroup> extends Field
formWidgetValuePane = new FormWidgetValuePane(creator.toData(), false);
double f = TableLayout.FILL;
double p = TableLayout.PREFERRED;
initExtraPane();
Component[][] components = new Component[][]{
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Label_Name")), labelNameTextField},
new Component[]{widgetValueLabel, formWidgetValuePane},
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_DS_Dictionary")), dictionaryEditor},
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Font_Size")), fontSizePane},
new Component[]{extraPane, null},
new Component[]{buttonGroupDictPane, null}
};
double[] rowSize = {p, p, p, p, p, p, p};
@ -60,6 +66,33 @@ public abstract class ButtonGroupDefinePane<T extends ButtonGroup> extends Field
return advancePane;
}
protected void refreshExtraAdvancedPane() {
extraPaneList.clear();
boolean containsExtraPane = false;
Set<WidgetAdvancedPaneProvider<T>> providers = ExtraDesignClassManager.getInstance().getArray(WidgetAdvancedPaneProvider.XML_TAG);
for (WidgetAdvancedPaneProvider<T> provider : providers) {
if (!provider.accept(creator)) {
continue;
}
insertShortCut(provider.getInsertPosition(extraPaneList.size()), provider.createExtraAdvancedPane());
containsExtraPane = true;
}
if (containsExtraPane) {
extraPane = FRGUIPaneFactory.createYBoxEmptyBorderPane();
for (BasicBeanPane<T> pane : extraPaneList) {
extraPane.add(pane);
}
} else {
Component[][] components = new Component[][]{
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Font_Size")), fontSizePane}
};
double[] rowSize = {P};
double[] columnSize = {P, F};
int[][] rowCount = {{1, 1}};
extraPane = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, IntervalConstants.INTERVAL_W1, IntervalConstants.INTERVAL_L1);
}
}
public JPanel createOtherPane() {
return null;
}

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

@ -1311,7 +1311,9 @@ public class JWorkBook extends JTemplate<WorkBook, WorkBookUndoState> {
boolean shouldCreateUndoState = compatible == TemplateThemeCompatible.NONE && !StringUtils.equals(oldTheme.getName(), newTheme.getName());
getTarget().setTemplateTheme(newTheme, compatible);
getTarget().getReportParameterAttr().onTemplateUsingThemeChange(newTheme, compatible);
if (getTarget().getReportParameterAttr() != null) {
getTarget().getReportParameterAttr().onTemplateUsingThemeChange(newTheme, compatible);
}
setTarget((WorkBook) FineColorSynchronizer.flush(getTarget(), newTheme, compatible));
if (HistoryTemplateListCache.getInstance().getCurrentEditingTemplate() == this) {

28
designer-realize/src/main/java/com/fr/design/mainframe/ReportHyperlinkGroupPane.java

@ -1,21 +1,11 @@
package com.fr.design.mainframe;
import com.fr.base.Style;
import com.fr.design.actions.utils.ReportActionUtils;
import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.gui.frpane.HyperlinkGroupPane;
import com.fr.design.gui.frpane.HyperlinkGroupPaneActionProvider;
import com.fr.general.FRFont;
import com.fr.grid.selection.CellSelection;
import com.fr.grid.selection.FloatSelection;
import com.fr.grid.selection.Selection;
import com.fr.js.NameJavaScriptGroup;
import com.fr.report.cell.CellElement;
import com.fr.report.cell.FloatElement;
import com.fr.report.elementcase.TemplateElementCase;
import com.fr.stable.Constants;
import java.awt.*;
import com.fr.general.ComparatorUtils;
import com.fr.js.FormHyperlinkProvider;
import com.fr.stable.bridge.StableFactory;
/**
* Created by plough on 2017/7/21.
@ -37,10 +27,20 @@ public class ReportHyperlinkGroupPane extends HyperlinkGroupPane {
}
protected void refreshPane() {
ElementCasePane reportPane = ((JWorkBook)HistoryTemplateListPane.getInstance().getCurrentEditingTemplate()).getEditingElementCasePane();
ElementCasePane reportPane = ((JWorkBook) HistoryTemplateListPane.getInstance().getCurrentEditingTemplate()).getEditingElementCasePane();
if (reportPane == null) {
return;
}
populate(reportPane);
}
@Override
protected void initCreatorsFilter() {
this.creatorsFilter = nameableCreator -> {
// 如果是普通报表单元格,那么没有 FormHyperlink 选项
FormHyperlinkProvider formHyperlink = StableFactory.getMarkedInstanceObjectFromClass(FormHyperlinkProvider.XML_TAG, FormHyperlinkProvider.class);
return !ComparatorUtils.equals(nameableCreator.getHyperlink(), formHyperlink.getClass());
};
}
}

49
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java

@ -20,6 +20,7 @@ import com.fr.plugin.basic.version.Version;
import com.fr.plugin.basic.version.VersionIntervalFactory;
import com.fr.stable.ArrayUtils;
import com.fr.stable.EncodeConstants;
import com.fr.stable.ProductConstants;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
@ -29,7 +30,7 @@ import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.function.ToLongFunction;
import java.util.stream.Collectors;
/**
* Created by XiaXiang on 2017/3/27.
@ -120,7 +121,7 @@ public class PluginSearchManager implements AlphaFineSearchProvider {
return lessModelList;
}
SearchResult noConnectList = AlphaFineHelper.getNoConnectList(Holder.INSTANCE);
if(noConnectList != null){
if (noConnectList != null) {
return noConnectList;
}
for (int j = 0; j < searchText.length; j++) {
@ -184,7 +185,7 @@ public class PluginSearchManager implements AlphaFineSearchProvider {
List<PluginModel> pluginModels = new ArrayList<>();
pluginModels.addAll(parseDefaultPluginModel(plugins));
pluginModels.forEach(m->this.defaultModelList.add(m));
pluginModels.forEach(m -> this.defaultModelList.add(m));
} catch (Exception e) {
FineLoggerFactory.getLogger().error("plugin search error :" + e.getMessage());
@ -196,33 +197,31 @@ public class PluginSearchManager implements AlphaFineSearchProvider {
/**
* 将jsonobject转化为PluginModel
* 并按照更新时间排序取最新的10个
* */
* 并按照更新时间排序取最新的10个并过滤掉不是当前版本的
*/
List<PluginModel> parseDefaultPluginModel(List<Map> jsonObjects) {
List<PluginModel> pluginModels = new ArrayList<>();
String version = "v" + ProductConstants.MAIN_VERSION;
if (!Collections.isEmpty(jsonObjects)) {
SimpleDateFormat format = new SimpleDateFormat(TIME_FORMAT);
try {
jsonObjects.sort(Comparator.comparingLong(new ToLongFunction<Map>() {
@Override
public long applyAsLong(Map value) {
long time = 0L;
try {
time = format.parse((String) value.get(UPLOAD_TIME)).getTime();
} catch (ParseException e) {
FineLoggerFactory.getLogger().error(e, e.getMessage());
}
return time;
}
}).reversed());
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e, e.getMessage());
}
for (int i = 0; i < DEFAULT_LIST_SIZE; i++) {
pluginModels.add(getPluginModel(new JSONObject(jsonObjects.get(i)), false));
}
pluginModels = jsonObjects.stream()
.filter(o -> ((Integer) o.get(version)) == 1)
.sorted((Map map1, Map map2) -> Long.compare(parseTime(map2), parseTime(map1)))
.limit(DEFAULT_LIST_SIZE)
.map(jsonObject -> getPluginModel(new JSONObject(jsonObject), false))
.collect(Collectors.toList());
}
return pluginModels;
}
private static long parseTime(Map value) {
SimpleDateFormat format = new SimpleDateFormat(TIME_FORMAT);
long t = 0L;
try {
t = format.parse((String) value.get(UPLOAD_TIME)).getTime();
} catch (ParseException e) {
FineLoggerFactory.getLogger().error(e, e.getMessage());
}
return t;
}
}

Loading…
Cancel
Save