Browse Source

Merge branch 'final/10.0' into persist/10.0

persist/10.0
jeo 5 years ago
parent
commit
2d9d795a84
  1. 5
      designer-base/src/main/java/com/fr/design/DesignerEnvManager.java
  2. 7
      designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java
  3. 6
      designer-base/src/main/java/com/fr/design/actions/TableDataSourceAction.java
  4. 16
      designer-base/src/main/java/com/fr/design/actions/server/GlobalTableDataAction.java
  5. 50
      designer-base/src/main/java/com/fr/design/base/clipboard/ClipboardFilter.java
  6. 68
      designer-base/src/main/java/com/fr/design/base/clipboard/DesignerClipboard.java
  7. 2
      designer-base/src/main/java/com/fr/design/data/BasicTableDataTreePane.java
  8. 36
      designer-base/src/main/java/com/fr/design/data/BasicTableDataUtils.java
  9. 34
      designer-base/src/main/java/com/fr/design/data/datapane/ChoosePane.java
  10. 4
      designer-base/src/main/java/com/fr/design/data/datapane/ReportTableDataPane.java
  11. 3
      designer-base/src/main/java/com/fr/design/data/datapane/TableDataCreatorProducer.java
  12. 15
      designer-base/src/main/java/com/fr/design/data/datapane/TableDataNameObjectCreator.java
  13. 44
      designer-base/src/main/java/com/fr/design/data/datapane/TableDataPaneListPane.java
  14. 11
      designer-base/src/main/java/com/fr/design/data/datapane/TreeTableDataComboBox.java
  15. 5
      designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java
  16. 4
      designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/EmbeddedTableDataDefinedPane.java
  17. 3
      designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/EmbeddedTableDataPane.java
  18. 20
      designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/MaxMemRowCountPanel.java
  19. 5
      designer-base/src/main/java/com/fr/design/dialog/UIDialog.java
  20. 6
      designer-base/src/main/java/com/fr/design/editor/editor/WidgetNameEditor.java
  21. 5
      designer-base/src/main/java/com/fr/design/env/DesignerWorkspaceGenerator.java
  22. 18
      designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java
  23. 34
      designer-base/src/main/java/com/fr/design/formula/FormulaPane.java
  24. 21
      designer-base/src/main/java/com/fr/design/fun/CellExpandAttrPanelProvider.java
  25. 45
      designer-base/src/main/java/com/fr/design/fun/ClipboardHandlerProvider.java
  26. 23
      designer-base/src/main/java/com/fr/design/fun/DesignerStartClassProcessor.java
  27. 7
      designer-base/src/main/java/com/fr/design/fun/FormAdaptiveConfigUIProcessor.java
  28. 39
      designer-base/src/main/java/com/fr/design/fun/impl/AbstractCellExpandAttrPanelProvider.java
  29. 17
      designer-base/src/main/java/com/fr/design/fun/impl/AbstractClipboardHandlerProvider.java
  30. 23
      designer-base/src/main/java/com/fr/design/fun/impl/AbstractDesignerStartClassProcessorProcessor.java
  31. 10
      designer-base/src/main/java/com/fr/design/gui/UILookAndFeel.java
  32. 103
      designer-base/src/main/java/com/fr/design/gui/ifilechooser/AbstractFileChooser.java
  33. 153
      designer-base/src/main/java/com/fr/design/gui/ifilechooser/UINativeFileChooser.java
  34. 10
      designer-base/src/main/java/com/fr/design/gui/style/BorderPane.java
  35. 39
      designer-base/src/main/java/com/fr/design/gui/style/FormatPane.java
  36. 25
      designer-base/src/main/java/com/fr/design/mainframe/DesignerContext.java
  37. 27
      designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java
  38. 2
      designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java
  39. 17
      designer-base/src/main/java/com/fr/design/mainframe/burying/point/AbstractPointCollector.java
  40. 9
      designer-base/src/main/java/com/fr/design/mainframe/burying/point/AbstractPointInfo.java
  41. 47
      designer-base/src/main/java/com/fr/design/mainframe/chart/info/ChartInfo.java
  42. 85
      designer-base/src/main/java/com/fr/design/mainframe/chart/info/ChartInfoCollector.java
  43. 2
      designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogHandler.java
  44. 107
      designer-base/src/main/java/com/fr/design/mainframe/loghandler/LogHandlerBar.java
  45. 9
      designer-base/src/main/java/com/fr/design/mainframe/loghandler/LogHandlerBarUI.java
  46. 50
      designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileCollapsedStyleExpandPane.java
  47. 153
      designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileCollapsedStylePane.java
  48. 5
      designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileComboBoxDialogEditor.java
  49. 135
      designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileStyleDefinePane.java
  50. 122
      designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileStyleFontConfigPane.java
  51. 116
      designer-base/src/main/java/com/fr/design/mainframe/template/info/TemplateInfo.java
  52. 127
      designer-base/src/main/java/com/fr/design/mainframe/template/info/TemplateInfoCollector.java
  53. 20
      designer-base/src/main/java/com/fr/design/mainframe/template/info/TemplateOperate.java
  54. 49
      designer-base/src/main/java/com/fr/design/mainframe/template/info/TemplateProcessInfo.java
  55. 2
      designer-base/src/main/java/com/fr/design/mainframe/widget/BasicPropertyPane.java
  56. 10
      designer-base/src/main/java/com/fr/design/os/impl/DatabaseDialogAction.java
  57. 12
      designer-base/src/main/java/com/fr/design/os/impl/SupportOSImpl.java
  58. 4
      designer-base/src/main/java/com/fr/design/utils/DesignUtils.java
  59. 5
      designer-base/src/main/java/com/fr/design/utils/DesignerPort.java
  60. 8
      designer-base/src/main/java/com/fr/design/widget/WidgetBoundsPaneFactory.java
  61. 11
      designer-base/src/main/java/com/fr/file/FILEChooserPane.java
  62. 13
      designer-base/src/main/java/com/fr/start/server/FineEmbedServerActivator.java
  63. 62
      designer-base/src/test/java/com/fr/design/base/clipboard/ClipboardFilterTest.java
  64. 75
      designer-base/src/test/java/com/fr/design/base/clipboard/DesignerClipboardTest.java
  65. 29
      designer-base/src/test/java/com/fr/design/base/clipboard/TestClipboardHandlerProvider.java
  66. 44
      designer-base/src/test/java/com/fr/design/data/BasicTableDataUtilsTest.java
  67. 25
      designer-base/src/test/java/com/fr/design/formula/FormulaPaneTest.java
  68. 136
      designer-base/src/test/java/com/fr/design/mainframe/template/info/TemplateInfoCollectorTest.java
  69. 90
      designer-base/src/test/java/com/fr/design/mainframe/template/info/TemplateInfoTest.java
  70. 18
      designer-base/src/test/java/com/fr/design/mainframe/template/info/TemplateInfoTestHelper.java
  71. 44
      designer-base/src/test/resources/com/fr/design/mainframe/template/info/tpl.info
  72. 12
      designer-chart/src/main/java/com/fr/design/chart/series/SeriesCondition/impl/ChartHyperPopAttrPane.java
  73. 10
      designer-chart/src/main/java/com/fr/design/chart/series/SeriesCondition/impl/ChartHyperRelateFloatLinkPane.java
  74. 5
      designer-chart/src/main/java/com/fr/design/chartx/component/combobox/ColorSchemeComboBox.java
  75. 33
      designer-chart/src/main/java/com/fr/design/gui/xcombox/MarkerComboBox.java
  76. 16
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartDataPane.java
  77. 8
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartOtherPane.java
  78. 4
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ChartTextAttrPane.java
  79. 4
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/series/ChartSeriesPane.java
  80. 9
      designer-chart/src/main/java/com/fr/design/module/ChartPreFillStylePane.java
  81. 21
      designer-chart/src/main/java/com/fr/design/module/ChartPreStyleAction.java
  82. 4
      designer-chart/src/main/java/com/fr/van/chart/area/VanChartAreaConditionPane.java
  83. 14
      designer-chart/src/main/java/com/fr/van/chart/area/VanChartAreaSeriesPane.java
  84. 1
      designer-chart/src/main/java/com/fr/van/chart/custom/VanChartCustomDataPane.java
  85. 4
      designer-chart/src/main/java/com/fr/van/chart/custom/VanChartCustomPlotDataContentsTabPane.java
  86. 3
      designer-chart/src/main/java/com/fr/van/chart/custom/VanChartCustomPlotPane.java
  87. 5
      designer-chart/src/main/java/com/fr/van/chart/custom/component/VanChartCustomPlotAxisPane.java
  88. 4
      designer-chart/src/main/java/com/fr/van/chart/custom/style/VanChartCustomAxisPane.java
  89. 4
      designer-chart/src/main/java/com/fr/van/chart/custom/style/VanChartCustomLabelPane.java
  90. 4
      designer-chart/src/main/java/com/fr/van/chart/custom/style/VanChartCustomSeriesPane.java
  91. 6
      designer-chart/src/main/java/com/fr/van/chart/custom/style/VanChartCustomTooltipPane.java
  92. 4
      designer-chart/src/main/java/com/fr/van/chart/designer/component/LineTypeComboBox.java
  93. 35
      designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartFillStylePane.java
  94. 80
      designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartLineTypePane.java
  95. 11
      designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartLineTypePaneWithoutDashed.java
  96. 8
      designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartLineWidthPane.java
  97. 15
      designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartMarkerPane.java
  98. 88
      designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartTrendLinePane.java
  99. 156
      designer-chart/src/main/java/com/fr/van/chart/designer/component/marker/VanChartCommonMarkerPane.java
  100. 16
      designer-chart/src/main/java/com/fr/van/chart/designer/other/condition/item/VanChartLineTypeConditionPaneWithoutDashed.java
  101. Some files were not shown because too many files have changed in this diff Show More

5
designer-base/src/main/java/com/fr/design/DesignerEnvManager.java

@ -58,6 +58,7 @@ import javax.swing.SwingWorker.StateValue;
import java.awt.Color;
import java.awt.Rectangle;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.FileWriter;
@ -206,9 +207,11 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
GeneralContext.setLocale(designerEnvManager.getLanguage());
try {
XMLTools.readFileXML(designerEnvManager, designerEnvManager.getDesignerEnvFile());
} catch (Exception e) {
} catch (FileNotFoundException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
XmlHandler.Self.handle(e);
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
// james:如果没有env定义,要设置一个默认的

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

@ -359,7 +359,7 @@ public class EnvChangeEntrance {
*/
private String formatBranch(String branch){
if(branch.contains("#")){
return branch.substring(branch.lastIndexOf("#") + 1, branch.length() - 13);
return branch.substring(branch.lastIndexOf("-") + 1, branch.length() - 13);
}
return branch;
}
@ -415,10 +415,7 @@ public class EnvChangeEntrance {
@Override
public void doOk() {
ProcessEventPipe pipe = FineProcessContext.getParentPipe();
if (FineProcessContext.getParentPipe() != null) {
pipe.fire(new CarryMessageEvent(ReportState.ACTIVE.getValue()));
}
FineProcessContext.getParentPipe().fire(new CarryMessageEvent(ReportState.ACTIVE.getValue()));
if (!envListOkAction(envListPane, PopTipStrategy.NOW)) {
DesignerExiter.getInstance().execute();
}

6
designer-base/src/main/java/com/fr/design/actions/TableDataSourceAction.java

@ -42,11 +42,15 @@ public class TableDataSourceAction extends TemplateComponentAction<JTemplate<?,
populate(tds);
}
};
BasicDialog reportTableDataDialog = tableDataPane.showLargeWindow(SwingUtilities.getWindowAncestor(this.getEditingComponent()), null);
final BasicDialog reportTableDataDialog = tableDataPane.showLargeWindow(SwingUtilities.getWindowAncestor(this.getEditingComponent()), null);
reportTableDataDialog.addDialogActionListener(new DialogActionAdapter() {
@Override
public void doOk() {
if (!tableDataPane.isNamePermitted()) {
reportTableDataDialog.setDoOKSucceed(false);
return;
}
DesignModelAdapter.getCurrentModelAdapter().renameTableData(tableDataPane.getDsNameChangedMap());
tableDataPane.update(tds);
TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter());

16
designer-base/src/main/java/com/fr/design/actions/server/GlobalTableDataAction.java

@ -27,6 +27,7 @@ import com.fr.transaction.Worker;
import com.fr.transaction.WorkerFacade;
import javax.swing.KeyStroke;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.util.HashMap;
import java.util.Map;
@ -35,7 +36,8 @@ import java.util.Map;
* Global TableData.
*/
public class GlobalTableDataAction extends UpdateAction implements ResponseDataSourceChange {
//private static TableDataManagerPane globalTableDataPane = new TableDataManagerPane();
private static final Dimension DEFAULT_DIMENSION = new Dimension(1000, 600);
public GlobalTableDataAction() {
this.setMenuKeySet(SERVER_TABLEDATA);
@ -77,20 +79,10 @@ public class GlobalTableDataAction extends UpdateAction implements ResponseDataS
}
protected void renameConnection(final String oldName, final String newName) {
Configurations.update(new Worker() {
@Override
public void run() {
tableDataConfig.renameTableData(oldName, newName);
}
@Override
public Class<? extends Configuration>[] targets() {
return new Class[]{TableDataConfig.class, ProcedureConfig.class};
}
});
}
};
final BasicDialog globalTableDataDialog = globalTableDataPane.showLargeWindow(designerFrame, null);
final BasicDialog globalTableDataDialog = globalTableDataPane.showWindowWithCustomSize(designerFrame, null, DEFAULT_DIMENSION);
globalTableDataDialog.addDialogActionListener(new DialogActionAdapter() {

50
designer-base/src/main/java/com/fr/design/base/clipboard/ClipboardFilter.java

@ -0,0 +1,50 @@
package com.fr.design.base.clipboard;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.fun.ClipboardHandlerProvider;
import com.fr.plugin.injectable.PluginModule;
import java.util.Set;
/**
* created by Harrison on 2020/05/14
**/
@SuppressWarnings({"rawtypes", "unchecked"})
public abstract class ClipboardFilter {
public static <T> T cut(T selection) {
ExtraDesignClassManager manager = PluginModule.getAgent(PluginModule.ExtraDesign);
Set<ClipboardHandlerProvider> providers = manager.getArray(ClipboardHandlerProvider.XML_TAG);
for (ClipboardHandlerProvider provider : providers) {
if (provider.support(selection)) {
selection = ((ClipboardHandlerProvider<T>) provider).cut(selection);
}
}
return selection;
}
public static <T> T copy(T selection) {
ExtraDesignClassManager manager = PluginModule.getAgent(PluginModule.ExtraDesign);
Set<ClipboardHandlerProvider> providers = manager.getArray(ClipboardHandlerProvider.XML_TAG);
for (ClipboardHandlerProvider provider : providers) {
if (provider.support(selection)) {
selection = ((ClipboardHandlerProvider<T>) provider).copy(selection);
}
}
return selection;
}
public static <T> T paste(T selection) {
ExtraDesignClassManager manager = PluginModule.getAgent(PluginModule.ExtraDesign);
Set<ClipboardHandlerProvider> providers = manager.getArray(ClipboardHandlerProvider.XML_TAG);
for (ClipboardHandlerProvider provider : providers) {
if (provider.support(selection)) {
selection = ((ClipboardHandlerProvider<T>) provider).paste(selection);
}
}
return selection;
}
}

68
designer-base/src/main/java/com/fr/design/base/clipboard/DesignerClipboard.java

@ -0,0 +1,68 @@
package com.fr.design.base.clipboard;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.ClipboardOwner;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.FlavorListener;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.io.IOException;
/**
* created by Harrison on 2020/05/11
**/
public class DesignerClipboard extends Clipboard {
private Clipboard clipboard;
public DesignerClipboard(Clipboard clipboard) {
super(clipboard.getName());
this.clipboard = clipboard;
}
@Override
public synchronized void setContents(Transferable contents, ClipboardOwner owner) {
//处理 contents/owner
Transferable filtered = ClipboardFilter.copy(contents);
clipboard.setContents(filtered, owner);
}
@Override
public synchronized Transferable getContents(Object requestor) {
Transferable contents = clipboard.getContents(requestor);
//处理 contents
Transferable filtered = ClipboardFilter.paste(contents);
return filtered;
}
@Override
public DataFlavor[] getAvailableDataFlavors() {
return clipboard.getAvailableDataFlavors();
}
@Override
public boolean isDataFlavorAvailable(DataFlavor flavor) {
return clipboard.isDataFlavorAvailable(flavor);
}
@Override
public Object getData(DataFlavor flavor) throws UnsupportedFlavorException, IOException {
return clipboard.getData(flavor);
}
@Override
public synchronized void addFlavorListener(FlavorListener listener) {
clipboard.addFlavorListener(listener);
}
@Override
public synchronized void removeFlavorListener(FlavorListener listener) {
clipboard.removeFlavorListener(listener);
}
@Override
public synchronized FlavorListener[] getFlavorListeners() {
return clipboard.getFlavorListeners();
}
}

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

@ -137,6 +137,8 @@ public abstract class BasicTableDataTreePane extends DockingView implements Resp
nPanel.setShowText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Stored_Procedure_Name_Tips"));
dg.setButtonEnabled(false);
}
} else if (!BasicTableDataUtils.checkName(tempName)) {
dg.setButtonEnabled(false);
} else {
nPanel.setShowText(StringUtils.BLANK);
dg.setButtonEnabled(true);

36
designer-base/src/main/java/com/fr/design/data/BasicTableDataUtils.java

@ -0,0 +1,36 @@
package com.fr.design.data;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.i18n.Toolkit;
import com.fr.stable.StringUtils;
/**
* @author hades
* @version 10.0
* Created by hades on 2020/4/27
*/
public abstract class BasicTableDataUtils {
private static final int LEN = 2;
public static boolean checkName(String name) {
if (isInValidName(name)) {
FineJOptionPane.showMessageDialog(null,
Toolkit.i18nText("Fine-Design_Basic_DataSet_Rename_Warning", name),
Toolkit.i18nText("Fine-Design_Basic_Alert"),
FineJOptionPane.WARNING_MESSAGE);
return false;
}
return true;
}
public static boolean isInValidName(String name) {
String[] values = name.split("\\.");
if (values.length == LEN) {
return (StringUtils.isNotEmpty(values[0]) && StringUtils.isNotEmpty(values[1]))
|| (StringUtils.isEmpty(values[0]) && StringUtils.isNotEmpty(values[1]));
}
return false;
}
}

34
designer-base/src/main/java/com/fr/design/data/datapane/ChoosePane.java

@ -1,12 +1,10 @@
package com.fr.design.data.datapane;
import com.fr.base.BaseUtils;
import com.fr.base.TableData;
import com.fr.data.core.DataCoreUtils;
import com.fr.data.core.db.DBUtils;
import com.fr.data.core.db.TableProcedure;
import com.fr.data.core.db.dialect.DialectFactory;
import com.fr.data.impl.Connection;
import com.fr.data.impl.DBTableData;
import com.fr.data.operator.DataOperator;
import com.fr.design.DesignerEnvManager;
@ -37,6 +35,7 @@ import com.fr.general.IOUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils;
import com.fr.workspace.WorkContext;
import com.fr.workspace.server.connection.DBConnectAuth;
import javax.swing.JList;
import javax.swing.JOptionPane;
@ -61,9 +60,10 @@ import java.awt.event.FocusEvent;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Enumeration;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* @author zhou
@ -210,10 +210,7 @@ public class ChoosePane extends BasicBeanPane<DataBaseItems> implements Refresha
@SuppressWarnings("unchecked")
protected void initDsNameComboBox() {
dsNameComboBox.setRefreshingModel(true);
ConnectionConfig connectionConfig = ConnectionConfig.getInstance();
List<String> dsList = new ArrayList<>();
dsList.addAll(connectionConfig.getConnections().keySet());
FilterableComboBoxModel dsNameComboBoxModel = new FilterableComboBoxModel(dsList);
FilterableComboBoxModel dsNameComboBoxModel = new FilterableComboBoxModel(getHasAuthConnections());
dsNameComboBox.setModel(dsNameComboBoxModel);
dsNameComboBox.setRefreshingModel(false);
}
@ -322,14 +319,31 @@ public class ChoosePane extends BasicBeanPane<DataBaseItems> implements Refresha
return null; // peter:选中了当前的零长度的节点,直接返回.
}
ConnectionConfig connectionConfig = ConnectionConfig.getInstance();
for (Map.Entry<String, Connection> entry : connectionConfig.getConnections().entrySet()) {
if (ComparatorUtils.equals(selectedDSName, entry.getKey())) {
return entry.getValue();
List<String> authConnections = getHasAuthConnections();
for (String name : authConnections) {
if (ComparatorUtils.equals(selectedDSName, name)) {
return connectionConfig.getConnection(name);
}
}
return null;
}
private List<String> getHasAuthConnections() {
List<String> authConnections = new ArrayList<>();
Set<String> allConnections = ConnectionConfig.getInstance().getConnections().keySet();
Collection<String> noAuthConnections = WorkContext.getCurrent().get(DBConnectAuth.class).getNoAuthConnections();
if (noAuthConnections == null) {
return authConnections;
}
for (String name : allConnections) {
if (!noAuthConnections.contains(name)) {
authConnections.add(name);
}
}
return authConnections;
}
/**
* 刷新没多大用而且要刷新也不是这儿刷新
*/

4
designer-base/src/main/java/com/fr/design/data/datapane/ReportTableDataPane.java

@ -59,4 +59,8 @@ public class ReportTableDataPane extends LoadingBasicPane {
public Map<String, String> getDsNameChangedMap() {
return tdPane.getDsNameChangedMap();
}
public boolean isNamePermitted() {
return tdPane.isNamePermitted();
}
}

3
designer-base/src/main/java/com/fr/design/data/datapane/TableDataCreatorProducer.java

@ -35,6 +35,7 @@ public class TableDataCreatorProducer {
"ds",
"/com/fr/design/images/data/database.png", DBTableData.class, DBTableDataPane.class);
TableDataNameObjectCreator ds_Class = new TableDataNameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tabledata_Type_Class"),
"Class",
"/com/fr/design/images/data/source/classTableData.png", ClassTableData.class, ClassTableDataPane.class);
TableDataNameObjectCreator table = new TableDataNameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tabledata_Type_Embedded"),
"Embedded",
@ -60,6 +61,7 @@ public class TableDataCreatorProducer {
"Proc",
"/com/fr/design/images/data/store_procedure.png",
StoreProcedure.class, ProcedureDataPane.class) {
@Override
public boolean shouldInsertSeparator() {
return true;
}
@ -92,6 +94,7 @@ public class TableDataCreatorProducer {
};
TableDataNameObjectCreator storeProcedure = new TableDataNameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tabledata_Type_Stored_Procedure"), "/com/fr/design/images/data/store_procedure.png",
StoreProcedure.class, ProcedureDataPane.class) {
@Override
public boolean shouldInsertSeparator() {
return true;
}

15
designer-base/src/main/java/com/fr/design/data/datapane/TableDataNameObjectCreator.java

@ -5,10 +5,13 @@ import com.fr.data.impl.DBTableData;
import com.fr.design.actions.tabledata.TableDataAction;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.gui.controlpane.NameObjectCreator;
import com.fr.design.gui.controlpane.UnrepeatedNameHelper;
import com.fr.design.icon.WarningIcon;
import com.fr.general.ComparatorUtils;
import com.fr.general.NameObject;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.ArrayUtils;
import com.fr.stable.Nameable;
import com.fr.stable.StringUtils;
import javax.swing.Icon;
@ -95,6 +98,7 @@ public class TableDataNameObjectCreator extends NameObjectCreator {
*
* @return 图片
*/
@Override
public Icon menuIcon() {
return createMenuIcon();
}
@ -112,6 +116,7 @@ public class TableDataNameObjectCreator extends NameObjectCreator {
*
* @return 提示
*/
@Override
public String createTooltip() {
return b ? com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Connect_SQL_Cannot_Null") : null;
}
@ -166,11 +171,21 @@ public class TableDataNameObjectCreator extends NameObjectCreator {
return false;
}
@Override
public boolean equals(Object obj) {
return obj instanceof TableDataNameObjectCreator
&& ComparatorUtils.equals(menuName, ((TableDataNameObjectCreator) obj).menuName);
}
@Override
public Nameable createNameable(UnrepeatedNameHelper helper) {
try {
return new NameObject(helper.createUnrepeatedName(this.getPrefix()), clazzOfInitCase.newInstance());
} catch (InstantiationException | IllegalAccessException e) {
throw new RuntimeException(e);
}
}
@Override
public int hashCode() {
return menuName == null ? 0 : menuName.hashCode();

44
designer-base/src/main/java/com/fr/design/data/datapane/TableDataPaneListPane.java

@ -4,6 +4,7 @@ import com.fr.base.TableData;
import com.fr.data.TableDataSource;
import com.fr.data.api.StoreProcedureAssist;
import com.fr.data.impl.storeproc.StoreProcedure;
import com.fr.design.data.BasicTableDataUtils;
import com.fr.design.data.DesignTableDataManager;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.gui.controlpane.JListControlPane;
@ -14,6 +15,7 @@ import com.fr.file.ProcedureConfig;
import com.fr.file.TableDataConfig;
import com.fr.general.ComparatorUtils;
import com.fr.general.NameObject;
import com.fr.stable.ArrayUtils;
import com.fr.stable.Nameable;
import com.fr.stable.StringUtils;
import com.fr.stable.core.PropertyChangeAdapter;
@ -47,6 +49,14 @@ public class TableDataPaneListPane extends JListControlPane implements TableData
allListNames[nameableList.getSelectedIndex()] = StringUtils.EMPTY;
String tempName = getEditingName();
Object editingType = getEditingType();
if (!BasicTableDataUtils.checkName(tempName)) {
isNamePermitted = false;
nameableList.stopEditing();
setIllegalIndex(editingIndex);
return;
}
if (StringUtils.isEmpty(tempName)) {
isNamePermitted = false;
nameableList.stopEditing();
@ -133,36 +143,28 @@ public class TableDataPaneListPane extends JListControlPane implements TableData
return super.createUnrepeatedName(prefix);
}
String[] allDsNames = DesignTableDataManager.getAllDSNames(source);
// richer:生成的名字从1开始. kunsnat: 添加属性从0开始.
int count = 1;
while (isDsNameRepeated(prefix + count, allDsNames)) {
count++;
}
return prefix + count;
}
private boolean isDsNameRepeated(String name, String[] allDsNames) {
DefaultListModel model = this.getModel();
Nameable[] all = new Nameable[model.getSize()];
for (int i = 0; i < model.size(); i++) {
all[i] = ((ListModelElement) model.get(i)).wrapper;
}
// richer:生成的名字从1开始. kunsnat: 添加属性从0开始.
int count = all.length + 1;
while (true) {
String name_test = prefix + count;
boolean repeated = false;
for (int i = 0, len = model.size(); i < len; i++) {
Nameable nameable = all[i];
if (ComparatorUtils.equals(nameable.getName(), name_test)) {
repeated = true;
break;
}
}
for (String dsname : allDsNames) {
if (ComparatorUtils.equals(dsname, name_test)) {
repeated = true;
break;
if (ComparatorUtils.equals(nameable.getName(), name)) {
return true;
}
}
if (!repeated) {
return name_test;
}
count++;
}
return ArrayUtils.contains(allDsNames, name);
}
@Override

11
designer-base/src/main/java/com/fr/design/data/datapane/TreeTableDataComboBox.java

@ -2,6 +2,7 @@ package com.fr.design.data.datapane;
import com.fr.data.TableDataSource;
import com.fr.data.impl.RecursionTableData;
import com.fr.design.data.DesignTableDataManager;
import com.fr.design.data.tabledata.wrapper.ServerTableDataWrapper;
import com.fr.design.data.tabledata.wrapper.TableDataWrapper;
import com.fr.design.data.tabledata.wrapper.TemplateTableDataWrapper;
@ -70,8 +71,14 @@ public class TreeTableDataComboBox extends UIComboBox {
}
public void setSelectedTableDataByName(String name) {
TableDataWrapper tableDataWrappe = res_map.get(name);
this.getModel().setSelectedItem(tableDataWrappe);
TableDataWrapper tableDataWrapper;
if (res_map.get(name) != null) {
tableDataWrapper = res_map.get(name);
} else {
String changeName = DesignTableDataManager.getChangedDsNameByOldDsName(name);
tableDataWrapper = res_map.get(changeName);
}
this.getModel().setSelectedItem(tableDataWrapper);
}
@Override

5
designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java

@ -238,13 +238,10 @@ public class DBTableDataPane extends AbstractTableDataPane<DBTableData> {
isShareCheckBox.setBackground(Color.WHITE);
maxPanel = new MaxMemRowCountPanel();
maxPanel.setBorder(null);
JPanel wrapMaxPanel = FRGUIPaneFactory.createBorderLayout_S_Pane();
wrapMaxPanel.add(maxPanel);
wrapMaxPanel.setPreferredSize(new Dimension(350, 20));
UIToolbar editToolBar = ToolBarDef.createJToolBar();
toolBarDef.updateToolBar(editToolBar);
editToolBar.add(isShareCheckBox);
editToolBar.add(wrapMaxPanel);
editToolBar.add(maxPanel);
return editToolBar;
}

4
designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/EmbeddedTableDataDefinedPane.java

@ -25,7 +25,7 @@ import java.util.Date;
public class EmbeddedTableDataDefinedPane extends BasicPane{
private static final int MIN_CELL_WIDTH = 30;
private EmbeddedTableData tableData;
private JTable dataJTable;
private UIButton add;
@ -64,7 +64,7 @@ public class EmbeddedTableDataDefinedPane extends BasicPane{
// 行号显示
TableColumn tableColumn = dataJTable.getColumnModel().getColumn(0);
tableColumn.setCellRenderer(new CellRenderer());
tableColumn.setMaxWidth(dataJTable.getColumnCount());
tableColumn.setMaxWidth(Math.max(dataJTable.getColumnCount(), MIN_CELL_WIDTH));
// 控制按钮
add = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Add"));

3
designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/EmbeddedTableDataPane.java

@ -34,6 +34,7 @@ import java.util.Date;
public class EmbeddedTableDataPane extends AbstractTableDataPane<EmbeddedTableData> {
private static final int MIN_CELL_WIDTH = 30;
private JTable dataJTable ;
private JScrollPane scrollPane;
private UILabel coordinatelabel;
@ -220,7 +221,7 @@ public class EmbeddedTableDataPane extends AbstractTableDataPane<EmbeddedTableDa
// 行号显示,每次dateJTable的表结构发生变化时都要调用
TableColumn tableColumn = dataJTable.getColumnModel().getColumn(0);
tableColumn.setCellRenderer(new CellRenderer());
tableColumn.setMaxWidth(dataJTable.getColumnCount());
tableColumn.setMaxWidth(Math.max(dataJTable.getColumnCount(), MIN_CELL_WIDTH));
}
private class DoubleRenderer extends DefaultTableCellRenderer {

20
designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/MaxMemRowCountPanel.java

@ -4,6 +4,7 @@ import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import com.fr.base.GraphHelper;
import com.fr.design.constants.UIConstants;
import com.fr.design.gui.ilable.UILabel;
@ -15,6 +16,20 @@ import com.fr.design.gui.itoolbar.UIToolbar;
public class MaxMemRowCountPanel extends UIToolbar {
private static final int ALL_IN_MEMORY = 0;
private static final int MAX_IN_MEMORY = 1;
private static final String[] CACHE_LIST = {com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Save_All_Records_In_Memory"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Max_Mem_Row_Count") };
private static final int MAX_WIDTH = getMaxComBoBoxWidth() > 200 ? 350 : 250;
private static int getMaxComBoBoxWidth() {
int maxWidth = GraphHelper.getWidth(CACHE_LIST[0]);
for (int i = 1; i < CACHE_LIST.length; i++) {
int width = GraphHelper.getWidth(CACHE_LIST[i]);
if (width > maxWidth) {
maxWidth = width;
}
}
return maxWidth;
}
private UISpinner numberSpinner;
private UIComboBox switchCache;
@ -44,7 +59,7 @@ public class MaxMemRowCountPanel extends UIToolbar {
@Override
public Dimension getPreferredSize() {
Dimension dim = super.getPreferredSize();
dim.width = 340;
dim.width = MAX_WIDTH;
return dim;
};
@ -52,8 +67,7 @@ public class MaxMemRowCountPanel extends UIToolbar {
this.setFloatable(false);
this.setRollover(true);
this.setBackground(UIConstants.NORMAL_BACKGROUND);
String[] cacheList = { com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Save_All_Records_In_Memory"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Max_Mem_Row_Count") };
switchCache = new UIComboBox(cacheList);
switchCache = new UIComboBox(CACHE_LIST);
switchCache.addActionListener(switchStateL);
numberSpinner = new UISpinner(0, Integer.MAX_VALUE, 1);
}

5
designer-base/src/main/java/com/fr/design/dialog/UIDialog.java

@ -123,8 +123,11 @@ public abstract class UIDialog extends JDialog {
// transfer focus to CurrentEditor
inputMapAncestor.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "dialogOK");
actionMap.put("dialogOK", new AbstractAction() {
@Override
public void actionPerformed(ActionEvent evt) {
if (!okButton.isEnabled()) {
return;
}
doOK();
}
});

6
designer-base/src/main/java/com/fr/design/editor/editor/WidgetNameEditor.java

@ -4,6 +4,7 @@ import com.fr.design.DesignModelAdapter;
import com.fr.design.gui.icombobox.FilterComboBox;
import com.fr.design.gui.icombobox.UIComboBoxRenderer;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.stable.StringUtils;
import com.fr.stable.js.WidgetName;
import javax.swing.JList;
@ -19,6 +20,8 @@ import java.awt.Component;
* @since 2012-3-29下午6:04:37
*/
public class WidgetNameEditor extends Editor<WidgetName> {
static final WidgetName EMPTY_WIDGET_NAME = new WidgetName(StringUtils.EMPTY);
private FilterComboBox<WidgetName> comb;
@ -79,7 +82,8 @@ public class WidgetNameEditor extends Editor<WidgetName> {
@Override
public WidgetName getValue() {
return (WidgetName) comb.getSelectedItem();
WidgetName widgetName = (WidgetName) comb.getSelectedItem();
return widgetName == null ? EMPTY_WIDGET_NAME : widgetName;
}
@Override

5
designer-base/src/main/java/com/fr/design/env/DesignerWorkspaceGenerator.java vendored

@ -72,10 +72,7 @@ public class DesignerWorkspaceGenerator {
enum RemoteHandler {
SELF;
public static void handle(DesignerWorkspaceInfo config) {
ProcessEventPipe eventPipe = FineProcessContext.getParentPipe();
if (eventPipe != null) {
eventPipe.fire(new CarryMessageEvent(ReportState.STOP.getValue()));
}
FineProcessContext.getParentPipe().fire(new CarryMessageEvent(ReportState.STOP.getValue()));
StartErrorMessageCollector.getInstance().record(DesignerErrorMessage.REMOTE_DESIGN_NO_RESPONSE.getId(),
DesignerErrorMessage.REMOTE_DESIGN_NO_RESPONSE.getMessage(),
StringUtils.EMPTY);

18
designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java

@ -2,6 +2,7 @@ package com.fr.design.file;
import com.fr.base.chart.chartdata.CallbackEvent;
import com.fr.base.io.BaseBook;
import com.fr.design.DesignModelAdapter;
import com.fr.design.DesignerEnvManager;
import com.fr.design.base.mode.DesignModeContext;
import com.fr.design.data.DesignTableDataManager;
@ -384,9 +385,14 @@ public class HistoryTemplateListCache implements CallbackEvent {
historyList.set(i, template);
// 替换当前正在编辑的模板,使用添加并激活的方式,以便使用统一的入口来处理监听事件
if (isCurrentEditingFile(template.getPath())) {
DesignerContext.getDesignerFrame().addAndActivateJTemplate(template);
setCurrentEditingTemplate(template);
FineLoggerFactory.getLogger().info("Env Change Current Editing Template.");
loadCurrentTemplate(template);
}
} else {
// 当模板为空时 说明是一个新建的未保存模板 但是内存中保存了该模板 可以从中获取
JTemplate jt = historyList.get(i);
// 另外如果该模板是正在编辑的模板,需要要激活
if (jt != null && isCurrentEditingFile(jt.getPath())) {
loadCurrentTemplate(jt);
}
}
} catch (Exception e) {
@ -400,6 +406,12 @@ public class HistoryTemplateListCache implements CallbackEvent {
FineLoggerFactory.getLogger().info("Env Change Template Loaded.");
}
private void loadCurrentTemplate(JTemplate<?, ?> template) {
DesignerContext.getDesignerFrame().addAndActivateJTemplate(template);
setCurrentEditingTemplate(template);
FineLoggerFactory.getLogger().info("Env Change Current Editing Template " + template.getTemplateName());
}
/**
* 重新载入当前模板刷新数据/对象
*/

34
designer-base/src/main/java/com/fr/design/formula/FormulaPane.java

@ -2,7 +2,6 @@ package com.fr.design.formula;
import com.fr.base.BaseFormula;
import com.fr.base.BaseUtils;
import com.fr.base.FRContext;
import com.fr.design.actions.UpdateAction;
import com.fr.design.border.UIRoundedBorder;
import com.fr.design.constants.UIConstants;
@ -25,7 +24,6 @@ import com.fr.log.FineLoggerFactory;
import com.fr.parser.FRLexer;
import com.fr.parser.FRParser;
import com.fr.stable.EncodeConstants;
import com.fr.stable.ProductConstants;
import com.fr.stable.StringUtils;
import com.fr.stable.script.Expression;
@ -54,7 +52,10 @@ import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.io.StringReader;
import java.util.Locale;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
/**
* 公式编辑面板
@ -413,14 +414,19 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula {
if (keyWord.length() != 0) {
NameAndDescription[] descriptions = FunctionConstants.ALL.getDescriptions();
int lengthOfDes = descriptions.length;
List<String> list = new ArrayList<>();
for (int i = 0; i < lengthOfDes; i++) {
NameAndDescription and = descriptions[i];
String functionName = and.searchResult(keyWord, findDescription);
if (StringUtils.isNotBlank(functionName)) {
listModel.addElement(functionName);
list.add(functionName);
}
}
Collections.sort(list, new SimilarComparator(keyWord));
for (String name : list) {
listModel.addElement(name);
}
if (!listModel.isEmpty()) {
tipsList.setSelectedIndex(0);
@ -969,6 +975,26 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula {
}
}
public static class SimilarComparator implements Comparator<String> {
private String searchKey;
public SimilarComparator(String searchKey) {
this.searchKey = searchKey.toLowerCase();
}
@Override
public int compare(String o1, String o2) {
if (o1.toLowerCase().startsWith(searchKey)) {
return -1;
}
if (o2.toLowerCase().startsWith(searchKey)) {
return 1;
}
return o2.compareTo(o1);
}
}
public static class TextFolderUserObject {
private String text;

21
designer-base/src/main/java/com/fr/design/fun/CellExpandAttrPanelProvider.java

@ -0,0 +1,21 @@
package com.fr.design.fun;
import com.fr.design.beans.BasicBeanPane;
import com.fr.report.cell.TemplateCellElement;
import com.fr.stable.fun.mark.Mutable;
/**
* @author yaohwu
* created by yaohwu at 2020/4/26 15:50
*/
public interface CellExpandAttrPanelProvider extends Mutable {
String MARK_STRING = "CellExpandAttrPanelProvider";
int CURRENT_LEVEL = 1;
/**
* @return 创建单元格属性-扩展设置中的额外面板
*/
BasicBeanPane<TemplateCellElement> createPanel();
}

45
designer-base/src/main/java/com/fr/design/fun/ClipboardHandlerProvider.java

@ -0,0 +1,45 @@
package com.fr.design.fun;
import com.fr.stable.fun.mark.Mutable;
/**
* created by Harrison on 2020/05/14
**/
public interface ClipboardHandlerProvider<T> extends Mutable {
String XML_TAG = "ClipboardHandlerProvider";
int CURRENT_LEVEL = 1;
/**
* 剪切
*
* @param selection 选中
* @return 处理后的内容
*/
T cut(T selection);
/**
* 复制
*
* @param selection 选中
* @return 处理后的内容
*/
T copy(T selection);
/**
* 粘贴
*
* @param selection 选中
* @return 处理后的内容
*/
T paste(T selection);
/**
* 支持的类型
*
* @param selection 内容
* @return 是否
*/
boolean support(Object selection);
}

23
designer-base/src/main/java/com/fr/design/fun/DesignerStartClassProcessor.java

@ -0,0 +1,23 @@
package com.fr.design.fun;
import com.fr.stable.fun.mark.Mutable;
import com.fr.start.BaseDesigner;
/**
* 设计器启动类替换接口
*
* @author hades
* @version 10.0
* Created by hades on 2020/5/7
*/
public interface DesignerStartClassProcessor extends Mutable {
String MARK_STRING = "DesignerStartClassProcessor";
int CURRENT_LEVEL = 1;
Class<? extends BaseDesigner> transform();
}

7
designer-base/src/main/java/com/fr/design/fun/FormAdaptiveConfigUIProcessor.java

@ -32,5 +32,12 @@ public interface FormAdaptiveConfigUIProcessor extends Immutable {
*/
BufferedImage paintFormElementCaseImage(Dimension size, JComponent elementCasePane);
/**
* 获取新自适应下字体显示的dpi
* @return dpi
*/
int fontResolution();
}

39
designer-base/src/main/java/com/fr/design/fun/impl/AbstractCellExpandAttrPanelProvider.java

@ -0,0 +1,39 @@
package com.fr.design.fun.impl;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.fun.CellExpandAttrPanelProvider;
import com.fr.report.cell.TemplateCellElement;
import com.fr.stable.fun.mark.API;
/**
* @author yaohwu
* created by yaohwu at 2020/4/26 16:08
*/
@API(level = CellExpandAttrPanelProvider.CURRENT_LEVEL)
public class AbstractCellExpandAttrPanelProvider implements CellExpandAttrPanelProvider {
/**
* 当前接口的API等级,用于判断是否需要升级插件
*
* @return API等级
*/
@Override
public int currentAPILevel() {
return CellExpandAttrPanelProvider.CURRENT_LEVEL;
}
/**
* 获取当前provider的标记可以使用类路径保证唯一以避免provider的重复加载
*
* @return 当前provider的标记
*/
@Override
public String mark4Provider() {
return null;
}
@Override
public BasicBeanPane<TemplateCellElement> createPanel() {
return null;
}
}

17
designer-base/src/main/java/com/fr/design/fun/impl/AbstractClipboardHandlerProvider.java

@ -0,0 +1,17 @@
package com.fr.design.fun.impl;
import com.fr.design.fun.ClipboardHandlerProvider;
import com.fr.stable.fun.impl.AbstractProvider;
import com.fr.stable.fun.mark.API;
/**
* created by Harrison on 2020/05/14
**/
@API(level = ClipboardHandlerProvider.CURRENT_LEVEL)
public abstract class AbstractClipboardHandlerProvider<T> extends AbstractProvider implements ClipboardHandlerProvider<T> {
@Override
public int currentAPILevel() {
return ClipboardHandlerProvider.CURRENT_LEVEL;
}
}

23
designer-base/src/main/java/com/fr/design/fun/impl/AbstractDesignerStartClassProcessorProcessor.java

@ -0,0 +1,23 @@
package com.fr.design.fun.impl;
import com.fr.design.fun.DesignerStartClassProcessor;
import com.fr.stable.fun.mark.API;
/**
* @author hades
* @version 10.0
* Created by hades on 2020/5/7
*/
@API(level = DesignerStartClassProcessor.CURRENT_LEVEL)
public abstract class AbstractDesignerStartClassProcessorProcessor implements DesignerStartClassProcessor {
@Override
public String mark4Provider() {
return getClass().getName();
}
@Override
public int currentAPILevel() {
return CURRENT_LEVEL;
}
}

10
designer-base/src/main/java/com/fr/design/gui/UILookAndFeel.java

@ -29,11 +29,11 @@ import com.fr.design.gui.itoolbar.UIToolBarBorder;
import com.fr.design.gui.itoolbar.UIToolBarSeparatorUI;
import com.fr.design.gui.itooltip.UIToolTipBorder;
import com.fr.design.gui.itree.UITreeUI;
import com.fr.design.i18n.Toolkit;
import com.fr.log.FineLoggerFactory;
import com.fr.general.IOUtils;
import javax.swing.ImageIcon;
import javax.swing.UIDefaults;
import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.border.EmptyBorder;
import javax.swing.plaf.BorderUIResource;
@ -52,6 +52,12 @@ import java.net.URL;
*/
public class UILookAndFeel extends MetalLookAndFeel {
static {
UIManager.put("ProgressMonitor.progressText", Toolkit.i18nText("Fine-Design_Basic_ProgressBar_Title"));
UIManager.put("OptionPane.cancelButtonText", Toolkit.i18nText("Fine-Design_Basic_Cancel"));
}
public static boolean CONTROL_PANEL_INSTANTIATED = false;

103
designer-base/src/main/java/com/fr/design/gui/ifilechooser/AbstractFileChooser.java

@ -0,0 +1,103 @@
package com.fr.design.gui.ifilechooser;
import javax.swing.filechooser.FileFilter;
import java.awt.*;
import java.io.File;
/**
* @author hades
* @version 10.0
* Created by hades on 2020/3/31
*/
public abstract class AbstractFileChooser {
/**
* 返回当前目录
*
*/
public abstract File getCurrentDirectory();
/**
* 返回当前的文件选择过滤器
*
*/
public abstract FileFilter getFileFilter();
/**
* 返回选择的文件
*
*/
public abstract File getSelectedFile();
/**
* 多文件选择模式下 返回选择的多个文件
*
*/
public abstract File[] getSelectedFiles();
/**
* 是否可以选择多个文件
*
*/
public abstract boolean isMultiSelectionEnabled();
/**
* 设置当前选择的目录
*
*/
public abstract void setCurrentDirectory(File dir);
/**
* 设置左上角标题
*
*/
public abstract void setDialogTitle(String title);
/**
* 设置当前的文件过滤器
*
*/
public abstract void setFileFilter(final FileFilter filter);
/**
* 设置文件选择器模式
*
* JFileChooser.FILES_ONLY
* JFileChooser.DIRECTORIES_ONLY
* JFileChooser.FILES_AND_DIRECTORIES
*/
public abstract void setFileSelectionMode(int selectionMode);
/**
* 设置是否允许选择多个文件
*
*/
public abstract void setMultiSelectionEnabled(boolean multiple);
/**
* 设置选择的文件 用于showSaveDialog
*
*/
public abstract void setSelectedFile(File file);
/**
* 弹出文件选择器 打开文件
*
*/
public abstract int showOpenDialog(Component parent);
/**
* 弹出文件选择器 保存文件
*
*/
public abstract int showSaveDialog(Component parent);
/**
* https://bugs.java.com/bugdatabase/view_bug.do?bug_id=4031440
*
* 设置文件名后缀 起到文件过滤的作用 形如 "*.jpg;*.jpeg"
*
*/
public abstract void setExtensionFilter(String file);
}

153
designer-base/src/main/java/com/fr/design/gui/ifilechooser/UINativeFileChooser.java

@ -0,0 +1,153 @@
package com.fr.design.gui.ifilechooser;
import com.fr.design.mainframe.DesignerContext;
import com.fr.stable.os.OperatingSystem;
import javax.swing.*;
import javax.swing.filechooser.FileFilter;
import java.awt.*;
import java.io.File;
import java.io.FilenameFilter;
/**
* 系统原生风格的文件选择器
*
* jdk问题
* https://bugs.openjdk.java.net/browse/JDK-4811090 不支持文件扩展选择
* https://stackoverflow.com/questions/40713398/filter-not-working-in-filedialog windows下 setFilenameFilter不work
*
* @author hades
* @version 10.0
* Created by hades on 2020/3/31
*/
public class UINativeFileChooser extends AbstractFileChooser {
private final FileDialog fileDialog;
private FileFilter fileFilter;
private int selectionMode;
public UINativeFileChooser(File file) {
fileDialog = new FileDialog(DesignerContext.getDesignerFrame());
if (file != null) {
fileDialog.setDirectory(file.getAbsolutePath());
fileDialog.setFile(file.toString());
}
}
public UINativeFileChooser() {
this(null);
}
@Override
public File getCurrentDirectory() {
return new File(fileDialog.getDirectory());
}
@Override
public FileFilter getFileFilter() {
return fileFilter;
}
@Override
public File getSelectedFile() {
return new File(fileDialog.getDirectory() + fileDialog.getFile());
}
@Override
public File[] getSelectedFiles() {
return fileDialog.getFiles();
}
@Override
public boolean isMultiSelectionEnabled() {
return fileDialog.isMultipleMode();
}
@Override
public void setCurrentDirectory(File f) {
fileDialog.setDirectory(f.toString());
}
@Override
public void setDialogTitle(String title) {
fileDialog.setTitle(title);
}
@Override
public void setFileFilter(final FileFilter cff) {
FilenameFilter filter = new FilenameFilter() {
@Override
public boolean accept(File Directory, String fileName) {
return cff.accept(new File(Directory.getAbsolutePath() + fileName));
}
};
fileDialog.setFilenameFilter(filter);
fileFilter = cff;
}
@Override
public void setFileSelectionMode(int selectionMode) {
this.selectionMode = selectionMode;
}
@Override
public void setMultiSelectionEnabled(boolean multiple) {
fileDialog.setMultipleMode(multiple);
}
@Override
public void setSelectedFile(File file) {
fileDialog.setDirectory(file.getAbsolutePath());
fileDialog.setFile(file.getName());
}
@Override
public int showOpenDialog(Component parent) {
boolean appleProperty = OperatingSystem.isMacos() && selectionMode == JFileChooser.DIRECTORIES_ONLY;
if (appleProperty) {
System.setProperty("apple.awt.fileDialogForDirectories", "true");
}
try {
fileDialog.setLocale(JComponent.getDefaultLocale());
fileDialog.setMode(FileDialog.LOAD);
fileDialog.setVisible(true);
return fileDialog.getFile() == null ? JFileChooser.CANCEL_OPTION : JFileChooser.APPROVE_OPTION;
} finally {
if (appleProperty) {
System.setProperty("apple.awt.fileDialogForDirectories", "false");
}
}
}
@Override
public int showSaveDialog(Component parent) {
fileDialog.setLocale(JComponent.getDefaultLocale());
fileDialog.setMode(FileDialog.SAVE);
fileDialog.setVisible(true);
return fileDialog.getFile() == null ? JFileChooser.CANCEL_OPTION : JFileChooser.APPROVE_OPTION;
}
@Override
public void setExtensionFilter(String file) {
fileDialog.setFile(file);
}
/**
* 确认本地文件选择器是否支持选择模式
* @param selectionMode 选择模式
* @return 是否支持选择模式
*/
public static boolean supportsSelectionMode(int selectionMode) {
switch (selectionMode) {
case JFileChooser.FILES_AND_DIRECTORIES:
return false;
case JFileChooser.DIRECTORIES_ONLY:
return OperatingSystem.isMacos();
case JFileChooser.FILES_ONLY:
default:
return true;
}
}
}

10
designer-base/src/main/java/com/fr/design/gui/style/BorderPane.java

@ -229,6 +229,16 @@ public class BorderPane extends AbstractBasicStylePane implements GlobalNameObse
cellBorderStyle.setVerticalStyle(verticalToggleButton.isSelected() ? lineStyle : Constants.LINE_NONE);
cellBorderStyle.setHorizontalColor(lineColor);
cellBorderStyle.setHorizontalStyle(horizontalToggleButton.isSelected() ? lineStyle : Constants.LINE_NONE);
if (leftToggleButton.isSelected() && bottomToggleButton.isSelected() && rightToggleButton.isSelected() && topToggleButton.isSelected()) {
outerToggleButton.setSelected(true);
} else {
outerToggleButton.setSelected(false);
}
if (verticalToggleButton.isSelected() && horizontalToggleButton.isSelected()) {
innerToggleButton.setSelected(true);
} else {
innerToggleButton.setSelected(false);
}
return cellBorderStyle;
}

39
designer-base/src/main/java/com/fr/design/gui/style/FormatPane.java

@ -6,6 +6,7 @@ import com.fr.base.Style;
import com.fr.base.TextFormat;
import com.fr.data.core.FormatField;
import com.fr.data.core.FormatField.FormatContents;
import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.i18n.Toolkit;
import com.fr.design.border.UIRoundedBorder;
import com.fr.design.constants.LayoutConstants;
@ -22,6 +23,8 @@ import com.fr.general.ComparatorUtils;
import com.fr.stable.StringUtils;
import java.math.BigDecimal;
import java.math.RoundingMode;
import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.border.TitledBorder;
@ -63,6 +66,8 @@ public class FormatPane extends AbstractBasicStylePane implements GlobalNameObse
private JPanel contentPane;
private JPanel txtCenterPane;
private JPanel centerPane;
private JPanel optionPane;
private UICheckBox roundingBox;
private JPanel formatFontPane;
private FRFontPane frFontPane;
private boolean isRightFormat;
@ -123,6 +128,22 @@ public class FormatPane extends AbstractBasicStylePane implements GlobalNameObse
// centerPane.setBorder(LEFT_BORDER);
frFontPane.setBorder(LEFT_BORDER);
JPanel option = new JPanel(new BorderLayout());
option.add(new UILabel(Toolkit.i18nText("Fine-Design_Report_Base_Option"), SwingConstants.LEFT), BorderLayout.WEST);
roundingBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Report_Base_Option_Half_Up"));
roundingBox.setBorder(BorderFactory.createEmptyBorder(0, 40, 0, 0));
roundingBox.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
}
});
roundingBox.setGlobalName("roundingBox");
option.add(roundingBox, BorderLayout.CENTER);
optionPane = new JPanel(new CardLayout());
optionPane.add(new JPanel(), "hide");
optionPane.setPreferredSize(new Dimension(0, 0));
optionPane.add(option, "show");
Component[][] components = getComponent(fontPane, centerPane, typePane);
this.add(createContentPane(components), BorderLayout.CENTER);
}
@ -142,6 +163,7 @@ public class FormatPane extends AbstractBasicStylePane implements GlobalNameObse
new Component[]{null, null},
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Report_Base_Format"), SwingConstants.LEFT), typePane},
new Component[]{centerPane, null},
new Component[]{optionPane, null},
new Component[]{fontPane, frFontPane},
};
}
@ -220,6 +242,7 @@ public class FormatPane extends AbstractBasicStylePane implements GlobalNameObse
setPatternComboBoxAndList(FormatContents.CURRENCY, pattern);
} else if (pattern.indexOf("%") > 0) {
setPatternComboBoxAndList(FormatContents.PERCENT, pattern);
this.roundingBox.setSelected(((CoreDecimalFormat) format).getRoundingMode().equals(RoundingMode.HALF_UP));
} else if (pattern.indexOf("E") > 0) {
setPatternComboBoxAndList(FormatContents.SCIENTIFIC, pattern);
} else {
@ -286,7 +309,8 @@ public class FormatPane extends AbstractBasicStylePane implements GlobalNameObse
}
if (isRightFormat) {
if (StringUtils.isNotEmpty(patternString)) {
return FormatField.getInstance().getFormat(getFormatContents(), patternString);
RoundingMode roundingMode = roundingBox.isSelected() ? RoundingMode.HALF_UP : RoundingMode.HALF_EVEN;
return FormatField.getInstance().getFormat(getFormatContents(), patternString, roundingMode);
}
}
return null;
@ -342,6 +366,15 @@ public class FormatPane extends AbstractBasicStylePane implements GlobalNameObse
centerPane.setPreferredSize(new Dimension(270, 65));
cardLayout.show(centerPane, "show");
}
CardLayout optionLayout = ((CardLayout) optionPane.getLayout());
if (getFormatContents() == FormatContents.PERCENT) {
optionPane.setPreferredSize(new Dimension(100, 20));
optionLayout.show(optionPane, "show");
} else {
optionPane.setPreferredSize(new Dimension(0, 0));
optionLayout.show(optionPane, "hide");
roundingBox.setSelected(false);
}
}
}
@ -370,7 +403,9 @@ public class FormatPane extends AbstractBasicStylePane implements GlobalNameObse
* update
*/
public Style update(Style style) {
if (ComparatorUtils.equals(globalNameListener.getGlobalName(), "textField") || ComparatorUtils.equals(globalNameListener.getGlobalName(), "typeComboBox")) {
if (ComparatorUtils.equals(globalNameListener.getGlobalName(), "textField")
|| ComparatorUtils.equals(globalNameListener.getGlobalName(), "typeComboBox")
|| ComparatorUtils.equals(globalNameListener.getGlobalName(), "roundingBox")) {
return style.deriveFormat(this.update());
} else {
return style.deriveFRFont(this.frFontPane.update(style.getFRFont()));

25
designer-base/src/main/java/com/fr/design/mainframe/DesignerContext.java

@ -4,6 +4,7 @@
package com.fr.design.mainframe;
import com.fr.base.Style;
import com.fr.design.base.clipboard.DesignerClipboard;
import com.fr.design.designer.TargetComponent;
import com.fr.design.dialog.BasicDialog;
import com.fr.log.FineLoggerFactory;
@ -62,10 +63,24 @@ public class DesignerContext {
}
/**
* Gets the Clipboard.
* get this custom clipboard
*/
public static Clipboard getClipboard(JComponent comp) {
if (DesignerContext.clipboard == null) {
Clipboard clipboard = getClipboard0(comp);
return new DesignerClipboard(clipboard);
}
return DesignerContext.clipboard;
}
/**
* Gets the system Clipboard.
*/
private static Clipboard getClipboard0(JComponent comp) {
Clipboard clipboard = null;
try {
Action transferAction = TransferHandler.getCutAction();
Method clipMethod = StableUtils.getDeclaredMethod(transferAction.getClass(), "getClipboard", new Class[]{JComponent.class});
@ -78,15 +93,13 @@ public class DesignerContext {
//这样可以保证和TextField直接的copy paste
try {
//控件的Clipboard.
DesignerContext.clipboard = comp.getToolkit().getSystemClipboard();
clipboard = comp.getToolkit().getSystemClipboard();
} catch (Exception exp) {
FineLoggerFactory.getLogger().error(exp.getMessage(), exp);
DesignerContext.clipboard = new Clipboard("FR");
clipboard = new Clipboard("FR");
}
}
}
return DesignerContext.clipboard;
return clipboard;
}

27
designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java

@ -11,6 +11,7 @@ import com.fr.design.gui.ibutton.UIButtonUI;
import com.fr.design.gui.icontainer.UIEastResizableContainer;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.VerticalFlowLayout;
import com.fr.design.ui.util.UIUtil;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.design.utils.gui.GUIPaintUtils;
import com.fr.general.FRFont;
@ -150,12 +151,18 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
public void on(PluginEvent event) {
PluginContext context = event.getContext();
PluginRuntime runtime = context.getRuntime();
Set<PropertyItemPaneProvider> providers = runtime.get(PropertyItemPaneProvider.XML_TAG);
final Set<PropertyItemPaneProvider> providers = runtime.get(PropertyItemPaneProvider.XML_TAG);
// UI相关的逻辑 用UI线程执行 不走FinePluginController线程 走FinePluginController线程有几率出问题
// 容易导致FinePluginController持有Swing内部的java.awt.Component$AWTTreeLock 这个锁不能被UI线程之外的线程持有 否则容易造成UI线程被Blocked住
UIUtil.invokeLaterIfNeeded(new Runnable() {
@Override
public void run() {
for (PropertyItemPaneProvider provider : providers) {
addPropertyItem(provider);
}
updateAllPropertyPane();
}
}); }
}, filter);
PluginListenerRegistration.getInstance().listen(
PluginEventType.BeforeStop,
@ -164,13 +171,17 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
public void on(PluginEvent event) {
PluginContext context = event.getContext();
PluginRuntime runtime = context.getRuntime();
Set<PropertyItemPaneProvider> providers = runtime.get(PropertyItemPaneProvider.XML_TAG);
final Set<PropertyItemPaneProvider> providers = runtime.get(PropertyItemPaneProvider.XML_TAG);
UIUtil.invokeLaterIfNeeded(new Runnable() {
@Override
public void run() {
for (PropertyItemPaneProvider provider : providers) {
removePropertyItem(provider);
}
updateAllPropertyPane();
}
});
}
}, filter);
}
@ -240,7 +251,7 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
"floatelement", new PropertyMode[]{PropertyMode.REPORT, PropertyMode.REPORT_PARA, PropertyMode.REPORT_FLOAT, PropertyMode.POLY, PropertyMode.POLY_CHART},
new PropertyMode[]{PropertyMode.REPORT, PropertyMode.REPORT_FLOAT, PropertyMode.POLY_REPORT});
// 控件设置
PropertyItem widgetSettings = new PropertyItem(KEY_WIDGET_SETTINGS, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Widget_Settings"),
PropertyItem widgetSettings = new PropertyItem(KEY_WIDGET_SETTINGS, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Component_Settings"),
"widgetsettings", new PropertyMode[]{PropertyMode.REPORT, PropertyMode.REPORT_PARA, PropertyMode.REPORT_FLOAT, PropertyMode.FORM, PropertyMode.POLY},
new PropertyMode[]{PropertyMode.REPORT, PropertyMode.REPORT_PARA, PropertyMode.FORM, PropertyMode.POLY_REPORT, PropertyMode.POLY_CHART});
// 条件属性
@ -483,10 +494,16 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
propertyItemMap.get(KEY_CONFIGURED_ROLES).replaceContentPane(pane);
}
public void replaceKeyPane(String key, JComponent pane) {
public void replaceKeyPane(final String key, final JComponent pane) {
//需要放到 ui 线程中处理
UIUtil.invokeLaterIfNeeded(new Runnable() {
@Override
public void run() {
propertyItemMap.get(key).replaceContentPane(pane);
}
});
}
public JComponent getConfiguredRolesPane() {
return propertyItemMap.get(KEY_CONFIGURED_ROLES).getContentPane();

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

@ -97,7 +97,7 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
private static short currentIndex = 0;// 此变量用于多次新建模板时,让名字不重复
private DesignModelAdapter<T, ?> designModel;
private PreviewProvider previewType;
private TimeConsumeTimer consumeTimer = new TimeConsumeTimer();
protected TimeConsumeTimer consumeTimer = new TimeConsumeTimer();
public int resolution = ScreenResolution.getScreenResolution();
public JTemplate() {

17
designer-base/src/main/java/com/fr/design/mainframe/burying/point/AbstractPointCollector.java

@ -5,6 +5,8 @@ import com.fr.base.io.XMLReadHelper;
import com.fr.design.DesignerEnvManager;
import com.fr.design.mainframe.template.info.SendHelper;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.ProductConstants;
import com.fr.stable.StableUtils;
import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLTools;
import com.fr.stable.xml.XMLableReader;
@ -121,10 +123,23 @@ public abstract class AbstractPointCollector<T extends AbstractPointInfo> implem
}
}
private File getInfoFile() {
File file = new File(StableUtils.pathJoin(ProductConstants.getEnvHome(), getInfoFilePath()));
try {
if (!file.exists()) {
StableUtils.makesureFileExist(file);
}
} catch (Exception ex) {
FineLoggerFactory.getLogger().error(ex.getMessage(), ex);
}
return file;
}
/**
* 获取缓存文件存放路径
*/
protected abstract File getInfoFile();
protected abstract String getInfoFilePath();
protected abstract void addIdleDayCount();
}

9
designer-base/src/main/java/com/fr/design/mainframe/burying/point/AbstractPointInfo.java

@ -11,6 +11,9 @@ public abstract class AbstractPointInfo implements BasePointInfo {
protected int idleDayCount; // 到现在为止,埋点闲置的天数
//是否是测试模板
protected boolean testTemplate;
@Override
public void resetIdleDayCount() {
this.idleDayCount = 0;
@ -38,10 +41,14 @@ public abstract class AbstractPointInfo implements BasePointInfo {
}
}
public void setTestTemplate(boolean testTemplate) {
this.testTemplate = testTemplate;
}
/**
* 是否为测试模板
*/
protected abstract boolean isTestTemplate();
public abstract boolean isTestTemplate();
/**
* 是否已经制作完成

47
designer-base/src/main/java/com/fr/design/mainframe/chart/info/ChartInfo.java

@ -1,6 +1,10 @@
package com.fr.design.mainframe.chart.info;
import com.fr.base.io.BaseBook;
import com.fr.chartx.attr.ChartProvider;
import com.fr.chartx.config.info.AbstractConfig;
import com.fr.chartx.config.info.ChartConfigInfo;
import com.fr.chartx.config.info.constant.ConfigType;
import com.fr.config.MarketConfig;
import com.fr.design.DesignModelAdapter;
import com.fr.design.DesignerEnvManager;
@ -26,7 +30,7 @@ import java.util.Map;
public class ChartInfo extends AbstractPointInfo {
public static final String XML_TAG = "ChartInfo";
private static final String CHART_CONSUMING_URL = CloudCenter.getInstance().acquireUrlByKind("chartinfo.consuming") + "/single";
private static final String CHART_FUNCTION_URL = CloudCenter.getInstance().acquireUrlByKind("chart.info.function") + "/single";
private static final String XML_CHART_CONSUMING_MAP = "chartConsumingMap";
private static final String ATTR_TEST_TEMPLATE = "testTemplate";
@ -59,9 +63,10 @@ public class ChartInfo extends AbstractPointInfo {
private Map<String, String> chartConsumingMap = new HashMap<>();
private ChartConfigInfo chartConfigInfo = new ChartConfigInfo();
private BaseBook book;
private boolean testTemplate;
private boolean testChart;
@ -93,7 +98,6 @@ public class ChartInfo extends AbstractPointInfo {
this.chartConsumingMap.put(ATTR_TEMPLATE_ID, templateId);
}
public BaseBook getBook() {
return book;
}
@ -117,17 +121,19 @@ public class ChartInfo extends AbstractPointInfo {
return chartInfo;
}
public static ChartInfo newInstance(String chartId, String chartType) {
return newInstance(chartId, chartType, null, false, false);
public static ChartInfo newInstance(ChartProvider chartProvider) {
return newInstance(chartProvider, null, false, false);
}
public static ChartInfo newInstance(String chartId, String chartType, String createTime, boolean isNew, boolean isReuse) {
public static ChartInfo newInstance(ChartProvider chartProvider, String createTime, boolean isNew, boolean isReuse) {
HashMap<String, String> chartConsumingMap = new HashMap<>();
String username = MarketConfig.getInstance().getBbsUsername();
String userId = String.valueOf(MarketConfig.getInstance().getBbsUid());
String uuid = DesignerEnvManager.getEnvManager().getUUID();
String activityKey = DesignerEnvManager.getEnvManager().getActivationKey();
String chartId = chartProvider.getChartUuid();
String chartType = chartProvider.getID();
BaseBook book = DesignModelAdapter.getCurrentModelAdapter().getBook();
String templateId = book.getTemplateID();
@ -160,6 +166,7 @@ public class ChartInfo extends AbstractPointInfo {
ChartInfo chartInfo = new ChartInfo(chartId, templateId, book);
chartInfo.chartConsumingMap = chartConsumingMap;
chartProvider.initChartConfigInfo(chartInfo.chartConfigInfo);
return chartInfo;
}
@ -196,6 +203,8 @@ public class ChartInfo extends AbstractPointInfo {
writer.attr(ATTR_IS_NEW, chartConsumingMap.get(ATTR_IS_NEW));
writer.attr(ATTR_IS_REUSE, chartConsumingMap.get(ATTR_IS_REUSE));
writer.end();
chartConfigInfo.writeXML(writer);
writer.end();
}
@ -230,6 +239,9 @@ public class ChartInfo extends AbstractPointInfo {
chartConsumingMap.put(ATTR_IS_NEW, reader.getAttrAsString(ATTR_IS_NEW, StringUtils.EMPTY));
chartConsumingMap.put(ATTR_IS_REUSE, reader.getAttrAsString(ATTR_IS_REUSE, StringUtils.EMPTY));
}
if (ChartConfigInfo.XML_TAG.equals(name)) {
this.chartConfigInfo = (ChartConfigInfo) reader.readXMLObject(new ChartConfigInfo());
}
}
}
@ -243,9 +255,17 @@ public class ChartInfo extends AbstractPointInfo {
public Map<String, String> getSendInfo() {
Map<String, String> sendMap = new HashMap<>();
sendMap.put(CHART_CONSUMING_URL, new JSONObject(chartConsumingMap).toString());
sendMap.put(CHART_FUNCTION_URL, getFunctionJson());
return sendMap;
}
private String getFunctionJson() {
JSONObject jsonObject = JSONObject.create();
jsonObject.put("chartID", this.chartId);
chartConfigInfo.toJSONObject(jsonObject);
return jsonObject.toString();
}
public void updatePropertyTime() {
String propertyTime = DateTime.now().toString("yyyy-MM-dd HH:mm:ss");
@ -255,22 +275,32 @@ public class ChartInfo extends AbstractPointInfo {
chartConsumingMap.put(ATTR_CHART_PROPERTY_END_TIME, propertyTime);
}
public void updateChartType(String chartType) {
public void updateChartType(ChartProvider chartProvider) {
String typeTime = DateTime.now().toString("yyyy-MM-dd HH:mm:ss");
chartConsumingMap.put(ATTR_CHART_TYPE_TIME, typeTime);
chartConsumingMap.put(ATTR_CHART_TYPE, chartType);
chartConsumingMap.put(ATTR_CHART_TYPE, chartProvider.getID());
chartConsumingMap.put(ATTR_CHART_PROPERTY_FIRST_TIME, "");
chartConsumingMap.put(ATTR_CHART_PROPERTY_END_TIME, "");
String count = chartConsumingMap.get(ATTR_OVER_CHART_TYPE_COUNT);
count = StringUtils.isEmpty(count) ? "1" : String.valueOf(Integer.parseInt(count) + 1);
chartConsumingMap.put(ATTR_OVER_CHART_TYPE_COUNT, count);
resetChartConfigInfo(chartProvider);
}
public void resetChartConfigInfo(ChartProvider chartProvider) {
chartConfigInfo.reset();
chartProvider.initChartConfigInfo(chartConfigInfo);
}
public void updateFirstType(String chartType) {
chartConsumingMap.put(ATTR_FIRST_CHART_TYPE, chartType);
}
public void updateChartConfig(ConfigType configType, AbstractConfig config) {
chartConfigInfo.updateChartConfig(configType, config);
}
@Override
public ChartInfo clone() {
@ -284,6 +314,7 @@ public class ChartInfo extends AbstractPointInfo {
chartConsumingMap.put(entry.getKey(), entry.getValue());
}
chartInfo.chartConsumingMap = chartConsumingMap;
chartInfo.chartConfigInfo = chartConfigInfo.clone();
return chartInfo;
}
}

85
designer-base/src/main/java/com/fr/design/mainframe/chart/info/ChartInfoCollector.java

@ -2,19 +2,16 @@ package com.fr.design.mainframe.chart.info;
import com.fr.base.io.BaseBook;
import com.fr.chartx.attr.ChartProvider;
import com.fr.chartx.config.info.AbstractConfig;
import com.fr.chartx.config.info.constant.ConfigType;
import com.fr.design.mainframe.burying.point.AbstractPointCollector;
import com.fr.design.mainframe.template.info.TemplateInfo;
import com.fr.design.mainframe.template.info.TemplateProcessInfo;
import com.fr.general.ComparatorUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.ProductConstants;
import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils;
import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLableReader;
import com.fr.third.joda.time.DateTime;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
@ -55,63 +52,89 @@ public class ChartInfoCollector extends AbstractPointCollector<ChartInfo> {
collection(chartProvider, createTime, false);
}
public void collection(ChartProvider chartProvider, String createTime, boolean isReuse) {
collection(chartProvider.getChartUuid(), chartProvider.getID(), createTime, isReuse);
}
/**
* 新建图表保存状态
*/
public void collection(String chartId, String chartType, String createTime, boolean isReuse) {
public void collection(ChartProvider chartProvider, String createTime, boolean isReuse) {
String chartId = chartProvider.getChartUuid();
if (!shouldCollectInfo() || StringUtils.isEmpty(chartId)) {
return;
}
ChartInfo chartInfo = ChartInfo.newInstance(chartId, chartType, createTime, true, isReuse);
ChartInfo chartInfo = ChartInfo.newInstance(chartProvider, createTime, true, isReuse);
chartInfoCacheMap.put(chartId, chartInfo);
}
/**
* 图表编辑更新编辑时间
*/
public void updateChartPropertyTime(ChartProvider chartProvider) {
updateChartPropertyTime(chartProvider.getChartUuid(), chartProvider.getID());
if (!shouldCollectInfo() || StringUtils.isEmpty(chartProvider.getChartUuid())) {
return;
}
ChartInfo chartInfo = getOrCreateChartInfo(chartProvider);
//更新编辑时间
chartInfo.updatePropertyTime();
//重置计数
chartInfo.resetIdleDayCount();
}
/**
* 图表编辑更新编辑时间
*/
public void updateChartPropertyTime(String chartId, String chartType) {
if (!shouldCollectInfo() || StringUtils.isEmpty(chartId)) {
public void updateChartConfig(ChartProvider chartProvider, ConfigType configType, AbstractConfig config) {
if (!shouldCollectInfo() || StringUtils.isEmpty(chartProvider.getChartUuid())) {
return;
}
ChartInfo chartInfo = getOrCreateChartInfo(chartId, chartType, null);
ChartInfo chartInfo = getOrCreateChartInfo(chartProvider);
//更新编辑时间
chartInfo.updatePropertyTime();
//更新对应的配置
chartInfo.updateChartConfig(configType, config);
//重置计数
chartInfo.resetIdleDayCount();
}
public void updateChartTypeTime(ChartProvider chartProvider, String oldType) {
updateChartTypeTime(chartProvider.getChartUuid(), chartProvider.getID(), oldType);
/**
* 图表子类型更新
*/
public void updateChartMiniType(ChartProvider chartProvider) {
if (!shouldCollectInfo() || StringUtils.isEmpty(chartProvider.getChartUuid())) {
return;
}
ChartInfo chartInfo = getOrCreateChartInfo(chartProvider);
//图表子类型更新
chartInfo.resetChartConfigInfo(chartProvider);
//重置计数
chartInfo.resetIdleDayCount();
}
/**
* 图表类型变化更新类型和类型确认时间
*/
public void updateChartTypeTime(String chartId, String chartType, String oldType) {
if (!shouldCollectInfo() || StringUtils.isEmpty(chartId)) {
public void updateChartTypeTime(ChartProvider chartProvider, String oldType) {
if (!shouldCollectInfo() || StringUtils.isEmpty(chartProvider.getChartUuid())) {
return;
}
ChartInfo chartInfo = getOrCreateChartInfo(chartId, chartType, oldType);
ChartInfo chartInfo = getOrCreateChartInfo(chartProvider, oldType);
//更新类型确认时间和类型
chartInfo.updateChartType(chartType);
chartInfo.updateChartType(chartProvider);
//重置计数
chartInfo.resetIdleDayCount();
}
private ChartInfo getOrCreateChartInfo(String chartId, String chartType, String oldType) {
private ChartInfo getOrCreateChartInfo(ChartProvider chartProvider) {
return getOrCreateChartInfo(chartProvider, null);
}
private ChartInfo getOrCreateChartInfo(ChartProvider chartProvider, String oldType) {
String chartId = chartProvider.getChartUuid();
//缓存中有从缓存中拿
if (chartInfoCacheMap.containsKey(chartId)) {
return chartInfoCacheMap.get(chartId);
@ -123,7 +146,7 @@ public class ChartInfoCollector extends AbstractPointCollector<ChartInfo> {
return chartInfo;
}
//都没有的话创建一个并加入到缓存中
ChartInfo chartInfo = ChartInfo.newInstance(chartId, chartType);
ChartInfo chartInfo = ChartInfo.newInstance(chartProvider);
if (StringUtils.isNotEmpty(oldType)) {
chartInfo.updateFirstType(oldType);
}
@ -207,16 +230,8 @@ public class ChartInfoCollector extends AbstractPointCollector<ChartInfo> {
* 获取缓存文件存放路径
*/
@Override
protected File getInfoFile() {
File file = new File(StableUtils.pathJoin(ProductConstants.getEnvHome(), XML_FILE_NAME));
try {
if (!file.exists()) {
file.createNewFile();
}
} catch (Exception ex) {
FineLoggerFactory.getLogger().error(ex.getMessage(), ex);
}
return file;
protected String getInfoFilePath() {
return XML_FILE_NAME;
}
@Override

2
designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogHandler.java

@ -45,7 +45,7 @@ public class DesignerLogHandler {
private final SimpleDateFormat LOG_SIMPLE_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
private static final int GAP_X = -150;
private static final int GAP_X = -75;
private static final int INFO_GAP_Y = -60;

107
designer-base/src/main/java/com/fr/design/mainframe/loghandler/LogHandlerBar.java

@ -2,26 +2,39 @@ package com.fr.design.mainframe.loghandler;
import com.fr.base.BaseUtils;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.ui.util.UIUtil;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.concurrent.atomic.AtomicBoolean;
import static com.fr.design.i18n.Toolkit.i18nText;
public class LogHandlerBar extends JPanel implements ItemSelectable {
// 可以作为常量 提前初始化 不用每次都去实时频繁的读取
private static final String NORMAL_MARK = i18nText("Fine-Design_Basic_NNormal");
private static final String ALERT_MARK = i18nText("Fine-Design_Basic_Alert");
private static final String SERIOUSLY_MARK = i18nText("Fine-Design_Basic_Seriously");
private static final long serialVersionUID = 1L;
private ItemListener listeners;
private UIButton clear;
private UIButton selectedall;
private UIButton set;
private UILabel normalLabel;
private UILabel alertLabel;
private UILabel seriouslyLabel;
private String text;
private int INFONUM = 0;
private int ERRORNUM = 0;
private int SERVERNUM = 0;
private static final int FLOW_LAYOUT_HGAP = 10;
private static final int FLOW_LAYOUT_VGAP = 5;
private boolean isWithSerious;
@ -30,33 +43,57 @@ public class LogHandlerBar extends JPanel implements ItemSelectable {
}
public LogHandlerBar(String text) {
this.setLayout(new CaptionLayout());
this.setLayout(new FlowLayout(FlowLayout.RIGHT, FLOW_LAYOUT_HGAP, FLOW_LAYOUT_VGAP));
this.setUI(new LogHandlerBarUI());
this.text = text;
clear = new UIButton(BaseUtils.readIcon("com/fr/design/images/log/clear.png"));
clear.setMargin(null);
clear.setOpaque(false);
clear.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
clear.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Clear_All"));
clear.setToolTipText(i18nText("Fine-Design_Basic_Clear_All"));
selectedall = new UIButton(BaseUtils.readIcon("com/fr/design/images/log/selectedall.png"));
selectedall.setMargin(null);
selectedall.setOpaque(false);
selectedall.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
selectedall.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Select_All"));
selectedall.setToolTipText(i18nText("Fine-Design_Basic_Select_All"));
set = new UIButton(BaseUtils.readIcon("com/fr/design/images/log/setting.png"));
set.setMargin(null);
set.setOpaque(false);
set.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
set.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Set"));
set.setToolTipText(i18nText("Fine-Design_Report_Set"));
normalLabel = new UILabel(i18nText("Fine-Design_Basic_NNormal") + "(0)");
alertLabel = new UILabel(i18nText("Fine-Design_Basic_Alert") + "(0)");
seriouslyLabel = new UILabel(i18nText("Fine-Design_Basic_Seriously") + "(0)");
this.add(normalLabel);
this.add(alertLabel);
this.add(seriouslyLabel);
this.add(clear);
this.add(selectedall);
this.add(set);
}
/**
* 更新日志数量统计标签
*/
private void changeLabel() {
UIUtil.invokeLaterIfNeeded(new Runnable() {
@Override
public void run() {
// 这块逻辑执行地很频繁
// 容易造成 AWT 与 FinePluginController 发生死锁
// in18Text每次读取 资源的时候 都会走下插件引擎逻辑去读取下插件的资源
// 应该避免每次都去读取 可以作为常量提前初始化好 避免与FinePluginController的竞争
normalLabel.setText(NORMAL_MARK + '(' + getInfo() + ')');
alertLabel.setText(ALERT_MARK + '(' + getError() + ')');
seriouslyLabel.setText(SERIOUSLY_MARK + '(' + getServer() + ')');
}
});
}
public void clearMessage() {
INFONUM = ERRORNUM = SERVERNUM = 0;
repaint();
changeLabel();
}
public boolean IsWithSerious() {
@ -69,27 +106,17 @@ public class LogHandlerBar extends JPanel implements ItemSelectable {
public void infoAdd() {
INFONUM++;
repaint();
changeLabel();
}
public void errorAdd() {
ERRORNUM++;
timerPaint();
changeLabel();
}
public void serverAdd() {
SERVERNUM++;
timerPaint();
}
private AtomicBoolean painting = new AtomicBoolean(false);
public void timerPaint() {
if(!painting.get()) {
painting.set(true);
repaint();
painting.set(false);
}
changeLabel();
}
public int getInfo() {
@ -141,44 +168,4 @@ public class LogHandlerBar extends JPanel implements ItemSelectable {
public void addSetListener(ActionListener l) {
set.addActionListener(l);
}
private class CaptionLayout implements LayoutManager {
@Override
public void addLayoutComponent(String name, Component comp) {
}
@Override
public void removeLayoutComponent(Component comp) {
}
@Override
public Dimension preferredLayoutSize(Container parent) {
return new Dimension(120, 24);
}
@Override
public Dimension minimumLayoutSize(Container parent) {
return new Dimension(0, 0);
}
@Override
public void layoutContainer(Container target) {
Insets insets = target.getInsets();
int top = insets.top;
int right = target.getWidth() - insets.right;
clear.setBounds(right - CLEAR_OFFSET, top + TOP_OFFSET, clear.getPreferredSize().width, clear.getPreferredSize().height);
selectedall.setBounds(right - SELECT_OFFSET, top + TOP_OFFSET, selectedall.getPreferredSize().width, selectedall.getPreferredSize().height);
set.setBounds(right - SET_OFFSET, top + TOP_OFFSET, set.getPreferredSize().width, set.getPreferredSize().height);
}
private static final int CLEAR_OFFSET = 130;
private static final int TOP_OFFSET = 4;
private static final int SELECT_OFFSET = 100;
private static final int SET_OFFSET = 70;
}
}

9
designer-base/src/main/java/com/fr/design/mainframe/loghandler/LogHandlerBarUI.java

@ -1,5 +1,7 @@
package com.fr.design.mainframe.loghandler;
import javax.swing.JComponent;
import javax.swing.plaf.ComponentUI;
import java.awt.Color;
import java.awt.Cursor;
import java.awt.FontMetrics;
@ -11,9 +13,6 @@ import java.awt.event.FocusListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import javax.swing.JComponent;
import javax.swing.plaf.ComponentUI;
public class LogHandlerBarUI extends ComponentUI implements MouseListener, FocusListener {
@ -99,10 +98,6 @@ public class LogHandlerBarUI extends ComponentUI implements MouseListener, Focus
if (button.getText() != null) {
g.drawString(button.getText(), textLeadingGap, y);
}
g.drawString(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_NNormal") + '(' + button.getInfo() + ')', button.getWidth() - 310, y);
g.drawString(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Alert") + '(' + button.getError() + ')', button.getWidth() - 250, y);
g.drawString(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Seriously") + '(' + button.getServer() + ')', button.getWidth() - 190, y);
}
/**

50
designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileCollapsedStyleExpandPane.java

@ -6,13 +6,12 @@ import com.fr.design.gui.itextfield.UIIntNumberField;
import com.fr.design.gui.itextfield.UINumberField;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.widget.UITitleSplitLine;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.form.ui.mobile.MobileCollapsedStyle;
import com.fr.form.ui.mobile.MobileFormCollapsedStyle;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Dimension;
import javax.swing.*;
import java.awt.*;
/**
* @author hades
@ -21,34 +20,45 @@ import java.awt.Dimension;
*/
public class MobileCollapsedStyleExpandPane extends MobileCollapsedStylePane {
private static final Dimension DEFAULT_SPINNER_SIZE = new Dimension(60, 24);
private UISpinner rowSpinner;
public MobileCollapsedStyleExpandPane() {
}
@Override
protected JPanel createLinePane() {
UITitleSplitLine splitLine = new UITitleSplitLine(Toolkit.i18nText("Fine-Design_Mobile_Collapse_Line_Number"), 520);
splitLine.setPreferredSize(new Dimension(520, 20));
protected void createConfigPanes(JPanel settingPane) {
JPanel lineNumberConfigPane = this.createLineNumberConfigPane();
settingPane.add(lineNumberConfigPane);
super.createConfigPanes(settingPane);
}
protected JPanel createLineNumberConfigPane() {
JPanel configPane = super.createTitleConfigPane(Toolkit.i18nText("Fine-Design_Mobile_Collapse_Line_Number"));
UILabel collapseLocationLabel = createLabel(Toolkit.i18nText("Fine-Design_Mobile_Collapse_Show_Button"));
this.rowSpinner = new UISpinner(1, Integer.MAX_VALUE, 1, 1) {
@Override
protected UINumberField initNumberField(){
return new UIIntNumberField();
}
};
rowSpinner.setPreferredSize(DEFAULT_SPINNER_SIZE);
JPanel panel = new JPanel();
panel.setLayout(FRGUIPaneFactory.createBoxFlowLayout());
panel.add(new UILabel(Toolkit.i18nText("Fine-Design_Mobile_Collapse_Start_From")));
panel.add(rowSpinner);
panel.add(new UILabel(Toolkit.i18nText("Fine-Design_Mobile_Collapse_Row_To_Fold")));
JPanel linePane = FRGUIPaneFactory.createBorderLayout_S_Pane();
linePane.add(splitLine, BorderLayout.NORTH);
linePane.add(panel, BorderLayout.CENTER);
return linePane;
this.rowSpinner.setPreferredSize(new Dimension(62, COMPONENT_HEIGHT));
JPanel defaultCollapsedStatePanel = FRGUIPaneFactory.createLeftFlowZeroGapBorderPane();
defaultCollapsedStatePanel.add(createLabel(Toolkit.i18nText("Fine-Design_Mobile_Collapse_Start_From") + " "));
defaultCollapsedStatePanel.add(rowSpinner);
defaultCollapsedStatePanel.add(createLabel(" " + Toolkit.i18nText("Fine-Design_Mobile_Collapse_Row_To_Fold")));
double[] rowSize = {COMPONENT_HEIGHT};
double[] columnSize = {LABEL_WIDTH, COMPONENT_WIDTH};
double[] verticalGaps = {0};
JPanel navButtonSettingsPanel = TableLayoutHelper.createDiffVGapTableLayoutPane(new JComponent[][]{
{collapseLocationLabel, defaultCollapsedStatePanel},
}, rowSize, columnSize, 5, verticalGaps);
navButtonSettingsPanel.setBorder(BorderFactory.createEmptyBorder(10, 0, 15, 0));
configPane.add(navButtonSettingsPanel);
return configPane;
}
@Override

153
designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileCollapsedStylePane.java

@ -1,8 +1,6 @@
package com.fr.design.mainframe.mobile.ui;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.constants.LayoutConstants;
import com.fr.design.designer.IntervalConstants;
import com.fr.design.gui.ibutton.ModeButtonGroup;
import com.fr.design.gui.ibutton.UIRadioButton;
import com.fr.design.gui.icheckbox.UICheckBox;
@ -10,9 +8,7 @@ import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itextfield.UITextField;
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.layout.VerticalFlowLayout;
import com.fr.design.mainframe.widget.UITitleSplitLine;
import com.fr.design.style.color.NewColorSelectBox;
import com.fr.design.utils.gui.GUICoreUtils;
@ -21,13 +17,7 @@ import com.fr.form.ui.mobile.MobileChartCollapsedStyle;
import com.fr.form.ui.mobile.MobileCollapsedStyle;
import javax.swing.*;
import javax.swing.border.TitledBorder;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.*;
/**
* @author hades
@ -36,6 +26,13 @@ import java.awt.FlowLayout;
*/
public class MobileCollapsedStylePane extends BasicBeanPane<MobileCollapsedStyle> {
public final static Color THEME_COLOR = Color.decode("#2F8EF1");
public final static Font TEXT_FONT = new Font("Default", Font.PLAIN, 12);
public final static Color TEXT_FONT_COLOR = Color.decode("#333334");
public final static int LABEL_WIDTH = 96;
public final static int COMPONENT_HEIGHT = 20;
public final static int COMPONENT_WIDTH = 160;
private UICheckBox showButtonCheck;
private NewColorSelectBox buttonColorBox;
private UITextField foldedTextFiled;
@ -44,74 +41,94 @@ public class MobileCollapsedStylePane extends BasicBeanPane<MobileCollapsedStyle
public MobileCollapsedStylePane() {
TitledBorder titledBorder = GUICoreUtils.createTitledBorder(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Set"), null);
VerticalFlowLayout layout = new VerticalFlowLayout(FlowLayout.LEADING, 0, 10);
layout.setAlignLeft(true);
this.setBorder(titledBorder);
this.setLayout(layout);
this.add(createLinePane());
this.add(createSettingPane());
this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
this.setBorder(BorderFactory.createEmptyBorder( 10, 5, 0, 5));
JPanel settingPane = this.createSettingPane();
this.createConfigPanes(settingPane);
this.add(settingPane);
}
private JPanel createSettingPane() {
JPanel settingPane = FRGUIPaneFactory.createVerticalFlowLayout_Pane(true, FlowLayout.LEADING, 0, 0);
UITitleSplitLine splitLine = new UITitleSplitLine(Toolkit.i18nText("Fine-Design_Mobile_Collapse_Button"), 520);
splitLine.setPreferredSize(new Dimension(520, 20));
UILabel showButtonLabel = new UILabel(Toolkit.i18nText("Fine-Design_Mobile_Collapse_Show_Button"));
showButtonCheck = new UICheckBox(Toolkit.i18nText("Fine-Design_Mobile_Collapse_Show_Button_On_Right"));
showButtonCheck.setPreferredSize(new Dimension(140, 24));
UILabel buttonColorLabel = new UILabel(Toolkit.i18nText("Fine-Design_Mobile_Collapse_Button_Color"));
buttonColorBox = new NewColorSelectBox(137);
UILabel foldedLabel = new UILabel(Toolkit.i18nText("Fine-Design_Mobile_Collapse_Folded_Hint"));
JPanel settingPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane();
settingPane.setBorder(GUICoreUtils.createTitledBorder(Toolkit.i18nText("Fine-Design_Report_Set"), THEME_COLOR));
return settingPane;
}
protected UILabel createLabel(String text) {
UILabel label = new UILabel(text, SwingConstants.RIGHT);
label.setForeground(TEXT_FONT_COLOR);
label.setFont(TEXT_FONT);
return label;
}
protected void createConfigPanes(JPanel settingPane) {
JPanel collapsedButtonConfigPane = this.createCollapsedButtonConfigPane();
settingPane.add(collapsedButtonConfigPane);
}
protected JPanel createTitleConfigPane(String title) {
JPanel configPane = new JPanel();
configPane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
configPane.setLayout(new BoxLayout(configPane, BoxLayout.Y_AXIS));
Dimension titleLineDim = new Dimension(610, 20);
UITitleSplitLine splitLine = new UITitleSplitLine(title, titleLineDim.width);
splitLine.setPreferredSize(titleLineDim);
configPane.add(splitLine);
return configPane;
}
private JPanel createCollapsedButtonConfigPane() {
JPanel configPane = this.createTitleConfigPane(Toolkit.i18nText("Fine-Design_Mobile_Collapse_Button"));
UILabel showButtonLabel = this.createLabel(Toolkit.i18nText("Fine-Design_Mobile_Collapse_Show_Button"));
showButtonCheck = new UICheckBox(Toolkit.i18nText(Toolkit.i18nText("Fine-Design_Mobile_Collapse_Show_Button_On_Right")));
showButtonCheck.setForeground(TEXT_FONT_COLOR);
showButtonCheck.setFont(TEXT_FONT);
UILabel buttonColorLabel = this.createLabel(Toolkit.i18nText("Fine-Design_Mobile_Collapse_Button_Color"));
buttonColorBox = new NewColorSelectBox(COMPONENT_WIDTH);
UILabel foldedLabel = this.createLabel(Toolkit.i18nText("Fine-Design_Mobile_Collapse_Folded_Hint"));
foldedTextFiled = new UITextField();
UILabel unfoldedLabel = new UILabel(Toolkit.i18nText("Fine-Design_Mobile_Collapse_UnFolded_Hint"));
UILabel unfoldedLabel = this.createLabel(Toolkit.i18nText("Fine-Design_Mobile_Collapse_UnFolded_Hint"));
unfoldedTextFiled = new UITextField();
UILabel defaultStateLabel = new UILabel(Toolkit.i18nText("Fine-Design_Mobile_Collapse_Default_State"));
buttonGroup = new ModeButtonGroup<>();
UILabel defaultCollapsedStateLabel = this.createLabel(Toolkit.i18nText("Fine-Design_Mobile_Collapse_Default_State"));
JPanel defaultCollapsedStatePanel = FRGUIPaneFactory.createLeftFlowZeroGapBorderPane();
UIRadioButton foldedButton = new UIRadioButton(Toolkit.i18nText("Fine-Design_Mobile_Collapse_Fold"));
foldedButton.setSelected(true);
foldedButton.setPreferredSize(new Dimension(COMPONENT_WIDTH / 2, COMPONENT_HEIGHT));
foldedButton.setForeground(TEXT_FONT_COLOR);
foldedButton.setFont(TEXT_FONT);
UIRadioButton unfoldedButton = new UIRadioButton(Toolkit.i18nText("Fine-Design_Mobile_Collapse_Unfold"));
unfoldedButton.setPreferredSize(new Dimension(COMPONENT_WIDTH / 2, COMPONENT_HEIGHT));
unfoldedButton.setForeground(TEXT_FONT_COLOR);
unfoldedButton.setFont(TEXT_FONT);
defaultCollapsedStatePanel.add(foldedButton);
defaultCollapsedStatePanel.add(unfoldedButton);
buttonGroup = new ModeButtonGroup<>();
buttonGroup.put(CollapseState.FOLDED, foldedButton);
buttonGroup.put(CollapseState.UNFOLDED, unfoldedButton);
JPanel flowLeftPane = FRGUIPaneFactory.createNormalFlowInnerContainer_M_Pane();
flowLeftPane.add(foldedButton);
flowLeftPane.add(unfoldedButton);
Component[][] northComponents = new Component[][] {
new Component[] {showButtonLabel, showButtonCheck}
};
Component[][] southComponents = new Component[][] {
new Component[] {defaultStateLabel, flowLeftPane}
};
double f = TableLayout.FILL;
double p = TableLayout.PREFERRED;
double[] rowSize = {p, p, p, p, p};
double[] colSize = {p, f};
int[][] rowCount = {{1, 1}, {1, 1}, {1, 1}};
Component[][] centerComponents = new Component[][] {
new Component[] {buttonColorLabel, buttonColorBox},
new Component[] {foldedLabel, foldedTextFiled},
new Component[] {unfoldedLabel, unfoldedTextFiled},
};
JPanel northPane = TableLayoutHelper.createGapTableLayoutPane(northComponents, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W2, IntervalConstants.INTERVAL_L1);
JPanel southPane = TableLayoutHelper.createGapTableLayoutPane(southComponents, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W1, IntervalConstants.INTERVAL_L1);
final JPanel centerPane = TableLayoutHelper.createGapTableLayoutPane(centerComponents, rowSize, colSize, rowCount, LayoutConstants.HGAP_LARGE, LayoutConstants.VGAP_SMALL);
JPanel panel = FRGUIPaneFactory.createBorderLayout_S_Pane();
panel.add(northPane, BorderLayout.NORTH);
panel.add(centerPane, BorderLayout.CENTER);
panel.add(southPane, BorderLayout.SOUTH);
settingPane.add(splitLine);
settingPane.add(panel);
showButtonCheck.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
centerPane.setVisible(showButtonCheck.isSelected());
}
});
return settingPane;
}
protected JPanel createLinePane() {
return FRGUIPaneFactory.createBorderLayout_S_Pane();
double[] rowSize = {COMPONENT_HEIGHT, COMPONENT_HEIGHT, COMPONENT_HEIGHT, COMPONENT_HEIGHT, COMPONENT_HEIGHT};
double[] columnSize = {LABEL_WIDTH, COMPONENT_WIDTH};
double[] verticalGaps = {10, 10, 10, 10, 10};
JPanel contentPane = TableLayoutHelper.createDiffVGapTableLayoutPane(new JComponent[][]{
{showButtonLabel, showButtonCheck},
{buttonColorLabel, buttonColorBox},
{foldedLabel, foldedTextFiled},
{unfoldedLabel, unfoldedTextFiled},
{defaultCollapsedStateLabel, defaultCollapsedStatePanel}
}, rowSize, columnSize, 5, verticalGaps);
contentPane.setBorder(BorderFactory.createEmptyBorder(10, 0, 15, 0));
configPane.add(contentPane);
return configPane;
}
@Override

5
designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileComboBoxDialogEditor.java

@ -9,8 +9,8 @@ import com.fr.design.i18n.Toolkit;
import com.fr.form.ui.mobile.MobileCollapsedStyle;
import com.fr.general.ComparatorUtils;
import javax.swing.SwingUtilities;
import java.awt.Dimension;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
@ -33,6 +33,7 @@ public class MobileComboBoxDialogEditor extends BasicPane {
private ActionListener listener;
public MobileComboBoxDialogEditor(MobileCollapsedStylePane stylePane) {
this.setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
this.stylePane = stylePane;
this.comboBox = new UIComboBox(new Object[] {NONE, CUSTOM});
this.comboBox.setPreferredSize(COMBOX_DIMENSION);

135
designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileStyleDefinePane.java

@ -2,29 +2,57 @@ package com.fr.design.mainframe.mobile.ui;
import com.fr.base.background.ColorBackground;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.constants.LayoutConstants;
import com.fr.design.designer.IntervalConstants;
import com.fr.design.gui.icombobox.LineComboBox;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.ispinner.UISpinner;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.style.color.ColorSelectBox;
import com.fr.design.style.color.NewColorSelectBox;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.form.ui.Widget;
import com.fr.form.ui.mobile.MobileStyle;
import com.fr.general.FRFont;
import com.fr.invoke.Reflect;
import com.fr.stable.Constants;
import javax.swing.*;
import javax.swing.JPanel;
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.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
public class MobileStyleDefinePane extends BasicBeanPane<MobileStyle> {
public class MobileStyleDefinePane extends BasicBeanPane<MobileStyle> {
private final static int[] BORDER_LINE_STYLE_ARRAY = new int[]{
Constants.LINE_NONE,
Constants.LINE_THIN, //1px
Constants.LINE_MEDIUM, //2px
Constants.LINE_THICK, //3px
};
private static final int NORMAL_COMBO_WIDTH = 152;
private Widget widget;
private MobileStyleCustomDefinePane customBeanPane;
private Class<? extends MobileStyle> mobileStyleClazz;
private UIComboBox customCombo;
private JPanel settingPane;
private ColorSelectBox colorSelectBox;
private Color titleColor = new Color(47, 142, 241);
private JPanel commomPane;
private LineComboBox borderType;
private NewColorSelectBox borderColor;
private UISpinner borderRadius;
private NewColorSelectBox iconColor;
private MobileStyleFontConfigPane fontConfigPane;
MobileStyleDefinePane(Widget widget, Class<? extends MobileStyleCustomDefinePane> customBeanPaneClass,
Class<? extends MobileStyle> mobileStyleClazz) {
@ -37,9 +65,22 @@ public class MobileStyleDefinePane extends BasicBeanPane<MobileStyle> {
@Override
public void populateBean(MobileStyle ob) {
this.customBeanPane.populateBean(ob);
customCombo.setSelectedIndex(ob.isCommonCustom() ? 1 : 0);
if(ob.getBackground() != null) {
colorSelectBox.setSelectObject(((ColorBackground)ob.getBackground()).getColor());
}
borderType.setSelectedLineStyle(ob.getBorderType());
if (ob.getBorderColor() != null) {
borderColor.setSelectObject(ob.getBorderColor());
}
borderRadius.setValue(ob.getBorderRadius());
if (ob.getIconColor() != null) {
iconColor.setSelectObject(ob.getIconColor());
}
if (ob.getFont() != null) {
fontConfigPane.populateBean(ob.getFont());
}
}
@Override
@ -47,7 +88,13 @@ public class MobileStyleDefinePane extends BasicBeanPane<MobileStyle> {
MobileStyle mobileStyle = Reflect.on(mobileStyleClazz).create().get();
this.widget.setMobileStyle(mobileStyle);
this.customBeanPane.updateBean();
mobileStyle.setCommonCustom(customCombo.getSelectedIndex() == 1);
mobileStyle.setBackground(ColorBackground.getInstance(colorSelectBox.getSelectObject()));
mobileStyle.setBorderType(borderType.getSelectedLineStyle());
mobileStyle.setBorderColor(borderColor.getSelectObject());
mobileStyle.setBorderRadius(borderRadius.getValue());
mobileStyle.setIconColor(iconColor.getSelectObject());
mobileStyle.setFont(fontConfigPane.updateBean());
return mobileStyle;
}
@ -64,7 +111,7 @@ public class MobileStyleDefinePane extends BasicBeanPane<MobileStyle> {
private void createGeneralPane() {
createPreviewPane();
createBackgroundPane();
createCommonPane();
}
private void createPreviewPane() {
@ -79,29 +126,62 @@ public class MobileStyleDefinePane extends BasicBeanPane<MobileStyle> {
}
}
private void createBackgroundPane() {
private void createCommonPane() {
TitledBorder titledBorder = createTitledBorder(Toolkit.i18nText("Fine-Design_Mobile_Common_Attribute"));
commomPane = FRGUIPaneFactory.createVerticalFlowLayout_Pane(true, FlowLayout.LEADING, 0, 10);
commomPane.setBorder(titledBorder);
this.add(commomPane, BorderLayout.NORTH);
customCombo = new UIComboBox(new String[]{Toolkit.i18nText("Fine-Design_Mobile_Default"), Toolkit.i18nText("Fine-Design_Mobile_Custom")});
customCombo.setSelectedIndex(0);
customCombo.setPreferredSize(new Dimension(NORMAL_COMBO_WIDTH + 15, 20));
customCombo.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
boolean custom = customCombo.getSelectedIndex() == 1;
settingPane.setVisible(custom);
}
});
commomPane.add(createLeftRightComponentsPane(createConfigLabel(Toolkit.i18nText("Fine-Design_Mobile_Attribute_Settings")), customCombo));
JPanel backgroundPane = new JPanel();
backgroundPane.setLayout(new FlowLayout(FlowLayout.LEFT, 10, 5));
backgroundPane.setPreferredSize(new Dimension(500, 65));
settingPane = FRGUIPaneFactory.createVerticalFlowLayout_Pane(true, FlowLayout.LEADING, 0, 10);
settingPane.setVisible(false);
commomPane.add(settingPane);
TitledBorder titledBorder = createTitledBorder(Toolkit.i18nText("Fine-Design_Mobile_Common_Attribute"));
backgroundPane.setBorder(titledBorder);
createBackgroundPane();
createBorderPane();
createIconSettingPane();
createFontPane();
}
UILabel colorSelectLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Widget_Background"), UILabel.RIGHT);
colorSelectLabel.setPreferredSize(new Dimension(65, 20));
private void createBackgroundPane() {
colorSelectBox = new ColorSelectBox(NORMAL_COMBO_WIDTH);
colorSelectBox = new ColorSelectBox(152);
colorSelectBox.addSelectChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
JPanel backgroundPane = createLeftRightComponentsPane(createConfigLabel(Toolkit.i18nText("Fine-Design_Mobile_Widget_Background")), colorSelectBox);
settingPane.add(backgroundPane);
}
private void createBorderPane() {
borderType = new LineComboBox(BORDER_LINE_STYLE_ARRAY);
borderType.setSelectedLineStyle(Constants.LINE_THIN);
borderType.setPreferredSize(new Dimension(NORMAL_COMBO_WIDTH + 15, 20));
borderColor = new NewColorSelectBox(NORMAL_COMBO_WIDTH);
borderRadius = new UISpinner(0, Integer.MAX_VALUE, 1, 2);
borderRadius.setPreferredSize(new Dimension(NORMAL_COMBO_WIDTH + 20, 20));
settingPane.add(createLeftRightComponentsPane(createConfigLabel(Toolkit.i18nText("Fine-Design_Mobile_Widget_BorderType")), borderType));
settingPane.add(createLeftRightComponentsPane(createConfigLabel(Toolkit.i18nText("Fine-Design_Mobile_Widget_BorderColor")), borderColor));
settingPane.add(createLeftRightComponentsPane(createConfigLabel(Toolkit.i18nText("Fine-Design_Mobile_Widget_BorderRadius")), borderRadius));
}
});
backgroundPane.add(colorSelectLabel);
backgroundPane.add(colorSelectBox);
private void createIconSettingPane() {
iconColor = new NewColorSelectBox(NORMAL_COMBO_WIDTH);
iconColor.setSelectObject(new Color(31,173,229));
settingPane.add(createLeftRightComponentsPane(createConfigLabel(Toolkit.i18nText("Fine-Design_Mobile_Widget_Icon_Color")), iconColor));
}
this.add(backgroundPane, BorderLayout.NORTH);
private void createFontPane() {
fontConfigPane = new MobileStyleFontConfigPane();
settingPane.add(createLeftRightComponentsPane(createConfigLabel(Toolkit.i18nText("Fine-Design_Mobile_Widget_Font")), fontConfigPane));
}
private void createCustomPane() {
@ -109,6 +189,7 @@ public class MobileStyleDefinePane extends BasicBeanPane<MobileStyle> {
TitledBorder titledBorder = createTitledBorder(Toolkit.i18nText("Fine-Design_Report_Set"));
configPane.setBorder(titledBorder);
JPanel container = FRGUIPaneFactory.createVerticalFlowLayout_Pane(true, FlowLayout.LEADING, 0, 10);
configPane.add(this.customBeanPane, BorderLayout.CENTER);
this.add(configPane, BorderLayout.CENTER);
@ -119,4 +200,14 @@ public class MobileStyleDefinePane extends BasicBeanPane<MobileStyle> {
titledBorder.setTitleFont(FRFont.getInstance("PingFangSC-Regular", Font.PLAIN, 12));
return titledBorder;
}
private UILabel createConfigLabel(String title) {
UILabel label = new UILabel(title + ":", UILabel.RIGHT);
label.setPreferredSize(new Dimension(75, 20));
return label;
}
private JPanel createLeftRightComponentsPane(Component... components) {
return TableLayoutHelper.createGapTableLayoutPane(new Component[][]{components}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_MEDIUM);
}
}

122
designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileStyleFontConfigPane.java

@ -0,0 +1,122 @@
package com.fr.design.mainframe.mobile.ui;
import com.fr.base.BaseUtils;
import com.fr.design.constants.LayoutConstants;
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.icombobox.UIComboBoxRenderer;
import com.fr.design.i18n.Toolkit;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.FRFont;
import com.fr.stable.Constants;
import com.fr.stable.StringUtils;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.util.Vector;
public class MobileStyleFontConfigPane extends JPanel {
public static final int FONT_NONE = 0;
private static final int MAX_FONT_SIZE = 18;
private static final int MIN_FONT_SIZE = 12;
private static final Dimension BUTTON_SIZE = new Dimension(20, 18);
public static Vector<Integer> getFontSizes() {
Vector<Integer> FONT_SIZES = new Vector<Integer>();
for (int i = MIN_FONT_SIZE; i <= MAX_FONT_SIZE; i++) {
FONT_SIZES.add(i);
}
return FONT_SIZES;
}
private UIComboBox fontSizeComboBox;
private UIColorButton color;
private UIToggleButton italic;
private UIToggleButton bold;
public MobileStyleFontConfigPane() {
this.initComponent();
}
private void initComponent() {
fontSizeComboBox = new UIComboBox();
fontSizeComboBox.setModel(new DefaultComboBoxModel(getFontSizes()));
fontSizeComboBox.setSelectedItem(16);
fontSizeComboBox.setPreferredSize(new Dimension(60, 20));
fontSizeComboBox.setRenderer(new LineCellRenderer());
color = new UIColorButton();
italic = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/italic.png"));
bold = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/bold.png"));
this.setButtonsTips();
this.setButtonsSize(BUTTON_SIZE);
Component[] components_font = new Component[]{
fontSizeComboBox, color, italic, bold
};
JPanel buttonPane = new JPanel(new BorderLayout());
buttonPane.add(GUICoreUtils.createFlowPane(components_font, FlowLayout.LEFT, LayoutConstants.HGAP_LARGE));
this.setLayout(new BorderLayout(0,0));
this.add(buttonPane, BorderLayout.CENTER);
}
private void setButtonsTips() {
color.setToolTipText(Toolkit.i18nText("Fine-Design_Report_Foreground"));
italic.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Italic"));
bold.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Bold"));
}
private void setButtonsSize(Dimension size) {
color.setPreferredSize(size);
italic.setPreferredSize(size);
bold.setPreferredSize(size);
}
public void populateBean(FRFont frFont) {
fontSizeComboBox.setSelectedItem(frFont.getSize());
color.setColor(frFont.getForeground());
bold.setSelected(frFont.isBold());
italic.setSelected(frFont.isItalic());
}
public FRFont updateBean() {
int style = Font.PLAIN;
style += this.bold.isSelected() ? Font.BOLD : Font.PLAIN;
style += this.italic.isSelected() ? Font.ITALIC : Font.PLAIN;
return FRFont.getInstance(
FRFont.DEFAULT_FONTNAME,
style,
Float.parseFloat(fontSizeComboBox.getSelectedItem().toString()),
color.getColor(),
Constants.LINE_NONE
);
}
private class LineCellRenderer extends UIComboBoxRenderer {
public LineCellRenderer() {
super();
}
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
JLabel renderer =(JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
int currentValue = ((Integer) value).intValue();
if (currentValue == MobileStyleFontConfigPane.FONT_NONE) {
renderer.setText(StringUtils.BLANK + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_None"));
}
return renderer;
}
}
}

116
designer-base/src/main/java/com/fr/design/mainframe/template/info/TemplateInfo.java

@ -4,15 +4,14 @@ import com.fr.config.MarketConfig;
import com.fr.design.DesignerEnvManager;
import com.fr.design.mainframe.burying.point.AbstractPointInfo;
import com.fr.general.CloudCenter;
import com.fr.general.GeneralUtils;
import com.fr.json.JSON;
import com.fr.json.JSONFactory;
import com.fr.json.JSONObject;
import com.fr.stable.ProductConstants;
import com.fr.stable.StringUtils;
import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLableReader;
import com.fr.third.joda.time.DateTime;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.HashMap;
import java.util.Map;
@ -22,6 +21,7 @@ import java.util.Map;
*/
public class TemplateInfo extends AbstractPointInfo {
static final String XML_TAG = "TemplateInfo";
private static final String SIMPLE_DATE_PATTRN = "yyyy-MM-dd HH:mm";
private static final String CONSUMING_URL = CloudCenter.getInstance().acquireUrlByKind("tempinfo.consuming") + "/single";
private static final String PROCESS_URL = CloudCenter.getInstance().acquireUrlByKind("tempinfo.process") + "/single";
@ -37,18 +37,18 @@ public class TemplateInfo extends AbstractPointInfo {
private static final String ATTR_CELL_COUNT = "cell_count";
private static final String ATTR_BLOCK_COUNT = "block_count";
private static final String ATTR_REPORT_TYPE = "report_type";
private static final String ATTR_ACTIVITYKEY = "activitykey";
private static final String ATTR_JAR_TIME = "jar_time";
private static final String ATTR_CREATE_TIME = "create_time";
private static final String ATTR_UUID = "uuid";
private static final String ATTR_TIME_CONSUME = "time_consume";
private static final String ATTR_ORIGIN_TIME = "originTime";
private static final String ATTR_VERSION = "version";
private static final String ATTR_USERNAME = "username";
private static final String ATTR_UID = "uid";
private static final String ATTR_SAVE_RECORD = "saveRecord";
private static final String ATTR_PARA_APPLY = "paraApply";
private static final String ATTR_COMPONENTS_INFO = "components_info";
private static final String ATTR_REUSE_CMP_LIST = "reuseCmptList";
private static final String TEST_TEMPLATE_FLAG = "test_template";
private static final int VALID_CELL_COUNT = 5; // 有效报表模板的格子数
private static final int VALID_WIDGET_COUNT = 5; // 有效报表模板的控件数
private static final int COMPLETE_DAY_COUNT = 15; // 判断模板是否完成的天数
private String templateID = StringUtils.EMPTY;
private String originID = StringUtils.EMPTY;
@ -76,28 +76,25 @@ public class TemplateInfo extends AbstractPointInfo {
}
public static TemplateInfo newInstance(String templateID) {
return newInstance(templateID, StringUtils.EMPTY, 0);
return newInstance(templateID, StringUtils.EMPTY, StringUtils.EMPTY, StringUtils.EMPTY);
}
public static TemplateInfo newInstance(String templateID, String originID, String saveRecord) {
String createTime = DateTime.now().toString(SIMPLE_DATE_PATTRN);
return newInstance(templateID, originID, saveRecord, createTime);
}
public static TemplateInfo newInstance(String templateID, String originID, int originTime) {
public static TemplateInfo newInstance(String templateID, String originID, String saveRecord, String createTime) {
HashMap<String, Object> consumingMap = new HashMap<>();
String username = MarketConfig.getInstance().getBbsUsername();
String uuid = DesignerEnvManager.getEnvManager().getUUID();
String activitykey = DesignerEnvManager.getEnvManager().getActivationKey();
String createTime = new SimpleDateFormat("yyyy-MM-dd HH:mm").format(Calendar.getInstance().getTime());
String jarTime = GeneralUtils.readBuildNO();
String version = ProductConstants.VERSION;
consumingMap.put(ATTR_USERNAME, username);
MarketConfig config = MarketConfig.getInstance();
consumingMap.put(ATTR_UUID, uuid);
consumingMap.put(ATTR_ACTIVITYKEY, activitykey);
consumingMap.put(ATTR_TEMPLATE_ID, templateID);
consumingMap.put(ATTR_ORIGIN_ID, originID);
consumingMap.put(ATTR_CREATE_TIME, createTime);
consumingMap.put(ATTR_TIME_CONSUME, originTime); // timeConsume 在原来模版的基础上累加
consumingMap.put(ATTR_ORIGIN_TIME, originTime);
consumingMap.put(ATTR_JAR_TIME, jarTime);
consumingMap.put(ATTR_VERSION, version);
consumingMap.put(ATTR_UID, config.getBBSAttr().getBbsUid());
consumingMap.put(ATTR_SAVE_RECORD, saveRecord);
TemplateInfo templateInfo = new TemplateInfo(templateID, originID);
templateInfo.consumingMap = consumingMap;
@ -109,14 +106,21 @@ public class TemplateInfo extends AbstractPointInfo {
return templateID;
}
String getOriginID() {
return originID;
public String getTemplateInfoID() {
return templateID + "_" + getSaveTime();
}
int getTimeConsume() {
return (int) consumingMap.get(ATTR_TIME_CONSUME);
public long getSaveTime() {
String saveRecord = (String) consumingMap.get(ATTR_SAVE_RECORD);
JSONObject jo = JSONFactory.createJSON(JSON.OBJECT, saveRecord);
return jo.getLong("time");
}
public String getTemplateCreateTime() {
return (String) consumingMap.get(ATTR_CREATE_TIME);
}
@Override
public void writeXML(XMLPrintWriter writer) {
writer.startTAG(XML_TAG);
@ -129,6 +133,7 @@ public class TemplateInfo extends AbstractPointInfo {
if (idleDayCount >= 0) {
writer.attr(ATTR_DAY_COUNT, this.idleDayCount);
}
writer.attr(TEST_TEMPLATE_FLAG, this.testTemplate);
writeProcessMap(writer);
writeConsumingMap(writer);
@ -143,19 +148,18 @@ public class TemplateInfo extends AbstractPointInfo {
writer.attr(ATTR_CELL_COUNT, (int) processMap.get(ATTR_CELL_COUNT));
writer.attr(ATTR_BLOCK_COUNT, (int) processMap.get(ATTR_BLOCK_COUNT));
writer.attr(ATTR_REPORT_TYPE, (int) processMap.get(ATTR_REPORT_TYPE));
writer.attr(ATTR_PARA_APPLY, (int) processMap.get(ATTR_PARA_APPLY));
writer.attr(ATTR_COMPONENTS_INFO, (String) processMap.get(ATTR_COMPONENTS_INFO));
writer.attr(ATTR_REUSE_CMP_LIST, (String) processMap.get(ATTR_REUSE_CMP_LIST));
writer.end();
}
private void writeConsumingMap(XMLPrintWriter writer) {
writer.startTAG(XML_CONSUMING_MAP);
writer.attr(ATTR_ACTIVITYKEY, (String) consumingMap.get(ATTR_ACTIVITYKEY));
writer.attr(ATTR_JAR_TIME, (String) consumingMap.get(ATTR_JAR_TIME));
writer.attr(ATTR_CREATE_TIME, (String) consumingMap.get(ATTR_CREATE_TIME));
writer.attr(ATTR_UUID, (String) consumingMap.get(ATTR_UUID));
writer.attr(ATTR_TIME_CONSUME, (int) consumingMap.get(ATTR_TIME_CONSUME));
writer.attr(ATTR_ORIGIN_TIME, (int) consumingMap.get(ATTR_ORIGIN_TIME));
writer.attr(ATTR_VERSION, (String) consumingMap.get(ATTR_VERSION));
writer.attr(ATTR_USERNAME, (String) consumingMap.get(ATTR_USERNAME));
writer.attr(ATTR_UID, (int) consumingMap.get(ATTR_UID));
writer.attr(ATTR_SAVE_RECORD, (String) consumingMap.get(ATTR_SAVE_RECORD));
writer.end();
}
@ -163,6 +167,7 @@ public class TemplateInfo extends AbstractPointInfo {
public void readXML(XMLableReader reader) {
if (!reader.isChildNode()) {
idleDayCount = reader.getAttrAsInt(ATTR_DAY_COUNT, 0);
testTemplate = reader.getAttrAsBoolean(TEST_TEMPLATE_FLAG, false);
templateID = reader.getAttrAsString(ATTR_TEMPLATE_ID, StringUtils.EMPTY);
originID = reader.getAttrAsString(ATTR_ORIGIN_ID, StringUtils.EMPTY);
} else {
@ -175,18 +180,17 @@ public class TemplateInfo extends AbstractPointInfo {
processMap.put(ATTR_CELL_COUNT, reader.getAttrAsInt(ATTR_CELL_COUNT, 0));
processMap.put(ATTR_BLOCK_COUNT, reader.getAttrAsInt(ATTR_BLOCK_COUNT, 0));
processMap.put(ATTR_REPORT_TYPE, reader.getAttrAsInt(ATTR_REPORT_TYPE, 0));
processMap.put(ATTR_PARA_APPLY, reader.getAttrAsInt(ATTR_PARA_APPLY, 0));
processMap.put(ATTR_COMPONENTS_INFO, reader.getAttrAsString(ATTR_COMPONENTS_INFO, StringUtils.EMPTY));
processMap.put(ATTR_REUSE_CMP_LIST, reader.getAttrAsString(ATTR_REUSE_CMP_LIST, StringUtils.EMPTY));
processMap.put(ATTR_TEMPLATE_ID, templateID);
} else if (XML_CONSUMING_MAP.equals(name)) {
consumingMap.put(ATTR_ACTIVITYKEY, reader.getAttrAsString(ATTR_ACTIVITYKEY, StringUtils.EMPTY));
consumingMap.put(ATTR_JAR_TIME, reader.getAttrAsString(ATTR_JAR_TIME, StringUtils.EMPTY));
consumingMap.put(ATTR_CREATE_TIME, reader.getAttrAsString(ATTR_CREATE_TIME, StringUtils.EMPTY));
consumingMap.put(ATTR_TEMPLATE_ID, templateID);
consumingMap.put(ATTR_ORIGIN_ID, originID);
consumingMap.put(ATTR_UUID, reader.getAttrAsString(ATTR_UUID, StringUtils.EMPTY));
consumingMap.put(ATTR_TIME_CONSUME, reader.getAttrAsInt(ATTR_TIME_CONSUME, 0));
consumingMap.put(ATTR_ORIGIN_TIME, reader.getAttrAsInt(ATTR_ORIGIN_TIME, 0));
consumingMap.put(ATTR_VERSION, reader.getAttrAsString(ATTR_VERSION, "8.0"));
consumingMap.put(ATTR_USERNAME, reader.getAttrAsString(ATTR_USERNAME, StringUtils.EMPTY));
consumingMap.put(ATTR_UID, reader.getAttrAsInt(ATTR_UID, 0));
consumingMap.put(ATTR_SAVE_RECORD, reader.getAttrAsString(ATTR_SAVE_RECORD, StringUtils.EMPTY));
}
} catch (Exception ex) {
// 什么也不做,使用默认值
@ -195,17 +199,8 @@ public class TemplateInfo extends AbstractPointInfo {
}
@Override
protected boolean isTestTemplate() {
if (!isComplete()) {
return false;
}
int reportType = (int) processMap.get(ATTR_REPORT_TYPE);
int cellCount = (int) processMap.get(ATTR_CELL_COUNT);
int floatCount = (int) processMap.get(ATTR_FLOAT_COUNT);
int blockCount = (int) processMap.get(ATTR_BLOCK_COUNT);
int widgetCount = (int) processMap.get(ATTR_WIDGET_COUNT);
return isTestTemplate(reportType, cellCount, floatCount, blockCount, widgetCount);
public boolean isTestTemplate() {
return testTemplate;
}
public static boolean isTestTemplate(int reportType, int cellCount, int floatCount, int blockCount, int widgetCount) {
@ -222,25 +217,17 @@ public class TemplateInfo extends AbstractPointInfo {
@Override
protected boolean isComplete() {
// 条件 1. 超过15天未编辑
// 条件 2. 设计器在这段未编辑的时间内启动超过 X 次(目前定的 X = 3)。即"设计器最近 X 次启动的时间跨度" < "未编辑时间";
return idleDayCount > COMPLETE_DAY_COUNT
&& DesignerOpenHistory.getInstance().isOpenEnoughTimesInPeriod(idleDayCount);
return true;
}
@Override
public Map<String, String> getSendInfo() {
Map<String, String> sendMap = new HashMap<>();
sendMap.put(CONSUMING_URL, new JSONObject(consumingMap).toString());
sendMap.put(PROCESS_URL, new JSONObject(processMap).toString());
sendMap.put(CONSUMING_URL, JSONFactory.createJSON(JSON.OBJECT, consumingMap).toString());
sendMap.put(PROCESS_URL, JSONFactory.createJSON(JSON.OBJECT, processMap).toString());
return sendMap;
}
void addTimeConsume(int timeConsume) {
timeConsume += (int) consumingMap.get(ATTR_TIME_CONSUME); // 加上之前的累计编辑时间
consumingMap.put(ATTR_TIME_CONSUME, timeConsume);
}
void updateProcessMap(TemplateProcessInfo processInfo) {
HashMap<String, Object> processMap = new HashMap<>();
@ -253,10 +240,13 @@ public class TemplateInfo extends AbstractPointInfo {
processMap.put(ATTR_FLOAT_COUNT, processInfo.getFloatCount());
processMap.put(ATTR_BLOCK_COUNT, processInfo.getBlockCount());
processMap.put(ATTR_WIDGET_COUNT, processInfo.getWidgetCount());
processMap.put(ATTR_PARA_APPLY, processInfo.useParaPane() ? 1 : 0);
processMap.put(ATTR_COMPONENTS_INFO, processInfo.getComponentsInfo().toString());
processMap.put(ATTR_REUSE_CMP_LIST, processInfo.getReuseCmpList().toString());
this.processMap = processMap;
}
int getIdleDayCount() {
return this.idleDayCount;
}

127
designer-base/src/main/java/com/fr/design/mainframe/template/info/TemplateInfoCollector.java

@ -1,13 +1,18 @@
package com.fr.design.mainframe.template.info;
import com.fr.design.mainframe.burying.point.AbstractPointCollector;
import com.fr.stable.ProductConstants;
import com.fr.stable.StableUtils;
import com.fr.design.mainframe.burying.point.AbstractPointInfo;
import com.fr.json.JSON;
import com.fr.json.JSONFactory;
import com.fr.json.JSONObject;
import com.fr.stable.StringUtils;
import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLableReader;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/**
* 做模板的过程和耗时收集辅助类
@ -18,9 +23,12 @@ public class TemplateInfoCollector extends AbstractPointCollector<TemplateInfo>
private static final String XML_TEMPLATE_INFO_LIST = "TemplateInfoList";
private static final String XML_FILE_NAME = "tpl.info";
private static TemplateInfoCollector instance;
private DesignerOpenHistory designerOpenHistory;
private DesignerOpenHistory designerOpenHistory = DesignerOpenHistory.getInstance();
//记录指定模板最新的模板耗时信息ID
private Map<String, Long> latestTemplateInfo;
private TemplateInfoCollector() {
super();
}
public static TemplateInfoCollector getInstance() {
@ -34,7 +42,7 @@ public class TemplateInfoCollector extends AbstractPointCollector<TemplateInfo>
* 根据模板ID是否在收集列表中判断是否需要收集当前模板的信息
*/
public boolean contains(String templateID) {
return StringUtils.isNotEmpty(templateID) && pointInfoMap.containsKey(templateID);
return StringUtils.isNotEmpty(templateID) && latestTemplateInfo.containsKey(templateID);
}
/**
@ -51,42 +59,41 @@ public class TemplateInfoCollector extends AbstractPointCollector<TemplateInfo>
if (!shouldCollectInfo()) {
return;
}
long saveTime = System.currentTimeMillis();
TemplateInfo templateInfo;
if (this.contains(templateID)) {
templateInfo = pointInfoMap.get(templateID);
} else {
int originTime = this.contains(originID) ? pointInfoMap.get(originID).getTimeConsume() : 0;
templateInfo = TemplateInfo.newInstance(templateID, originID, originTime);
pointInfoMap.put(templateID, templateInfo);
}
TemplateInfo templateInfo = createTemplateInfo(templateID, originID, saveTime, timeConsume);
pointInfoMap.put(templateInfo.getTemplateInfoID(), templateInfo);
//更新下此模板最新保存记录
updateLatestTemplateInfo(templateID, saveTime);
// 收集制作耗时
templateInfo.addTimeConsume(timeConsume);
// 收集模版基本信息
templateInfo.updateProcessMap(processInfo);
//设置是否是测试模板
templateInfo.setTestTemplate(processInfo.isTestTemplate());
// 刷新闲置日计数器
templateInfo.resetIdleDayCount();
// 每次更新之后,都同步到暂存文件中
saveInfo();
}
/**
* 获取缓存文件存放路径
*/
@Override
protected File getInfoFile() {
return new File(StableUtils.pathJoin(ProductConstants.getEnvHome(), XML_FILE_NAME));
private TemplateInfo createTemplateInfo(String templateID, String originID, long saveTime, int timeConsume){
JSONObject saveRecord = JSONFactory.createJSON(JSON.OBJECT);
saveRecord.put("time", saveTime);
saveRecord.put("consume", timeConsume);
if (this.contains(templateID)){
return TemplateInfo.newInstance(templateID, originID, saveRecord.toString(), getTemplateCreateTime(templateID));
}
TemplateInfo getOrCreateTemplateInfoByID(String templateID) {
if (pointInfoMap.containsKey(templateID)) {
return pointInfoMap.get(templateID);
return TemplateInfo.newInstance(templateID, originID, saveRecord.toString());
}
TemplateInfo templateInfo = TemplateInfo.newInstance(templateID);
pointInfoMap.put(templateID, templateInfo);
return templateInfo;
private String getTemplateCreateTime(String templateID) {
long latestSaveTime = latestTemplateInfo.get(templateID);
TemplateInfo latestTemplateInfo = pointInfoMap.get(templateID + "_" + latestSaveTime);
return latestTemplateInfo.getTemplateCreateTime();
}
/**
@ -104,6 +111,20 @@ public class TemplateInfoCollector extends AbstractPointCollector<TemplateInfo>
designerOpenHistory.update();
}
private void updateLatestTemplateInfo(TemplateInfo templateInfo) {
String templateID = templateInfo.getTemplateID();
if (latestTemplateInfo.containsKey(templateID)) {
long latestSaveTime = latestTemplateInfo.get(templateID);
updateLatestTemplateInfo(templateID, Math.max(latestSaveTime, templateInfo.getSaveTime()));
} else {
updateLatestTemplateInfo(templateID, templateInfo.getSaveTime());
}
}
private void updateLatestTemplateInfo(String templateID, long saveTime) {
latestTemplateInfo.put(templateID, saveTime);
}
@Override
public void readXML(XMLableReader reader) {
if (reader.isChildNode()) {
@ -116,7 +137,8 @@ public class TemplateInfoCollector extends AbstractPointCollector<TemplateInfo>
reader.readXMLObject(designerOpenHistory);
} else if (TemplateInfo.XML_TAG.equals(name)) {
TemplateInfo templateInfo = TemplateInfo.newInstanceByRead(reader);
pointInfoMap.put(templateInfo.getTemplateID(), templateInfo);
updateLatestTemplateInfo(templateInfo);
pointInfoMap.put(templateInfo.getTemplateInfoID(), templateInfo);
}
} catch (Exception ex) {
// 什么也不做,使用默认值
@ -138,4 +160,51 @@ public class TemplateInfoCollector extends AbstractPointCollector<TemplateInfo>
writer.end();
}
/**
* 获取缓存文件存放路径
*/
@Override
protected String getInfoFilePath() {
return XML_FILE_NAME;
}
@Override
public void sendPointInfo() {
addIdleDayCount();
List<String> removeList = new ArrayList<>();
List<String> sendList = new ArrayList<>();
for (String latestTemplateInfokey : latestTemplateInfo.keySet()) {
AbstractPointInfo pointInfo = pointInfoMap.get(latestTemplateInfokey + "_" + latestTemplateInfo.get(latestTemplateInfokey));
if (pointInfo.isTestTemplate()) {
continue;
}
for (String key : pointInfoMap.keySet()) {
if (key.startsWith(latestTemplateInfokey)) {
sendList.add(key);
}
}
}
// 发送记录
for (String key : sendList) {
if (SendHelper.sendPointInfo(pointInfoMap.get(key))) {
removeList.add(key);
}
}
// 清空记录
for (String key : removeList) {
pointInfoMap.remove(key);
}
saveInfo();
}
@Override
protected void loadFromFile() {
latestTemplateInfo = new ConcurrentHashMap<>();
super.loadFromFile();
}
}

20
designer-base/src/main/java/com/fr/design/mainframe/template/info/TemplateOperate.java

@ -0,0 +1,20 @@
package com.fr.design.mainframe.template.info;
import com.fr.json.JSONObject;
/**
* Created by kerry on 2020-05-08
*/
public interface TemplateOperate {
/**
* 获取模板操作类型
* @return 操作类型
*/
String getOperateType();
/**
* 将模板操作信息转换成json格式
* @return jsonObject
*/
JSONObject toJSONObject();
}

49
designer-base/src/main/java/com/fr/design/mainframe/template/info/TemplateProcessInfo.java

@ -1,6 +1,10 @@
package com.fr.design.mainframe.template.info;
import com.fr.base.Style;
import com.fr.base.io.BaseBook;
import com.fr.chart.chartattr.ChartCollection;
import com.fr.chartx.attr.ChartProvider;
import com.fr.json.JSONArray;
/**
* Created by plough on 2017/3/17.
@ -19,12 +23,57 @@ public abstract class TemplateProcessInfo<T extends BaseBook> {
// 获取模板类型。0 代表普通报表,1 代表聚合报表,2 代表表单
public abstract int getReportType();
// 获取模板格子数
public abstract int getCellCount();
// 获取模板悬浮元素个数
public abstract int getFloatCount();
// 获取模板聚合块个数
public abstract int getBlockCount();
// 获取模板控件数
public abstract int getWidgetCount();
//是否是测试模板
public abstract boolean isTestTemplate();
//是否使用参数面板
public abstract boolean useParaPane();
//获取组件信息
public abstract JSONArray getComponentsInfo();
//获取重用组件数
public abstract JSONArray getReuseCmpList();
public abstract void updateTemplateOperationInfo(TemplateOperate templateOption);
protected boolean isTestCell(Object value, Style style) {
if (value instanceof ChartCollection && isTestChartCollection((ChartCollection) value)) {
return true;
}
if (value == null && Style.getInstance().equals(style)) {
return true;
}
return false;
}
protected boolean isTestChartCollection(ChartCollection chartCollection) {
int chartCount = chartCollection.getChartCount();
if (chartCount == 0) {
return true;
}
for (int i = 0; i < chartCount; i++) {
ChartProvider chart = chartCollection.getChart(i, ChartProvider.class);
if (chart.isTestChart()) {
return true;
}
}
return false;
}
}

2
designer-base/src/main/java/com/fr/design/mainframe/widget/BasicPropertyPane.java

@ -63,7 +63,7 @@ public class BasicPropertyPane extends BasicPane {
double[] columnSize = {p, f};
int[][] rowCount = {{1, 1}};
Component[][] components = new Component[][]{
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Widget_Name")), widgetName},
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Component_Name")), widgetName},
};
JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, IntervalConstants.INTERVAL_W1, IntervalConstants.INTERVAL_L1);
panel.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0));

10
designer-base/src/main/java/com/fr/design/os/impl/DatabaseDialogAction.java

@ -24,11 +24,13 @@ public class DatabaseDialogAction implements OSBasedAction {
@Override
public void execute(Object... objects) {
if (ServerPreferenceConfig.getInstance().isUseUniverseDBM() && !OperatingSystem.isLinux()) {
UniversalDatabaseOpener.showUniverseDatabaseDialog();
} else {
// if (ServerPreferenceConfig.getInstance().isUseUniverseDBM() && !OperatingSystem.isLinux()) {
// UniversalDatabaseOpener.showUniverseDatabaseDialog();
// } else {
// }
// 直接这里屏蔽掉 防止有设置过 导致配置数据库值为true 即使设置界面屏蔽也没用
openDesignDatabaseManager();
}
}
private void openDesignDatabaseManager() {

12
designer-base/src/main/java/com/fr/design/os/impl/SupportOSImpl.java

@ -105,6 +105,18 @@ public enum SupportOSImpl implements SupportOS {
public boolean support() {
return OperatingSystem.isWindows();
}
},
/**
* 原生文件选择器弹窗
* https://bugs.java.com/bugdatabase/view_bug.do?bug_id=8019464 mac下原生弹窗国际化设置无效,jdk11中有修复
*
*/
NATIVE_CHOOSER {
@Override
public boolean support() {
return OperatingSystem.isWindows();
}
}
}

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

@ -291,10 +291,8 @@ public class DesignUtils {
if (isDisplaySimSun(defaultLocale)) {
guiFRFont = getNamedFont("SimSun");
} else if (isDisplayDialog(defaultLocale)) {
guiFRFont = getNamedFont("Dialog");
} else {
guiFRFont = getNamedFont("Tahoma");
guiFRFont = getNamedFont("Dialog");
}
//先初始化的设计器locale, 后初始化lookandfeel.如果顺序改了, 这边也要调整.

5
designer-base/src/main/java/com/fr/design/utils/DesignerPort.java

@ -90,10 +90,7 @@ public class DesignerPort implements XMLReadable, XMLWriter {
}
public void resetPort() {
ProcessEventPipe eventPipe = FineProcessContext.getParentPipe();
if (eventPipe != null) {
eventPipe.fire(new CarryMessageEvent(ReportState.STOP.getValue()));
}
FineProcessContext.getParentPipe().fire(new CarryMessageEvent(ReportState.STOP.getValue()));
TipDialog dialog = new TipDialog(null,
StringUtils.EMPTY,
Toolkit.i18nText("Fine-Design_Port_Found_Port_Conflict"),

8
designer-base/src/main/java/com/fr/design/widget/WidgetBoundsPaneFactory.java

@ -25,7 +25,7 @@ public class WidgetBoundsPaneFactory {
double f = TableLayout.FILL;
double p = TableLayout.PREFERRED;
Component[][] components = new Component[][]{
new Component[]{FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Widget_Size")), createRightPane(width, height)},
new Component[]{FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Component_Size")), createRightPane(width, height)},
new Component[]{null, createRightPane(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tree_Width"), SwingConstants.CENTER), new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tree_Height"), SwingConstants.CENTER))},
};
double[] rowSize = {p, p};
@ -53,11 +53,11 @@ public class WidgetBoundsPaneFactory {
double p = TableLayout.PREFERRED;
Component[][] northComponents = new Component[][]{
new Component[]{FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Widget_Position")), createRightPane(x, y)},
new Component[]{FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Component_Position")), createRightPane(x, y)},
new Component[]{null, createRightPane(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_X_Coordinate"), SwingConstants.CENTER), new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Y_Coordinate"), SwingConstants.CENTER))},
};
Component[][] centerComponents = new Component[][]{
new Component[]{FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Widget_Size")), createRightPane(width, height)},
new Component[]{FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Component_Size")), createRightPane(width, height)},
new Component[]{null, createRightPane(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tree_Width"), SwingConstants.CENTER), new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tree_Height"), SwingConstants.CENTER))},
};
double[] rowSize = {p, p};
@ -79,7 +79,7 @@ public class WidgetBoundsPaneFactory {
double f = TableLayout.FILL;
double p = TableLayout.PREFERRED;
Component[][] components = new Component[][]{
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Widget_Size")), width},
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Component_Size")), width},
};
double[] rowSize = {p};
double[] columnSize = {p, f};

11
designer-base/src/main/java/com/fr/file/FILEChooserPane.java

@ -505,12 +505,21 @@ public class FILEChooserPane extends BasicPane {
if (StringUtils.isEmpty(fileName) || StringUtils.isEmpty(filterExtension) || fileFilter.containsExtension(fileExtension.getExtension())) {
return fileName;
}
if (!ComparatorUtils.equals(fileNameExtension, filterExtension)) {
if (!ComparatorUtils.equals(fileNameExtension, filterExtension) && !isMapping(fileNameExtension, filterExtension)) {
return fileName + filterExtension;
}
return fileNameWithOutExtension + filterExtension;
}
private boolean isMapping(String fromExtension, String toExtension){
if(FileExtension.CPTX.matchExtension(fromExtension)){
return FileExtension.CPT.matchExtension(toExtension);
}else if(FileExtension.CPT.matchExtension(fromExtension)){
return FileExtension.CPTX.matchExtension(toExtension);
}
return false;
}
private void doCancel() {
this.locationBtnPane.setPopDir(null);
dialogExit();

13
designer-base/src/main/java/com/fr/start/server/FineEmbedServerActivator.java

@ -62,6 +62,7 @@ public class FineEmbedServerActivator extends Activator {
tomcat.setPort(DesignerEnvManager.getEnvManager().getEmbedServerPort());
// 设置解码uri使用的字符编码
tomcat.getConnector().setURIEncoding(EncodeConstants.ENCODING_UTF_8);
setMaxPostSize();
String docBase = new File(WorkContext.getCurrent().getPath()).getParent();
//内置的上下文使用工程目录比如webroot
@ -80,6 +81,18 @@ public class FineEmbedServerActivator extends Activator {
context.addServletContainerInitializer(initializer, classes);
}
// tomcat的maxPostSize会影响到post参数获取,默认2M
private void setMaxPostSize() {
if (System.getProperty("tomcat-maxPostSize") != null) {
try {
tomcat.getConnector().setMaxPostSize(Integer.parseInt(System.getProperty("tomcat-maxPostSize")));
} catch (Exception e) {
FineLoggerFactory.getLogger().error("maxPostSize error: " + e.getMessage(), e);
}
}
}
private void stopServerActivator() {

62
designer-base/src/test/java/com/fr/design/base/clipboard/ClipboardFilterTest.java

@ -0,0 +1,62 @@
package com.fr.design.base.clipboard;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.fun.ClipboardHandlerProvider;
import com.fr.plugin.injectable.PluginModule;
import com.fr.stable.fun.mark.Mutable;
import org.easymock.EasyMock;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.api.easymock.PowerMock;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import java.util.HashSet;
import java.util.Set;
@PrepareForTest(PluginModule.class)
@RunWith(PowerMockRunner.class)
public class ClipboardFilterTest {
@Before
public void setUp() throws Exception {
Set<Mutable> providers = new HashSet<>();
providers.add(new TestClipboardHandlerProvider<Object>());
ExtraDesignClassManager designClassManager = EasyMock.mock(ExtraDesignClassManager.class);
EasyMock.expect(designClassManager.getArray(ClipboardHandlerProvider.XML_TAG))
.andReturn(providers)
.anyTimes();
EasyMock.replay(designClassManager);
PowerMock.mockStatic(PluginModule.class);
EasyMock.expect(PluginModule.getAgent(PluginModule.ExtraDesign))
.andReturn(designClassManager)
.anyTimes();
PowerMock.replayAll();
}
@After
public void tearDown() throws Exception {
PowerMock.resetAll();
}
@Test
public void testClipboard() {
ClipboardFilter.cut("cut");
String paste1 = ClipboardFilter.paste("paste");
Assert.assertNull(paste1);
ClipboardFilter.copy("copy");
String paste2 = ClipboardFilter.paste("paste");
Assert.assertNull(paste2);
}
}

75
designer-base/src/test/java/com/fr/design/base/clipboard/DesignerClipboardTest.java

@ -0,0 +1,75 @@
package com.fr.design.base.clipboard;
import com.fr.design.fun.ClipboardHandlerProvider;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.dnd.ArrayListTransferable;
import com.fr.form.main.ExtraFormClassManager;
import com.fr.plugin.injectable.PluginModule;
import com.fr.stable.fun.mark.Mutable;
import com.fr.third.guava.collect.Lists;
import org.easymock.EasyMock;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.api.easymock.PowerMock;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import javax.swing.JPanel;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Set;
@PrepareForTest(PluginModule.class)
@RunWith(PowerMockRunner.class)
@PowerMockIgnore("javax.swing.*")
public class DesignerClipboardTest {
@Before
public void setUp() throws Exception {
Set<Mutable> providers = new HashSet<>();
ExtraFormClassManager formClassManager = EasyMock.mock(ExtraFormClassManager.class);
EasyMock.expect(formClassManager.getArray(ClipboardHandlerProvider.XML_TAG))
.andReturn(providers)
.anyTimes();
EasyMock.replay(formClassManager);
PowerMock.mockStatic(PluginModule.class);
EasyMock.expect(PluginModule.getAgent(PluginModule.ExtraForm))
.andReturn(formClassManager)
.anyTimes();
PowerMock.replayAll();
}
@After
public void tearDown() throws Exception {
PowerMock.resetAll();
}
@Test
public void testClipboard() throws Exception {
JPanel panel = new JPanel();
Clipboard clipboard = DesignerContext.getClipboard(panel);
ArrayList<String> transferData = Lists.newArrayList("test", "test2");
ArrayListTransferable transferable = new ArrayListTransferable(transferData);
clipboard.setContents(transferable, null);
Transferable filterTransferable = clipboard.getContents(null);
DataFlavor[] flavors = transferable.getTransferDataFlavors();
ArrayList<String> transferData2 = (ArrayList<String>) filterTransferable.getTransferData(flavors[0]);
Assert.assertEquals(transferData.get(0), transferData2.get(0));
}
}

29
designer-base/src/test/java/com/fr/design/base/clipboard/TestClipboardHandlerProvider.java

@ -0,0 +1,29 @@
package com.fr.design.base.clipboard;
import com.fr.design.fun.impl.AbstractClipboardHandlerProvider;
/**
* created by Harrison on 2020/05/15
**/
class TestClipboardHandlerProvider<T> extends AbstractClipboardHandlerProvider<T> {
@Override
public T cut(T selection) {
return selection;
}
@Override
public T copy(T selection) {
return selection;
}
@Override
public T paste(T selection) {
return null;
}
@Override
public boolean support(Object selection) {
return true;
}
}

44
designer-base/src/test/java/com/fr/design/data/BasicTableDataUtilsTest.java

@ -0,0 +1,44 @@
package com.fr.design.data;
import junit.framework.TestCase;
import org.junit.Assert;
import org.junit.Test;
/**
* @author hades
* @version 10.0
* Created by hades on 2020/4/27
*/
public class BasicTableDataUtilsTest extends TestCase {
@Test
public void testIsInValidName() {
boolean result1 = BasicTableDataUtils.isInValidName("a.b");
boolean result2 = BasicTableDataUtils.isInValidName("a.b.c");
boolean result3 = BasicTableDataUtils.isInValidName("a..b");
boolean result4 = BasicTableDataUtils.isInValidName("a.");
boolean result5 = BasicTableDataUtils.isInValidName("a.b.");
boolean result6 = BasicTableDataUtils.isInValidName("abc");
boolean result7 = BasicTableDataUtils.isInValidName(".abc");
boolean result8 = BasicTableDataUtils.isInValidName(".ab.c");
boolean result9 = BasicTableDataUtils.isInValidName("ab.c.");
boolean result10 = BasicTableDataUtils.isInValidName(".abc.");
boolean result11 = BasicTableDataUtils.isInValidName(".ab.c.");
boolean result12 = BasicTableDataUtils.isInValidName("..");
Assert.assertTrue(result1);
Assert.assertFalse(result2);
Assert.assertFalse(result3);
Assert.assertFalse(result4);
Assert.assertTrue(result5);
Assert.assertFalse(result6);
Assert.assertTrue(result7);
Assert.assertFalse(result8);
Assert.assertTrue(result9);
Assert.assertTrue(result10);
Assert.assertFalse(result11);
Assert.assertFalse(result12);
}
}

25
designer-base/src/test/java/com/fr/design/formula/FormulaPaneTest.java

@ -0,0 +1,25 @@
package com.fr.design.formula;
import junit.framework.TestCase;
import org.junit.Assert;
import org.junit.Test;
import java.util.Arrays;
/**
* @author hades
* @version 10.0
* Created by hades on 2020/5/20
*/
public class FormulaPaneTest extends TestCase {
@Test
public void testSimilarComparator() {
String[] strs = new String[] {"ScriptEval", "SPLIT", "SUMPRECISE"};
String[] result = new String[] {"SPLIT", "ScriptEval", "SUMPRECISE"};
Arrays.sort(strs, new FormulaPane.SimilarComparator("sp"));
Assert.assertArrayEquals(result, strs);
}
}

136
designer-base/src/test/java/com/fr/design/mainframe/template/info/TemplateInfoCollectorTest.java

@ -1,19 +1,23 @@
package com.fr.design.mainframe.template.info;
import com.fr.config.MarketConfig;
import com.fr.general.GeneralUtils;
import com.fr.design.DesignerEnvManager;
import com.fr.invoke.Reflect;
import com.fr.json.JSONObject;
import com.fr.json.JSON;
import com.fr.json.JSONArray;
import com.fr.json.JSONFactory;
import com.fr.stable.ProductConstants;
import com.fr.stable.StringUtils;
import com.fr.third.org.apache.commons.io.FileUtils;
import org.easymock.EasyMock;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.api.easymock.PowerMock;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.core.classloader.annotations.SuppressStaticInitializationFor;
import org.powermock.modules.junit4.PowerMockRunner;
import java.io.File;
@ -29,7 +33,8 @@ import static org.junit.Assert.assertTrue;
* Created by plough on 2019/4/18.
*/
@RunWith(PowerMockRunner.class)
@PrepareForTest({ProductConstants.class, MarketConfig.class, ProductConstants.class, GeneralUtils.class})
@PrepareForTest({ProductConstants.class, MarketConfig.class, DesignerEnvManager.class})
@SuppressStaticInitializationFor({"com.fr.jvm.assist.FineAssist"})
public class TemplateInfoCollectorTest {
private String filePath;
private String initialFileContent;
@ -51,6 +56,10 @@ public class TemplateInfoCollectorTest {
EasyMock.expect(mockProcessInfo.getFloatCount()).andReturn(1).anyTimes();
EasyMock.expect(mockProcessInfo.getReportType()).andReturn(0).anyTimes();
EasyMock.expect(mockProcessInfo.getWidgetCount()).andReturn(0).anyTimes();
EasyMock.expect(mockProcessInfo.useParaPane()).andReturn(false).anyTimes();
EasyMock.expect(mockProcessInfo.getComponentsInfo()).andReturn(new JSONArray()).anyTimes();
EasyMock.expect(mockProcessInfo.isTestTemplate()).andReturn(true).anyTimes();
EasyMock.expect(mockProcessInfo.getReuseCmpList()).andReturn(JSONArray.create().add("reuse-id-1")).anyTimes();
EasyMock.replay(mockProcessInfo);
// 缓存 tpl.info
@ -72,36 +81,37 @@ public class TemplateInfoCollectorTest {
assertEquals(",,", DesignerOpenHistory.getInstance().toString());
TemplateInfoCollector collector = TemplateInfoCollector.getInstance();
assertEquals(7, ((Map) Reflect.on(collector).field("pointInfoMap").get()).size());
assertEquals("2019-04-08,2019-04-03,2019-03-29", DesignerOpenHistory.getInstance().toString());
assertEquals("2020-05-07,2020-05-06,2020-04-30", DesignerOpenHistory.getInstance().toString());
}
@Test
public void testCollectInfo() {
public void testCollectInfo() throws Exception {
setUpMockForNewInstance();
TemplateInfoCollector collector = TemplateInfoCollector.getInstance();
String templateID = "16a988ce-8529-42f5-b17c-2ee849355071";
String templateID = "e5d7dbb2-d1df-43d4-b974-67acb5ecbffa";
int timeConsume = 200;
collector.collectInfo(templateID, StringUtils.EMPTY, mockProcessInfo, timeConsume);
// 检查是否写入成功
Reflect.on(collector).call("loadFromFile");
TemplateInfo templateInfo = collector.getOrCreateTemplateInfoByID(templateID);
TemplateInfo templateInfo = getTemplateInfoByID(templateID);
Map consumingMap = Reflect.on(templateInfo).field("consumingMap").get();
Map processMap = Reflect.on(templateInfo).field("processMap").get();
assertJsonStringEquals("{\"process\":\"\",\"float_count\":1,\"widget_count\":0," +
"\"cell_count\":13,\"block_count\":3,\"report_type\":0," +
"\"templateID\":\"16a988ce-8529-42f5-b17c-2ee849355071\"}", new JSONObject(processMap).toString());
assertJsonStringEquals("{\"activitykey\":\"2e0ea413-fa9c241e0-9723-4354fce51e81\"," +
"\"jar_time\":\"不是安装版本\",\"create_time\":\"2019-03-26 16:13\"," +
"\"templateID\":\"16a988ce-8529-42f5-b17c-2ee849355071\",\"originID\":\"\"," +
"\"uuid\":\"476ca2cc-f789-4c5d-8e89-ef146580775c\",\"time_consume\":329,\"originTime\":0," +
"\"version\":\"10.0\",\"username\":\"plough\"}", new JSONObject(consumingMap).toString());
"\"cell_count\":13,\"paraApply\":0,\"block_count\":3,\"report_type\":0,\"components_info\":\"[]\"," +
"\"templateID\":\"e5d7dbb2-d1df-43d4-b974-67acb5ecbffa\",\"reuseCmptList\":\"[\\\"reuse-id-1\\\"]\"" +
"}",
JSONFactory.createJSON(JSON.OBJECT, processMap).toString());
Assert.assertEquals(71113, consumingMap.get("uid"));
Assert.assertEquals("2020-05-07 17:25", consumingMap.get("create_time"));
Assert.assertEquals("e5d7dbb2-d1df-43d4-b974-67acb5ecbffa", consumingMap.get("templateID"));
Assert.assertEquals("6b6699ff-ec63-43b0-9deb-b580a5f10411", consumingMap.get("uuid"));
}
@Test
@ -110,7 +120,7 @@ public class TemplateInfoCollectorTest {
TemplateInfoCollector collector = TemplateInfoCollector.getInstance();
String templateID = "73a97777-8jnk-47cd-b57c-2ee89991279796";
String templateID = "e5d7dbb2-d1df-43d4-b974-67acb5ecbffa";
int timeConsume = 200;
collector.collectInfo(templateID, StringUtils.EMPTY, mockProcessInfo, timeConsume);
@ -119,20 +129,21 @@ public class TemplateInfoCollectorTest {
Reflect.on(collector).call("loadFromFile");
assertTrue(collector.contains(templateID));
TemplateInfo templateInfo = collector.getOrCreateTemplateInfoByID(templateID);
TemplateInfo templateInfo = getTemplateInfoByID(templateID);
Map processMap = Reflect.on(templateInfo).field("processMap").get();
assertEquals(templateID, templateInfo.getTemplateID());
assertJsonStringEquals("{\"process\":\"\",\"float_count\":1,\"widget_count\":0," +
"\"cell_count\":13,\"block_count\":3,\"report_type\":0," +
"\"templateID\":\"73a97777-8jnk-47cd-b57c-2ee89991279796\"}", new JSONObject(processMap).toString());
"\"cell_count\":13,\"paraApply\":0,\"block_count\":3,\"report_type\":0,\"components_info\":\"[]\"," +
"\"templateID\":\"e5d7dbb2-d1df-43d4-b974-67acb5ecbffa\",\"reuseCmptList\":\"[\\\"reuse-id-1\\\"]\"" +
"}", JSONFactory.createJSON(JSON.OBJECT, processMap).toString());
Map<String, Object> consumingMap = Reflect.on(templateInfo).field("consumingMap").get();
assertEquals(templateID, consumingMap.get("templateID"));
assertEquals(StringUtils.EMPTY, consumingMap.get("originID"));
assertEquals(200, consumingMap.get("time_consume"));
assertEquals(0, consumingMap.get("originTime"));
Assert.assertEquals(71113, consumingMap.get("uid"));
Assert.assertEquals("2020-05-07 17:25", consumingMap.get("create_time"));
Assert.assertEquals("e5d7dbb2-d1df-43d4-b974-67acb5ecbffa", consumingMap.get("templateID"));
Assert.assertEquals("6b6699ff-ec63-43b0-9deb-b580a5f10411", consumingMap.get("uuid"));
}
@Test
@ -141,7 +152,7 @@ public class TemplateInfoCollectorTest {
TemplateInfoCollector collector = TemplateInfoCollector.getInstance();
String templateID = "423238d4-5223-22vj-vlsj-42jc49245iw3";
String templateID = "e5d7dbb2-d1df-43d4-b974-67acb5ecbffa";
String originID = "16a988ce-8529-42f5-b17c-2ee849355071";
int timeConsume = 200;
@ -149,18 +160,20 @@ public class TemplateInfoCollectorTest {
// 检查是否写入成功
Reflect.on(collector).call("loadFromFile");
TemplateInfo templateInfo = collector.getOrCreateTemplateInfoByID(templateID);
TemplateInfo templateInfo = getTemplateInfoByID(templateID);
Map processMap = Reflect.on(templateInfo).field("processMap").get();
assertJsonStringEquals("{\"process\":\"\",\"float_count\":1,\"widget_count\":0," +
"\"cell_count\":13,\"block_count\":3,\"report_type\":0," +
"\"templateID\":\"423238d4-5223-22vj-vlsj-42jc49245iw3\"}", new JSONObject(processMap).toString());
"\"cell_count\":13,\"paraApply\":0,\"block_count\":3,\"report_type\":0,\"components_info\":\"[]\"," +
"\"templateID\":\"e5d7dbb2-d1df-43d4-b974-67acb5ecbffa\",\"reuseCmptList\":\"[\\\"reuse-id-1\\\"]\"" +
"}", JSONFactory.createJSON(JSON.OBJECT, processMap).toString());
Map<String, Object> consumingMap = Reflect.on(templateInfo).field("consumingMap").get();
assertEquals(templateID, consumingMap.get("templateID"));
assertEquals(originID, consumingMap.get("originID"));
assertEquals(329, consumingMap.get("time_consume"));
assertEquals(129, consumingMap.get("originTime"));
Assert.assertEquals(71113, consumingMap.get("uid"));
Assert.assertEquals("2020-05-07 17:25", consumingMap.get("create_time"));
Assert.assertEquals("e5d7dbb2-d1df-43d4-b974-67acb5ecbffa", consumingMap.get("templateID"));
Assert.assertEquals("6b6699ff-ec63-43b0-9deb-b580a5f10411", consumingMap.get("uuid"));
Assert.assertEquals("16a988ce-8529-42f5-b17c-2ee849355071", consumingMap.get("originID"));
}
@Test
@ -169,36 +182,71 @@ public class TemplateInfoCollectorTest {
TemplateInfoCollector collector = TemplateInfoCollector.getInstance();
String templateID = "423238d4-5223-22vj-vlsj-42jc49245iw3";
String templateID = "e5d7dbb2-d1df-43d4-b974-67acb5ecbffa";
String originID = "3kha8jcs-31xw-42f5-h2ww-2ee84935312z";
int timeConsume = 200;
collector.collectInfo(templateID, originID, mockProcessInfo, timeConsume);
TemplateInfo templateInfo = collector.getOrCreateTemplateInfoByID(templateID);
TemplateInfo templateInfo = getTemplateInfoByID(templateID);
assertEquals(templateID, templateInfo.getTemplateID());
assertEquals(originID, templateInfo.getOriginID());
Map<String, Object> consumingMap = Reflect.on(templateInfo).field("consumingMap").get();
assertEquals(templateID, consumingMap.get("templateID"));
assertEquals(originID, consumingMap.get("originID"));
assertEquals(200, consumingMap.get("time_consume"));
assertEquals(0, consumingMap.get("originTime"));
Assert.assertEquals(71113, consumingMap.get("uid"));
Assert.assertEquals("2020-05-07 17:25", consumingMap.get("create_time"));
Assert.assertEquals("e5d7dbb2-d1df-43d4-b974-67acb5ecbffa", consumingMap.get("templateID"));
Assert.assertEquals("6b6699ff-ec63-43b0-9deb-b580a5f10411", consumingMap.get("uuid"));
Assert.assertEquals("3kha8jcs-31xw-42f5-h2ww-2ee84935312z", consumingMap.get("originID"));
}
@Test
public void testAddIdleDateCount() {
String templateID = "16a988ce-8529-42f5-b17c-2ee849355071";
String templateID = "e5d7dbb2-d1df-43d4-b974-67acb5ecbffa";
TemplateInfoCollector collecter = TemplateInfoCollector.getInstance();
TemplateInfo templateInfo = collecter.getOrCreateTemplateInfoByID(templateID);
TemplateInfo templateInfo = getTemplateInfoByID(templateID);
assertEquals(9, templateInfo.getIdleDayCount());
assertEquals(0, templateInfo.getIdleDayCount());
Reflect.on(collecter).call("addIdleDayCount");
assertEquals(10, templateInfo.getIdleDayCount());
assertEquals(1, templateInfo.getIdleDayCount());
// 同一天内多次调用无效
Reflect.on(collecter).call("addIdleDayCount");
assertEquals(10, templateInfo.getIdleDayCount());
assertEquals(1, templateInfo.getIdleDayCount());
}
@Test
public void testContains() {
TemplateInfoCollector collector = TemplateInfoCollector.getInstance();
String templateID1 = "e5d7dbb2-d1df-43d4-b974-67acb5ecbffa";
Assert.assertTrue(collector.contains(templateID1));
String templateID2 = "e5d7dbb2-d1df-43d4-b974-67acb5ecbffb";
Assert.assertFalse(collector.contains(templateID2));
}
@Test
public void testGetTemplateCreateTime() throws Exception {
setUpMockForNewInstance();
TemplateInfoCollector collector = TemplateInfoCollector.getInstance();
String templateID = "e5d7dbb2-d1df-43d4-b974-67acb5ecbffa";
String createTime = Reflect.on(collector).call("getTemplateCreateTime", templateID).get();
Assert.assertEquals("2020-05-07 17:25", createTime);
templateID = "2521d03c-b238-41a5-9a1d-2498efff3a97";
createTime = Reflect.on(collector).call("getTemplateCreateTime", templateID).get();
Assert.assertEquals("2020-05-07 17:45", createTime);
}
private TemplateInfo getTemplateInfoByID(String templateID) {
TemplateInfoCollector collector = TemplateInfoCollector.getInstance();
Map<String, Long> latestTemplateInfo = Reflect.on(collector).field("latestTemplateInfo").get();
Map<String, TemplateInfo> pointInfoMap = Reflect.on(collector).field("pointInfoMap").get();
if (latestTemplateInfo.containsKey(templateID)) {
long latestSaveTime = latestTemplateInfo.get(templateID);
return pointInfoMap.get(templateID + "_" + latestSaveTime);
} else {
return TemplateInfo.newInstance(templateID);
}
}
}

90
designer-base/src/test/java/com/fr/design/mainframe/template/info/TemplateInfoTest.java

@ -1,13 +1,15 @@
package com.fr.design.mainframe.template.info;
import com.fr.config.MarketConfig;
import com.fr.general.GeneralUtils;
import com.fr.design.DesignerEnvManager;
import com.fr.invoke.Reflect;
import com.fr.json.JSON;
import com.fr.json.JSONFactory;
import com.fr.json.JSONObject;
import com.fr.stable.ProductConstants;
import com.fr.stable.StringUtils;
import com.fr.stable.xml.XMLableReader;
import com.fr.third.javax.xml.stream.XMLStreamException;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@ -25,17 +27,17 @@ import static org.junit.Assert.assertEquals;
* Created by plough on 2019/4/19.
*/
@RunWith(PowerMockRunner.class)
@PrepareForTest({MarketConfig.class, ProductConstants.class, GeneralUtils.class})
@PrepareForTest({MarketConfig.class, DesignerEnvManager.class})
public class TemplateInfoTest {
private static final String NORMAL_INFO = "<TemplateInfo templateID=\"16a988ce-8529-42f5-b17c-2ee849355071\" day_count=\"9\">\n" +
"<processMap process=\"\" float_count=\"0\" widget_count=\"0\" cell_count=\"1\" block_count=\"0\" report_type=\"0\"/>\n" +
"<consumingMap activitykey=\"2e0ea413-fa9c241e0-9723-4354fce51e81\" jar_time=\"不是安装版本\" create_time=\"2019-03-26 16:13\" uuid=\"476ca2cc-f789-4c5d-8e89-ef146580775c\" time_consume=\"129\" version=\"10.0\" username=\"plough\"/>\n" +
private static final String NORMAL_INFO = "<TemplateInfo templateID=\"aac1139e-018b-4481-867a-a18fc6d6f3e6\" day_count=\"0\" test_template=\"true\">\n" +
"<processMap process=\"\" float_count=\"0\" widget_count=\"0\" cell_count=\"3\" block_count=\"0\" report_type=\"0\" paraApply=\"0\" components_info=\"[]\"/>\n" +
"<consumingMap create_time=\"2020-05-07 17:28\" uuid=\"6b6699ff-ec63-43b0-9deb-b580a5f10411\" uid=\"71113\" saveRecord=\"{&quot;time&quot;:1588843693000,&quot;consume&quot;:4}\"/>\n" +
"</TemplateInfo>";
private static final String SAVE_AS_INFO = "<TemplateInfo templateID=\"49avd2c4-1104-92j2-wx24-3dd0k2136080\" originID=\"16a988ce-8529-42f5-b17c-2ee849355071\" day_count=\"9\">\n" +
"<processMap process=\"\" float_count=\"0\" widget_count=\"0\" cell_count=\"1\" block_count=\"0\" report_type=\"0\"/>\n" +
"<consumingMap activitykey=\"2e0ea413-fa9c241e0-9723-4354fce51e81\" jar_time=\"不是安装版本\" create_time=\"2019-03-26 16:13\" uuid=\"476ca2cc-f789-4c5d-8e89-ef146580775c\" time_consume=\"429\" originTime=\"129\" version=\"10.0\" username=\"plough\"/>\n" +
private static final String SAVE_AS_INFO = "<TemplateInfo templateID=\"2521d03c-b238-41a5-9a1d-2498efff3a97\" originID=\"aac1139e-018b-4481-867a-a18fc6d6f3e6\" day_count=\"0\" test_template=\"true\">\n" +
"<processMap process=\"\" float_count=\"0\" widget_count=\"0\" cell_count=\"3\" block_count=\"0\" report_type=\"0\" paraApply=\"0\" components_info=\"[]\"/>\n" +
"<consumingMap create_time=\"2020-05-07 17:45\" uuid=\"6b6699ff-ec63-43b0-9deb-b580a5f10411\" uid=\"71113\" saveRecord=\"{&quot;time&quot;:1588844751000,&quot;consume&quot;:1058}\"/>\n" +
"</TemplateInfo>";
private TemplateInfo templateInfo;
@ -56,15 +58,14 @@ public class TemplateInfoTest {
assertEquals(templateID, templateInfo.getTemplateID());
assertEquals(StringUtils.EMPTY, Reflect.on(templateInfo).field("originID").get());
assertEquals(0, (int) Reflect.on(templateInfo).field("idleDayCount").get());
assertEquals(false, templateInfo.isTestTemplate());
Map<String, Object> consumingMap = Reflect.on(templateInfo).field("consumingMap").get();
assertEquals(templateID, consumingMap.get("templateID"));
assertEquals(0, consumingMap.get("originTime"));
assertEquals(StringUtils.EMPTY, consumingMap.get("originID"));
assertEquals(0, consumingMap.get("time_consume"));
assertEquals("不是安装版本", consumingMap.get("jar_time"));
assertEquals("plough", consumingMap.get("username"));
assertEquals("10.0", consumingMap.get("version"));
assertEquals("6b6699ff-ec63-43b0-9deb-b580a5f10411", consumingMap.get("uuid"));
assertEquals(71113, consumingMap.get("uid"));
assertEquals(StringUtils.EMPTY, consumingMap.get("saveRecord"));
}
@Test
@ -73,26 +74,27 @@ public class TemplateInfoTest {
String templateID = "24121212-u2c8-ncd2-82nx-8ud0i8138888";
String originID = "24avc8n2-1iq8-iuj2-wx24-8yy0i8132302";
int originTime = 100;
TemplateInfo templateInfo = TemplateInfo.newInstance(templateID, originID, originTime);
String saveRecord = "{\"time\";:1588843629000,\"consume\":81}";
String createTime = "2020-05-07 17:25";
TemplateInfo templateInfo = TemplateInfo.newInstance(templateID, originID, saveRecord, createTime);
assertEquals(templateID, templateInfo.getTemplateID());
assertEquals(originID, Reflect.on(templateInfo).field("originID").get());
assertEquals(0, (int) Reflect.on(templateInfo).field("idleDayCount").get());
assertEquals(false, templateInfo.isTestTemplate());
Map<String, Object> consumingMap = Reflect.on(templateInfo).field("consumingMap").get();
assertEquals(templateID, consumingMap.get("templateID"));
assertEquals(originTime, consumingMap.get("originTime"));
assertEquals(originID, consumingMap.get("originID"));
assertEquals(originTime, consumingMap.get("time_consume"));
assertEquals("不是安装版本", consumingMap.get("jar_time"));
assertEquals("plough", consumingMap.get("username"));
assertEquals("10.0", consumingMap.get("version"));
assertEquals("6b6699ff-ec63-43b0-9deb-b580a5f10411", consumingMap.get("uuid"));
assertEquals(71113, consumingMap.get("uid"));
assertEquals(saveRecord, consumingMap.get("saveRecord"));
assertEquals(createTime, consumingMap.get("create_time"));
}
@Test
public void testGetTemplateID() {
assertEquals("16a988ce-8529-42f5-b17c-2ee849355071", templateInfo.getTemplateID());
assertEquals("49avd2c4-1104-92j2-wx24-3dd0k2136080", templateInfoSaveAs.getTemplateID());
assertEquals("aac1139e-018b-4481-867a-a18fc6d6f3e6", templateInfo.getTemplateID());
assertEquals("2521d03c-b238-41a5-9a1d-2498efff3a97", templateInfoSaveAs.getTemplateID());
}
@Test
@ -102,19 +104,21 @@ public class TemplateInfoTest {
Map processMap = Reflect.on(templateInfo).field("processMap").get();
Map consumingMap1 = Reflect.on(templateInfoSaveAs).field("consumingMap").get();
Map processMap1 = Reflect.on(templateInfoSaveAs).field("processMap").get();
assertJsonStringEquals("{\"activitykey\":\"2e0ea413-fa9c241e0-9723-4354fce51e81\",\"jar_time\":\"不是安装版本\"," +
"\"create_time\":\"2019-03-26 16:13\",\"templateID\":\"16a988ce-8529-42f5-b17c-2ee849355071\",\"originID\":\"\"," +
"\"uuid\":\"476ca2cc-f789-4c5d-8e89-ef146580775c\",\"time_consume\":129,\"originTime\":0,\"version\":\"10.0\"," +
"\"username\":\"plough\"}", new JSONObject(consumingMap).toString());
assertJsonStringEquals("{\"activitykey\":\"2e0ea413-fa9c241e0-9723-4354fce51e81\",\"jar_time\":\"不是安装版本\"," +
"\"create_time\":\"2019-03-26 16:13\",\"templateID\":\"49avd2c4-1104-92j2-wx24-3dd0k2136080\",\"originID\":\"16a988ce-8529-42f5-b17c-2ee849355071\"," +
"\"uuid\":\"476ca2cc-f789-4c5d-8e89-ef146580775c\",\"time_consume\":429,\"originTime\":129,\"version\":\"10.0\"," +
"\"username\":\"plough\"}", new JSONObject(consumingMap1).toString());
assertJsonStringEquals("{\"process\":\"\",\"float_count\":0,\"widget_count\":0,\"cell_count\":1," +
"\"block_count\":0,\"report_type\":0,\"templateID\":\"16a988ce-8529-42f5-b17c-2ee849355071\"}", new JSONObject(processMap).toString());
assertJsonStringEquals("{\"process\":\"\",\"float_count\":0,\"widget_count\":0,\"cell_count\":1," +
"\"block_count\":0,\"report_type\":0,\"templateID\":\"49avd2c4-1104-92j2-wx24-3dd0k2136080\"}", new JSONObject(processMap1).toString());
assertJsonStringEquals("{\"uid\":71113,\"originID\":\"\",\"create_time\":\"2020-05-07 17:28\"," +
"\"saveRecord\":\"{\\\"time\\\":1588843693000,\\\"consume\\\":4}\"," +
"\"templateID\":\"aac1139e-018b-4481-867a-a18fc6d6f3e6\"," +
"\"uuid\":\"6b6699ff-ec63-43b0-9deb-b580a5f10411\"}", JSONFactory.createJSON(JSON.OBJECT, consumingMap).toString());
assertJsonStringEquals("{\"uid\":71113,\"originID\":\"aac1139e-018b-4481-867a-a18fc6d6f3e6\"," +
"\"create_time\":\"2020-05-07 17:45\",\"saveRecord\":\"{\\\"time\\\":1588844751000,\\\"consume\\\":1058}\"," +
"\"templateID\":\"2521d03c-b238-41a5-9a1d-2498efff3a97\"," +
"\"uuid\":\"6b6699ff-ec63-43b0-9deb-b580a5f10411\"}", JSONFactory.createJSON(JSON.OBJECT, consumingMap1).toString());
assertJsonStringEquals("{\"process\":\"\",\"float_count\":0,\"widget_count\":0,\"cell_count\":3," +
"\"paraApply\":0,\"block_count\":0,\"report_type\":0,\"components_info\":\"[]\"," +
"\"templateID\":\"aac1139e-018b-4481-867a-a18fc6d6f3e6\"}", JSONFactory.createJSON(JSON.OBJECT, processMap).toString());
assertJsonStringEquals("{\"process\":\"\",\"float_count\":0,\"widget_count\":0,\"cell_count\":3," +
"\"paraApply\":0,\"block_count\":0,\"report_type\":0,\"components_info\":\"[]\"," +
"\"templateID\":\"2521d03c-b238-41a5-9a1d-2498efff3a97\"}", JSONFactory.createJSON(JSON.OBJECT, processMap1).toString());
}
private TemplateInfo createTemplateInfo(String xmlContent) throws XMLStreamException {
@ -122,4 +126,18 @@ public class TemplateInfoTest {
XMLableReader xmlReader = XMLableReader.createXMLableReader(sr);
return TemplateInfo.newInstanceByRead(xmlReader);
}
@Test
public void testGetSaveTime() {
Map consumingMap = Reflect.on(templateInfo).field("consumingMap").get();
String saveRecord = (String) consumingMap.get("saveRecord");
JSONObject object = JSONFactory.createJSON(JSON.OBJECT, saveRecord);
Assert.assertEquals(1588843693000L, object.optLong("time"));
}
@Test
public void testGetTemplateCreateTime() {
Map consumingMap = Reflect.on(templateInfo).field("consumingMap").get();
Assert.assertEquals("2020-05-07 17:28", (String) consumingMap.get("create_time"));
}
}

18
designer-base/src/test/java/com/fr/design/mainframe/template/info/TemplateInfoTestHelper.java

@ -1,10 +1,10 @@
package com.fr.design.mainframe.template.info;
import com.fr.config.BBSAttr;
import com.fr.config.MarketConfig;
import com.fr.design.DesignerEnvManager;
import com.fr.general.ComparatorUtils;
import com.fr.general.GeneralUtils;
import com.fr.json.JSONObject;
import com.fr.stable.ProductConstants;
import org.easymock.EasyMock;
import org.powermock.api.easymock.PowerMock;
@ -33,17 +33,21 @@ class TemplateInfoTestHelper {
static void setUpMockForNewInstance() throws Exception {
MarketConfig mockMarketConfig = EasyMock.mock(MarketConfig.class);
EasyMock.expect(mockMarketConfig.getBbsUsername()).andReturn("plough").anyTimes();
BBSAttr bbsAttr = EasyMock.mock(BBSAttr.class);
EasyMock.expect(bbsAttr.getBbsUid()).andReturn(71113).anyTimes();
EasyMock.expect(mockMarketConfig.getBBSAttr()).andReturn(bbsAttr).anyTimes();
PowerMock.mockStatic(MarketConfig.class);
EasyMock.expect(MarketConfig.getInstance()).andReturn(mockMarketConfig).anyTimes();
PowerMock.mockStatic(GeneralUtils.class);
EasyMock.expect(GeneralUtils.readBuildNO()).andReturn("不是安装版本").anyTimes();
PowerMock.mockStatic(DesignerEnvManager.class);
DesignerEnvManager envManager = EasyMock.mock( DesignerEnvManager.class);
EasyMock.expect(envManager.getUUID()).andReturn("6b6699ff-ec63-43b0-9deb-b580a5f10411").anyTimes();
EasyMock.expect(envManager.isJoinProductImprove()).andReturn(true).anyTimes();
EasyMock.expect(DesignerEnvManager.getEnvManager()).andReturn(envManager).anyTimes();
EasyMock.replay(mockMarketConfig, bbsAttr, envManager);
setFinalStatic(ProductConstants.class.getDeclaredField("VERSION"), "10.0");
EasyMock.replay(mockMarketConfig);
PowerMock.replayAll();
}
}

44
designer-base/src/test/resources/com/fr/design/mainframe/template/info/tpl.info

@ -1,35 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<TplInfo xmlVersion="20170720" releaseVersion="10.0.0">
<DesignerOpenHistory>
<![CDATA[2019-04-08,2019-04-03,2019-03-29]]></DesignerOpenHistory>
<![CDATA[2020-05-07,2020-05-06,2020-04-30]]></DesignerOpenHistory>
<TemplateInfoList>
<TemplateInfo templateID="16a988ce-8529-42f5-b17c-2ee849355071" day_count="9">
<processMap process="" float_count="0" widget_count="0" cell_count="1" block_count="0" report_type="0"/>
<consumingMap activitykey="2e0ea413-fa9c241e0-9723-4354fce51e81" jar_time="不是安装版本" create_time="2019-03-26 16:13" uuid="476ca2cc-f789-4c5d-8e89-ef146580775c" time_consume="129" version="10.0" username="plough"/>
<TemplateInfo templateID="e5d7dbb2-d1df-43d4-b974-67acb5ecbffa" day_count="0" test_template="true">
<processMap process="" float_count="0" widget_count="2" cell_count="0" block_count="0" report_type="2" paraApply="1" components_info="[{&quot;componentID&quot;:&quot;60e291c2-be60-4908-83ef-08b4a79d5f03&quot;,&quot;componentName&quot;:&quot;button1&quot;,&quot;componentType&quot;:&quot;Widget&quot;,&quot;createTime&quot;:1588843627801,&quot;deleteTime&quot;:0},{&quot;componentID&quot;:&quot;fcf77ee3-05f0-4219-8fd2-d2a9ec95477e&quot;,&quot;componentName&quot;:&quot;button0&quot;,&quot;componentType&quot;:&quot;Widget&quot;,&quot;createTime&quot;:1588843624940,&quot;deleteTime&quot;:0}]"/>
<consumingMap create_time="2020-05-07 17:25" uuid="6b6699ff-ec63-43b0-9deb-b580a5f10411" uid="71113" saveRecord="{&quot;time&quot;:1588843629000,&quot;consume&quot;:81}"/>
</TemplateInfo>
<TemplateInfo templateID="23817e4f-64b6-438e-b23b-91c1a4d0b254" day_count="9">
<processMap process="" float_count="0" widget_count="0" cell_count="231" block_count="0" report_type="0"/>
<consumingMap activitykey="2e0ea413-fa9c241e0-9723-4354fce51e81" jar_time="不是安装版本" create_time="2019-03-26 16:52" uuid="476ca2cc-f789-4c5d-8e89-ef146580775c" time_consume="91" version="10.0" username="plough"/>
<TemplateInfo templateID="2521d03c-b238-41a5-9a1d-2498efff3a97" originID="aac1139e-018b-4481-867a-a18fc6d6f3e6" day_count="0" test_template="true">
<processMap process="" float_count="0" widget_count="0" cell_count="3" block_count="0" report_type="0" paraApply="0" components_info="[]"/>
<consumingMap create_time="2020-05-07 17:45" uuid="6b6699ff-ec63-43b0-9deb-b580a5f10411" uid="71113" saveRecord="{&quot;time&quot;:1588844751000,&quot;consume&quot;:1058}"/>
</TemplateInfo>
<TemplateInfo templateID="31319947-5ce7-4d82-97e4-3cfea825df9c" day_count="9">
<processMap process="" float_count="0" widget_count="0" cell_count="3" block_count="0" report_type="0"/>
<consumingMap activitykey="2e0ea413-fa9c241e0-9723-4354fce51e81" jar_time="不是安装版本" create_time="2019-03-26 16:49" uuid="476ca2cc-f789-4c5d-8e89-ef146580775c" time_consume="160" version="10.0" username="plough"/>
<TemplateInfo templateID="e5d7dbb2-d1df-43d4-b974-67acb5ecbffa" day_count="0" test_template="true">
<processMap process="" float_count="0" widget_count="2" cell_count="0" block_count="0" report_type="2" paraApply="1" components_info="[{&quot;componentID&quot;:&quot;e28e24af-a01a-42cd-aa06-e14dd7990621&quot;,&quot;componentName&quot;:&quot;button1&quot;,&quot;componentType&quot;:&quot;Widget&quot;,&quot;createTime&quot;:1588843526090,&quot;deleteTime&quot;:0},{&quot;componentID&quot;:&quot;0e7ce6df-f19b-40a9-a4d9-d47bdc097e31&quot;,&quot;componentName&quot;:&quot;button0&quot;,&quot;componentType&quot;:&quot;Widget&quot;,&quot;createTime&quot;:1588843525059,&quot;deleteTime&quot;:0}]"/>
<consumingMap create_time="2020-05-07 17:25" uuid="6b6699ff-ec63-43b0-9deb-b580a5f10411" uid="71113" saveRecord="{&quot;time&quot;:1588843530000,&quot;consume&quot;:6}"/>
</TemplateInfo>
<TemplateInfo templateID="43bdd914-a3f7-405c-ad96-2feaf28bed74" day_count="8">
<processMap process="" float_count="0" widget_count="0" cell_count="1" block_count="0" report_type="0"/>
<consumingMap activitykey="2e0ea413-fa9c241e0-9723-4354fce51e81" jar_time="2019.01.04.18.06.01.38" create_time="2019-03-27 16:17" uuid="476ca2cc-f789-4c5d-8e89-ef146580775c" time_consume="1426" version="10.0" username="plough"/>
<TemplateInfo templateID="aac1139e-018b-4481-867a-a18fc6d6f3e6" day_count="0" test_template="true">
<processMap process="" float_count="0" widget_count="0" cell_count="3" block_count="0" report_type="0" paraApply="0" components_info="[]"/>
<consumingMap create_time="2020-05-07 17:28" uuid="6b6699ff-ec63-43b0-9deb-b580a5f10411" uid="71113" saveRecord="{&quot;time&quot;:1588843693000,&quot;consume&quot;:4}"/>
</TemplateInfo>
<TemplateInfo templateID="cd527ae5-06e4-48fb-a73e-e9a06c9e7c58" day_count="12">
<processMap process="" float_count="0" widget_count="0" cell_count="3" block_count="0" report_type="0"/>
<consumingMap activitykey="2e0ea413-fa9c241e0-9723-4354fce51e81" jar_time="2019.01.04.18.06.01.38" create_time="2019-03-15 10:02" uuid="476ca2cc-f789-4c5d-8e89-ef146580775c" time_consume="430" version="10.0" username="plough"/>
<TemplateInfo templateID="e5d7dbb2-d1df-43d4-b974-67acb5ecbffa" day_count="0" test_template="true">
<processMap process="" float_count="0" widget_count="1" cell_count="0" block_count="0" report_type="2" paraApply="1" components_info="[{&quot;componentID&quot;:&quot;60e291c2-be60-4908-83ef-08b4a79d5f03&quot;,&quot;componentName&quot;:&quot;button1&quot;,&quot;componentType&quot;:&quot;Widget&quot;,&quot;createTime&quot;:0,&quot;deleteTime&quot;:1588843630822}]"/>
<consumingMap create_time="2020-05-07 17:25" uuid="6b6699ff-ec63-43b0-9deb-b580a5f10411" uid="71113" saveRecord="{&quot;time&quot;:1588843631000,&quot;consume&quot;:2}"/>
</TemplateInfo>
<TemplateInfo templateID="08f9c404-8124-4615-a34c-735dcabee137" day_count="9">
<processMap process="" float_count="0" widget_count="0" cell_count="2" block_count="0" report_type="0"/>
<consumingMap activitykey="2e0ea413-fa9c241e0-9723-4354fce51e81" jar_time="不是安装版本" create_time="2019-03-25 17:22" uuid="476ca2cc-f789-4c5d-8e89-ef146580775c" time_consume="1497" version="10.0" username="plough"/>
<TemplateInfo templateID="e5d7dbb2-d1df-43d4-b974-67acb5ecbffa" day_count="0" test_template="true">
<processMap process="" float_count="0" widget_count="0" cell_count="0" block_count="0" report_type="2" paraApply="1" components_info="[{&quot;componentID&quot;:&quot;fcf77ee3-05f0-4219-8fd2-d2a9ec95477e&quot;,&quot;componentName&quot;:&quot;button0&quot;,&quot;componentType&quot;:&quot;Widget&quot;,&quot;createTime&quot;:0,&quot;deleteTime&quot;:1588843641882}]"/>
<consumingMap create_time="2020-05-07 17:25" uuid="6b6699ff-ec63-43b0-9deb-b580a5f10411" uid="71113" saveRecord="{&quot;time&quot;:1588843642000,&quot;consume&quot;:10}"/>
</TemplateInfo>
<TemplateInfo templateID="981314a5-9c5b-4831-97d8-15e76735f9e2" day_count="1">
<processMap process="" float_count="0" widget_count="0" cell_count="3" block_count="0" report_type="0"/>
<consumingMap activitykey="2e0ea413-fa9c241e0-9723-4354fce51e81" jar_time="不是安装版本" create_time="2019-04-17 16:24" uuid="476ca2cc-f789-4c5d-8e89-ef146580775c" time_consume="155" version="10.0" username="plough"/>
<TemplateInfo templateID="e5d7dbb2-d1df-43d4-b974-67acb5ecbffa" day_count="0" test_template="true">
<processMap process="" float_count="0" widget_count="1" cell_count="0" block_count="0" report_type="2" paraApply="1" components_info="[]"/>
<consumingMap create_time="2020-05-07 17:25" uuid="6b6699ff-ec63-43b0-9deb-b580a5f10411" uid="71113" saveRecord="{&quot;time&quot;:1588843548000,&quot;consume&quot;:17}"/>
</TemplateInfo>
</TemplateInfoList>
</TplInfo>

12
designer-chart/src/main/java/com/fr/design/chart/series/SeriesCondition/impl/ChartHyperPopAttrPane.java

@ -13,13 +13,14 @@ import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.chart.AbstractChartAttrPane;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.stable.ParameterProvider;
import com.fr.stable.StringUtils;
import javax.swing.*;
import java.awt.*;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import java.util.List;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
/**
* 图表弹出超链, 悬浮窗属性设置界面.
@ -108,9 +109,6 @@ public class ChartHyperPopAttrPane extends AbstractChartAttrPane {
*/
public void updateBean(ChartHyperPoplink chartHyperlink) {
String title = titleField.getText();
if (StringUtils.isBlank(title)) {
title = "Chart";
}
chartHyperlink.setChartDigTitle(title);
chartHyperlink.setWidth((int)widthField.getValue());
chartHyperlink.setHeight((int)heightField.getValue());

10
designer-chart/src/main/java/com/fr/design/chart/series/SeriesCondition/impl/ChartHyperRelateFloatLinkPane.java

@ -17,13 +17,13 @@ import javax.swing.JPanel;
import javax.swing.border.Border;
import javax.swing.border.LineBorder;
import javax.swing.border.TitledBorder;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
/**
* @author kunsnat E-mail:kunsnat@gmail.com
@ -84,9 +84,13 @@ public class ChartHyperRelateFloatLinkPane extends AbstractHyperLinkPane<ChartHy
private String[] getFloatNames() {
DesignModelAdapter adapter = DesignModelAdapter.getCurrentModelAdapter();
try {
if (adapter != null) {
return adapter.getFloatNames();
}
}catch (Exception Ignore){
}
return new String[0];
}

5
designer-chart/src/main/java/com/fr/design/chartx/component/combobox/ColorSchemeComboBox.java

@ -82,6 +82,11 @@ public class ColorSchemeComboBox extends UIComboBox {
return colorSchemes;
}
public void refresh() {
this.colorSchemes = getColorSchemesFromConfig();
this.setModel(new DefaultComboBoxModel(colorSchemes.keySet().toArray()));
}
public ColorInfo getSelectColorInfo() {
String selectedItem = (String) getSelectedItem();
return colorSchemes.get(selectedItem);

33
designer-chart/src/main/java/com/fr/design/gui/xcombox/MarkerComboBox.java

@ -8,9 +8,11 @@ import com.fr.base.GraphHelper;
import com.fr.base.ScreenResolution;
import com.fr.base.background.ColorBackground;
import com.fr.chart.chartglyph.Marker;
import com.fr.chart.chartglyph.NullMarker;
import com.fr.general.ComparatorUtils;
import com.fr.plugin.chart.ConfigHelper;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.icombobox.UIComboBoxRenderer;
import com.fr.design.i18n.Toolkit;
import com.fr.general.FRFont;
@ -21,6 +23,8 @@ import java.awt.*;
* Combobox for selecting marker.
*/
public class MarkerComboBox extends UIComboBox {
private static final double TEXT_X_COORDINATES = 12d;
/**
* Constructor.
*
@ -65,15 +69,15 @@ public class MarkerComboBox extends UIComboBox {
g2d.setFont(FRContext.getDefaultValues().getFRFont());
if (marker != null) {
if (marker instanceof NullMarker) {
g2d.setColor(Color.black);
FRFont font = FRContext.getDefaultValues().getFRFont();
int resolution = ScreenResolution.getScreenResolution();
Font rfont = font.applyResolutionNP(resolution);
g2d.setFont(rfont);
FontMetrics fm = GraphHelper.getFontMetrics(rfont);
boolean isAutoMarker = ComparatorUtils.equals(marker.getMarkerType(), ConfigHelper.AUTO_M);
boolean isNullMarker = ComparatorUtils.equals(marker.getMarkerType(), ConfigHelper.NULL_M);
GraphHelper.drawString(g2d, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_None"), 12, (d.height - fm.getHeight()) / 2 + fm.getAscent());
if (isAutoMarker || isNullMarker) {
String text = isNullMarker
?Toolkit.i18nText("Fine-Design_Report_None")
:Toolkit.i18nText("Fine-Design_Basic_ChartF_Auto");
paintTextMarker(g2d, d, text);
} else {
if (marker.getBackground() == null) {
marker.setBackground(ColorBackground.getInstance(Color.black));
@ -98,5 +102,16 @@ public class MarkerComboBox extends UIComboBox {
private Marker marker = null;
private boolean isSelected = false;
private void paintTextMarker(Graphics2D g2d, Dimension d, String text) {
g2d.setColor(Color.black);
FRFont font = FRContext.getDefaultValues().getFRFont();
int resolution = ScreenResolution.getScreenResolution();
Font rfont = font.applyResolutionNP(resolution);
g2d.setFont(rfont);
FontMetrics fm = GraphHelper.getFontMetrics(rfont);
GraphHelper.drawString(g2d, text, TEXT_X_COORDINATES, (d.height - fm.getHeight()) / 2 + fm.getAscent());
}
}
}

16
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartDataPane.java

@ -3,6 +3,7 @@ package com.fr.design.mainframe.chart.gui;
import com.fr.chart.chartattr.ChartCollection;
import com.fr.chart.chartattr.GisMapPlot;
import com.fr.chart.chartattr.MapPlot;
import com.fr.chartx.config.info.constant.ConfigType;
import com.fr.design.chart.report.GisMapDataPane;
import com.fr.design.chart.report.MapDataPane;
import com.fr.design.gui.frpane.AttributeChangeListener;
@ -10,6 +11,9 @@ import com.fr.design.mainframe.chart.AbstractChartAttrPane;
import com.fr.design.mainframe.chart.PaneTitleConstants;
import com.fr.design.mainframe.chart.gui.data.DataContentsPane;
import com.fr.design.mainframe.chart.gui.data.NormalChartDataPane;
import com.fr.design.mainframe.chart.info.ChartInfoCollector;
import com.fr.plugin.chart.attr.plot.VanChartPlot;
import com.fr.plugin.chart.vanchart.VanChart;
import javax.swing.JPanel;
import java.awt.BorderLayout;
@ -108,6 +112,18 @@ public class ChartDataPane extends AbstractChartAttrPane {
public void update(ChartCollection collection) {
if (contentsPane != null) {
contentsPane.update(collection);
updateBuryingPoint(collection);
}
}
protected void updateBuryingPoint(ChartCollection collection){
VanChart vanchart = collection.getSelectedChartProvider(VanChart.class);
if (vanchart != null) {
VanChartPlot plot = vanchart.getPlot();
if( !plot.isInCustom()) {
ChartInfoCollector.getInstance().updateChartConfig(vanchart, ConfigType.DATA,
vanchart.getBuryingPointDataConfig());
}
}
}

8
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartOtherPane.java

@ -3,6 +3,7 @@ package com.fr.design.mainframe.chart.gui;
import com.fr.chart.chartattr.Chart;
import com.fr.chart.chartattr.ChartCollection;
import com.fr.chart.chartattr.Plot;
import com.fr.chartx.config.info.constant.ConfigType;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.dialog.BasicPane;
import com.fr.design.mainframe.chart.AbstractChartAttrPane;
@ -11,11 +12,12 @@ import com.fr.design.mainframe.chart.PaneTitleConstants;
import com.fr.design.mainframe.chart.gui.other.ChartConditionAttrPane;
import com.fr.design.mainframe.chart.gui.other.ChartInteractivePane;
import com.fr.design.mainframe.chart.gui.type.ChartTabPane;
import com.fr.design.mainframe.chart.info.ChartInfoCollector;
import javax.swing.*;
import java.awt.*;
import javax.swing.JPanel;
import java.util.ArrayList;
import java.util.List;
import java.awt.BorderLayout;
public class ChartOtherPane extends AbstractChartAttrPane {
private static final long serialVersionUID = -5612046386597783406L;
@ -121,6 +123,8 @@ public class ChartOtherPane extends AbstractChartAttrPane {
if (ChartOtherPane.this.isHaveCondition()) {
conditionAttrPane.updateBean(chart);
}
//特效埋点
ChartInfoCollector.getInstance().updateChartConfig(chart, ConfigType.EFFECT, chart.getBuryingPointEffectConfig());
}
/**

4
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ChartTextAttrPane.java

@ -1,6 +1,7 @@
package com.fr.design.mainframe.chart.gui.style;
import com.fr.base.BaseUtils;
import com.fr.base.FRContext;
import com.fr.base.Utils;
import com.fr.chart.base.TextAttr;
import com.fr.design.constants.LayoutConstants;
@ -14,7 +15,6 @@ import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.TableLayout;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.FRFont;
import com.fr.general.GeneralUtils;
import com.fr.van.chart.designer.TableLayout4VanChartHelper;
@ -202,7 +202,7 @@ public class ChartTextAttrPane extends BasicPane {
this.setLayout(new BorderLayout());
this.add(getContentPane(buttonPane), BorderLayout.CENTER);
populate(FRFont.getInstance());
populate(FRContext.getDefaultValues().getFRFont());
}
protected JPanel getContentPane(JPanel buttonPane) {

4
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/series/ChartSeriesPane.java

@ -2,9 +2,11 @@ package com.fr.design.mainframe.chart.gui.style.series;
import com.fr.chart.chartattr.Chart;
import com.fr.chartx.config.info.constant.ConfigType;
import com.fr.design.ChartTypeInterfaceManager;
import com.fr.design.mainframe.chart.PaneTitleConstants;
import com.fr.design.mainframe.chart.gui.ChartStylePane;
import com.fr.design.mainframe.chart.info.ChartInfoCollector;
import com.fr.van.chart.designer.AbstractVanChartScrollPane;
import javax.swing.JPanel;
@ -60,6 +62,8 @@ public class ChartSeriesPane extends AbstractVanChartScrollPane<Chart> {
if(seriesStyleContentPane != null) {
seriesStyleContentPane.setCurrentChart(chart);
seriesStyleContentPane.updateBean(chart.getPlot());
//系列埋点
ChartInfoCollector.getInstance().updateChartConfig(chart, ConfigType.SERIES, chart.getPlot().getBuryingPointSeriesConfig());
}
}

9
designer-chart/src/main/java/com/fr/design/module/ChartPreFillStylePane.java

@ -12,6 +12,7 @@ import com.fr.design.style.background.gradient.FixedGradientBar;
import javax.swing.JPanel;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.awt.BorderLayout;
import java.awt.CardLayout;
@ -25,6 +26,7 @@ import java.awt.event.ActionListener;
/**
* 预定义的图表配色界面.
*
* @author kunsnat E-mail:kunsnat@gmail.com
* @version 创建时间2013-8-21 下午03:16:27
*/
@ -129,7 +131,12 @@ public class ChartPreFillStylePane extends BasicBeanPane<ChartColorMatching> {
gradientButton.setSelected(false);
cardLayout.show(changeColorSetPane, "acc");
if (colorList.size() > 0) {
if (colorList.isEmpty()) {
List<Color> resultList = new ArrayList<>();
Collections.addAll(resultList, ChartColorAdjustPane.DEFAULT_COLORS);
condition.setColorList(resultList);
colorAdjustPane.updateColor(ChartColorAdjustPane.DEFAULT_COLORS);
} else {
colorAdjustPane.updateColor(colorList.toArray(new Color[colorList.size()]));
}
}

21
designer-chart/src/main/java/com/fr/design/module/ChartPreStyleAction.java

@ -1,6 +1,7 @@
package com.fr.design.module;
import com.fr.base.ChartPreStyleConfig;
import com.fr.concurrent.NamedThreadFactory;
import com.fr.design.actions.UpdateAction;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.DialogActionAdapter;
@ -8,11 +9,14 @@ import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.DesignerFrame;
import com.fr.design.menu.MenuKeySet;
import com.fr.general.IOUtils;
import com.fr.module.ModuleContext;
import com.fr.transaction.CallBackAdaptor;
import com.fr.transaction.Configurations;
import com.fr.transaction.WorkerFacade;
import com.fr.van.chart.designer.component.VanChartFillStylePane;
import javax.swing.KeyStroke;
import java.util.concurrent.ExecutorService;
import java.awt.event.ActionEvent;
/**
@ -22,6 +26,9 @@ import java.awt.event.ActionEvent;
*/
public class ChartPreStyleAction extends UpdateAction {
private static ExecutorService refreshDesignPool = ModuleContext.getExecutor().newFixedThreadPool(
10, new NamedThreadFactory("refreshChartStylePane"));
public ChartPreStyleAction() {
this.setMenuKeySet(CHART_DEFAULT_STYLE);
this.setName(getMenuKeySet().getMenuKeySetName()+ "...");
@ -54,6 +61,20 @@ public class ChartPreStyleAction extends UpdateAction {
if (frame != null) {
frame.repaint();
}
if (refreshDesignPool.isTerminated()) {
synchronized (refreshDesignPool) {
if (refreshDesignPool.isTerminated()) {
refreshDesignPool = ModuleContext.getExecutor().newFixedThreadPool(
10, new NamedThreadFactory("refreshChartStylePane"));
}
}
}
refreshDesignPool.execute(new Runnable() {
@Override
public void run() {
DesignerContext.getDesignerBean(VanChartFillStylePane.name).refreshBeanElement();
}
});
}
}));
}

4
designer-chart/src/main/java/com/fr/van/chart/area/VanChartAreaConditionPane.java

@ -20,7 +20,7 @@ import com.fr.van.chart.designer.other.condition.item.VanChartAreaFillColorCondi
import com.fr.van.chart.designer.other.condition.item.VanChartDataSheetContentPane;
import com.fr.van.chart.designer.other.condition.item.VanChartEffectConditionPane;
import com.fr.van.chart.designer.other.condition.item.VanChartLabelConditionPane;
import com.fr.van.chart.designer.other.condition.item.VanChartLineTypeConditionPane;
import com.fr.van.chart.designer.other.condition.item.VanChartLineTypeConditionPaneWithoutDashed;
import com.fr.van.chart.designer.other.condition.item.VanChartMarkerConditionPane;
import com.fr.van.chart.designer.other.condition.item.VanChartSeriesColorConditionPane;
import com.fr.van.chart.designer.other.condition.item.VanChartTooltipConditionPane;
@ -50,7 +50,7 @@ public class VanChartAreaConditionPane extends DataSeriesConditionPane {
classPaneMap.put(AttrBackground.class, new VanChartSeriesColorConditionPane(this));
classPaneMap.put(VanChartAttrTrendLine.class, new VanChartTrendLineConditionPane(this));
classPaneMap.put(AttrAreaSeriesFillColorBackground.class, new VanChartAreaFillColorConditionPane(this, plot));
classPaneMap.put(VanChartAttrLine.class, new VanChartLineTypeConditionPane(this));
classPaneMap.put(VanChartAttrLine.class, new VanChartLineTypeConditionPaneWithoutDashed(this));
classPaneMap.put(AttrTooltip.class, new VanChartTooltipConditionPane(this, plot));
//是否使用数据表
if (plot.getDataSheet().isVisible()) {

14
designer-chart/src/main/java/com/fr/van/chart/area/VanChartAreaSeriesPane.java

@ -2,11 +2,16 @@ package com.fr.van.chart.area;
import com.fr.chart.chartattr.Plot;
import com.fr.design.beans.BasicBeanPane;
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.van.chart.column.VanChartCustomStackAndAxisConditionPane;
import com.fr.van.chart.designer.TableLayout4VanChartHelper;
import com.fr.van.chart.designer.component.VanChartBeautyPane;
import com.fr.van.chart.designer.component.VanChartLineTypePane;
import com.fr.van.chart.designer.component.VanChartLineTypePaneWithoutDashed;
import com.fr.van.chart.designer.component.VanChartMarkerPane;
import com.fr.van.chart.line.VanChartLineSeriesPane;
import javax.swing.JPanel;
@ -49,4 +54,13 @@ public class VanChartAreaSeriesPane extends VanChartLineSeriesPane {
protected VanChartBeautyPane createStylePane() {
return new VanChartBeautyPane();
}
protected VanChartLineTypePane getLineTypePane() {
return new VanChartLineTypePaneWithoutDashed();
}
protected JPanel createMarkerPane() {
markerPane = new VanChartMarkerPane();
return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Marker"), markerPane);
}
}

1
designer-chart/src/main/java/com/fr/van/chart/custom/VanChartCustomDataPane.java

@ -62,6 +62,7 @@ public class VanChartCustomDataPane extends ChartDataPane {
public void update(ChartCollection collection){
if(contentsTabPane != null) {
contentsTabPane.updateBean(collection);
updateBuryingPoint(collection);
}
}
}

4
designer-chart/src/main/java/com/fr/van/chart/custom/VanChartCustomPlotDataContentsTabPane.java

@ -14,7 +14,7 @@ import com.fr.van.chart.custom.component.VanChartDataPane;
import javax.swing.JPanel;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@ -118,7 +118,7 @@ public class VanChartCustomPlotDataContentsTabPane extends VanChartCustomPlotTab
}
try {
Map<CustomPlotType, TopDefinitionProvider> definitionMap = new HashMap<CustomPlotType, TopDefinitionProvider>();
Map<CustomPlotType, TopDefinitionProvider> definitionMap = new LinkedHashMap<CustomPlotType, TopDefinitionProvider>();
//已经有的数据配置不允许重置

3
designer-chart/src/main/java/com/fr/van/chart/custom/VanChartCustomPlotPane.java

@ -29,6 +29,7 @@ import com.fr.van.chart.designer.type.AbstractVanChartTypePane;
import javax.swing.JPanel;
import javax.swing.JSeparator;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.awt.CardLayout;
import java.awt.Component;
@ -192,7 +193,7 @@ public class VanChartCustomPlotPane extends AbstractVanChartTypePane {
return;
}
Map<CustomPlotType, TopDefinitionProvider> newDefinitionMap = new HashMap<CustomPlotType, TopDefinitionProvider>();
Map<CustomPlotType, TopDefinitionProvider> newDefinitionMap = new LinkedHashMap<CustomPlotType, TopDefinitionProvider>();
VanChartCustomPlot customPlot = (VanChartCustomPlot) chart.getPlot();
for (int i = 0; i < customPlot.getCustomPlotList().size(); i++) {

5
designer-chart/src/main/java/com/fr/van/chart/custom/component/VanChartCustomPlotAxisPane.java

@ -7,6 +7,7 @@ import com.fr.plugin.chart.attr.plot.VanChartPlot;
import com.fr.plugin.chart.attr.plot.VanChartRectanglePlot;
import com.fr.plugin.chart.base.AttrSeriesStackAndAxis;
import com.fr.plugin.chart.custom.VanChartCustomPlot;
import com.fr.plugin.chart.vanchart.VanChart;
import com.fr.van.chart.custom.CustomPlotDesignerPaneFactory;
import com.fr.van.chart.designer.style.VanChartStylePane;
import com.fr.van.chart.designer.style.axis.VanChartAxisPane;
@ -52,4 +53,8 @@ public class VanChartCustomPlotAxisPane extends VanChartAxisPane {
}
}
}
@Override
protected void updateBuryingPoint(VanChart chart) {
}
}

4
designer-chart/src/main/java/com/fr/van/chart/custom/style/VanChartCustomAxisPane.java

@ -1,8 +1,10 @@
package com.fr.van.chart.custom.style;
import com.fr.chart.chartattr.Chart;
import com.fr.chartx.config.info.constant.ConfigType;
import com.fr.design.dialog.BasicScrollPane;
import com.fr.design.mainframe.chart.PaneTitleConstants;
import com.fr.design.mainframe.chart.info.ChartInfoCollector;
import com.fr.plugin.chart.custom.VanChartCustomPlot;
import com.fr.plugin.chart.vanchart.VanChart;
import com.fr.van.chart.designer.style.VanChartStylePane;
@ -63,6 +65,8 @@ public class VanChartCustomAxisPane extends BasicScrollPane<Chart> {
}
VanChartCustomPlot plot = (VanChartCustomPlot) chart.getPlot();
axisPane.updateBean(plot);
//坐标轴埋点
ChartInfoCollector.getInstance().updateChartConfig(chart, ConfigType.AXIS, chart.getBuryingPointAxisConfig());
}
@Override

4
designer-chart/src/main/java/com/fr/van/chart/custom/style/VanChartCustomLabelPane.java

@ -2,8 +2,10 @@ package com.fr.van.chart.custom.style;
import com.fr.chart.chartattr.Chart;
import com.fr.chartx.config.info.constant.ConfigType;
import com.fr.design.dialog.BasicScrollPane;
import com.fr.design.mainframe.chart.PaneTitleConstants;
import com.fr.design.mainframe.chart.info.ChartInfoCollector;
import com.fr.plugin.chart.custom.VanChartCustomPlot;
import com.fr.van.chart.designer.style.VanChartStylePane;
@ -63,6 +65,8 @@ public class VanChartCustomLabelPane extends BasicScrollPane<Chart> {
}
labelPane.updateBean((VanChartCustomPlot)chart.getPlot());
//标签埋点
ChartInfoCollector.getInstance().updateChartConfig(chart, ConfigType.LABEL, chart.getBuryingPointLabelConfig());
}
@Override

4
designer-chart/src/main/java/com/fr/van/chart/custom/style/VanChartCustomSeriesPane.java

@ -1,10 +1,12 @@
package com.fr.van.chart.custom.style;
import com.fr.chart.chartattr.Chart;
import com.fr.chartx.config.info.constant.ConfigType;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.chart.gui.ChartStylePane;
import com.fr.design.mainframe.chart.gui.style.series.ChartSeriesPane;
import com.fr.design.mainframe.chart.info.ChartInfoCollector;
import com.fr.plugin.chart.attr.plot.VanChartPlot;
import com.fr.plugin.chart.custom.VanChartCustomPlot;
import com.fr.van.chart.designer.component.VanChartBeautyPane;
@ -112,6 +114,8 @@ public class VanChartCustomSeriesPane extends ChartSeriesPane {
if (seriesPane != null){
plotSeriesPane.updateBean(plot);
}
//系列埋点
ChartInfoCollector.getInstance().updateChartConfig(chart, ConfigType.SERIES, chart.getBuryingPointSeriesConfig());
}
/**

6
designer-chart/src/main/java/com/fr/van/chart/custom/style/VanChartCustomTooltipPane.java

@ -1,8 +1,9 @@
package com.fr.van.chart.custom.style;
import com.fr.chart.chartattr.Chart;
import com.fr.chartx.config.info.constant.ConfigType;
import com.fr.design.dialog.BasicScrollPane;
import com.fr.design.mainframe.chart.info.ChartInfoCollector;
import com.fr.plugin.chart.custom.VanChartCustomPlot;
import com.fr.van.chart.designer.style.VanChartStylePane;
@ -63,7 +64,8 @@ public class VanChartCustomTooltipPane extends BasicScrollPane<Chart> {
}
tooltipPane.updateBean((VanChartCustomPlot)chart.getPlot());
//提示埋点
ChartInfoCollector.getInstance().updateChartConfig(chart, ConfigType.TOOLTIP, chart.getBuryingPointTooltipConfig());
}
@Override

4
designer-chart/src/main/java/com/fr/van/chart/designer/component/LineTypeComboBox.java

@ -59,10 +59,10 @@ public class LineTypeComboBox extends UIComboBox {
FontMetrics fm = GraphHelper.getFontMetrics(rfont);
GraphHelper.drawString(g2d, Toolkit.i18nText("Fine-Design_Report_None"), 4, (d.height - fm.getHeight()) / 2 + fm.getAscent());
break;
case NORMAL:
case SOLID:
GraphHelper.drawLine(g2d, 4, d.height / 2, d.width - 8, d.height / 2);
break;
case DASH:
case DASHED:
GraphHelper.drawLine(g2d, 4, d.height / 2, d.width - 8, d.height / 2, Constants.LINE_DASH);
break;
default:

35
designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartFillStylePane.java

@ -13,13 +13,17 @@ import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout;
import com.fr.design.mainframe.DesignerBean;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.chart.gui.style.ChartColorAdjustPane;
import com.fr.design.style.background.gradient.FixedGradientBar;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.stable.StringUtils;
import com.fr.van.chart.designer.TableLayout4VanChartHelper;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import java.util.List;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Color;
@ -31,8 +35,9 @@ import java.awt.event.ActionListener;
/**
* Created by mengao on 2017/8/17.
*/
public class VanChartFillStylePane extends BasicBeanPane<AttrFillStyle> {
public class VanChartFillStylePane extends BasicBeanPane<AttrFillStyle> implements DesignerBean {
public static final String name = "vanChartFillStyle";
protected ColorSchemeComboBox styleSelectBox;
protected JPanel customPane;
@ -71,6 +76,8 @@ public class VanChartFillStylePane extends BasicBeanPane<AttrFillStyle> {
customPane.add(changeColorSetPane, BorderLayout.CENTER);
initListener();
initLayout();
DesignerContext.setDesignerBean(name, this);
}
private void initListener() {
@ -231,7 +238,31 @@ public class VanChartFillStylePane extends BasicBeanPane<AttrFillStyle> {
def.setFillStyleName(Utils.objectToString(styleSelectBox.getSelectedItem()));
return def;
} else {
return updateDefaultColor();
return updateModifyColor();
}
}
private AttrFillStyle updateModifyColor() {
AttrFillStyle condition = new AttrFillStyle();
condition.clearColors();
ColorSchemeComboBox.ColorInfo selectColorInfo = styleSelectBox.getSelectColorInfo();
boolean isGradient = selectColorInfo.isGradient();
List<Color> colors = selectColorInfo.getColors();
condition.setColorList(colors);
condition.setCustomFillStyle(true);
condition.setColorStyle(isGradient ? ChartConstants.COLOR_GRADIENT : ChartConstants.COLOR_ACC);
return condition;
}
/**
* 刷新组件对象
*/
public void refreshBeanElement() {
AttrFillStyle attrFillStyle = updateBean();
styleSelectBox.refresh();
populateBean(attrFillStyle);
GUICoreUtils.repaint(this);
}
}

80
designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartLineTypePane.java

@ -2,7 +2,6 @@ package com.fr.van.chart.designer.component;
import com.fr.design.dialog.BasicPane;
import com.fr.design.gui.ibutton.UIButtonGroup;
import com.fr.design.gui.icombobox.LineComboBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.ispinner.UISpinner;
import com.fr.design.i18n.Toolkit;
@ -13,8 +12,6 @@ import com.fr.general.ComparatorUtils;
import com.fr.plugin.chart.base.VanChartAttrLine;
import com.fr.plugin.chart.type.LineStyle;
import com.fr.plugin.chart.type.LineType;
import com.fr.stable.Constants;
import com.fr.stable.CoreConstants;
import com.fr.van.chart.designer.TableLayout4VanChartHelper;
import javax.swing.JPanel;
@ -30,26 +27,28 @@ import java.util.Arrays;
public class VanChartLineTypePane extends BasicPane {
private static final long serialVersionUID = -6581862503009962973L;
//线型支持虚线 恢复用注释。下面1行删除。
protected LineComboBox lineWidth;//线型
private static final double LINE_WIDTH_MIN_VALUE = 0.5;
private static final double LINE_WIDTH_DIERTA_VALUE = 0.5;
private static final double LINE_WIDTH_DEFAULT_VALUE = 2;
private LineTypeComboBox lineTypeComboBox;//线型
private UISpinner lineWidthSpinner;//线宽
protected UIButtonGroup<LineStyle> lineStyle;//形态
private UIButtonGroup<LineStyle> lineStyle;//形态
private UIButtonGroup nullValueBreak;//空值断开
private JPanel lineWidthPane;
private JPanel lineStylePane;
public VanChartLineTypePane() {
//线型支持虚线 恢复用注释。下面1行删除。
lineWidth = new LineComboBox(CoreConstants.STRIKE_LINE_STYLE_ARRAY_4_CHART);
JPanel typeAndWidthPane = createTypeAndWidthPane();
createLineStyle();
lineStyle = createLineStyle();
nullValueBreak = new UIButtonGroup(new String[]{Toolkit.i18nText("Fine-Design_Chart_Open"), Toolkit.i18nText("Fine-Design_Chart_Close")});
nullValueBreak = new UIButtonGroup(new String[]{
Toolkit.i18nText("Fine-Design_Chart_Open"),
Toolkit.i18nText("Fine-Design_Chart_Close")});
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
@ -67,16 +66,15 @@ public class VanChartLineTypePane extends BasicPane {
lineStylePane = TableLayout4VanChartHelper.createGapTableLayoutPane(components, row, col);
this.setLayout(new BorderLayout(0, 6));
//线型支持虚线 恢复用注释。取消注释。
//this.add(typeAndWidthPane, BorderLayout.NORTH);
this.add(typeAndWidthPane, BorderLayout.NORTH);
this.add(lineStylePane, BorderLayout.CENTER);
}
private JPanel createTypeAndWidthPane() {
lineTypeComboBox = new LineTypeComboBox(new LineType[]{LineType.NONE, LineType.NORMAL, LineType.DASH});
lineTypeComboBox = createLineType();
lineWidthSpinner = new UISpinner(0.5, Integer.MAX_VALUE, 0.5, 2);
lineWidthSpinner = new UISpinner(LINE_WIDTH_MIN_VALUE, Integer.MAX_VALUE, LINE_WIDTH_DIERTA_VALUE, LINE_WIDTH_DEFAULT_VALUE);
lineTypeComboBox.addActionListener(new ActionListener() {
@Override
@ -87,6 +85,7 @@ public class VanChartLineTypePane extends BasicPane {
});
Component[][] lineTypeComps = new Component[][]{
new Component[]{null, null},
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Line_Style")), lineTypeComboBox}
};
Component[][] lineWidthComps = new Component[][]{
@ -96,10 +95,10 @@ public class VanChartLineTypePane extends BasicPane {
};
double p = TableLayout.PREFERRED, f = TableLayout.FILL, e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH;
double[] row = {p}, col = {f, e};
double[] col = {f, e};
JPanel lineTypePane = TableLayout4VanChartHelper.createGapTableLayoutPane(lineTypeComps, row, col);
lineWidthPane = TableLayout4VanChartHelper.createGapTableLayoutPane(lineWidthComps, row, col);
JPanel lineTypePane = TableLayout4VanChartHelper.createGapTableLayoutPane(lineTypeComps, new double[]{p, p}, col);
lineWidthPane = TableLayout4VanChartHelper.createGapTableLayoutPane(lineWidthComps, new double[]{p}, col);
JPanel contentPane = new JPanel(new BorderLayout(0, 6));
@ -109,20 +108,21 @@ public class VanChartLineTypePane extends BasicPane {
return contentPane;
}
protected void createLineStyle() {
String[] textArray = new String[]{Toolkit.i18nText("Fine-Design_Chart_Normal_Line"),
Toolkit.i18nText("Fine-Design_Chart_StepLine"), Toolkit.i18nText("Fine-Design_Chart_CurveLine")};
lineStyle = new UIButtonGroup<LineStyle>(textArray, LineStyle.values());
protected LineTypeComboBox createLineType() {
return new LineTypeComboBox(new LineType[]{LineType.NONE, LineType.SOLID, LineType.DASHED});
}
protected UIButtonGroup<LineStyle> createLineStyle() {
String[] textArray = new String[]{
Toolkit.i18nText("Fine-Design_Chart_Normal_Line"),
Toolkit.i18nText("Fine-Design_Chart_StepLine"),
Toolkit.i18nText("Fine-Design_Chart_CurveLine")};
return new UIButtonGroup<>(textArray, LineStyle.values());
}
protected Component[][] createContentComponent(Component[] lineStyleComponent, Component[] nullValueBreakComponent) {
return new Component[][]{
//线型支持虚线 恢复用注释。下面5行删除。
new Component[]{null, null},
new Component[]{
FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Chart_Line_Style")),
UIComponentUtils.wrapWithBorderLayoutPane(lineWidth)
},
lineStyleComponent,
nullValueBreakComponent
};
@ -141,16 +141,10 @@ public class VanChartLineTypePane extends BasicPane {
}
public void checkLarge(boolean large) {
//线型支持虚线 恢复用注释。下面4行删除。
if (large) {
lineWidth.setSelectedLineStyle(Constants.LINE_NONE);
}
lineWidth.setEnabled(!large);
//线型支持虚线 恢复用注释。取消注释。
// if (large) {
// lineTypeComboBox.setSelectedItem(LineType.NONE);
// }
// lineTypeComboBox.setEnabled(!large);
lineTypeComboBox.setSelectedItem(LineType.NONE);
}
lineTypeComboBox.setEnabled(!large);
lineStyle.setEnabled(!large);
}
@ -162,11 +156,8 @@ public class VanChartLineTypePane extends BasicPane {
if (line == null) {
line = initVanChartAttrLine();
}
//线型支持虚线 恢复用注释。下面1行删除。
lineWidth.setSelectedLineStyle(line.getLineWidth());
//线型支持虚线 恢复用注释。取消注释。
// lineTypeComboBox.setSelectedItem(line.getLineType());
// lineWidthSpinner.setValue(line.getLineWidth());
lineTypeComboBox.setSelectedItem(line.getLineType());
lineWidthSpinner.setValue(line.getLineWidth());
lineStyle.setSelectedItem(line.getLineStyle());
nullValueBreak.setSelectedIndex(line.isNullValueBreak() ? 0 : 1);
}
@ -177,11 +168,8 @@ public class VanChartLineTypePane extends BasicPane {
public VanChartAttrLine update() {
VanChartAttrLine line = new VanChartAttrLine();
//线型支持虚线 恢复用注释。下面1行删除。
line.setLineWidth(lineWidth.getSelectedLineStyle());
//线型支持虚线 恢复用注释。取消注释。
// line.setLineType((LineType) lineTypeComboBox.getSelectedItem());
// line.setLineWidth(lineWidthSpinner.getValue());
line.setLineType((LineType) lineTypeComboBox.getSelectedItem());
line.setLineWidth(lineWidthSpinner.getValue());
line.setLineStyle(lineStyle.getSelectedItem());
line.setNullValueBreak(nullValueBreak.getSelectedIndex() == 0);
return line;

11
designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartLineTypePaneWithoutDashed.java

@ -0,0 +1,11 @@
package com.fr.van.chart.designer.component;
import com.fr.plugin.chart.type.LineType;
public class VanChartLineTypePaneWithoutDashed extends VanChartLineTypePane{
@Override
protected LineTypeComboBox createLineType() {
return new LineTypeComboBox(new LineType[]{LineType.NONE, LineType.SOLID});
}
}

8
designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartLineWidthPane.java

@ -1,22 +1,16 @@
package com.fr.van.chart.designer.component;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
import java.awt.Component;
/**
* 线型+线宽+空值断开
*/
public class VanChartLineWidthPane extends VanChartLineTypePane {
public class VanChartLineWidthPane extends VanChartLineTypePaneWithoutDashed {
private static final long serialVersionUID = 4537158946119294689L;
@Override
protected Component[][] createContentComponent(Component[] lineStyleComponent, Component[] nullValueBreakComponent) {
return new Component[][]{
//线型支持虚线 恢复用注释。下面2行删除。
new Component[]{null, null},
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Line_Style")), lineWidth},
nullValueBreakComponent
};
}

15
designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartMarkerPane.java

@ -1,6 +1,7 @@
package com.fr.van.chart.designer.component;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.i18n.Toolkit;
import com.fr.design.dialog.BasicPane;
import com.fr.design.gui.ibutton.UIButtonGroup;
import com.fr.plugin.chart.base.VanChartAttrMarker;
@ -31,7 +32,7 @@ public class VanChartMarkerPane extends BasicPane {
public VanChartMarkerPane() {
this.setLayout(new BorderLayout(0, 4));
String[] array = new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Rule"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Custom")};
String[] array = new String[]{Toolkit.i18nText("Fine-Design_Chart_Rule"), Toolkit.i18nText("Fine-Design_Chart_Custom")};
commonORCustom = new UIButtonGroup<String>(array, array);
commonORCustom.addChangeListener(new ChangeListener() {
@ -56,8 +57,8 @@ public class VanChartMarkerPane extends BasicPane {
}
}
};
centerPane.add(commonMarkerPane, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Rule"));
centerPane.add(imageMarkerPane, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Custom"));
centerPane.add(commonMarkerPane, Toolkit.i18nText("Fine-Design_Chart_Rule"));
centerPane.add(imageMarkerPane, Toolkit.i18nText("Fine-Design_Chart_Custom"));
layoutComponents();
}
@ -75,8 +76,10 @@ public class VanChartMarkerPane extends BasicPane {
}
protected VanChartCommonMarkerPane createCommonMarkerPane() {
return new VanChartCommonMarkerPane(){
protected double[] getcolumnSize () {
protected double[] getColumnSize() {
double s = TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH;
double d = TableLayout4VanChartHelper.DESCRIPTION_AREA_WIDTH;
return new double[] {d, s};
@ -85,7 +88,7 @@ public class VanChartMarkerPane extends BasicPane {
}
protected void layoutComponents() {
this.add(TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Point_Style"), commonORCustom), BorderLayout.NORTH);
this.add(TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Chart_Point_Style"), commonORCustom), BorderLayout.NORTH);
this.add(centerPane, BorderLayout.CENTER);
}
@ -98,7 +101,7 @@ public class VanChartMarkerPane extends BasicPane {
}
protected String title4PopupWindow(){
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Marker");
return Toolkit.i18nText("Fine-Design_Chart_Marker");
}
public void populate(VanChartAttrMarker marker) {

88
designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartTrendLinePane.java

@ -4,7 +4,6 @@ import com.fr.chart.base.AttrColor;
import com.fr.chart.base.AttrLineStyle;
import com.fr.chart.base.LineStyleInfo;
import com.fr.design.dialog.BasicPane;
import com.fr.design.gui.icombobox.LineComboBox;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.ispinner.UISpinner;
@ -17,7 +16,6 @@ import com.fr.design.utils.gui.UIComponentUtils;
import com.fr.design.widget.FRWidgetFactory;
import com.fr.plugin.chart.base.TrendLineType;
import com.fr.plugin.chart.base.VanChartAttrTrendLine;
import com.fr.plugin.chart.base.VanChartConstants;
import com.fr.plugin.chart.type.LineType;
import com.fr.van.chart.designer.TableLayout4VanChartHelper;
@ -34,14 +32,15 @@ import java.awt.event.ActionListener;
public class VanChartTrendLinePane extends BasicPane{
private static final TrendLineType[] TYPES = new TrendLineType[] {TrendLineType.EXP, TrendLineType.LINE, TrendLineType.LOG, TrendLineType.POLY};
private static final int PREFERRED_WIDTH = 100;
private static final double LINE_WIDTH_MIN_VALUE = 0.5;
private static final double LINE_WIDTH_DIERTA_VALUE = 0.5;
private static final double LINE_WIDTH_DEFAULT_VALUE = 1;
private UITextField trendLineName;
private ColorSelectBox trendLineColor;
//线型支持虚线 恢复用注释。下面1行删除。
private LineComboBox trendLineStyle;//线型
//线型支持虚线 恢复用注释。取消注释。
// private LineTypeComboBox trendLineStyle;//线型
// private UISpinner lineWidthSpinner;//线宽
private LineTypeComboBox trendLineStyle;//线型
private UISpinner lineWidthSpinner;//线宽
private UIComboBox trendLineType;//趋势线函数类型
private UISpinner prePeriod;
@ -58,15 +57,11 @@ public class VanChartTrendLinePane extends BasicPane{
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH;
double[] row = {p, p, p, p, p, p};
double[] col = {f, e};
trendLineName = new UITextField();
trendLineColor = new ColorSelectBox(100);
//线型支持虚线 恢复用注释。下面1行删除。
trendLineStyle = new LineComboBox(VanChartConstants.ALERT_LINE_STYLE);
//线型支持虚线 恢复用注释。取消注释。
// trendLineStyle = new LineTypeComboBox(new LineType[]{LineType.NONE, LineType.NORMAL, LineType.DASH});
// lineWidthSpinner = new UISpinner(0.5, Integer.MAX_VALUE, 0.5, 2);
trendLineColor = new ColorSelectBox(PREFERRED_WIDTH);
trendLineStyle = new LineTypeComboBox(new LineType[]{LineType.NONE, LineType.SOLID, LineType.DASHED});
lineWidthSpinner = new UISpinner(LINE_WIDTH_MIN_VALUE, Integer.MAX_VALUE, LINE_WIDTH_DIERTA_VALUE, LINE_WIDTH_DEFAULT_VALUE);
trendLineType = new UIComboBox(TYPES);
prePeriod = new UISpinner(0, Integer.MAX_VALUE, 1, 0);
afterPeriod = new UISpinner(0, Integer.MAX_VALUE, 1, 0);
@ -82,42 +77,26 @@ public class VanChartTrendLinePane extends BasicPane{
UILabel label = new UILabel(Toolkit.i18nText("Fine-Design_Chart_Period"));
label.setVerticalAlignment(SwingConstants.TOP);
//线型支持虚线 恢复用注释。开始删除。
Component[][] components = new Component[][]{
new Component[]{null, null},
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Name")), trendLineName},
new Component[]{
FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Chart_Line_Style")),
UIComponentUtils.wrapWithBorderLayoutPane(trendLineStyle)
},
}
};
Component[][] componentsMayHide = new Component[][]{
new Component[]{
FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Chart_Line_Width")),
UIComponentUtils.wrapWithBorderLayoutPane(lineWidthSpinner)},
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Color")), trendLineColor},
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Type")), trendLineType},
new Component[]{label, periodPane}
};
//线型支持虚线 恢复用注释。结束删除。
//线型支持虚线 恢复用注释。取消注释。
// Component[][] components = new Component[][]{
// new Component[]{null, null},
// new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Name")), trendLineName},
// new Component[]{
// FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Chart_Line_Style")),
// UIComponentUtils.wrapWithBorderLayoutPane(trendLineStyle)
// }
// };
//
// Component[][] componentsMayHide = new Component[][]{
// new Component[]{
// FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Chart_Line_Width")),
// UIComponentUtils.wrapWithBorderLayoutPane(lineWidthSpinner)},
// new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Color")), trendLineColor},
// new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Type")), trendLineType},
// new Component[]{label, periodPane}
// };
// trendLineHidePane = TableLayout4VanChartHelper.createGapTableLayoutPane(componentsMayHide, row, col);
JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(components, row, col);
JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(components, new double[]{p,p,p}, col);
trendLineHidePane = TableLayout4VanChartHelper.createGapTableLayoutPane(componentsMayHide, new double[]{p,p,p,p}, col);
trendLineStyle.addActionListener(new ActionListener() {
@Override
@ -129,8 +108,7 @@ public class VanChartTrendLinePane extends BasicPane{
checkHidePaneVisible();
this.add(panel, BorderLayout.CENTER);
//线型支持虚线 恢复用注释。取消注释。
//this.add(trendLineHidePane, BorderLayout.SOUTH);
this.add(trendLineHidePane, BorderLayout.SOUTH);
}
protected String title4PopupWindow(){
@ -142,12 +120,14 @@ public class VanChartTrendLinePane extends BasicPane{
if(trendLine != null){
trendLineName.setText(trendLine.getTrendLineName());
LineStyleInfo lineStyleInfo = trendLine.getLineStyleInfo();
AttrLineStyle attrLineStyle = lineStyleInfo.getAttrLineStyle();
if (attrLineStyle != null) {
trendLineStyle.setSelectedItem(attrLineStyle.getLineType());
lineWidthSpinner.setValue(attrLineStyle.getLineWidth());
}
trendLineColor.setSelectObject(lineStyleInfo.getAttrLineColor().getSeriesColor());
//线型支持虚线 恢复用注释。下面1行删除。
trendLineStyle.setSelectedLineStyle(lineStyleInfo.getAttrLineStyle().getLineStyle());
//线型支持虚线 恢复用注释。取消注释。
// trendLineStyle.setSelectedItem(lineStyleInfo.getAttrLineStyle().getLineType());
// lineWidthSpinner.setValue(lineStyleInfo.getAttrLineStyle().getLineWidth());
trendLineType.setSelectedItem(trendLine.getTrendLineType());
prePeriod.setValue(trendLine.getPrePeriod());
afterPeriod.setValue(trendLine.getAfterPeriod());
@ -159,11 +139,13 @@ public class VanChartTrendLinePane extends BasicPane{
trendLine.setTrendLineName(trendLineName.getText());
LineStyleInfo lineStyleInfo = trendLine.getLineStyleInfo();
//线型支持虚线 恢复用注释。下面1行删除。
lineStyleInfo.setAttrLineStyle(new AttrLineStyle(trendLineStyle.getSelectedLineStyle()));
//线型支持虚线 恢复用注释。取消注释。
// lineStyleInfo.getAttrLineStyle().setLineWidth(lineWidthSpinner.getValue());
// lineStyleInfo.getAttrLineStyle().setLineType((LineType) trendLineStyle.getSelectedItem());
AttrLineStyle attrLineStyle = lineStyleInfo.getAttrLineStyle();
if (attrLineStyle != null) {
attrLineStyle.setLineWidth(lineWidthSpinner.getValue());
attrLineStyle.setLineType((LineType) trendLineStyle.getSelectedItem());
}
lineStyleInfo.setAttrLineColor(new AttrColor(trendLineColor.getSelectObject()));
trendLine.setTrendLineType((TrendLineType) trendLineType.getSelectedItem());

156
designer-chart/src/main/java/com/fr/van/chart/designer/component/marker/VanChartCommonMarkerPane.java

@ -5,26 +5,33 @@ import com.fr.design.beans.BasicBeanPane;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.ispinner.UISpinner;
import com.fr.design.gui.xcombox.MarkerComboBox;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.plugin.chart.base.VanChartAttrMarker;
import com.fr.plugin.chart.marker.type.MarkerType;
import com.fr.van.chart.designer.TableLayout4VanChartHelper;
import com.fr.van.chart.designer.component.background.VanChartMarkerBackgroundPane;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
/**
* Created by Mitisky on 16/5/19.
* 通用标记点,标记点类型/颜色/半径
*/
public class VanChartCommonMarkerPane extends BasicBeanPane<VanChartAttrMarker> {
private MarkerComboBox markerPane;
private MarkerComboBox markerTypeComboBox;
private VanChartMarkerBackgroundPane markerFillColor;
private UISpinner radius;
private JPanel markerTypePane;
private JPanel markerConfigPane;
private static final MarkerType[] NORMAL_TYPES = {
MarkerType.MARKER_NULL,
MarkerType.MARKER_CIRCLE,
MarkerType.MARKER_SQUARE,
MarkerType.MARKER_DIAMOND,
@ -34,114 +41,106 @@ public class VanChartCommonMarkerPane extends BasicBeanPane<VanChartAttrMarker>
MarkerType.MARKER_DIAMOND_HOLLOW,
MarkerType.MARKER_TRIANGLE_HOLLOW
};
private static Marker[] normalMarkers = null;
protected static Marker[] getNormalMarkers() {
if(normalMarkers == null){
normalMarkers = new Marker[NORMAL_TYPES.length];
int i = 0;
for(MarkerType markerType : NORMAL_TYPES){
normalMarkers[i++] = Marker.createMarker(markerType);
}
}
return normalMarkers;
}
//没有无这个选项
private static final MarkerType[] MAP_TYPES = {
MarkerType.MARKER_CIRCLE,
MarkerType.MARKER_SQUARE,
MarkerType.MARKER_DIAMOND,
MarkerType.MARKER_TRIANGLE,
MarkerType.MARKER_CIRCLE_HOLLOW,
MarkerType.MARKER_SQUARE_HOLLOW,
MarkerType.MARKER_DIAMOND_HOLLOW,
MarkerType.MARKER_TRIANGLE_HOLLOW
};
private static Marker[] mapMarkers = null;
protected static Marker[] getMapScatterMarkers() {
if(mapMarkers == null){
mapMarkers = new Marker[MAP_TYPES.length];
int i = 0;
for(MarkerType markerType : MAP_TYPES){
mapMarkers[i++] = Marker.createMarker(markerType);
}
}
return mapMarkers;
}
protected Marker[] getNormalMarkersWithCustom(MarkerType[] types) {
MarkerType[] customTypes = types == null ? new MarkerType[0] : types;
Marker[] result = new Marker[customTypes.length + NORMAL_TYPES.length];
//甘特图的菱形是实心的,之前写的空心。
//兼容:模板属性不做兼容。只是之前空心做界面兼容。前台展现实心空心一样的效果,所以不用做什么
private static final MarkerType[] GANTT_TYPES = {
MarkerType.MARKER_TRIANGLE,
MarkerType.MARKER_DIAMOND,
MarkerType.MARKER_STAR
};
private static Marker[] ganttMarkers = null;
protected static Marker[] getGanttMarkers() {
if(ganttMarkers == null){
ganttMarkers = new Marker[GANTT_TYPES.length];
int i = 0;
for(MarkerType markerType : GANTT_TYPES){
ganttMarkers[i++] = Marker.createMarker(markerType);
for (MarkerType markerType : customTypes) {
result[i++] = Marker.createMarker(markerType);
}
for (MarkerType markerType : NORMAL_TYPES) {
result[i++] = Marker.createMarker(markerType);
}
return ganttMarkers;
return result;
}
public MarkerComboBox getMarkerTypeComboBox() {
return markerTypeComboBox;
}
protected MarkerComboBox getMarkerPane(){
return markerPane;
public UISpinner getRadius() {
return radius;
}
public VanChartCommonMarkerPane() {
markerPane = new MarkerComboBox(getMarkers());
markerTypeComboBox = new MarkerComboBox(getMarkers());
markerFillColor = new VanChartMarkerBackgroundPane() {
protected JPanel initContentPanel() {
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double e = getColumnSize()[1];
double[] columnSize = {f, e};
double[] rowSize = {p, p, p};
return TableLayoutHelper.createTableLayoutPane(getPaneComponents(), rowSize, columnSize);
}
protected Component[][] getPaneComponents() {
return new Component[][]{
new Component[]{typeComboBox, null},
new Component[]{centerPane, null},
new Component[]{null, null},
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Fill_Color")), typeComboBox},
new Component[]{null, centerPane},
};
}
};
radius = new UISpinner(0, 100, 0.5, 0);
double p = TableLayout.PREFERRED;
double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH;
double d = TableLayout4VanChartHelper.DESCRIPTION_AREA_WIDTH;
double[] row = {p, p, p};
Component[][] components = getUseComponent();
JPanel jPanel = TableLayout4VanChartHelper.createGapTableLayoutPane(components, row, getcolumnSize());
markerTypePane = TableLayout4VanChartHelper.createGapTableLayoutPane(getMarkerTypeComponent(), new double[]{p}, getColumnSize());
markerConfigPane = TableLayout4VanChartHelper.createGapTableLayoutPane(getMarkerConfigComponent(), new double[]{p, p}, getColumnSize());
this.add(jPanel);
markerTypeComboBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
checkMarkType();
}
});
protected double[] getcolumnSize () {
double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH;
double d = TableLayout4VanChartHelper.DESCRIPTION_AREA_WIDTH;
return new double[] {d, e};
}
JPanel contentPane = new JPanel(new BorderLayout(0, 6));
protected Marker[] getMarkers() {
return getNormalMarkers();
contentPane.add(markerTypePane, BorderLayout.CENTER);
contentPane.add(markerConfigPane, BorderLayout.SOUTH);
this.add(contentPane);
}
protected Component[][] getUseComponent() {
protected Component[][] getMarkerTypeComponent() {
return new Component[][]{
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Type")), markerPane},
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Fill_Color")), markerFillColor},
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Radius")), radius},
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Type")), markerTypeComboBox}
};
}
protected Component[][] getUseComponentWithOutFillColor() {
protected Component[][] getMarkerConfigComponent() {
return new Component[][]{
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Type")), markerPane},
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Radius")), radius},
new Component[]{markerFillColor, null},
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Radius")), radius}
};
}
private void checkMarkType() {
if (markerConfigPane != null && markerTypeComboBox != null) {
MarkerType type = MarkerType.parse(markerTypeComboBox.getSelectedMarkder().getMarkerType());
markerConfigPane.setVisible(type != MarkerType.MARKER_NULL);
}
}
protected double[] getColumnSize() {
double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH;
double d = TableLayout4VanChartHelper.DESCRIPTION_AREA_WIDTH;
return new double[]{d, e};
}
protected Marker[] getMarkers() {
return getNormalMarkersWithCustom(new MarkerType[]{MarkerType.MARKER_NULL});
}
/**
* title应该是一个属性不只是对话框的标题时用到与其他组件结合时也会用得到
@ -162,9 +161,11 @@ public class VanChartCommonMarkerPane extends BasicBeanPane<VanChartAttrMarker>
marker = new VanChartAttrMarker();
marker.setCommon(true);
}
markerPane.setSelectedMarker(Marker.createMarker(populateMarkType(marker)));
markerTypeComboBox.setSelectedMarker(Marker.createMarker(populateMarkType(marker)));
populateColor(marker);
radius.setValue(marker.getRadius());
checkMarkType();
}
protected void populateColor(VanChartAttrMarker marker) {
@ -174,6 +175,7 @@ public class VanChartCommonMarkerPane extends BasicBeanPane<VanChartAttrMarker>
protected MarkerType populateMarkType(VanChartAttrMarker marker) {
return marker.getMarkerType();
}
/**
* Update.
*/
@ -188,7 +190,7 @@ public class VanChartCommonMarkerPane extends BasicBeanPane<VanChartAttrMarker>
marker.setCommon(true);
updateColor(marker);
marker.setRadius(radius.getValue());
marker.setMarkerType(MarkerType.parse(markerPane.getSelectedMarkder().getMarkerType()));
marker.setMarkerType(MarkerType.parse(markerTypeComboBox.getSelectedMarkder().getMarkerType()));
}
protected void updateColor(VanChartAttrMarker marker) {

16
designer-chart/src/main/java/com/fr/van/chart/designer/other/condition/item/VanChartLineTypeConditionPaneWithoutDashed.java

@ -0,0 +1,16 @@
package com.fr.van.chart.designer.other.condition.item;
import com.fr.design.condition.ConditionAttributesPane;
import com.fr.van.chart.designer.component.VanChartLineTypePane;
import com.fr.van.chart.designer.component.VanChartLineTypePaneWithoutDashed;
public class VanChartLineTypeConditionPaneWithoutDashed extends VanChartLineTypeConditionPane {
public VanChartLineTypeConditionPaneWithoutDashed(ConditionAttributesPane conditionAttributesPane) {
super(conditionAttributesPane);
}
protected VanChartLineTypePane createLinePane() {
return new VanChartLineTypePaneWithoutDashed();
}
}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save