Browse Source

Merge remote-tracking branch 'origin/feature/x' into feature/x

feature/x
xiqiu 3 years ago
parent
commit
ab7de686bd
  1. 1
      build.gradle
  2. 15
      designer-base/src/main/java/com/fr/design/DesignerEnvManager.java
  3. 2
      designer-base/src/main/java/com/fr/design/actions/community/BugAction.java
  4. 2
      designer-base/src/main/java/com/fr/design/actions/community/NeedAction.java
  5. 5
      designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java
  6. 61
      designer-base/src/main/java/com/fr/design/cell/CellRectangleStylePreviewPane.java
  7. 45
      designer-base/src/main/java/com/fr/design/cell/CellStylePreviewPane.java
  8. 112
      designer-base/src/main/java/com/fr/design/data/datapane/ChoosePane.java
  9. 2
      designer-base/src/main/java/com/fr/design/data/datapane/ChoosePaneSupportFormula.java
  10. 7
      designer-base/src/main/java/com/fr/design/event/ComponentChangeListener.java
  11. 6
      designer-base/src/main/java/com/fr/design/event/ComponentChangeObserver.java
  12. 29
      designer-base/src/main/java/com/fr/design/extra/PluginInstalledPane.java
  13. 12
      designer-base/src/main/java/com/fr/design/extra/PluginOperateUtils.java
  14. 11
      designer-base/src/main/java/com/fr/design/gui/frpane/AbstractAttrNoScrollPane.java
  15. 6
      designer-base/src/main/java/com/fr/design/gui/icheckbox/UICheckBox.java
  16. 4
      designer-base/src/main/java/com/fr/design/gui/icombobox/FRTreeComboBox.java
  17. 200
      designer-base/src/main/java/com/fr/design/gui/icombobox/SearchFRTreeComboBox.java
  18. 77
      designer-base/src/main/java/com/fr/design/gui/icombobox/SearchPreTaskTreeComboBox.java
  19. 3
      designer-base/src/main/java/com/fr/design/gui/style/BorderPane.java
  20. 235
      designer-base/src/main/java/com/fr/design/gui/style/TextFormatPane.java
  21. 6
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java
  22. 46
      designer-base/src/main/java/com/fr/design/mainframe/DesignerUIModeConfig.java
  23. 4
      designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java
  24. 2
      designer-base/src/main/java/com/fr/design/mainframe/PX.java
  25. 2
      designer-base/src/main/java/com/fr/design/mainframe/PXReportLengthUNIT.java
  26. 20
      designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/ColorBackgroundQuickPane.java
  27. 42
      designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogAppender.java
  28. 22
      designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogHandler.java
  29. 41
      designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogger.java
  30. 27
      designer-base/src/main/java/com/fr/design/mainframe/loghandler/LogEventConverter.java
  31. 45
      designer-base/src/main/java/com/fr/design/mainframe/theme/ThemedCellStyleListPane.java
  32. 22
      designer-base/src/main/java/com/fr/design/mainframe/theme/dialog/TemplateThemeDialog.java
  33. 8
      designer-base/src/main/java/com/fr/design/mainframe/theme/edit/cell/CellStyleEditPane.java
  34. 2
      designer-base/src/main/java/com/fr/design/mainframe/theme/edit/ui/ColorListPane.java
  35. 5
      designer-base/src/main/java/com/fr/design/mainframe/theme/preview/ReportThemePreviewPane.java
  36. 4
      designer-base/src/main/java/com/fr/start/server/FineEmbedServerActivator.java
  37. BIN
      designer-base/src/main/resources/com/fr/design/images/sort/add.png
  38. 19
      designer-base/src/main/resources/com/fr/design/images/sort/asc.svg
  39. 17
      designer-base/src/main/resources/com/fr/design/images/sort/des.svg
  40. BIN
      designer-base/src/main/resources/com/fr/design/images/sort/down_arrow.png
  41. BIN
      designer-base/src/main/resources/com/fr/design/images/sort/left_arrow.png
  42. 41
      designer-base/src/main/resources/com/fr/design/images/sort/nosort.svg
  43. 26
      designer-chart/src/main/java/com/fr/van/chart/config/DefaultStyleConstants.java
  44. 4
      designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartTooltipContentPane.java
  45. 115
      designer-form/src/main/java/com/fr/design/actions/NewFormMobileAttrAction.java
  46. 109
      designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteLayout.java
  47. 100
      designer-form/src/main/java/com/fr/design/designer/creator/XWFitLayout.java
  48. 4
      designer-form/src/main/java/com/fr/design/designer/properties/FRFitLayoutConstraints.java
  49. 109
      designer-form/src/main/java/com/fr/design/fit/JFormType.java
  50. 103
      designer-form/src/main/java/com/fr/design/fit/NewJForm.java
  51. 145
      designer-form/src/main/java/com/fr/design/fit/common/AdaptiveSwitchUtil.java
  52. 15
      designer-form/src/main/java/com/fr/design/fit/common/LayoutTool.java
  53. 100
      designer-form/src/main/java/com/fr/design/fit/common/TemplateTool.java
  54. 26
      designer-form/src/main/java/com/fr/design/fit/toolbar/SwitchAction.java
  55. 137
      designer-form/src/main/java/com/fr/design/mainframe/FormArea.java
  56. 10
      designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java
  57. 3
      designer-form/src/main/java/com/fr/design/mainframe/FormDesignerUI.java
  58. 3
      designer-form/src/main/java/com/fr/design/mainframe/FormSelectionUtils.java
  59. 4
      designer-form/src/main/java/com/fr/design/mainframe/JForm.java
  60. 15
      designer-form/src/main/java/com/fr/design/mainframe/share/action/CreateComponentAction.java
  61. 3
      designer-form/src/main/java/com/fr/design/mainframe/share/select/ComponentTransformerImpl.java
  62. 33
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/base/PlaceholderTextArea.java
  63. 4
      designer-form/src/main/java/com/fr/design/parameter/RootDesignDefinePane.java
  64. 4
      designer-form/src/main/java/com/fr/design/widget/ui/designer/component/WidgetBoundPane.java
  65. 10
      designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/ElementEditorDefinePane.java
  66. 6
      designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRAbsoluteBodyLayoutDefinePane.java
  67. 4
      designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRAbsoluteLayoutDefinePane.java
  68. 8
      designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRFitLayoutDefinePane.java
  69. 11
      designer-form/src/test/java/com/fr/design/fit/FormUIModeConfigTest.java
  70. 1
      designer-form/src/test/java/com/fr/design/fit/PXReportLengthUNITTest.java
  71. 1
      designer-form/src/test/java/com/fr/design/fit/PXTest.java
  72. 2
      designer-realize/src/main/java/com/fr/design/actions/cell/BorderAction.java
  73. 2
      designer-realize/src/main/java/com/fr/design/actions/columnrow/ColumnRowSizingAction.java
  74. 2
      designer-realize/src/main/java/com/fr/design/condition/WHPane.java
  75. 145
      designer-realize/src/main/java/com/fr/design/dscolumn/DSColumnAdvancedPane.java
  76. 70
      designer-realize/src/main/java/com/fr/design/fit/grid/GridHeaderWithBoundMouseHandler.java
  77. 194
      designer-realize/src/main/java/com/fr/design/fit/grid/GridLimitColumnMouseHandler.java
  78. 190
      designer-realize/src/main/java/com/fr/design/fit/grid/GridLimitRowMouseHandler.java
  79. 201
      designer-realize/src/main/java/com/fr/design/fit/grid/NewFormDesignerGridUI.java
  80. 41
      designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePane.java
  81. 2
      designer-realize/src/main/java/com/fr/design/mainframe/app/DesignerAppUtils.java
  82. 109
      designer-realize/src/main/java/com/fr/design/mainframe/cell/AbstractDSCellEditorPane.java
  83. 20
      designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellExpandAttrPane.java
  84. 74
      designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellStylePane.java
  85. 7
      designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/NameStyleListPane.java
  86. 59
      designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/StylePane.java
  87. 47
      designer-realize/src/main/java/com/fr/design/mainframe/errorinfo/ErrorInfoLogAppender.java
  88. 27
      designer-realize/src/main/java/com/fr/design/mainframe/errorinfo/ErrorInfoUploader.java
  89. 1
      designer-realize/src/main/java/com/fr/design/mainframe/form/FormElementCaseDesigner.java
  90. 46
      designer-realize/src/main/java/com/fr/design/mainframe/form/FormElementCasePaneDelegate.java
  91. 5
      designer-realize/src/main/java/com/fr/design/mainframe/form/FormReportComponentComposite.java
  92. 3
      designer-realize/src/main/java/com/fr/design/mainframe/socketio/AbstractSocketConfig.java
  93. 1
      designer-realize/src/main/java/com/fr/design/mainframe/socketio/ContainerSocketConfig.java
  94. 11
      designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java
  95. 16
      designer-realize/src/main/java/com/fr/design/report/ReportStylePane.java
  96. 40
      designer-realize/src/main/java/com/fr/design/sort/celldscolumn/CellDSColumnSortGroupPane.java
  97. 40
      designer-realize/src/main/java/com/fr/design/sort/celldscolumn/CellDSColumnSortItemPane.java
  98. 59
      designer-realize/src/main/java/com/fr/design/sort/celldscolumn/CellDSColumnSortPane.java
  99. 19
      designer-realize/src/main/java/com/fr/design/sort/cellexpand/CellExpandSortGroupPane.java
  100. 37
      designer-realize/src/main/java/com/fr/design/sort/cellexpand/CellExpandSortItemPane.java
  101. Some files were not shown because too many files have changed in this diff Show More

1
build.gradle

@ -69,6 +69,7 @@ allprojects {
implementation 'org.swingexplorer:swag:1.0' implementation 'org.swingexplorer:swag:1.0'
implementation 'net.java.dev.jna:jna:5.4.0' implementation 'net.java.dev.jna:jna:5.4.0'
implementation 'org.apache.tomcat:tomcat-catalina:8.5.72' implementation 'org.apache.tomcat:tomcat-catalina:8.5.72'
implementation 'org.apache.tomcat:tomcat-websocket:8.5.72'
implementation 'io.socket:socket.io-client:0.7.0' implementation 'io.socket:socket.io-client:0.7.0'
implementation 'com.fr.third:fine-third:' + frVersion implementation 'com.fr.third:fine-third:' + frVersion
implementation 'com.fr.core:fine-core:' + frDevVersion implementation 'com.fr.core:fine-core:' + frDevVersion

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

@ -53,7 +53,8 @@ import com.fr.stable.xml.XMLReadable;
import com.fr.stable.xml.XMLTools; import com.fr.stable.xml.XMLTools;
import com.fr.stable.xml.XMLWriter; import com.fr.stable.xml.XMLWriter;
import com.fr.stable.xml.XMLableReader; import com.fr.stable.xml.XMLableReader;
import com.fr.third.apache.log4j.FileAppender; import com.fr.third.apache.logging.log4j.core.appender.FileAppender;
import com.fr.third.apache.logging.log4j.core.layout.PatternLayout;
import com.fr.third.org.apache.commons.io.FilenameUtils; import com.fr.third.org.apache.commons.io.FilenameUtils;
import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContext;
import com.fr.workspace.WorkContextCallback; import com.fr.workspace.WorkContextCallback;
@ -324,18 +325,18 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
if (!new File(fileName).exists()) { if (!new File(fileName).exists()) {
StableUtils.makesureFileExist(new File(fileName)); StableUtils.makesureFileExist(new File(fileName));
} }
LogHandler handler = new LogHandler<FileAppender>() { LogHandler<FileAppender> handler = new LogHandler<FileAppender>() {
final FileAppender appender = new FileAppender( final FileAppender appender = FileAppender.newBuilder().
new com.fr.third.apache.log4j.PatternLayout("%d{HH:mm:ss} %t %p [%c] %m%n"), setName(FileAppender.class.getSimpleName()).
fileName setLayout(PatternLayout.newBuilder().withPattern("%d{HH:mm:ss} %t %p [%c] %m%n").build()).
); withFileName(fileName).build();
@Override @Override
public FileAppender getHandler() { public FileAppender getHandler() {
return appender; return appender;
} }
}; };
handler.getHandler().start();
FineLoggerFactory.getLogger().addLogAppender(handler); FineLoggerFactory.getLogger().addLogAppender(handler);
} catch (SecurityException e) { } catch (SecurityException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);

2
designer-base/src/main/java/com/fr/design/actions/community/BugAction.java

@ -17,7 +17,7 @@ public class BugAction extends AbstractDesignerSSO {
@Override @Override
public String getJumpUrl() { public String getJumpUrl() {
return CloudCenter.getInstance().acquireUrlByKind("bbs.bugs", "https://service.fanruan.com/PF/FR/feedback"); return CloudCenter.getInstance().acquireUrlByKind("bbs.bugs", "https://service.fanruan.com/PF/FR/feedback?type=2");
} }
public static final MenuKeySet BUG = new MenuKeySet() { public static final MenuKeySet BUG = new MenuKeySet() {

2
designer-base/src/main/java/com/fr/design/actions/community/NeedAction.java

@ -18,7 +18,7 @@ public class NeedAction extends AbstractDesignerSSO {
@Override @Override
public String getJumpUrl() { public String getJumpUrl() {
return CloudCenter.getInstance().acquireUrlByKind("bbs.needs", "https://service.fanruan.com/PF/FR/feedback"); return CloudCenter.getInstance().acquireUrlByKind("bbs.needs", "https://service.fanruan.com/PF/FR/feedback?type=1");
} }
public static final MenuKeySet NEED = new MenuKeySet() { public static final MenuKeySet NEED = new MenuKeySet() {

5
designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java

@ -29,7 +29,6 @@ import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper; import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.layout.VerticalFlowLayout; import com.fr.design.layout.VerticalFlowLayout;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.vcs.VcsConfigManager; import com.fr.design.mainframe.vcs.VcsConfigManager;
import com.fr.design.mainframe.vcs.common.VcsHelper; import com.fr.design.mainframe.vcs.common.VcsHelper;
import com.fr.design.os.impl.SupportOSImpl; import com.fr.design.os.impl.SupportOSImpl;
@ -45,14 +44,12 @@ import com.fr.locale.InterProviderFactory;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.stable.Constants; import com.fr.stable.Constants;
import com.fr.stable.os.OperatingSystem; import com.fr.stable.os.OperatingSystem;
import com.fr.third.apache.log4j.Level; import com.fr.third.apache.logging.log4j.Level;
import com.fr.transaction.Configurations; import com.fr.transaction.Configurations;
import com.fr.transaction.Worker; import com.fr.transaction.Worker;
import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContext;
import com.fr.workspace.server.vcs.VcsOperator; import com.fr.workspace.server.vcs.VcsOperator;
import com.fr.workspace.server.vcs.git.config.GcConfig; import com.fr.workspace.server.vcs.git.config.GcConfig;
import com.sun.javafx.tk.FileChooserType;
import javafx.stage.FileChooser;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.BoxLayout; import javax.swing.BoxLayout;

61
designer-base/src/main/java/com/fr/design/cell/CellRectangleStylePreviewPane.java

@ -1,6 +1,6 @@
package com.fr.design.cell; package com.fr.design.cell;
import com.fr.report.cell.CellElementBorderSourceFlag; import com.fr.base.CellBorderSourceFlag;
import com.fr.base.CellBorderStyle; import com.fr.base.CellBorderStyle;
import com.fr.base.Style; import com.fr.base.Style;
import com.fr.design.mainframe.theme.utils.DefaultThemedTemplateCellElementCase; import com.fr.design.mainframe.theme.utils.DefaultThemedTemplateCellElementCase;
@ -20,34 +20,39 @@ public class CellRectangleStylePreviewPane extends JPanel {
private static final int COLUMN_COUNT = 2; private static final int COLUMN_COUNT = 2;
private final TemplateCellElement[][] cellElementGrid = new TemplateCellElement[ROW_COUNT][COLUMN_COUNT]; private final TemplateCellElement[][] cellElementGrid = new TemplateCellElement[ROW_COUNT][COLUMN_COUNT];
private final int[][] borderSourceFlags = new int[ROW_COUNT][COLUMN_COUNT];
private final CellStylePreviewPane[][] cellStylePreviewPaneGrid = new CellStylePreviewPane[ROW_COUNT][COLUMN_COUNT]; private final CellStylePreviewPane[][] cellStylePreviewPaneGrid = new CellStylePreviewPane[ROW_COUNT][COLUMN_COUNT];
public CellRectangleStylePreviewPane() { public CellRectangleStylePreviewPane(boolean supportInnerBorder) {
setLayout(new GridLayout(2, 2)); setLayout(new GridLayout(2, 2));
for (int r = 0; r < ROW_COUNT; r++) { for (int r = 0; r < ROW_COUNT; r++) {
for (int c = 0; c < COLUMN_COUNT; c++) { for (int c = 0; c < COLUMN_COUNT; c++) {
CellStylePreviewPane pane = new CellStylePreviewPane(); CellStylePreviewPane pane = new CellStylePreviewPane();
TemplateCellElement cellElement = DefaultThemedTemplateCellElementCase.createInstance(c, r); TemplateCellElement cellElement = DefaultThemedTemplateCellElementCase.createInstance(c, r);
int flags = CellElementBorderSourceFlag.ALL_BORDER_SOURCE_OUTER; int flags = CellBorderSourceFlag.INVALID_BORDER_SOURCE;
if (r != 0) { if (supportInnerBorder) {
flags |= CellElementBorderSourceFlag.TOP_BORDER_SOURCE_INNER; flags = CellBorderSourceFlag.ALL_BORDER_SOURCE_OUTER;
if (r != 0) {
flags |= CellBorderSourceFlag.TOP_BORDER_SOURCE_INNER;
}
if (r != ROW_COUNT - 1) {
flags |= CellBorderSourceFlag.BOTTOM_BORDER_SOURCE_INNER;
}
if (c != 0) {
flags |= CellBorderSourceFlag.LEFT_BORDER_SOURCE_INNER;
}
if (c != COLUMN_COUNT - 1) {
flags |= CellBorderSourceFlag.RIGHT_BORDER_SOURCE_INNER;
}
} }
if (r != ROW_COUNT - 1) {
flags |= CellElementBorderSourceFlag.BOTTOM_BORDER_SOURCE_INNER;
}
if (c != 0) {
flags |= CellElementBorderSourceFlag.LEFT_BORDER_SOURCE_INNER;
}
if (c != COLUMN_COUNT - 1) {
flags |= CellElementBorderSourceFlag.RIGHT_BORDER_SOURCE_INNER;
}
cellElement.setBorderSourceFlags(flags);
pane.setStyle(cellElement.getStyle()); pane.setStyle(cellElement.getStyle());
add(pane); add(pane);
cellElementGrid[r][c] = cellElement; cellElementGrid[r][c] = cellElement;
borderSourceFlags[r][c] = flags;
cellStylePreviewPaneGrid[r][c] = pane; cellStylePreviewPaneGrid[r][c] = pane;
} }
} }
@ -64,7 +69,8 @@ public class CellRectangleStylePreviewPane extends JPanel {
for (int j = 0; j < COLUMN_COUNT; j++) { for (int j = 0; j < COLUMN_COUNT; j++) {
CellStylePreviewPane pane = cellStylePreviewPaneGrid[i][j]; CellStylePreviewPane pane = cellStylePreviewPaneGrid[i][j];
TemplateCellElement cellElement = cellElementGrid[i][j]; TemplateCellElement cellElement = cellElementGrid[i][j];
cellElement.setStyle(style, borderStyle); int flag = borderSourceFlags[i][j];
cellElement.setStyle(CellBorderSourceFlag.deriveBorderedStyle(style, borderStyle, flag));
pane.setStyle(cellElement.getStyle()); pane.setStyle(cellElement.getStyle());
} }
@ -73,7 +79,26 @@ public class CellRectangleStylePreviewPane extends JPanel {
} }
@Override @Override
public Dimension getMinimumSize() { public void setPreferredSize(Dimension preferredSize) {
return getPreferredSize(); super.setPreferredSize(preferredSize);
int hw = preferredSize.width / 2;
int hh = preferredSize.height / 2;
cellStylePreviewPaneGrid[0][0].setPreferredSize(new Dimension(hw, hh));
cellStylePreviewPaneGrid[0][1].setPreferredSize(new Dimension(hw, hh));
cellStylePreviewPaneGrid[1][0].setPreferredSize(new Dimension(hw, hh));
cellStylePreviewPaneGrid[1][1].setPreferredSize(new Dimension(hw, hh));
}
@Override
public Dimension getPreferredSize() {
Dimension d00 = cellStylePreviewPaneGrid[0][0].getPreferredSize();
Dimension d01 = cellStylePreviewPaneGrid[0][1].getPreferredSize();
Dimension d10 = cellStylePreviewPaneGrid[1][0].getPreferredSize();
Dimension d11 = cellStylePreviewPaneGrid[1][1].getPreferredSize();
int width = Math.max(d00.width + d01.width, d10.width + d11.width);
int height = Math.max(d00.height + d10.height, d01.height + d11.height);
return new Dimension(width, height);
} }
} }

45
designer-base/src/main/java/com/fr/design/cell/CellStylePreviewPane.java

@ -1,19 +1,26 @@
package com.fr.design.cell; package com.fr.design.cell;
import com.fr.base.BaseUtils;
import com.fr.base.GraphHelper;
import com.fr.base.NameStyle; import com.fr.base.NameStyle;
import com.fr.base.ScreenResolution; import com.fr.base.ScreenResolution;
import com.fr.base.Style; import com.fr.base.Style;
import com.fr.general.FRFont;
import com.fr.general.IOUtils; import com.fr.general.IOUtils;
import com.fr.stable.unit.PT;
import javax.swing.JPanel; import javax.swing.JPanel;
import java.awt.AlphaComposite; import java.awt.AlphaComposite;
import java.awt.Color; import java.awt.Color;
import java.awt.Composite; import java.awt.Composite;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics; import java.awt.Graphics;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import java.awt.RenderingHints; import java.awt.RenderingHints;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.util.List;
/** /**
* @author Starryi * @author Starryi
@ -22,6 +29,7 @@ import java.awt.image.BufferedImage;
*/ */
public class CellStylePreviewPane extends JPanel { public class CellStylePreviewPane extends JPanel {
public static final int MINIMUM_HEIGHT = 40;
private static final BufferedImage transparentBackgroundImage = IOUtils.readImage("/com/fr/design/images/transparent_background.png"); private static final BufferedImage transparentBackgroundImage = IOUtils.readImage("/com/fr/design/images/transparent_background.png");
private final float transparentBackgroundWidth; private final float transparentBackgroundWidth;
private final float transparentBackgroundHeight; private final float transparentBackgroundHeight;
@ -31,6 +39,7 @@ public class CellStylePreviewPane extends JPanel {
public CellStylePreviewPane() { public CellStylePreviewPane() {
transparentBackgroundWidth = transparentBackgroundImage.getWidth(null); transparentBackgroundWidth = transparentBackgroundImage.getWidth(null);
transparentBackgroundHeight = transparentBackgroundImage.getHeight(null); transparentBackgroundHeight = transparentBackgroundImage.getHeight(null);
setPreferredSize(new Dimension(0, 0));
} }
public void setPaintText(String paintText) { public void setPaintText(String paintText) {
@ -118,7 +127,39 @@ public class CellStylePreviewPane extends JPanel {
} }
@Override @Override
public Dimension getMinimumSize() { public Dimension getPreferredSize() {
return getPreferredSize(); Dimension size = super.getPreferredSize();
int width = size.width;
int height = size.height;
if (height != 0) {
// 使用者设置了一个高度
return size;
} else if (width == 0) {
// 使用者未设置任何尺寸
return new Dimension(width, MINIMUM_HEIGHT);
} else {
// 使用者设置了宽度,但未设置高度
return getAutoWrapContentPreferredSize(width, height);
}
}
private Dimension getAutoWrapContentPreferredSize(int width, int height) {
int resolution = ScreenResolution.getScreenResolution();
// 计算文本区域高度
final FRFont frFont = style.getFRFont();
final Font rfont = frFont.applyResolutionNP(resolution);
final FontMetrics metrics = GraphHelper.getFontMetrics(rfont);
final int textLineHeight = metrics.getHeight();
final double textLineSpacing = PT.pt2pix(style.getLineSpacing(), resolution);
List textLineList = BaseUtils.getLineTextList(paintText, style, rfont, height, width, resolution);
double textLinesHeight = textLineList.size() * textLineHeight + Math.max(0, textLineList.size() - 1) * textLineSpacing;
height = (int) Math.max(MINIMUM_HEIGHT, textLinesHeight);
return new Dimension(width, height);
} }
} }

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

@ -1,12 +1,12 @@
package com.fr.design.data.datapane; package com.fr.design.data.datapane;
import com.fr.base.TableData; import com.fr.base.TableData;
import com.fr.concurrent.NamedThreadFactory;
import com.fr.data.core.DataCoreUtils; import com.fr.data.core.DataCoreUtils;
import com.fr.data.core.db.DBUtils; import com.fr.data.core.db.DBUtils;
import com.fr.data.core.db.TableProcedure; import com.fr.data.core.db.TableProcedure;
import com.fr.data.core.db.dialect.Dialect; import com.fr.data.core.db.dialect.Dialect;
import com.fr.data.core.db.dialect.DialectFactory; import com.fr.data.core.db.dialect.DialectFactory;
import com.fr.data.impl.Connection;
import com.fr.data.impl.DBTableData; import com.fr.data.impl.DBTableData;
import com.fr.data.operator.DataOperator; import com.fr.data.operator.DataOperator;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
@ -19,7 +19,7 @@ import com.fr.design.data.datapane.preview.PreviewTablePane;
import com.fr.design.data.tabledata.Prepare4DataSourceChange; import com.fr.design.data.tabledata.Prepare4DataSourceChange;
import com.fr.design.dialog.FineJOptionPane; import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.gui.icombobox.FilterableComboBoxModel; import com.fr.design.gui.icombobox.FilterableComboBoxModel;
import com.fr.design.gui.icombobox.SearchPreTaskTreeComboBox; import com.fr.design.gui.icombobox.SearchFRTreeComboBox;
import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.icombobox.UIComboBoxEditor; import com.fr.design.gui.icombobox.UIComboBoxEditor;
import com.fr.design.gui.icombobox.UIComboBoxRenderer; import com.fr.design.gui.icombobox.UIComboBoxRenderer;
@ -40,11 +40,6 @@ import com.fr.stable.StringUtils;
import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContext;
import com.fr.workspace.server.connection.DBConnectAuth; import com.fr.workspace.server.connection.DBConnectAuth;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.util.Collections;
import java.util.concurrent.CancellationException;
import javax.swing.JList; import javax.swing.JList;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
import javax.swing.JPanel; import javax.swing.JPanel;
@ -58,21 +53,20 @@ import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeCellRenderer; import javax.swing.tree.DefaultTreeCellRenderer;
import javax.swing.tree.DefaultTreeModel; import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreeCellRenderer; import javax.swing.tree.TreeCellRenderer;
import javax.swing.tree.TreeNode;
import javax.swing.tree.TreePath; import javax.swing.tree.TreePath;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.event.FocusAdapter; import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent; import java.awt.event.FocusEvent;
import java.awt.event.ItemEvent; import java.awt.event.ItemEvent;
import java.awt.event.ItemListener; import java.awt.event.ItemListener;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Enumeration; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.concurrent.Callable; import java.util.concurrent.CancellationException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.FutureTask;
/** /**
* @author zhou * @author zhou
@ -97,41 +91,12 @@ public class ChoosePane extends BasicBeanPane<DataBaseItems> implements Refresha
/** /**
* 表名 * 表名
*/ */
protected SearchPreTaskTreeComboBox tableNameComboBox; protected SearchFRTreeComboBox tableNameComboBox;
private static final ExecutorService SERVICE = Executors.newSingleThreadExecutor(new NamedThreadFactory("ChoosePane"));
private SwingWorker populateWorker; private SwingWorker populateWorker;
private SwingWorker<List<String>, Void> initWorker; private SwingWorker<List<String>, Void> initWorker;
private PopupMenuListener popupMenuListener = new PopupMenuListener() {
@Override
public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
FutureTask<Void> task = new FutureTask<Void>(new Callable<Void>() {
@Override
public Void call() throws Exception {
calculateTableDataNames();
return null;
}
});
tableNameComboBox.setPreSearchTask(task);
SERVICE.submit(task);
}
@Override
public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
// Do nothing
}
@Override
public void popupMenuCanceled(PopupMenuEvent e) {
// Do nothing
}
};
private PopupMenuListener listener = new PopupMenuListener() { private PopupMenuListener listener = new PopupMenuListener() {
@Override @Override
public void popupMenuCanceled(PopupMenuEvent e) { public void popupMenuCanceled(PopupMenuEvent e) {
@ -181,7 +146,7 @@ public class ChoosePane extends BasicBeanPane<DataBaseItems> implements Refresha
schemaBox = new StringUIComboBox(); schemaBox = new StringUIComboBox();
schemaBox.setEditor(new ComboBoxEditor()); schemaBox.setEditor(new ComboBoxEditor());
tableNameComboBox = new SearchPreTaskTreeComboBox(new JTree(new DefaultMutableTreeNode()), tableNameTreeRenderer, false); tableNameComboBox = new SearchFRTreeComboBox(this, new JTree(new DefaultMutableTreeNode()), tableNameTreeRenderer);
tableNameComboBox.setEditable(true); tableNameComboBox.setEditable(true);
tableNameComboBox.setRenderer(listCellRenderer); tableNameComboBox.setRenderer(listCellRenderer);
registerDSChangeListener(); registerDSChangeListener();
@ -198,7 +163,6 @@ public class ChoosePane extends BasicBeanPane<DataBaseItems> implements Refresha
}); });
schemaBox.addPopupMenuListener(listener); schemaBox.addPopupMenuListener(listener);
addFocusListener(); addFocusListener();
this.tableNameComboBox.addPopupMenuListener(popupMenuListener);
} }
protected void addDSBoxListener() { protected void addDSBoxListener() {
@ -355,7 +319,7 @@ public class ChoosePane extends BasicBeanPane<DataBaseItems> implements Refresha
GUICoreUtils.setSelectedItemQuietly(tableNameComboBox, -1); GUICoreUtils.setSelectedItemQuietly(tableNameComboBox, -1);
} }
protected com.fr.data.impl.Connection getConnection() { public Connection getConnection() {
String selectedDSName = this.getDSName(); String selectedDSName = this.getDSName();
if (StringUtils.isEmpty(selectedDSName)) { if (StringUtils.isEmpty(selectedDSName)) {
return null; // peter:选中了当前的零长度的节点,直接返回. return null; // peter:选中了当前的零长度的节点,直接返回.
@ -455,56 +419,6 @@ public class ChoosePane extends BasicBeanPane<DataBaseItems> implements Refresha
return "choosepane"; return "choosepane";
} }
protected void calculateTableDataNames() {
JTree tree = tableNameComboBox.getTree();
if (tree == null) {
return;
}
DefaultMutableTreeNode rootTreeNode = (DefaultMutableTreeNode) tree.getModel().getRoot();
rootTreeNode.removeAllChildren();
String selectedDSName = this.getDSName();
com.fr.data.impl.Connection selectedDatabase = this.getConnection();
if (selectedDatabase == null) {
return;
}
try {
String schema = StringUtils.isEmpty(this.schemaBox.getSelectedItem()) ? null : this.schemaBox.getSelectedItem();
TableProcedure[] sqlTableArray = DataCoreUtils.getTables(selectedDatabase, TableProcedure.TABLE, schema, DesignerEnvManager.getEnvManager().isOracleSystemSpace());
if (sqlTableArray.length > 0) {
ExpandMutableTreeNode tableTreeNode = new ExpandMutableTreeNode(selectedDSName + "-" + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_SQL_Table"));
rootTreeNode.add(tableTreeNode);
for (int i = 0; i < sqlTableArray.length; i++) {
ExpandMutableTreeNode tableChildTreeNode = new ExpandMutableTreeNode(sqlTableArray[i]);
tableTreeNode.add(tableChildTreeNode);
}
}
TableProcedure[] sqlViewArray = DataCoreUtils.getTables(selectedDatabase, TableProcedure.VIEW, schema, DesignerEnvManager.getEnvManager().isOracleSystemSpace());
if (sqlViewArray.length > 0) {
ExpandMutableTreeNode viewTreeNode = new ExpandMutableTreeNode(selectedDSName + "-" + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_SQL_View"));
rootTreeNode.add(viewTreeNode);
for (int i = 0; i < sqlViewArray.length; i++) {
ExpandMutableTreeNode viewChildTreeNode = new ExpandMutableTreeNode(sqlViewArray[i]);
viewTreeNode.add(viewChildTreeNode);
}
}
((DefaultTreeModel) tree.getModel()).reload();
// daniel 展开所有tree
TreeNode root = (TreeNode) tree.getModel().getRoot();
TreePath parent = new TreePath(root);
TreeNode node = (TreeNode) parent.getLastPathComponent();
for (Enumeration e = node.children(); e.hasMoreElements(); ) {
TreeNode n = (TreeNode) e.nextElement();
TreePath path = parent.pathByAddingChild(n);
tree.expandPath(path);
}
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Database_Connection_Failed"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Failed"), JOptionPane.ERROR_MESSAGE);
}
}
/** /**
* 创建选中的数据集数据 * 创建选中的数据集数据
* *
@ -558,10 +472,14 @@ public class ChoosePane extends BasicBeanPane<DataBaseItems> implements Refresha
return tableData; return tableData;
} }
protected String getDSName() { public String getDSName() {
return this.dsNameComboBox.getSelectedItem(); return this.dsNameComboBox.getSelectedItem();
} }
public String getSchema() {
return this.schemaBox.getSelectedItem();
}
protected void failedToFindTable() { protected void failedToFindTable() {
// Do nothing // Do nothing
} }

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

@ -83,7 +83,7 @@ public class ChoosePaneSupportFormula extends ChoosePane {
* *
* @return * @return
*/ */
protected String getDSName() { public String getDSName() {
String selectedDSName = null; String selectedDSName = null;
String item = Utils.objectToString(this.dsNameComboBox.getEditor().getItem()); String item = Utils.objectToString(this.dsNameComboBox.getEditor().getItem());
// 没有选中的列表项 那么看看是不是手输值 // 没有选中的列表项 那么看看是不是手输值

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

@ -0,0 +1,7 @@
package com.fr.design.event;
import java.awt.*;
public interface ComponentChangeListener {
void initListener(Container changedComponent);
}

6
designer-base/src/main/java/com/fr/design/event/ComponentChangeObserver.java

@ -0,0 +1,6 @@
package com.fr.design.event;
public interface ComponentChangeObserver {
void registerChangeListener(ComponentChangeListener uiChangeableListener);
}

29
designer-base/src/main/java/com/fr/design/extra/PluginInstalledPane.java

@ -60,11 +60,14 @@ public class PluginInstalledPane extends PluginAbstractViewPane {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
PluginView plugin = controlPane.getSelectedPlugin(); PluginView plugin = controlPane.getSelectedPlugin();
if (plugin != null) { if (plugin != null) {
boolean isActive = plugin.isActive(); PluginContext pluginContext = getPluginContextByView(plugin);
PluginMarker pluginMarker = PluginMarker.create(plugin.getID(), plugin.getVersion()); if (pluginContext == null) {
final String modifyMessage = isActive ? com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Has_Been_Actived") : com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Has_Been_Disabled"); return;
if (isActive) { }
PluginManager.getController().forbid(pluginMarker, new PluginTaskCallback() { boolean running = pluginContext.isRunning();
final String modifyMessage = running ? com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Has_Been_Actived") : com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Has_Been_Disabled");
if (running) {
PluginManager.getController().forbidPersistently(pluginContext.getMarker(), new PluginTaskCallback() {
@Override @Override
public void done(PluginTaskResult result) { public void done(PluginTaskResult result) {
if (result.isSuccess()) { if (result.isSuccess()) {
@ -75,7 +78,7 @@ public class PluginInstalledPane extends PluginAbstractViewPane {
} }
}); });
} else { } else {
PluginManager.getController().enable(pluginMarker, new PluginTaskCallback() { PluginManager.getController().enablePersistently(pluginContext.getMarker(), new PluginTaskCallback() {
@Override @Override
public void done(PluginTaskResult result) { public void done(PluginTaskResult result) {
if (result.isSuccess()) { if (result.isSuccess()) {
@ -145,13 +148,25 @@ public class PluginInstalledPane extends PluginAbstractViewPane {
} }
private void changeTextForButton(PluginView plugin) { private void changeTextForButton(PluginView plugin) {
if (plugin.isActive()) { PluginContext pluginContext = getPluginContextByView(plugin);
if (pluginContext == null) {
return;
}
if (pluginContext.isRunning()) {
disableButton.setText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Disable")); disableButton.setText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Disable"));
} else { } else {
disableButton.setText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Active")); disableButton.setText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Active"));
} }
} }
private PluginContext getPluginContextByView(PluginView pluginView) {
if (pluginView != null) {
PluginMarker pluginMarker = PluginMarker.create(pluginView.getID(), pluginView.getVersion());
return PluginManager.getContext(pluginMarker);
}
return null;
}
@Override @Override
protected String title4PopupWindow() { protected String title4PopupWindow() {
return "Installed"; return "Installed";

12
designer-base/src/main/java/com/fr/design/extra/PluginOperateUtils.java

@ -99,9 +99,9 @@ public class PluginOperateUtils {
public void run() { public void run() {
PluginMarker pluginMarker = PluginUtils.createPluginMarker(pluginInfo); PluginMarker pluginMarker = PluginUtils.createPluginMarker(pluginInfo);
PluginContext plugin = PluginManager.getContext(pluginMarker); PluginContext plugin = PluginManager.getContext(pluginMarker);
boolean active = plugin.isActive(); boolean isRunning = plugin.isRunning();
PluginTaskCallback modifyStatusCallback = new ModifyStatusCallback(active, jsCallback); PluginTaskCallback modifyStatusCallback = new ModifyStatusCallback(isRunning, jsCallback);
if (active) { if (isRunning) {
PluginXmlElement forbidReminder = plugin.getXml().getElement(PluginElementName.ForbidReminder); PluginXmlElement forbidReminder = plugin.getXml().getElement(PluginElementName.ForbidReminder);
if (forbidReminder != null && forbidReminder.getContent() != null) { if (forbidReminder != null && forbidReminder.getContent() != null) {
// 禁用前提示 // 禁用前提示
@ -113,14 +113,14 @@ public class PluginOperateUtils {
JOptionPane.WARNING_MESSAGE JOptionPane.WARNING_MESSAGE
); );
if (rv == JOptionPane.OK_OPTION) { if (rv == JOptionPane.OK_OPTION) {
PluginManager.getController().forbid(pluginMarker, modifyStatusCallback); PluginManager.getController().forbidPersistently(pluginMarker, modifyStatusCallback);
} }
} else { } else {
// 正常禁用 // 正常禁用
PluginManager.getController().forbid(pluginMarker, modifyStatusCallback); PluginManager.getController().forbidPersistently(pluginMarker, modifyStatusCallback);
} }
} else { } else {
PluginManager.getController().enable(pluginMarker, modifyStatusCallback); PluginManager.getController().enablePersistently(pluginMarker, modifyStatusCallback);
} }
} }
}); });

11
designer-base/src/main/java/com/fr/design/gui/frpane/AbstractAttrNoScrollPane.java

@ -3,6 +3,8 @@ package com.fr.design.gui.frpane;
import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.BasicPane;
import com.fr.design.event.GlobalNameListener; import com.fr.design.event.GlobalNameListener;
import com.fr.design.event.GlobalNameObserver; import com.fr.design.event.GlobalNameObserver;
import com.fr.design.event.ComponentChangeListener;
import com.fr.design.event.ComponentChangeObserver;
import com.fr.design.event.UIObserver; import com.fr.design.event.UIObserver;
import com.fr.design.event.UIObserverListener; import com.fr.design.event.UIObserverListener;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
@ -103,6 +105,15 @@ public abstract class AbstractAttrNoScrollPane extends BasicPane {
} }
}); });
} }
if(tmpComp instanceof ComponentChangeObserver){
ComponentChangeObserver uiChangeableObserver = ((ComponentChangeObserver)tmpComp);
uiChangeableObserver.registerChangeListener(new ComponentChangeListener() {
@Override
public void initListener(Container changedComponent) {
AbstractAttrNoScrollPane.this.initListener(changedComponent);
}
});
}
} }
} }

6
designer-base/src/main/java/com/fr/design/gui/icheckbox/UICheckBox.java

@ -58,7 +58,7 @@ public class UICheckBox extends JCheckBox implements UIObserver, GlobalNameObser
super(locText, b); super(locText, b);
setUI(new UICheckBoxUI()); setUI(new UICheckBoxUI());
initListener(); initListener();
this.markMnemonic=markMnemonic; this.markMnemonic = markMnemonic;
} }
public UICheckBox(String text, Icon icon) { public UICheckBox(String text, Icon icon) {
@ -100,6 +100,10 @@ public class UICheckBox extends JCheckBox implements UIObserver, GlobalNameObser
} }
public void removeChangeListener() {
uiObserverListener = null;
}
@Override @Override
public void setGlobalName(String name) { public void setGlobalName(String name) {
checkboxName = name; checkboxName = name;

4
designer-base/src/main/java/com/fr/design/gui/icombobox/FRTreeComboBox.java

@ -248,7 +248,7 @@ public class FRTreeComboBox extends UIComboBox {
private static TreePopup treePopup; private static TreePopup treePopup;
private static class FRTreeComboBoxUI extends BasicComboBoxUI implements MouseListener{ protected static class FRTreeComboBoxUI extends BasicComboBoxUI implements MouseListener{
private boolean isRollover = false; private boolean isRollover = false;
public FRTreeComboBoxUI() { public FRTreeComboBoxUI() {
@ -535,7 +535,7 @@ public class FRTreeComboBox extends UIComboBox {
public class FrTreeSearchComboBoxEditor extends UIComboBoxEditor implements DocumentListener { public class FrTreeSearchComboBoxEditor extends UIComboBoxEditor implements DocumentListener {
private volatile boolean setting = false; private volatile boolean setting = false;
private FRTreeComboBox comboBox; private FRTreeComboBox comboBox;
private Object item; protected Object item;
public FrTreeSearchComboBoxEditor(FRTreeComboBox comboBox) { public FrTreeSearchComboBoxEditor(FRTreeComboBox comboBox) {
super(); super();

200
designer-base/src/main/java/com/fr/design/gui/icombobox/SearchFRTreeComboBox.java

@ -0,0 +1,200 @@
package com.fr.design.gui.icombobox;
import com.fr.data.core.DataCoreUtils;
import com.fr.data.core.db.TableProcedure;
import com.fr.data.impl.Connection;
import com.fr.design.DesignerEnvManager;
import com.fr.design.data.datapane.ChoosePane;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode;
import com.fr.design.mainframe.DesignerContext;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.ArrayUtils;
import com.fr.stable.StringUtils;
import javax.swing.JOptionPane;
import javax.swing.JTree;
import javax.swing.SwingWorker;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreeCellRenderer;
import javax.swing.tree.TreeNode;
import javax.swing.tree.TreePath;
import java.awt.event.MouseEvent;
import java.util.Enumeration;
/**
* 实现模糊搜索的FRTreeComboBox
* FRTreeComboBox搜索后滚动到首个匹配节点
* SearchFRTreeComboBox显示所有匹配的节点
*
* @author Lucian.Chen
* @version 10.0
* Created by Lucian.Chen on 2021/4/14
*/
public class SearchFRTreeComboBox extends FRTreeComboBox {
// 持有父容器,需要实时获取其他组件值
private final ChoosePane parent;
public SearchFRTreeComboBox(ChoosePane parent, JTree tree, TreeCellRenderer renderer) {
super(tree, renderer);
this.parent = parent;
setUI(new SearchFRTreeComboBoxUI());
}
protected UIComboBoxEditor createEditor() {
return new SearchFRComboBoxEditor(this);
}
/**
* 执行模糊搜索
*/
private void searchExecute() {
UIComboBoxEditor searchEditor = (UIComboBoxEditor) this.getEditor();
new SwingWorker<Void, Void>() {
@Override
protected Void doInBackground() {
processTableDataNames(
parent.getDSName(),
parent.getConnection(),
parent.getSchema(),
createFilter((String) searchEditor.getItem()));
return null;
}
@Override
protected void done() {
expandTree();
// 输入框获取焦点
searchEditor.getEditorComponent().requestFocus();
}
}.execute();
}
private TableNameFilter createFilter(String text) {
return StringUtils.isEmpty(text) ? EMPTY_FILTER : new TableNameFilter(text);
}
/**
* 查询数据库表并构建节点目录
*
* @param databaseName 数据库名
* @param connection 数据连接
* @param schema 模式
* @param filter 模糊搜索过滤器
*/
private void processTableDataNames(String databaseName, Connection connection, String schema, TableNameFilter filter) {
if (tree == null) {
return;
}
DefaultMutableTreeNode rootTreeNode = (DefaultMutableTreeNode) tree.getModel().getRoot();
rootTreeNode.removeAllChildren();
if (connection == null) {
return;
}
try {
schema = StringUtils.isEmpty(schema) ? null : schema;
TableProcedure[] sqlTableArray = DataCoreUtils.getTables(connection, TableProcedure.TABLE, schema, DesignerEnvManager.getEnvManager().isOracleSystemSpace());
if (ArrayUtils.isNotEmpty(sqlTableArray)) {
ExpandMutableTreeNode tableTreeNode = new ExpandMutableTreeNode(databaseName + "-" + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_SQL_Table"));
rootTreeNode.add(tableTreeNode);
addArrayNode(tableTreeNode, sqlTableArray, filter);
}
TableProcedure[] sqlViewArray = DataCoreUtils.getTables(connection, TableProcedure.VIEW, schema, DesignerEnvManager.getEnvManager().isOracleSystemSpace());
if (ArrayUtils.isNotEmpty(sqlViewArray)) {
ExpandMutableTreeNode viewTreeNode = new ExpandMutableTreeNode(databaseName + "-" + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_SQL_View"));
rootTreeNode.add(viewTreeNode);
addArrayNode(viewTreeNode, sqlViewArray, filter);
}
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Database_Connection_Failed"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Failed"), JOptionPane.ERROR_MESSAGE);
}
}
private void addArrayNode(ExpandMutableTreeNode rootNode, TableProcedure[] sqlArray, TableNameFilter filter) {
if (sqlArray != null) {
for (TableProcedure procedure : sqlArray) {
if (filter.accept(procedure)) {
ExpandMutableTreeNode viewChildTreeNode = new ExpandMutableTreeNode(procedure);
rootNode.add(viewChildTreeNode);
}
}
}
}
/**
* 展开节点
*/
private void expandTree() {
((DefaultTreeModel) tree.getModel()).reload();
// daniel 展开所有tree
TreeNode root = (TreeNode) tree.getModel().getRoot();
TreePath parent = new TreePath(root);
TreeNode node = (TreeNode) parent.getLastPathComponent();
for (Enumeration e = node.children(); e.hasMoreElements(); ) {
TreeNode n = (TreeNode) e.nextElement();
TreePath path = parent.pathByAddingChild(n);
tree.expandPath(path);
}
}
/**
* 重写输入框编辑器实现输入框模糊搜索逻辑
*/
private class SearchFRComboBoxEditor extends FrTreeSearchComboBoxEditor {
public SearchFRComboBoxEditor(FRTreeComboBox comboBox) {
super(comboBox);
}
@Override
protected void changeHandler() {
if (isSetting()) {
return;
}
setPopupVisible(true);
this.item = textField.getText();
searchExecute();
}
}
private static final TableNameFilter EMPTY_FILTER = new TableNameFilter(StringUtils.EMPTY) {
public boolean accept(TableProcedure procedure) {
return true;
}
};
/**
* 表名模糊搜索实现
*/
private static class TableNameFilter {
private final String searchFilter;
public TableNameFilter(String searchFilter) {
if (StringUtils.isNotEmpty(searchFilter)) {
searchFilter = searchFilter.toLowerCase().trim();
}
this.searchFilter = searchFilter;
}
// 字符串匹配
public boolean accept(TableProcedure procedure) {
return procedure.getName().toLowerCase().contains(searchFilter);
}
}
/**
* 重写FRTreeComboBoxUI实现点击下拉时触发模糊搜索
*/
private class SearchFRTreeComboBoxUI extends FRTreeComboBoxUI {
@Override
public void mouseClicked(MouseEvent e) {
searchExecute();
}
}
}

77
designer-base/src/main/java/com/fr/design/gui/icombobox/SearchPreTaskTreeComboBox.java

@ -1,77 +0,0 @@
package com.fr.design.gui.icombobox;
import com.fr.log.FineLoggerFactory;
import javax.swing.JTree;
import javax.swing.SwingWorker;
import javax.swing.tree.TreeCellRenderer;
import java.util.concurrent.FutureTask;
/**
* 模糊搜索前需执行完前置任务的TreeComboBox
* @author Lucian.Chen
* @version 10.0
* Created by Lucian.Chen on 2021/4/14
*/
public class SearchPreTaskTreeComboBox extends FRTreeComboBox {
/**
* 模糊搜索前任务
*/
private FutureTask<Void> preSearchTask;
public SearchPreTaskTreeComboBox(JTree tree, TreeCellRenderer renderer, boolean editable) {
super(tree, renderer, editable);
}
public FutureTask<Void> getPreSearchTask() {
return preSearchTask;
}
public void setPreSearchTask(FutureTask<Void> preSearchTask) {
this.preSearchTask = preSearchTask;
}
protected UIComboBoxEditor createEditor() {
return new SearchPreTaskComboBoxEditor(this);
}
private class SearchPreTaskComboBoxEditor extends FrTreeSearchComboBoxEditor {
public SearchPreTaskComboBoxEditor(FRTreeComboBox comboBox) {
super(comboBox);
}
protected void changeHandler() {
if (isSetting()) {
return;
}
setPopupVisible(true);
new SwingWorker<Void, Void>() {
@Override
protected Void doInBackground() {
FutureTask<Void> task = getPreSearchTask();
try {
// 确保模糊搜索前任务执行完成后,再进行模糊搜索
if (task != null) {
task.get();
}
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
if (task != null) {
// 任务执行后置空,否则会被别的操作重复触发
setPreSearchTask(null);
}
return null;
}
@Override
protected void done() {
// 模糊搜索
search();
}
}.execute();
}
}
}

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

@ -223,6 +223,9 @@ public class BorderPane extends AbstractBasicStylePane implements GlobalNameObse
} else if (cellBorderStyle.getHorizontalStyle() != Constants.LINE_NONE) { } else if (cellBorderStyle.getHorizontalStyle() != Constants.LINE_NONE) {
this.currentLineCombo.setSelectedLineStyle(cellBorderStyle.getHorizontalStyle()); this.currentLineCombo.setSelectedLineStyle(cellBorderStyle.getHorizontalStyle());
this.currentLineColorPane.setSelectObject(cellBorderStyle.getHorizontalColor()); this.currentLineColorPane.setSelectObject(cellBorderStyle.getHorizontalColor());
} else {
this.currentLineCombo.setSelectedLineStyle(Constants.LINE_NONE);
this.currentLineColorPane.setSelectObject(Color.BLACK);
} }
} }

235
designer-base/src/main/java/com/fr/design/gui/style/TextFormatPane.java

@ -7,7 +7,6 @@ import com.fr.base.TextFormat;
import com.fr.data.core.FormatField; import com.fr.data.core.FormatField;
import com.fr.data.core.FormatField.FormatContents; import com.fr.data.core.FormatField.FormatContents;
import com.fr.design.border.UIRoundedBorder; import com.fr.design.border.UIRoundedBorder;
import com.fr.design.constants.LayoutConstants;
import com.fr.design.constants.UIConstants; import com.fr.design.constants.UIConstants;
import com.fr.design.event.GlobalNameListener; import com.fr.design.event.GlobalNameListener;
import com.fr.design.event.GlobalNameObserver; import com.fr.design.event.GlobalNameObserver;
@ -18,21 +17,18 @@ import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.icombobox.UIComboBoxRenderer; import com.fr.design.gui.icombobox.UIComboBoxRenderer;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.JComponent;
import javax.swing.JLabel; import javax.swing.JLabel;
import javax.swing.JList; import javax.swing.JList;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.SwingConstants;
import javax.swing.UIManager; import javax.swing.UIManager;
import javax.swing.border.Border; import javax.swing.border.Border;
import javax.swing.border.TitledBorder; import javax.swing.border.TitledBorder;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Color; import java.awt.Color;
import java.awt.Component; import java.awt.Component;
import java.awt.Dimension; import java.awt.Dimension;
@ -43,7 +39,6 @@ import java.awt.event.ItemListener;
import java.math.RoundingMode; import java.math.RoundingMode;
import java.text.Format; import java.text.Format;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Arrays;
/** /**
* @author Starryi * @author Starryi
@ -68,69 +63,45 @@ public class TextFormatPane extends AbstractBasicStylePane implements GlobalName
private static final Integer[] DATE_TYPES = new Integer[]{FormatContents.NULL, FormatContents.DATE, FormatContents.TIME}; private static final Integer[] DATE_TYPES = new Integer[]{FormatContents.NULL, FormatContents.DATE, FormatContents.TIME};
private Format format; protected UIComboBox typeComboBox;
protected TextFontComboBox<String> textField;
private UIComboBox typeComboBox; protected UICheckBox roundingBox;
private TextFontComboBox textField; protected UILabel previewLabel;
private UILabel sampleLabel;
private JPanel contentPane;
private JPanel txtCenterPane;
private JPanel centerPane;
private JPanel optionPane;
private UICheckBox roundingBox;
private JPanel formatFontPane;
private boolean isRightFormat; private boolean isRightFormat;
private boolean isDate = false; private boolean isDate = false;
private GlobalNameListener globalNameListener = null; private GlobalNameListener globalNameListener = null;
/**
* Constructor.
*/
public TextFormatPane() { public TextFormatPane() {
this.initComponents(TYPES);
}
protected UIComboBox getTypeComboBox() { initFormatTypesComboBox();
return typeComboBox; initTextFontComboBox4GeneralFormats();
initRoundingCheckBox4PercentFormat();
initPreviewLabel4GeneralFormat();
initLayout();
setTextFieldVisible(false);
setRoundingBoxVisible(false);
setPreviewLabelVisible(false);
} }
protected void initComponents(Integer[] types) { private void initFormatTypesComboBox() {
this.setLayout(new BorderLayout(0, 4)); typeComboBox = new UIComboBox(TextFormatPane.TYPES);
initSampleLabel(); typeComboBox.setRenderer(createComBoxRender());
contentPane = new JPanel(new BorderLayout(0, 4)) {
@Override
public Dimension getPreferredSize() {
return new Dimension(super.getPreferredSize().width, 65);
}
};
typeComboBox = new UIComboBox(types);
UIComboBoxRenderer render = createComBoxRender();
typeComboBox.setRenderer(render);
typeComboBox.addItemListener(itemListener); typeComboBox.addItemListener(itemListener);
typeComboBox.setGlobalName("typeComboBox"); typeComboBox.setGlobalName("typeComboBox");
contentPane.add(sampleLabel, BorderLayout.NORTH); typeComboBox.setPreferredSize(new Dimension(155,20));
}
txtCenterPane = new JPanel(new BorderLayout()); private void initTextFontComboBox4GeneralFormats() {
textField = new TextFontComboBox(); textField = new TextFontComboBox<>();
textField.addItemListener(textFieldItemListener); textField.addItemListener(textFieldItemListener);
textField.setEditable(true); textField.setEditable(true);
textField.setGlobalName("textField"); textField.setGlobalName("textField");
txtCenterPane.add(textField, BorderLayout.NORTH); }
contentPane.add(txtCenterPane, BorderLayout.CENTER);
centerPane = new JPanel(new CardLayout());
centerPane.add(new JPanel(), "hide");
centerPane.setPreferredSize(new Dimension(0, 0));
centerPane.add(contentPane, "show");
typeComboBox.setPreferredSize(new Dimension(155,20));
JPanel typePane = new JPanel(new BorderLayout());
typePane.add(typeComboBox, BorderLayout.CENTER);
typePane.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 0));
JPanel option = new JPanel(new BorderLayout()); private void initRoundingCheckBox4PercentFormat() {
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 = new UICheckBox(Toolkit.i18nText("Fine-Design_Report_Base_Option_Half_Up"));
roundingBox.setBorder(BorderFactory.createEmptyBorder(0, 30, 0, 0)); roundingBox.setBorder(BorderFactory.createEmptyBorder(0, 30, 0, 0));
roundingBox.addItemListener(new ItemListener() { roundingBox.addItemListener(new ItemListener() {
@ -139,54 +110,13 @@ public class TextFormatPane extends AbstractBasicStylePane implements GlobalName
} }
}); });
roundingBox.setGlobalName("roundingBox"); 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(centerPane, typePane);
this.add(createContentPane(components), BorderLayout.CENTER);
}
protected JPanel createContentPane (Component[][] components) {
double f = TableLayout.FILL;
double p = TableLayout.PREFERRED;
double[] rowSize = new double[components.length];
Arrays.fill(rowSize, p);
double[] columnSize = {p, f};
int[][] rowCount = new int[components.length][2];
Arrays.fill(rowCount, new int[] {1, 1});
return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_LARGE, LayoutConstants.VGAP_MEDIUM);
}
protected Component[][] getComponent (JPanel centerPane, JPanel typePane) {
return new Component[][]{
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Report_Base_Format"), SwingConstants.LEFT), typePane},
new Component[]{centerPane, null},
new Component[]{optionPane, null},
};
}
protected UIComboBoxRenderer createComBoxRender() {
return new UIComboBoxRenderer() {
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
JLabel label = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
if (value instanceof Integer) {
label.setText(" " + FormatField.getInstance().getName((Integer) value));
}
return label;
}
};
} }
private void initSampleLabel() { private void initPreviewLabel4GeneralFormat() {
Border interBorder = new UIRoundedBorder(UIConstants.LINE_COLOR, 1, 4); Border interBorder = new UIRoundedBorder(UIConstants.LINE_COLOR, 1, 4);
String title = Toolkit.i18nText("Fine-Design_Report_Base_StyleFormat_Sample"); String title = Toolkit.i18nText("Fine-Design_Report_Base_StyleFormat_Sample");
Border border = BorderFactory.createTitledBorder(interBorder, title, TitledBorder.LEFT, 0, null, UIConstants.LINE_COLOR); Border border = BorderFactory.createTitledBorder(interBorder, title, TitledBorder.LEFT, 0, null, UIConstants.LINE_COLOR);
sampleLabel = new UILabel(FormatField.getInstance().getFormatValue()) { previewLabel = new UILabel(FormatField.getInstance().getFormatValue()) {
@Override @Override
public void paint(Graphics g) { public void paint(Graphics g) {
@ -198,12 +128,65 @@ public class TextFormatPane extends AbstractBasicStylePane implements GlobalName
g.setColor(UIConstants.LINE_COLOR); g.setColor(UIConstants.LINE_COLOR);
FontMetrics cellFM = g.getFontMetrics(); FontMetrics cellFM = g.getFontMetrics();
int textWidth = cellFM.stringWidth(getText()); int textWidth = cellFM.stringWidth(getText());
GraphHelper.drawString(g, getText(), (width - textWidth) / 2, 26); GraphHelper.drawString(g, getText(), (width - textWidth) / 2F, 26);
g.setColor(original); g.setColor(original);
} }
}; };
sampleLabel.setHorizontalAlignment(UILabel.CENTER); previewLabel.setHorizontalAlignment(UILabel.CENTER);
sampleLabel.setBorder(border); previewLabel.setBorder(border);
}
protected void initLayout() {
JPanel labeledFormatTypeComboBoxPane = new JPanel(new BorderLayout(20, 0));
labeledFormatTypeComboBoxPane.add(new UILabel(Toolkit.i18nText("Fine-Design_Report_Base_Format")), BorderLayout.WEST);
labeledFormatTypeComboBoxPane.add(typeComboBox, BorderLayout.CENTER);
JPanel labeledRoundingCheckboxPane = new JPanel(new BorderLayout(0, 0));
labeledRoundingCheckboxPane.add(new UILabel(Toolkit.i18nText("Fine-Design_Report_Base_Option")), BorderLayout.WEST);
labeledRoundingCheckboxPane.add(roundingBox, BorderLayout.CENTER);
addComponents(4, new JComponent[] { labeledFormatTypeComboBoxPane, textField, labeledRoundingCheckboxPane, previewLabel});
}
protected void setTextFieldVisible(boolean visible) {
textField.setVisible(visible);
}
protected void setRoundingBoxVisible(boolean visible) {
roundingBox.getParent().setVisible(visible);
}
protected void setPreviewLabelVisible(boolean visible) {
previewLabel.setVisible(visible);
}
protected void addComponents(int gap, JComponent[] components) {
JPanel container = this;
container.setLayout(new BorderLayout(0, gap));
for (JComponent component: components) {
if (component != null) {
container.add(component, BorderLayout.NORTH);
JPanel nextContainer = new JPanel(new BorderLayout(0, gap));
container.add(nextContainer, BorderLayout.CENTER);
container = nextContainer;
}
}
if (container.getComponentCount() == 0) {
container.getParent().remove(container);
}
}
protected UIComboBoxRenderer createComBoxRender() {
return new UIComboBoxRenderer() {
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
JLabel label = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
if (value instanceof Integer) {
label.setText(" " + FormatField.getInstance().getName((Integer) value));
}
return label;
}
};
} }
@ -231,8 +214,6 @@ public class TextFormatPane extends AbstractBasicStylePane implements GlobalName
* Populate * Populate
*/ */
public void populateBean(Format format) { public void populateBean(Format format) {
this.format = format;
if (format == null) { if (format == null) {
this.typeComboBox.setSelectedIndex(FormatContents.NULL); this.typeComboBox.setSelectedIndex(FormatContents.NULL);
} else { } else {
@ -325,17 +306,17 @@ public class TextFormatPane extends AbstractBasicStylePane implements GlobalName
* Refresh preview label. * Refresh preview label.
*/ */
private void refreshPreviewLabel() { private void refreshPreviewLabel() {
this.sampleLabel.setText(FormatField.getInstance().getFormatValue()); this.previewLabel.setText(FormatField.getInstance().getFormatValue());
this.sampleLabel.setForeground(UIManager.getColor("Label.foreground")); this.previewLabel.setForeground(UIManager.getColor("Label.foreground"));
try { try {
isRightFormat = true; isRightFormat = true;
if (StringUtils.isEmpty(String.valueOf(textField.getSelectedItem()))) { if (StringUtils.isEmpty(String.valueOf(textField.getSelectedItem()))) {
return; return;
} }
this.sampleLabel.setText(FormatField.getInstance().getFormatValue(getFormatContents(), String.valueOf(textField.getSelectedItem()))); this.previewLabel.setText(FormatField.getInstance().getFormatValue(getFormatContents(), String.valueOf(textField.getSelectedItem())));
} catch (Exception e) { } catch (Exception e) {
this.sampleLabel.setForeground(Color.red); this.previewLabel.setForeground(Color.red);
this.sampleLabel.setText(e.getMessage()); this.previewLabel.setText(e.getMessage());
isRightFormat = false; isRightFormat = false;
} }
} }
@ -354,28 +335,16 @@ public class TextFormatPane extends AbstractBasicStylePane implements GlobalName
public void itemStateChanged(ItemEvent e) { public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) { if (e.getStateChange() == ItemEvent.SELECTED) {
int contents = getFormatContents(); int contents = getFormatContents();
String[] items = FormatField.getInstance().getFormatArray(contents, false);
CardLayout cardLayout = (CardLayout) centerPane.getLayout();
if (isTextOrNull()) { if (!isTextOrNull()) {
centerPane.setPreferredSize(new Dimension(0, 0));
cardLayout.show(centerPane, "hide");
} else {
textField.removeAllItems(); textField.removeAllItems();
String[] items = FormatField.getInstance().getFormatArray(contents, false);
textField.setItemArray(items); textField.setItemArray(items);
textField.setSelectedIndex(0); textField.setSelectedIndex(0);
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);
} }
setTextFieldVisible(!isTextOrNull());
setPreviewLabelVisible(!isTextOrNull());
setRoundingBoxVisible(getFormatContents() == FormatContents.PERCENT);
} }
} }
@ -403,10 +372,20 @@ public class TextFormatPane extends AbstractBasicStylePane implements GlobalName
* update * update
*/ */
public Style update(Style style) { public Style update(Style style) {
if (ComparatorUtils.equals(globalNameListener.getGlobalName(), "textField") return updateByGlobalNamedSetting(style);
|| ComparatorUtils.equals(globalNameListener.getGlobalName(), "typeComboBox") }
|| ComparatorUtils.equals(globalNameListener.getGlobalName(), "roundingBox")) {
return style.deriveFormat(this.update()); private Style updateByGlobalNamedSetting(Style style) {
if (globalNameListener != null) {
String[] alterSettingNames = new String[] {"typeComboBox", "textField", "roundingBox"};
String globalSettingName = globalNameListener.getGlobalName();
if (StringUtils.isNotEmpty(globalSettingName)) {
for (String alterSettingName : alterSettingNames) {
if (ComparatorUtils.equals(alterSettingName, globalSettingName)) {
return style.deriveFormat(this.update());
}
}
}
} }
return style; return style;
} }

6
designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java

@ -221,10 +221,14 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
if (success) { if (success) {
FileNode fileNode = TemplateTreePane.getInstance().getFileNode(); FileNode fileNode = TemplateTreePane.getInstance().getFileNode();
refreshRightToolBarBy(fileNode); refreshRightToolBarBy(fileNode);
TemplateTreePane.getInstance().refresh();
} else { } else {
FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Design_Template_Unlock_Failed"),
Toolkit.i18nText("Fine-Design_Basic_Alert"),
JOptionPane.WARNING_MESSAGE);
FineLoggerFactory.getLogger().error("Unlock {} failed", path); FineLoggerFactory.getLogger().error("Unlock {} failed", path);
} }
TemplateTreePane.getInstance().refresh();
} }
} }
}); });

46
designer-form/src/main/java/com/fr/design/fit/DesignerUIModeConfig.java → designer-base/src/main/java/com/fr/design/mainframe/DesignerUIModeConfig.java

@ -1,19 +1,16 @@
package com.fr.design.fit; package com.fr.design.mainframe;
import com.fr.base.ScreenResolution; import com.fr.base.ScreenResolution;
import com.fr.design.fun.ReportLengthUNITProvider; import com.fr.design.fun.ReportLengthUNITProvider;
import com.fr.design.unit.UnitConvertUtil; import com.fr.design.unit.UnitConvertUtil;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.FRScreen;
import com.fr.stable.Constants; import com.fr.stable.Constants;
import java.awt.Dimension;
/** /**
* Created by kerry on 2020-06-05 * Created by kerry on 2020-06-05
*/ */
public class DesignerUIModeConfig { public class DesignerUIModeConfig {
private DesignerUIMode mode = DesignerUIMode.NEW_UI_MODE; private DesignerUIMode mode = DesignerUIMode.ABSOLUTE_MEASURE_UI_MODE;
private static class DesignerUIModeConfigHolder { private static class DesignerUIModeConfigHolder {
private static final DesignerUIModeConfig designerUIModeConfig = new DesignerUIModeConfig(); private static final DesignerUIModeConfig designerUIModeConfig = new DesignerUIModeConfig();
@ -33,22 +30,22 @@ public class DesignerUIModeConfig {
* *
* @return boolean * @return boolean
*/ */
public boolean newUIMode() { public boolean simulateWebUIMode() {
return ComparatorUtils.equals(DesignerUIMode.NEW_UI_MODE, mode); return ComparatorUtils.equals(DesignerUIMode.SIMULATE_WEB_UI_MODE, mode);
} }
/** /**
* 设置新ui模式 * 设置新ui模式
*/ */
public void setNewUIMode() { public void setSimulateWebUIMode() {
this.mode = DesignerUIMode.NEW_UI_MODE; this.mode = DesignerUIMode.SIMULATE_WEB_UI_MODE;
} }
/** /**
* 设置老ui模式 * 设置老ui模式
*/ */
public void setOldUIMode() { public void setAbsoluteMeasureUIMode() {
this.mode = DesignerUIMode.OLD_UI_MODE; this.mode = DesignerUIMode.ABSOLUTE_MEASURE_UI_MODE;
} }
/** /**
@ -70,55 +67,38 @@ public class DesignerUIModeConfig {
return mode.getScreenResolution(); return mode.getScreenResolution();
} }
/**
* 根据屏幕尺寸获取设计时的FRScreen
*
* @param screen 屏幕尺寸
* @return FRScreen
*/
public FRScreen getDesignScreenByDimension(Dimension screen) {
return mode.getDesignScreenByDimension(screen);
}
private enum DesignerUIMode { private enum DesignerUIMode {
OLD_UI_MODE { ABSOLUTE_MEASURE_UI_MODE {
@Override @Override
protected ReportLengthUNITProvider parseLengthUNIT(int unitType) { protected ReportLengthUNITProvider parseLengthUNIT(int unitType) {
return UnitConvertUtil.parseLengthUNIT(unitType); return UnitConvertUtil.parseLengthUNIT(unitType);
} }
@Override
protected FRScreen getDesignScreenByDimension(Dimension screen) {
return FRScreen.getDesignScreenByDimension(screen);
}
@Override @Override
protected int getScreenResolution() { protected int getScreenResolution() {
return ScreenResolution.getScreenResolution(); return ScreenResolution.getScreenResolution();
} }
}, },
NEW_UI_MODE { SIMULATE_WEB_UI_MODE {
@Override @Override
protected ReportLengthUNITProvider parseLengthUNIT(int unitType) { protected ReportLengthUNITProvider parseLengthUNIT(int unitType) {
return new PXReportLengthUNIT(); return new PXReportLengthUNIT();
} }
@Override
protected FRScreen getDesignScreenByDimension(Dimension screen) {
return FRScreen.p1440;
}
@Override @Override
protected int getScreenResolution() { protected int getScreenResolution() {
return Constants.DEFAULT_WEBWRITE_AND_SCREEN_RESOLUTION; return Constants.DEFAULT_WEBWRITE_AND_SCREEN_RESOLUTION;
} }
}; };
protected abstract ReportLengthUNITProvider parseLengthUNIT(int unitType); protected abstract ReportLengthUNITProvider parseLengthUNIT(int unitType);
protected abstract FRScreen getDesignScreenByDimension(Dimension screen);
protected abstract int getScreenResolution(); protected abstract int getScreenResolution();
} }
} }

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

@ -1869,4 +1869,8 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
} }
public void setDesignerUIMode(){
DesignerUIModeConfig.getInstance().setAbsoluteMeasureUIMode();
}
} }

2
designer-form/src/main/java/com/fr/design/fit/PX.java → designer-base/src/main/java/com/fr/design/mainframe/PX.java

@ -1,4 +1,4 @@
package com.fr.design.fit; package com.fr.design.mainframe;
import com.fr.stable.Constants; import com.fr.stable.Constants;
import com.fr.stable.unit.LEN_UNIT; import com.fr.stable.unit.LEN_UNIT;

2
designer-form/src/main/java/com/fr/design/fit/PXReportLengthUNIT.java → designer-base/src/main/java/com/fr/design/mainframe/PXReportLengthUNIT.java

@ -1,4 +1,4 @@
package com.fr.design.fit; package com.fr.design.mainframe;
import com.fr.design.fun.impl.AbstractReportLengthUNITProvider; import com.fr.design.fun.impl.AbstractReportLengthUNITProvider;
import com.fr.stable.unit.UNIT; import com.fr.stable.unit.UNIT;

20
designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/ColorBackgroundQuickPane.java

@ -19,7 +19,17 @@ public class ColorBackgroundQuickPane extends BackgroundQuickPane {
public ColorBackgroundQuickPane() { public ColorBackgroundQuickPane() {
this.setLayout(FRGUIPaneFactory.createBorderLayout()); this.setLayout(FRGUIPaneFactory.createBorderLayout());
colorSelectBox = new NewColorSelectBox(100); colorSelectBox = new NewColorSelectBox(100) {
@Override
public boolean shouldResponseChangeListener() {
// ColorBackgroundQuickPane注册监听器ChangeListenerImpl的逻辑不能丢,因为里面有修改字段backgroundChange的逻辑.
// 所以在监听器重复注册以及UndoState重复生成时,应该保留ChangeListenerImpl, 而放弃NewColorSelectBox内部自己注册
// ChangeListener
// REPORT-63760 【主题切换】撤销以后,样式设置有问题
// REPORT-64006 【模板主题】单元格自定义样式背景色设置不生效
return false;
}
};
this.add(colorSelectBox, BorderLayout.NORTH); this.add(colorSelectBox, BorderLayout.NORTH);
} }
@ -41,14 +51,10 @@ public class ColorBackgroundQuickPane extends BackgroundQuickPane {
} }
@Override @Override
public boolean shouldResponseChangeListener() { public void registerChangeListener(final UIObserverListener listener) {
// NewColorSelectBox实现了UIObserver接口,这里就不要重复注册监听器了,以避免产生重复UndoState. this.colorSelectBox.addSelectChangeListener(new ChangeListenerImpl(listener));
return false;
} }
@Override
public void registerChangeListener(final UIObserverListener listener) { }
@Override @Override
/** /**
* 是否为ColorBackground 类型 * 是否为ColorBackground 类型

42
designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogAppender.java

@ -1,41 +1,41 @@
package com.fr.design.mainframe.loghandler; package com.fr.design.mainframe.loghandler;
import com.fr.third.apache.logging.log4j.Level;
import com.fr.third.apache.log4j.AppenderSkeleton; import com.fr.third.apache.logging.log4j.core.Filter;
import com.fr.third.apache.log4j.Level; import com.fr.third.apache.logging.log4j.core.Layout;
import com.fr.third.apache.log4j.spi.LoggingEvent; import com.fr.third.apache.logging.log4j.core.LogEvent;
import com.fr.third.apache.logging.log4j.core.appender.AbstractAppender;
import com.fr.third.apache.logging.log4j.core.config.Property;
import com.fr.third.apache.logging.log4j.core.layout.PatternLayout;
import java.io.Serializable;
import java.util.Date; import java.util.Date;
/** /**
* Created by Administrator on 2017/7/18 0018. * Created by Administrator on 2017/7/18 0018.
*/ */
public class DesignerLogAppender extends AppenderSkeleton { public class DesignerLogAppender extends AbstractAppender {
public DesignerLogAppender() { protected DesignerLogAppender(String name, Filter filter,
this.layout = new com.fr.third.apache.log4j.PatternLayout("%d{HH:mm:ss} %t %p [%c] %m%n"); Layout<? extends Serializable> layout,
boolean ignoreExceptions,
Property[] properties) {
super(name, filter, layout, ignoreExceptions, properties);
} }
protected void append(LoggingEvent event) { public static DesignerLogAppender createDesignerLogAppender() {
this.subAppend(event); return new DesignerLogAppender(DesignerLogAppender.class.getSimpleName(), null, PatternLayout.newBuilder().withPattern("%d{HH:mm:ss} %t %p [%c] %m%n %throwable{0}").build(), false, Property.EMPTY_ARRAY);
} }
public boolean requiresLayout() { @Override
return true; public void append(LogEvent event) {
this.subAppend(event);
} }
public synchronized void close() {
if (this.closed) {
return;
}
this.closed = true;
}
public void subAppend(LoggingEvent event) { public void subAppend(LogEvent event) {
synchronized (DesignerLogHandler.getInstance()) { synchronized (DesignerLogHandler.getInstance()) {
Level level = event.getLevel(); Level level = event.getLevel();
String msg = this.layout.format(event); String msg = (String) this.toSerializable(event);
DesignerLogHandler.getInstance().printRemoteLog(msg, level, new Date()); DesignerLogHandler.getInstance().printRemoteLog(msg, level, new Date());
} }
} }

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

@ -9,10 +9,9 @@ import com.fr.general.ComparatorUtils;
import com.fr.general.log.Log4jConfig; import com.fr.general.log.Log4jConfig;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.third.apache.log4j.Level;
import com.fr.third.apache.log4j.spi.LoggingEvent;
import com.fr.third.apache.log4j.spi.ThrowableInformation;
import com.fr.third.apache.logging.log4j.Level;
import com.fr.third.apache.logging.log4j.core.LogEvent;
import javax.swing.AbstractAction; import javax.swing.AbstractAction;
import javax.swing.ActionMap; import javax.swing.ActionMap;
import javax.swing.InputMap; import javax.swing.InputMap;
@ -128,7 +127,7 @@ public class DesignerLogHandler {
JPopupMenu jPopupMenu = new JPopupMenu(); JPopupMenu jPopupMenu = new JPopupMenu();
int logLevelInt = Log4jConfig.getInstance().getRootLevel().toInt(); int logLevelInt = Log4jConfig.getInstance().getRootLevel().intLevel();
if (logLevelInt <= DesignerLogger.INFO_INT) { if (logLevelInt <= DesignerLogger.INFO_INT) {
jPopupMenu.add(showInfo); jPopupMenu.add(showInfo);
jPopupMenu.add(showError); jPopupMenu.add(showError);
@ -240,23 +239,22 @@ public class DesignerLogHandler {
return resultPane; return resultPane;
} }
public void printStackTrace(LoggingEvent event) { public void printStackTrace(LogEvent event) {
int intLevel = event.getLevel().toInt(); int intLevel = event.getLevel().intLevel();
Date date = new Date(event.getTimeStamp()); Date date = new Date(event.getTimeMillis());
ThrowableInformation information = event.getThrowableInformation();
if (intLevel == DesignerLogger.INFO_INT && showInfo.isSelected()) { if (intLevel == DesignerLogger.INFO_INT && showInfo.isSelected()) {
printMessage(event.getRenderedMessage(), intLevel, date, information == null ? null : information.getThrowable()); printMessage(event.getMessage().getFormattedMessage(), intLevel, date, event.getThrown());
} else if (intLevel == DesignerLogger.ERROR_INT && showError.isSelected()) { } else if (intLevel == DesignerLogger.ERROR_INT && showError.isSelected()) {
printMessage(event.getRenderedMessage(), intLevel, date, information == null ? null : information.getThrowable()); printMessage(event.getMessage().getFormattedMessage(), intLevel, date, event.getThrown());
} else if (intLevel == DesignerLogger.WARN_INT && showServer.isSelected()) { } else if (intLevel == DesignerLogger.WARN_INT && showServer.isSelected()) {
printMessage(event.getRenderedMessage(), intLevel, date, information == null ? null : information.getThrowable()); printMessage(event.getMessage().getFormattedMessage(), intLevel, date, event.getThrown());
} }
} }
public void printStackTrace(String message, Level level, Date date) { public void printStackTrace(String message, Level level, Date date) {
int intLevel = level.toInt(); int intLevel = level.intLevel();
if (intLevel == DesignerLogger.INFO_INT && showInfo.isSelected()) { if (intLevel == DesignerLogger.INFO_INT && showInfo.isSelected()) {
printMessage(message, intLevel, date); printMessage(message, intLevel, date);
} else if (intLevel == DesignerLogger.ERROR_INT && showError.isSelected()) { } else if (intLevel == DesignerLogger.ERROR_INT && showError.isSelected()) {

41
designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogger.java

@ -1,26 +1,25 @@
package com.fr.design.mainframe.loghandler; package com.fr.design.mainframe.loghandler;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.third.apache.log4j.Level; import com.fr.third.apache.logging.log4j.Level;
import com.fr.third.apache.log4j.spi.LoggingEvent; import com.fr.third.apache.logging.log4j.core.LogEvent;
import com.fr.third.apache.log4j.spi.ThrowableInformation;
/** /**
* 设计器日志记录 * 设计器日志记录
*/ */
public class DesignerLogger { public class DesignerLogger {
public static final int INFO_INT = Level.INFO.toInt(); public static final int INFO_INT = Level.INFO.intLevel();
public static final int ERROR_INT = Level.ERROR.toInt(); public static final int ERROR_INT = Level.ERROR.intLevel();
public static final int WARN_INT = Level.WARN.toInt(); public static final int WARN_INT = Level.WARN.intLevel();
/** /**
* 记录LoggingEvent对象 * 记录LoggingEvent对象
* *
* @param event * @param event
*/ */
public static void log(LoggingEvent event) { public static void log(LogEvent event) {
if (event == null) { if (event == null) {
return; return;
} }
@ -30,29 +29,27 @@ public class DesignerLogger {
public enum LogParser { public enum LogParser {
DEFAULT(-1) { DEFAULT(-1) {
@Override @Override
public void log(LoggingEvent event) { public void log(LogEvent event) {
} }
}, },
INFO(Level.INFO.toInt()) { INFO(Level.INFO.intLevel()) {
@Override @Override
public void log(LoggingEvent event) { public void log(LogEvent event) {
FineLoggerFactory.getLogger().info(event.getRenderedMessage()); FineLoggerFactory.getLogger().info(event.getMessage().getFormattedMessage());
} }
}, },
WARN(Level.WARN.toInt()) { WARN(Level.WARN.intLevel()) {
@Override @Override
public void log(LoggingEvent event) { public void log(LogEvent event) {
ThrowableInformation information = event.getThrowableInformation(); FineLoggerFactory.getLogger().warn(event.getMessage().getFormattedMessage(), event.getThrown());
FineLoggerFactory.getLogger().warn(event.getRenderedMessage(), information == null ? null : information.getThrowable());
} }
}, },
ERROR(Level.ERROR.toInt()) { ERROR(Level.ERROR.intLevel()) {
@Override @Override
public void log(LoggingEvent event) { public void log(LogEvent event) {
ThrowableInformation information = event.getThrowableInformation(); FineLoggerFactory.getLogger().error(event.getMessage().getFormattedMessage(), event.getThrown());
FineLoggerFactory.getLogger().error(event.getRenderedMessage(), information == null ? null : information.getThrowable());
} }
}; };
private int level; private int level;
@ -65,8 +62,8 @@ public class DesignerLogger {
return level; return level;
} }
public static LogParser parse(LoggingEvent event) { public static LogParser parse(LogEvent event) {
int intLevel = event.getLevel().toInt(); int intLevel = event.getLevel().intLevel();
for (LogParser logParser : values()) { for (LogParser logParser : values()) {
if (logParser.getLevel() == intLevel) { if (logParser.getLevel() == intLevel) {
return logParser; return logParser;
@ -76,7 +73,7 @@ public class DesignerLogger {
} }
public void log(LoggingEvent event) { public void log(LogEvent event) {
} }
} }
} }

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

@ -0,0 +1,27 @@
package com.fr.design.mainframe.loghandler;
import com.fr.third.apache.log4j.spi.LoggingEvent;
import com.fr.third.apache.logging.log4j.Level;
import com.fr.third.apache.logging.log4j.core.LogEvent;
import com.fr.third.apache.logging.log4j.core.impl.Log4jLogEvent;
import com.fr.third.apache.logging.log4j.message.SimpleMessage;
/**
* 兼容log4j1和2之间logEvent之间的转换
*
* @author hades
* @version 11.0
* Created by hades on 2021/12/9
*/
public class LogEventConverter {
public static LogEvent convert(LoggingEvent loggingEvent) {
SimpleMessage message = new SimpleMessage(loggingEvent.getRenderedMessage());
return Log4jLogEvent.newBuilder().
setMessage(message).
setLevel(Level.getLevel(loggingEvent.getLevel().toString())).
build();
}
}

45
designer-base/src/main/java/com/fr/design/mainframe/theme/ThemedCellStyleListPane.java

@ -4,7 +4,6 @@ import com.fr.base.theme.TemplateTheme;
import com.fr.base.theme.settings.ThemedCellStyle; import com.fr.base.theme.settings.ThemedCellStyle;
import com.fr.design.beans.FurtherBasicBeanPane; import com.fr.design.beans.FurtherBasicBeanPane;
import com.fr.design.cell.CellRectangleStylePreviewPane; import com.fr.design.cell.CellRectangleStylePreviewPane;
import com.fr.design.cell.CellStylePreviewPane;
import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.gui.ibutton.UIRadioButton; import com.fr.design.gui.ibutton.UIRadioButton;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
@ -36,14 +35,10 @@ public class ThemedCellStyleListPane extends FurtherBasicBeanPane<ThemedCellStyl
private final JList<ThemedCellStyle> styleList; private final JList<ThemedCellStyle> styleList;
private ChangeListener changeListener; private ChangeListener changeListener;
public ThemedCellStyleListPane() { public ThemedCellStyleListPane(boolean supportInnerBorder) {
this(false);
}
public ThemedCellStyleListPane(boolean supportCellRange) {
defaultListModel = new DefaultListModel<>(); defaultListModel = new DefaultListModel<>();
styleList = new JList<>(defaultListModel); styleList = new JList<>(defaultListModel);
styleList.setCellRenderer(supportCellRange ? new RadioButtonListCellRangeRenderer() : new RadioButtonListCellRenderer()); styleList.setCellRenderer(new RadioButtonListCellRangeRenderer(supportInnerBorder));
styleList.setOpaque(false); styleList.setOpaque(false);
styleList.setBackground(null); styleList.setBackground(null);
styleList.addListSelectionListener(new ListSelectionListener() { styleList.addListSelectionListener(new ListSelectionListener() {
@ -115,44 +110,18 @@ public class ThemedCellStyleListPane extends FurtherBasicBeanPane<ThemedCellStyl
styleList.setModel(defaultListModel); styleList.setModel(defaultListModel);
} }
private static class RadioButtonListCellRenderer extends JPanel implements ListCellRenderer<ThemedCellStyle>, Serializable {
private final UIRadioButton button;
private final CellStylePreviewPane previewArea;
public RadioButtonListCellRenderer() {
super();
setLayout(new BorderLayout(20, 0));
setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
setPreferredSize(new Dimension(getPreferredSize().width, 40));
button = new UIRadioButton();
previewArea = new CellStylePreviewPane();
add(button, BorderLayout.WEST);
add(previewArea, BorderLayout.CENTER);
}
@Override
public Component getListCellRendererComponent(JList<? extends ThemedCellStyle> list, ThemedCellStyle value, int index, boolean isSelected, boolean cellHasFocus) {
button.setSelected(isSelected);
previewArea.setPaintText(value.getName());
previewArea.setStyle(value.getStyle());
return this;
}
}
private static class RadioButtonListCellRangeRenderer extends JPanel implements ListCellRenderer<ThemedCellStyle>, Serializable { private static class RadioButtonListCellRangeRenderer extends JPanel implements ListCellRenderer<ThemedCellStyle>, Serializable {
private final UIRadioButton button; private final UIRadioButton button;
private final CellRectangleStylePreviewPane previewArea; private final CellRectangleStylePreviewPane previewArea;
public RadioButtonListCellRangeRenderer() { public RadioButtonListCellRangeRenderer(boolean supportInnerBorder) {
super(); super();
setLayout(new BorderLayout(5, 0)); setLayout(new BorderLayout(5, 0));
setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0)); setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0));
setPreferredSize(new Dimension(getPreferredSize().width, 80));
button = new UIRadioButton(); button = new UIRadioButton();
button.setBorder(BorderFactory.createEmptyBorder()); button.setBorder(BorderFactory.createEmptyBorder());
previewArea = new CellRectangleStylePreviewPane(); previewArea = new CellRectangleStylePreviewPane(supportInnerBorder);
add(button, BorderLayout.WEST); add(button, BorderLayout.WEST);
add(previewArea, BorderLayout.CENTER); add(previewArea, BorderLayout.CENTER);
} }
@ -162,6 +131,12 @@ public class ThemedCellStyleListPane extends FurtherBasicBeanPane<ThemedCellStyl
button.setSelected(isSelected); button.setSelected(isSelected);
previewArea.setPlainText(value.getName()); previewArea.setPlainText(value.getName());
previewArea.setStyle(value.getStyle(), value.getCellBorderStyle()); previewArea.setStyle(value.getStyle(), value.getCellBorderStyle());
int preferredWidth = list.getWidth() - 15 - button.getPreferredSize().width;
preferredWidth = Math.max(0, preferredWidth);
int preferredHeight = 0;
previewArea.setPreferredSize(new Dimension(preferredWidth, preferredHeight));
return this; return this;
} }
} }

22
designer-base/src/main/java/com/fr/design/mainframe/theme/dialog/TemplateThemeDialog.java

@ -28,15 +28,14 @@ public abstract class TemplateThemeDialog extends JDialog {
private final JPanel contentContainer; private final JPanel contentContainer;
private final JPanel actionContainer; private final JPanel actionContainer;
private final int dialogContentHeight;
public TemplateThemeDialog(Window parent, String title, int contentWidth, int contentHeight) { public TemplateThemeDialog(Window parent, String title, int contentWidth, int contentHeight) {
super(parent, ModalityType.APPLICATION_MODAL); super(parent, ModalityType.APPLICATION_MODAL);
setTitle(title); setTitle(title);
setResizable(false); setResizable(false);
setLayout(FRGUIPaneFactory.createBorderLayout()); setLayout(FRGUIPaneFactory.createBorderLayout());
dialogContentHeight = contentHeight + DIALOG_BOTTOM_ACTION_BAR_HEIGHT;
int dialogContentHeight = contentHeight + DIALOG_BOTTOM_ACTION_BAR_HEIGHT;
int dialogWindowHeight = dialogContentHeight + DIALOG_TITLE_HEIGHT; int dialogWindowHeight = dialogContentHeight + DIALOG_TITLE_HEIGHT;
setSize(new Dimension(contentWidth, dialogWindowHeight)); setSize(new Dimension(contentWidth, dialogWindowHeight));
@ -54,6 +53,12 @@ public abstract class TemplateThemeDialog extends JDialog {
setContentPane(contentContainer); setContentPane(contentContainer);
} }
@Override
public void doLayout() {
this.setSize(new Dimension(this.getWidth(), dialogContentHeight + this.getInsets().top));
super.doLayout();
}
protected void setupContentPane() { protected void setupContentPane() {
contentContainer.add(createContentPane(), BorderLayout.CENTER, 0); contentContainer.add(createContentPane(), BorderLayout.CENTER, 0);
} }
@ -63,10 +68,11 @@ public abstract class TemplateThemeDialog extends JDialog {
} }
protected UIButton[] createLeftButtons() { protected UIButton[] createLeftButtons() {
return new UIButton[] {}; return new UIButton[]{};
} }
protected UIButton[] createRightButtons() { protected UIButton[] createRightButtons() {
return new UIButton[] {}; return new UIButton[]{};
} }
public void setupActionButtons() { public void setupActionButtons() {
@ -89,7 +95,7 @@ public abstract class TemplateThemeDialog extends JDialog {
} }
private JPanel createActionsContainer(int align, UIButton... buttons) { private JPanel createActionsContainer(int align, UIButton... buttons) {
JPanel container = new JPanel(new FlowLayout(align, DIALOG_BOTTOM_ACTION_BUTTON_GAP, 0)); JPanel container = new JPanel(new FlowLayout(align, DIALOG_BOTTOM_ACTION_BUTTON_GAP, 0));
int paddingVertical = getPaddingVertical(); int paddingVertical = getPaddingVertical();
container.setBorder(BorderFactory.createEmptyBorder(paddingVertical, 0, paddingVertical, 0)); container.setBorder(BorderFactory.createEmptyBorder(paddingVertical, 0, paddingVertical, 0));
@ -97,7 +103,7 @@ public abstract class TemplateThemeDialog extends JDialog {
return container; return container;
} }
for (UIButton button: buttons) { for (UIButton button : buttons) {
if (button != null) { if (button != null) {
button.setPreferredSize(new Dimension(button.getPreferredSize().width, DIALOG_BOTTOM_ACTION_BUTTON_HEIGHT)); button.setPreferredSize(new Dimension(button.getPreferredSize().width, DIALOG_BOTTOM_ACTION_BUTTON_HEIGHT));
container.add(button); container.add(button);
@ -111,7 +117,7 @@ public abstract class TemplateThemeDialog extends JDialog {
return createActionsContainer(FlowLayout.RIGHT, buttons); return createActionsContainer(FlowLayout.RIGHT, buttons);
} }
private int getPaddingVertical(){ private int getPaddingVertical() {
return (DIALOG_BOTTOM_ACTION_BAR_HEIGHT - DIALOG_BOTTOM_ACTION_BUTTON_HEIGHT) / 2; return (DIALOG_BOTTOM_ACTION_BAR_HEIGHT - DIALOG_BOTTOM_ACTION_BUTTON_HEIGHT) / 2;
} }

8
designer-base/src/main/java/com/fr/design/mainframe/theme/edit/cell/CellStyleEditPane.java

@ -116,9 +116,11 @@ public class CellStyleEditPane extends MultiTabPane<ThemedCellStyle> {
jPanel.setLayout(new BorderLayout(0, 4)); jPanel.setLayout(new BorderLayout(0, 4));
JPanel previewPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); JPanel previewPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
previewArea = new CellRectangleStylePreviewPane(); previewArea = new CellRectangleStylePreviewPane(true);
previewArea.setPreferredSize(new Dimension(223, 60)); previewArea.setPreferredSize(new Dimension(215, 52));
previewPane.setBorder(BorderUtils.createTitleBorder(i18nText("Fine-Design_Basic_Preview"))); previewPane.setBorder(BorderFactory.createCompoundBorder(
BorderUtils.createTitleBorder(i18nText("Fine-Design_Basic_Preview")),
BorderFactory.createEmptyBorder(4, 4, 4, 4)));
previewPane.add(previewArea, BorderLayout.CENTER); previewPane.add(previewArea, BorderLayout.CENTER);
this.add(previewPane, BorderLayout.NORTH); this.add(previewPane, BorderLayout.NORTH);

2
designer-base/src/main/java/com/fr/design/mainframe/theme/edit/ui/ColorListPane.java

@ -139,7 +139,7 @@ public class ColorListPane extends JPanel implements UIObserver {
return true; return true;
} }
private static class ColorButton extends AbstractSelectBox<Color> { public static class ColorButton extends AbstractSelectBox<Color> {
private Color color; private Color color;
private NewColorSelectPane colorPane; private NewColorSelectPane colorPane;
private ChangeListener changeListener; private ChangeListener changeListener;

5
designer-base/src/main/java/com/fr/design/mainframe/theme/preview/ReportThemePreviewPane.java

@ -45,8 +45,9 @@ public class ReportThemePreviewPane extends TemplateThemePreviewPane<ReportTheme
chartPreviewPane.populate(initColumnChart()); chartPreviewPane.populate(initColumnChart());
chartPreviewPane.setCallbackEvent(this); chartPreviewPane.setCallbackEvent(this);
reportPreviewPane = new ECReportPreviewPane(); reportPreviewPane = new ECReportPreviewPane();
this.add(reportPreviewPane, BorderLayout.CENTER); reportPreviewPane.setPreferredSize(new Dimension(615, 297));
this.add(chartPreviewPane, BorderLayout.SOUTH); this.add(reportPreviewPane, BorderLayout.NORTH);
this.add(chartPreviewPane, BorderLayout.CENTER);
} }
@Override @Override

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

@ -8,8 +8,10 @@ import com.fr.stable.EncodeConstants;
import com.fr.stable.ProductConstants; import com.fr.stable.ProductConstants;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.startup.FineWebApplicationInitializer; import com.fr.startup.FineWebApplicationInitializer;
import com.fr.third.guava.collect.Sets;
import com.fr.third.springframework.web.SpringServletContainerInitializer; import com.fr.third.springframework.web.SpringServletContainerInitializer;
import com.fr.third.springframework.web.context.support.AnnotationConfigWebApplicationContext; import com.fr.third.springframework.web.context.support.AnnotationConfigWebApplicationContext;
import com.fr.web.socketio.WebSocketEndpoint;
import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContext;
import org.apache.catalina.Context; import org.apache.catalina.Context;
import org.apache.catalina.LifecycleException; import org.apache.catalina.LifecycleException;
@ -17,6 +19,7 @@ import org.apache.catalina.Wrapper;
import org.apache.catalina.loader.WebappLoader; import org.apache.catalina.loader.WebappLoader;
import org.apache.catalina.startup.Tomcat; import org.apache.catalina.startup.Tomcat;
import org.apache.catalina.webresources.StandardRoot; import org.apache.catalina.webresources.StandardRoot;
import org.apache.tomcat.websocket.server.WsSci;
import java.io.File; import java.io.File;
import java.util.HashSet; import java.util.HashSet;
@ -92,6 +95,7 @@ public class FineEmbedServerActivator extends Activator {
Set<Class<?>> classes = new HashSet<Class<?>>(); Set<Class<?>> classes = new HashSet<Class<?>>();
classes.add(FineWebApplicationInitializer.class); classes.add(FineWebApplicationInitializer.class);
context.addServletContainerInitializer(initializer, classes); context.addServletContainerInitializer(initializer, classes);
context.addServletContainerInitializer(new WsSci(), Sets.newHashSet(WebSocketEndpoint.class));
} }
// tomcat的maxPostSize会影响到post参数获取,默认2M // tomcat的maxPostSize会影响到post参数获取,默认2M

BIN
designer-base/src/main/resources/com/fr/design/images/sort/add.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 141 B

19
designer-base/src/main/resources/com/fr/design/images/sort/asc.svg

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="16px" height="16px" viewBox="0 0 16 16" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>升序备份</title>
<g id="页面-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="画板" transform="translate(-641.000000, -632.000000)">
<g id="升序备份" transform="translate(641.000000, 632.000000)">
<rect id="矩形" x="0" y="0" width="16" height="16"></rect>
<g id="编组-2" transform="translate(1.000000, 2.000000)" fill="#{fillColor}">
<rect id="矩形" x="10.5" y="1" width="1" height="11"></rect>
<path d="M11.16,0.213333333 L13.76,3.68 C13.8262742,3.76836556 13.8083656,3.89372583 13.72,3.96 C13.6853808,3.98596443 13.643274,4 13.6,4 L8.4,4 C8.28954305,4 8.2,3.91045695 8.2,3.8 C8.2,3.75672596 8.21403557,3.71461923 8.24,3.68 L10.84,0.213333333 C10.9062742,0.124967773 11.0316344,0.107059163 11.12,0.173333333 C11.1351611,0.184704183 11.1486292,0.1981722 11.16,0.213333333 Z" id="三角形"></path>
<rect id="矩形" x="0" y="4" width="7" height="1"></rect>
<rect id="矩形备份-3" x="0" y="0.5" width="6" height="1"></rect>
<rect id="矩形备份" x="0" y="7.5" width="8" height="1"></rect>
<rect id="矩形备份-2" x="0" y="11" width="9" height="1"></rect>
</g>
</g>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.5 KiB

17
designer-base/src/main/resources/com/fr/design/images/sort/des.svg

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="16px" height="16px" viewBox="0 0 16 16" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>降序</title>
<g id="页面-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="画板" transform="translate(-641.000000, -662.000000)">
<g id="降序" transform="translate(641.000000, 662.000000)">
<rect id="矩形" transform="translate(8.000000, 8.000000) scale(1, -1) translate(-8.000000, -8.000000) " x="0" y="0" width="16" height="16"></rect>
<rect id="矩形" fill="#{fillColor}" transform="translate(12.000000, 7.500000) scale(1, -1) translate(-12.000000, -7.500000) " x="11.5" y="2" width="1" height="11"></rect>
<path d="M12.16,10.2133333 L14.76,13.68 C14.8262742,13.7683656 14.8083656,13.8937258 14.72,13.96 C14.6853808,13.9859644 14.643274,14 14.6,14 L9.4,14 C9.28954305,14 9.2,13.9104569 9.2,13.8 C9.2,13.756726 9.21403557,13.7146192 9.24,13.68 L11.84,10.2133333 C11.9062742,10.1249678 12.0316344,10.1070592 12.12,10.1733333 C12.1351611,10.1847042 12.1486292,10.1981722 12.16,10.2133333 Z" id="三角形" fill="#{fillColor}" transform="translate(12.000000, 12.000000) scale(1, -1) translate(-12.000000, -12.000000) "></path>
<rect id="矩形" fill="#{fillColor}" transform="translate(4.500000, 9.500000) scale(1, -1) translate(-4.500000, -9.500000) " x="1" y="9" width="7" height="1"></rect>
<rect id="矩形备份-3" fill="#{fillColor}" transform="translate(4.000000, 13.000000) scale(1, -1) translate(-4.000000, -13.000000) " x="1" y="12.5" width="6" height="1"></rect>
<rect id="矩形备份" fill="#{fillColor}" transform="translate(5.000000, 6.000000) scale(1, -1) translate(-5.000000, -6.000000) " x="1" y="5.5" width="8" height="1"></rect>
<rect id="矩形备份-2" fill="#{fillColor}" transform="translate(5.500000, 2.500000) scale(1, -1) translate(-5.500000, -2.500000) " x="1" y="2" width="9" height="1"></rect>
</g>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.1 KiB

BIN
designer-base/src/main/resources/com/fr/design/images/sort/down_arrow.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 175 B

BIN
designer-base/src/main/resources/com/fr/design/images/sort/left_arrow.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 166 B

41
designer-base/src/main/resources/com/fr/design/images/sort/nosort.svg

@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="16px" height="16px" viewBox="0 0 16 16" version="1.1" xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
<title>不排序</title>
<g id="页面-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="画板" transform="translate(-641.000000, -692.000000)">
<g id="不排序" transform="translate(641.000000, 692.000000)">
<rect id="矩形" transform="translate(8.000000, 8.000000) scale(1, -1) translate(-8.000000, -8.000000) "
x="0" y="0" width="16" height="16"></rect>
<g id="编组-5" transform="translate(9.000000, 8.000000)" fill="#{fillColor}">
<rect id="矩形"
transform="translate(3.000000, 2.500000) scale(1, -1) translate(-3.000000, -2.500000) "
x="2.5" y="0" width="1" height="5"></rect>
<path d="M3.16,2.21333333 L5.76,5.68 C5.82627417,5.76836556 5.80836556,5.89372583 5.72,5.96 C5.68538077,5.98596443 5.64327404,6 5.6,6 L0.4,6 C0.28954305,6 0.2,5.91045695 0.2,5.8 C0.2,5.75672596 0.214035574,5.71461923 0.24,5.68 L2.84,2.21333333 C2.90627417,2.12496777 3.03163444,2.10705916 3.12,2.17333333 C3.13516113,2.18470418 3.14862915,2.1981722 3.16,2.21333333 Z"
id="三角形"
transform="translate(3.000000, 4.000000) scale(1, -1) translate(-3.000000, -4.000000) "></path>
</g>
<g id="编组-5"
transform="translate(12.000000, 4.000000) scale(1, -1) translate(-12.000000, -4.000000) translate(9.000000, 1.000000)"
fill="#{fillColor}">
<rect id="矩形"
transform="translate(3.000000, 2.500000) scale(1, -1) translate(-3.000000, -2.500000) "
x="2.5" y="0" width="1" height="5"></rect>
<path d="M3.16,2.21333333 L5.76,5.68 C5.82627417,5.76836556 5.80836556,5.89372583 5.72,5.96 C5.68538077,5.98596443 5.64327404,6 5.6,6 L0.4,6 C0.28954305,6 0.2,5.91045695 0.2,5.8 C0.2,5.75672596 0.214035574,5.71461923 0.24,5.68 L2.84,2.21333333 C2.90627417,2.12496777 3.03163444,2.10705916 3.12,2.17333333 C3.13516113,2.18470418 3.14862915,2.1981722 3.16,2.21333333 Z"
id="三角形"
transform="translate(3.000000, 4.000000) scale(1, -1) translate(-3.000000, -4.000000) "></path>
</g>
<rect id="矩形" fill="#{fillColor}"
transform="translate(4.500000, 9.500000) scale(1, -1) translate(-4.500000, -9.500000) " x="1"
y="9" width="7" height="1"></rect>
<rect id="矩形备份-3" fill="#{fillColor}" x="1" y="12.5" width="6" height="1"></rect>
<rect id="矩形备份" fill="#{fillColor}"
transform="translate(4.500000, 6.000000) scale(1, -1) translate(-4.500000, -6.000000) " x="1"
y="5.5" width="7" height="1"></rect>
<rect id="矩形备份-2" fill="#{fillColor}"
transform="translate(4.000000, 2.500000) scale(1, -1) translate(-4.000000, -2.500000) " x="1"
y="2" width="6" height="1"></rect>
</g>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 3.3 KiB

26
designer-chart/src/main/java/com/fr/van/chart/config/DefaultStyleConstants.java

@ -18,35 +18,35 @@ import java.awt.Font;
* Created by shine on 2021/6/25 * Created by shine on 2021/6/25
*/ */
public class DefaultStyleConstants { public class DefaultStyleConstants {
static final FRFont TITLE = FRFont.getInstance(ChartBaseUtils.getLocalDefaultFont("Microsoft YaHei"), Font.BOLD, 14, new Color(241, 246, 255)); static final FRFont TITLE = FRFont.getInstance(ChartBaseUtils.getLocalDefaultFont("Microsoft YaHei"), Font.BOLD, 19, new Color(241, 246, 255));
static final FRFont LEGEND = FRFont.getInstance(ChartBaseUtils.getLocalDefaultFont("Microsoft YaHei"), Font.PLAIN, 9, new Color(159, 173, 191)); static final FRFont LEGEND = FRFont.getInstance(ChartBaseUtils.getLocalDefaultFont("Microsoft YaHei"), Font.PLAIN, 12, new Color(159, 173, 191));
static final FRFont AXIS_LABEL = FRFont.getInstance(ChartBaseUtils.getLocalDefaultFont("Microsoft YaHei"), Font.PLAIN, 9, new Color(159, 173, 191)); static final FRFont AXIS_LABEL = FRFont.getInstance(ChartBaseUtils.getLocalDefaultFont("Microsoft YaHei"), Font.PLAIN, 12, new Color(159, 173, 191));
static final FRFont AXIS_TITLE = FRFont.getInstance(ChartBaseUtils.getLocalDefaultFont("Microsoft YaHei"), Font.PLAIN, 9, new Color(200, 211, 228)); static final FRFont AXIS_TITLE = FRFont.getInstance(ChartBaseUtils.getLocalDefaultFont("Microsoft YaHei"), Font.PLAIN, 12, new Color(200, 211, 228));
static final Color AXIS_LINE = new Color(46, 75, 102); static final Color AXIS_LINE = new Color(46, 75, 102);
static final Color GRID_LINE = new Color(30, 55, 78); static final Color GRID_LINE = new Color(30, 55, 78);
static final FRFont ALERT_FONT = FRFont.getInstance(ChartBaseUtils.getLocalDefaultFont("Microsoft YaHei"), Font.PLAIN, 9, new Color(255, 0, 0)); static final FRFont ALERT_FONT = FRFont.getInstance(ChartBaseUtils.getLocalDefaultFont("Microsoft YaHei"), Font.PLAIN, 12, new Color(255, 0, 0));
static final FRFont DATA_SHEET = FRFont.getInstance(ChartBaseUtils.getLocalDefaultFont("Microsoft YaHei"), Font.PLAIN, 9, new Color(159, 173, 191)); static final FRFont DATA_SHEET = FRFont.getInstance(ChartBaseUtils.getLocalDefaultFont("Microsoft YaHei"), Font.PLAIN, 12, new Color(159, 173, 191));
static final Color DATA_SHEET_BORDER = new Color(46, 75, 102); static final Color DATA_SHEET_BORDER = new Color(46, 75, 102);
static final Color BORDER = Color.BLACK; static final Color BORDER = Color.BLACK;
static final int BORDER_WIDTH = Constants.LINE_NONE; static final int BORDER_WIDTH = Constants.LINE_NONE;
static final int SPECIAL_BORDER_WIDTH = Constants.LINE_THIN; static final int SPECIAL_BORDER_WIDTH = Constants.LINE_THIN;
static final FRFont PIE_CATEGORY_LABEL = FRFont.getInstance(ChartBaseUtils.getLocalDefaultFont("Microsoft YaHei"), Font.PLAIN, 10, new Color(232, 232, 232)); static final FRFont PIE_CATEGORY_LABEL = FRFont.getInstance(ChartBaseUtils.getLocalDefaultFont("Microsoft YaHei"), Font.PLAIN, 13, new Color(232, 232, 232));
static final Color GAUGE_PANE_BACK_COLOR = null; static final Color GAUGE_PANE_BACK_COLOR = null;
static final Color GAUGE_HINGE = null; static final Color GAUGE_HINGE = null;
static final Color GAUGE_PANE_BACK_COLOR_4_RING = new Color(72, 73, 79); static final Color GAUGE_PANE_BACK_COLOR_4_RING = new Color(72, 73, 79);
static final Color GAUGE_SLOT_BACKGROUND_COLOR = new Color(72, 73, 79); static final Color GAUGE_SLOT_BACKGROUND_COLOR = new Color(72, 73, 79);
private static final String FONT_NAME = ChartBaseUtils.getLocalDefaultFont("verdana"); private static final String FONT_NAME = ChartBaseUtils.getLocalDefaultFont("verdana");
static final FRFont THERMOMETER_LABEL_FONT = FRFont.getInstance(FONT_NAME, Font.BOLD, 9, new Color(232, 232, 232));//试管仪表盘标签的默认样式 static final FRFont THERMOMETER_LABEL_FONT = FRFont.getInstance(FONT_NAME, Font.BOLD, 12, new Color(232, 232, 232));//试管仪表盘标签的默认样式
static final FRFont THERMOMETER_AXIS_LABEL = FRFont.getInstance(FONT_NAME, Font.PLAIN, 8, new Color(159, 173, 191)); static final FRFont THERMOMETER_AXIS_LABEL = FRFont.getInstance(FONT_NAME, Font.PLAIN, 11, new Color(159, 173, 191));
static final FRFont RING_VALUE_LABEL_FONT = FRFont.getInstance(FONT_NAME, Font.PLAIN, ChartConstants.AUTO_FONT_SIZE, new Color(232, 232, 232));//百分比圆环仪表盘值标签的默认样式 static final FRFont RING_VALUE_LABEL_FONT = FRFont.getInstance(FONT_NAME, Font.PLAIN, ChartConstants.AUTO_FONT_SIZE, new Color(232, 232, 232));//百分比圆环仪表盘值标签的默认样式
static final FRFont POINTER_VALUE_LABEL_FONT = FRFont.getInstance(FONT_NAME, Font.PLAIN, ChartConstants.AUTO_FONT_SIZE, new Color(232, 232, 232));//多指针仪表盘值标签的默认样式 static final FRFont POINTER_VALUE_LABEL_FONT = FRFont.getInstance(FONT_NAME, Font.PLAIN, ChartConstants.AUTO_FONT_SIZE, new Color(232, 232, 232));//多指针仪表盘值标签的默认样式
static final FRFont POINTER_CATE_LABEL_FONT = FRFont.getInstance(FONT_NAME, Font.PLAIN, 10, new Color(232, 232, 232));//多指针仪表盘分类标签的默认样式 static final FRFont POINTER_CATE_LABEL_FONT = FRFont.getInstance(FONT_NAME, Font.PLAIN, 13, new Color(232, 232, 232));//多指针仪表盘分类标签的默认样式
static final Color MAP_NULL_VALUE_COLOR = new Color(168, 168, 168); static final Color MAP_NULL_VALUE_COLOR = new Color(168, 168, 168);
static final Color MAP_BORDER = Color.BLACK; static final Color MAP_BORDER = Color.BLACK;
@ -56,12 +56,6 @@ public class DefaultStyleConstants {
static final Color DRILL_MAP_DRILL_TOOLS_BACK = Color.BLACK; static final Color DRILL_MAP_DRILL_TOOLS_BACK = Color.BLACK;
static final float DRILL_MAP_DRILL_TOOLS_BACK_OPACITY = 0.8f; static final float DRILL_MAP_DRILL_TOOLS_BACK_OPACITY = 0.8f;
//todo vancharts
private static final Color GANTT_OUT_LINE = GRID_LINE;
private static final FRFont GANTT_LABEL = FRFont.getInstance(ChartBaseUtils.getLocalDefaultFont("Microsoft YaHei"), Font.PLAIN, 8, new Color(217, 217, 217));
private static final Color GANTT_BORDER_LINE = new Color(30, 36, 58);
private static final Color GAUGE_TICK = new Color(39, 49, 71);
static final Background BACK = null; static final Background BACK = null;
//新特新 //新特新

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

@ -11,6 +11,7 @@ import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper; import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPane; import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPane;
import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPaneWithAuto;
import com.fr.design.ui.ModernUIPane; import com.fr.design.ui.ModernUIPane;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.plugin.chart.base.AttrTooltipContent; import com.fr.plugin.chart.base.AttrTooltipContent;
@ -21,6 +22,7 @@ import com.fr.plugin.chart.base.format.AttrTooltipFormat;
import com.fr.plugin.chart.base.format.AttrTooltipPercentFormat; import com.fr.plugin.chart.base.format.AttrTooltipPercentFormat;
import com.fr.plugin.chart.base.format.AttrTooltipSeriesFormat; import com.fr.plugin.chart.base.format.AttrTooltipSeriesFormat;
import com.fr.plugin.chart.base.format.AttrTooltipValueFormat; import com.fr.plugin.chart.base.format.AttrTooltipValueFormat;
import com.fr.plugin.chart.type.FontAutoType;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.van.chart.designer.TableLayout4VanChartHelper; import com.fr.van.chart.designer.TableLayout4VanChartHelper;
import com.fr.van.chart.designer.component.format.CategoryNameFormatPaneWithCheckBox; import com.fr.van.chart.designer.component.format.CategoryNameFormatPaneWithCheckBox;
@ -315,7 +317,7 @@ public class VanChartTooltipContentPane extends BasicBeanPane<AttrTooltipContent
Toolkit.i18nText("Fine-Design_Chart_Custom") Toolkit.i18nText("Fine-Design_Chart_Custom")
}); });
textAttrPane = new ChartTextAttrPane() { textAttrPane = new ChartTextAttrPaneWithAuto(FontAutoType.COLOR) {
protected Component[][] getComponents(JPanel buttonPane) { protected Component[][] getComponents(JPanel buttonPane) {
return new Component[][]{ return new Component[][]{
new Component[]{null, null}, new Component[]{null, null},

115
designer-form/src/main/java/com/fr/design/actions/NewFormMobileAttrAction.java

@ -1,115 +0,0 @@
package com.fr.design.actions;
import com.fr.base.iofile.attr.MobileOnlyTemplateAttrMark;
import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.creator.XWAbsoluteBodyLayout;
import com.fr.design.designer.creator.XWFitLayout;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.fit.NewJForm;
import com.fr.design.fit.common.AdaptiveSwitchUtil;
import com.fr.design.fit.common.TemplateTool;
import com.fr.design.form.mobile.FormMobileAttrPane;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.FormArea;
import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.JForm;
import com.fr.design.mainframe.WidgetPropertyPane;
import com.fr.file.FILE;
import com.fr.form.main.Form;
import com.fr.form.main.mobile.FormMobileAttr;
import com.fr.record.analyzer.EnableMetrics;
import com.fr.stable.StringUtils;
import java.awt.event.ActionEvent;
/**
* Created by fanglei on 2016/11/14.
*/
@EnableMetrics
public class NewFormMobileAttrAction extends FormMobileAttrAction {
public NewFormMobileAttrAction(JForm jf) {
super(jf);
}
/**
* 执行动作
*
* @return 是否执行成功
*/
@Override
public void actionPerformed(ActionEvent e) {
final JForm jf = getEditingComponent();
if (jf == null) {
return;
}
final Form formTpl = jf.getTarget();
FormMobileAttr mobileAttr = formTpl.getFormMobileAttr();
final FormMobileAttrPane mobileAttrPane = new FormMobileAttrPane();
mobileAttrPane.populateBean(mobileAttr);
final boolean oldMobileOnly = mobileAttr.isMobileOnly();
final boolean oldAdaptive = mobileAttr.isAdaptivePropertyAutoMatch();
BasicDialog dialog = mobileAttrPane.showWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() {
@Override
public void doOk() {
FormMobileAttr formMobileAttr = mobileAttrPane.updateBean();
if (formMobileAttr.isMobileOnly() && jf.getTarget().getAttrMark(MobileOnlyTemplateAttrMark.XML_TAG) == null) {
// 如果是老模板,选择手机专属之后需要另存为
FILE editingFILE = jf.getEditingFILE();
if (editingFILE != null && editingFILE.exists()) {
String fileName = editingFILE.getName().substring(0, editingFILE.getName().length() - jf.suffix().length()) + "_mobile";
if (!jf.saveAsTemplate(true, fileName)) {
return;
}
}
// 放到后面。如果提前 return 了,则仍然处于未设置状态,不要添加
jf.getTarget().addAttrMark(new MobileOnlyTemplateAttrMark());
}
// 设置移动端属性并刷新界面
formTpl.setFormMobileAttr(formMobileAttr); // 会调整 body 的自适应布局,放到最后
boolean changeSize = (!oldMobileOnly && formMobileAttr.isMobileOnly()) || (oldMobileOnly && !formMobileAttr.isMobileOnly());
if (changeSize) {
((FormArea)jf.getFormDesign().getParent()).onMobileAttrModified();
}
//改变布局为自适应布局,只在移动端属性设置保存后改变一次
boolean changeLayout = !oldAdaptive && formMobileAttr.isAdaptivePropertyAutoMatch();
if (changeLayout) {
jf.getFormDesign().getSelectionModel().setSelectedCreator(jf.getFormDesign().getRootComponent());
doChangeBodyLayout();
WidgetPropertyPane.getInstance().refreshDockingView();
}
jf.fireTargetModified();
FILE editingFILE = jf.getEditingFILE();
if(editingFILE != null && editingFILE.exists()){
JForm jForm = getEditingComponent();
TemplateTool.saveForm(jForm);
if (jForm instanceof NewJForm) {
AdaptiveSwitchUtil.switch2OldUI();
}
}else {
AdaptiveSwitchUtil.switch2OldUIMode();
NewJForm mobileJForm = new NewJForm(jf.getTarget(), jf.getEditingFILE());
//设置临时的id,和新建的模板区分
mobileJForm.getTarget().setTemplateID(StringUtils.EMPTY);
TemplateTool.resetTabPaneEditingTemplate(mobileJForm);
TemplateTool.activeAndResizeTemplate(mobileJForm);
}
}
});
dialog.setVisible(true);
}
private void doChangeBodyLayout(){
FormDesigner formDesigner = WidgetPropertyPane.getInstance().getEditingFormDesigner();
XLayoutContainer rootLayout = formDesigner.getRootComponent();
if (rootLayout.getComponentCount() == 1 && rootLayout.getXCreator(0).acceptType(XWAbsoluteBodyLayout.class)) {
rootLayout = (XWAbsoluteBodyLayout) rootLayout.getXCreator(0);
}
((XWFitLayout)formDesigner.getRootComponent()).switch2FitBodyLayout(rootLayout);
}
}

109
designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteLayout.java

@ -4,15 +4,11 @@
package com.fr.design.designer.creator; package com.fr.design.designer.creator;
import com.fr.base.GraphHelper; import com.fr.base.GraphHelper;
import com.fr.design.designer.beans.AdapterBus;
import com.fr.design.designer.beans.ComponentAdapter;
import com.fr.design.designer.beans.LayoutAdapter; import com.fr.design.designer.beans.LayoutAdapter;
import com.fr.design.designer.beans.adapters.layout.FRAbsoluteLayoutAdapter; import com.fr.design.designer.beans.adapters.layout.FRAbsoluteLayoutAdapter;
import com.fr.design.designer.beans.location.Direction; import com.fr.design.designer.beans.location.Direction;
import com.fr.design.designer.beans.models.SelectionModel;
import com.fr.design.designer.creator.cardlayout.XWTabFitLayout; import com.fr.design.designer.creator.cardlayout.XWTabFitLayout;
import com.fr.design.designer.properties.mobile.MobileBooKMarkUsePropertyUI; import com.fr.design.designer.properties.mobile.MobileBooKMarkUsePropertyUI;
import com.fr.design.fit.DesignerUIModeConfig;
import com.fr.design.form.layout.FRAbsoluteLayout; import com.fr.design.form.layout.FRAbsoluteLayout;
import com.fr.design.form.util.FormDesignerUtils; import com.fr.design.form.util.FormDesignerUtils;
import com.fr.design.fun.WidgetPropertyUIProvider; import com.fr.design.fun.WidgetPropertyUIProvider;
@ -26,6 +22,7 @@ import com.fr.form.ui.Widget;
import com.fr.form.ui.container.WAbsoluteLayout; import com.fr.form.ui.container.WAbsoluteLayout;
import com.fr.form.ui.container.WAbsoluteLayout.BoundsWidget; import com.fr.form.ui.container.WAbsoluteLayout.BoundsWidget;
import com.fr.form.ui.container.WLayout; import com.fr.form.ui.container.WLayout;
import com.fr.general.FRScreen;
import com.fr.stable.AssistUtils; import com.fr.stable.AssistUtils;
import com.fr.stable.Constants; import com.fr.stable.Constants;
@ -34,7 +31,6 @@ import java.awt.Cursor;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.Graphics; import java.awt.Graphics;
import java.awt.Rectangle; import java.awt.Rectangle;
import java.awt.Toolkit;
import java.awt.event.ContainerEvent; import java.awt.event.ContainerEvent;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.beans.IntrospectionException; import java.beans.IntrospectionException;
@ -51,9 +47,7 @@ public class XWAbsoluteLayout extends XLayoutContainer {
private int minHeight = WLayout.MIN_HEIGHT; private int minHeight = WLayout.MIN_HEIGHT;
private static final Color OUTER_BORDER_COLOR = new Color(65, 155, 249, 30); private static final Color OUTER_BORDER_COLOR = new Color(65, 155, 249, 30);
private static final Color INNER_BORDER_COLOR = new Color(65, 155, 249); private static final Color INNER_BORDER_COLOR = new Color(65, 155, 249);
private static final double DEFAULT_CONTAINER_PERCENT = 1.0D;
//由于屏幕分辨率不同,界面上的容器大小可能不是默认的100%,此时拖入组件时,保存的大小按照100%时的计算
protected double containerPercent = 1.0;
private HashMap<Connector, XConnector> xConnectorMap; private HashMap<Connector, XConnector> xConnectorMap;
@ -73,8 +67,6 @@ public class XWAbsoluteLayout extends XLayoutContainer {
connector = widget.getConnectorIndex(i); connector = widget.getConnectorIndex(i);
xConnectorMap.put(connector, new XConnector(connector, this)); xConnectorMap.put(connector, new XConnector(connector, this));
} }
initPercent(widget);
} }
/** /**
@ -87,36 +79,6 @@ public class XWAbsoluteLayout extends XLayoutContainer {
return new Dimension(500, 300); return new Dimension(500, 300);
} }
//根据屏幕大小来确定显示的百分比, 1440*900默认100%, 1366*768缩放90%
private void initPercent(WAbsoluteLayout widget) {
Toolkit toolkit = Toolkit.getDefaultToolkit();
Dimension scrnsize = toolkit.getScreenSize();
double screenValue = DesignerUIModeConfig.getInstance().getDesignScreenByDimension(scrnsize).getValue();
if (!AssistUtils.equals(screenValue, FormArea.DEFAULT_SLIDER)) {
this.setContainerPercent(screenValue / FormArea.DEFAULT_SLIDER);
}
}
/**
* 返回容器大小的百分比
*
* @return the containerPercent
*/
public double getContainerPercent() {
return containerPercent;
}
/**
* 设置容器大小的百分比
*
* @param containerPercent the containerPercent to set
*/
public void setContainerPercent(double containerPercent) {
this.containerPercent = containerPercent;
minWidth = (int) (XWAbsoluteLayout.MIN_WIDTH * containerPercent);
minHeight = (int) (XWAbsoluteLayout.MIN_HEIGHT * containerPercent);
}
/** /**
* 返回界面处根据百分比调整后的最小宽度 * 返回界面处根据百分比调整后的最小宽度
* *
@ -142,30 +104,14 @@ public class XWAbsoluteLayout extends XLayoutContainer {
*/ */
public int getAcualInterval() { public int getAcualInterval() {
// adapter那边交叉三等分、删除都要判断是否对齐,所以间隔转为偶数 // adapter那边交叉三等分、删除都要判断是否对齐,所以间隔转为偶数
int interval = (int) (toData().getCompInterval() * containerPercent); int interval = (int) (toData().getCompInterval() );
int val = interval / 2; int val = interval / 2;
return val * 2; return val * 2;
} }
/**
* 界面容器大小不是默认的时处理控件的BoundsWidget且避免出现空隙
*/
private Rectangle dealWidgetBound(Rectangle rec) {
if (AssistUtils.equals(1.0, containerPercent)) {
return rec;
}
rec.x = (int) (rec.x / containerPercent);
rec.y = (int) (rec.y / containerPercent);
rec.width = (int) (rec.width / containerPercent);
rec.height = (int) (rec.height / containerPercent);
return rec;
}
/** /**
* 新增删除拉伸后单个组件的BoundsWidget * 新增删除拉伸后单个组件的BoundsWidget
*/ */
public void updateBoundsWidget(XCreator xCreator) { public void updateBoundsWidget(XCreator xCreator) {
WAbsoluteLayout layout = this.toData();
if (xCreator.hasTitleStyle()) { if (xCreator.hasTitleStyle()) {
xCreator = (XLayoutContainer) xCreator.getParent(); xCreator = (XLayoutContainer) xCreator.getParent();
} }
@ -223,32 +169,33 @@ public class XWAbsoluteLayout extends XLayoutContainer {
} }
} }
/** /**
* 更新子组件的Bound * 更新子组件的Bound
* 这边主要用于绝对布局子组件在适应区域选项时 * 这边主要用于绝对布局子组件在适应区域选项时
* 涉及到的不同分辨率下缩放 * 涉及到的不同分辨率下缩放
* * 兼容方法老的模板中绝对布局带有分辨率参数的兼容处理
* @param minHeight 最小高度 *
*/ * @param minHeight 最小高度
@Override */
public void updateChildBound(int minHeight) { @Override
double prevContainerPercent = DesignerUIModeConfig.getInstance().getDesignScreenByDimension(toData().getDesigningResolution()).getValue() / FormArea.DEFAULT_SLIDER; public void updateChildBound(int minHeight) {
if (toData().getCompState() == 0 && !AssistUtils.equals(containerPercent, prevContainerPercent)) { double prevContainerPercent = FRScreen.getFRScreenByDimension(toData().getDesigningResolution()).getValue() / FormArea.DEFAULT_SLIDER;
for (int i = 0; i < this.getComponentCount(); i++) { if (!AssistUtils.equals(DEFAULT_CONTAINER_PERCENT, prevContainerPercent)) {
XCreator creator = getXCreator(i); for (int i = 0; i < this.getComponentCount(); i++) {
Rectangle rec = new Rectangle(creator.getBounds()); XCreator creator = getXCreator(i);
rec.x = (int)Math.round (rec.x / prevContainerPercent * containerPercent); Rectangle rec = new Rectangle(creator.getBounds());
rec.y = (int)Math.round (rec.y / prevContainerPercent * containerPercent); rec.x = (int) Math.round(rec.x / prevContainerPercent);
rec.height = (int)Math.round (rec.height / prevContainerPercent * containerPercent); rec.y = (int) Math.round(rec.y / prevContainerPercent);
rec.width = (int)Math.round (rec.width / prevContainerPercent * containerPercent); rec.height = (int) Math.round(rec.height / prevContainerPercent);
BoundsWidget wgt = (BoundsWidget) toData().getBoundsWidget(creator.toData()); rec.width = (int) Math.round(rec.width / prevContainerPercent);
wgt.setBounds(rec); BoundsWidget wgt = (BoundsWidget) toData().getBoundsWidget(creator.toData());
creator.setBounds(rec); wgt.setBounds(rec);
creator.updateChildBound(minHeight); creator.setBounds(rec);
creator.updateChildBound(minHeight);
}
} }
toData().setDesigningResolution(FRScreen.p1440.getDimension());
} }
toData().setDesigningResolution(Toolkit.getDefaultToolkit().getScreenSize());
}
/** /**
* 增加对齐线 * 增加对齐线

100
designer-form/src/main/java/com/fr/design/designer/creator/XWFitLayout.java

@ -3,15 +3,12 @@ package com.fr.design.designer.creator;
import com.fr.design.designer.beans.LayoutAdapter; import com.fr.design.designer.beans.LayoutAdapter;
import com.fr.design.designer.beans.adapters.layout.FRFitLayoutAdapter; import com.fr.design.designer.beans.adapters.layout.FRFitLayoutAdapter;
import com.fr.design.designer.beans.adapters.layout.FRFixLayoutAdapter; import com.fr.design.designer.beans.adapters.layout.FRFixLayoutAdapter;
import com.fr.design.designer.beans.adapters.layout.FRNoFixLayoutAdapter;
import com.fr.design.designer.beans.location.Direction; import com.fr.design.designer.beans.location.Direction;
import com.fr.design.designer.creator.cardlayout.XWCardMainBorderLayout; import com.fr.design.designer.creator.cardlayout.XWCardMainBorderLayout;
import com.fr.design.designer.creator.cardlayout.XWTabFitLayout; import com.fr.design.designer.creator.cardlayout.XWTabFitLayout;
import com.fr.design.designer.properties.mobile.BodyMobilePropertyUI; import com.fr.design.designer.properties.mobile.BodyMobilePropertyUI;
import com.fr.design.fit.DesignerUIModeConfig;
import com.fr.design.form.layout.FRFitLayout; import com.fr.design.form.layout.FRFitLayout;
import com.fr.design.fun.WidgetPropertyUIProvider; import com.fr.design.fun.WidgetPropertyUIProvider;
import com.fr.design.mainframe.FormArea;
import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.WidgetPropertyPane; import com.fr.design.mainframe.WidgetPropertyPane;
import com.fr.design.utils.gui.LayoutUtils; import com.fr.design.utils.gui.LayoutUtils;
@ -24,12 +21,10 @@ import com.fr.form.ui.container.WLayout;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.FRLogger; import com.fr.general.FRLogger;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
import com.fr.stable.AssistUtils;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
import java.awt.Component; import java.awt.Component;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.Rectangle; import java.awt.Rectangle;
import java.awt.Toolkit;
import java.awt.event.ContainerEvent; import java.awt.event.ContainerEvent;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
@ -46,9 +41,6 @@ public class XWFitLayout extends XLayoutContainer {
private static final long serialVersionUID = 8112908607102660176L; private static final long serialVersionUID = 8112908607102660176L;
private static final int EACH_ROW_COUNT = 4; private static final int EACH_ROW_COUNT = 4;
//由于屏幕分辨率不同,界面上的容器大小可能不是默认的100%,此时拖入组件时,保存的大小按照100%时的计算
protected double containerPercent = 1.0;
// 布局缩小的时候,考虑最小宽高,若挨着右侧或底侧边框的控件缩小后达到最小宽或高,此时容器大小微调下 // 布局缩小的时候,考虑最小宽高,若挨着右侧或底侧边框的控件缩小后达到最小宽或高,此时容器大小微调下
private int needAddWidth = 0; private int needAddWidth = 0;
private int needAddHeight = 0; private int needAddHeight = 0;
@ -64,20 +56,6 @@ public class XWFitLayout extends XLayoutContainer {
public XWFitLayout(WFitLayout widget, Dimension initSize) { public XWFitLayout(WFitLayout widget, Dimension initSize) {
super(widget, initSize); super(widget, initSize);
initPercent();
widget.setResolutionScaling(containerPercent);
}
//根据屏幕大小来确定显示的百分比, 1440*900默认100%, 1366*768缩放90%
private void initPercent(){
Toolkit toolkit = Toolkit.getDefaultToolkit();
Dimension scrnsize = toolkit.getScreenSize();
double screenValue = DesignerUIModeConfig.getInstance().getDesignScreenByDimension(scrnsize).getValue();
if (!AssistUtils.equals(FormArea.DEFAULT_SLIDER, screenValue)) {
this.setContainerPercent(screenValue / FormArea.DEFAULT_SLIDER);
}
} }
@Override @Override
@ -252,19 +230,16 @@ public class XWFitLayout extends XLayoutContainer {
* @return int[] 横坐标数组 * @return int[] 横坐标数组
*/ */
public int[] getHors(boolean isActualSize) { public int[] getHors(boolean isActualSize) {
double perc = isActualSize ? containerPercent : 1.0;
List<Integer> posX = new ArrayList<Integer>(); List<Integer> posX = new ArrayList<Integer>();
// 保存实际大小时,组件大小已经去除内边距,此处也判断下 // 保存实际大小时,组件大小已经去除内边距,此处也判断下
PaddingMargin margin = isActualSize ? new PaddingMargin(0,0,0,0) : toData().getMargin(); PaddingMargin margin = isActualSize ? new PaddingMargin(0, 0, 0, 0) : toData().getMargin();
posX.add(margin.getLeft()); posX.add(margin.getLeft());
int width = this.getWidth() - margin.getLeft() - margin.getRight(); int width = this.getWidth() - margin.getLeft() - margin.getRight();
int containW = (int) (width / perc); posX.add(width + margin.getLeft());
posX.add(containW + margin.getLeft()); for (int i = 0, len = this.getComponentCount(); i < len; i++) {
for (int i=0, len=this.getComponentCount(); i < len; i++) {
int x = this.getComponent(i).getX(); int x = this.getComponent(i).getX();
int finalX = (int) (x / perc); if (!posX.contains(x)) {
if (!posX.contains(finalX)) { posX.add(x);
posX.add(finalX);
} }
} }
Collections.sort(posX); Collections.sort(posX);
@ -278,19 +253,16 @@ public class XWFitLayout extends XLayoutContainer {
* *
*/ */
public int[] getVeris(boolean isActualSize) { public int[] getVeris(boolean isActualSize) {
double perc = isActualSize ? containerPercent : 1.0;
List<Integer> posY = new ArrayList<Integer>(); List<Integer> posY = new ArrayList<Integer>();
// 保存实际大小时,组件大小已经去除内边距,此处也判断下 // 保存实际大小时,组件大小已经去除内边距,此处也判断下
PaddingMargin margin = isActualSize ? new PaddingMargin(0,0,0,0) : toData().getMargin(); PaddingMargin margin = isActualSize ? new PaddingMargin(0,0,0,0) : toData().getMargin();
posY.add(margin.getTop()); posY.add(margin.getTop());
int height = this.getHeight() - margin.getTop() - margin.getBottom(); int height = this.getHeight() - margin.getTop() - margin.getBottom();
int containH = (int) (height / perc); posY.add(height + margin.getTop());
posY.add(containH + margin.getTop());
for (int i=0, len=this.getComponentCount(); i < len; i++) { for (int i=0, len=this.getComponentCount(); i < len; i++) {
int y = this.getComponent(i).getY(); int y = this.getComponent(i).getY();
int finalY = (int) (y / perc); if (!posY.contains(y)) {
if (!posY.contains(finalY)) { posY.add(y);
posY.add(finalY);
} }
} }
Collections.sort(posY); Collections.sort(posY);
@ -721,34 +693,6 @@ public class XWFitLayout extends XLayoutContainer {
creator.setBackupParent(this); creator.setBackupParent(this);
} }
/**
* 界面容器大小不是默认的时处理控件的BoundsWidget且避免出现空隙
*/
private Rectangle dealWidgetBound(Rectangle rec) {
if (AssistUtils.equals(1.0, containerPercent)) {
return rec;
}
rec.x = (int) (rec.x/containerPercent);
rec.y = (int) (rec.y/containerPercent);
rec.width = (int) (rec.width/containerPercent);
rec.height = (int) (rec.height/containerPercent);
return rec;
}
/**
* 界面容器大小不是默认的时恢复组件实际大小
*/
private Rectangle dealWgtBound(Rectangle rec) {
if (AssistUtils.equals(1.0, containerPercent)) {
return rec;
}
rec.x = (int) (rec.x * containerPercent);
rec.y = (int) (rec.y * containerPercent);
rec.width = (int) (rec.width * containerPercent);
rec.height = (int) (rec.height * containerPercent);
return rec;
}
/** /**
* 新增删除拉伸后更新每个组件的BoundsWidget * 新增删除拉伸后更新每个组件的BoundsWidget
*/ */
@ -774,7 +718,7 @@ public class XWFitLayout extends XLayoutContainer {
XCreator creator = (XCreator) this.getComponent(index); XCreator creator = (XCreator) this.getComponent(index);
BoundsWidget wgt = (BoundsWidget) layout.getBoundsWidget(creator.toData()); BoundsWidget wgt = (BoundsWidget) layout.getBoundsWidget(creator.toData());
// 用当前的显示大小计算后调正具体位置 // 用当前的显示大小计算后调正具体位置
Rectangle wgtBound = dealWidgetBound(creator.getBounds()); Rectangle wgtBound = creator.getBounds();
Rectangle rec = recalculateWidgetBounds(wgtBound, hors, veris); Rectangle rec = recalculateWidgetBounds(wgtBound, hors, veris);
wgt.setBounds(rec); wgt.setBounds(rec);
creator.toData().updateChildBounds(rec); creator.toData().updateChildBounds(rec);
@ -814,7 +758,7 @@ public class XWFitLayout extends XLayoutContainer {
//更新的时候一定要带上backupBound //更新的时候一定要带上backupBound
if (creator.getBackupBound() == null && wgt.getBeforeScaleBounds() != null) { if (creator.getBackupBound() == null && wgt.getBeforeScaleBounds() != null) {
creator.setBackupBound(dealWgtBound(wgt.getBeforeScaleBounds())); creator.setBackupBound(wgt.getBeforeScaleBounds());
} }
((XWAbsoluteLayout) creator).updateBoundsWidget(); ((XWAbsoluteLayout) creator).updateBoundsWidget();
creator.setBackupBound(creator.getBounds()); creator.setBackupBound(creator.getBounds());
@ -1170,24 +1114,6 @@ public class XWFitLayout extends XLayoutContainer {
return this.getComponentAt(x+w-default_Length, y+h+default_Length+val); return this.getComponentAt(x+w-default_Length, y+h+default_Length+val);
} }
/**
* 返回容器大小的百分比
* @return the containerPercent
*/
public double getContainerPercent() {
return containerPercent;
}
/**
* 设置容器大小的百分比
* @param containerPercent the containerPercent to set
*/
public void setContainerPercent(double containerPercent) {
this.containerPercent = containerPercent;
minWidth = (int) (XWFitLayout.MIN_WIDTH*containerPercent);
minHeight = (int) (XWFitLayout.MIN_HEIGHT*containerPercent);
}
/** /**
* 该组件是否可以拖拽(表单中参数面板和自适应布局不可以拖拽) * 该组件是否可以拖拽(表单中参数面板和自适应布局不可以拖拽)
* @return 是则返回true * @return 是则返回true
@ -1218,9 +1144,9 @@ public class XWFitLayout extends XLayoutContainer {
*/ */
public int getAcualInterval() { public int getAcualInterval() {
// adapter那边交叉三等分、删除都要判断是否对齐,所以间隔转为偶数 // adapter那边交叉三等分、删除都要判断是否对齐,所以间隔转为偶数
int interval = (int) (toData().getCompInterval()*containerPercent); int interval = toData().getCompInterval();
int val = interval/2; int val = interval / 2;
return val*2; return val * 2;
} }
/** /**

4
designer-form/src/main/java/com/fr/design/designer/properties/FRFitLayoutConstraints.java

@ -92,8 +92,8 @@ public class FRFitLayoutConstraints implements ConstraintsGroupModel {
Rectangle bounds = getBounds(); Rectangle bounds = getBounds();
Rectangle rec = ComponentUtils.getRelativeBounds(parent); Rectangle rec = ComponentUtils.getRelativeBounds(parent);
WFitLayout wFitLayout = parent.toData(); WFitLayout wFitLayout = parent.toData();
int minHeight = (int)(MINHEIGHT * wFitLayout.getResolutionScaling()); int minHeight = MINHEIGHT;
int minWidth = (int)(MINWIDTH * wFitLayout.getResolutionScaling()); int minWidth = MINWIDTH;
PaddingMargin margin= wFitLayout.getMargin(); PaddingMargin margin= wFitLayout.getMargin();
switch (row) { switch (row) {
case 0: case 0:

109
designer-form/src/main/java/com/fr/design/fit/JFormType.java

@ -1,30 +1,10 @@
package com.fr.design.fit; package com.fr.design.fit;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.fit.common.AdaptiveSwitchUtil;
import com.fr.form.fit.NewFormMarkAttr;
import com.fr.form.fit.config.FormFitConfig; import com.fr.form.fit.config.FormFitConfig;
import com.fr.design.fit.menupane.FormFitAttrPane;
import com.fr.design.fun.PreviewProvider;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.preview.FormAdaptivePreview;
import com.fr.design.preview.FormPreview;
import com.fr.design.report.fit.menupane.ReportFitAttrPane;
import com.fr.form.main.Form;
import com.fr.report.fit.ReportFitAttr; import com.fr.report.fit.ReportFitAttr;
public enum JFormType { public enum JFormType {
OLD_TYPE(0, new FormPreview()) { OLD_TYPE(0) {
@Override
public void switchUI() {
AdaptiveSwitchUtil.switch2OldUI();
}
@Override
public void switchUIMode() {
AdaptiveSwitchUtil.switch2OldUIMode();
}
@Override @Override
public ReportFitAttr obtainFitAttr() { public ReportFitAttr obtainFitAttr() {
return FormFitConfig.getInstance().getOldFitAttr(); return FormFitConfig.getInstance().getOldFitAttr();
@ -35,23 +15,9 @@ public enum JFormType {
FormFitConfig.getInstance().setOldFitAttr(attr); FormFitConfig.getInstance().setOldFitAttr(attr);
} }
@Override
public BasicBeanPane obtainAttrPane(NewJForm newJForm) {
return new ReportFitAttrPane();
}
}, },
NEW_TYPE(1, new FormAdaptivePreview()) { NEW_TYPE(1) {
@Override
public void switchUI() {
AdaptiveSwitchUtil.switch2NewUI();
}
@Override
public void switchUIMode() {
AdaptiveSwitchUtil.switch2NewUIMode();
}
@Override @Override
public ReportFitAttr obtainFitAttr() { public ReportFitAttr obtainFitAttr() {
return FormFitConfig.getInstance().getNewFitAttr(); return FormFitConfig.getInstance().getNewFitAttr();
@ -62,80 +28,35 @@ public enum JFormType {
FormFitConfig.getInstance().setNewFitAttr(attr); FormFitConfig.getInstance().setNewFitAttr(attr);
} }
@Override
public BasicBeanPane obtainAttrPane(NewJForm newJForm) {
return new FormFitAttrPane(newJForm);
}
}; };
private int type; private final int type;
private boolean newType; private final boolean newType;
private PreviewProvider defaultPreviewType;
JFormType(int type, PreviewProvider defaultPreviewType) { JFormType(int type) {
this.type = type; this.type = type;
this.newType = (type == 1); this.newType = (type == 1);
this.defaultPreviewType = defaultPreviewType;
} }
public int getType() { public int getType() {
return type; return type;
} }
public boolean isNewType() {
return newType;
}
public PreviewProvider getDefaultPreviewType() { public static JFormType parseFormType(int type) {
return defaultPreviewType; for (JFormType formType : values()) {
if (formType.getType() == type) {
return formType;
}
}
return JFormType.OLD_TYPE;
} }
public abstract void switchUI(); public boolean isNewType() {
return newType;
public abstract void switchUIMode(); }
public abstract ReportFitAttr obtainFitAttr(); public abstract ReportFitAttr obtainFitAttr();
public abstract void updateFitAttr(ReportFitAttr attr); public abstract void updateFitAttr(ReportFitAttr attr);
public abstract BasicBeanPane obtainAttrPane(NewJForm newJForm);
/**
* @Description: 更新模板的标志位
* @param jTemplate
* @return:
* @Author: Henry.Wang
* @date: 2020/12/17 16:17
*/
public void updateJFromTemplateType(JTemplate jTemplate) {
if (jTemplate instanceof NewJForm) {
NewJForm newJForm = (NewJForm) jTemplate;
Form form = newJForm.getTarget();
NewFormMarkAttr newFormMarkAttr = form.getAttrMark(NewFormMarkAttr.XML_TAG);
if (newFormMarkAttr == null) {
newFormMarkAttr = new NewFormMarkAttr(this.getType());
form.addAttrMark(newFormMarkAttr);
}
newFormMarkAttr.setType(this.getType());
newJForm.setJFormType(this);
}
}
/**
* @Description: 更新预览方式
* @param jTemplate
* @return:
* @Author: Henry.Wang
* @date: 2020/12/17 16:17
*/
public void updatePreviewType(JTemplate jTemplate) {
if (jTemplate.getPreviewType() != null) {
PreviewProvider[] previewProviders = jTemplate.supportPreview();
for (PreviewProvider previewProvider : previewProviders) {
if (previewProvider.getClass() == jTemplate.getPreviewType().getClass()) {
return;
}
}
}
jTemplate.setPreviewType(this.getDefaultPreviewType());
}
} }

103
designer-form/src/main/java/com/fr/design/fit/NewJForm.java

@ -2,19 +2,18 @@ package com.fr.design.fit;
import com.fr.base.DynamicUnitList; import com.fr.base.DynamicUnitList;
import com.fr.base.Parameter; import com.fr.base.Parameter;
import com.fr.design.actions.TemplateParameterAction;
import com.fr.design.designer.beans.AdapterBus; import com.fr.design.designer.beans.AdapterBus;
import com.fr.design.designer.beans.LayoutAdapter; import com.fr.design.designer.beans.LayoutAdapter;
import com.fr.design.designer.beans.adapters.layout.FRFitLayoutAdapter; import com.fr.design.designer.beans.adapters.layout.FRFitLayoutAdapter;
import com.fr.design.designer.beans.events.DesignerEditListener; import com.fr.design.designer.beans.events.DesignerEditListener;
import com.fr.design.designer.beans.events.DesignerEvent; import com.fr.design.designer.beans.events.DesignerEvent;
import com.fr.design.designer.creator.*; import com.fr.design.designer.creator.XComponent;
import com.fr.design.fit.common.AdaptiveSwitchUtil; import com.fr.design.designer.creator.XCreatorUtils;
import com.fr.design.fit.common.LayoutTool; import com.fr.design.designer.creator.XElementCase;
import com.fr.form.fit.NewFormMarkAttr; import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.fit.common.TemplateTool; import com.fr.design.designer.creator.XWTitleLayout;
import com.fr.design.actions.NewFormMobileAttrAction;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.mainframe.DesignerUIModeConfig;
import com.fr.design.preview.DeveloperPreview; import com.fr.design.preview.DeveloperPreview;
import com.fr.design.preview.FormAdaptivePreview; import com.fr.design.preview.FormAdaptivePreview;
import com.fr.design.fit.toolbar.SwitchAction; import com.fr.design.fit.toolbar.SwitchAction;
@ -22,14 +21,13 @@ import com.fr.design.fun.PreviewProvider;
import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.JForm; import com.fr.design.mainframe.JForm;
import com.fr.design.mainframe.WidgetPropertyPane; import com.fr.design.mainframe.WidgetPropertyPane;
import com.fr.design.menu.ShortCut;
import com.fr.design.preview.FormPreview; import com.fr.design.preview.FormPreview;
import com.fr.design.preview.MobilePreview; import com.fr.design.preview.MobilePreview;
import com.fr.design.utils.ComponentUtils; import com.fr.design.utils.ComponentUtils;
import com.fr.file.FILE; import com.fr.file.FILE;
import com.fr.form.FormElementCaseProvider; import com.fr.form.FormElementCaseProvider;
import com.fr.form.fit.NewFormMarkAttr;
import com.fr.form.main.Form; import com.fr.form.main.Form;
import com.fr.form.main.mobile.FormMobileAttr;
import com.fr.form.ui.ElementCaseEditor; import com.fr.form.ui.ElementCaseEditor;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
@ -49,13 +47,13 @@ public class NewJForm extends JForm {
public NewJForm() { public NewJForm() {
super(); super();
init(); init();
changePaneSize();
} }
public NewJForm(Form form) { public NewJForm(Form form) {
super(form); super(form);
init(); init();
changePaneSize(); //新建的模板都要加上新表单标志attr
form.addAttrMark(NewFormMarkAttr.createNewFormAttr());
} }
public NewJForm(Form form, FILE file, Parameter[] parameters) { public NewJForm(Form form, FILE file, Parameter[] parameters) {
@ -64,51 +62,7 @@ public class NewJForm extends JForm {
public NewJForm(Form form, FILE file) { public NewJForm(Form form, FILE file) {
super(form, file); super(form, file);
if (DesignerUIModeConfig.getInstance().newUIMode()) { init();
init();
}
changePaneSize();
}
/**
* @Description:改变body的大小主要针对新模式下打开老模板出现截断的情况
* @param
* @return:
* @Author: Henry.Wang
* @date: 2020/9/13 23:23
*/
private void changePaneSize() {
NewFormMarkAttr newFormMarkAttr = this.getTarget().getAttrMark(NewFormMarkAttr.XML_TAG);
if (newFormMarkAttr.isNotSetOriginSize()) {
newFormMarkAttr.setBodyHeight(LayoutTool.getBodyHeight(this));
newFormMarkAttr.setBodyWidth(LayoutTool.getBodyWidth(this));
return;
}
//这种是针对body为绝对布局时,可能出现截断的情况
if (LayoutTool.absoluteLayoutForm(this)) {
int bodyHeight = newFormMarkAttr.getBodyHeight();
int bodyWidth = newFormMarkAttr.getBodyWidth();
Rectangle rectangle = LayoutTool.getAbsoluteBodySize(this);
if (!isNewJFrom() && (rectangle.width != bodyWidth || rectangle.height != bodyHeight)) {
TemplateTool.onlyChangeAbsoluteBodySize(bodyHeight, bodyWidth, this);
} else if (isNewJFrom()) {
if (rectangle.width > bodyWidth && rectangle.height > bodyHeight) {
TemplateTool.onlyChangeAbsoluteBodySize(rectangle.height, rectangle.width, this);
} else if (rectangle.width > bodyWidth) {
TemplateTool.onlyChangeAbsoluteBodySize(bodyHeight, rectangle.width, this);
} else if (rectangle.height > bodyHeight) {
TemplateTool.onlyChangeAbsoluteBodySize(rectangle.height, bodyWidth, this);
}
}
} else if (AdaptiveSwitchUtil.isSwitchJFromIng()) {
//这种是针对body中有绝对画布块,导致截断的情况
double scale = LayoutTool.getContainerPercent();
if (isNewJFrom()) {
LayoutTool.scaleAbsoluteBlockComponentsBounds(this.getFormDesign().getRootComponent(), 1 / scale);
} else {
LayoutTool.scaleAbsoluteBlockComponentsBounds(this.getFormDesign().getRootComponent(), scale);
}
}
} }
public JFormType getJFormType() { public JFormType getJFormType() {
@ -119,22 +73,6 @@ public class NewJForm extends JForm {
this.jFormType = jFormType; this.jFormType = jFormType;
} }
/**
* 模板菜单
*
* @return 返回菜单
*/
@Override
public ShortCut[] shortcut4TemplateMenu() {
if (this.index == FORM_TAB) {
return ArrayUtils.addAll(new ShortCut[]{new TemplateParameterAction(this), new NewFormMobileAttrAction(this), getReportFitAttrAction()}, new ShortCut[0]);
} else {
return ArrayUtils.addAll(new ShortCut[]{new TemplateParameterAction(this), new NewFormMobileAttrAction(this), getReportFitAttrAction()}, this.getElementCaseDesign().shortcut4TemplateMenu());
}
}
private void init() { private void init() {
this.getFormDesign().addDesignerEditListener(new DesignerEditListener() { this.getFormDesign().addDesignerEditListener(new DesignerEditListener() {
private Rectangle oldRec; private Rectangle oldRec;
@ -247,6 +185,13 @@ public class NewJForm extends JForm {
} }
}); });
Form form = this.getTarget();
NewFormMarkAttr newFormMarkAttr = form.getAttrMark(NewFormMarkAttr.XML_TAG);
if (newFormMarkAttr == null) {
newFormMarkAttr = new NewFormMarkAttr();
}
this.setJFormType(JFormType.parseFormType(newFormMarkAttr.getType()));
} }
@ -270,24 +215,14 @@ public class NewJForm extends JForm {
return new PreviewProvider[]{new FormPreview(), new MobilePreview()}; return new PreviewProvider[]{new FormPreview(), new MobilePreview()};
} }
public boolean mobileForm() {
FormMobileAttr mobileAttr = this.getTarget().getFormMobileAttr();
if (mobileAttr.isMobileOnly() && mobileAttr.isAdaptivePropertyAutoMatch()) {
return true;
}
return false;
}
private SwitchAction switchAction;
public UIButton[] createExtraButtons() { public UIButton[] createExtraButtons() {
UIButton[] extraButtons = super.createExtraButtons(); UIButton[] extraButtons = super.createExtraButtons();
return addAdaptiveSwitchButton(extraButtons); return addAdaptiveSwitchButton(extraButtons);
} }
private UIButton[] addAdaptiveSwitchButton(UIButton[] extraButtons) { private UIButton[] addAdaptiveSwitchButton(UIButton[] extraButtons) {
switchAction = new SwitchAction(); SwitchAction switchAction = new SwitchAction(this);
return ArrayUtils.addAll(extraButtons, new UIButton[]{switchAction.getToolBarButton()}); return ArrayUtils.addAll(extraButtons, switchAction.getToolBarButton());
} }
public boolean isNewJFrom() { public boolean isNewJFrom() {

145
designer-form/src/main/java/com/fr/design/fit/common/AdaptiveSwitchUtil.java

@ -1,15 +1,14 @@
package com.fr.design.fit.common; package com.fr.design.fit.common;
import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.DesignTableDataManager;
import com.fr.design.fit.DesignerUIModeConfig;
import com.fr.design.fit.NewJForm; import com.fr.design.fit.NewJForm;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.JForm;
import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.JTemplate;
import com.fr.design.preview.FormAdaptivePreview; import com.fr.design.preview.FormAdaptivePreview;
import com.fr.design.preview.FormPreview; import com.fr.design.preview.FormPreview;
import com.fr.file.FILE; import com.fr.file.FILE;
import com.fr.file.MemFILE; import com.fr.file.MemFILE;
import com.fr.form.fit.NewFormMarkAttr;
import com.fr.form.main.Form; import com.fr.form.main.Form;
import com.fr.form.main.WidgetGather; import com.fr.form.main.WidgetGather;
import com.fr.form.ui.Widget; import com.fr.form.ui.Widget;
@ -33,25 +32,10 @@ public class AdaptiveSwitchUtil {
} }
public static void switch2NewUI() { /**
switch2NewUIMode(); * 新老表单转换的方法
reload(); */
} public static void switchReload() {
public static void switch2NewUIMode() {
DesignerUIModeConfig.getInstance().setNewUIMode();
}
public static void switch2OldUI() {
switch2OldUIMode();
reload();
}
public static void switch2OldUIMode() {
DesignerUIModeConfig.getInstance().setOldUIMode();
}
public static void reload() {
SwingUtilities.invokeLater(new Runnable() { SwingUtilities.invokeLater(new Runnable() {
@Override @Override
public void run() { public void run() {
@ -61,15 +45,15 @@ public class AdaptiveSwitchUtil {
return; return;
} }
JTemplate<?, ?> old = TemplateTool.getCurrentEditingTemplate(); JTemplate<?, ?> old = TemplateTool.getCurrentEditingTemplate();
if (old == null || !(old instanceof JForm)) { if (!(old instanceof NewJForm)) {
return; return;
} }
JTemplate<?, ?> template = createNewJTemplate(old); JTemplate<?, ?> template = createNewJTemplate((NewJForm) old);
if (template != null) { if (template != null) {
DesignTableDataManager.closeTemplate(old); DesignTableDataManager.closeTemplate(old);
TemplateTool.resetTabPaneEditingTemplate(template); TemplateTool.resetTabPaneEditingTemplate(template);
TemplateTool.activeAndResizeTemplate(template); TemplateTool.activeAndResizeTemplate(template);
setPreviewType(); setPreviewType(template);
} }
} catch (Exception e) { } catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage()); FineLoggerFactory.getLogger().error(e.getMessage());
@ -83,14 +67,12 @@ public class AdaptiveSwitchUtil {
/** /**
* @Description: 设置预览方式 * @Description: 设置预览方式
* @return: 新创建的模板
* @Author: Henry.Wang * @Author: Henry.Wang
* @date: 2020/10/13 14:08 * @date: 2020/10/13 14:08
*/ */
private static void setPreviewType() { private static void setPreviewType(JTemplate jTemplate) {
JTemplate jTemplate = TemplateTool.getCurrentEditingTemplate();
if (jTemplate != null) { if (jTemplate != null) {
if (DesignerUIModeConfig.getInstance().newUIMode()) { if (TemplateTool.isNewJForm(jTemplate)) {
jTemplate.setPreviewType(new FormAdaptivePreview()); jTemplate.setPreviewType(new FormAdaptivePreview());
} else { } else {
jTemplate.setPreviewType(new FormPreview()); jTemplate.setPreviewType(new FormPreview());
@ -99,29 +81,30 @@ public class AdaptiveSwitchUtil {
} }
/** /**
* @param oldForm 以前的模板
* @Description: 创建模板 * @Description: 创建模板
* @param old 以前的模板
* @return: 新创建的模板 * @return: 新创建的模板
* @Author: Henry.Wang * @Author: Henry.Wang
* @date: 2020/9/6 14:08 * @date: 2020/9/6 14:08
*/ */
public static JTemplate<?, ?> createNewJTemplate(JTemplate<?, ?> old) { public static JTemplate<?, ?> createNewJTemplate(NewJForm oldForm) {
JTemplate<?, ?> template; NewJForm newJForm = createNewJTemplateInternal(oldForm);
template = createNewJTemplateInternal(old); if (newJForm == null) {
if (template instanceof NewJForm) { return null;
NewJForm jForm = ((NewJForm) template); }
//如果是从旧的设计模板转化为新的设计模式,并且不是全局配置的模板。则更新新模板的Pc端自适应属性 //如果是从旧的设计模板转化为新的设计模式,并且不是全局配置的模板。则更新新模板的Pc端自适应属性
if (DesignerUIModeConfig.getInstance().newUIMode() && jForm.getTarget().getReportFitAttr() != null && isSwitchJFromIng()) { if (newJForm.getTarget().getReportFitAttr() != null && newJForm.isNewJFrom()) {
jForm.getTarget().setReportFitAttr(shiftReportFitAttr(old, jForm.getTarget().getReportFitAttr().isFitFont())); //修改自适应属性
} newJForm.getTarget().setReportFitAttr(shiftReportFitAttr(oldForm, newJForm.getTarget().getReportFitAttr().isFitFont()));
processAbsoluteLayoutCompatible(jForm.getTarget()); //修改绝对布局中的缩放属性
TemplateTool.saveForm(jForm); processAbsoluteLayoutCompatible(newJForm.getTarget());
} }
return template; TemplateTool.saveForm(newJForm);
return newJForm;
} }
private static void processAbsoluteLayoutCompatible(Form form){ private static void processAbsoluteLayoutCompatible(Form form) {
Form.traversalWidget(form.getContainer(), new WidgetGather() { Form.traversalWidget(form.getContainer(), new WidgetGather() {
@Override @Override
public void dealWith(Widget widget) { public void dealWith(Widget widget) {
@ -141,25 +124,28 @@ public class AdaptiveSwitchUtil {
} }
/** /**
* @Description: 创建模板核心方法
* @param old 以前的方法 * @param old 以前的方法
* @Description: 创建模板核心方法
* @return: 新创建的模板 * @return: 新创建的模板
* @Author: Henry.Wang * @Author: Henry.Wang
* @date: 2020/9/6 14:09 * @date: 2020/9/6 14:09
*/ */
private static JTemplate<?, ?> createNewJTemplateInternal(JTemplate<?, ?> old) { private static NewJForm createNewJTemplateInternal(JTemplate<?, ?> old) {
FILE file = old.getEditingFILE(); FILE file = old.getEditingFILE();
if ((file instanceof MemFILE) || !old.isSaved()) { if ((file instanceof MemFILE) || !old.isSaved()) {
if (old instanceof NewJForm) {
TemplateTool.resetAbsoluteBodySize((NewJForm) old);
}
TemplateTool.saveForm(old); TemplateTool.saveForm(old);
} }
if (old.getTarget() instanceof Form) { if (old.getTarget() instanceof Form) {
try { try {
return new NewJForm((Form) (old.getTarget()).clone(), old.getEditingFILE()); //这边进行数据模型中的标志位切换
Form form = (Form) old.getTarget().clone();
NewFormMarkAttr oldFormAttr = form.getAttrMark(NewFormMarkAttr.XML_TAG);
if (oldFormAttr == null) {
oldFormAttr = new NewFormMarkAttr();
}
form.addAttrMark(oldFormAttr.switchAttr());
return new NewJForm(form, old.getEditingFILE());
} catch (Exception e) { } catch (Exception e) {
FineLoggerFactory.getLogger().error(e, e.getMessage()); FineLoggerFactory.getLogger().error(e, e.getMessage());
return null; return null;
@ -170,46 +156,43 @@ public class AdaptiveSwitchUtil {
} }
/** /**
* @Description: 老模板切换到新模板的属性配置转换
* 1绝对布局-适应区域--双向自适应
* 2自适应布局-双向自适应--双向自适应
* 3自适应布局-横向自适应--横向自适应
* 4绝对布局-固定大小--不自适应
*
* @param old * @param old
* @param fitFont 字体是否自适应 * @param fitFont 字体是否自适应
* @Description: 老模板切换到新模板的属性配置转换
* 1绝对布局-适应区域--双向自适应
* 2自适应布局-双向自适应--双向自适应
* 3自适应布局-横向自适应--横向自适应
* 4绝对布局-固定大小--不自适应
*
* @return: * @return:
* @Author: Henry.Wang * @Author: Henry.Wang
* @date: 2020/9/6 14:01 * @date: 2020/9/6 14:01
*/ */
private static ReportFitAttr shiftReportFitAttr(JTemplate old, boolean fitFont) { private static ReportFitAttr shiftReportFitAttr(NewJForm old, boolean fitFont) {
if (old instanceof JForm && DesignerUIModeConfig.getInstance().newUIMode()) { try {
JForm jForm = (JForm) old; int layoutType = LayoutTool.getFormLayoutType(old);
try { int compState = -1;
int layoutType = LayoutTool.getFormLayoutType(jForm); //自适应布局
int compState = -1; if (layoutType == 0) {
//自适应布局 compState = ((WFitLayout) old.getFormDesign().getRootComponent().toData()).getCompState();
if (layoutType == 0) { if (compState == WFitLayout.STATE_FULL) {
compState = ((WFitLayout) jForm.getFormDesign().getRootComponent().toData()).getCompState(); return new ReportFitAttr(2, fitFont);
if (compState == WFitLayout.STATE_FULL) { } else if (compState == WFitLayout.STATE_ORIGIN) {
return new ReportFitAttr(2, fitFont); return new ReportFitAttr(1, fitFont);
} else if (compState == WFitLayout.STATE_ORIGIN) { }
return new ReportFitAttr(1, fitFont); } else if (layoutType == 1) {//绝对布局
} Widget widget = ((CRBoundsWidget) old.getFormDesign().getRootComponent().toData().getWidget(0)).getWidget();
} else if (layoutType == 1) {//绝对布局 if (widget instanceof WAbsoluteLayout) {
Widget widget = ((CRBoundsWidget) jForm.getFormDesign().getRootComponent().toData().getWidget(0)).getWidget(); compState = ((WAbsoluteLayout) widget).getCompState();
if (widget instanceof WAbsoluteLayout) { }
compState = ((WAbsoluteLayout) widget).getCompState(); if (compState == WAbsoluteLayout.STATE_FIT) {
} return new ReportFitAttr(2, fitFont);
if (compState == WAbsoluteLayout.STATE_FIT) { } else if (compState == WAbsoluteLayout.STATE_FIXED) {
return new ReportFitAttr(2, fitFont); return new ReportFitAttr(3, fitFont);
} else if (compState == WAbsoluteLayout.STATE_FIXED) {
return new ReportFitAttr(3, fitFont);
}
} }
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
} }
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
} }
return null; return null;
} }

15
designer-form/src/main/java/com/fr/design/fit/common/LayoutTool.java

@ -7,20 +7,16 @@ import com.fr.design.designer.creator.XWAbsoluteLayout;
import com.fr.design.designer.creator.cardlayout.XWCardLayout; import com.fr.design.designer.creator.cardlayout.XWCardLayout;
import com.fr.design.designer.creator.cardlayout.XWCardMainBorderLayout; import com.fr.design.designer.creator.cardlayout.XWCardMainBorderLayout;
import com.fr.design.fit.NewJForm; import com.fr.design.fit.NewJForm;
import com.fr.design.mainframe.FormArea;
import com.fr.design.mainframe.JForm; import com.fr.design.mainframe.JForm;
import com.fr.design.utils.gui.LayoutUtils; import com.fr.design.utils.gui.LayoutUtils;
import com.fr.form.ui.container.WAbsoluteBodyLayout; import com.fr.form.ui.container.WAbsoluteBodyLayout;
import com.fr.form.ui.container.WFitLayout; import com.fr.form.ui.container.WFitLayout;
import com.fr.form.ui.container.WLayout; import com.fr.form.ui.container.WLayout;
import com.fr.form.ui.widget.CRBoundsWidget; import com.fr.form.ui.widget.CRBoundsWidget;
import com.fr.general.FRScreen;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import java.awt.Component; import java.awt.Component;
import java.awt.Dimension;
import java.awt.Rectangle; import java.awt.Rectangle;
import java.awt.Toolkit;
/** /**
* @description:布局工具类 * @description:布局工具类
@ -163,15 +159,4 @@ public class LayoutTool {
} }
} }
/**
* @Description: 获取老预览时的缩放比例
* @return:
* @Author: Henry.Wang
* @date: 2020/10/26 20:39
*/
public static double getContainerPercent(){
Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
double screenValue = FRScreen.getFRScreenByDimension(screen).getValue();
return screenValue / FormArea.DEFAULT_SLIDER;
}
} }

100
designer-form/src/main/java/com/fr/design/fit/common/TemplateTool.java

@ -1,30 +1,16 @@
package com.fr.design.fit.common; package com.fr.design.fit.common;
import com.fr.design.designer.beans.events.DesignerEvent;
import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.creator.XWAbsoluteBodyLayout;
import com.fr.design.designer.creator.XWFitLayout;
import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.file.MutilTempalteTabPane; import com.fr.design.file.MutilTempalteTabPane;
import com.fr.design.fit.DesignerUIModeConfig;
import com.fr.design.fit.JFormType;
import com.fr.design.fit.NewJForm; import com.fr.design.fit.NewJForm;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.FormArea;
import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.JForm;
import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.JTemplate;
import com.fr.event.Event; import com.fr.event.Event;
import com.fr.event.Listener; import com.fr.event.Listener;
import com.fr.file.MemFILE; import com.fr.file.MemFILE;
import com.fr.file.StashedFILE; import com.fr.file.StashedFILE;
import com.fr.form.fit.common.LightTool; import com.fr.form.fit.common.LightTool;
import com.fr.form.fit.NewFormMarkAttr;
import com.fr.form.ui.Widget;
import com.fr.form.ui.widget.CRBoundsWidget;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import java.awt.Rectangle;
import java.util.List; import java.util.List;
/** /**
@ -33,31 +19,20 @@ import java.util.List;
* @create: 2020/09/03 14:19 * @create: 2020/09/03 14:19
*/ */
public class TemplateTool { public class TemplateTool {
//和转换有关的所有代码都在这个监听器中 private static final Listener<JTemplate> switchListener = new Listener<JTemplate>() {
//在判断新老模式时,统一使用FormUIModeConfig.getInstance().newUIMode()进行判断
private static Listener<JTemplate> switchListener = new Listener<JTemplate>() {
@Override @Override
public void on(Event event, JTemplate jTemplate) { public void on(Event event, JTemplate jTemplate) {
if (!(jTemplate instanceof JForm)) { jTemplate.setDesignerUIMode();
JFormType.OLD_TYPE.switchUIMode();
return;
}
JFormType currentType = JFormType.OLD_TYPE;
if (AdaptiveSwitchUtil.isSwitchJFromIng()) {
currentType = DesignerUIModeConfig.getInstance().newUIMode() ? JFormType.NEW_TYPE : JFormType.OLD_TYPE;
} else if (isNewJForm(jTemplate)) {
currentType = JFormType.NEW_TYPE;
}
//UI转换
currentType.switchUIMode();
//标志位转换
currentType.updateJFromTemplateType(jTemplate);
//预览方式转换
currentType.updatePreviewType(jTemplate);
} }
}; };
private static boolean isNewJForm(JTemplate jTemplate) {
public static Listener<JTemplate> getSwitchListener() {
return switchListener;
}
public static boolean isNewJForm(JTemplate jTemplate) {
if (jTemplate instanceof NewJForm) { if (jTemplate instanceof NewJForm) {
NewJForm newJForm = (NewJForm) jTemplate; NewJForm newJForm = (NewJForm) jTemplate;
if (LightTool.containNewFormFlag(newJForm.getTarget()) || newJForm.getTarget().getTemplateID() == null) { if (LightTool.containNewFormFlag(newJForm.getTarget()) || newJForm.getTarget().getTemplateID() == null) {
@ -67,8 +42,8 @@ public class TemplateTool {
return false; return false;
} }
public static Listener<JTemplate> getSwitchListener() { public static boolean isCurrentEditingNewJForm(){
return switchListener; return isNewJForm(HistoryTemplateListCache.getInstance().getCurrentEditingTemplate());
} }
/** /**
@ -79,8 +54,7 @@ public class TemplateTool {
* @date: 2020/9/6 14:17 * @date: 2020/9/6 14:17
*/ */
public static JTemplate getCurrentEditingTemplate() { public static JTemplate getCurrentEditingTemplate() {
JTemplate jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); return HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
return jTemplate;
} }
/** /**
@ -168,55 +142,7 @@ public class TemplateTool {
jTemplate.requestFocus(); jTemplate.requestFocus();
} }
/**
* @param height
* @param width
* @param newJForm
* @Description: 只改变绝对布局body的尺寸
* @return:
* @Author: Henry.Wang
* @date: 2020/9/11 15:14
*/
public static void onlyChangeAbsoluteBodySize(int height, int width, NewJForm newJForm) {
FormDesigner formDesigner = newJForm.getFormDesign();
FormArea formArea = formDesigner.getArea();
XLayoutContainer root = formDesigner.getRootComponent();
XWAbsoluteBodyLayout xwAbsoluteBodyLayout = LayoutTool.getXWAbsoluteBodyLayout(newJForm);
if (root.acceptType(XWFitLayout.class) && xwAbsoluteBodyLayout != null) {
XWFitLayout layout = (XWFitLayout) root;
if (height == layout.toData().getContainerHeight() && width == layout.toData().getContainerWidth())
return;
formArea.setWidthPaneValue(width);
formArea.setHeightPaneValue(height);
layout.setSize(width, height);
xwAbsoluteBodyLayout.setSize(width, height);
Widget widget = layout.toData().getWidget(0);
if (widget instanceof CRBoundsWidget) {
((CRBoundsWidget) widget).setBounds(new Rectangle(0, 0, width, height));
}
layout.toData().setContainerWidth(width);
layout.toData().setContainerHeight(height);
formArea.doReCalculateRoot(width, height, layout);
}
formDesigner.getEditListenerTable().fireCreatorModified(DesignerEvent.CREATOR_EDITED);
}
/**
* @param newJForm
* @Description: 因为新老模板切换有截断的问题所以body的尺寸会在调用onlyChangeAbsoluteBodySize之后发生改变为了使模板文件中的尺寸不发生要在模板保存时调用此函数
* @return:
* @Author: Henry.Wang
* @date: 2020/9/11 15:20
*/
public static void resetAbsoluteBodySize(NewJForm newJForm) {
if (LayoutTool.absoluteLayoutForm(newJForm)) {
NewFormMarkAttr newFormMarkAttr = newJForm.getTarget().getAttrMark(NewFormMarkAttr.XML_TAG);
XLayoutContainer root = newJForm.getFormDesign().getRootComponent();
if (newFormMarkAttr != null && root instanceof XWFitLayout) {
((XWFitLayout) root).toData().setContainerWidth(newFormMarkAttr.getBodyWidth());
((XWFitLayout) root).toData().setContainerHeight(newFormMarkAttr.getBodyHeight());
}
}
}
} }

26
designer-form/src/main/java/com/fr/design/fit/toolbar/SwitchAction.java

@ -3,7 +3,6 @@ package com.fr.design.fit.toolbar;
import com.fr.design.actions.UpdateAction; import com.fr.design.actions.UpdateAction;
import com.fr.design.dialog.FineJOptionPane; import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.file.TemplateTreePane; import com.fr.design.file.TemplateTreePane;
import com.fr.design.fit.DesignerUIModeConfig;
import com.fr.design.fit.NewJForm; import com.fr.design.fit.NewJForm;
import com.fr.design.fit.common.AdaptiveSwitchUtil; import com.fr.design.fit.common.AdaptiveSwitchUtil;
import com.fr.design.fit.common.TemplateTool; import com.fr.design.fit.common.TemplateTool;
@ -11,6 +10,7 @@ import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.BaseJForm; import com.fr.design.mainframe.BaseJForm;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.JForm;
import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.JTemplate;
import com.fr.design.menu.MenuKeySet; import com.fr.design.menu.MenuKeySet;
import com.fr.file.FILE; import com.fr.file.FILE;
@ -64,11 +64,11 @@ public class SwitchAction extends UpdateAction {
} }
}; };
public SwitchAction() { public SwitchAction(JForm jForm) {
initMenuStyle(); initMenuStyle(jForm);
} }
private void initMenuStyle() { private void initMenuStyle(JForm jForm) {
this.setMenuKeySet(SWITCH_ATTR); this.setMenuKeySet(SWITCH_ATTR);
this.setName(getMenuKeySet().getMenuKeySetName()); this.setName(getMenuKeySet().getMenuKeySetName());
this.setMnemonic(getMenuKeySet().getMnemonic()); this.setMnemonic(getMenuKeySet().getMnemonic());
@ -80,7 +80,7 @@ public class SwitchAction extends UpdateAction {
Font oldFont = switchBtn.getFont(); Font oldFont = switchBtn.getFont();
switchBtn.setFont(new Font(oldFont.getName(),oldFont.getStyle(),12)); switchBtn.setFont(new Font(oldFont.getName(),oldFont.getStyle(),12));
switchBtn.setForeground(new Color(0x33, 0x33, 0x34)); switchBtn.setForeground(new Color(0x33, 0x33, 0x34));
freshSwitchButton(); freshSwitchButton(jForm);
} }
@Override @Override
@ -92,11 +92,7 @@ public class SwitchAction extends UpdateAction {
if (confirmSwitchDialog() && backUpOldModeJTemplate()) { if (confirmSwitchDialog() && backUpOldModeJTemplate()) {
AdaptiveSwitchUtil.setSwitchJFromIng(1); AdaptiveSwitchUtil.setSwitchJFromIng(1);
showLoadingJPanel(); showLoadingJPanel();
if (DesignerUIModeConfig.getInstance().newUIMode()) { AdaptiveSwitchUtil.switchReload();
AdaptiveSwitchUtil.switch2OldUI();
} else {
AdaptiveSwitchUtil.switch2NewUI();
}
} }
} }
@ -175,7 +171,7 @@ public class SwitchAction extends UpdateAction {
*/ */
private boolean backUpOldModeJTemplate() { private boolean backUpOldModeJTemplate() {
JTemplate<?, ?> jTemplate = TemplateTool.getCurrentEditingTemplate(); JTemplate<?, ?> jTemplate = TemplateTool.getCurrentEditingTemplate();
if (jTemplate != null && !DesignerUIModeConfig.getInstance().newUIMode()) { if (jTemplate != null && !TemplateTool.isNewJForm(jTemplate)) {
FILE editingFILE = jTemplate.getEditingFILE(); FILE editingFILE = jTemplate.getEditingFILE();
if (editingFILE != null && editingFILE.exists()) { if (editingFILE != null && editingFILE.exists()) {
try { try {
@ -237,7 +233,7 @@ public class SwitchAction extends UpdateAction {
* @date: 2020/9/18 11:20 * @date: 2020/9/18 11:20
*/ */
private boolean confirmSwitchDialog() { private boolean confirmSwitchDialog() {
Object message = DesignerUIModeConfig.getInstance().newUIMode() ? Toolkit.i18nText("Fine-Designer_Fit_Confirm_New_Old_Switch") : Toolkit.i18nText("Fine-Designer_Fit_Confirm_Old_New_Switch"); Object message = TemplateTool.isCurrentEditingNewJForm() ? Toolkit.i18nText("Fine-Designer_Fit_Confirm_New_Old_Switch") : Toolkit.i18nText("Fine-Designer_Fit_Confirm_Old_New_Switch");
int returnVal = FineJOptionPane.showConfirmDialog( int returnVal = FineJOptionPane.showConfirmDialog(
DesignerContext.getDesignerFrame(), DesignerContext.getDesignerFrame(),
message, message,
@ -269,8 +265,8 @@ public class SwitchAction extends UpdateAction {
* @Author: Henry.Wang * @Author: Henry.Wang
* @date: 2020/8/31 16:39 * @date: 2020/8/31 16:39
*/ */
public UIButton freshSwitchButton() { public UIButton freshSwitchButton(JForm jForm) {
if (DesignerUIModeConfig.getInstance().newUIMode()) { if (TemplateTool.isNewJForm(jForm)) {
switchBtn.setToolTipText(Toolkit.i18nText("Fine-Designer_Fit_Switch_To_Old_UI")); switchBtn.setToolTipText(Toolkit.i18nText("Fine-Designer_Fit_Switch_To_Old_UI"));
switchBtn.setText(Toolkit.i18nText("Fine-Designer_Fit_Switch_To_Old_Version")); switchBtn.setText(Toolkit.i18nText("Fine-Designer_Fit_Switch_To_Old_Version"));
} else { } else {
@ -281,7 +277,7 @@ public class SwitchAction extends UpdateAction {
} }
public UIButton getToolBarButton() { public UIButton getToolBarButton() {
return freshSwitchButton(); return switchBtn;
} }
} }

137
designer-form/src/main/java/com/fr/design/mainframe/FormArea.java

@ -7,7 +7,6 @@ import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XLayoutContainer; import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.creator.XWBorderLayout; import com.fr.design.designer.creator.XWBorderLayout;
import com.fr.design.designer.creator.XWFitLayout; import com.fr.design.designer.creator.XWFitLayout;
import com.fr.design.fit.DesignerUIModeConfig;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ibutton.UIButtonUI; import com.fr.design.gui.ibutton.UIButtonUI;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
@ -25,11 +24,11 @@ import com.fr.design.scrollruler.VerticalRuler;
import com.fr.design.utils.ComponentUtils; import com.fr.design.utils.ComponentUtils;
import com.fr.design.utils.gui.GUIPaintUtils; import com.fr.design.utils.gui.GUIPaintUtils;
import com.fr.design.utils.gui.LayoutUtils; import com.fr.design.utils.gui.LayoutUtils;
import com.fr.form.fit.NewFormMarkAttr;
import com.fr.form.main.mobile.FormMobileAttr; import com.fr.form.main.mobile.FormMobileAttr;
import com.fr.form.ui.container.WBodyLayoutType; import com.fr.form.ui.container.WBodyLayoutType;
import com.fr.form.ui.container.WBorderLayout; import com.fr.form.ui.container.WBorderLayout;
import com.fr.form.ui.container.WFitLayout; import com.fr.form.ui.container.WFitLayout;
import com.fr.general.FRScreen;
import com.fr.general.IOUtils; import com.fr.general.IOUtils;
import com.fr.stable.AssistUtils; import com.fr.stable.AssistUtils;
@ -66,12 +65,10 @@ import java.awt.event.MouseWheelEvent;
import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER; import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER;
public class FormArea extends JComponent implements ScrollRulerComponent { public class FormArea extends JComponent implements ScrollRulerComponent {
private static final double SLIDER_FLOAT = 400.0;
private static final double SLIDER_MIN = 10.0;
private static final String SCALE_PLUS_COMMAND = "scale_plus"; private static final String SCALE_PLUS_COMMAND = "scale_plus";
private static final String SCALE_MINUS_COMMAND = "scale_minus"; private static final String SCALE_MINUS_COMMAND = "scale_minus";
public static final String FIX_LAYOUT_SWITCH_BUTTON = "fix_layout_switch_button"; public static final String FIX_LAYOUT_SWITCH_BUTTON = "fix_layout_switch_button";
public static final double DEFAULT_SLIDER = 100.0; public static final double DEFAULT_SLIDER = 100.0D;
private static final int ROTATIONS = 50; private static final int ROTATIONS = 50;
public static final int SHOWVALMAX = 400; public static final int SHOWVALMAX = 400;
public static final int SHOWVALMIN = 10; public static final int SHOWVALMIN = 10;
@ -90,21 +87,9 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
private UINumberField heightPane; private UINumberField heightPane;
private JFormSliderPane slidePane; private JFormSliderPane slidePane;
private boolean isValid = true; private boolean isValid = true;
// 初始时滑块值为100,托动后的值设为START_VALUE;
private double START_VALUE = DEFAULT_SLIDER;
private double screenValue;
private UIButton fixLayoutSwitchButton; private UIButton fixLayoutSwitchButton;
private boolean isFixLayoutEditState; private boolean isFixLayoutEditState;
public FormScrollBar getHorScrollBar() {
return horScrollBar;
}
public void setHorScrollBar(FormScrollBar horScrollBar) {
this.horScrollBar = horScrollBar;
}
public FormArea(FormDesigner designer) { public FormArea(FormDesigner designer) {
this(designer, true); this(designer, true);
} }
@ -243,7 +228,6 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
heightPane.setPreferredSize(new Dimension(60, 0)); heightPane.setPreferredSize(new Dimension(60, 0));
slidePane = JFormSliderPane.getInstance(); slidePane = JFormSliderPane.getInstance();
JPanel resizePane = TableLayoutHelper.createCommonTableLayoutPane( JPanel resizePane = TableLayoutHelper.createCommonTableLayoutPane(
new JComponent[][]{{tipsPane, layoutSwitchPane, widthPane, new JComponent[][]{{tipsPane, layoutSwitchPane, widthPane,
new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Indent_Pixel")), new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Indent_Pixel")),
@ -258,6 +242,7 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
slidePane.setVisible(true); slidePane.setVisible(true);
initCalculateSize(); initCalculateSize();
slidePane.addValueChangeListener(showValSpinnerChangeListener); slidePane.addValueChangeListener(showValSpinnerChangeListener);
slidePane.setShowValue(FRScreen.getFRScreenByDimension(Toolkit.getDefaultToolkit().getScreenSize()).getValue().intValue());
} }
public void undoFixLayoutState(boolean isFixLayout) { public void undoFixLayoutState(boolean isFixLayout) {
@ -309,41 +294,10 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
this.designer.repaint(); this.designer.repaint();
} }
/**
* 返回当前的屏幕分辨率对应的百分比值
*
* @return 缩放的百分比值
*/
public double getScreenValue() {
return screenValue;
}
/**
* 设置屏幕分辨率对应的百分比值
*
* @param screenValue 百分比值
*/
public void setScreenValue(double screenValue) {
this.screenValue = screenValue;
}
private void initCalculateSize() { private void initCalculateSize() {
Toolkit toolkit = Toolkit.getDefaultToolkit();
Dimension scrnsize = toolkit.getScreenSize();
this.screenValue = DesignerUIModeConfig.getInstance().getDesignScreenByDimension(scrnsize).getValue();
XLayoutContainer root = FormArea.this.designer.getRootComponent(); XLayoutContainer root = FormArea.this.designer.getRootComponent();
// 7.1.1不放缩放滑块,但表单大小仍按屏幕分辨率调整
// slidePane.populateBean(screenValue);
if (root.acceptType(XWFitLayout.class)) { if (root.acceptType(XWFitLayout.class)) {
XWFitLayout layout = (XWFitLayout) root; reCalculateDefaultRoot();
if ( !AssistUtils.equals(screenValue, DEFAULT_SLIDER) ) {
reCalculateRoot(screenValue, true);
} else {
// 组件间隔啊
// REPORT-2585 原有的逻辑导致嵌套的tab中的间隔加不上去,会在后续拖动的过程中出问题
reCalculateDefaultRoot(screenValue, true);
}
} }
LayoutUtils.layoutContainer(root); LayoutUtils.layoutContainer(root);
updateCreatorsBackupBound(root); updateCreatorsBackupBound(root);
@ -380,18 +334,10 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
// 失去焦点时,可以认为输入结束 // 失去焦点时,可以认为输入结束
int width = (int) ((UINumberField) e.getSource()).getValue(); int width = (int) ((UINumberField) e.getSource()).getValue();
changeWidthPaneValue(width); changeWidthPaneValue(width);
changeFormMarkAttrWidth(width);
} }
}); });
} }
private void changeFormMarkAttrWidth(int width) {
NewFormMarkAttr newFormMarkAttr = designer.getTarget().getAttrMark(NewFormMarkAttr.XML_TAG);
if (newFormMarkAttr != null) {
newFormMarkAttr.setBodyWidth(width);
}
}
private void changeWidthPaneValue(int width) { private void changeWidthPaneValue(int width) {
XWFitLayout layout = (XWFitLayout) designer.getRootComponent(); XWFitLayout layout = (XWFitLayout) designer.getRootComponent();
@ -407,7 +353,6 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
public void actionPerformed(ActionEvent evt) { public void actionPerformed(ActionEvent evt) {
int height = (int) ((UINumberField) evt.getSource()).getValue(); int height = (int) ((UINumberField) evt.getSource()).getValue();
changeHeightPaneValue(height); changeHeightPaneValue(height);
changeFormMarkAttrHeight(height);
} }
}); });
heightPane.addFocusListener( heightPane.addFocusListener(
@ -420,13 +365,6 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
}); });
} }
private void changeFormMarkAttrHeight(int height){
NewFormMarkAttr newFormMarkAttr = designer.getTarget().getAttrMark(NewFormMarkAttr.XML_TAG);
if (newFormMarkAttr != null) {
newFormMarkAttr.setBodyHeight(height);
}
}
private void changeHeightPaneValue(int height) { private void changeHeightPaneValue(int height) {
XWFitLayout layout = (XWFitLayout) designer.getRootComponent(); XWFitLayout layout = (XWFitLayout) designer.getRootComponent();
@ -497,78 +435,26 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
* 修改大小后再根据屏幕分辨率调整下 * 修改大小后再根据屏幕分辨率调整下
*/ */
public void doReCalculateRoot(int width, int height, XWFitLayout layout) { public void doReCalculateRoot(int width, int height, XWFitLayout layout) {
// double value = slidePane.updateBean(); layout.getParent().setSize(width, height + designer.getParaHeight());
//重置滑块的值为默认值100 FormArea.this.validate();
START_VALUE = DEFAULT_SLIDER;
if ( AssistUtils.equals(screenValue, DEFAULT_SLIDER) ) {
layout.getParent().setSize(width, height + designer.getParaHeight());
FormArea.this.validate();
} else {
layout.setBackupGap(screenValue / DEFAULT_SLIDER);
reCalculateRoot(screenValue, false);
}
}
/**
* 按照界面大小的百分比值调整root大小
*
* @param needCalculateParaHeight 是否需要调整参数界面高度
* @param value
*/
private void reCalculateRoot(double value, boolean needCalculateParaHeight) {
if ( AssistUtils.equals(value, START_VALUE) ) {
return;
}
double percent = (value - START_VALUE) / START_VALUE;
XLayoutContainer root = FormArea.this.designer.getRootComponent();
if (root.acceptType(XWFitLayout.class)) {
XWFitLayout layout = (XWFitLayout) root;
layout.setContainerPercent(value / DEFAULT_SLIDER);
traverAndAdjust(layout, percent);
layout.adjustCreatorsWhileSlide(percent);
// 拖动滑块,先将内部组件百分比大小计算,再计算容器大小
Dimension d = new Dimension(layout.getWidth(), layout.getHeight());
// 自适应布局的父层是border
if (layout.getParent() != null) {
int paraHeight = designer.getParaHeight();
if (needCalculateParaHeight && paraHeight > 0) {
designer.setParaHeight(paraHeight);
XWBorderLayout parent = (XWBorderLayout) layout.getParent();
parent.toData().setNorthSize(paraHeight);
parent.removeAll();
parent.add(designer.getParaComponent(), WBorderLayout.NORTH);
parent.add(designer.getRootComponent(), WBorderLayout.CENTER);
}
layout.getParent().setSize(d.width, d.height + paraHeight);
// 调整自适应布局大小后,同步调整参数界面和border大小,此时刷新下formArea
FormArea.this.validate();
}
START_VALUE = value;
}
} }
/** /**
* 按照界面大小的百分比值调整root大小 * 按照界面大小的百分比值调整root大小
* *
* @param needCalculateParaHeight 是否需要调整参数界面高度
* @param value
*/ */
private void reCalculateDefaultRoot(double value, boolean needCalculateParaHeight) { private void reCalculateDefaultRoot() {
XLayoutContainer root = FormArea.this.designer.getRootComponent(); XLayoutContainer root = FormArea.this.designer.getRootComponent();
if (root.acceptType(XWFitLayout.class)) { if (root.acceptType(XWFitLayout.class)) {
XWFitLayout layout = (XWFitLayout) root; XWFitLayout layout = (XWFitLayout) root;
layout.setContainerPercent(1.0);
traverAndAdjust(layout, 0.0); traverAndAdjust(layout, 0.0);
layout.adjustCreatorsWhileSlide(0.0); layout.adjustCreatorsWhileSlide(0.0);
// 拖动滑块,先将内部组件百分比大小计算,再计算容器大小 // 拖动滑块,先将内部组件百分比大小计算,再计算容器大小
Dimension d = new Dimension(layout.getWidth(), layout.getHeight()); Dimension d = new Dimension(layout.getWidth(), layout.getHeight());
// 自适应布局的父层是border // 自适应布局的父层是border
if (layout.getParent() != null) { if (layout.getParent() != null) {
int paraHeight = designer.getParaHeight(); int paraHeight = designer.getParaHeight();
if (needCalculateParaHeight && paraHeight > 0) { if (paraHeight > 0) {
designer.setParaHeight(paraHeight); designer.setParaHeight(paraHeight);
XWBorderLayout parent = (XWBorderLayout) layout.getParent(); XWBorderLayout parent = (XWBorderLayout) layout.getParent();
parent.toData().setNorthSize(paraHeight); parent.toData().setNorthSize(paraHeight);
@ -885,16 +771,11 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
heightPane.setValue(height); heightPane.setValue(height);
reCalculateHeight((int) height); reCalculateHeight((int) height);
} }
if (designer.getRootComponent().acceptType(XWFitLayout.class) && AssistUtils.equals(screenValue, DEFAULT_SLIDER) ) { if (designer.getRootComponent().acceptType(XWFitLayout.class) ) {
XWFitLayout layout = (XWFitLayout) designer.getRootComponent(); XWFitLayout layout = (XWFitLayout) designer.getRootComponent();
// 撤销时先refreshRoot了,此处去掉内边距再增加间隔 // 撤销时先refreshRoot了,此处去掉内边距再增加间隔
layout.moveContainerMargin(); layout.moveContainerMargin();
layout.addCompInterval(layout.getAcualInterval()); layout.addCompInterval(layout.getAcualInterval());
} else if (designer.getRootComponent().acceptType(XWFitLayout.class)) {
START_VALUE = DEFAULT_SLIDER;
reCalculateRoot(screenValue, true);
// slidePane.populateBean(slide);
} }
this.slidePane.setShowValue((int) slide); this.slidePane.setShowValue((int) slide);
} }

10
designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java

@ -43,7 +43,6 @@ import com.fr.design.designer.properties.FormWidgetAuthorityEditPane;
import com.fr.design.dialog.FineJOptionPane; import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.event.DesignerOpenedListener; import com.fr.design.event.DesignerOpenedListener;
import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.fit.DesignerUIModeConfig;
import com.fr.design.form.util.XCreatorConstants; import com.fr.design.form.util.XCreatorConstants;
import com.fr.design.fun.RightSelectionHandlerProvider; import com.fr.design.fun.RightSelectionHandlerProvider;
import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus; import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus;
@ -151,7 +150,6 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
// 存储被选择组件和剪切板的model // 存储被选择组件和剪切板的model
private transient SelectionModel selectionModel; private transient SelectionModel selectionModel;
private int resolution = DesignerUIModeConfig.getInstance().getScreenResolution();
// 编辑状态的事件表 // 编辑状态的事件表
private CreatorEventListenerTable edit; private CreatorEventListenerTable edit;
protected List<UpdateAction> designerActions; protected List<UpdateAction> designerActions;
@ -1801,14 +1799,6 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
} }
public void setResolution(int resolution) {
this.resolution = resolution;
}
public int getResolution() {
return this.resolution;
}
public double getScale() { public double getScale() {
return scale; return scale;
} }

3
designer-form/src/main/java/com/fr/design/mainframe/FormDesignerUI.java

@ -1,6 +1,7 @@
package com.fr.design.mainframe; package com.fr.design.mainframe;
import com.fr.base.GraphHelper; import com.fr.base.GraphHelper;
import com.fr.base.ScreenResolution;
import com.fr.base.Utils; import com.fr.base.Utils;
import com.fr.base.iofile.attr.WatermarkAttr; import com.fr.base.iofile.attr.WatermarkAttr;
import com.fr.base.vcs.DesignerMode; import com.fr.base.vcs.DesignerMode;
@ -132,7 +133,7 @@ public class FormDesignerUI extends ComponentUI {
return; return;
} }
WatermarkAttr watermark = ReportUtils.getWatermarkAttrFromTemplateAndGlobal(designer.getTarget()); WatermarkAttr watermark = ReportUtils.getWatermarkAttrFromTemplateAndGlobal(designer.getTarget());
WatermarkPainter painter = WatermarkPainter.createPainter(watermark, designer.getResolution()); WatermarkPainter painter = WatermarkPainter.createPainter(watermark, ScreenResolution.getScreenResolution());
painter.paint(g, 0, 0, designer.getArea().getBounds()); painter.paint(g, 0, 0, designer.getArea().getBounds());
} }

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

@ -182,11 +182,10 @@ public class FormSelectionUtils {
if (!childrenList.isEmpty()) { if (!childrenList.isEmpty()) {
for (Object aChildrenList : childrenList) { for (Object aChildrenList : childrenList) {
XWTabFitLayout tabLayout = (XWTabFitLayout) aChildrenList; XWTabFitLayout tabLayout = (XWTabFitLayout) aChildrenList;
double percent = tabLayout.getContainerPercent();
Component[] components = tabLayout.getComponents(); Component[] components = tabLayout.getComponents();
for (Component component : components) { for (Component component : components) {
Rectangle show = component.getBounds(); Rectangle show = component.getBounds();
component.setBounds(new Rectangle((int) (show.x * percent), (int) (show.y * percent), (int) (show.width * percent), (int) (show.height * percent))); component.setBounds(new Rectangle(show.x, show.y, show.width, show.height));
} }
} }
} }

4
designer-form/src/main/java/com/fr/design/mainframe/JForm.java

@ -1235,4 +1235,8 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm<F
DesignerContext.getDesignerFrame().addAndActivateJTemplate(jForm); DesignerContext.getDesignerFrame().addAndActivateJTemplate(jForm);
DesignerContext.getDesignerFrame().getCenterTemplateCardPane().showForbiddenStatus(); DesignerContext.getDesignerFrame().getCenterTemplateCardPane().showForbiddenStatus();
} }
public void setDesignerUIMode(){
DesignerUIModeConfig.getInstance().setSimulateWebUIMode();
}
} }

15
designer-form/src/main/java/com/fr/design/mainframe/share/action/CreateComponentAction.java

@ -10,7 +10,9 @@ import com.fr.data.impl.NameTableData;
import com.fr.data.impl.TableDataDictionary; import com.fr.data.impl.TableDataDictionary;
import com.fr.design.actions.UpdateAction; import com.fr.design.actions.UpdateAction;
import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.DesignTableDataManager;
import com.fr.design.designer.creator.XChartEditor;
import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XWTitleLayout;
import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.BasicPane;
import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.dialog.FineJOptionPane; import com.fr.design.dialog.FineJOptionPane;
@ -56,8 +58,10 @@ import javax.swing.Action;
import javax.swing.UIManager; import javax.swing.UIManager;
import java.awt.Color; import java.awt.Color;
import java.awt.Component; import java.awt.Component;
import java.awt.Dimension;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import java.awt.Image; import java.awt.Image;
import java.awt.Insets;
import java.awt.Rectangle; import java.awt.Rectangle;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
@ -263,6 +267,17 @@ public class CreateComponentAction extends UpdateAction {
g2d.setColor(Color.WHITE); g2d.setColor(Color.WHITE);
g2d.fillRect(0, 0 , rect.width, rect.height); g2d.fillRect(0, 0 , rect.width, rect.height);
comp.paint(im.getGraphics()); comp.paint(im.getGraphics());
if (comp instanceof XWTitleLayout) {
XCreator body = ((XWTitleLayout) comp).getBodyCreator();
if (body instanceof XChartEditor) {
XChartEditor chartEditor = (XChartEditor) body;
Dimension size = chartEditor.getSize();
BufferedImage chartImage = new BufferedImage(size.width, size.height, BufferedImage.TYPE_INT_ARGB);
Insets margin = chartEditor.getInsets();;
chartEditor.getDesignerEditor().paintEditor(chartImage.getGraphics(), size, margin);
im.getGraphics().drawImage(chartImage, 0, chartEditor.getY(), null);
}
}
return im; return im;
} }

3
designer-form/src/main/java/com/fr/design/mainframe/share/select/ComponentTransformerImpl.java

@ -30,7 +30,6 @@ import org.jetbrains.annotations.Nullable;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.Rectangle; import java.awt.Rectangle;
import java.awt.Toolkit;
import java.util.Comparator; import java.util.Comparator;
import java.util.Map; import java.util.Map;
import java.util.TreeMap; import java.util.TreeMap;
@ -88,8 +87,6 @@ public class ComponentTransformerImpl implements ComponentTransformer {
FRContext.getLogger().error(e1.getMessage(), e1); FRContext.getLogger().error(e1.getMessage(), e1);
} }
} }
wAbsoluteLayout.setDesigningResolution(Toolkit.getDefaultToolkit().getScreenSize());
selectedCreator = new XWAbsoluteLayout(wAbsoluteLayout, new Dimension(selectedTriple.width, selectedTriple.height)); selectedCreator = new XWAbsoluteLayout(wAbsoluteLayout, new Dimension(selectedTriple.width, selectedTriple.height));
selectedWidget = selectedCreator.toData(); selectedWidget = selectedCreator.toData();

33
designer-form/src/main/java/com/fr/design/mainframe/share/ui/base/PlaceholderTextArea.java

@ -10,22 +10,27 @@ import java.awt.RenderingHints;
* created by Harrison on 2020/04/21 * created by Harrison on 2020/04/21
**/ **/
public class PlaceholderTextArea extends UITextArea { public class PlaceholderTextArea extends UITextArea {
private String placeholder; private String placeholder;
public PlaceholderTextArea() { public PlaceholderTextArea() {
} }
public PlaceholderTextArea(String s, String placeholder) { public PlaceholderTextArea(String s, String placeholder) {
super(s); super(s);
this.placeholder = placeholder; this.placeholder = placeholder;
} }
public PlaceholderTextArea(int i, int j, String placeholder) {
super(i, j);
this.placeholder = placeholder;
}
public void setPlaceholder(String placeholder) { public void setPlaceholder(String placeholder) {
this.placeholder = placeholder; this.placeholder = placeholder;
} }
@Override @Override
protected void paintComponent(final Graphics pG) { protected void paintComponent(final Graphics pG) {
super.paintComponent(pG); super.paintComponent(pG);
@ -37,6 +42,16 @@ public class PlaceholderTextArea extends UITextArea {
RenderingHints.KEY_ANTIALIASING, RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON); RenderingHints.VALUE_ANTIALIAS_ON);
g.setColor(getDisabledTextColor()); g.setColor(getDisabledTextColor());
g.drawString(placeholder, getInsets().left, pG.getFontMetrics() drawPlaceholder(pG);
.getMaxAscent() + getInsets().top + 1); }
}}
private void drawPlaceholder(Graphics g) {
int x = getInsets().left;
int y = g.getFontMetrics().getMaxAscent() + getInsets().top + 1;
for (String line : placeholder.split("\n")) {
g.drawString(line, x, y);
y += g.getFontMetrics().getHeight();
}
}
}

4
designer-form/src/main/java/com/fr/design/parameter/RootDesignDefinePane.java

@ -10,7 +10,6 @@ import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XWParameterLayout; import com.fr.design.designer.creator.XWParameterLayout;
import com.fr.design.designer.properties.PropertyTab; import com.fr.design.designer.properties.PropertyTab;
import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.fit.DesignerUIModeConfig;
import com.fr.design.fit.common.TemplateTool; import com.fr.design.fit.common.TemplateTool;
import com.fr.design.foldablepane.UIExpandablePane; import com.fr.design.foldablepane.UIExpandablePane;
import com.fr.design.fun.ParameterExpandablePaneUIProvider; import com.fr.design.fun.ParameterExpandablePaneUIProvider;
@ -22,6 +21,7 @@ import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper; import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.DesignerUIModeConfig;
import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.FormSelection; import com.fr.design.mainframe.FormSelection;
import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.JTemplate;
@ -61,7 +61,7 @@ public class RootDesignDefinePane extends AbstractDataModify<WParameterLayout> {
public RootDesignDefinePane(XCreator xCreator) { public RootDesignDefinePane(XCreator xCreator) {
super(xCreator); super(xCreator);
newForm = TemplateTool.getCurrentEditingNewJForm() != null && DesignerUIModeConfig.getInstance().newUIMode(); newForm = TemplateTool.getCurrentEditingNewJForm() != null && DesignerUIModeConfig.getInstance().simulateWebUIMode();
this.root = (XWParameterLayout) xCreator; this.root = (XWParameterLayout) xCreator;
initComponent(); initComponent();
} }

4
designer-form/src/main/java/com/fr/design/widget/ui/designer/component/WidgetBoundPane.java

@ -150,7 +150,7 @@ public class WidgetBoundPane extends BasicPane {
public void limitWidth(WLayout wabs, int w, Rectangle bounds, Rectangle rec) { public void limitWidth(WLayout wabs, int w, Rectangle bounds, Rectangle rec) {
int difference = 0; int difference = 0;
int minWidth = (int) (MINWIDTH * ((WFitLayout) wabs).getResolutionScaling()); int minWidth = MINWIDTH;
PaddingMargin margin = wabs.getMargin(); PaddingMargin margin = wabs.getMargin();
if (bounds.width != w) { if (bounds.width != w) {
if (bounds.width == rec.width - margin.getLeft() - margin.getRight()) { if (bounds.width == rec.width - margin.getLeft() - margin.getRight()) {
@ -172,7 +172,7 @@ public class WidgetBoundPane extends BasicPane {
public void limitHeight(WLayout wabs, int h, Rectangle bounds, Rectangle rec) { public void limitHeight(WLayout wabs, int h, Rectangle bounds, Rectangle rec) {
int difference = 0; int difference = 0;
PaddingMargin margin = wabs.getMargin(); PaddingMargin margin = wabs.getMargin();
int minHeight = (int) (MINHEIGHT * ((WFitLayout) wabs).getResolutionScaling()); int minHeight = MINHEIGHT;
if (bounds.height != h) { if (bounds.height != h) {
if (bounds.height == rec.height - margin.getTop() - margin.getBottom()) { if (bounds.height == rec.height - margin.getTop() - margin.getBottom()) {
FineJOptionPane.showMessageDialog(null, i18nText("Fine-Design_Form_Beyond_Bounds")); FineJOptionPane.showMessageDialog(null, i18nText("Fine-Design_Form_Beyond_Bounds"));

10
designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/ElementEditorDefinePane.java

@ -5,7 +5,7 @@ import com.fr.base.theme.TemplateTheme;
import com.fr.base.theme.settings.ThemedComponentStyle; import com.fr.base.theme.settings.ThemedComponentStyle;
import com.fr.design.designer.IntervalConstants; import com.fr.design.designer.IntervalConstants;
import com.fr.design.designer.creator.*; import com.fr.design.designer.creator.*;
import com.fr.design.fit.DesignerUIModeConfig; import com.fr.design.fit.common.TemplateTool;
import com.fr.design.fit.attrpane.PcFitExpandablePane; import com.fr.design.fit.attrpane.PcFitExpandablePane;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.style.FollowingThemePane; import com.fr.design.gui.style.FollowingThemePane;
@ -76,7 +76,7 @@ public class ElementEditorDefinePane extends WTitleLayoutDefinePane<ElementCaseE
centerPane.add(extraPropertyGroupPane, BorderLayout.CENTER); centerPane.add(extraPropertyGroupPane, BorderLayout.CENTER);
} }
pcFitExpandablePane = new PcFitExpandablePane(this); pcFitExpandablePane = new PcFitExpandablePane(this);
if (DesignerUIModeConfig.getInstance().newUIMode()) { if (TemplateTool.isCurrentEditingNewJForm()) {
centerPane.add(pcFitExpandablePane, BorderLayout.SOUTH); centerPane.add(pcFitExpandablePane, BorderLayout.SOUTH);
} }
@ -84,7 +84,7 @@ public class ElementEditorDefinePane extends WTitleLayoutDefinePane<ElementCaseE
} }
private CRPropertyDescriptor[] removeOldFitEditor(CRPropertyDescriptor[] extraTableEditor) { private CRPropertyDescriptor[] removeOldFitEditor(CRPropertyDescriptor[] extraTableEditor) {
if (!DesignerUIModeConfig.getInstance().newUIMode()) { if (!TemplateTool.isCurrentEditingNewJForm()) {
return extraTableEditor; return extraTableEditor;
} }
List<CRPropertyDescriptor> list = new ArrayList<CRPropertyDescriptor>(); List<CRPropertyDescriptor> list = new ArrayList<CRPropertyDescriptor>();
@ -102,7 +102,7 @@ public class ElementEditorDefinePane extends WTitleLayoutDefinePane<ElementCaseE
paddingBoundPane.update(elementCaseEditor); paddingBoundPane.update(elementCaseEditor);
} }
elementCaseEditor.setToolBars((FormToolBarManager[]) elementCaseToolBarEditor.getValue()); elementCaseEditor.setToolBars((FormToolBarManager[]) elementCaseToolBarEditor.getValue());
if (DesignerUIModeConfig.getInstance().newUIMode()) { if (TemplateTool.isCurrentEditingNewJForm()) {
ReportFitAttr fitAttr = pcFitExpandablePane.update(); ReportFitAttr fitAttr = pcFitExpandablePane.update();
elementCaseEditor.setReportFitAttr(fitAttr); elementCaseEditor.setReportFitAttr(fitAttr);
} }
@ -114,7 +114,7 @@ public class ElementEditorDefinePane extends WTitleLayoutDefinePane<ElementCaseE
paddingBoundPane.populate(ob); paddingBoundPane.populate(ob);
elementCaseToolBarEditor.setValue(ob.getToolBars()); elementCaseToolBarEditor.setValue(ob.getToolBars());
extraPropertyGroupPane.populate(ob); extraPropertyGroupPane.populate(ob);
if (DesignerUIModeConfig.getInstance().newUIMode()) { if (TemplateTool.isCurrentEditingNewJForm()) {
pcFitExpandablePane.populate(ob.getReportFitAttr()); pcFitExpandablePane.populate(ob.getReportFitAttr());
} }
} }

6
designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRAbsoluteBodyLayoutDefinePane.java

@ -11,7 +11,7 @@ import com.fr.design.designer.creator.XWFitLayout;
import com.fr.design.designer.properties.items.FRLayoutTypeItems; import com.fr.design.designer.properties.items.FRLayoutTypeItems;
import com.fr.design.designer.properties.items.Item; import com.fr.design.designer.properties.items.Item;
import com.fr.design.dialog.FineJOptionPane; import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.fit.DesignerUIModeConfig; import com.fr.design.fit.common.TemplateTool;
import com.fr.design.foldablepane.UIExpandablePane; import com.fr.design.foldablepane.UIExpandablePane;
import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
@ -65,7 +65,7 @@ public class FRAbsoluteBodyLayoutDefinePane extends FRAbsoluteLayoutDefinePane {
initUIComboBox(); initUIComboBox();
this.setLayout(FRGUIPaneFactory.createBorderLayout()); this.setLayout(FRGUIPaneFactory.createBorderLayout());
boundPane = new WidgetBoundPane(creator); boundPane = new WidgetBoundPane(creator);
if (!DesignerUIModeConfig.getInstance().newUIMode()){ if (!TemplateTool.isCurrentEditingNewJForm()){
this.add(boundPane, BorderLayout.NORTH); this.add(boundPane, BorderLayout.NORTH);
} }
JPanel panel1 = FRGUIPaneFactory.createBorderLayout_S_Pane(); JPanel panel1 = FRGUIPaneFactory.createBorderLayout_S_Pane();
@ -124,7 +124,7 @@ public class FRAbsoluteBodyLayoutDefinePane extends FRAbsoluteLayoutDefinePane {
UILabel layoutTypeLabel = FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Attr_Layout_Type")); UILabel layoutTypeLabel = FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Attr_Layout_Type"));
UILabel scaleModeLabel = FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Scaling_Mode")); UILabel scaleModeLabel = FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Scaling_Mode"));
Component[][] components = DesignerUIModeConfig.getInstance().newUIMode() ? new Component[][]{ Component[][] components = TemplateTool.isCurrentEditingNewJForm() ? new Component[][]{
{layoutTypeLabel, layoutCombox} {layoutTypeLabel, layoutCombox}
} : new Component[][]{ } : new Component[][]{
{layoutTypeLabel, layoutCombox}, {layoutTypeLabel, layoutCombox},

4
designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRAbsoluteLayoutDefinePane.java

@ -5,7 +5,7 @@ import com.fr.design.designer.IntervalConstants;
import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.properties.items.FRAbsoluteConstraintsItems; import com.fr.design.designer.properties.items.FRAbsoluteConstraintsItems;
import com.fr.design.designer.properties.items.Item; import com.fr.design.designer.properties.items.Item;
import com.fr.design.fit.DesignerUIModeConfig; import com.fr.design.fit.common.TemplateTool;
import com.fr.design.foldablepane.UIExpandablePane; import com.fr.design.foldablepane.UIExpandablePane;
import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
@ -40,7 +40,7 @@ public class FRAbsoluteLayoutDefinePane extends AbstractFRLayoutDefinePane<WAbso
jPanel.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0)); jPanel.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0));
thirdPane.add(jPanel, BorderLayout.CENTER); thirdPane.add(jPanel, BorderLayout.CENTER);
UIExpandablePane layoutExpandablePane = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Area_Scaling"), 280, 20, thirdPane); UIExpandablePane layoutExpandablePane = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Area_Scaling"), 280, 20, thirdPane);
if (!DesignerUIModeConfig.getInstance().newUIMode()){ if (!TemplateTool.isCurrentEditingNewJForm()){
this.add(layoutExpandablePane, BorderLayout.CENTER); this.add(layoutExpandablePane, BorderLayout.CENTER);
} }
} }

8
designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRFitLayoutDefinePane.java

@ -16,7 +16,7 @@ import com.fr.design.designer.creator.XWScaleLayout;
import com.fr.design.designer.properties.items.FRFitConstraintsItems; import com.fr.design.designer.properties.items.FRFitConstraintsItems;
import com.fr.design.designer.properties.items.FRLayoutTypeItems; import com.fr.design.designer.properties.items.FRLayoutTypeItems;
import com.fr.design.designer.properties.items.Item; import com.fr.design.designer.properties.items.Item;
import com.fr.design.fit.DesignerUIModeConfig; import com.fr.design.fit.common.TemplateTool;
import com.fr.design.foldablepane.UIExpandablePane; import com.fr.design.foldablepane.UIExpandablePane;
import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
@ -30,7 +30,6 @@ import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.FormSelectionUtils; import com.fr.design.mainframe.FormSelectionUtils;
import com.fr.design.mainframe.WidgetPropertyPane; import com.fr.design.mainframe.WidgetPropertyPane;
import com.fr.design.mainframe.widget.accessibles.AccessibleBodyWatermarkEditor; import com.fr.design.mainframe.widget.accessibles.AccessibleBodyWatermarkEditor;
import com.fr.design.ui.util.UIUtil;
import com.fr.design.utils.gui.UIComponentUtils; import com.fr.design.utils.gui.UIComponentUtils;
import com.fr.design.widget.FRWidgetFactory; import com.fr.design.widget.FRWidgetFactory;
import com.fr.design.widget.ui.designer.component.PaddingBoundPane; import com.fr.design.widget.ui.designer.component.PaddingBoundPane;
@ -46,10 +45,7 @@ import com.fr.log.FineLoggerFactory;
import com.fr.report.core.ReportUtils; import com.fr.report.core.ReportUtils;
import javax.swing.*; import javax.swing.*;
import javax.swing.border.Border;
import java.awt.*; import java.awt.*;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
/** /**
* Created by ibm on 2017/8/2. * Created by ibm on 2017/8/2.
@ -151,7 +147,7 @@ public class FRFitLayoutDefinePane extends AbstractFRLayoutDefinePane<WFitLayout
UILabel adaptLabel = FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Component_Scale")); UILabel adaptLabel = FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Component_Scale"));
UILabel intervalLabel = FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Component_Interval")); UILabel intervalLabel = FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Component_Interval"));
Component[][] components = DesignerUIModeConfig.getInstance().newUIMode() ? new Component[][]{ Component[][] components = TemplateTool.isCurrentEditingNewJForm() ? new Component[][]{
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Attr_Layout_Type")), layoutComboBox}, {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Attr_Layout_Type")), layoutComboBox},
{intervalLabel, componentIntervelPane} {intervalLabel, componentIntervelPane}
} : new Component[][]{ } : new Component[][]{

11
designer-form/src/test/java/com/fr/design/fit/FormUIModeConfigTest.java

@ -1,5 +1,6 @@
package com.fr.design.fit; package com.fr.design.fit;
import com.fr.design.mainframe.DesignerUIModeConfig;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
@ -9,14 +10,14 @@ import org.junit.Test;
public class FormUIModeConfigTest { public class FormUIModeConfigTest {
@Test @Test
public void testSetNewUIMode(){ public void testSetNewUIMode(){
DesignerUIModeConfig.getInstance().setNewUIMode(); DesignerUIModeConfig.getInstance().setSimulateWebUIMode();
Assert.assertTrue(DesignerUIModeConfig.getInstance().newUIMode()); Assert.assertTrue(DesignerUIModeConfig.getInstance().simulateWebUIMode());
} }
@Test @Test
public void testSetOldUIMode(){ public void testSetOldUIMode(){
Assert.assertTrue(DesignerUIModeConfig.getInstance().newUIMode()); Assert.assertTrue(DesignerUIModeConfig.getInstance().simulateWebUIMode());
DesignerUIModeConfig.getInstance().setOldUIMode(); DesignerUIModeConfig.getInstance().setAbsoluteMeasureUIMode();
Assert.assertFalse(DesignerUIModeConfig.getInstance().newUIMode()); Assert.assertFalse(DesignerUIModeConfig.getInstance().simulateWebUIMode());
} }
} }

1
designer-form/src/test/java/com/fr/design/fit/PXReportLengthUNITTest.java

@ -1,6 +1,7 @@
package com.fr.design.fit; package com.fr.design.fit;
import com.fr.base.ScreenResolution; import com.fr.base.ScreenResolution;
import com.fr.design.mainframe.PXReportLengthUNIT;
import com.fr.stable.unit.FU; import com.fr.stable.unit.FU;
import org.easymock.EasyMock; import org.easymock.EasyMock;
import org.junit.Assert; import org.junit.Assert;

1
designer-form/src/test/java/com/fr/design/fit/PXTest.java

@ -1,6 +1,7 @@
package com.fr.design.fit; package com.fr.design.fit;
import com.fr.base.ScreenResolution; import com.fr.base.ScreenResolution;
import com.fr.design.mainframe.PX;
import com.fr.invoke.Reflect; import com.fr.invoke.Reflect;
import org.easymock.EasyMock; import org.easymock.EasyMock;
import org.junit.Assert; import org.junit.Assert;

2
designer-realize/src/main/java/com/fr/design/actions/cell/BorderAction.java

@ -14,7 +14,6 @@ import com.fr.design.style.BorderUtils;
import com.fr.grid.selection.CellSelection; import com.fr.grid.selection.CellSelection;
import com.fr.grid.selection.FloatSelection; import com.fr.grid.selection.FloatSelection;
import com.fr.grid.selection.Selection; import com.fr.grid.selection.Selection;
import com.fr.report.cell.CellElementBorderSourceFlag;
import com.fr.report.cell.FloatElement; import com.fr.report.cell.FloatElement;
import com.fr.report.cell.StyleProvider; import com.fr.report.cell.StyleProvider;
import com.fr.report.cell.TemplateCellElement; import com.fr.report.cell.TemplateCellElement;
@ -102,7 +101,6 @@ public class BorderAction extends ElementCaseAction implements ChangeListener {
TemplateCellElement cellElement = elementCase.getTemplateCellElement(column, row); TemplateCellElement cellElement = elementCase.getTemplateCellElement(column, row);
if (cellElement != null) { if (cellElement != null) {
resetElementStyleToCustom(cellElement); resetElementStyleToCustom(cellElement);
cellElement.setBorderSourceFlags(CellElementBorderSourceFlag.INVALID_BORDER_SOURCE);
}; };
} }
} }

2
designer-realize/src/main/java/com/fr/design/actions/columnrow/ColumnRowSizingAction.java

@ -4,7 +4,7 @@
package com.fr.design.actions.columnrow; package com.fr.design.actions.columnrow;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.fit.DesignerUIModeConfig; import com.fr.design.mainframe.DesignerUIModeConfig;
import com.fr.design.fun.ReportLengthUNITProvider; import com.fr.design.fun.ReportLengthUNITProvider;
import com.fr.design.gui.frpane.UnitInputPane; import com.fr.design.gui.frpane.UnitInputPane;
import com.fr.design.gui.frpane.UnitInputPane.ValueNotChangeException; import com.fr.design.gui.frpane.UnitInputPane.ValueNotChangeException;

2
designer-realize/src/main/java/com/fr/design/condition/WHPane.java

@ -1,7 +1,7 @@
package com.fr.design.condition; package com.fr.design.condition;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.fit.DesignerUIModeConfig; import com.fr.design.mainframe.DesignerUIModeConfig;
import com.fr.design.fun.ReportLengthUNITProvider; import com.fr.design.fun.ReportLengthUNITProvider;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.ispinner.UIBasicSpinner; import com.fr.design.gui.ispinner.UIBasicSpinner;

145
designer-realize/src/main/java/com/fr/design/dscolumn/DSColumnAdvancedPane.java

@ -2,6 +2,7 @@ package com.fr.design.dscolumn;
import com.fr.base.BaseFormula; import com.fr.base.BaseFormula;
import com.fr.data.util.SortOrder; import com.fr.data.util.SortOrder;
import com.fr.design.border.UITitledBorder;
import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.DesignTableDataManager;
import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.BasicPane;
import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.dialog.DialogActionAdapter;
@ -9,10 +10,10 @@ import com.fr.design.formula.CustomVariableResolver;
import com.fr.design.formula.FormulaFactory; import com.fr.design.formula.FormulaFactory;
import com.fr.design.formula.SortFormulaPane; import com.fr.design.formula.SortFormulaPane;
import com.fr.design.formula.UIFormula; import com.fr.design.formula.UIFormula;
import com.fr.design.gui.frpane.AbstractAttrNoScrollPane;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.ispinner.UISpinner; import com.fr.design.gui.ispinner.UISpinner;
import com.fr.design.gui.itextfield.UITextField; import com.fr.design.gui.itextfield.UITextField;
@ -20,14 +21,13 @@ import com.fr.design.gui.style.TextFormatPane;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper; import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.style.FormatPane; import com.fr.design.sort.celldscolumn.CellDSColumnSortPane;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.report.cell.CellElement; import com.fr.report.cell.CellElement;
import com.fr.report.cell.TemplateCellElement; import com.fr.report.cell.TemplateCellElement;
import com.fr.report.cell.cellattr.CellExpandAttr; import com.fr.report.cell.cellattr.CellExpandAttr;
import com.fr.report.cell.cellattr.core.group.DSColumn; import com.fr.report.cell.cellattr.core.group.DSColumn;
import com.fr.report.cell.cellattr.core.group.SelectCount; import com.fr.report.cell.cellattr.core.group.SelectCount;
import com.fr.van.chart.designer.component.format.FormatPaneWithOutFont;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
@ -49,28 +49,41 @@ public class DSColumnAdvancedPane extends BasicPane {
private UICheckBox verticalExtendableCheckBox; private UICheckBox verticalExtendableCheckBox;
private UICheckBox useMultiplyNumCheckBox; private UICheckBox useMultiplyNumCheckBox;
private UISpinner multiNumSpinner; private UISpinner multiNumSpinner;
private JPanel contentPane;
public DSColumnAdvancedPane() { public DSColumnAdvancedPane() {
this(DSColumnPane.SETTING_ALL); this(DSColumnPane.SETTING_ALL);
} }
public DSColumnAdvancedPane(int setting) { public DSColumnAdvancedPane(int setting) {
this.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3)); initContentPane(setting);
this.setLayout(FRGUIPaneFactory.createBorderLayout()); initScrollPane();
}
private void initScrollPane() {
ScrollPane scrollPane = new ScrollPane(contentPane);
this.add(scrollPane);
}
private void initContentPane(int setting) {
contentPane = new JPanel();
contentPane.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
contentPane.setLayout(FRGUIPaneFactory.createBorderLayout());
sortPane = new SortPane(); sortPane = new SortPane();
sortPane.setBorder(GUICoreUtils.createTitledBorder(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Sort_Sort_Order"), null)); sortPane.setBorder(UITitledBorder.createBorderWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Sort_Sort_Order")));
if (setting > DSColumnPane.SETTING_DSRELATED) { if (setting > DSColumnPane.SETTING_DSRELATED) {
selectCountPane = new SelectCountPane(); selectCountPane = new SelectCountPane();
selectCountPane.setBorder(GUICoreUtils.createTitledBorder(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Bind_Column_Results_Filter"), null)); selectCountPane.setBorder(UITitledBorder.createBorderWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Bind_Column_Results_Filter")));
} }
valuePane = new ValuePane(); valuePane = new ValuePane();
valuePane.setBorder(GUICoreUtils.createTitledBorder(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Bind_Column_Custom_Data_Appearance"), null)); valuePane.setBorder(UITitledBorder.createBorderWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Bind_Column_Custom_Data_Appearance")));
formatAttrPane = new FormatAttrPane(); formatAttrPane = new FormatAttrPane();
JPanel titleBorderedFormatPane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Base_Format"));
titleBorderedFormatPane.add(formatAttrPane, BorderLayout.NORTH);
JPanel extendablePane = null; JPanel extendablePane = null;
if (setting > DSColumnPane.SETTING_DSRELATED) { if (setting > DSColumnPane.SETTING_DSRELATED) {
@ -109,7 +122,7 @@ public class DSColumnAdvancedPane extends BasicPane {
{sortPane}, {sortPane},
{selectCountPane}, {selectCountPane},
{valuePane}, {valuePane},
{formatAttrPane}, {titleBorderedFormatPane},
{extendablePane}, {extendablePane},
{multiNumPane} {multiNumPane}
}; };
@ -117,7 +130,7 @@ public class DSColumnAdvancedPane extends BasicPane {
components = new Component[][]{ components = new Component[][]{
{sortPane}, {sortPane},
{valuePane}, {valuePane},
{formatAttrPane} {titleBorderedFormatPane}
}; };
} }
@ -125,7 +138,7 @@ public class DSColumnAdvancedPane extends BasicPane {
TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED}; TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED};
double[] columnSize = {TableLayout.FILL}; double[] columnSize = {TableLayout.FILL};
this.add(TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize), BorderLayout.CENTER); contentPane.add(TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize), BorderLayout.CENTER);
} }
@Override @Override
@ -138,7 +151,7 @@ public class DSColumnAdvancedPane extends BasicPane {
return; return;
} }
sortPane.populate(cellElement); sortPane.populateBean(cellElement);
valuePane.populate(cellElement); valuePane.populate(cellElement);
formatAttrPane.populate(cellElement); formatAttrPane.populate(cellElement);
@ -188,7 +201,7 @@ public class DSColumnAdvancedPane extends BasicPane {
return; return;
} }
sortPane.update(cellElement); sortPane.updateBean(cellElement);
valuePane.update(cellElement); valuePane.update(cellElement);
formatAttrPane.update(cellElement); formatAttrPane.update(cellElement);
@ -224,66 +237,25 @@ public class DSColumnAdvancedPane extends BasicPane {
} }
} }
private static class SortPane extends SortFormulaPane { private static class ScrollPane extends UIScrollPane {
private CellElement cellElement; ScrollPane(Component component) {
super(component);
this.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
}
@Override @Override
public void formulaAction() { public Dimension getPreferredSize() {
if (cellElement == null) { return new Dimension(DSColumnPane.DEFAULT_DIMENSION.width - 20, DSColumnPane.DEFAULT_DIMENSION.height - 100);
return;
}
Object value = cellElement.getValue();
if (value == null || !(value instanceof DSColumn)) {
return;
}
String[] displayNames = DesignTableDataManager.getSelectedColumnNames(
DesignTableDataManager.getEditingTableDataSource(), ((DSColumn) value).getDSName());
showFormulaDialog(displayNames);
} }
}
void populate(CellElement cellElement) { private static class SortPane extends CellDSColumnSortPane {
if (cellElement == null) { SortPane() {
return; this.setLayout(new FlowLayout(FlowLayout.LEFT));
}
this.cellElement = cellElement;
Object value = cellElement.getValue();
if (value == null || !(value instanceof DSColumn)) {
return;
}
DSColumn dSColumn = (DSColumn) value;
int sort = dSColumn.getOrder();
this.sortOrderComboBox.setSortOrder(new SortOrder(sort));
String sortFormula = dSColumn.getSortFormula();
sortFormulaTextField.setText(sortFormula);
} }
public void update(CellElement cellElement) { protected boolean needSortHeaderPane() {
if (cellElement == null) { return false;
return;
}
Object value = cellElement.getValue();
if (value == null || !(value instanceof DSColumn)) {
return;
}
DSColumn dSColumn = (DSColumn) (cellElement.getValue());
dSColumn.setOrder(this.sortOrderComboBox.getSortOrder().getOrder());
//lance:sort formula
String sText = null;
if (!(sortFormulaTextField.getText() == null || sortFormulaTextField.getText().trim().equals("") || sortFormulaTextField.getText().trim().equals("$$$"))) {
sText = new String(sortFormulaTextField.getText());
}
if (!(sText == null || sText.length() < 1)) {
dSColumn.setSortFormula(sText);
} else {
dSColumn.setSortFormula(null);
}
} }
} }
@ -538,40 +510,31 @@ public class DSColumnAdvancedPane extends BasicPane {
} }
} }
public class FormatAttrPane extends AbstractAttrNoScrollPane { public static class FormatAttrPane extends TextFormatPane {
private TextFormatPane formatPane;
@Override protected void initLayout() {
protected JPanel createContentPane() { JPanel settingPane = FRGUIPaneFactory.createBoxFlowInnerContainer_S_Pane(0, 4, 0);
this.formatPane = new TextFormatPane(); settingPane.add(typeComboBox);
return this.formatPane; settingPane.add(textField);
} settingPane.add(roundingBox);
@Override addComponents(4, new JComponent[]{settingPane, previewLabel});
public Dimension getPreferredSize() {
if (formatPane == null) {
return super.getPreferredSize();
}
return formatPane.getPreferredSize();
} }
protected void initContentPane() { @Override
leftContentPane = createContentPane(); protected void setRoundingBoxVisible(boolean visible) {
if (leftContentPane != null) { roundingBox.setVisible(visible);
leftContentPane.setBorder(BorderFactory.createEmptyBorder());
this.add(leftContentPane, BorderLayout.CENTER);
}
} }
public void populate(CellElement cellElement) { public void populate(CellElement cellElement) {
if (cellElement != null && formatPane != null) { if (cellElement != null) {
formatPane.populateBean(cellElement.getStyle()); populateBean(cellElement.getStyle());
} }
} }
public void update(CellElement cellElement) { public void update(CellElement cellElement) {
if (cellElement != null && formatPane != null) { if (cellElement != null) {
cellElement.setStyle(formatPane.update(cellElement.getStyle())); cellElement.setStyle(update(cellElement.getStyle()));
} }
} }
} }

70
designer-realize/src/main/java/com/fr/design/fit/grid/GridHeaderWithBoundMouseHandler.java

@ -1,70 +0,0 @@
package com.fr.design.fit.grid;
import com.fr.base.DynamicUnitList;
import com.fr.design.fit.DesignerUIModeConfig;
import com.fr.design.mainframe.ElementCasePane;
import com.fr.grid.GridHeader;
import com.fr.grid.AbstractGridHeaderMouseHandler;
import com.fr.report.elementcase.ElementCase;
import com.fr.report.elementcase.TemplateElementCase;
import java.awt.event.MouseEvent;
public abstract class GridHeaderWithBoundMouseHandler extends AbstractGridHeaderMouseHandler{
protected static final int FUZZY_EDGE = 10;
private int limit;
public GridHeaderWithBoundMouseHandler(GridHeader gHeader, int limit) {
super(gHeader);
this.limit = limit;
}
public void setLimit(int limit) {
this.limit = limit;
}
public int getLimit() {
return limit;
}
public int getDragIndex(MouseEvent evt) {
ElementCase report = this.getEditingElementCase();
DynamicUnitList sizeList = getSizeList(report);
int scrollValue = getScrollValue(this.getElementCasePane());
int scrollExtent = getScrollExtent(this.getElementCasePane());
int endValue = scrollValue + scrollExtent + 1;
int beginValue = getBeginValue(this.getElementCasePane());
double tmpSize1 = 0;
double tmpSize2;
double tmpIncreaseSize = 0;
int resolution = DesignerUIModeConfig.getInstance().getScreenResolution();
for (int index = beginValue; index < endValue; index++) {
if (index == 0) {
index = scrollValue;
}
tmpSize1 += tmpIncreaseSize;
tmpIncreaseSize = sizeList.get(index).toPixD(resolution);
tmpSize2 = tmpSize1 + Math.max(1, tmpIncreaseSize);
if (isOnSeparatorLineIncludeZero(evt, tmpSize2, tmpIncreaseSize) || isOnNormalSeparatorLine(evt, tmpSize2)) {
return index;
}
}
return -1;
}
public ElementCasePane getElementCasePane() {
return this.gHeader.getElementCasePane();
}
public TemplateElementCase getEditingElementCase() {
return this.getElementCasePane().getEditingElementCase();
}
}

194
designer-realize/src/main/java/com/fr/design/fit/grid/GridLimitColumnMouseHandler.java

@ -1,194 +0,0 @@
package com.fr.design.fit.grid;
import com.fr.base.DynamicUnitList;
import com.fr.design.fit.DesignerUIModeConfig;
import com.fr.design.gui.imenu.UIPopupMenu;
import com.fr.design.mainframe.ElementCasePane;
import com.fr.grid.GridColumn;
import com.fr.grid.GridHeader;
import com.fr.grid.GridUtils;
import com.fr.grid.selection.CellSelection;
import com.fr.grid.selection.Selection;
import com.fr.report.ReportHelper;
import com.fr.report.elementcase.ElementCase;
import com.fr.stable.ColumnRow;
import com.fr.stable.unit.FU;
import com.fr.stable.unit.UNIT;
import javax.swing.SwingUtilities;
import java.awt.Dimension;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.Toolkit;
import java.awt.event.MouseEvent;
/**
* peter:处理对GridColumn的Mouse事件.
*/
public class GridLimitColumnMouseHandler extends GridHeaderWithBoundMouseHandler {
public GridLimitColumnMouseHandler(GridColumn gridColumn, int limit) {
super(gridColumn, limit);
this.resolution = gridColumn.getResolution();
}
@Override
protected void resetSelectionByRightButton(ColumnRow selectedCellPoint, Selection cs, ElementCasePane ePane) {
int[] selectedColumns = cs.getSelectedColumns();
if (selectedColumns.length == 0
|| selectedCellPoint.getColumn() < selectedColumns[0]
|| selectedCellPoint.getColumn() > selectedColumns[selectedColumns.length - 1]) {
resetGridSelectionBySelect(selectedCellPoint.getColumn(), ePane);
}
}
protected int doChooseFrom() {
return CellSelection.CHOOSE_COLUMN;
}
@Override
protected Rectangle resetSelectedBoundsByShift(Rectangle editRectangle, ColumnRow selectedCellPoint, ElementCasePane reportPane) {
int tempOldSelectedCellX = editRectangle.x;// editRectangle.x;
// adjust them to got the correct selected bounds.
if (selectedCellPoint.getColumn() >= editRectangle.x) {
selectedCellPoint = ColumnRow.valueOf(selectedCellPoint.getColumn() + 1, selectedCellPoint.getRow());
} else {
tempOldSelectedCellX++;
}
int lastRow = GridUtils.getAdjustLastColumnRowOfReportPane(reportPane).getRow();
return new Rectangle(Math.min(tempOldSelectedCellX, selectedCellPoint.getColumn()), 0, Math.max(editRectangle.width, Math.abs(tempOldSelectedCellX
- selectedCellPoint.getColumn())), lastRow);
}
@Override
protected int[] getGridSelectionIndices(CellSelection cs) {
return cs.getSelectedColumns();
}
@Override
protected int getScrollValue(ElementCasePane casePane) {
return casePane.getGrid().getHorizontalValue();
}
@Override
protected int getScrollExtent(ElementCasePane casePane) {
return casePane.getGrid().getHorizontalExtent();
}
@Override
protected int getBeginValue(ElementCasePane casePane) {
return casePane.getGrid().getHorizontalBeginValue();
}
@Override
protected int getColumnOrRowByGridHeader(ColumnRow selectedCellPoint) {
return selectedCellPoint.getColumn();
}
/**
* Checks whether is on zero separator line.
*/
@Override
protected boolean isOnSeparatorLineIncludeZero(MouseEvent evt, double tmpWidth2, double tmpIncreaseWidth) {
return tmpIncreaseWidth <= 1 && (evt.getX() >= tmpWidth2 + 2 && (evt.getX() <= tmpWidth2 + SEPARATOR_GAP));
}
@Override
protected boolean between(MouseEvent evt, double from, double to) {
return evt.getX() > from && evt.getX() <= to;
}
/**
* Checks whether is on normal separator line.
*/
@Override
protected boolean isOnNormalSeparatorLine(MouseEvent evt, double tmpWidth2) {
return (evt.getX() >= tmpWidth2 - 2) && (evt.getX() <= tmpWidth2 + 2);
}
@Override
protected int evtOffset(MouseEvent evt, int offset) {
return evt.getX() - offset;
}
@Override
protected DynamicUnitList getSizeList(ElementCase elementCase) {
return ReportHelper.getColumnWidthList(elementCase);
}
@Override
protected String methodName() {
return "setColumnWidth";
}
@Override
protected String getSelectedHeaderTooltip(int selectedColumnCount) {
return selectedColumnCount + "C";
}
@Override
protected Point getTipLocationByMouseEvent(MouseEvent evt, GridHeader gHeader, Dimension tipPreferredSize) {
Point convertPoint = new Point(evt.getX(), 0);
SwingUtilities.convertPointToScreen(convertPoint, gHeader);
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
convertPoint.x = Math.max(0, Math.min(convertPoint.x - tipPreferredSize.width / 2, screenSize.width - tipPreferredSize.width));
convertPoint.y = convertPoint.y - tipPreferredSize.height - 2;
return convertPoint;
}
@Override
protected void resetGridSelectionBySelect(int column, ElementCasePane ePane) {
int lastRow = GridUtils.getAdjustLastColumnRowOfReportPane(ePane).getRow();
CellSelection cellSelection = new CellSelection(column, 0, 1, lastRow);
cellSelection.setSelectedType(CellSelection.CHOOSE_COLUMN);
ePane.setSelection(cellSelection);
}
@Override
protected String nameOfMoveCursorGIF() {
return "cursor_hmove";
}
@Override
protected String nameOfSelectCursorGIF() {
return "cursor_hselect";
}
@Override
protected String nameOfSplitCursorGIF() {
return "cursor_hsplit";
}
@Override
protected UIPopupMenu createPopupMenu(ElementCasePane reportPane,
MouseEvent evt, int columnIndex) {
return ElementCasePaneUtil.createColumnPopupMenu(reportPane, evt, columnIndex);
}
@Override
protected void resetGridSelectionByDrag(CellSelection gridSelection, ElementCasePane reportPane,
int startMultiSelectIndex, int endMultiSelectIndex) {
int lastRow = GridUtils.getAdjustLastColumnRowOfReportPane(reportPane).getRow();
gridSelection.setLastRectangleBounds(Math.min(endMultiSelectIndex, startMultiSelectIndex), 0, Math.abs(startMultiSelectIndex - endMultiSelectIndex) + 1, lastRow);
}
@Override
public void mouseReleased(MouseEvent e) {
super.mouseReleased(e);
int resolution = DesignerUIModeConfig.getInstance().getScreenResolution();
int dragIndex = getDragIndex(e);
if (Math.abs(e.getX() - getLimit()) < FUZZY_EDGE && dragIndex >= 0) {
UNIT oldValue = this.getEditingElementCase().getColumnWidth(dragIndex);
this.getEditingElementCase().setColumnWidth(dragIndex, FU.valueOfPix(oldValue.toPixI(resolution) + getLimit() - e.getX(), resolution));
}
this.getElementCasePane().repaint();
}
}

190
designer-realize/src/main/java/com/fr/design/fit/grid/GridLimitRowMouseHandler.java

@ -1,190 +0,0 @@
package com.fr.design.fit.grid;
import com.fr.base.DynamicUnitList;
import com.fr.design.fit.DesignerUIModeConfig;
import com.fr.design.gui.imenu.UIPopupMenu;
import com.fr.design.mainframe.ElementCasePane;
import com.fr.grid.GridHeader;
import com.fr.grid.GridRow;
import com.fr.grid.GridUtils;
import com.fr.grid.selection.CellSelection;
import com.fr.grid.selection.Selection;
import com.fr.report.ReportHelper;
import com.fr.report.elementcase.ElementCase;
import com.fr.stable.ColumnRow;
import com.fr.stable.unit.FU;
import com.fr.stable.unit.UNIT;
import javax.swing.SwingUtilities;
import java.awt.Dimension;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.event.MouseEvent;
/**
* peter:处理对GridRow的Mouse事件.
*/
public class GridLimitRowMouseHandler extends GridHeaderWithBoundMouseHandler {
public GridLimitRowMouseHandler(GridRow gridRow, int limit) {
super(gridRow, limit);
}
@Override
protected void resetSelectionByRightButton(ColumnRow selectedCellPoint, Selection cs, ElementCasePane ePane) {
int[] selectedRows = cs.getSelectedRows();
if (selectedRows.length == 0
|| selectedCellPoint.getRow() < selectedRows[0]
|| selectedCellPoint.getRow() > selectedRows[selectedRows.length - 1]) {
resetGridSelectionBySelect(selectedCellPoint.getRow(), ePane);
}
}
protected int doChooseFrom() {
return CellSelection.CHOOSE_ROW;
}
@Override
protected int getScrollValue(ElementCasePane casePane) {
return casePane.getGrid().getVerticalValue();
}
@Override
protected int getScrollExtent(ElementCasePane casePane) {
return casePane.getGrid().getVerticalExtent();
}
@Override
protected int getBeginValue(ElementCasePane casePane) {
return casePane.getGrid().getVerticalBeginValue();
}
@Override
protected Rectangle resetSelectedBoundsByShift(Rectangle editRectangle, ColumnRow selectedCellPoint, ElementCasePane reportPane) {
int tempOldSelectedCellY = editRectangle.y;// editRectangle.x;
// ajust them to got the correct selected bounds.
if (selectedCellPoint.getRow() >= editRectangle.y) {
selectedCellPoint = ColumnRow.valueOf(selectedCellPoint.getColumn(), selectedCellPoint.getRow() + 1);
} else {
tempOldSelectedCellY++;
}
int lastColumn = GridUtils.getAdjustLastColumnRowOfReportPane(reportPane).getColumn();
return new Rectangle(0, Math.min(tempOldSelectedCellY, selectedCellPoint.getRow()),
lastColumn, Math.max(editRectangle.height, Math.abs(tempOldSelectedCellY - selectedCellPoint.getRow())));
}
@Override
protected int[] getGridSelectionIndices(CellSelection cs) {
return cs.getSelectedRows();
}
@Override
protected int getColumnOrRowByGridHeader(ColumnRow selectedCellPoint) {
return selectedCellPoint.getRow();
}
@Override
protected void resetGridSelectionBySelect(int row, ElementCasePane ePane) {
int lastColumn = GridUtils.getAdjustLastColumnRowOfReportPane(ePane).getColumn();
CellSelection cellSelection = new CellSelection(0, row, lastColumn, 1);
cellSelection.setSelectedType(CellSelection.CHOOSE_ROW);
ePane.setSelection(cellSelection);
}
/**
* Checks whether is on zero separator line.
*/
@Override
protected boolean isOnSeparatorLineIncludeZero(MouseEvent evt, double tmpHeight2, double tmpIncreaseHeight) {
return tmpIncreaseHeight <= 1 && (evt.getY() >= tmpHeight2 + 2 && evt.getY() <= tmpHeight2 + SEPARATOR_GAP);
}
@Override
protected boolean between(MouseEvent evt, double from, double to) {
return evt.getY() > from && evt.getY() <= to;
}
@Override
protected DynamicUnitList getSizeList(ElementCase elementCase) {
return ReportHelper.getRowHeightList(elementCase);
}
@Override
protected String methodName() {
return "setRowHeight";
}
/**
* Checks whether is on normal separator line.
*/
@Override
protected boolean isOnNormalSeparatorLine(MouseEvent evt, double tmpHeight2) {
return (evt.getY() >= tmpHeight2 - 2) && (evt.getY() <= tmpHeight2 + 2);
}
@Override
protected int evtOffset(MouseEvent evt, int offset) {
return evt.getY() - offset;
}
@Override
protected String getSelectedHeaderTooltip(int rowSelectedCount) {
return rowSelectedCount + "R";
}
@Override
protected Point getTipLocationByMouseEvent(MouseEvent evt, GridHeader gHeader, Dimension tipPreferredSize) {
Point convertPoint = new Point(0, evt.getY());
SwingUtilities.convertPointToScreen(convertPoint, gHeader);
convertPoint.x = convertPoint.x + gHeader.getSize().width + 2;
convertPoint.y = convertPoint.y - tipPreferredSize.height / 2;
return convertPoint;
}
@Override
protected String nameOfMoveCursorGIF() {
return "cursor_vmove";
}
@Override
protected String nameOfSelectCursorGIF() {
return "cursor_vselect";
}
@Override
protected String nameOfSplitCursorGIF() {
return "cursor_vsplit";
}
@Override
protected UIPopupMenu createPopupMenu(ElementCasePane reportPane,
MouseEvent evt, int rowIndex) {
return ElementCasePaneUtil.createRowPopupMenu(reportPane, evt, rowIndex);
}
@Override
protected void resetGridSelectionByDrag(CellSelection gridSelection, ElementCasePane reportPane,
int startMultiSelectIndex, int endMultiSelectIndex) {
int lastColumn = GridUtils.getAdjustLastColumnRowOfReportPane(reportPane).getColumn();
gridSelection.setLastRectangleBounds(0, Math.min(endMultiSelectIndex, startMultiSelectIndex), lastColumn, Math.abs(startMultiSelectIndex - endMultiSelectIndex) + 1);
}
@Override
public void mouseReleased(MouseEvent e) {
super.mouseReleased(e);
int resolution = DesignerUIModeConfig.getInstance().getScreenResolution();
int dragIndex = getDragIndex(e);
if (Math.abs(e.getY() - getLimit()) < FUZZY_EDGE && dragIndex >= 0) {
UNIT oldValue = this.getEditingElementCase().getRowHeight(dragIndex);
this.getEditingElementCase().setRowHeight(dragIndex, FU.valueOfPix(oldValue.toPixI(resolution) + getLimit() - e.getY(), resolution));
}
this.getElementCasePane().repaint();
}
}

201
designer-realize/src/main/java/com/fr/design/fit/grid/NewFormDesignerGridUI.java

@ -1,201 +0,0 @@
package com.fr.design.fit.grid;
import com.fr.design.designer.creator.XElementCase;
import com.fr.design.fit.AdaptiveCellElementPainter;
import com.fr.design.fit.DesignerUIModeConfig;
import com.fr.design.fit.common.FormDesignerUtil;
import com.fr.design.mainframe.ElementCasePane;
import com.fr.design.mainframe.FormDesigner;
import com.fr.grid.CellElementPainter;
import com.fr.grid.Grid;
import com.fr.grid.GridColumn;
import com.fr.grid.GridRow;
import com.fr.grid.GridUI;
import com.fr.report.elementcase.TemplateElementCase;
import com.fr.report.worksheet.FormElementCase;
import com.fr.stable.Constants;
import com.fr.stable.GraphDrawHelper;
import javax.swing.JComponent;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Insets;
import java.awt.Rectangle;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import java.awt.event.MouseWheelListener;
/**
* Created by kerry on 2020-04-14
*/
public class NewFormDesignerGridUI extends GridUI {
private GridLimitColumnMouseHandler gridColumnMouseHandler;
private GridLimitRowMouseHandler gridRowMouseHandler;
private AdaptiveGridListener adaptiveGridListener;
private FormDesigner designer;
public NewFormDesignerGridUI(FormDesigner designer, int resolution) {
super(resolution);
this.designer = designer;
this.setCellElementPainter(new AdaptiveCellElementPainter());
}
public void setCellElementPainter(CellElementPainter elementPainter) {
this.painter = elementPainter;
}
public void paint(Graphics g, JComponent c) {
Graphics2D g2d = (Graphics2D) g;
Grid grid = (Grid) c;
// 取得ElementCasePane.ElementCase
ElementCasePane elementCasePane = grid.getElementCasePane();
final TemplateElementCase elementCase = elementCasePane.getEditingElementCase();
super.paint(g, c);
if (!(elementCase instanceof FormElementCase)) {
return;
}
final Rectangle rectangle = getBoundsLineRect(elementCase, grid);
int width = getScaleWidth(rectangle.width) - columnWidthList.getRangeValue(0, horizontalValue).toPixI(resolution);
int height = getScaleHeight(rectangle.height) - rowHeightList.getRangeValue(0, verticalValue).toPixI(resolution);
drawBoundsLine(g2d, width, height);
addListener(grid, elementCasePane, width, height, rectangle.width, rectangle.height);
}
private int getScaleWidth(int width) {
return width * resolution / DesignerUIModeConfig.getInstance().getScreenResolution();
}
private int getScaleHeight(int height) {
return height * resolution / DesignerUIModeConfig.getInstance().getScreenResolution();
}
/**
* 获取需要画线的矩形大小
*/
private Rectangle getBoundsLineRect(TemplateElementCase elementCase, Grid grid) {
final Rectangle rectangle = new Rectangle();
XElementCase xElementCase = FormDesignerUtil.getXelementCase(designer.getRootComponent(), (FormElementCase) elementCase);
if (xElementCase != null) {
rectangle.setBounds(xElementCase.getBounds());
//减去内边距的宽和高
Insets insets = xElementCase.getInsets();
rectangle.width -= insets.left + insets.right;
rectangle.height -= insets.top + insets.bottom;
}
return rectangle;
}
private void addListener(Grid grid, ElementCasePane elementCasePane, int width, int height, int actualWidth, int actualHeight) {
addGridColumnListener(elementCasePane.getGridColumn(), width);
addGridRowListener(elementCasePane.getGridRow(), height);
addMouseListener(grid, width, height, actualWidth, actualHeight);
}
private void drawBoundsLine(Graphics2D g2d, int width, int height) {
g2d.setPaint(Color.black);
g2d.setStroke(GraphDrawHelper.getStroke(Constants.LINE_DASH_DOT));
g2d.drawLine(0, height, width, height);
g2d.drawLine(width, 0, width, height);
}
private void removeGridColumnListener(GridColumn column) {
MouseMotionListener[] mouseMotionListeners = column.getMouseMotionListeners();
for (MouseMotionListener mouseMotionListener : mouseMotionListeners) {
if (mouseMotionListener instanceof com.fr.grid.GridColumnMouseHandler || mouseMotionListener instanceof GridLimitColumnMouseHandler) {
column.removeMouseMotionListener(mouseMotionListener);
}
}
MouseListener[] mouseListeners = column.getMouseListeners();
for (MouseListener motionListener : mouseListeners) {
if (motionListener instanceof com.fr.grid.GridColumnMouseHandler || motionListener instanceof GridLimitColumnMouseHandler) {
column.removeMouseListener(motionListener);
}
}
}
private void removeGridRowListener(GridRow row) {
MouseMotionListener[] mouseMotionListeners = row.getMouseMotionListeners();
for (MouseMotionListener mouseMotionListener : mouseMotionListeners) {
if (mouseMotionListener instanceof com.fr.grid.GridRowMouseHandler || mouseMotionListener instanceof GridLimitRowMouseHandler) {
row.removeMouseMotionListener(mouseMotionListener);
}
}
MouseListener[] mouseListeners = row.getMouseListeners();
for (MouseListener motionListener : mouseListeners) {
if (motionListener instanceof com.fr.grid.GridRowMouseHandler || motionListener instanceof GridLimitRowMouseHandler) {
row.removeMouseListener(motionListener);
}
}
}
private void removeGridListener(Grid grid) {
MouseMotionListener[] mouseMotionListeners = grid.getMouseMotionListeners();
for (MouseMotionListener mouseMotionListener : mouseMotionListeners) {
if (mouseMotionListener instanceof AdaptiveGridListener) {
grid.removeMouseMotionListener(mouseMotionListener);
break;
}
}
MouseListener[] mouseListeners = grid.getMouseListeners();
for (MouseListener motionListener : mouseListeners) {
if (motionListener instanceof AdaptiveGridListener) {
grid.removeMouseListener(motionListener);
break;
}
}
MouseWheelListener[] mouseWheelListeners = grid.getMouseWheelListeners();
for (MouseWheelListener mouseWheelListener : mouseWheelListeners) {
if (mouseWheelListener instanceof AdaptiveGridListener) {
grid.removeMouseWheelListener(mouseWheelListener);
break;
}
}
}
private void addGridColumnListener(GridColumn column, int width) {
if (gridColumnMouseHandler != null) {
gridColumnMouseHandler.setLimit(width);
return;
}
removeGridColumnListener(column);
gridColumnMouseHandler = new GridLimitColumnMouseHandler(column, width);
column.addMouseListener(gridColumnMouseHandler);
column.addMouseMotionListener(gridColumnMouseHandler);
}
private void addGridRowListener(GridRow row, int height) {
if (gridRowMouseHandler != null) {
gridRowMouseHandler.setLimit(height);
return;
}
removeGridRowListener(row);
gridRowMouseHandler = new GridLimitRowMouseHandler(row, height);
row.addMouseMotionListener(gridRowMouseHandler);
row.addMouseListener(gridRowMouseHandler);
}
private void addMouseListener(Grid grid, int width, int height, int actualWidth, int actualHeight) {
if (adaptiveGridListener != null) {
adaptiveGridListener.resetBoundInfo(width, height, actualWidth, actualHeight);
return;
}
removeGridListener(grid);
adaptiveGridListener = new AdaptiveGridListener(grid, width, height, actualWidth, actualHeight);
grid.addMouseMotionListener(adaptiveGridListener);
grid.addMouseListener(adaptiveGridListener);
grid.addMouseWheelListener(adaptiveGridListener);
}
}

41
designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePane.java

@ -6,7 +6,7 @@ package com.fr.design.mainframe;
import com.fr.base.BaseFormula; import com.fr.base.BaseFormula;
import com.fr.base.DynamicUnitList; import com.fr.base.DynamicUnitList;
import com.fr.base.Formula; import com.fr.base.Formula;
import com.fr.base.ScreenResolution; import com.fr.base.NameStyle;
import com.fr.base.Style; import com.fr.base.Style;
import com.fr.base.vcs.DesignerMode; import com.fr.base.vcs.DesignerMode;
import com.fr.design.DesignState; import com.fr.design.DesignState;
@ -67,7 +67,6 @@ import com.fr.design.constants.UIConstants;
import com.fr.design.designer.EditingState; import com.fr.design.designer.EditingState;
import com.fr.design.designer.TargetComponent; import com.fr.design.designer.TargetComponent;
import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.fit.DesignerUIModeConfig;
import com.fr.design.fun.ElementUIProvider; import com.fr.design.fun.ElementUIProvider;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.imenu.UIPopupMenu; import com.fr.design.gui.imenu.UIPopupMenu;
@ -97,6 +96,7 @@ import com.fr.page.PageAttributeGetter;
import com.fr.page.ReportPageAttrProvider; import com.fr.page.ReportPageAttrProvider;
import com.fr.poly.creator.PolyElementCasePane; import com.fr.poly.creator.PolyElementCasePane;
import com.fr.report.ReportHelper; import com.fr.report.ReportHelper;
import com.fr.report.cell.CellElement;
import com.fr.report.cell.FloatElement; import com.fr.report.cell.FloatElement;
import com.fr.report.cell.TemplateCellElement; import com.fr.report.cell.TemplateCellElement;
import com.fr.report.cell.cellattr.core.RichText; import com.fr.report.cell.cellattr.core.RichText;
@ -133,6 +133,7 @@ import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
import java.util.Iterator;
import java.util.Set; import java.util.Set;
import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER; import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER;
@ -157,10 +158,10 @@ public abstract class ElementCasePane<T extends TemplateElementCase> extends Tar
// alex: // alex:
private boolean supportDefaultParentCalculate = false; private boolean supportDefaultParentCalculate = false;
// GUI. // GUI.
private Grid grid; protected Grid grid;
private GridRow gridRow; protected GridRow gridRow;
private GridColumn gridColumn; protected GridColumn gridColumn;
private GridCorner gridCorner; protected GridCorner gridCorner;
private JScrollBar verScrollBar; private JScrollBar verScrollBar;
private JScrollBar horScrollBar; private JScrollBar horScrollBar;
// Visible // Visible
@ -365,7 +366,6 @@ public abstract class ElementCasePane<T extends TemplateElementCase> extends Tar
} }
} }
public void setResolution(int resolution) { public void setResolution(int resolution) {
this.resolution = resolution; this.resolution = resolution;
} }
@ -1374,6 +1374,33 @@ public abstract class ElementCasePane<T extends TemplateElementCase> extends Tar
return cellNeedTOFormat; return cellNeedTOFormat;
} }
public void traverseSelectedCellElements(TemplateCellElementVisitor visitor) {
Selection selection = getSelection();
if (!(selection instanceof CellSelection)) {
return;
}
CellSelection cs = (CellSelection) selection;
TemplateElementCase elementCase = getEditingElementCase();
int cellRectangleCount = cs.getCellRectangleCount();
for (int rect = 0; rect < cellRectangleCount; rect++) {
Rectangle cellRectangle = cs.getCellRectangle(rect);
for (int j = 0; j < cellRectangle.height; j++) {
for (int i = 0; i < cellRectangle.width; i++) {
int column = i + cellRectangle.x;
int row = j + cellRectangle.y;
TemplateCellElement cellElement = elementCase.getTemplateCellElement(column, row);
visitor.visit(column, row, cellElement);
}
}
}
}
public interface TemplateCellElementVisitor {
void visit(int column, int row, TemplateCellElement cellElement);
}
private class ElementCaseEditingState implements EditingState { private class ElementCaseEditingState implements EditingState {
protected Selection selection; protected Selection selection;

2
designer-realize/src/main/java/com/fr/design/mainframe/app/DesignerAppUtils.java

@ -220,7 +220,7 @@ public class DesignerAppUtils {
Multimap<String, PluginMarkerAdapter> stringPluginMarkerAdapterMultimap = popPluginInfoMap(key); Multimap<String, PluginMarkerAdapter> stringPluginMarkerAdapterMultimap = popPluginInfoMap(key);
Collection<PluginMarkerAdapter> disablePlugins = stringPluginMarkerAdapterMultimap.get(TemplateIOErrorContextHolder.DISABLE_PLUGIN); Collection<PluginMarkerAdapter> disablePlugins = stringPluginMarkerAdapterMultimap.get(TemplateIOErrorContextHolder.DISABLE_PLUGIN);
for (PluginMarkerAdapter disablePlugin : disablePlugins) { for (PluginMarkerAdapter disablePlugin : disablePlugins) {
PluginManager.getController().enable(disablePlugin, new ModifyStatusCallback(false)); PluginManager.getController().enablePersistently(disablePlugin, new ModifyStatusCallback(false));
} }
Collection<PluginMarkerAdapter> uninstallPlugins = stringPluginMarkerAdapterMultimap.get(TemplateIOErrorContextHolder.NOT_INSTALLED_PLUGIN); Collection<PluginMarkerAdapter> uninstallPlugins = stringPluginMarkerAdapterMultimap.get(TemplateIOErrorContextHolder.NOT_INSTALLED_PLUGIN);

109
designer-realize/src/main/java/com/fr/design/mainframe/cell/AbstractDSCellEditorPane.java

@ -1,17 +1,7 @@
package com.fr.design.mainframe.cell; package com.fr.design.mainframe.cell;
import com.fr.design.gui.iscrollbar.UIScrollBar; import com.fr.design.gui.frpane.AttributeChangeListener;
import com.fr.design.mainframe.CellElementPropertyPane; import com.fr.design.mainframe.AbstractAttrPane;
import com.fr.quickeditor.cellquick.layout.CellElementBarLayout;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.event.AdjustmentEvent;
import java.awt.event.AdjustmentListener;
import java.awt.event.MouseWheelEvent;
import java.awt.event.MouseWheelListener;
/** /**
* 右侧单元格元素面板抽象类 * 右侧单元格元素面板抽象类
@ -20,26 +10,8 @@ import java.awt.event.MouseWheelListener;
* @version 2017年7月25日 * @version 2017年7月25日
* @since 9.0 * @since 9.0
*/ */
public abstract class AbstractDSCellEditorPane extends JPanel { public abstract class AbstractDSCellEditorPane extends AbstractAttrPane {
/**
* 滚动条相关配置
*/
private static final int MAXVALUE = 100;
private static final int TITLE_HEIGHT = 95;
private static final int CONTENT_PANE_WIDTH_GAP = 3;
private static final int SCROLLBAR_WIDTH = 7;
private static final int MOUSE_WHEEL_SPEED = 5;
private int maxHeight = 280;
private JPanel leftContentPane;
private UIScrollBar scrollBar;
protected abstract JPanel createContentPane();
public abstract String getIconPath();
public abstract String title4PopupWindow();
/** /**
* 从面板拿数据保存 * 从面板拿数据保存
@ -51,78 +23,15 @@ public abstract class AbstractDSCellEditorPane extends JPanel {
*/ */
public abstract void populate(); public abstract void populate();
protected void createScrollPane() {
leftContentPane = this.createContentPane();
this.prepareScrollBar();
leftContentPane.setBorder(BorderFactory.createMatteBorder(10, 10, 0, 0, this.getBackground()));
this.setLayout(new CellElementBarLayout(leftContentPane) {
@Override
public void layoutContainer(Container parent) {
maxHeight = CellElementPropertyPane.getInstance().getHeight() - TITLE_HEIGHT;
int beginY;
if ((MAXVALUE - scrollBar.getVisibleAmount()) == 0) {
beginY = 0;
} else {
int preferredHeight = leftContentPane.getPreferredSize().height;
int value = scrollBar.getValue();
beginY = value * (preferredHeight - maxHeight) / (MAXVALUE - scrollBar.getVisibleAmount());
}
int width = parent.getWidth();
int height = parent.getHeight();
if (leftContentPane.getPreferredSize().height > maxHeight) {
leftContentPane.setBounds(0, -beginY, width - SCROLLBAR_WIDTH - CONTENT_PANE_WIDTH_GAP, height + beginY);
scrollBar.setBounds(width - SCROLLBAR_WIDTH - CONTENT_PANE_WIDTH_GAP, 0, SCROLLBAR_WIDTH + CONTENT_PANE_WIDTH_GAP, height);
} else {
leftContentPane.setBounds(0, 0, width - SCROLLBAR_WIDTH - CONTENT_PANE_WIDTH_GAP, height);
}
}
});
this.add(scrollBar);
this.add(leftContentPane);
}
private void prepareScrollBar() {
scrollBar = new UIScrollBar(UIScrollBar.VERTICAL) {
@Override
public int getVisibleAmount() {
int preferredHeight = leftContentPane.getPreferredSize().height;
int e = MAXVALUE * (maxHeight) / preferredHeight;
setVisibleAmount(e);
return e;
}
@Override
public int getMaximum() {
return MAXVALUE;
}
};
scrollBar.addAdjustmentListener(new AdjustmentListener() {
@Override
public void adjustmentValueChanged(AdjustmentEvent e) {
doLayout();
}
});
this.addMouseWheelListener(new MouseWheelListener() {
@Override
public void mouseWheelMoved(MouseWheelEvent e) {
int value = scrollBar.getValue();
value += MOUSE_WHEEL_SPEED * e.getWheelRotation();
scrollBar.setValue(value);
doLayout();
}
});
scrollBar.setPreferredSize(new Dimension(SCROLLBAR_WIDTH + CONTENT_PANE_WIDTH_GAP, this.getHeight()));
scrollBar.setBlockIncrement(SCROLLBAR_WIDTH + CONTENT_PANE_WIDTH_GAP);
scrollBar.setBorder(BorderFactory.createMatteBorder(0, CONTENT_PANE_WIDTH_GAP, 0, 0, this.getBackground()));
}
/** /**
* 释放tc * 释放tc
*/ */
protected abstract void release(); protected abstract void release();
protected abstract AttributeChangeListener getAttributeChangeListener();
public void addAttributeChangeListener(){
this.addAttributeChangeListener(getAttributeChangeListener());
}
} }

20
designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellExpandAttrPane.java

@ -4,7 +4,6 @@ import com.fr.design.constants.LayoutConstants;
import com.fr.design.constants.UIConstants; import com.fr.design.constants.UIConstants;
import com.fr.design.expand.ExpandLeftFatherPane; import com.fr.design.expand.ExpandLeftFatherPane;
import com.fr.design.expand.ExpandUpFatherPane; import com.fr.design.expand.ExpandUpFatherPane;
import com.fr.design.expand.SortExpandAttrPane;
import com.fr.design.foldablepane.UIExpandablePane; import com.fr.design.foldablepane.UIExpandablePane;
import com.fr.design.gui.ibutton.UIButtonGroup; import com.fr.design.gui.ibutton.UIButtonGroup;
import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.icheckbox.UICheckBox;
@ -13,6 +12,7 @@ import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper; import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.theme.utils.DefaultThemedTemplateCellElementCase; import com.fr.design.mainframe.theme.utils.DefaultThemedTemplateCellElementCase;
import com.fr.design.sort.cellexpand.CellExpandSortPane;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.IOUtils; import com.fr.general.IOUtils;
import com.fr.report.cell.TemplateCellElement; import com.fr.report.cell.TemplateCellElement;
@ -38,11 +38,11 @@ public class CellExpandAttrPane extends AbstractCellAttrPane {
private ExpandUpFatherPane rightFatherPane; private ExpandUpFatherPane rightFatherPane;
private UICheckBox horizontalExpandableCheckBox; private UICheckBox horizontalExpandableCheckBox;
private UICheckBox verticalExpandableCheckBox; private UICheckBox verticalExpandableCheckBox;
private SortExpandAttrPane sortAfterExpand;
private JPanel layoutPane; private JPanel layoutPane;
private JPanel basicPane; private JPanel basicPane;
private JPanel seniorPane; private JPanel seniorPane;
private CellExpandExtraAttrPane extraPane; private CellExpandExtraAttrPane extraPane;
private CellExpandSortPane cellExpandSortPane;
/** /**
@ -62,7 +62,6 @@ public class CellExpandAttrPane extends AbstractCellAttrPane {
rightFatherPane = new ExpandUpFatherPane(); rightFatherPane = new ExpandUpFatherPane();
horizontalExpandableCheckBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Report_ExpandD_Horizontal_Extendable")); horizontalExpandableCheckBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Report_ExpandD_Horizontal_Extendable"));
verticalExpandableCheckBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Report_ExpandD_Vertical_Extendable")); verticalExpandableCheckBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Report_ExpandD_Vertical_Extendable"));
sortAfterExpand = new SortExpandAttrPane();
initAllNames(); initAllNames();
return layoutPane(); return layoutPane();
} }
@ -81,8 +80,11 @@ public class CellExpandAttrPane extends AbstractCellAttrPane {
seniorPane = new JPanel(); seniorPane = new JPanel();
basicPane = new UIExpandablePane(Toolkit.i18nText("Fine-Design_Report_Basic"), 223, 24, basicPane()); basicPane = new UIExpandablePane(Toolkit.i18nText("Fine-Design_Report_Basic"), 223, 24, basicPane());
seniorPane = new UIExpandablePane(Toolkit.i18nText("Fine-Design_Report_Advanced"), 223, 24, seniorPane()); seniorPane = new UIExpandablePane(Toolkit.i18nText("Fine-Design_Report_Advanced"), 223, 24, seniorPane());
JPanel sortUIExpandablePane = new UIExpandablePane(Toolkit.i18nText("Fine-Design_Report_Expend_Sort"),
223, 24, cellExpandSortPane = new CellExpandSortPane(this));
layoutPane.add(basicPane, BorderLayout.NORTH); layoutPane.add(basicPane, BorderLayout.NORTH);
layoutPane.add(seniorPane, BorderLayout.CENTER); layoutPane.add(seniorPane, BorderLayout.CENTER);
layoutPane.add(sortUIExpandablePane, BorderLayout.SOUTH);
extraPane = CellExpandExtraAttrPane.getInstance(); extraPane = CellExpandExtraAttrPane.getInstance();
@ -119,16 +121,12 @@ public class CellExpandAttrPane extends AbstractCellAttrPane {
private JPanel seniorPane() { private JPanel seniorPane() {
double f = TableLayout.FILL; double f = TableLayout.FILL;
double p = TableLayout.PREFERRED; double p = TableLayout.PREFERRED;
UILabel expendSort = new UILabel(Toolkit.i18nText("Fine-Design_Report_Expend_Sort"), SwingConstants.LEFT);
JPanel expendSortPane = new JPanel(new BorderLayout());
expendSortPane.add(expendSort, BorderLayout.NORTH);
horizontalExpandableCheckBox.setBorder(UIConstants.CELL_ATTR_ZEROBORDER); horizontalExpandableCheckBox.setBorder(UIConstants.CELL_ATTR_ZEROBORDER);
verticalExpandableCheckBox.setBorder(UIConstants.CELL_ATTR_ZEROBORDER); verticalExpandableCheckBox.setBorder(UIConstants.CELL_ATTR_ZEROBORDER);
Component[][] components = new Component[][]{ Component[][] components = new Component[][]{
new Component[]{null, null}, new Component[]{null, null},
new Component[]{horizontalExpandableCheckBox, null}, new Component[]{horizontalExpandableCheckBox, null},
new Component[]{verticalExpandableCheckBox, null}, new Component[]{verticalExpandableCheckBox, null},
new Component[]{expendSortPane, sortAfterExpand},
}; };
double[] rowSize = {p, p, p, p, p}; double[] rowSize = {p, p, p, p, p};
double[] columnSize = {p, f}; double[] columnSize = {p, f};
@ -169,9 +167,8 @@ public class CellExpandAttrPane extends AbstractCellAttrPane {
} }
} }
sortAfterExpand.populate(cellExpandAttr);
extraPane.populate(cellElement); extraPane.populate(cellElement);
cellExpandSortPane.populateBean(cellElement);
} }
@ -217,11 +214,8 @@ public class CellExpandAttrPane extends AbstractCellAttrPane {
} }
} }
if (ComparatorUtils.equals(getGlobalName(), Toolkit.i18nText("Fine-Design_Basic_ExpandD_Sort_After_Expand"))) {
sortAfterExpand.update(cellExpandAttr);
}
extraPane.update(cellElement); extraPane.update(cellElement);
cellExpandSortPane.updateBean(cellElement);
} }
/** /**

74
designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellStylePane.java

@ -1,22 +1,23 @@
package com.fr.design.mainframe.cell.settingpane; package com.fr.design.mainframe.cell.settingpane;
import com.fr.base.CellBorderStyle; import com.fr.base.CellBorderStyle;
import com.fr.base.NameStyle;
import com.fr.base.Style; import com.fr.base.Style;
import com.fr.design.actions.utils.ReportActionUtils; import com.fr.design.actions.utils.ReportActionUtils;
import com.fr.design.constants.UIConstants; import com.fr.design.constants.UIConstants;
import com.fr.design.gui.style.BorderPane; import com.fr.design.mainframe.ElementCasePane;
import com.fr.design.mainframe.cell.settingpane.style.StylePane; import com.fr.design.mainframe.cell.settingpane.style.StylePane;
import com.fr.design.mainframe.theme.utils.DefaultThemedTemplateCellElementCase; import com.fr.design.mainframe.theme.utils.DefaultThemedTemplateCellElementCase;
import com.fr.design.style.BorderUtils; import com.fr.design.style.BorderUtils;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.report.cell.TemplateCellElement; import com.fr.report.cell.TemplateCellElement;
import com.fr.report.elementcase.TemplateElementCase; import com.fr.report.elementcase.TemplateElementCase;
import javax.swing.*; import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener; import javax.swing.event.ChangeListener;
import java.awt.*; import java.awt.BorderLayout;
/** /**
* @author zhou * @author zhou
@ -71,29 +72,56 @@ public class CellStylePane extends AbstractCellAttrPane {
@Override @Override
public void updateBeans() { public void updateBeans() {
Object[] selectionCellBorderObjects = BorderUtils.createCellBorderObject(elementCasePane); // 因为存在框选多个单元格的情况,跟随主题切换到自定义的行为似乎不太适合由updateBeans完成,它更像是个工具栏上的Action.
// 但它又会触发updateBeans...
boolean isSwitchToCustomStyleAction = stylePane.isFollowingThemeSettingChanged() && !stylePane.isFollowingTheme();
if (isSwitchToCustomStyleAction) {
switchCellStylesToCustom();
return;
}
updateCellStylesByPaneSettings();
}
private void switchCellStylesToCustom() {
TemplateElementCase elementCase = elementCasePane.getEditingElementCase(); TemplateElementCase elementCase = elementCasePane.getEditingElementCase();
int cellRectangleCount = cs.getCellRectangleCount(); elementCasePane.traverseSelectedCellElements(new ElementCasePane.TemplateCellElementVisitor() {
for (int rect = 0; rect < cellRectangleCount; rect++) { @Override
Rectangle cellRectangle = cs.getCellRectangle(rect); public void visit(int column, int row, TemplateCellElement cellElement) {
for (int j = 0; j < cellRectangle.height; j++) { if (cellElement == null) {
for (int i = 0; i < cellRectangle.width; i++) { cellElement = DefaultThemedTemplateCellElementCase.createInstance(column, row);
int column = i + cellRectangle.x; elementCase.addCellElement(cellElement);
int row = j + cellRectangle.y;
TemplateCellElement cellElement = elementCase.getTemplateCellElement(column, row);
if (cellElement == null) {
cellElement = DefaultThemedTemplateCellElementCase.createInstance(column, row);
elementCase.addCellElement(cellElement);
}
Style style = stylePane.updateBean();
cellElement.setStyle(style);
} }
Style style = cellElement.getStyle();
if (style instanceof NameStyle) {
style = ((NameStyle) style).getRealStyle();
}
if (style == null) {
style = Style.DEFAULT_STYLE;
}
cellElement.setStyle(style);
} }
} });
}
private void updateCellStylesByPaneSettings() {
Object[] oldSelectionCellBorderObjects = BorderUtils.createCellBorderObject(elementCasePane);
TemplateElementCase elementCase = elementCasePane.getEditingElementCase();
elementCasePane.traverseSelectedCellElements(new ElementCasePane.TemplateCellElementVisitor() {
@Override
public void visit(int column, int row, TemplateCellElement cellElement) {
if (cellElement == null) {
cellElement = DefaultThemedTemplateCellElementCase.createInstance(column, row);
elementCase.addCellElement(cellElement);
}
Style style = stylePane.updateBean();
cellElement.setStyle(style);
}
});
// border必须特别处理 // border必须特别处理
CellBorderStyle cellBorderStyle = stylePane.updateBorderStyle(); CellBorderStyle newCellBorderStyle = stylePane.updateBorderStyle();
if (cellBorderStyle != null) { if (newCellBorderStyle != null) {
BorderUtils.update(elementCasePane, selectionCellBorderObjects, cellBorderStyle); BorderUtils.update(elementCasePane, oldSelectionCellBorderObjects, newCellBorderStyle);
} }
} }

7
designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/NameStyleListPane.java

@ -16,11 +16,8 @@ import com.fr.design.mainframe.theme.ThemedCellStyleListPane;
*/ */
public class NameStyleListPane extends ThemedCellStyleListPane { public class NameStyleListPane extends ThemedCellStyleListPane {
public NameStyleListPane() { public NameStyleListPane(boolean supportInnerBorder) {
} super(supportInnerBorder);
public NameStyleListPane(boolean supportCellRange) {
super(supportCellRange);
} }
public void populateNameStyle(NameStyle style) { public void populateNameStyle(NameStyle style) {

59
designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/StylePane.java

@ -51,6 +51,7 @@ public class StylePane extends BasicPane implements UIObserver {
private final List<UIObserverListener> observerListeners = new ArrayList<>(); private final List<UIObserverListener> observerListeners = new ArrayList<>();
private Style backupStyleFromPopulating = Style.DEFAULT_STYLE; private Style backupStyleFromPopulating = Style.DEFAULT_STYLE;
private boolean isFollowingThemeSettingChanged = false;
public StylePane() { public StylePane() {
followingThemeButtonGroup = new UIButtonGroup<>(FOLLOWING_THEME_STRING_ARRAYS); followingThemeButtonGroup = new UIButtonGroup<>(FOLLOWING_THEME_STRING_ARRAYS);
@ -77,6 +78,7 @@ public class StylePane extends BasicPane implements UIObserver {
followingThemeButtonGroup.addActionListener(new ActionListener() { followingThemeButtonGroup.addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
isFollowingThemeSettingChanged = true;
AttributeChangeUtils.changeComposedUI(StylePane.this, false, new AttributeChangeUtils.UIChangeAction() { AttributeChangeUtils.changeComposedUI(StylePane.this, false, new AttributeChangeUtils.UIChangeAction() {
@Override @Override
public void changeComposedUI() { public void changeComposedUI() {
@ -85,6 +87,7 @@ public class StylePane extends BasicPane implements UIObserver {
} }
}); });
fireStateChanged(); fireStateChanged();
isFollowingThemeSettingChanged = false;
} }
}); });
@ -103,25 +106,33 @@ public class StylePane extends BasicPane implements UIObserver {
cardLayout.show(contentPane, FOLLOWING_THEME_STRING_ARRAYS[selectedIndex]); cardLayout.show(contentPane, FOLLOWING_THEME_STRING_ARRAYS[selectedIndex]);
if (!isFollowingTheme) { if (!isFollowingTheme) {
// 对于同一个单元格,跟随主题切换到自定义,自定义中的配置与其保持一致 // 对于同一个单元格,跟随主题切换到自定义,自定义中的配置与其保持一致
NameStyle lastSelectedNameStyle = nameStyleListPane.updateNameStyle(); syncCustomStylePaneBySelectedNameStyle();
if (lastSelectedNameStyle != null) {
Style lastSelectedRealStyle = lastSelectedNameStyle.getRealStyle();
try {
lastSelectedRealStyle = (Style) lastSelectedRealStyle.clone();
if (lastSelectedRealStyle != null) {
customStylePane.populateBean(lastSelectedRealStyle);
customStylePane.dealWithBorder();
}
} catch (CloneNotSupportedException ex) {
FineLoggerFactory.getLogger().error(ex.getMessage(), ex);
}
}
} else { } else {
// 对于同一个单元格,自定义切换到跟随主题,跟随主题选中"默认"样式,并使用默认样式设置选中的单元格 // 对于同一个单元格,自定义切换到跟随主题,跟随主题选中"默认"样式,并使用默认样式设置选中的单元格
nameStyleListPane.reset(); nameStyleListPane.reset();
} }
} }
private void syncCustomStylePaneBySelectedNameStyle() {
NameStyle lastSelectedNameStyle = nameStyleListPane.updateNameStyle();
if (lastSelectedNameStyle != null) {
Style lastSelectedRealStyle = lastSelectedNameStyle.getRealStyle();
try {
lastSelectedRealStyle = (Style) lastSelectedRealStyle.clone();
if (lastSelectedRealStyle != null) {
customStylePane.populateBean(lastSelectedRealStyle);
customStylePane.dealWithBorder();
}
} catch (CloneNotSupportedException ex) {
FineLoggerFactory.getLogger().error(ex.getMessage(), ex);
}
}
}
public boolean isFollowingThemeSettingChanged() {
return isFollowingThemeSettingChanged;
}
protected JPanel createTabbedContentPane() { protected JPanel createTabbedContentPane() {
JPanel contentPane = new JPanel(cardLayout) { JPanel contentPane = new JPanel(cardLayout) {
@Override @Override
@ -161,14 +172,22 @@ public class StylePane extends BasicPane implements UIObserver {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Style"); return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Style");
} }
public void setSelectedIndex(int index) { public boolean isFollowingTheme() {
return getSelectedIndex() == 0;
}
public void setFollowingTheme(boolean followingTheme) {
setSelectedIndex(followingTheme ? 0 : 1);
}
private void setSelectedIndex(int index) {
if (0 <= index && index < FOLLOWING_THEME_STRING_ARRAYS.length) { if (0 <= index && index < FOLLOWING_THEME_STRING_ARRAYS.length) {
followingThemeButtonGroup.setSelectedIndex(index); followingThemeButtonGroup.setSelectedIndex(index);
cardLayout.show(contentPane, FOLLOWING_THEME_STRING_ARRAYS[index]); cardLayout.show(contentPane, FOLLOWING_THEME_STRING_ARRAYS[index]);
} }
} }
public int getSelectedIndex() { private int getSelectedIndex() {
return followingThemeButtonGroup.getSelectedIndex(); return followingThemeButtonGroup.getSelectedIndex();
} }
@ -185,11 +204,11 @@ public class StylePane extends BasicPane implements UIObserver {
} }
public void setSelctedByName(String id) { public void setSelctedByName(String id) {
setSelectedIndex(ComparatorUtils.equals(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Custom"), id)? 1 : 0); setFollowingTheme(!ComparatorUtils.equals(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Custom"), id));
} }
public CellBorderStyle updateBorderStyle() { public CellBorderStyle updateBorderStyle() {
if (getSelectedIndex() == 0) { if (isFollowingTheme()) {
return nameStyleListPane.updateBorderStyle(); return nameStyleListPane.updateBorderStyle();
} else if (customStylePane.isBorderPaneSelected()) { } else if (customStylePane.isBorderPaneSelected()) {
return customStylePane.updateBorderStyle(); return customStylePane.updateBorderStyle();
@ -199,7 +218,7 @@ public class StylePane extends BasicPane implements UIObserver {
public Style updateBean() { public Style updateBean() {
Style finalStyle = null; Style finalStyle = null;
if (getSelectedIndex() == 0) { if (isFollowingTheme()) {
finalStyle = nameStyleListPane.updateNameStyle(); finalStyle = nameStyleListPane.updateNameStyle();
} }
if (finalStyle == null) { if (finalStyle == null) {
@ -215,7 +234,7 @@ public class StylePane extends BasicPane implements UIObserver {
if (style instanceof NameStyle) { if (style instanceof NameStyle) {
NameStyle nameStyle = (NameStyle) style; NameStyle nameStyle = (NameStyle) style;
setSelectedIndex(0); setFollowingTheme(true);
nameStyleListPane.populateNameStyle(nameStyle); nameStyleListPane.populateNameStyle(nameStyle);
Style realStyle = nameStyle.getRealStyle(); Style realStyle = nameStyle.getRealStyle();
try { try {
@ -225,7 +244,7 @@ public class StylePane extends BasicPane implements UIObserver {
e.printStackTrace(); e.printStackTrace();
} }
} else { } else {
setSelectedIndex(1); setFollowingTheme(false);
customStylePane.populateBean(style); customStylePane.populateBean(style);
} }
//单元格配置界面是单例 所以直接在populate的时候把跟随主题的按钮组设置不可见 //单元格配置界面是单例 所以直接在populate的时候把跟随主题的按钮组设置不可见

47
designer-realize/src/main/java/com/fr/design/mainframe/errorinfo/ErrorInfoLogAppender.java

@ -4,6 +4,13 @@ import com.fr.base.io.IOFile;
import com.fr.base.io.XMLReadHelper; import com.fr.base.io.XMLReadHelper;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.third.apache.logging.log4j.Level;
import com.fr.third.apache.logging.log4j.core.Filter;
import com.fr.third.apache.logging.log4j.core.Layout;
import com.fr.third.apache.logging.log4j.core.LogEvent;
import com.fr.third.apache.logging.log4j.core.appender.AbstractAppender;
import com.fr.third.apache.logging.log4j.core.config.Property;
import com.fr.third.apache.logging.log4j.core.layout.PatternLayout;
import com.fr.web.session.SessionLocalManager; import com.fr.web.session.SessionLocalManager;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
@ -12,22 +19,20 @@ import com.fr.stable.project.ProjectConstants;
import com.fr.stable.web.SessionProvider; import com.fr.stable.web.SessionProvider;
import com.fr.stable.xml.XMLPrintWriter; import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLableReader; import com.fr.stable.xml.XMLableReader;
import com.fr.third.apache.log4j.AppenderSkeleton;
import com.fr.third.apache.log4j.Level;
import com.fr.third.apache.log4j.spi.LoggingEvent;
import com.fr.web.core.SessionPoolManager; import com.fr.web.core.SessionPoolManager;
import com.fr.web.core.TemplateSessionIDInfo; import com.fr.web.core.TemplateSessionIDInfo;
import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContext;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.InputStream; import java.io.InputStream;
import java.io.Serializable;
/** /**
* 收集设计器报错信息的appender. * 收集设计器报错信息的appender.
* <p> * <p>
* Created by Administrator on 2017/7/24 0024. * Created by Administrator on 2017/7/24 0024.
*/ */
public class ErrorInfoLogAppender extends AppenderSkeleton { public class ErrorInfoLogAppender extends AbstractAppender {
private static final int ERROR_LEN = 8; private static final int ERROR_LEN = 8;
private static final int ERROR_STACK_TRACE = 15; private static final int ERROR_STACK_TRACE = 15;
@ -38,16 +43,23 @@ public class ErrorInfoLogAppender extends AppenderSkeleton {
private String uuid; private String uuid;
private String activekey; private String activekey;
public ErrorInfoLogAppender() { protected ErrorInfoLogAppender(String name, Filter filter,
this.layout = new com.fr.third.apache.log4j.PatternLayout("%d{HH:mm:ss} %t %p [%c] %m%n"); Layout<? extends Serializable> layout,
boolean ignoreExceptions,
Property[] properties) {
super(name, filter, layout, ignoreExceptions, properties);
DesignerEnvManager envManager = DesignerEnvManager.getEnvManager(); DesignerEnvManager envManager = DesignerEnvManager.getEnvManager();
this.username = envManager.getDesignerLoginUsername(); this.username = envManager.getDesignerLoginUsername();
this.uuid = envManager.getUUID(); this.uuid = envManager.getUUID();
this.activekey = envManager.getActivationKey(); this.activekey = envManager.getActivationKey();
} }
protected void append(LoggingEvent event) { public static ErrorInfoLogAppender createErrorLogAppender() {
return new ErrorInfoLogAppender(ErrorInfoLogAppender.class.getSimpleName(), null, PatternLayout.newBuilder().withPattern("%d{HH:mm:ss} %t %p [%c] %m%n %throwable{0}").build(), false, Property.EMPTY_ARRAY);
}
@Override
public void append(LogEvent event) {
this.subAppend(event); this.subAppend(event);
} }
@ -55,19 +67,12 @@ public class ErrorInfoLogAppender extends AppenderSkeleton {
return true; return true;
} }
public synchronized void close() {
if (this.closed) {
return;
}
this.closed = true;
}
public void subAppend(LoggingEvent event) { public void subAppend(LogEvent event) {
Level level = event.getLevel(); Level level = event.getLevel();
// 只分析上传记录error以上的. // 只分析上传记录error以上的.
if (level.isGreaterOrEqual(Level.ERROR)) { if (level.isMoreSpecificThan(Level.ERROR)) {
String msg = this.layout.format(event); String msg = (String) this.toSerializable(event);
// 这个id并不是一定会有的, 有就记录下, 说明是预览模板出的错. // 这个id并不是一定会有的, 有就记录下, 说明是预览模板出的错.
String templateid = readTemplateID(); String templateid = readTemplateID();
String logid = readLogID(msg); String logid = readLogID(msg);
@ -80,13 +85,13 @@ public class ErrorInfoLogAppender extends AppenderSkeleton {
} }
} }
private String readStackTrace(LoggingEvent event) { private String readStackTrace(LogEvent event) {
String[] s = event.getThrowableStrRep(); StackTraceElement[] s = event.getThrown() == null ? null : event.getThrown().getStackTrace();
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
if (s != null) { if (s != null) {
int len = Math.min(s.length, ERROR_STACK_TRACE); int len = Math.min(s.length, ERROR_STACK_TRACE);
for (int i = 0; i < len; i++) { for (int i = 0; i < len; i++) {
sb.append(s[i]).append("\n"); sb.append(s[i].toString()).append("\n");
} }
} }
return sb.toString(); return sb.toString();

27
designer-realize/src/main/java/com/fr/design/mainframe/errorinfo/ErrorInfoUploader.java

@ -44,30 +44,35 @@ public class ErrorInfoUploader {
//单次发送的错误信息最大条数 //单次发送的错误信息最大条数
private static final int MAX_ITEMS = 200; private static final int MAX_ITEMS = 200;
private static LogHandler<ErrorInfoLogAppender> logHandler;
static { static {
GeneralContext.addEnvChangedListener(new EnvChangedListener() { GeneralContext.addEnvChangedListener(new EnvChangedListener() {
@Override @Override
public void envChanged() { public void envChanged() {
FineLoggerFactory.getLogger().addLogAppender(new LogHandler<ErrorInfoLogAppender>() { if (logHandler != null) {
private ErrorInfoLogAppender errorInfoLogAppender = new ErrorInfoLogAppender(); logHandler.getHandler().stop();
FineLoggerFactory.getLogger().removeLogAppender(logHandler);
@Override logHandler.getHandler().start();
public ErrorInfoLogAppender getHandler() { FineLoggerFactory.getLogger().addLogAppender(logHandler);
return errorInfoLogAppender; }
}
});
} }
}); });
} }
private ErrorInfoUploader() { private ErrorInfoUploader() {
FineLoggerFactory.getLogger().addLogAppender(new LogHandler<ErrorInfoLogAppender>() { logHandler = new LogHandler<ErrorInfoLogAppender>() {
private final ErrorInfoLogAppender errorInfoLogAppender = ErrorInfoLogAppender.createErrorLogAppender();
@Override @Override
public ErrorInfoLogAppender getHandler() { public ErrorInfoLogAppender getHandler() {
return new ErrorInfoLogAppender(); return errorInfoLogAppender;
} }
}); };
logHandler.getHandler().start();
FineLoggerFactory.getLogger().addLogAppender(logHandler);
} }
public static ErrorInfoUploader getInstance() { public static ErrorInfoUploader getInstance() {

1
designer-realize/src/main/java/com/fr/design/mainframe/form/FormElementCaseDesigner.java

@ -13,7 +13,6 @@ import com.fr.design.designer.EditingState;
import com.fr.design.designer.TargetComponent; import com.fr.design.designer.TargetComponent;
import com.fr.design.event.TargetModifiedEvent; import com.fr.design.event.TargetModifiedEvent;
import com.fr.design.event.TargetModifiedListener; import com.fr.design.event.TargetModifiedListener;
import com.fr.design.fit.DesignerUIModeConfig;
import com.fr.design.gui.frpane.HyperlinkGroupPane; import com.fr.design.gui.frpane.HyperlinkGroupPane;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.AuthorityEditPane; import com.fr.design.mainframe.AuthorityEditPane;

46
designer-realize/src/main/java/com/fr/design/mainframe/form/FormElementCasePaneDelegate.java

@ -6,8 +6,10 @@ import com.fr.design.actions.core.ActionFactory;
import com.fr.design.actions.form.FormECBackgroundAction; import com.fr.design.actions.form.FormECBackgroundAction;
import com.fr.design.actions.form.FormECColumnsAction; import com.fr.design.actions.form.FormECColumnsAction;
import com.fr.design.actions.form.FormECFrozenAction; import com.fr.design.actions.form.FormECFrozenAction;
import com.fr.design.designer.creator.XElementCase;
import com.fr.design.event.TargetModifiedEvent; import com.fr.design.event.TargetModifiedEvent;
import com.fr.design.event.TargetModifiedListener; import com.fr.design.event.TargetModifiedListener;
import com.fr.design.fit.common.FormDesignerUtil;
import com.fr.design.gui.frpane.HyperlinkGroupPane; import com.fr.design.gui.frpane.HyperlinkGroupPane;
import com.fr.design.mainframe.*; import com.fr.design.mainframe.*;
import com.fr.design.mainframe.cell.QuickEditorRegion; import com.fr.design.mainframe.cell.QuickEditorRegion;
@ -18,21 +20,27 @@ import com.fr.design.menu.ToolBarDef;
import com.fr.design.present.ConditionAttributesGroupPane; import com.fr.design.present.ConditionAttributesGroupPane;
import com.fr.form.main.Form; import com.fr.form.main.Form;
import com.fr.grid.Grid; import com.fr.grid.Grid;
import com.fr.grid.GridColumn;
import com.fr.grid.GridCorner;
import com.fr.grid.GridRow;
import com.fr.page.ReportSettingsProvider; import com.fr.page.ReportSettingsProvider;
import com.fr.report.elementcase.TemplateElementCase;
import com.fr.report.worksheet.FormElementCase; import com.fr.report.worksheet.FormElementCase;
import com.fr.design.selection.SelectionEvent; import com.fr.design.selection.SelectionEvent;
import com.fr.design.selection.SelectionListener; import com.fr.design.selection.SelectionListener;
import javax.swing.JComponent; import javax.swing.JComponent;
import javax.swing.JPanel; import javax.swing.JPanel;
import java.awt.Insets;
import java.awt.Rectangle;
/** /**
*/ */
public class FormElementCasePaneDelegate extends ElementCasePane<FormElementCase>{ public class FormElementCasePaneDelegate extends ElementCasePane<FormElementCase>{
public FormElementCasePaneDelegate(FormElementCase sheet, Form form) { public FormElementCasePaneDelegate(FormElementCase sheet, Form form) {
super(sheet); super(sheet);
this.getGrid().setPaginateLineShowType(form.getFormMobileAttr().isMobileOnly() this.getGrid().setPaginateLineShowType(form.getFormMobileAttr().isMobileOnly()
? Grid.SINGLE_HORIZONTAL_PAGINATE_LINE ? Grid.SINGLE_HORIZONTAL_PAGINATE_LINE
: Grid.NO_PAGINATE_LINE); : Grid.NO_PAGINATE_LINE);
@ -55,6 +63,42 @@ public class FormElementCasePaneDelegate extends ElementCasePane<FormElementCase
}); });
} }
private Rectangle getBoundsLineRect(TemplateElementCase elementCase) {
FormDesigner designer = WidgetPropertyPane.getInstance().getEditingFormDesigner();
final Rectangle rectangle = new Rectangle();
XElementCase xElementCase = FormDesignerUtil.getXelementCase(designer.getRootComponent(), (FormElementCase) elementCase);
if (xElementCase != null) {
rectangle.setBounds(xElementCase.getBounds());
//减去内边距的宽和高
Insets insets = xElementCase.getInsets();
rectangle.width -= insets.left + insets.right;
rectangle.height -= insets.top + insets.bottom;
}
return rectangle;
}
protected void initGridComponent() {
Rectangle adsorbRec = getBoundsLineRect(this.getEditingElementCase());
// Components
if (this.grid == null) {
this.grid = new Grid(this.getResolution(), adsorbRec.width, adsorbRec.height);
this.grid.setAdsorbWidth(adsorbRec.width);
this.grid.setAdsorbHeight(adsorbRec.height);
}
if (this.gridColumn == null) {
this.gridColumn = new GridColumn(this.getResolution(), adsorbRec.width);
}
if (this.gridRow == null) {
this.gridRow = new GridRow(this.getResolution(), adsorbRec.height);
}
if (this.gridCorner == null) {
this.gridCorner = new GridCorner();
}
}
private void refreshPropertyPanes() { private void refreshPropertyPanes() {
CellElementPropertyPane.getInstance().populate(FormElementCasePaneDelegate.this); CellElementPropertyPane.getInstance().populate(FormElementCasePaneDelegate.this);
QuickEditorRegion.getInstance().populate(getCurrentEditor()); QuickEditorRegion.getInstance().populate(getCurrentEditor());

5
designer-realize/src/main/java/com/fr/design/mainframe/form/FormReportComponentComposite.java

@ -6,10 +6,10 @@ import com.fr.common.inputevent.InputEventBaseOnOS;
import com.fr.design.cell.bar.DynamicScrollBar; import com.fr.design.cell.bar.DynamicScrollBar;
import com.fr.design.event.TargetModifiedEvent; import com.fr.design.event.TargetModifiedEvent;
import com.fr.design.event.TargetModifiedListener; import com.fr.design.event.TargetModifiedListener;
import com.fr.design.fit.DesignerUIModeConfig;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.BaseJForm; import com.fr.design.mainframe.BaseJForm;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.DesignerUIModeConfig;
import com.fr.design.mainframe.ElementCasePane; import com.fr.design.mainframe.ElementCasePane;
import com.fr.design.mainframe.JFormSliderPane; import com.fr.design.mainframe.JFormSliderPane;
import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus; import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus;
@ -20,6 +20,7 @@ import com.fr.grid.GridUtils;
import com.fr.report.ReportHelper; import com.fr.report.ReportHelper;
import com.fr.report.worksheet.FormElementCase; import com.fr.report.worksheet.FormElementCase;
import com.fr.stable.AssistUtils; import com.fr.stable.AssistUtils;
import com.fr.stable.Constants;
import javax.swing.*; import javax.swing.*;
import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeEvent;
@ -54,6 +55,7 @@ public class FormReportComponentComposite extends JComponent implements TargetMo
jSliderContainer.addValueChangeListener(showValSpinnerChangeListener); jSliderContainer.addValueChangeListener(showValSpinnerChangeListener);
this.elementCaseDesigner.elementCasePane.getGrid().addMouseWheelListener(showValSpinnerMouseWheelListener); this.elementCaseDesigner.elementCasePane.getGrid().addMouseWheelListener(showValSpinnerMouseWheelListener);
elementCaseDesigner.addTargetModifiedListener(this); elementCaseDesigner.addTargetModifiedListener(this);
this.jSliderContainer.setShowValue((ScreenResolution.getScreenResolution() * HUND) / Constants.DEFAULT_WEBWRITE_AND_SCREEN_RESOLUTION);
} }
MouseWheelListener showValSpinnerMouseWheelListener = new MouseWheelListener() { MouseWheelListener showValSpinnerMouseWheelListener = new MouseWheelListener() {
@ -76,7 +78,6 @@ public class FormReportComponentComposite extends JComponent implements TargetMo
value = value < MIN ? MIN : value; value = value < MIN ? MIN : value;
int resolution = (int) (DesignerUIModeConfig.getInstance().getScreenResolution() * value / HUND); int resolution = (int) (DesignerUIModeConfig.getInstance().getScreenResolution() * value / HUND);
setScale(resolution); setScale(resolution);
// HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().setScale(resolution);
} }
}; };

3
designer-realize/src/main/java/com/fr/design/mainframe/socketio/AbstractSocketConfig.java

@ -15,6 +15,8 @@ import com.fr.workspace.base.WorkspaceConstants;
import com.fr.workspace.connect.WorkspaceConnection; import com.fr.workspace.connect.WorkspaceConnection;
import com.fr.workspace.connect.WorkspaceConnectionInfo; import com.fr.workspace.connect.WorkspaceConnectionInfo;
import io.socket.client.IO; import io.socket.client.IO;
import io.socket.engineio.client.transports.Polling;
import io.socket.engineio.client.transports.WebSocket;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
@ -45,6 +47,7 @@ public abstract class AbstractSocketConfig {
public IO.Options createOptions() { public IO.Options createOptions() {
IO.Options options = new IO.Options(); IO.Options options = new IO.Options();
options.path = WebSocketConfig.getInstance().getSocketContext(); options.path = WebSocketConfig.getInstance().getSocketContext();
options.transports = new String[]{WebSocket.NAME, Polling.NAME};;
try { try {
if (ComparatorUtils.equals(currentProtocol, HTTPS)) { if (ComparatorUtils.equals(currentProtocol, HTTPS)) {
options.sslContext = getSSLContext(); options.sslContext = getSSLContext();

1
designer-realize/src/main/java/com/fr/design/mainframe/socketio/ContainerSocketConfig.java

@ -29,7 +29,6 @@ public class ContainerSocketConfig extends AbstractSocketConfig {
@Override @Override
public IO.Options createOptions() { public IO.Options createOptions() {
IO.Options options = super.createOptions(); IO.Options options = super.createOptions();
options.transports = new String[]{WebSocket.NAME, Polling.NAME};
options.path = String.format("/%s%s", FRContext.getCommonOperator().getAppName(), WebSocketConstants.WEBSOCKET_PATH); options.path = String.format("/%s%s", FRContext.getCommonOperator().getAppName(), WebSocketConstants.WEBSOCKET_PATH);
return options; return options;
} }

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

@ -11,6 +11,7 @@ import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.loghandler.DesignerLogger; import com.fr.design.mainframe.loghandler.DesignerLogger;
import com.fr.design.mainframe.loghandler.LogEventConverter;
import com.fr.design.mainframe.share.ui.base.MouseClickListener; import com.fr.design.mainframe.share.ui.base.MouseClickListener;
import com.fr.design.mainframe.toast.DesignerToastMsgUtil; import com.fr.design.mainframe.toast.DesignerToastMsgUtil;
import com.fr.design.mainframe.toast.ToastMsgDialog; import com.fr.design.mainframe.toast.ToastMsgDialog;
@ -23,6 +24,7 @@ import com.fr.serialization.SerializerHelper;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
import com.fr.third.apache.log4j.spi.LoggingEvent; import com.fr.third.apache.log4j.spi.LoggingEvent;
import com.fr.third.apache.logging.log4j.core.LogEvent;
import com.fr.third.org.apache.http.client.config.RequestConfig; import com.fr.third.org.apache.http.client.config.RequestConfig;
import com.fr.third.org.apache.http.client.methods.CloseableHttpResponse; import com.fr.third.org.apache.http.client.methods.CloseableHttpResponse;
import com.fr.third.org.apache.http.client.methods.HttpGet; import com.fr.third.org.apache.http.client.methods.HttpGet;
@ -148,7 +150,14 @@ public class DesignerSocketIO {
public void call(Object... objects) { public void call(Object... objects) {
if (ArrayUtils.isNotEmpty(objects)) { if (ArrayUtils.isNotEmpty(objects)) {
try { try {
LoggingEvent event = SerializerHelper.deserialize((byte[]) objects[0]); Object obj = SerializerHelper.deserialize((byte[]) objects[0]);
// 兼容下老版本服务器
LogEvent event;
if (obj instanceof LoggingEvent) {
event = LogEventConverter.convert((LoggingEvent) obj);
} else {
event = (LogEvent) obj;
}
DesignerLogger.log(event); DesignerLogger.log(event);
} catch (Exception e) { } catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);

16
designer-realize/src/main/java/com/fr/design/report/ReportStylePane.java

@ -118,13 +118,12 @@ public class ReportStylePane extends BasicPane {
private JPanel createPreviewPane() { private JPanel createPreviewPane() {
JPanel container = FRGUIPaneFactory.createBorderLayout_S_Pane(); JPanel container = FRGUIPaneFactory.createBorderLayout_S_Pane();
container.setBorder(createTitleBorder(Toolkit.i18nText("Fine-Design_Basic_Preview"))); container.setBorder(BorderFactory.createCompoundBorder(
container.setPreferredSize(new Dimension(container.getPreferredSize().width, 60)); createTitleBorder(Toolkit.i18nText("Fine-Design_Basic_Preview")),
JPanel content = FRGUIPaneFactory.createBorderLayout_S_Pane(); BorderFactory.createEmptyBorder(4, 4, 4, 4)
content.setBorder(BorderFactory.createEmptyBorder(4, 4, 2, 2)); ));
previewArea.setPreferredSize(new Dimension(container.getPreferredSize().width, 42)); previewArea.setPreferredSize(new Dimension(container.getPreferredSize().width, 40));
content.add(previewArea, BorderLayout.NORTH); container.add(previewArea, BorderLayout.CENTER);
container.add(content, BorderLayout.NORTH);
return container; return container;
} }
@ -541,7 +540,8 @@ public class ReportStylePane extends BasicPane {
UITabbedPane mainTabbedPane = new UITabbedPane(); UITabbedPane mainTabbedPane = new UITabbedPane();
setLayout(FRGUIPaneFactory.createBorderLayout()); setLayout(FRGUIPaneFactory.createBorderLayout());
nameStyleListPane = new NameStyleListPane(); nameStyleListPane = new NameStyleListPane(false);
nameStyleListPane.addChangeListener(this);
nameStyleListPane.setBorder(BorderFactory.createEmptyBorder()); nameStyleListPane.setBorder(BorderFactory.createEmptyBorder());
UIScrollPane scrollPane = new UIScrollPane(nameStyleListPane); UIScrollPane scrollPane = new UIScrollPane(nameStyleListPane);
scrollPane.setBorder(BorderFactory.createEmptyBorder(10, 5, 5, 0)); scrollPane.setBorder(BorderFactory.createEmptyBorder(10, 5, 5, 0));

40
designer-realize/src/main/java/com/fr/design/sort/celldscolumn/CellDSColumnSortGroupPane.java

@ -0,0 +1,40 @@
package com.fr.design.sort.celldscolumn;
import com.fr.design.data.DesignTableDataManager;
import com.fr.design.data.tabledata.wrapper.TableDataWrapper;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.sort.common.AbstractSortGroupPane;
import com.fr.design.sort.common.AbstractSortItemPane;
import com.fr.report.cell.cellattr.core.group.DSColumn;
import com.fr.report.core.sort.sortexpression.SortExpression;
public class CellDSColumnSortGroupPane extends AbstractSortGroupPane {
DSColumn dsColumn;
public CellDSColumnSortGroupPane(int sortGroupPaneWidth, int sortGroupPaneRightWidth) {
super(sortGroupPaneWidth, sortGroupPaneRightWidth);
}
public void populateDsColumn(DSColumn dsColumn) {
this.dsColumn = dsColumn;
}
@Override
protected AbstractSortItemPane refreshSortItemPane(int sortItemPaneWidth, int sortItemPaneRightWidth, SortExpression sortExpression) {
CellDSColumnSortItemPane cellDSColumnSortItemPane = new CellDSColumnSortItemPane(sortItemPaneWidth, sortItemPaneRightWidth);
java.util.Map<String, TableDataWrapper> tableDataWrapperMap =
DesignTableDataManager.getAllEditingDataSet(HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getTarget());
TableDataWrapper tableDataWrapper = tableDataWrapperMap.get(dsColumn.getDSName());
if (tableDataWrapper != null) {
java.util.List<String> columnNameList = tableDataWrapper.calculateColumnNameList();
String[] columnNames = new String[columnNameList.size()];
columnNameList.toArray(columnNames);
cellDSColumnSortItemPane.sortAreaUiComboBox.removeAllItems();
for (String columnName : columnNames) {
cellDSColumnSortItemPane.sortAreaUiComboBox.addItem(columnName);
}
}
cellDSColumnSortItemPane.populateBean(sortExpression);
return cellDSColumnSortItemPane;
}
}

40
designer-realize/src/main/java/com/fr/design/sort/celldscolumn/CellDSColumnSortItemPane.java

@ -0,0 +1,40 @@
package com.fr.design.sort.celldscolumn;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.sort.common.AbstractSortItemPane;
import com.fr.design.sort.common.AbstractSortPane;
import com.fr.report.core.sort.sortexpression.SortExpression;
import javax.swing.*;
import java.awt.*;
public class CellDSColumnSortItemPane extends AbstractSortItemPane {
UIComboBox sortAreaUiComboBox;
public CellDSColumnSortItemPane(int sortItemPaneWidth, int sortItemPaneRightWidth) {
super(sortItemPaneWidth, sortItemPaneRightWidth);
}
@Override
public void initMainSortAreaPane(JPanel sortAreaPane) {
sortAreaUiComboBox = new UIComboBox(new String[0]);
sortAreaUiComboBox.setPreferredSize(new Dimension(sortItemPaneRightWidth, AbstractSortPane.PANE_COMPONENT_HEIGHT));
sortAreaPane.add(sortAreaUiComboBox);
}
public void populateBean(SortExpression sortExpression) {
sortAreaUiComboBox.setSelectedItem(sortExpression.getSortArea());
super.populateBean(sortExpression);
}
public SortExpression updateBean() {
SortExpression sortExpression = super.updateBean();
if (sortExpression != null) {
sortExpression.setSortArea(sortAreaUiComboBox.getSelectedItem().toString());
}
return sortExpression;
}
}

59
designer-realize/src/main/java/com/fr/design/sort/celldscolumn/CellDSColumnSortPane.java

@ -0,0 +1,59 @@
package com.fr.design.sort.celldscolumn;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.sort.common.AbstractSortPane;
import com.fr.general.data.TableDataColumn;
import com.fr.report.cell.TemplateCellElement;
import com.fr.report.cell.cellattr.core.group.DSColumn;
import com.fr.report.core.sort.common.CellSortAttr;
import javax.swing.*;
public class CellDSColumnSortPane extends AbstractSortPane {
public CellDSColumnSortPane() {
super(220, 150);
//this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
}
@Override
protected void initSortGroupPane() {
sortGroupPane = new CellDSColumnSortGroupPane(sortPaneWidth, sortPaneRightWidth);
this.add(sortGroupPane);
}
@Override
protected CellSortAttr getCellSortAttr(TemplateCellElement cellElement) {
if (cellElement.getValue() instanceof DSColumn) {
DSColumn dsColumn = ((DSColumn) cellElement.getValue());
if (dsColumn.getCellSortAttr() == null) {
dsColumn.setCellSortAttr(new CellSortAttr());
}
return dsColumn.getCellSortAttr();
}
return null;
}
protected void populateSortArea(TemplateCellElement cellElement) {
super.populateSortArea(cellElement);
if (cellElement.getValue() instanceof DSColumn) {
DSColumn dsColumn = ((DSColumn) cellElement.getValue());
TableDataColumn tableDataColumn = dsColumn.getColumn();
if (tableDataColumn instanceof TableDataColumn) {
selfSortArea = TableDataColumn.getColumnName(tableDataColumn);
}
}
}
public void populateBean(TemplateCellElement cellElement) {
if (cellElement.getValue() instanceof DSColumn) {
DSColumn dsColumn = ((DSColumn) cellElement.getValue());
if (sortGroupPane != null) {
((CellDSColumnSortGroupPane) sortGroupPane).populateDsColumn(dsColumn);
}
}
super.populateBean(cellElement);
}
}

19
designer-realize/src/main/java/com/fr/design/sort/cellexpand/CellExpandSortGroupPane.java

@ -0,0 +1,19 @@
package com.fr.design.sort.cellexpand;
import com.fr.design.sort.common.AbstractSortGroupPane;
import com.fr.design.sort.common.AbstractSortItemPane;
import com.fr.report.core.sort.sortexpression.SortExpression;
public class CellExpandSortGroupPane extends AbstractSortGroupPane {
public CellExpandSortGroupPane(int sortGroupPaneWidth, int sortGroupPaneRightWidth) {
super(sortGroupPaneWidth, sortGroupPaneRightWidth);
}
@Override
protected AbstractSortItemPane refreshSortItemPane(int sortItemPaneWidth, int sortItemPaneRightWidth, SortExpression sortExpression) {
AbstractSortItemPane abstractSortItemPane = new CellExpandSortItemPane( sortItemPaneWidth, sortItemPaneRightWidth);
abstractSortItemPane.populateBean(sortExpression);
return abstractSortItemPane;
}
}

37
designer-realize/src/main/java/com/fr/design/sort/cellexpand/CellExpandSortItemPane.java

@ -0,0 +1,37 @@
package com.fr.design.sort.cellexpand;
import com.fr.design.sort.common.AbstractSortPane;
import com.fr.design.sort.common.SortColumnRowPane;
import com.fr.design.sort.common.AbstractSortItemPane;
import com.fr.report.core.sort.sortexpression.SortExpression;
import com.fr.stable.ColumnRow;
import javax.swing.*;
public class CellExpandSortItemPane extends AbstractSortItemPane {
SortColumnRowPane columnRowPane;
public CellExpandSortItemPane(int sortItemPaneWidth, int sortItemPaneRightWidth) {
super(sortItemPaneWidth, sortItemPaneRightWidth);
}
@Override
public void initMainSortAreaPane(JPanel sortAreaPane) {
columnRowPane = new SortColumnRowPane(sortItemPaneRightWidth + 4, AbstractSortPane.PANE_COMPONENT_HEIGHT);
sortAreaPane.add(columnRowPane);
}
public void populateBean(SortExpression sortExpression) {
columnRowPane.populateBean(ColumnRow.valueOf(sortExpression.getSortArea()));
super.populateBean(sortExpression);
}
public SortExpression updateBean() {
SortExpression sortExpression = super.updateBean();
if (sortExpression != null) {
ColumnRow columnRow = columnRowPane.updateBean();
sortExpression.setSortArea(columnRow == null ? null : columnRow.toString());
}
return sortExpression;
}
}

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

Loading…
Cancel
Save