Browse Source

Merge branch 'release/11.0' of ssh://code.fineres.com:7999/~fanglei/design into release/11.0

* 'release/11.0' of ssh://code.fineres.com:7999/~fanglei/design: (91 commits)
  合并冲突
  REPORT-64601 公式编辑器首次进入的时候光标位置不正确 1.放到swing执行队列队尾。
  REPORT-64601 公式编辑器首次进入的时候光标位置不正确 1.修改代码。
  REPORT-64601 公式编辑器首次进入的时候光标位置不正确 1.加载完公式编辑器后异步请求一下光标;
  REPORT-64811 保持设计器商城下载reu文件名中的版本信息
  REPORT-64506 && REPORT-64457 && REPORT-64456 && REPORT-64425 && REPORT-64422
  REPORT-64702【frm设计器界面修改】新&旧模式下,新拖入的报表块,组件尺寸是250*150,进入报表块编辑,悬浮虚线看到的尺寸也是250*150,但退出编辑,拖拽调整报表块尺寸时,虚线范围比刚才看到的大了
  REPORT-64022:面板添加一个提示
  REPORT-64412 连续选中两次同一选项,编辑框值不对
  CHART-21877 fix:fvs.cpt 批量设置单元格背景颜色后 单元格字体是黑色
  REPORT-64527 && REPORT-64525 && REPORT-64489 && REPORT-64485 && REPORT-64466 && REPORT-64463 && REPORT-64462 && REPORT-64460
  CHART-22076 fix:fvs.cpt 单元格设置超链删除超链 文本白色
  REPORT-55241:修改没有开启固定分页时固定分页的数值
  REPORT-55241:修改一下代码格式
  REPORT-64642 【主题边框】左侧预览图中单元格设置逻辑调整
  REPORT-63808 【主题优化】格式单独拿出来以后,发现数据列的弹窗配置中没有格式项
  REPORT-55241:添加报表引擎属性埋点
  REPORT-64656 设计器操作,双击已打开的模板,不会定位到对应模板
  update
  CHART-22090 条件属性-颜色控件残留
  ...

# Conflicts:
#	designer-form/src/main/java/com/fr/design/fit/toolbar/SwitchAction.java
bugfix/11.0
方磊 3 years ago
parent
commit
fc368f94a1
  1. 1
      build.gradle
  2. 12
      designer-base/src/main/java/com/fr/common/exception/ThrowableHandler.java
  3. 15
      designer-base/src/main/java/com/fr/design/DesignerEnvManager.java
  4. 5
      designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java
  5. 104
      designer-base/src/main/java/com/fr/design/cell/CellRectangleStylePreviewPane.java
  6. 62
      designer-base/src/main/java/com/fr/design/cell/CellStylePreviewPane.java
  7. 52
      designer-base/src/main/java/com/fr/design/config/DesignerProperties.java
  8. 119
      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. 147
      designer-base/src/main/java/com/fr/design/data/datapane/connect/AdvancePane.java
  11. 35
      designer-base/src/main/java/com/fr/design/data/datapane/connect/DBCPAttrPane.java
  12. 44
      designer-base/src/main/java/com/fr/design/data/datapane/connect/DatabaseConnectionPane.java
  13. 7
      designer-base/src/main/java/com/fr/design/event/ComponentChangeListener.java
  14. 6
      designer-base/src/main/java/com/fr/design/event/ComponentChangeObserver.java
  15. 6
      designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java
  16. 4
      designer-base/src/main/java/com/fr/design/file/MutilTempalteTabPane.java
  17. 46
      designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java
  18. 5
      designer-base/src/main/java/com/fr/design/formula/FormulaPane.java
  19. 11
      designer-base/src/main/java/com/fr/design/gui/frpane/AbstractAttrNoScrollPane.java
  20. 14
      designer-base/src/main/java/com/fr/design/gui/frpane/TreeSettingPane.java
  21. 6
      designer-base/src/main/java/com/fr/design/gui/icheckbox/UICheckBox.java
  22. 4
      designer-base/src/main/java/com/fr/design/gui/icombobox/FRTreeComboBox.java
  23. 77
      designer-base/src/main/java/com/fr/design/gui/icombobox/SearchPreTaskTreeComboBox.java
  24. 217
      designer-base/src/main/java/com/fr/design/gui/icombobox/TableSearchTreeComboBox.java
  25. 7
      designer-base/src/main/java/com/fr/design/gui/itextfield/UIAutoCompletionField.java
  26. 108
      designer-base/src/main/java/com/fr/design/gui/style/BorderPane.java
  27. 235
      designer-base/src/main/java/com/fr/design/gui/style/TextFormatPane.java
  28. 121
      designer-base/src/main/java/com/fr/design/lock/LockInfoDialog.java
  29. 23
      designer-base/src/main/java/com/fr/design/lock/LockInfoUtils.java
  30. 11
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java
  31. 69
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java
  32. 46
      designer-base/src/main/java/com/fr/design/mainframe/DesignerUIModeConfig.java
  33. 12
      designer-base/src/main/java/com/fr/design/mainframe/DesktopCardPane.java
  34. 189
      designer-base/src/main/java/com/fr/design/mainframe/ForbiddenPane.java
  35. 37
      designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java
  36. 4
      designer-base/src/main/java/com/fr/design/mainframe/NorthRegionContainerPane.java
  37. 2
      designer-base/src/main/java/com/fr/design/mainframe/PX.java
  38. 2
      designer-base/src/main/java/com/fr/design/mainframe/PXReportLengthUNIT.java
  39. 17
      designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/ColorBackgroundQuickPane.java
  40. 42
      designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogAppender.java
  41. 22
      designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogHandler.java
  42. 41
      designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogger.java
  43. 77
      designer-base/src/main/java/com/fr/design/mainframe/theme/ThemedCellStyleListPane.java
  44. 17
      designer-base/src/main/java/com/fr/design/mainframe/theme/ThemedFeatureController.java
  45. 22
      designer-base/src/main/java/com/fr/design/mainframe/theme/dialog/TemplateThemeDialog.java
  46. 18
      designer-base/src/main/java/com/fr/design/mainframe/theme/edit/CellStyleListEditPane.java
  47. 56
      designer-base/src/main/java/com/fr/design/mainframe/theme/edit/cell/CellStyleEditPane.java
  48. 3
      designer-base/src/main/java/com/fr/design/mainframe/theme/edit/chart/ChartFontPane.java
  49. 2
      designer-base/src/main/java/com/fr/design/mainframe/theme/edit/ui/ColorListPane.java
  50. 5
      designer-base/src/main/java/com/fr/design/mainframe/theme/preview/ReportThemePreviewPane.java
  51. 38
      designer-base/src/main/java/com/fr/design/mainframe/theme/preview/ecpreview/AbstractECPreviewPane.java
  52. 47
      designer-base/src/main/java/com/fr/design/mainframe/theme/preview/ecpreview/ECPreviewPane.java
  53. 88
      designer-base/src/main/java/com/fr/design/mainframe/theme/preview/ecpreview/ECReportPreviewPane.java
  54. 27
      designer-base/src/main/java/com/fr/design/mainframe/theme/preview/ecpreview/cell/AbstractPreviewCell.java
  55. 7
      designer-base/src/main/java/com/fr/design/os/impl/SupportOSImpl.java
  56. 135
      designer-base/src/main/java/com/fr/design/utils/TemplateUtils.java
  57. 16
      designer-base/src/main/java/com/fr/design/utils/gui/AdjustWorkBookDefaultStyleUtils.java
  58. 10
      designer-base/src/main/java/com/fr/design/worker/open/OpenWorker.java
  59. 113
      designer-base/src/main/java/com/fr/design/worker/save/SaveFailureHandler.java
  60. 11
      designer-base/src/main/java/com/fr/design/worker/save/SaveWorker.java
  61. 10
      designer-base/src/main/java/com/fr/file/FILEChooserPane.java
  62. 2
      designer-base/src/main/java/com/fr/start/BaseDesigner.java
  63. 4
      designer-base/src/main/java/com/fr/start/server/FineEmbedServerActivator.java
  64. 5
      designer-base/src/main/resources/com/fr/design/images/buttonicon/select_disabled.svg
  65. 5
      designer-base/src/main/resources/com/fr/design/images/buttonicon/select_normal.svg
  66. BIN
      designer-base/src/main/resources/com/fr/design/images/mainframe/lock_template.png
  67. BIN
      designer-base/src/main/resources/com/fr/design/images/mainframe/refreh_icon.png
  68. BIN
      designer-base/src/main/resources/com/fr/design/images/sort/add.png
  69. 19
      designer-base/src/main/resources/com/fr/design/images/sort/asc.svg
  70. 17
      designer-base/src/main/resources/com/fr/design/images/sort/des.svg
  71. BIN
      designer-base/src/main/resources/com/fr/design/images/sort/down_arrow.png
  72. BIN
      designer-base/src/main/resources/com/fr/design/images/sort/left_arrow.png
  73. 41
      designer-base/src/main/resources/com/fr/design/images/sort/nosort.svg
  74. BIN
      designer-base/src/main/resources/com/fr/design/images/sort/sequence.png
  75. BIN
      designer-base/src/main/resources/com/fr/design/images/toolbarbtn/lock.png
  76. BIN
      designer-base/src/main/resources/com/fr/design/images/toolbarbtn/unlock.png
  77. 6
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ChartTextAttrPaneWithThemeStyle.java
  78. 4
      designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartTooltipContentPane.java
  79. 11
      designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartUIListControlPane.java
  80. 14
      designer-chart/src/main/java/com/fr/van/chart/funnel/designer/style/VanChartFunnelSeriesPane.java
  81. 5
      designer-chart/src/main/java/com/fr/van/chart/pie/style/VanChartPieCategoryLabelContentPane.java
  82. 115
      designer-form/src/main/java/com/fr/design/actions/NewFormMobileAttrAction.java
  83. 109
      designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteLayout.java
  84. 100
      designer-form/src/main/java/com/fr/design/designer/creator/XWFitLayout.java
  85. 4
      designer-form/src/main/java/com/fr/design/designer/properties/FRFitLayoutConstraints.java
  86. 109
      designer-form/src/main/java/com/fr/design/fit/JFormType.java
  87. 103
      designer-form/src/main/java/com/fr/design/fit/NewJForm.java
  88. 145
      designer-form/src/main/java/com/fr/design/fit/common/AdaptiveSwitchUtil.java
  89. 1266
      designer-form/src/main/java/com/fr/design/fit/common/BaseUtils.java
  90. 15
      designer-form/src/main/java/com/fr/design/fit/common/LayoutTool.java
  91. 2030
      designer-form/src/main/java/com/fr/design/fit/common/NewFormStyle.java
  92. 20
      designer-form/src/main/java/com/fr/design/fit/common/NewUIModeAutoChangeLine.java
  93. 69
      designer-form/src/main/java/com/fr/design/fit/common/NewUIModeRotationDraw.java
  94. 835
      designer-form/src/main/java/com/fr/design/fit/common/PaintUtils.java
  95. 100
      designer-form/src/main/java/com/fr/design/fit/common/TemplateTool.java
  96. 28
      designer-form/src/main/java/com/fr/design/fit/toolbar/SwitchAction.java
  97. 137
      designer-form/src/main/java/com/fr/design/mainframe/FormArea.java
  98. 10
      designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java
  99. 3
      designer-form/src/main/java/com/fr/design/mainframe/FormDesignerUI.java
  100. 3
      designer-form/src/main/java/com/fr/design/mainframe/FormSelectionUtils.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 'net.java.dev.jna:jna:5.4.0'
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 'com.fr.third:fine-third:' + frVersion
implementation 'com.fr.core:fine-core:' + frDevVersion

12
designer-base/src/main/java/com/fr/common/exception/ThrowableHandler.java

@ -0,0 +1,12 @@
package com.fr.common.exception;
/**
* @author hades
* @version 11.0
* Created by hades on 2021/12/7
*/
public interface ThrowableHandler {
boolean process(Throwable e);
}

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

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.TableLayoutHelper;
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.common.VcsHelper;
import com.fr.design.os.impl.SupportOSImpl;
@ -45,14 +44,12 @@ import com.fr.locale.InterProviderFactory;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.Constants;
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.Worker;
import com.fr.workspace.WorkContext;
import com.fr.workspace.server.vcs.VcsOperator;
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.BoxLayout;

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

@ -0,0 +1,104 @@
package com.fr.design.cell;
import com.fr.base.CellBorderSourceFlag;
import com.fr.base.CellBorderStyle;
import com.fr.base.Style;
import com.fr.design.mainframe.theme.utils.DefaultThemedTemplateCellElementCase;
import com.fr.report.cell.TemplateCellElement;
import javax.swing.JPanel;
import java.awt.Dimension;
import java.awt.GridLayout;
/**
* @author Starryi
* @version 1.0
* Created by Starryi on 2021/9/3
*/
public class CellRectangleStylePreviewPane extends JPanel {
private static final int ROW_COUNT = 2;
private static final int COLUMN_COUNT = 2;
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];
public CellRectangleStylePreviewPane(boolean supportInnerBorder) {
setLayout(new GridLayout(2, 2));
for (int r = 0; r < ROW_COUNT; r++) {
for (int c = 0; c < COLUMN_COUNT; c++) {
CellStylePreviewPane pane = new CellStylePreviewPane();
TemplateCellElement cellElement = DefaultThemedTemplateCellElementCase.createInstance(c, r);
int flags = CellBorderSourceFlag.INVALID_BORDER_SOURCE;
if (supportInnerBorder) {
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;
}
}
pane.setStyle(cellElement.getStyle());
add(pane);
cellElementGrid[r][c] = cellElement;
borderSourceFlags[r][c] = flags;
cellStylePreviewPaneGrid[r][c] = pane;
}
}
}
public void setPlainText(String text) {
cellStylePreviewPaneGrid[0][1].setPaintText(text);
cellStylePreviewPaneGrid[1][1].setPaintText(text);
repaint();
}
public void setStyle(Style style, CellBorderStyle borderStyle) {
for (int i = 0; i < ROW_COUNT; i++) {
for (int j = 0; j < COLUMN_COUNT; j++) {
CellStylePreviewPane pane = cellStylePreviewPaneGrid[i][j];
TemplateCellElement cellElement = cellElementGrid[i][j];
int flag = borderSourceFlags[i][j];
cellElement.setStyle(CellBorderSourceFlag.deriveBorderedStyle(style, borderStyle, flag));
pane.setStyle(cellElement.getStyle());
}
}
repaint();
}
@Override
public void setPreferredSize(Dimension preferredSize) {
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);
}
}

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

@ -1,19 +1,26 @@
package com.fr.design.cell;
import com.fr.base.BaseUtils;
import com.fr.base.GraphHelper;
import com.fr.base.NameStyle;
import com.fr.base.ScreenResolution;
import com.fr.base.Style;
import com.fr.general.FRFont;
import com.fr.general.IOUtils;
import com.fr.stable.unit.PT;
import javax.swing.JPanel;
import java.awt.AlphaComposite;
import java.awt.Color;
import java.awt.Composite;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.image.BufferedImage;
import java.util.List;
/**
* @author Starryi
@ -22,6 +29,7 @@ import java.awt.image.BufferedImage;
*/
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 final float transparentBackgroundWidth;
private final float transparentBackgroundHeight;
@ -31,16 +39,24 @@ public class CellStylePreviewPane extends JPanel {
public CellStylePreviewPane() {
transparentBackgroundWidth = transparentBackgroundImage.getWidth(null);
transparentBackgroundHeight = transparentBackgroundImage.getHeight(null);
setPreferredSize(new Dimension(0, 0));
}
public void setPaintText(String paintText) {
this.paintText = paintText;
repaint();
}
public void setStyle(Style style) {
this.style = style;
if (style instanceof NameStyle) {
paintText = ((NameStyle) style).getName();
}
repaint();
}
public void setStyle(NameStyle style) {
paintText = style.getName();
setStyle(style.getRealStyle());
}
@Override
public void paint(Graphics g) {
Graphics2D g2d = (Graphics2D) g;
@ -107,11 +123,45 @@ public class CellStylePreviewPane extends JPanel {
Style.paintContent(g2d, paintText, style, width, height, resolution);
Style.paintBorder(g2d, style, width, height);
Style.paintBorder(g2d, style,
width - GraphHelper.getLineStyleSize(style.getBorderRight()) / 2F,
height - GraphHelper.getLineStyleSize(style.getBorderBottom()) / 2F);
}
@Override
public Dimension getMinimumSize() {
return getPreferredSize();
public Dimension 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);
}
}

52
designer-base/src/main/java/com/fr/design/config/DesignerProperties.java

@ -0,0 +1,52 @@
package com.fr.design.config;
import com.fr.general.IOUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils;
import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.util.Properties;
public class DesignerProperties {
private static DesignerProperties holder = null;
private boolean supportLoginEntry = true;
public DesignerProperties() {
String filePath = StableUtils.pathJoin(StableUtils.getInstallHome(), "/config/config.properties");
InputStream is = null;
try {
is = new BufferedInputStream(new FileInputStream(filePath));
Properties ps = new Properties();
ps.load(is);
this.initProperties(ps);
} catch (FileNotFoundException e) {
// ignore
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e, e.getMessage());
} finally {
IOUtils.close(is);
}
}
public static DesignerProperties getInstance() {
if (holder == null) {
holder = new DesignerProperties();
}
return holder;
}
private void initProperties(Properties ps) {
String supportLoginEntry = ps.getProperty("supportLoginEntry");
if (StringUtils.isNotEmpty(supportLoginEntry)) {
this.supportLoginEntry = Boolean.valueOf(supportLoginEntry);
}
}
public boolean isSupportLoginEntry() {
return supportLoginEntry;
}
}

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

@ -1,12 +1,12 @@
package com.fr.design.data.datapane;
import com.fr.base.TableData;
import com.fr.concurrent.NamedThreadFactory;
import com.fr.data.core.DataCoreUtils;
import com.fr.data.core.db.DBUtils;
import com.fr.data.core.db.TableProcedure;
import com.fr.data.core.db.dialect.Dialect;
import com.fr.data.core.db.dialect.DialectFactory;
import com.fr.data.impl.Connection;
import com.fr.data.impl.DBTableData;
import com.fr.data.operator.DataOperator;
import com.fr.design.DesignerEnvManager;
@ -19,7 +19,7 @@ import com.fr.design.data.datapane.preview.PreviewTablePane;
import com.fr.design.data.tabledata.Prepare4DataSourceChange;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.gui.icombobox.FilterableComboBoxModel;
import com.fr.design.gui.icombobox.SearchPreTaskTreeComboBox;
import com.fr.design.gui.icombobox.TableSearchTreeComboBox;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.icombobox.UIComboBoxEditor;
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.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.JOptionPane;
import javax.swing.JPanel;
@ -58,21 +53,20 @@ import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeCellRenderer;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreeCellRenderer;
import javax.swing.tree.TreeNode;
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.FocusEvent;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Enumeration;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.FutureTask;
import java.util.concurrent.CancellationException;
/**
* @author zhou
@ -97,41 +91,12 @@ public class ChoosePane extends BasicBeanPane<DataBaseItems> implements Refresha
/**
* 表名
*/
protected SearchPreTaskTreeComboBox tableNameComboBox;
private static final ExecutorService SERVICE = Executors.newSingleThreadExecutor(new NamedThreadFactory("ChoosePane"));
protected TableSearchTreeComboBox tableNameComboBox;
private SwingWorker populateWorker;
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() {
@Override
public void popupMenuCanceled(PopupMenuEvent e) {
@ -181,7 +146,7 @@ public class ChoosePane extends BasicBeanPane<DataBaseItems> implements Refresha
schemaBox = new StringUIComboBox();
schemaBox.setEditor(new ComboBoxEditor());
tableNameComboBox = new SearchPreTaskTreeComboBox(new JTree(new DefaultMutableTreeNode()), tableNameTreeRenderer, false);
tableNameComboBox = new TableSearchTreeComboBox(this, new JTree(new DefaultMutableTreeNode()), tableNameTreeRenderer);
tableNameComboBox.setEditable(true);
tableNameComboBox.setRenderer(listCellRenderer);
registerDSChangeListener();
@ -198,7 +163,6 @@ public class ChoosePane extends BasicBeanPane<DataBaseItems> implements Refresha
});
schemaBox.addPopupMenuListener(listener);
addFocusListener();
this.tableNameComboBox.addPopupMenuListener(popupMenuListener);
}
protected void addDSBoxListener() {
@ -355,7 +319,7 @@ public class ChoosePane extends BasicBeanPane<DataBaseItems> implements Refresha
GUICoreUtils.setSelectedItemQuietly(tableNameComboBox, -1);
}
protected com.fr.data.impl.Connection getConnection() {
public Connection getConnection() {
String selectedDSName = this.getDSName();
if (StringUtils.isEmpty(selectedDSName)) {
return null; // peter:选中了当前的零长度的节点,直接返回.
@ -455,56 +419,6 @@ public class ChoosePane extends BasicBeanPane<DataBaseItems> implements Refresha
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,22 +472,23 @@ public class ChoosePane extends BasicBeanPane<DataBaseItems> implements Refresha
return tableData;
}
protected String getDSName() {
public String getDSName() {
return this.dsNameComboBox.getSelectedItem();
}
public String getSchema() {
return this.schemaBox.getSelectedItem();
}
protected void failedToFindTable() {
// Do nothing
}
protected String getTableName() {
String tableName = "";
Object obj = this.tableNameComboBox.getSelectedItemObject();
Object obj = this.tableNameComboBox.getSelectedItem();
if (obj == null) {
obj = this.tableNameComboBox.getSelectedItem();
if (obj == null) {
obj = this.tableNameComboBox.getEditor().getItem();
}
obj = this.tableNameComboBox.getEditor().getItem();
}
if (obj instanceof TreePath) {
Object tp = ((ExpandMutableTreeNode) ((TreePath) obj).getLastPathComponent()).getUserObject();

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

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

147
designer-base/src/main/java/com/fr/design/data/datapane/connect/AdvancePane.java

@ -0,0 +1,147 @@
package com.fr.design.data.datapane.connect;
import com.fr.data.impl.JDBCDatabaseConnection;
import com.fr.data.pool.DBCPConnectionPoolAttr;
import com.fr.design.dialog.BasicPane;
import com.fr.design.editor.editor.IntegerEditor;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.stable.StringUtils;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
/**
* @author xiqiu
* @date 2021/11/22
* @description
*/
public class AdvancePane extends BasicPane {
private IntegerEditor DBCP_MAX_ACTIVE = new IntegerEditor();
private UIComboBox DBCP_TESTONBORROW = new UIComboBox(new String[]{Toolkit.i18nText("Fine-Design_Basic_No"), Toolkit.i18nText("Fine-Design_Basic_Yes")});
private IntegerEditor DBCP_MAX_WAIT = new IntegerEditor();
private SpecialUITextField DBCP_VALIDATION_QUERY = new SpecialUITextField();
public AdvancePane() {
DBCP_VALIDATION_QUERY.addFocusListener(new JTextFieldHintListener(DBCP_VALIDATION_QUERY));
;
double p = TableLayout.PREFERRED;
DBCP_VALIDATION_QUERY.setColumns(15);
double[] rowSizeDbcp = {p, p, p, p};
double[] columnDbcp = {p, p};
Component[][] comps = {
{new UILabel(Toolkit.i18nText("Fine-Design_Basic_Dbcp_Max_Active") + ":", SwingConstants.RIGHT), DBCP_MAX_ACTIVE},
{new UILabel(Toolkit.i18nText("Fine-Design_Basic_Dbcp_Validation_Query") + ":", SwingConstants.RIGHT), DBCP_VALIDATION_QUERY},
{new UILabel(Toolkit.i18nText("Fine-Design_Basic_Dbcp_Test_On_Borrow") + ":", SwingConstants.RIGHT), DBCP_TESTONBORROW},
{new UILabel(Toolkit.i18nText("Fine-Design_Basic_Connection_Pool_Max_Wait_Time") + ":", SwingConstants.RIGHT), DBCP_MAX_WAIT}
};
JPanel contextPane = TableLayoutHelper.createGapTableLayoutPane(comps, rowSizeDbcp, columnDbcp, 11, 11);
this.add(contextPane);
this.setPreferredSize(new Dimension(630, 120));
this.setLayout(FRGUIPaneFactory.createLeftZeroVgapNormalHgapLayout());
}
public void populate(JDBCDatabaseConnection jdbcDatabase) {
DBCPConnectionPoolAttr dbcpAttr = jdbcDatabase.getDbcpAttr();
if (dbcpAttr == null) {
dbcpAttr = new DBCPConnectionPoolAttr();
jdbcDatabase.setDbcpAttr(dbcpAttr);
}
this.DBCP_MAX_ACTIVE.setValue(dbcpAttr.getMaxActive());
this.DBCP_MAX_WAIT.setValue(dbcpAttr.getMaxWait());
this.DBCP_VALIDATION_QUERY.setText(dbcpAttr.getValidationQuery());
this.DBCP_TESTONBORROW.setSelectedIndex(dbcpAttr.isTestOnBorrow() ? 1 : 0);
}
public void update(JDBCDatabaseConnection jdbcDatabase) {
DBCPConnectionPoolAttr dbcpAttr = jdbcDatabase.getDbcpAttr();
if (dbcpAttr == null) {
dbcpAttr = new DBCPConnectionPoolAttr();
jdbcDatabase.setDbcpAttr(dbcpAttr);
}
dbcpAttr.setMaxActive(this.DBCP_MAX_ACTIVE.getValue().intValue());
dbcpAttr.setMaxWait(this.DBCP_MAX_WAIT.getValue().intValue());
dbcpAttr.setValidationQuery(this.DBCP_VALIDATION_QUERY.getText());
dbcpAttr.setTestOnBorrow(this.DBCP_TESTONBORROW.getSelectedIndex() == 0 ? false : true);
}
@Override
protected String title4PopupWindow() {
return Toolkit.i18nText("Fine-Design_Basic_Advanced_Setup");
}
private class JTextFieldHintListener implements FocusListener {
private SpecialUITextField textField;
public JTextFieldHintListener(SpecialUITextField jTextField) {
this.textField = jTextField;
}
@Override
public void focusGained(FocusEvent e) {
//获取焦点时,清空提示内容
String temp = textField.getText();
textField.setForeground(Color.BLACK);
textField.setTextOrigin(temp);
}
@Override
public void focusLost(FocusEvent e) {
//失去焦点时,没有输入内容,显示提示内容
String temp = textField.getTextOrigin();
textField.setText(temp);
}
}
private class SpecialUITextField extends UITextField {
@Override
public String getText() {
String text = super.getText();
if (isUseless(text)) {
return StringUtils.EMPTY;
}
return text;
}
@Override
public void setText(String text) {
if (isUseless(text)) {
this.setForeground(Color.GRAY);
super.setText(Toolkit.i18nText("Fine-Design_Dbcp_Default_Query"));
} else {
this.setForeground(Color.BLACK);
super.setText(text);
}
}
public String getTextOrigin() {
return super.getText();
}
public void setTextOrigin(String text) {
super.setText(text);
}
private boolean isUseless(String text) {
return text == null || text.isEmpty() || Toolkit.i18nText("Fine-Design_Dbcp_Default_Query").equals(text);
}
}
}

35
designer-base/src/main/java/com/fr/design/data/datapane/connect/DBCPAttrPane.java

@ -20,6 +20,7 @@ import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Window;
@ -45,13 +46,8 @@ public class DBCPAttrPane extends BasicPane {
private static final int EMPTY_FETCHSIZE = -2;
// carl:DBCP的一些属性
private IntegerEditor DBCP_INITIAL_SIZE = new IntegerEditor();
private IntegerEditor DBCP_MAX_ACTIVE = new IntegerEditor();
private IntegerEditor DBCP_MAX_IDLE = new IntegerEditor();
private IntegerEditor DBCP_MIN_IDLE = new IntegerEditor();
private IntegerEditor DBCP_MAX_WAIT = new IntegerEditor();
private UITextField DBCP_VALIDATION_QUERY = new UITextField();
private UIComboBox DBCP_TESTONBORROW = new UIComboBox(new String[]{Toolkit.i18nText("Fine-Design_Basic_No"), Toolkit.i18nText("Fine-Design_Basic_Yes")});
private UIComboBox DBCP_TESTONRETURN = new UIComboBox(new String[]{Toolkit.i18nText("Fine-Design_Basic_No"), Toolkit.i18nText("Fine-Design_Basic_Yes")});
private UIComboBox DBCP_TESTWHILEIDLE = new UIComboBox(new String[]{Toolkit.i18nText("Fine-Design_Basic_No"), Toolkit.i18nText("Fine-Design_Basic_Yes")});
@ -75,25 +71,19 @@ public class DBCPAttrPane extends BasicPane {
defaultPane = this;
// JPanel northFlowPane
northFlowPane = FRGUIPaneFactory.createTitledBorderPane(Toolkit.i18nText("Fine-Design_Basic_ConnectionPool_Attr"));
northFlowPane.setPreferredSize(new Dimension(630, 320));
northFlowPane = FRGUIPaneFactory.createTopVerticalTitledBorderPane(Toolkit.i18nText("Fine-Design_Basic_ConnectionPool_Attr"));
northFlowPane.setPreferredSize(new Dimension(630, 330));
defaultPane.add(northFlowPane, BorderLayout.NORTH);
DBCP_VALIDATION_QUERY.setColumns(15);
// ContextPane
double f = TableLayout.FILL;
// double p = TableLayout.PREFERRED;
double[] rowSize = {f, f, f, f, f, f, f, f, f, f, f, f};
double[] rowSize = {f, f, f, f, f, f, f};
double[] columnSize = {f, f};
Component[][] comps = {
{new UILabel(Toolkit.i18nText("Fine-Design_Basic_Dbcp_Initial_Size") + ":", SwingConstants.RIGHT), DBCP_INITIAL_SIZE},
{new UILabel(Toolkit.i18nText("Fine-Design_Basic_Dbcp_Max_Active") + ":", SwingConstants.RIGHT), DBCP_MAX_ACTIVE},
{new UILabel(Toolkit.i18nText("Fine-Design_Basic_Dbcp_Max_Idle") + ":", SwingConstants.RIGHT), DBCP_MAX_IDLE},
{new UILabel(Toolkit.i18nText("Fine-Design_Basic_Dbcp_Min_Idle") + ":", SwingConstants.RIGHT), DBCP_MIN_IDLE},
{new UILabel(Toolkit.i18nText("Fine-Design_Basic_Connection_Pool_Max_Wait_Time") + ":", SwingConstants.RIGHT), DBCP_MAX_WAIT},
{new UILabel(Toolkit.i18nText("Fine-Design_Basic_Dbcp_Validation_Query") + ":", SwingConstants.RIGHT), DBCP_VALIDATION_QUERY},
{new UILabel(Toolkit.i18nText("Fine-Design_Basic_Dbcp_Test_On_Borrow") + ":", SwingConstants.RIGHT), DBCP_TESTONBORROW},
{new UILabel(Toolkit.i18nText("Fine-Design_Basic_Dbcp_Test_On_Return") + ":", SwingConstants.RIGHT), DBCP_TESTONRETURN},
{new UILabel(Toolkit.i18nText("Fine-Design_Basic_Dbcp_Test_While_Idle") + ":", SwingConstants.RIGHT), DBCP_TESTWHILEIDLE},
{new UILabel(Toolkit.i18nText("Fine-Design_Basic_Connection_Pool_Evictionruns_millis") + ":", SwingConstants.RIGHT),
@ -102,8 +92,13 @@ public class DBCPAttrPane extends BasicPane {
{new UILabel(Toolkit.i18nText("Fine-Design_Basic_Connection_Pool_Mix_Evictable_Idle_Time_Millis") + ":", SwingConstants.RIGHT),
DBCP_MINEVICTABLEIDLETIMEMILLIS}};
JPanel contextPane = TableLayoutHelper.createGapTableLayoutPane(comps, rowSize, columnSize, 10, 4);
JPanel contextPane = TableLayoutHelper.createGapTableLayoutPane(comps, rowSize, columnSize, 10, 10);
northFlowPane.add(contextPane);
JPanel boxFlowInnerContainer = FRGUIPaneFactory.createBoxFlowInnerContainer_S_Pane(0, 5, 5);
UILabel uiLabel = new UILabel(Toolkit.i18nText("Fine-Design_Dbcp_Warning"));
uiLabel.setForeground(Color.RED);
boxFlowInnerContainer.add(uiLabel);
northFlowPane.add(boxFlowInnerContainer);
}
public void populate(JDBCDatabaseConnection jdbcDatabase) {
@ -113,12 +108,7 @@ public class DBCPAttrPane extends BasicPane {
jdbcDatabase.setDbcpAttr(dbcpAttr);
}
this.DBCP_INITIAL_SIZE.setValue(dbcpAttr.getInitialSize());
this.DBCP_MAX_ACTIVE.setValue(dbcpAttr.getMaxActive());
this.DBCP_MAX_IDLE.setValue(dbcpAttr.getMaxIdle());
this.DBCP_MAX_WAIT.setValue(dbcpAttr.getMaxWait());
this.DBCP_MIN_IDLE.setValue(dbcpAttr.getMinIdle());
this.DBCP_VALIDATION_QUERY.setText(dbcpAttr.getValidationQuery());
this.DBCP_TESTONBORROW.setSelectedIndex(dbcpAttr.isTestOnBorrow() ? 1 : 0);
this.DBCP_TESTONRETURN.setSelectedIndex(dbcpAttr.isTestOnReturn() ? 1 : 0);
this.DBCP_TESTWHILEIDLE.setSelectedIndex(dbcpAttr.isTestWhileIdle() ? 1 : 0);
this.DBCP_MINEVICTABLEIDLETIMEMILLIS.setValue(dbcpAttr.getMinEvictableIdleTimeMillis() / TIME_MULTIPLE);
@ -141,12 +131,7 @@ public class DBCPAttrPane extends BasicPane {
jdbcDatabase.setDbcpAttr(dbcpAttr);
}
dbcpAttr.setInitialSize(this.DBCP_INITIAL_SIZE.getValue().intValue());
dbcpAttr.setMaxActive(this.DBCP_MAX_ACTIVE.getValue().intValue());
dbcpAttr.setMaxIdle(this.DBCP_MAX_IDLE.getValue().intValue());
dbcpAttr.setMaxWait(this.DBCP_MAX_WAIT.getValue().intValue());
dbcpAttr.setMinIdle(this.DBCP_MIN_IDLE.getValue().intValue());
dbcpAttr.setValidationQuery(this.DBCP_VALIDATION_QUERY.getText());
dbcpAttr.setTestOnBorrow(this.DBCP_TESTONBORROW.getSelectedIndex() == 0 ? false : true);
dbcpAttr.setTestOnReturn(this.DBCP_TESTONRETURN.getSelectedIndex() == 0 ? false : true);
dbcpAttr.setTestWhileIdle(this.DBCP_TESTWHILEIDLE.getSelectedIndex() == 0 ? false : true);
dbcpAttr.setMinEvictableIdleTimeMillis(((Number) this.DBCP_MINEVICTABLEIDLETIMEMILLIS.getValue()).intValue() * TIME_MULTIPLE);

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

@ -14,11 +14,11 @@ import com.fr.data.solution.processor.SolutionProcessor;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.ilable.ActionLabel;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.scrollruler.ModLineBorder;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.rpc.ExceptionHandler;
@ -34,6 +34,7 @@ import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.ScrollPaneConstants;
import javax.swing.SwingUtilities;
import javax.swing.SwingWorker;
import javax.swing.UIManager;
@ -60,6 +61,8 @@ import java.util.concurrent.ExecutionException;
* Database Connection pane.
*/
public abstract class DatabaseConnectionPane<E extends com.fr.data.impl.Connection> extends BasicBeanPane<com.fr.data.impl.Connection> {
private static int MAX_MAIN_PANEL_HEIGHT = 430;
private static int MAX_MAIN_PANEL_WIDTH = 675;
private UILabel message;
private UIButton okButton;
@ -305,6 +308,10 @@ public abstract class DatabaseConnectionPane<E extends com.fr.data.impl.Connecti
protected abstract E updateSubDatabaseConnectionBean();
protected JPanel getAdvancePane() {
throw new UnsupportedOperationException();
}
protected void initComponents() {
message = new UILabel();
uiLabel = new UILabel();
@ -330,15 +337,14 @@ public abstract class DatabaseConnectionPane<E extends com.fr.data.impl.Connecti
// Center
mainPanel = mainPanel();
northPane.add(mainPanel, BorderLayout.CENTER);
JPanel advancedPanel = FRGUIPaneFactory.createBorderLayout_L_Pane();
advancedPanel.setBorder(BorderFactory.createTitledBorder(
new ModLineBorder(ModLineBorder.TOP),
Toolkit.i18nText("Fine-Design_Basic_Advanced")
));
JPanel advancedPanel = FRGUIPaneFactory.createTopVerticalTitledBorderPane(Toolkit.i18nText("Fine-Design_Basic_Advanced"));
if (mainPanel instanceof JDBCDefPane) {
ActionLabel actionLabel = new ActionLabel(Toolkit.i18nText("Fine-Design_Basic_Advanced_Setup"));
mainPanel.setPreferredSize(new Dimension(MAX_MAIN_PANEL_WIDTH, 280));
advancedPanel.setPreferredSize(new Dimension(MAX_MAIN_PANEL_WIDTH, 210));
northPane.add(mainPanel, BorderLayout.CENTER);
ActionLabel actionLabel = new ActionLabel(Toolkit.i18nText("Fine-Design_Advanced_More_Settings"));
actionLabel.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
JDialog wDialog = createJDialog();
if (wDialog != null) {
@ -349,10 +355,24 @@ public abstract class DatabaseConnectionPane<E extends com.fr.data.impl.Connecti
JPanel actionLabelPanel = FRGUIPaneFactory.createBorderLayout_S_Pane();
actionLabelPanel.setBorder(BorderFactory.createEmptyBorder(2, 4, 4, 20));
actionLabelPanel.add(actionLabel, BorderLayout.WEST);
JPanel advancePane = getAdvancePane();
if (advancePane != null) {
advancedPanel.add(advancePane);
}
advancedPanel.add(actionLabelPanel);
} else {
//非jdbc配置布局保持不变
advancedPanel.setPreferredSize(new Dimension(MAX_MAIN_PANEL_WIDTH, 60));
if (mainPanel.getPreferredSize().height > MAX_MAIN_PANEL_HEIGHT || mainPanel.getPreferredSize().width > MAX_MAIN_PANEL_WIDTH) {
UIScrollPane jp = new
UIScrollPane(mainPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
jp.setPreferredSize(new Dimension(MAX_MAIN_PANEL_WIDTH, MAX_MAIN_PANEL_HEIGHT));
northPane.add(jp, BorderLayout.CENTER);
} else {
mainPanel.setPreferredSize(new Dimension(MAX_MAIN_PANEL_WIDTH, MAX_MAIN_PANEL_HEIGHT));
northPane.add(mainPanel, BorderLayout.CENTER);
}
// ChartSet
String[] defaultEncode = new String[]{Toolkit.i18nText("Fine-Design_Encode_Auto")};
charSetComboBox = new UIComboBox(ArrayUtils.addAll(defaultEncode, EncodeConstants.ENCODING_ARRAY));
@ -406,6 +426,7 @@ public abstract class DatabaseConnectionPane<E extends com.fr.data.impl.Connecti
public static class JDBC extends DatabaseConnectionPane<JDBCDatabaseConnection> {
private static JDBCDefPane jdbcDefPane = new JDBCDefPane();
private static DBCPAttrPane dbcpAttrPane = new DBCPAttrPane();
private static AdvancePane advancePane = new AdvancePane();
@Override
protected JPanel mainPanel() {
@ -425,15 +446,22 @@ public abstract class DatabaseConnectionPane<E extends com.fr.data.impl.Connecti
protected void populateSubDatabaseConnectionBean(JDBCDatabaseConnection ob) {
jdbcDefPane.populate(ob);
dbcpAttrPane.populate(jdbcDefPane.getJDBCDatabase());
advancePane.populate(jdbcDefPane.getJDBCDatabase());
}
@Override
protected JDBCDatabaseConnection updateSubDatabaseConnectionBean() {
JDBCDatabaseConnection jdbcDatabaseConnection = jdbcDefPane.update();
dbcpAttrPane.update(jdbcDatabaseConnection);
advancePane.update(jdbcDatabaseConnection);
return jdbcDatabaseConnection;
}
@Override
protected JPanel getAdvancePane() {
return advancePane;
}
@Override
protected String title4PopupWindow() {
return "JDBC";

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);
}

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

@ -253,7 +253,11 @@ public class HistoryTemplateListCache implements CallbackEvent {
for (int i = 0; i < vCount; i++) {
JTemplate overTemplate = historyList.get(i);
if (overTemplate.getEditingFILE().exists() && overTemplate.isALLSaved() && overTemplate != editingTemplate) {
boolean replaceWithJVirtualTemplate = overTemplate.getEditingFILE().exists()
&& overTemplate.isALLSaved()
&& overTemplate != editingTemplate
&& overTemplate.checkEnable();
if (replaceWithJVirtualTemplate) {
closeVirtualSelectedReport(overTemplate);
historyList.set(i, new JVirtualTemplate(overTemplate.getEditingFILE()));
}

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

@ -4,7 +4,6 @@ package com.fr.design.file;
import com.fr.base.BaseUtils;
import com.fr.base.GraphHelper;
import com.fr.base.vcs.DesignerMode;
import com.fr.design.base.mode.DesignModeContext;
import com.fr.design.constants.UIConstants;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.gui.imenu.UIMenuItem;
@ -17,6 +16,7 @@ import com.fr.design.utils.DesignUtils;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.design.utils.gui.GUIPaintUtils;
import com.fr.design.worker.WorkerManager;
import com.fr.design.utils.TemplateUtils;
import com.fr.design.worker.save.CallbackSaveWorker;
import com.fr.file.FILE;
import com.fr.general.ComparatorUtils;
@ -269,7 +269,7 @@ public class MutilTempalteTabPane extends JComponent {
private String tempalteShowName(JTemplate<?, ?> template) {
String name = template.getTemplateName();
String name = TemplateUtils.createLockeTemplatedName(template, template.getTemplateName());
if (!template.isSaved() && !name.endsWith(" *")) {
name += " *";
}

46
designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java

@ -12,7 +12,11 @@ import com.fr.design.gui.itree.filetree.TemplateFileTree;
import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.lock.LockInfoUtils;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.DesignerFrameFileDealerPane;
import com.fr.design.lock.LockInfoDialog;
import com.fr.design.mainframe.JTemplate;
import com.fr.file.FILE;
import com.fr.file.FileNodeFILE;
import com.fr.file.filetree.FileNode;
@ -21,12 +25,15 @@ import com.fr.form.fit.web.editpreview.FileLockStateObservable;
import com.fr.general.ComparatorUtils;
import com.fr.general.IOUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.workspace.base.UserInfo;
import com.fr.stable.ArrayUtils;
import com.fr.stable.CoreConstants;
import com.fr.stable.StableUtils;
import com.fr.stable.project.ProjectConstants;
import com.fr.workspace.WorkContext;
import com.fr.report.lock.LockInfoOperator;
import java.util.UUID;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
@ -50,6 +57,8 @@ import java.util.Enumeration;
import java.util.Objects;
import java.util.Observable;
import java.util.Observer;
import org.jetbrains.annotations.Nullable;
import static javax.swing.JOptionPane.WARNING_MESSAGE;
import static javax.swing.JOptionPane.YES_NO_OPTION;
@ -113,6 +122,7 @@ public class TemplateTreePane extends JPanel implements FileOperations {
if (toolBarStateChangeListener != null) {
toolBarStateChangeListener.stateChange();
}
DesignerFrameFileDealerPane.getInstance().refreshRightToolBarBy(reportletsTree.getSelectedFileNode());
}
};
// lx: add mouse listener
@ -216,15 +226,44 @@ public class TemplateTreePane extends JPanel implements FileOperations {
if (node == null) {
return;
}
String reportPath = reportletsTree.getSelectedTemplatePath();
final String selectedFilePath = StableUtils.pathJoin(ProjectConstants.REPORTLETS_NAME, reportPath);
String lock = node.getLock();
if (lock != null && !lock.equals(node.getUserID())) {
boolean showLockInfo = LockInfoUtils.isCompatibleOperator()
|| LockInfoUtils.unableGetLockInfo()
|| WorkContext.getCurrent().get(LockInfoOperator.class).isTplUnLocked(selectedFilePath)
? (lock != null && !lock.equals(node.getUserID()))
: WorkContext.getCurrent().get(LockInfoOperator.class).isTplLocked(selectedFilePath);
if (showLockInfo) {
UserInfo userInfo = WorkContext.getCurrent().get(LockInfoOperator.class).getUserInfo(selectedFilePath);
node.setLock(UUID.randomUUID().toString());
// 对于开发者预览占位锁定 定位到tab中
checkDevelopForBiddenTemplate(selectedFilePath);
LockInfoDialog.show(userInfo);
return;
} else {
node.setLock(null);
}
String reportPath = reportletsTree.getSelectedTemplatePath();
final String selectedFilePath = StableUtils.pathJoin(ProjectConstants.REPORTLETS_NAME, reportPath);
DesignerContext.getDesignerFrame().openTemplate(new FileNodeFILE(new FileNode(selectedFilePath, false)));
}
private void checkDevelopForBiddenTemplate(String selectedFilePath) {
JTemplate<?, ?> template = getOpenedTemplate(selectedFilePath);
if (template != null && template.isForbidden()) {
DesignerContext.getDesignerFrame().openTemplate(new FileNodeFILE(new FileNode(selectedFilePath, false)));
}
}
@Nullable
private JTemplate<?, ?> getOpenedTemplate(String path) {
for (JTemplate<?, ?> template : HistoryTemplateListCache.getInstance().getHistoryList()) {
if (ComparatorUtils.equals(template.getEditingFILE().getPath(), path)) {
return template;
}
}
return null;
}
/**
* 打开文件夹
*/
@ -248,6 +287,7 @@ public class TemplateTreePane extends JPanel implements FileOperations {
// 刷新远程文件夹权限
NodeAuthProcessor.getInstance().refresh();
reportletsTree.refresh();
DesignerFrameFileDealerPane.getInstance().refreshRightToolBarBy(null);
FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Basic_Template_File_Tree_Refresh_Successfully") + "!");
}

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

@ -290,6 +290,11 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula {
initTextPane();
initTipsPane();
initVariableTreeAndDescriptionArea();
refocusInWindow();
}
public void refocusInWindow() {
SwingUtilities.invokeLater(() -> formulaTextArea.requestFocusInWindow());
}
private void initVariableTreeAndDescriptionArea() {

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.event.GlobalNameListener;
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.UIObserverListener;
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);
}
});
}
}
}

14
designer-base/src/main/java/com/fr/design/gui/frpane/TreeSettingPane.java

@ -127,7 +127,7 @@ public class TreeSettingPane extends BasicPane implements DataCreatorUI {
buildBox.setSelectedIndex(1);
TableDataDictionary dictionary = treeEditor.getDictionary();
autoBuildPane.populate(dictionary);
} else if (treeEditor.isLayerBuild()) {
} else if (treeEditor.isFastLayerBuild()) {
buildBox.setSelectedIndex(0);
java.util.List<LayerConfig> layerConfigList = treeEditor.getLayerConfigs();
LayerConfig[] layerConfigs = new LayerConfig[layerConfigList.size()];
@ -156,12 +156,12 @@ public class TreeSettingPane extends BasicPane implements DataCreatorUI {
if (buildBox.getSelectedIndex() == 1) {
TableDataDictionary dictionary = this.autoBuildPane.update();
te.setAutoBuild(true);
te.setLayerBuild(false);
te.setFastLayerBuild(false);
te.setDictionary(dictionary);
te.setNodeOrDict(dictionary);
} else if (buildBox.getSelectedIndex() == 2) {
te.setAutoBuild(false);
te.setLayerBuild(false);
te.setFastLayerBuild(false);
NameObject no = this.controlPane.update();
if (no != null) {
TreeEditor editor = (TreeEditor) no.getObject();
@ -181,7 +181,7 @@ public class TreeSettingPane extends BasicPane implements DataCreatorUI {
} else {
LayerConfig[] configs = (LayerConfig[]) layerDataControlPane.update().getObject();
te.setAutoBuild(false);
te.setLayerBuild(true);
te.setFastLayerBuild(true);
te.setLayerConfigs(Arrays.asList(configs));
}
return te;
@ -215,12 +215,12 @@ public class TreeSettingPane extends BasicPane implements DataCreatorUI {
if (buildBox.getSelectedIndex() == 1) {
TableDataDictionary dictionary = this.autoBuildPane.update();
tcb.setAutoBuild(true);
tcb.setLayerBuild(false);
tcb.setFastLayerBuild(false);
tcb.setDictionary(dictionary);
tcb.setNodeOrDict(dictionary);
} else if (buildBox.getSelectedIndex() == 2) {
tcb.setAutoBuild(false);
tcb.setLayerBuild(false);
tcb.setFastLayerBuild(false);
NameObject no = this.controlPane.update();
if (no != null) {
if (no.getObject() instanceof TreeComboBoxEditor) {
@ -244,7 +244,7 @@ public class TreeSettingPane extends BasicPane implements DataCreatorUI {
}else {
LayerConfig[] configs = (LayerConfig[]) layerDataControlPane.update().getObject();
tcb.setAutoBuild(false);
tcb.setLayerBuild(true);
tcb.setFastLayerBuild(true);
tcb.setLayerConfigs(Arrays.asList(configs));
}
return tcb;

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);
setUI(new UICheckBoxUI());
initListener();
this.markMnemonic=markMnemonic;
this.markMnemonic = markMnemonic;
}
public UICheckBox(String text, Icon icon) {
@ -100,6 +100,10 @@ public class UICheckBox extends JCheckBox implements UIObserver, GlobalNameObser
}
public void removeChangeListener() {
uiObserverListener = null;
}
@Override
public void setGlobalName(String 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 class FRTreeComboBoxUI extends BasicComboBoxUI implements MouseListener{
protected static class FRTreeComboBoxUI extends BasicComboBoxUI implements MouseListener{
private boolean isRollover = false;
public FRTreeComboBoxUI() {
@ -535,7 +535,7 @@ public class FRTreeComboBox extends UIComboBox {
public class FrTreeSearchComboBoxEditor extends UIComboBoxEditor implements DocumentListener {
private volatile boolean setting = false;
private FRTreeComboBox comboBox;
private Object item;
protected Object item;
public FrTreeSearchComboBoxEditor(FRTreeComboBox comboBox) {
super();

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();
}
}
}

217
designer-base/src/main/java/com/fr/design/gui/icombobox/TableSearchTreeComboBox.java

@ -0,0 +1,217 @@
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.Filter;
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 TableSearchTreeComboBox extends FRTreeComboBox {
// 持有父容器,需要实时获取其他组件值
private final ChoosePane parent;
public TableSearchTreeComboBox(ChoosePane parent, JTree tree, TreeCellRenderer renderer) {
super(tree, renderer);
this.parent = parent;
setUI(new TableSearchTreeComboBoxUI());
}
protected UIComboBoxEditor createEditor() {
return new TableSearchComboBoxEditor(this);
}
@Override
protected String pathToString(TreePath path) {
Object obj = ((DefaultMutableTreeNode) path.getLastPathComponent()).getUserObject();
if (obj instanceof TableProcedure) {
return ((TableProcedure) obj).getName();
}
return super.pathToString(path);
}
@Override
public void setSelectedItemString(String _name) {
super.setSelectedItemString(_name);
// 会因为连续两次选中的值一致,导致未触发编辑框联动
this.getEditor().setItem(_name);
}
/**
* 执行模糊搜索
*/
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 static final TableNameFilter EMPTY_FILTER = new TableNameFilter() {
public boolean accept(TableProcedure procedure) {
return true;
}
};
/**
* 表名模糊搜索实现
*/
private static class TableNameFilter implements Filter<TableProcedure> {
private String searchFilter;
public TableNameFilter() {
}
public TableNameFilter(String searchFilter) {
this.searchFilter = searchFilter.toLowerCase().trim();
}
// 表名匹配
@Override
public boolean accept(TableProcedure procedure) {
return procedure.getName().toLowerCase().contains(searchFilter);
}
}
/**
* 重写FRTreeComboBoxUI实现点击下拉时触发模糊搜索
*/
private class TableSearchTreeComboBoxUI extends FRTreeComboBoxUI {
@Override
public void mouseClicked(MouseEvent e) {
searchExecute();
}
}
/**
* 重写输入框编辑器实现输入框模糊搜索逻辑
*/
private class TableSearchComboBoxEditor extends FrTreeSearchComboBoxEditor {
public TableSearchComboBoxEditor(FRTreeComboBox comboBox) {
super(comboBox);
}
@Override
protected void changeHandler() {
if (isSetting()) {
return;
}
setPopupVisible(true);
this.item = textField.getText();
searchExecute();
}
}
}

7
designer-base/src/main/java/com/fr/design/gui/itextfield/UIAutoCompletionField.java

@ -256,10 +256,9 @@ public class UIAutoCompletionField extends UITextField implements DocumentListen
*
*/
public void setText(String t) {
if (this.isOpen == true) {
if (!UIAutoCompletionField.this.isShowing()) {
return;
}
boolean unavailable = !this.isEnabled() && !this.isEditable();
if (unavailable) {
return;
}
try {
Document doc = getDocument();

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

@ -17,14 +17,21 @@ import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.style.color.NewColorSelectBox;
import com.fr.general.IOUtils;
import com.fr.design.utils.gui.AdjustWorkBookDefaultStyleUtils;
import com.fr.stable.Constants;
import com.fr.stable.CoreConstants;
import javax.swing.*;
import javax.swing.Icon;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.*;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
@ -38,7 +45,6 @@ public class BorderPane extends AbstractBasicStylePane implements GlobalNameObse
private static final String[] BORDERARRAY = {"currentLineCombo", "currentLineColorPane", "outerToggleButton", "topToggleButton",
"leftToggleButton", "bottomToggleButton", "rightToggleButton", "innerToggleButton", "horizontalToggleButton", "verticalToggleButton"};
private static final Set<String> BORDER_SET = new HashSet<>(Arrays.asList(BORDERARRAY));
private boolean insideMode = false;
private UIToggleButton topToggleButton;
private UIToggleButton horizontalToggleButton;
@ -50,11 +56,8 @@ public class BorderPane extends AbstractBasicStylePane implements GlobalNameObse
private UIToggleButton innerToggleButton;
private UIToggleButton outerToggleButton;
private LineComboBox currentLineCombo;
private NewColorSelectBox currentLineColorPane;
private JPanel panel;
private JPanel borderPanel;
private JPanel backgroundPanel;
protected LineComboBox currentLineCombo;
protected NewColorSelectBox currentLineColorPane;
private BackgroundPane backgroundPane;
private GlobalNameListener globalNameListener = null;
@ -81,18 +84,18 @@ public class BorderPane extends AbstractBasicStylePane implements GlobalNameObse
new Component[]{null, null},
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Color") + " ", SwingConstants.LEFT), currentLineColorPane},
new Component[]{null, null},
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Out_Border") + " ", SwingConstants.LEFT), outerToggleButton = new UIToggleButton(new Icon[]{BaseUtils.readIcon("com/fr/design/images/m_format/out.png"), BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/out_white.png")}, false)},
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Out_Border") + " ", SwingConstants.LEFT), outerToggleButton = new UIToggleButton(new Icon[]{IOUtils.readIcon("com/fr/design/images/m_format/out.png"), IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/out_white.png")}, false)},
new Component[]{null, externalPane},
new Component[]{null, null},
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_In_Border") + " ", SwingConstants.LEFT), innerToggleButton = new UIToggleButton(new Icon[]{BaseUtils.readIcon("com/fr/design/images/m_format/in.png"), BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/in_white.png")}, false)},
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_In_Border") + " ", SwingConstants.LEFT), innerToggleButton = new UIToggleButton(new Icon[]{IOUtils.readIcon("com/fr/design/images/m_format/in.png"), IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/in_white.png")}, false)},
new Component[]{null, insidePane},
new Component[]{null, null}
};
double[] rowSize = {p, p, p, p, p, p, p, p, p, p, p};
double[] columnSize = {p, f};
int[][] rowCount = {{1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}};
panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_SMALL, LayoutConstants.VGAP_MEDIUM);
borderPanel = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Border"), 280, 24, panel);
JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_SMALL, LayoutConstants.VGAP_MEDIUM);
JPanel borderPanel = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Border"), 280, 24, panel);
this.add(borderPanel, BorderLayout.NORTH);
UILabel backgroundFillLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Background_Fill"));
@ -102,7 +105,7 @@ public class BorderPane extends AbstractBasicStylePane implements GlobalNameObse
JPanel backgroundContainPane = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{backgroundFillLabel, backgroundPane}},
TableLayoutHelper.FILL_LASTCOLUMN, LayoutConstants.VGAP_SMALL, LayoutConstants.VGAP_MEDIUM);
backgroundPanel = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background"), 280, 24, backgroundContainPane);
JPanel backgroundPanel = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background"), 280, 24, backgroundContainPane);
this.add(backgroundPanel, BorderLayout.CENTER);
initAllNames();
outerToggleButton.addChangeListener(outerToggleButtonChangeListener);
@ -130,12 +133,12 @@ public class BorderPane extends AbstractBasicStylePane implements GlobalNameObse
};
private void initButtonsWithIcon() {
topToggleButton = new UIToggleButton(new Icon[]{BaseUtils.readIcon("/com/fr/base/images/dialog/border/top.png"), BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/top_white.png")}, false);
leftToggleButton = new UIToggleButton(new Icon[]{BaseUtils.readIcon("/com/fr/base/images/dialog/border/left.png"), BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/left_white.png")}, false);
bottomToggleButton = new UIToggleButton(new Icon[]{BaseUtils.readIcon("/com/fr/base/images/dialog/border/bottom.png"), BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/bottom_white.png")}, false);
rightToggleButton = new UIToggleButton(new Icon[]{BaseUtils.readIcon("/com/fr/base/images/dialog/border/right.png"), BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/right_white.png")}, false);
horizontalToggleButton = new UIToggleButton(new Icon[]{BaseUtils.readIcon("/com/fr/base/images/dialog/border/horizontal.png"), BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/horizontal_white.png")}, false);
verticalToggleButton = new UIToggleButton(new Icon[]{BaseUtils.readIcon("/com/fr/base/images/dialog/border/vertical.png"), BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/vertical_white.png")}, false);
topToggleButton = new UIToggleButton(new Icon[]{IOUtils.readIcon("/com/fr/base/images/dialog/border/top.png"), IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/top_white.png")}, false);
leftToggleButton = new UIToggleButton(new Icon[]{IOUtils.readIcon("/com/fr/base/images/dialog/border/left.png"), IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/left_white.png")}, false);
bottomToggleButton = new UIToggleButton(new Icon[]{IOUtils.readIcon("/com/fr/base/images/dialog/border/bottom.png"), IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/bottom_white.png")}, false);
rightToggleButton = new UIToggleButton(new Icon[]{IOUtils.readIcon("/com/fr/base/images/dialog/border/right.png"), IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/right_white.png")}, false);
horizontalToggleButton = new UIToggleButton(new Icon[]{IOUtils.readIcon("/com/fr/base/images/dialog/border/horizontal.png"), IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/horizontal_white.png")}, false);
verticalToggleButton = new UIToggleButton(new Icon[]{IOUtils.readIcon("/com/fr/base/images/dialog/border/vertical.png"), IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/vertical_white.png")}, false);
this.currentLineCombo = new LineComboBox(CoreConstants.UNDERLINE_STYLE_ARRAY);
this.currentLineColorPane = new NewColorSelectBox(100);
}
@ -174,15 +177,15 @@ public class BorderPane extends AbstractBasicStylePane implements GlobalNameObse
cellBorderStyle.setRightStyle(style.getBorderRight());
cellBorderStyle.setRightColor(style.getBorderRightColor());
this.backgroundPane.populateBean(style.getBackground());
this.populateBean(cellBorderStyle, false, style.getBorderTop(), style.getBorderTopColor());
this.populateBean(cellBorderStyle, false);
}
public void populateBean(CellBorderStyle cellBorderStyle, boolean insideMode, int currentStyle, Color currentColor) {
this.insideMode = insideMode;
public void populateBean(CellBorderStyle cellBorderStyle, boolean insideMode) {
populateBean(cellBorderStyle, insideMode, true);
}
this.currentLineCombo.setSelectedLineStyle(cellBorderStyle.getTopStyle() == Constants.LINE_NONE ? Constants.LINE_THIN : cellBorderStyle.getTopStyle());
this.currentLineColorPane.setSelectObject(cellBorderStyle.getTopColor());
public void populateBean(CellBorderStyle cellBorderStyle, boolean insideMode, boolean onlyInspectTop) {
this.topToggleButton.setSelected(cellBorderStyle.getTopStyle() != Constants.LINE_NONE);
this.bottomToggleButton.setSelected(cellBorderStyle.getBottomStyle() != Constants.LINE_NONE);
@ -195,16 +198,49 @@ public class BorderPane extends AbstractBasicStylePane implements GlobalNameObse
this.innerToggleButton.setSelected(cellBorderStyle.getInnerBorder() != Constants.LINE_NONE);
this.outerToggleButton.setSelected(cellBorderStyle.getOuterBorderStyle() != Constants.LINE_NONE);
this.innerToggleButton.setEnabled(this.insideMode);
this.horizontalToggleButton.setEnabled(this.insideMode);
this.verticalToggleButton.setEnabled(this.insideMode);
this.innerToggleButton.setEnabled(insideMode);
this.horizontalToggleButton.setEnabled(insideMode);
this.verticalToggleButton.setEnabled(insideMode);
populateLineStyleAndColor(cellBorderStyle, onlyInspectTop);
}
public void populateLineStyleAndColor(CellBorderStyle cellBorderStyle, boolean onlyInspectTop) {
if (cellBorderStyle.getTopStyle() != Constants.LINE_NONE) {
this.currentLineCombo.setSelectedLineStyle(cellBorderStyle.getTopStyle());
this.currentLineColorPane.setSelectObject(cellBorderStyle.getTopColor());
} else if (!onlyInspectTop) {
if (cellBorderStyle.getBottomStyle() != Constants.LINE_NONE) {
this.currentLineCombo.setSelectedLineStyle(cellBorderStyle.getBottomStyle());
this.currentLineColorPane.setSelectObject(cellBorderStyle.getBottomColor());
} else if (cellBorderStyle.getLeftStyle() != Constants.LINE_NONE) {
this.currentLineCombo.setSelectedLineStyle(cellBorderStyle.getLeftStyle());
this.currentLineColorPane.setSelectObject(cellBorderStyle.getLeftColor());
} else if (cellBorderStyle.getRightStyle() != Constants.LINE_NONE) {
this.currentLineCombo.setSelectedLineStyle(cellBorderStyle.getRightStyle());
this.currentLineColorPane.setSelectObject(cellBorderStyle.getRightColor());
} else if (cellBorderStyle.getVerticalStyle() != Constants.LINE_NONE) {
this.currentLineCombo.setSelectedLineStyle(cellBorderStyle.getVerticalStyle());
this.currentLineColorPane.setSelectObject(cellBorderStyle.getVerticalColor());
} else if (cellBorderStyle.getHorizontalStyle() != Constants.LINE_NONE) {
this.currentLineCombo.setSelectedLineStyle(cellBorderStyle.getHorizontalStyle());
this.currentLineColorPane.setSelectObject(cellBorderStyle.getHorizontalColor());
} else {
this.currentLineCombo.setSelectedLineStyle(Constants.LINE_NONE);
this.currentLineColorPane.setSelectObject(Color.BLACK);
}
}
if (this.currentLineCombo.getSelectedLineStyle() == Constants.LINE_NONE) {
this.currentLineCombo.setSelectedLineStyle(Constants.LINE_THIN);
}
}
@Override
public Style update(Style style) {
if (style == null) {
style = Style.DEFAULT_STYLE;
style = AdjustWorkBookDefaultStyleUtils.adjustCellElement(Style.DEFAULT_STYLE);
}
if (backgroundPane.currentPane.isBackgroundChange()) {
@ -213,7 +249,7 @@ public class BorderPane extends AbstractBasicStylePane implements GlobalNameObse
if (BORDER_SET.contains(globalNameListener.getGlobalName())) {
CellBorderStyle cellBorderStyle = this.update();
style = style.deriveBorder(cellBorderStyle.getTopStyle(), cellBorderStyle.getTopColor(), cellBorderStyle.getBottomStyle(), cellBorderStyle.getBottomColor(),
cellBorderStyle.getLeftStyle(), cellBorderStyle.getLeftColor(), cellBorderStyle.getRightStyle(), cellBorderStyle.getRightColor());
cellBorderStyle.getLeftStyle(), cellBorderStyle.getLeftColor(), cellBorderStyle.getRightStyle(), cellBorderStyle.getRightColor());
}
return style;
@ -253,16 +289,8 @@ public class BorderPane extends AbstractBasicStylePane implements GlobalNameObse
}
cellBorderStyle.setHorizontalStyle(horizontalToggleButton.isSelected() ? lineStyle : Constants.LINE_NONE);
if (leftToggleButton.isSelected() && bottomToggleButton.isSelected() && rightToggleButton.isSelected() && topToggleButton.isSelected()) {
outerToggleButton.setSelected(true);
} else {
outerToggleButton.setSelected(false);
}
if (verticalToggleButton.isSelected() && horizontalToggleButton.isSelected()) {
innerToggleButton.setSelected(true);
} else {
innerToggleButton.setSelected(false);
}
outerToggleButton.setSelected(leftToggleButton.isSelected() && bottomToggleButton.isSelected() && rightToggleButton.isSelected() && topToggleButton.isSelected());
innerToggleButton.setSelected(verticalToggleButton.isSelected() && horizontalToggleButton.isSelected());
return cellBorderStyle;
}

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.FormatContents;
import com.fr.design.border.UIRoundedBorder;
import com.fr.design.constants.LayoutConstants;
import com.fr.design.constants.UIConstants;
import com.fr.design.event.GlobalNameListener;
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.ilable.UILabel;
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.stable.StringUtils;
import javax.swing.BorderFactory;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import javax.swing.UIManager;
import javax.swing.border.Border;
import javax.swing.border.TitledBorder;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
@ -43,7 +39,6 @@ import java.awt.event.ItemListener;
import java.math.RoundingMode;
import java.text.Format;
import java.text.SimpleDateFormat;
import java.util.Arrays;
/**
* @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 Format format;
private UIComboBox typeComboBox;
private TextFontComboBox textField;
private UILabel sampleLabel;
private JPanel contentPane;
private JPanel txtCenterPane;
private JPanel centerPane;
private JPanel optionPane;
private UICheckBox roundingBox;
private JPanel formatFontPane;
protected UIComboBox typeComboBox;
protected TextFontComboBox<String> textField;
protected UICheckBox roundingBox;
protected UILabel previewLabel;
private boolean isRightFormat;
private boolean isDate = false;
private GlobalNameListener globalNameListener = null;
/**
* Constructor.
*/
public TextFormatPane() {
this.initComponents(TYPES);
}
protected UIComboBox getTypeComboBox() {
return typeComboBox;
initFormatTypesComboBox();
initTextFontComboBox4GeneralFormats();
initRoundingCheckBox4PercentFormat();
initPreviewLabel4GeneralFormat();
initLayout();
setTextFieldVisible(false);
setRoundingBoxVisible(false);
setPreviewLabelVisible(false);
}
protected void initComponents(Integer[] types) {
this.setLayout(new BorderLayout(0, 4));
initSampleLabel();
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);
private void initFormatTypesComboBox() {
typeComboBox = new UIComboBox(TextFormatPane.TYPES);
typeComboBox.setRenderer(createComBoxRender());
typeComboBox.addItemListener(itemListener);
typeComboBox.setGlobalName("typeComboBox");
contentPane.add(sampleLabel, BorderLayout.NORTH);
typeComboBox.setPreferredSize(new Dimension(155,20));
}
txtCenterPane = new JPanel(new BorderLayout());
textField = new TextFontComboBox();
private void initTextFontComboBox4GeneralFormats() {
textField = new TextFontComboBox<>();
textField.addItemListener(textFieldItemListener);
textField.setEditable(true);
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());
option.add(new UILabel(Toolkit.i18nText("Fine-Design_Report_Base_Option"), SwingConstants.LEFT), BorderLayout.WEST);
private void initRoundingCheckBox4PercentFormat() {
roundingBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Report_Base_Option_Half_Up"));
roundingBox.setBorder(BorderFactory.createEmptyBorder(0, 30, 0, 0));
roundingBox.addItemListener(new ItemListener() {
@ -139,54 +110,13 @@ public class TextFormatPane extends AbstractBasicStylePane implements GlobalName
}
});
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);
String title = Toolkit.i18nText("Fine-Design_Report_Base_StyleFormat_Sample");
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
public void paint(Graphics g) {
@ -198,12 +128,65 @@ public class TextFormatPane extends AbstractBasicStylePane implements GlobalName
g.setColor(UIConstants.LINE_COLOR);
FontMetrics cellFM = g.getFontMetrics();
int textWidth = cellFM.stringWidth(getText());
GraphHelper.drawString(g, getText(), (width - textWidth) / 2, 26);
GraphHelper.drawString(g, getText(), (width - textWidth) / 2F, 26);
g.setColor(original);
}
};
sampleLabel.setHorizontalAlignment(UILabel.CENTER);
sampleLabel.setBorder(border);
previewLabel.setHorizontalAlignment(UILabel.CENTER);
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
*/
public void populateBean(Format format) {
this.format = format;
if (format == null) {
this.typeComboBox.setSelectedIndex(FormatContents.NULL);
} else {
@ -325,17 +306,17 @@ public class TextFormatPane extends AbstractBasicStylePane implements GlobalName
* Refresh preview label.
*/
private void refreshPreviewLabel() {
this.sampleLabel.setText(FormatField.getInstance().getFormatValue());
this.sampleLabel.setForeground(UIManager.getColor("Label.foreground"));
this.previewLabel.setText(FormatField.getInstance().getFormatValue());
this.previewLabel.setForeground(UIManager.getColor("Label.foreground"));
try {
isRightFormat = true;
if (StringUtils.isEmpty(String.valueOf(textField.getSelectedItem()))) {
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) {
this.sampleLabel.setForeground(Color.red);
this.sampleLabel.setText(e.getMessage());
this.previewLabel.setForeground(Color.red);
this.previewLabel.setText(e.getMessage());
isRightFormat = false;
}
}
@ -354,28 +335,16 @@ public class TextFormatPane extends AbstractBasicStylePane implements GlobalName
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
int contents = getFormatContents();
String[] items = FormatField.getInstance().getFormatArray(contents, false);
CardLayout cardLayout = (CardLayout) centerPane.getLayout();
if (isTextOrNull()) {
centerPane.setPreferredSize(new Dimension(0, 0));
cardLayout.show(centerPane, "hide");
} else {
if (!isTextOrNull()) {
textField.removeAllItems();
String[] items = FormatField.getInstance().getFormatArray(contents, false);
textField.setItemArray(items);
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
*/
public Style update(Style style) {
if (ComparatorUtils.equals(globalNameListener.getGlobalName(), "textField")
|| ComparatorUtils.equals(globalNameListener.getGlobalName(), "typeComboBox")
|| ComparatorUtils.equals(globalNameListener.getGlobalName(), "roundingBox")) {
return style.deriveFormat(this.update());
return updateByGlobalNamedSetting(style);
}
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;
}

121
designer-base/src/main/java/com/fr/design/lock/LockInfoDialog.java

@ -0,0 +1,121 @@
package com.fr.design.lock;
import com.fr.design.file.TemplateTreePane;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.DesignerFrameFileDealerPane;
import com.fr.design.utils.TemplateUtils;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.file.FileNodeFILE;
import com.fr.file.filetree.FileNode;
import com.fr.general.IOUtils;
import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils;
import com.fr.stable.project.ProjectConstants;
import com.fr.workspace.base.UserInfo;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import javax.swing.BorderFactory;
import javax.swing.JDialog;
import javax.swing.JPanel;
/**
* @author hades
* @version 11.0
* Created by hades on 2021/12/2
*/
public class LockInfoDialog extends JDialog {
private static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm");
public LockInfoDialog(UserInfo userInfo) {
super(DesignerContext.getDesignerFrame());
JPanel panel = new JPanel(new BorderLayout());
panel.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 0));
panel.add(createContentPane(userInfo), BorderLayout.CENTER);
panel.add(createControlPane(), BorderLayout.SOUTH);
this.getContentPane().add(panel);
this.setTitle(Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Title_Hint"));
this.setSize(400, 160);
this.setResizable(false);
this.setModal(true);
GUICoreUtils.centerWindow(this);
this.setVisible(true);
}
private JPanel createContentPane(UserInfo userInfo) {
JPanel contentPanel = new JPanel(new BorderLayout());
contentPanel.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0));
JPanel messagePane = new JPanel(new BorderLayout(13, 0));
UILabel iconLabel = new UILabel(IOUtils.readIcon("/com/fr/design/images/warnings/warning32.png"));
iconLabel.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0));
messagePane.add(iconLabel, BorderLayout.WEST);
UILabel tipLabel = new UILabel(Toolkit.i18nText("Fine-Design_Template_Lock_And_SaveAs_Tip"));
tipLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
messagePane.add(tipLabel, BorderLayout.CENTER);
contentPanel.add(messagePane, BorderLayout.NORTH);
JPanel detailInfoPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_S_Pane();
detailInfoPane.setBorder(BorderFactory.createEmptyBorder(0, 45, 0,0));
if (userInfo != null && StringUtils.isNotEmpty(userInfo.getUserName())) {
UILabel label = createLabel(Toolkit.i18nText("Fine-Design_Template_Lock_Holder", userInfo.getUserName()));
label .setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
detailInfoPane.add(label);
}
if (userInfo != null && StringUtils.isNotEmpty(userInfo.getIp())) {
detailInfoPane.add(createLabel(Toolkit.i18nText("Fine-Design_Template_Lock_Holder_Ip", userInfo.getIp()) ));
}
detailInfoPane.add(createLabel(Toolkit.i18nText("Fine-Design_Template_Lock_Get_Time", FORMATTER.format(LocalDateTime.now()))));
contentPanel.add(detailInfoPane, BorderLayout.CENTER);
return contentPanel;
}
private UILabel createLabel(String text) {
UILabel label = new UILabel(text);
label.setForeground(Color.GRAY);
label.setBorder(BorderFactory.createEmptyBorder(8, 0, 0, 0));
return label;
}
private JPanel createControlPane() {
JPanel controlPane = new JPanel(new FlowLayout(FlowLayout.RIGHT, 10, 5));
controlPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0,5));
UIButton saveAsButton = new UIButton(Toolkit.i18nText("Fine_Design_Template_Lock_Save_As"));
UIButton cancelButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Button_Cancel"));
saveAsButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
dispose();
FileNode node = TemplateTreePane.getInstance().getFileNode();
if (node == null) {
return;
}
final String selectedFilePath = StableUtils.pathJoin(ProjectConstants.REPORTLETS_NAME, TemplateTreePane.getInstance().getFilePath());
TemplateUtils.createAndOpenTemplate(Toolkit.i18nText("Fine_Design_Template_Lock_Copy"), new FileNodeFILE(new FileNode(selectedFilePath, false)), true);
}
});
cancelButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
dispose();
}
});
controlPane.add(saveAsButton);
controlPane.add(cancelButton);
return controlPane;
}
public static void show(UserInfo userInfo) {
DesignerFrameFileDealerPane.getInstance().refreshRightToolBarBy(TemplateTreePane.getInstance().getFileNode());
new LockInfoDialog(userInfo);
}
}

23
designer-base/src/main/java/com/fr/design/lock/LockInfoUtils.java

@ -0,0 +1,23 @@
package com.fr.design.lock;
import com.fr.report.lock.DefaultLockInfoOperator;
import com.fr.report.lock.LockInfoOperator;
import com.fr.start.server.FineEmbedServer;
import com.fr.workspace.WorkContext;
/**
* @author hades
* @version 11.0
* Created by hades on 2021/12/8
*/
public class LockInfoUtils {
public static boolean isCompatibleOperator() {
LockInfoOperator lockInfoOperator = WorkContext.getCurrent().get(LockInfoOperator.class);
return lockInfoOperator instanceof DefaultLockInfoOperator;
}
public static boolean unableGetLockInfo() {
return WorkContext.getCurrent().isLocal() && !FineEmbedServer.isRunning();
}
}

11
designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java

@ -35,8 +35,11 @@ import com.fr.design.menu.ShortCut;
import com.fr.design.os.impl.MacOsAddListenerAction;
import com.fr.design.os.impl.SupportOSImpl;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.design.utils.TemplateUtils;
import com.fr.design.lock.LockInfoDialog;
import com.fr.event.EventDispatcher;
import com.fr.exception.DecryptTemplateException;
import com.fr.exception.TplLockedException;
import com.fr.exit.DesignerExiter;
import com.fr.file.FILE;
import com.fr.file.FILEFactory;
@ -57,6 +60,7 @@ import com.fr.workspace.WorkContext;
import com.fr.workspace.Workspace;
import com.fr.workspace.connect.WorkspaceConnectionInfo;
import java.util.UUID;
import javax.swing.Icon;
import javax.swing.JComponent;
import javax.swing.JFrame;
@ -678,7 +682,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
if (!editingTemplate.getEditingFILE().exists()) {
path = FILEFactory.MEM_PREFIX + path;
} else if (path.startsWith(ProjectConstants.REPORTLETS_NAME)) {
path = workspace.getPath() + File.separator + path;
path = workspace.getPath() + File.separator + TemplateUtils.createLockeTemplatedName(editingTemplate, path);
}
defaultTitleSB.append(" ").append(path);
}
@ -962,6 +966,11 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
}
} catch (Throwable t) {
FineLoggerFactory.getLogger().error(t.getMessage(), t);
if (t.getCause() instanceof TplLockedException) {
TemplateTreePane.getInstance().getFileNode().setLock(UUID.randomUUID().toString());
LockInfoDialog.show(null);
return;
}
addAndActivateJTemplate();
}

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

@ -43,6 +43,7 @@ import com.fr.file.FileNodeFILE;
import com.fr.file.filetree.FileNode;
import com.fr.general.ComparatorUtils;
import com.fr.general.GeneralContext;
import com.fr.general.IOUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.plugin.context.PluginContext;
import com.fr.plugin.injectable.PluginModule;
@ -56,6 +57,7 @@ import com.fr.stable.project.ProjectConstants;
import com.fr.third.org.apache.commons.io.FilenameUtils;
import com.fr.workspace.WorkContext;
import com.fr.report.lock.LockInfoOperator;
import javax.swing.BorderFactory;
import javax.swing.JDialog;
import javax.swing.JOptionPane;
@ -127,6 +129,8 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
private UIToolbar toolBar;
private UIToolbar rightToolBar;
private NewFolderAction newFolderAction = new NewFolderAction();
private RefreshTreeAction refreshTreeAction = new RefreshTreeAction();
@ -148,7 +152,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
toolBar.setBorderPainted(true);
JPanel tooBarPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
JPanel parent = new JPanel(new BorderLayout());
parent.add(toolBar, BorderLayout.CENTER);
parent.add(createUpToolBarPane(), BorderLayout.CENTER);
parent.setBorder(BorderFactory.createEmptyBorder(3, 0, 4, 0));
tooBarPane.add(parent, BorderLayout.CENTER);
tooBarPane.add(new UIMenuHighLight(), BorderLayout.SOUTH);
@ -186,6 +190,56 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
selectedOperation.refresh();
}
private JPanel createUpToolBarPane() {
JPanel panel = new JPanel(new BorderLayout());
panel.add(toolBar, BorderLayout.CENTER);
if (WorkContext.getCurrent().isRoot()) {
rightToolBar = new UIToolbar(FlowLayout.RIGHT);
rightToolBar.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, UIConstants.TOOLBAR_BORDER_COLOR));
rightToolBar.setBorderPainted(true);
UILabel tipLabel = new UILabel(Toolkit.i18nText("Fine_Design_Template_Lock_Status"));
tipLabel.setForeground(Color.GRAY);
rightToolBar.add(tipLabel);
UIButton button = new UIButton(IOUtils.readIcon("/com/fr/design/images/toolbarbtn/lock.png"));
button.setRolloverIcon(IOUtils.readIcon("/com/fr/design/images/toolbarbtn/unlock.png"));
button.setBorderPainted(false);
button.setContentAreaFilled(false);
button.set4ToolbarButton();
button.setToolTipText(Toolkit.i18nText("Fine_Design_Template_Unlock_Tip"));
button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
int option = FineJOptionPane.showOptionDialog(DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine_Design_Template_UnLock_Tip"),
Toolkit.i18nText("Fine-Design_Basic_Alert"),
JOptionPane.YES_NO_OPTION,
JOptionPane.WARNING_MESSAGE,
IOUtils.readIcon("/com/fr/design/images/warnings/warning32.png"),
new Object[] {Toolkit.i18nText("Fine_Design_Template_UnLock_I_Known"), Toolkit.i18nText("Fine-Design_Basic_Button_Cancel")}, null);
if (option == JOptionPane.YES_OPTION) {
String path = StableUtils.pathJoin(ProjectConstants.REPORTLETS_NAME, TemplateTreePane.getInstance().getTemplateFileTree().getSelectedTemplatePath());
boolean success = WorkContext.getCurrent().get(LockInfoOperator.class).unLockTpl(path);
if (success) {
FileNode fileNode = TemplateTreePane.getInstance().getFileNode();
refreshRightToolBarBy(fileNode);
} 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);
}
TemplateTreePane.getInstance().refresh();
}
}
});
rightToolBar.add(button);
refreshRightToolBarBy(TemplateTreePane.getInstance().getFileNode());
panel.add(rightToolBar, BorderLayout.EAST);
}
return panel;
}
public final void setCurrentEditingTemplate(JTemplate<?, ?> jt) {
DesignModelAdapter.setCurrentModelAdapter(jt.getModel());
@ -545,6 +599,19 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
}
}
public void refreshRightToolBarBy(FileNode fileNode) {
if (rightToolBar != null) {
boolean locked = fileNode != null
&& StringUtils.isNotEmpty(fileNode.getLock())
&& !ComparatorUtils.equals(fileNode.getLock(), fileNode.getUserID());
boolean visible = locked
&& WorkContext.getCurrent().isRoot()
&& WorkContext.getCurrent().get(LockInfoOperator.class).isUnLockable()
&& !WorkContext.getCurrent().get(LockInfoOperator.class).isTplUnLocked(fileNode.getEnvPath());
rightToolBar.setVisible(visible);
}
}
/**
* 重命名对话框
* 支持快捷键EnterESC

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

12
designer-base/src/main/java/com/fr/design/mainframe/DesktopCardPane.java

@ -32,12 +32,14 @@ public class DesktopCardPane extends BasicPane implements TargetModifiedListener
private static final int TRANSPARENT_LAYER = 1;
private static final int LOADING_LAYER = 2;
private static final int FAILED_LAYER = 3;
private static final int FORBIDDEN_LAYER = 4;
private static final long serialVersionUID = 1L;
private JTemplate<?, ?> component;
private TransparentPane transparentPane = new TransparentPane();
private JPanel loadingPane = LoadingUtils.createLoadingPane();
private OpenFailedPane failedPane = new OpenFailedPane();
private ForbiddenPane forbiddenPane = new ForbiddenPane();
Map<Component, Boolean> backUpToolbarComponentState = new HashMap<>();
@ -54,6 +56,7 @@ public class DesktopCardPane extends BasicPane implements TargetModifiedListener
setLayout(new BorderLayout());
layeredPane.add(transparentPane, TRANSPARENT_LAYER);
layeredPane.add(failedPane, FAILED_LAYER);
layeredPane.add(forbiddenPane, FORBIDDEN_LAYER);
add(layeredPane, BorderLayout.CENTER);
}
@ -95,6 +98,8 @@ public class DesktopCardPane extends BasicPane implements TargetModifiedListener
showOpenStatus();
} else if (jt.isOpenFailed()) {
showOpenFailedCover(jt.getTemplateOpenFailedTip());
} else if (jt.isForbidden()) {
showForbiddenStatus();
} else {
hideCover();
}
@ -140,6 +145,13 @@ public class DesktopCardPane extends BasicPane implements TargetModifiedListener
}
}
public void showForbiddenStatus() {
component.setVisible(false);
layeredPane.moveToFront(forbiddenPane);
forbidToolBar();
EastRegionContainerPane.getInstance().updateAllPropertyPane();
}
public void hideCover() {
recoverToolBar();
transparentPane.stop();

189
designer-base/src/main/java/com/fr/design/mainframe/ForbiddenPane.java

@ -0,0 +1,189 @@
package com.fr.design.mainframe;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.guide.base.GuideView;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.IOUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.workspace.WorkContext;
import com.fr.report.lock.LockInfoOperator;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.LayoutManager;
import java.awt.RenderingHints;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.SwingWorker;
/**
* @author hades
* @version 11.0
* Created by hades on 2021/12/6
*/
public class ForbiddenPane extends JPanel {
private static final ImageIcon LOCK_ICON = new ImageIcon(IOUtils.readImage("/com/fr/design/images/mainframe/lock_template.png"));
private static final Color TIP_COLOR = new Color(108, 174, 235);
private static final Color BUTTON_COLOR = new Color(63, 155, 249);
private static final int Y_GAP = 10;
private static final int X_GAP = 10;
private static final int ARC = 4;
private final UILabel lockLabel;
private final UILabel tipLabel;
private final JButton refreshButton;
public ForbiddenPane() {
setLayout(new LayoutManager() {
@Override
public void removeLayoutComponent(Component comp) {
}
@Override
public Dimension preferredLayoutSize(Container parent) {
return parent.getPreferredSize();
}
@Override
public Dimension minimumLayoutSize(Container parent) {
return null;
}
@Override
public void layoutContainer(Container parent) {
int width = parent.getParent().getWidth();
int height = parent.getParent().getHeight();
int lockLabelWidth = lockLabel.getPreferredSize().width;
int lockLabelHeight = lockLabel.getPreferredSize().height;
int lockLabelX = (width - lockLabelWidth) / 2;
int lockLabelY = (height - lockLabelHeight) / 2;
int tipLabelWidth = tipLabel.getPreferredSize().width;
int tipLabelHeight = tipLabel.getPreferredSize().height;
int tipLabelX = (width - tipLabelWidth) / 2 + X_GAP;
int tipLabelY = lockLabelY + lockLabelHeight;
int refreshButtonWidth = refreshButton.getPreferredSize().width;
int refreshButtonHeight = refreshButton.getPreferredSize().height;
int refreshButtonX = (width - refreshButtonWidth) / 2 + X_GAP;
int refreshButtonY = tipLabelY + refreshButtonHeight + Y_GAP;
lockLabel.setBounds(lockLabelX, lockLabelY, lockLabelWidth, lockLabelHeight);
tipLabel.setBounds(tipLabelX, tipLabelY, tipLabelWidth, tipLabelHeight);
refreshButton.setBounds(refreshButtonX, refreshButtonY, refreshButtonWidth, refreshButtonHeight);
}
@Override
public void addLayoutComponent(String name, Component comp) {
}
});
setBackground(Color.WHITE);
lockLabel = new UILabel(LOCK_ICON);
tipLabel = new UILabel(Toolkit.i18nText("Fine_Design_Template_Has_Been_Locked_Tip"));
Font labelFont = tipLabel.getFont();
tipLabel.setFont(new Font(labelFont.getName(), labelFont.getStyle(), 14));
tipLabel.setForeground(TIP_COLOR);
refreshButton = new JButton(Toolkit.i18nText("Fine-Design_Basic_Refresh")) {
@Override
public void paintComponent(Graphics g) {
Graphics2D g2d = (Graphics2D) g;
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2d.setColor(BUTTON_COLOR);
g2d.fillRoundRect(0, 0, getWidth(), getHeight(), ARC, ARC);
super.paintComponent(g2d);
}
};
refreshButton.setPreferredSize(new Dimension(68, 24));
refreshButton.setForeground(Color.WHITE);
refreshButton.setBorderPainted(false);
refreshButton.setContentAreaFilled(false);
refreshButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
final JTemplate<?, ?> template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (template == null) {
return;
}
// 展示下画面
LoadingDialog loadingDialog = new LoadingDialog();
loadingDialog.showDialog();
new SwingWorker<Boolean, Void>(){
@Override
protected Boolean doInBackground() throws Exception {
return WorkContext.getCurrent().get(LockInfoOperator.class).isTplLocked(template.getEditingFILE().getPath());
}
@Override
protected void done() {
boolean unLocked;
loadingDialog.hideDialog();
try {
unLocked = !get();
if (unLocked) {
template.whenClose();
JTemplate<?, ?> newTemplate = JTemplateFactory.createJTemplate(template.getEditingFILE());
HistoryTemplateListCache.getInstance().replaceCurrentEditingTemplate(newTemplate);
DesignerContext.getDesignerFrame().addAndActivateJTemplate(newTemplate);
}
} catch (Exception e) {
loadingDialog.hideDialog();
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
}.execute();
}
});
add(lockLabel);
add(tipLabel);
add(refreshButton);
}
}
class LoadingDialog extends JDialog {
private static final ImageIcon LOADING_ICON = new ImageIcon(IOUtils.readImage("/com/fr/design/images/mainframe/refreh_icon.png"));
private GuideView guideView;
public LoadingDialog() {
super(DesignerContext.getDesignerFrame());
setLayout(new BorderLayout());
this.getContentPane().setBackground(Color.WHITE);
this.setResizable(false);
this.setUndecorated(true);
this.setAlwaysOnTop(true);
this.setModal(false);
this.setSize(new Dimension(400, 100));
this.add(new UILabel(LOADING_ICON, UILabel.CENTER), BorderLayout.NORTH);
this.add(new UILabel(Toolkit.i18nText(Toolkit.i18nText("Fine_Design_Template_Refresh")), UILabel.CENTER), BorderLayout.CENTER);
GUICoreUtils.centerWindow(this);
}
public void showDialog() {
DesignerContext.getDesignerFrame().setExtendedState(JFrame.MAXIMIZED_BOTH);
guideView = new GuideView(DesignerContext.getDesignerFrame());
GUICoreUtils.centerWindow(DesignerContext.getDesignerFrame(), guideView);
guideView.setBounds(DesignerContext.getDesignerFrame().getBounds());
guideView.setVisible(true);
this.setVisible(true);
}
public void hideDialog() {
this.dispose();
guideView.dismissGuide();
}
}

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

@ -58,6 +58,7 @@ import com.fr.design.ui.util.UIUtil;
import com.fr.design.utils.DesignUtils;
import com.fr.design.worker.save.CallbackSaveWorker;
import com.fr.design.worker.save.EmptyCallBackSaveWorker;
import com.fr.design.worker.save.SaveFailureHandler;
import com.fr.design.write.submit.DBManipulationInWidgetEventPane;
import com.fr.design.write.submit.DBManipulationPane;
import com.fr.event.EventDispatcher;
@ -83,8 +84,11 @@ import com.fr.plugin.observer.PluginEvent;
import com.fr.plugin.observer.PluginEventListener;
import com.fr.plugin.observer.PluginEventType;
import com.fr.plugin.observer.PluginListenerRegistration;
import com.fr.report.InconsistentLockException;
import com.fr.report.UnLockedException;
import com.fr.report.cell.Elem;
import com.fr.report.cell.cellattr.CellImage;
import com.fr.report.lock.LockInfoOperator;
import com.fr.stable.ArrayUtils;
import com.fr.stable.Filter;
import com.fr.stable.ProductConstants;
@ -124,6 +128,8 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
protected U authorityUndoState = null;
protected T template; // 当前模板
private boolean isNewCreateTpl = false; //当前模板是否为新建模板
private volatile boolean forbidden;
/**
* 模板过程的相关信息
*
@ -640,6 +646,8 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
*/
public void redo() {
this.getUndoManager().redo();
// 重做前模版使用主题可能已经被删除或修改,需要重置模版样式
checkAndResetTheme();
fireSuperTargetModified();
}
@ -962,7 +970,7 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
export();
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), e.getMessage(), "Save Error", JOptionPane.ERROR_MESSAGE);
SaveFailureHandler.getInstance().process(e);
return false;
}
this.editingFILE = editingFILE;
@ -978,6 +986,14 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
}
protected boolean export() throws Exception {
// 保存前校验下未解锁
if (WorkContext.getCurrent().get(LockInfoOperator.class).isTplUnLocked(getEditingFILE().getPath())) {
throw new UnLockedException();
}
// 校验锁定信息是否一致
if (getEditingFILE().exists() && !WorkContext.getCurrent().get(LockInfoOperator.class).isConsistentLock(getEditingFILE().getPath())) {
throw new InconsistentLockException();
}
return this.getTarget().export(TemplateResourceManager.getResource().saveTemplate(getEditingFILE()));
}
@ -1806,8 +1822,16 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
this.openFailed = openFailed;
}
public boolean isForbidden() {
return forbidden;
}
public void setForbidden(boolean forbidden) {
this.forbidden = forbidden;
}
public boolean checkEnable() {
return !isSaving() && !isOpening() && !isOpenFailed();
return !isSaving() && !isOpening() && !isOpenFailed() && !isForbidden();
}
public String getRuntimeId() {
@ -1840,4 +1864,13 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
templateThemeButton.setText(name);
templateThemeButton.setToolTipText(name);
}
public void generateForBiddenTemplate() {
}
public void setDesignerUIMode(){
DesignerUIModeConfig.getInstance().setAbsoluteMeasureUIMode();
}
}

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

@ -151,7 +151,7 @@ public class NorthRegionContainerPane extends JPanel {
public void execute(Object... objects) {
bbsLoginPane[0] = ad.createBBSLoginPane();
}
}, SupportOSImpl.USERINFOPANE);
}, SupportOSImpl. BBS_USER_LOGIN_PANE);
processor.hold(northEastPane, LogMessageBar.getInstance(), bbsLoginPane[0]);
}
northEastPane.add(ad.createAlphaFinePane());
@ -166,7 +166,7 @@ public class NorthRegionContainerPane extends JPanel {
public void execute(Object... objects) {
northEastPane.add(ad.createBBSLoginPane());
}
}, SupportOSImpl.USERINFOPANE);
}, SupportOSImpl.BBS_USER_LOGIN_PANE);
}

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.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.stable.unit.UNIT;

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

@ -19,7 +19,17 @@ public class ColorBackgroundQuickPane extends BackgroundQuickPane {
public ColorBackgroundQuickPane() {
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);
}
@ -40,11 +50,6 @@ public class ColorBackgroundQuickPane extends BackgroundQuickPane {
return this.colorSelectBox.getSelectObject();
}
/**
* 给组件登记一个观察者监听事件
*
* @param listener 观察者监听事件
*/
@Override
public void registerChangeListener(final UIObserverListener listener) {
this.colorSelectBox.addSelectChangeListener(new ChangeListenerImpl(listener));

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

@ -1,41 +1,41 @@
package com.fr.design.mainframe.loghandler;
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.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 java.io.Serializable;
import java.util.Date;
/**
* Created by Administrator on 2017/7/18 0018.
*/
public class DesignerLogAppender extends AppenderSkeleton {
public class DesignerLogAppender extends AbstractAppender {
public DesignerLogAppender() {
this.layout = new com.fr.third.apache.log4j.PatternLayout("%d{HH:mm:ss} %t %p [%c] %m%n");
protected DesignerLogAppender(String name, Filter filter,
Layout<? extends Serializable> layout,
boolean ignoreExceptions,
Property[] properties) {
super(name, filter, layout, ignoreExceptions, properties);
}
protected void append(LoggingEvent event) {
this.subAppend(event);
public static DesignerLogAppender createDesignerLogAppender() {
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() {
return true;
@Override
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()) {
Level level = event.getLevel();
String msg = this.layout.format(event);
String msg = (String) this.toSerializable(event);
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.log.FineLoggerFactory;
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.ActionMap;
import javax.swing.InputMap;
@ -128,7 +127,7 @@ public class DesignerLogHandler {
JPopupMenu jPopupMenu = new JPopupMenu();
int logLevelInt = Log4jConfig.getInstance().getRootLevel().toInt();
int logLevelInt = Log4jConfig.getInstance().getRootLevel().intLevel();
if (logLevelInt <= DesignerLogger.INFO_INT) {
jPopupMenu.add(showInfo);
jPopupMenu.add(showError);
@ -240,23 +239,22 @@ public class DesignerLogHandler {
return resultPane;
}
public void printStackTrace(LoggingEvent event) {
public void printStackTrace(LogEvent event) {
int intLevel = event.getLevel().toInt();
Date date = new Date(event.getTimeStamp());
ThrowableInformation information = event.getThrowableInformation();
int intLevel = event.getLevel().intLevel();
Date date = new Date(event.getTimeMillis());
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()) {
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()) {
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) {
int intLevel = level.toInt();
int intLevel = level.intLevel();
if (intLevel == DesignerLogger.INFO_INT && showInfo.isSelected()) {
printMessage(message, intLevel, date);
} 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;
import com.fr.log.FineLoggerFactory;
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;
/**
* 设计器日志记录
*/
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对象
*
* @param event
*/
public static void log(LoggingEvent event) {
public static void log(LogEvent event) {
if (event == null) {
return;
}
@ -30,29 +29,27 @@ public class DesignerLogger {
public enum LogParser {
DEFAULT(-1) {
@Override
public void log(LoggingEvent event) {
public void log(LogEvent event) {
}
},
INFO(Level.INFO.toInt()) {
INFO(Level.INFO.intLevel()) {
@Override
public void log(LoggingEvent event) {
FineLoggerFactory.getLogger().info(event.getRenderedMessage());
public void log(LogEvent event) {
FineLoggerFactory.getLogger().info(event.getMessage().getFormattedMessage());
}
},
WARN(Level.WARN.toInt()) {
WARN(Level.WARN.intLevel()) {
@Override
public void log(LoggingEvent event) {
ThrowableInformation information = event.getThrowableInformation();
FineLoggerFactory.getLogger().warn(event.getRenderedMessage(), information == null ? null : information.getThrowable());
public void log(LogEvent event) {
FineLoggerFactory.getLogger().warn(event.getMessage().getFormattedMessage(), event.getThrown());
}
},
ERROR(Level.ERROR.toInt()) {
ERROR(Level.ERROR.intLevel()) {
@Override
public void log(LoggingEvent event) {
ThrowableInformation information = event.getThrowableInformation();
FineLoggerFactory.getLogger().error(event.getRenderedMessage(), information == null ? null : information.getThrowable());
public void log(LogEvent event) {
FineLoggerFactory.getLogger().error(event.getMessage().getFormattedMessage(), event.getThrown());
}
};
private int level;
@ -65,8 +62,8 @@ public class DesignerLogger {
return level;
}
public static LogParser parse(LoggingEvent event) {
int intLevel = event.getLevel().toInt();
public static LogParser parse(LogEvent event) {
int intLevel = event.getLevel().intLevel();
for (LogParser logParser : values()) {
if (logParser.getLevel() == intLevel) {
return logParser;
@ -76,7 +73,7 @@ public class DesignerLogger {
}
public void log(LoggingEvent event) {
public void log(LogEvent event) {
}
}
}

77
designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/ThemedCellStyleListPane.java → designer-base/src/main/java/com/fr/design/mainframe/theme/ThemedCellStyleListPane.java

@ -1,17 +1,14 @@
package com.fr.design.mainframe.cell.settingpane.style;
package com.fr.design.mainframe.theme;
import com.fr.base.NameStyle;
import com.fr.base.Style;
import com.fr.base.theme.TemplateTheme;
import com.fr.base.theme.settings.ThemedCellStyle;
import com.fr.design.beans.FurtherBasicBeanPane;
import com.fr.design.cell.CellStylePreviewPane;
import com.fr.design.cell.CellRectangleStylePreviewPane;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.gui.ibutton.UIRadioButton;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.DesignerBean;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.JTemplate;
import com.fr.general.ComparatorUtils;
@ -30,18 +27,18 @@ import java.awt.Dimension;
import java.io.Serializable;
import java.util.List;
public class ThemedCellStyleListPane extends FurtherBasicBeanPane<NameStyle> implements DesignerBean {
public class ThemedCellStyleListPane extends FurtherBasicBeanPane<ThemedCellStyle> implements DesignerBean {
private static final int LEFT_BORDER = 10;
private static final int RIGHT_BORDER = 10;
private final DefaultListModel<NameStyle> defaultListModel;
private final JList<NameStyle> styleList;
private final DefaultListModel<ThemedCellStyle> defaultListModel;
private final JList<ThemedCellStyle> styleList;
private ChangeListener changeListener;
public ThemedCellStyleListPane() {
public ThemedCellStyleListPane(boolean supportInnerBorder) {
defaultListModel = new DefaultListModel<>();
styleList = new JList<>(defaultListModel);
styleList.setCellRenderer(new RadioButtonListCellRenderer());
styleList.setCellRenderer(new RadioButtonListCellRangeRenderer(supportInnerBorder));
styleList.setOpaque(false);
styleList.setBackground(null);
styleList.addListSelectionListener(new ListSelectionListener() {
@ -55,15 +52,8 @@ public class ThemedCellStyleListPane extends FurtherBasicBeanPane<NameStyle> imp
setLayout(FRGUIPaneFactory.createBorderLayout());
add(styleList, BorderLayout.CENTER);
setBorder(BorderFactory.createEmptyBorder(0 ,LEFT_BORDER, 0, RIGHT_BORDER));
DesignerContext.setDesignerBean("predefinedStyle", this);
}
/**
* 添加改变监听
*
* @param changeListener 监听事件
*/
public void addChangeListener(ChangeListener changeListener) {
this.changeListener = changeListener;
}
@ -77,7 +67,7 @@ public class ThemedCellStyleListPane extends FurtherBasicBeanPane<NameStyle> imp
}
@Override
public void populateBean(NameStyle ob) {
public void populateBean(ThemedCellStyle ob) {
refreshBeanElement();
if (ob == null) {
styleList.setSelectedIndex(0);
@ -92,32 +82,21 @@ public class ThemedCellStyleListPane extends FurtherBasicBeanPane<NameStyle> imp
}
@Override
public NameStyle updateBean() {
public ThemedCellStyle updateBean() {
return styleList.getSelectedValue();
}
/**
* 获取面板标题
*
* @return 标题
*/
@Override
public String title4PopupWindow() {
return Toolkit.i18nText("Fine-Design_Report_Predefined_Style");
}
/**
* 是否可以接纳对象
*
* @param ob 组件对象
* @return 是否可以接纳对象
*/
@Override
public boolean accept(Object ob) {
return ob instanceof NameStyle;
return ob instanceof ThemedCellStyle;
}
/**
* 刷新组件对象
*/
@Override
public void refreshBeanElement() {
defaultListModel.removeAllElements();
JTemplate<?, ?> template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
@ -125,35 +104,39 @@ public class ThemedCellStyleListPane extends FurtherBasicBeanPane<NameStyle> imp
TemplateTheme theme = template.getTemplateTheme();
List<ThemedCellStyle> styleList = theme.getCellStyleList().getCellStyleList();
for (ThemedCellStyle themedCellStyle: styleList) {
String name = themedCellStyle.getName();
Style realStyle = themedCellStyle.getStyle();
NameStyle nameStyle = NameStyle.getPassiveInstance(name, realStyle);
defaultListModel.addElement(nameStyle);
defaultListModel.addElement(themedCellStyle);
}
}
styleList.setModel(defaultListModel);
}
private static class RadioButtonListCellRenderer extends JPanel implements ListCellRenderer<Object>, Serializable {
private static class RadioButtonListCellRangeRenderer extends JPanel implements ListCellRenderer<ThemedCellStyle>, Serializable {
private final UIRadioButton button;
private final CellStylePreviewPane previewArea;
private final CellRectangleStylePreviewPane previewArea;
public RadioButtonListCellRenderer() {
public RadioButtonListCellRangeRenderer(boolean supportInnerBorder) {
super();
setLayout(new BorderLayout(20, 0));
setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
setPreferredSize(new Dimension(getPreferredSize().width, 40));
setLayout(new BorderLayout(5, 0));
setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0));
button = new UIRadioButton();
previewArea = new CellStylePreviewPane();
button.setBorder(BorderFactory.createEmptyBorder());
previewArea = new CellRectangleStylePreviewPane(supportInnerBorder);
add(button, BorderLayout.WEST);
add(previewArea, BorderLayout.CENTER);
}
@Override
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
public Component getListCellRendererComponent(JList<? extends ThemedCellStyle> list, ThemedCellStyle value, int index, boolean isSelected, boolean cellHasFocus) {
button.setSelected(isSelected);
previewArea.setStyle((Style) value);
previewArea.setPlainText(value.getName());
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;
}
}

17
designer-base/src/main/java/com/fr/design/mainframe/theme/ThemedFeatureController.java

@ -0,0 +1,17 @@
package com.fr.design.mainframe.theme;
import com.fr.workspace.WorkContext;
import com.fr.workspace.server.theme.SupportThemedCellInnerBorderFeature;
import com.fr.workspace.server.theme.ThemedCellBorderFeature;
/**
* @author Starryi
* @version 1.0
* Created by Starryi on 2021/11/26
*/
public class ThemedFeatureController {
public static boolean isCellStyleSupportInnerBorder() {
ThemedCellBorderFeature controller = WorkContext.getCurrent().get(ThemedCellBorderFeature.class);
return controller instanceof SupportThemedCellInnerBorderFeature;
}
}

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

18
designer-base/src/main/java/com/fr/design/mainframe/theme/edit/CellStyleListEditPane.java

@ -1,9 +1,7 @@
package com.fr.design.mainframe.theme.edit;
import com.fr.base.Style;
import com.fr.base.theme.settings.ThemedCellStyle;
import com.fr.base.theme.settings.ThemedCellStyleList;
import com.fr.config.predefined.PredefinedCellStyle;
import com.fr.design.actions.UpdateAction;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.dialog.FineJOptionPane;
@ -122,7 +120,7 @@ public class CellStyleListEditPane extends JListControlPane {
}
@Override
public BasicBeanPane createPaneByCreators(NameableCreator creator) {
public BasicBeanPane<?> createPaneByCreators(NameableCreator creator) {
CellStyleEditPane stylePane = (CellStyleEditPane) super.createPaneByCreators(creator);
stylePane.registerAttrChangeListener(attributeChangeListener);
return stylePane;
@ -256,23 +254,15 @@ public class CellStyleListEditPane extends JListControlPane {
this(CellStyleEditPane.class);
}
public CellStyleNameObjectCreator(Class<? extends BasicBeanPane> updatePane) {
public CellStyleNameObjectCreator(Class<? extends BasicBeanPane<?>> updatePane) {
super(i18nText("Fine-Design_Predefined_Cell_New_Style"), ThemedCellStyle.class, updatePane);
}
@Override
public Nameable createNameable(UnrepeatedNameHelper helper) {
ThemedCellStyle cellStyle = new ThemedCellStyle();
ThemedCellStyle cellStyle = ThemedCellStyle.createInstanceUsed4New();
cellStyle.setName(menuName);
cellStyle.setStyle(Style.getInstance());
cellStyle.setRemovable(true);
cellStyle.setUse4Default(false);
cellStyle.setUse4BigTitle(false);
cellStyle.setUse4SmallTitle(false);
cellStyle.setUse4Header(false);
cellStyle.setUse4MainText(false);
cellStyle.setUse4SupportInfo(false);
cellStyle.setUse4HighlightText(false);
return new NameObject(helper.createUnrepeatedName(this.menuName()), cellStyle);
}

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

@ -1,7 +1,9 @@
package com.fr.design.mainframe.theme.edit.cell;
import com.fr.base.CellBorderStyle;
import com.fr.base.Style;
import com.fr.base.theme.settings.ThemedCellStyle;
import com.fr.design.cell.CellStylePreviewPane;
import com.fr.design.cell.CellRectangleStylePreviewPane;
import com.fr.design.constants.UIConstants;
import com.fr.design.dialog.AttrScrollPane;
import com.fr.design.dialog.BasicPane;
@ -14,6 +16,7 @@ import com.fr.design.gui.style.AlignmentPane;
import com.fr.design.gui.style.BorderPane;
import com.fr.design.gui.style.TextFontTippedPane;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.theme.ThemedFeatureController;
import com.fr.design.mainframe.theme.ui.BorderUtils;
import javax.swing.BorderFactory;
@ -35,7 +38,7 @@ import static com.fr.design.i18n.Toolkit.i18nText;
*/
public class CellStyleEditPane extends MultiTabPane<ThemedCellStyle> {
private ThemedCellStyle cellStyle;
private CellStylePreviewPane previewArea;
private CellRectangleStylePreviewPane previewArea;
private boolean populating;
private AttributeChangeListener attributeChangeListener;
@ -74,7 +77,11 @@ public class CellStyleEditPane extends MultiTabPane<ThemedCellStyle> {
for (BasicPane basicPane : paneList) {
((AbstractBasicStylePane) basicPane).populateBean(ob.getStyle());
previewArea.setStyle(ob.getStyle());
previewArea.setPlainText(ob.getName());
previewArea.setStyle(ob.getStyle(), ob.getCellBorderStyle());
if (ThemedFeatureController.isCellStyleSupportInnerBorder() && basicPane instanceof BorderPane) {
((BorderPane) basicPane).populateBean(ob.getCellBorderStyle(), true, false);
}
}
this.populating = false;
}
@ -82,9 +89,35 @@ public class CellStyleEditPane extends MultiTabPane<ThemedCellStyle> {
@Override
public ThemedCellStyle updateBean() {
AbstractBasicStylePane basicStylePane = (AbstractBasicStylePane) paneList.get(tabPane.getSelectedIndex());
this.cellStyle.setStyle(basicStylePane.update(this.cellStyle.getStyle()));
Style style = basicStylePane.update(this.cellStyle.getStyle());
CellBorderStyle borderStyle = createDefaultBorderStyleFromStyle(style);
if (ThemedFeatureController.isCellStyleSupportInnerBorder() && basicStylePane instanceof BorderPane) {
borderStyle = ((BorderPane) basicStylePane).update();
}
this.cellStyle.setStyle(style);
this.cellStyle.setCellBorderStyle(borderStyle);
return this.cellStyle;
}
private CellBorderStyle createDefaultBorderStyleFromStyle(Style style) {
CellBorderStyle cellBorderStyle = new CellBorderStyle();
cellBorderStyle.setTopStyle(style.getBorderTop());
cellBorderStyle.setTopColor(style.getBorderTopColor());
cellBorderStyle.setBottomStyle(style.getBorderBottom());
cellBorderStyle.setBottomColor(style.getBorderBottomColor());
cellBorderStyle.setLeftStyle(style.getBorderLeft());
cellBorderStyle.setLeftColor(style.getBorderLeftColor());
cellBorderStyle.setRightStyle(style.getBorderRight());
cellBorderStyle.setRightColor(style.getBorderRightColor());
return cellBorderStyle;
}
@Override
public boolean accept(Object ob) {
@ -102,16 +135,18 @@ public class CellStyleEditPane extends MultiTabPane<ThemedCellStyle> {
@Override
protected void initLayout() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.setLayout(new BorderLayout(0, 10));
JPanel jPanel = new JPanel();
jPanel.setLayout(new BorderLayout(0, 4));
JPanel previewPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
previewArea = new CellStylePreviewPane();
previewArea.setPreferredSize(new Dimension(223, 30));
previewPane.setBorder(BorderUtils.createTitleBorder(i18nText("Fine-Design_Basic_Preview")));
previewPane.add(previewArea, BorderLayout.CENTER);
previewArea = new CellRectangleStylePreviewPane(true);
previewArea.setPreferredSize(new Dimension(215, 48));
previewPane.setBorder(BorderFactory.createCompoundBorder(
BorderUtils.createTitleBorder(i18nText("Fine-Design_Basic_Preview")),
BorderFactory.createEmptyBorder(4, 4, 4, 4)));
previewPane.add(previewArea, BorderLayout.NORTH);
this.add(previewPane, BorderLayout.NORTH);
@ -135,7 +170,8 @@ public class CellStyleEditPane extends MultiTabPane<ThemedCellStyle> {
}
ThemedCellStyle cellStyle = updateBean();
if (cellStyle != null) {
previewArea.setStyle(cellStyle.getStyle());
previewArea.setPlainText(cellStyle.getName());
previewArea.setStyle(cellStyle.getStyle(), cellStyle.getCellBorderStyle());
}
fireAttrChangeListener();
}

3
designer-base/src/main/java/com/fr/design/mainframe/theme/edit/chart/ChartFontPane.java

@ -7,6 +7,7 @@ import com.fr.design.constants.LayoutConstants;
import com.fr.design.dialog.BasicPane;
import com.fr.design.event.UIObserverListener;
import com.fr.design.gui.ibutton.UIColorButton;
import com.fr.design.gui.ibutton.UIColorButtonWithAuto;
import com.fr.design.gui.ibutton.UIToggleButton;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.ilable.UILabel;
@ -56,7 +57,7 @@ public class ChartFontPane extends BasicPane {
fontSizeComboBox = new UIComboBox(FONT_SIZES);
bold = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/bold.png"));
italic = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/italic.png"));
fontColor = new UIColorButton();
fontColor = new UIColorButtonWithAuto();
}
protected void initComponents() {

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;
}
private static class ColorButton extends AbstractSelectBox<Color> {
public static class ColorButton extends AbstractSelectBox<Color> {
private Color color;
private NewColorSelectPane colorPane;
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.setCallbackEvent(this);
reportPreviewPane = new ECReportPreviewPane();
this.add(reportPreviewPane, BorderLayout.CENTER);
this.add(chartPreviewPane, BorderLayout.SOUTH);
reportPreviewPane.setPreferredSize(new Dimension(615, 297));
this.add(reportPreviewPane, BorderLayout.NORTH);
this.add(chartPreviewPane, BorderLayout.CENTER);
}
@Override

38
designer-base/src/main/java/com/fr/design/mainframe/theme/preview/ecpreview/AbstractECPreviewPane.java

@ -1,5 +1,6 @@
package com.fr.design.mainframe.theme.preview.ecpreview;
import com.fr.base.CellBorderStyle;
import com.fr.base.Style;
import com.fr.base.theme.TemplateTheme;
import com.fr.base.theme.settings.ThemedCellStyle;
@ -11,29 +12,6 @@ import com.fr.design.mainframe.theme.preview.ecpreview.cell.AbstractPreviewCell;
import java.util.List;
public abstract class AbstractECPreviewPane extends UINoOpaquePanel implements ThemePreviewed<TemplateTheme> {
protected Style getReportBigTitleStyle(ThemedCellStyleList cellStyleList) {
return getCellStyle(cellStyleList.getUse4BigTitle());
}
protected Style getReportHeaderStyle(ThemedCellStyleList cellStyleList) {
return getCellStyle(cellStyleList.getUse4Header());
}
protected Style getMainContentStyle(ThemedCellStyleList cellStyleList) {
return getCellStyle(cellStyleList.getUse4MainText());
}
protected Style getHighLightStyle(ThemedCellStyleList cellStyleList) {
return getCellStyle(cellStyleList.getUse4HighlightText());
}
protected Style getSmallTitleStyle(ThemedCellStyleList cellStyleList) {
return getCellStyle(cellStyleList.getUse4SmallTitle());
}
protected Style getAssistMsgStyle(ThemedCellStyleList cellStyleList) {
return getCellStyle(cellStyleList.getUse4SupportInfo());
}
private Style getCellStyle(ThemedCellStyle themedCellStyle) {
if (themedCellStyle == null) {
return Style.DEFAULT_STYLE;
@ -42,9 +20,19 @@ public abstract class AbstractECPreviewPane extends UINoOpaquePanel implements T
return style != null ? style : Style.DEFAULT_STYLE;
}
protected void refresh(List<AbstractPreviewCell> list, Style style) {
private CellBorderStyle getCellBorderStyle(ThemedCellStyle themedCellStyle) {
if (themedCellStyle == null) {
return null;
}
return themedCellStyle.getCellBorderStyle();
}
protected void refresh(List<AbstractPreviewCell> list, ThemedCellStyle themedCellStyle) {
Style style = getCellStyle(themedCellStyle);
CellBorderStyle borderStyle = getCellBorderStyle(themedCellStyle);
for (AbstractPreviewCell cell : list) {
cell.refresh(style);
cell.refresh(style, borderStyle);
}
}

47
designer-base/src/main/java/com/fr/design/mainframe/theme/preview/ecpreview/ECPreviewPane.java

@ -1,5 +1,6 @@
package com.fr.design.mainframe.theme.preview.ecpreview;
import com.fr.base.CellBorderSourceFlag;
import com.fr.base.theme.TemplateTheme;
import com.fr.base.theme.settings.ThemedCellStyleList;
import com.fr.design.i18n.Toolkit;
@ -36,8 +37,16 @@ public class ECPreviewPane extends AbstractECPreviewPane {
JPanel extCenterPane = FRGUIPaneFactory.createBorderLayout_NO_Opaque_Pane();
this.add(extCenterPane, BorderLayout.CENTER);
extCenterPane.add(titlePane, BorderLayout.NORTH);
for (int i = 0; i < COL_COUNT; i++) {
for (int c = 0; c < COL_COUNT; c++) {
PreviewCell cell = new PreviewCell(Toolkit.i18nText("Fine-Design_Basic_Predefined_Style_Header"));
int flag = CellBorderSourceFlag.ALL_BORDER_SOURCE_OUTER;
if (c > 0) {
flag |= CellBorderSourceFlag.LEFT_BORDER_SOURCE_INNER;
}
if (c < COL_COUNT - 1) {
flag |= CellBorderSourceFlag.RIGHT_BORDER_SOURCE_INNER;
}
cell.setBorderSourceFlag(flag);
cell.setPreferredSize(new Dimension(103, 36));
titlePane.add(cell);
headerCellList.add(cell);
@ -46,6 +55,22 @@ public class ECPreviewPane extends AbstractECPreviewPane {
extCenterPane.add(contentPane, BorderLayout.CENTER);
for (int i = 0; i < COL_COUNT * CONTENT_ROW_COUNT; i++) {
PreviewCell cell = new PreviewCell(Toolkit.i18nText("Fine-Design_Basic_Predefined_Style_Main_Text"));
int r = i / COL_COUNT;
int c = i % COL_COUNT;
int flag = CellBorderSourceFlag.ALL_BORDER_SOURCE_OUTER;
if (r > 0) {
flag |= CellBorderSourceFlag.TOP_BORDER_SOURCE_INNER;
}
if (r < CONTENT_ROW_COUNT - 1) {
flag |= CellBorderSourceFlag.BOTTOM_BORDER_SOURCE_INNER;
}
if (c > 0) {
flag |= CellBorderSourceFlag.LEFT_BORDER_SOURCE_INNER;
}
if (c < COL_COUNT - 1) {
flag |= CellBorderSourceFlag.RIGHT_BORDER_SOURCE_INNER;
}
cell.setBorderSourceFlag(flag);
cell.setPreferredSize(new Dimension(103, 30));
contentPane.add(cell);
contentCellList.add(cell);
@ -53,8 +78,16 @@ public class ECPreviewPane extends AbstractECPreviewPane {
JPanel endPane = new UINoOpaquePanel(new GridLayout());
extCenterPane.add(endPane, BorderLayout.SOUTH);
for (int i = 0; i < COL_COUNT; i++) {
for (int c = 0; c < COL_COUNT; c++) {
PreviewCell cell = new PreviewCell(Toolkit.i18nText("Fine-Design_Basic_Predefined_Style_Highlight_Text"));
int flag = CellBorderSourceFlag.ALL_BORDER_SOURCE_OUTER;
if (c > 0) {
flag |= CellBorderSourceFlag.LEFT_BORDER_SOURCE_INNER;
}
if (c < COL_COUNT - 1) {
flag |= CellBorderSourceFlag.RIGHT_BORDER_SOURCE_INNER;
}
cell.setBorderSourceFlag(flag);
cell.setPreferredSize(new Dimension(103, 30));
endPane.add(cell);
highLightCellList.add(cell);
@ -62,6 +95,7 @@ public class ECPreviewPane extends AbstractECPreviewPane {
JPanel extSouthPane = FRGUIPaneFactory.createBorderLayout_NO_Opaque_Pane();
PreviewCell assistCell = new PreviewCell(Toolkit.i18nText("Fine-Design_Basic_Predefined_Style_Assist_Text"));
assistCell.setBorderSourceFlag(CellBorderSourceFlag.ALL_BORDER_SOURCE_OUTER);
assistCell.setPreferredSize(new Dimension(123, 30));
assistCellList.add(assistCell);
extSouthPane.add(assistCell);
@ -71,11 +105,10 @@ public class ECPreviewPane extends AbstractECPreviewPane {
@Override
public void refresh(TemplateTheme theme) {
ThemedCellStyleList cellStyleConfig = theme.getCellStyleList();
refresh(headerCellList, getReportHeaderStyle(cellStyleConfig));
refresh(contentCellList, getMainContentStyle(cellStyleConfig));
refresh(highLightCellList, getHighLightStyle(cellStyleConfig));
refresh(highLightCellList, getHighLightStyle(cellStyleConfig));
refresh(assistCellList, getAssistMsgStyle(cellStyleConfig));
refresh(headerCellList, cellStyleConfig.getUse4Header());
refresh(contentCellList, cellStyleConfig.getUse4MainText());
refresh(highLightCellList, cellStyleConfig.getUse4HighlightText());
refresh(assistCellList, cellStyleConfig.getUse4SupportInfo());
}

88
designer-base/src/main/java/com/fr/design/mainframe/theme/preview/ecpreview/ECReportPreviewPane.java

@ -1,5 +1,6 @@
package com.fr.design.mainframe.theme.preview.ecpreview;
import com.fr.base.CellBorderSourceFlag;
import com.fr.base.theme.ReportTheme;
import com.fr.base.theme.TemplateTheme;
import com.fr.base.theme.settings.ThemedCellStyleList;
@ -22,12 +23,12 @@ import java.util.ArrayList;
import java.util.List;
public class ECReportPreviewPane extends UINoOpaquePanel implements ThemePreviewed<ReportTheme> {
private final List<AbstractPreviewCell> headerTitleCellList = new ArrayList<>();
private final List<AbstractPreviewCell> headerCellList = new ArrayList<>();
private final List<AbstractPreviewCell> titleCellList = new ArrayList<>();
private final List<AbstractPreviewCell> contentCellList = new ArrayList<>();
private final List<AbstractPreviewCell> highLightCellList = new ArrayList<>();
private final List<AbstractPreviewCell> assistCellList = new ArrayList<>();
private final List<AbstractPreviewCell> headerTitleCellList = new ArrayList<>(); // 大标题样式单元格
private final List<AbstractPreviewCell> headerCellList = new ArrayList<>(); // 表头样式单元格
private final List<AbstractPreviewCell> titleCellList = new ArrayList<>(); // 小标题样式单元格
private final List<AbstractPreviewCell> contentCellList = new ArrayList<>(); // 正文样式单元格
private final List<AbstractPreviewCell> highLightCellList = new ArrayList<>(); // 高亮文本样式单元格
private final List<AbstractPreviewCell> assistCellList = new ArrayList<>(); // 辅助信息样式单元格
private static final int CONTENT_ROW_COUNT = 3;
private static final int COL_COUNT = 5;
@ -64,31 +65,38 @@ public class ECReportPreviewPane extends UINoOpaquePanel implements ThemePreview
private JPanel createNorthPane() {
JPanel northPane = FRGUIPaneFactory.createBorderLayout_NO_Opaque_Pane();
AbstractPreviewCell bigTitleCell = new PreviewCell(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Profile_Pane_Cell_Style_Big_Title"));
bigTitleCell.setBorderSourceFlag(CellBorderSourceFlag.ALL_BORDER_SOURCE_OUTER);
bigTitleCell.setPreferredSize(new Dimension(615, 46));
headerTitleCellList.add(bigTitleCell);
northPane.add(bigTitleCell, BorderLayout.NORTH);
CornerPreviewCell cornerCell = new CornerPreviewCell(new String[]{Toolkit.i18nText("Fine-Design_Basic_Column_Name"),
Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Profile_Pane_EC_Data"), Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Profile_Pane_Row_Name")},
new Point2D[]{new Point(159, 71), new Point(225, 49)});
cornerCell.setBorderSourceFlag(CellBorderSourceFlag.INVALID_BORDER_SOURCE);
cornerCell.setPreferredSize(new Dimension(225, 71));
titleCellList.add(cornerCell);
northPane.add(cornerCell, BorderLayout.WEST);
JPanel centerPane = FRGUIPaneFactory.createBorderLayout_NO_Opaque_Pane();
northPane.add(centerPane, BorderLayout.CENTER);
PreviewCell cell = new PreviewCell(Toolkit.i18nText("Fine-Design_Basic_Predefined_Style_Small_Title"));
cell.setBorderSourceFlag(CellBorderSourceFlag.ALL_BORDER_SOURCE_OUTER);
titleCellList.add(cell);
cell.setPreferredSize(new Dimension(308, 38));
centerPane.add(cell, BorderLayout.NORTH);
JPanel eastSouthPane = new UINoOpaquePanel(new GridLayout());
PreviewCell cell1 = new PreviewCell(Toolkit.i18nText("Fine-Design_Basic_Predefined_Style_Header"));
PreviewCell cell2 = new PreviewCell(Toolkit.i18nText("Fine-Design_Basic_Predefined_Style_Header"));
PreviewCell cell3 = new PreviewCell(Toolkit.i18nText("Fine-Design_Basic_Predefined_Style_Header"));
headerCellList.add(cell1);
headerCellList.add(cell2);
headerCellList.add(cell3);
eastSouthPane.add(cell1);
eastSouthPane.add(cell2);
eastSouthPane.add(cell3);
for (int c = 0; c < CONTENT_ROW_COUNT; c++) {
PreviewCell headerCell = new PreviewCell(Toolkit.i18nText("Fine-Design_Basic_Predefined_Style_Header"));
int flag = CellBorderSourceFlag.ALL_BORDER_SOURCE_OUTER;
if (c > 0) {
flag |= CellBorderSourceFlag.LEFT_BORDER_SOURCE_INNER;
}
if (c < CONTENT_ROW_COUNT - 1) {
flag |= CellBorderSourceFlag.RIGHT_BORDER_SOURCE_INNER;
}
headerCell.setBorderSourceFlag(flag);
headerCellList.add(headerCell);
eastSouthPane.add(headerCell);
}
centerPane.add(eastSouthPane, BorderLayout.CENTER);
return northPane;
}
@ -102,8 +110,16 @@ public class ECReportPreviewPane extends UINoOpaquePanel implements ThemePreview
cell1.setPreferredSize(new Dimension(112, 153));
westPane.add(cell1, BorderLayout.WEST);
JPanel gridPane = new UINoOpaquePanel(new GridLayout(5, 1));
for (int i = 0; i < COL_COUNT; i++) {
for (int r = 0; r < COL_COUNT; r++) {
PreviewCell cell = new PreviewCell(Toolkit.i18nText("Fine-Design_Basic_Predefined_Style_Header"));
int flag = CellBorderSourceFlag.ALL_BORDER_SOURCE_OUTER;
if (r > 0) {
flag |= CellBorderSourceFlag.TOP_BORDER_SOURCE_INNER;
}
if (r < COL_COUNT - 1) {
flag |= CellBorderSourceFlag.BOTTOM_BORDER_SOURCE_INNER;
}
cell.setBorderSourceFlag(flag);
cell.setPreferredSize(new Dimension(113, 31));
headerCellList.add(cell);
gridPane.add(cell);
@ -114,11 +130,36 @@ public class ECReportPreviewPane extends UINoOpaquePanel implements ThemePreview
centerPane.add(innerCenterPane, BorderLayout.CENTER);
for (int i = 0; i < COL_COUNT * CONTENT_ROW_COUNT; i++) {
PreviewCell cell ;
if ((i + 1) % CONTENT_ROW_COUNT == 0) {
int r = i / CONTENT_ROW_COUNT;
int c = i % CONTENT_ROW_COUNT;
if (c == CONTENT_ROW_COUNT - 1) {
cell = new PreviewCell(Toolkit.i18nText("Fine-Design_Basic_Predefined_Style_Highlight_Text"));
int flag = CellBorderSourceFlag.ALL_BORDER_SOURCE_OUTER;
if (r != 0) {
flag |= CellBorderSourceFlag.TOP_BORDER_SOURCE_INNER;
}
if (r != COL_COUNT - 1) {
flag |= CellBorderSourceFlag.BOTTOM_BORDER_SOURCE_INNER;
}
cell.setBorderSourceFlag(flag);
highLightCellList.add(cell);
} else {
cell = new PreviewCell(Toolkit.i18nText("Fine-Design_Basic_Predefined_Style_Main_Text"));
int flag = CellBorderSourceFlag.ALL_BORDER_SOURCE_OUTER;
if (r > 0) {
flag |= CellBorderSourceFlag.TOP_BORDER_SOURCE_INNER;
}
if (r < COL_COUNT - 1) {
flag |= CellBorderSourceFlag.BOTTOM_BORDER_SOURCE_INNER;
}
if (c > 0) {
flag |= CellBorderSourceFlag.LEFT_BORDER_SOURCE_INNER;
}
if (c < CONTENT_ROW_COUNT - 2) {
flag |= CellBorderSourceFlag.RIGHT_BORDER_SOURCE_INNER;
}
cell.setBorderSourceFlag(flag);
contentCellList.add(cell);
}
cell.setPreferredSize(new Dimension(123, 31));
@ -132,6 +173,7 @@ public class ECReportPreviewPane extends UINoOpaquePanel implements ThemePreview
private JPanel createSouthPane(){
JPanel southPane = FRGUIPaneFactory.createBorderLayout_NO_Opaque_Pane();
PreviewCell assistCell = new PreviewCell(Toolkit.i18nText("Fine-Design_Basic_Predefined_Style_Assist_Text"));
assistCell.setBorderSourceFlag(CellBorderSourceFlag.ALL_BORDER_SOURCE_OUTER);
assistCell.setPreferredSize(new Dimension(123, 30));
assistCellList.add(assistCell);
southPane.add(assistCell, BorderLayout.CENTER);
@ -141,12 +183,12 @@ public class ECReportPreviewPane extends UINoOpaquePanel implements ThemePreview
@Override
public void refresh(TemplateTheme theme) {
ThemedCellStyleList cellStyleConfig = theme.getCellStyleList();
refresh(headerTitleCellList, getReportBigTitleStyle(cellStyleConfig));
refresh(headerCellList, getReportHeaderStyle(cellStyleConfig));
refresh(contentCellList, getMainContentStyle(cellStyleConfig));
refresh(titleCellList, getSmallTitleStyle(cellStyleConfig));
refresh(highLightCellList, getHighLightStyle(cellStyleConfig));
refresh(assistCellList, getAssistMsgStyle(cellStyleConfig));
refresh(headerTitleCellList, cellStyleConfig.getUse4BigTitle());
refresh(headerCellList, cellStyleConfig.getUse4Header());
refresh(contentCellList, cellStyleConfig.getUse4MainText());
refresh(titleCellList, cellStyleConfig.getUse4SmallTitle());
refresh(highLightCellList, cellStyleConfig.getUse4HighlightText());
refresh(assistCellList, cellStyleConfig.getUse4SupportInfo());
}
}
}

27
designer-base/src/main/java/com/fr/design/mainframe/theme/preview/ecpreview/cell/AbstractPreviewCell.java

@ -1,25 +1,46 @@
package com.fr.design.mainframe.theme.preview.ecpreview.cell;
import com.fr.base.CellBorderSourceFlag;
import com.fr.base.CellBorderStyle;
import com.fr.base.Style;
import com.fr.stable.Constants;
import javax.swing.JComponent;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
public abstract class AbstractPreviewCell extends JComponent {
private static final double BORDER_INSET = 0.5D;
protected Style style = Style.DEFAULT_STYLE;
private static final int NO_SCALE_RESOLUTION = 100;
private int borderSourceFlag = CellBorderSourceFlag.INVALID_BORDER_SOURCE;
public void setBorderSourceFlag(int borderSourceFlag) {
this.borderSourceFlag = borderSourceFlag;
}
public void refresh(Style style) {
this.style = style;
public void refresh(Style style, CellBorderStyle borderStyle) {
this.style = CellBorderSourceFlag.deriveBorderedStyle(style, borderStyle, borderSourceFlag);
}
public void paint(Graphics g) {
Graphics2D g2d = (Graphics2D) g;
Style.paintBackground(g2d, style, getWidth(), getHeight());
paintContent(g2d, NO_SCALE_RESOLUTION);
Style.paintBorder(g2d, style, getWidth(), getHeight());
paintBorder(g2d);
}
private void paintBorder(Graphics2D g2d) {
double width = getWidth();
double height = getHeight();
if (style.getBorderLeft() == Constants.LINE_SLIM || style.getBorderRight() == Constants.LINE_SLIM) {
width -= BORDER_INSET;
}
if (style.getBorderBottom() == Constants.LINE_SLIM || style.getBorderTop() == Constants.LINE_SLIM) {
height -= BORDER_INSET;
}
Style.paintBorder(g2d, style, width, height);
}
protected abstract void paintContent(Graphics2D g2d, int resolution);

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

@ -1,6 +1,7 @@
package com.fr.design.os.impl;
import com.fr.base.FRContext;
import com.fr.design.config.DesignerProperties;
import com.fr.design.jdk.JdkVersion;
import com.fr.general.CloudCenter;
import com.fr.general.GeneralContext;
@ -22,11 +23,11 @@ import java.util.Locale;
public enum SupportOSImpl implements SupportOS {
/**
* ARM下屏蔽登录
* 屏蔽登录入口
*/
USERINFOPANE{
BBS_USER_LOGIN_PANE {
public boolean support(){
return Arch.getArch() != Arch.ARM;
return Arch.getArch() != Arch.ARM && DesignerProperties.getInstance().isSupportLoginEntry();
}
},
/**

135
designer-base/src/main/java/com/fr/design/utils/TemplateUtils.java

@ -0,0 +1,135 @@
package com.fr.design.utils;
import com.fr.base.extension.FileExtension;
import com.fr.base.io.BaseBook;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.file.TemplateTreePane;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.worker.save.SaveFailureHandler;
import com.fr.file.FILE;
import com.fr.file.FILEChooserPane;
import com.fr.file.filter.ChooseFileFilter;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.ArrayUtils;
import com.fr.stable.CoreConstants;
import com.fr.stable.ProductConstants;
import com.fr.workspace.WorkContext;
import com.fr.workspace.server.lock.TplOperator;
import java.io.ByteArrayOutputStream;
import java.io.OutputStream;
import javax.swing.SwingWorker;
/**
* @author hades
* @version 11.0
* Created by hades on 2021/12/5
*/
public class TemplateUtils {
public static void createAndOpenTemplate(String prefix, FILE file, boolean needOpen) {
String fileName = file.getName();
String oldPath = file.getPath();
int indexOfLastDot = fileName.lastIndexOf(CoreConstants.DOT);
if (indexOfLastDot < 0) {
return;
}
String suffix = fileName.substring(indexOfLastDot + 1);
FILEChooserPane fileChooserPane = FILEChooserPane.getInstance(true, true);
fileChooserPane.setFileNameTextField(prefix + fileName, suffix);
FileExtension fileExtension = FileExtension.parse(suffix);
fileChooserPane.addChooseFILEFilter(new ChooseFileFilter(fileExtension, ProductConstants.APP_NAME + Toolkit.i18nText("Fine-Design_Report_Template_File")));
fileChooserPane.disableFileNameTextFiled();
int result = fileChooserPane.showSaveDialog(DesignerContext.getDesignerFrame(), suffix);
fileChooserPane.enableFileNameTextFiled();
if (isCancel(result)) {
return;
}
if (isOk(result)) {
file = fileChooserPane.getSelectedFILE();
_createAndOpenTemplate(file, oldPath, needOpen);
}
}
private static void _createAndOpenTemplate(FILE file, String oldPath, boolean needOpen){
new SwingWorker<Void, Void>() {
@Override
protected Void doInBackground() throws Exception {
byte[] content = new byte[0];
if (!needOpen) {
// 从当前编辑模板中生成备份文件
JTemplate<?, ?> template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
BaseBook target = template.getTarget();
if (target != null) {
target.export(outputStream);
content = outputStream.toByteArray();
}
} else {
content = WorkContext.getWorkResource().readFully(oldPath);
}
if (ArrayUtils.isEmpty(content)) {
throw new Exception(oldPath + " content is empty" );
}
OutputStream out = null;
try {
// 加锁
WorkContext.getCurrent().get(TplOperator.class).saveAs(file.getPath());
out = file.asOutputStream();
out.write(content);
} finally {
try {
if (out != null) {
out.close();
}
} finally {
// 解锁
WorkContext.getCurrent().get(TplOperator.class).closeAndFreeFile(file.getPath());
}
}
return null;
}
@Override
protected void done() {
try {
get();
if (needOpen) {
DesignerContext.getDesignerFrame().openTemplate(file);
}
// 备份成功刷新下目录树 展示出来备份的模板
TemplateTreePane.getInstance().refresh();
} catch (Exception e) {
SaveFailureHandler.getInstance().process(e);
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
}.execute();
}
private static boolean isCancel(int result) {
return result == FILEChooserPane.CANCEL_OPTION ||
result == FILEChooserPane.JOPTIONPANE_CANCEL_OPTION;
}
private static boolean isOk(int result) {
return result == FILEChooserPane.JOPTIONPANE_OK_OPTION ||
result == FILEChooserPane.OK_OPTION;
}
public static String createLockeTemplatedName(JTemplate<?, ?> template, String name) {
int index = name.lastIndexOf(CoreConstants.DOT);
if (index < 0 || !template.isForbidden()) {
return name;
}
return name.substring(0, index) + Toolkit.i18nText("Fine_Design_Template_Has_Been_Locked") + name.substring(index);
}
}

16
designer-base/src/main/java/com/fr/design/utils/gui/AdjustWorkBookDefaultStyleUtils.java

@ -17,6 +17,7 @@ public class AdjustWorkBookDefaultStyleUtils {
private static final Color TEMPLATE_BACKGROUND = new Color(16, 11, 43);
private static final Color CELL_ELEMENT_BORDER = new Color(110, 110, 110);
private static final Color CELL_ELEMENT_FONT_FOREGROUND = Color.WHITE;
private static Color currentStoryBack = null;
@ -31,13 +32,24 @@ public class AdjustWorkBookDefaultStyleUtils {
public static void adjustCellElement(CellElement cellElement) {
if (DesignModeContext.isDuchampMode()) {
Style style = cellElement.getStyle();
style = style.deriveFRFont(style.getFRFont().applyForeground(Color.WHITE));
style = adjustCellElement(style);
cellElement.setStyle(style);
}
}
public static Style adjustCellElement(Style style) {
if (DesignModeContext.isDuchampMode()) {
style = style.deriveFRFont(style.getFRFont().applyForeground(CELL_ELEMENT_FONT_FOREGROUND));
style = style.deriveBorder(0, CELL_ELEMENT_BORDER,
0, CELL_ELEMENT_BORDER,
0, CELL_ELEMENT_BORDER,
0, CELL_ELEMENT_BORDER);
cellElement.setStyle(style);
}
return style;
}
public static Color adjustCellElementFontForeground(Color color) {
return DesignModeContext.isDuchampMode() ? CELL_ELEMENT_FONT_FOREGROUND : color;
}
public static void adjustFloatElement(FloatElement floatElement) {

10
designer-base/src/main/java/com/fr/design/worker/open/OpenWorker.java

@ -3,18 +3,23 @@ package com.fr.design.worker.open;
import com.fr.base.chart.exception.ChartNotFoundException;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.file.MutilTempalteTabPane;
import com.fr.design.file.TemplateTreePane;
import com.fr.design.i18n.Toolkit;
import com.fr.design.lock.LockInfoDialog;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.DesignerFrameFileDealerPane;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.utils.DesignUtils;
import com.fr.design.worker.WorkerManager;
import com.fr.exception.DecryptTemplateException;
import com.fr.exception.TplLockedException;
import com.fr.file.FILE;
import com.fr.general.ComparatorUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils;
import java.util.UUID;
import javax.swing.JOptionPane;
import javax.swing.SwingWorker;
import javax.swing.UIManager;
@ -81,6 +86,11 @@ public class OpenWorker<T> extends SwingWorker<T, Void> {
JOptionPane.ERROR_MESSAGE,
UIManager.getIcon("OptionPane.errorIcon"));
}
if (cause.getCause() instanceof TplLockedException) {
MutilTempalteTabPane.getInstance().closeCurrentTpl();
TemplateTreePane.getInstance().getFileNode().setLock(UUID.randomUUID().toString());
LockInfoDialog.show(null);
}
FineLoggerFactory.getLogger().error(t.getMessage(), t);
return;
}

113
designer-base/src/main/java/com/fr/design/worker/save/SaveFailureHandler.java

@ -0,0 +1,113 @@
package com.fr.design.worker.save;
import com.fr.common.exception.ThrowableHandler;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.utils.TemplateUtils;
import com.fr.file.FileNodeFILE;
import com.fr.file.filetree.FileNode;
import com.fr.general.IOUtils;
import com.fr.report.UnLockedException;
import com.fr.workspace.exception.DiskSpaceFullException;
import com.fr.report.InconsistentLockException;
import java.awt.Frame;
import javax.swing.JOptionPane;
/**
* @author hades
* @version 11.0
* Created by hades on 2021/12/7
*/
public class SaveFailureHandler implements ThrowableHandler {
private static final SaveFailureHandler INSTANCE = new SaveFailureHandler();
public static SaveFailureHandler getInstance() {
return INSTANCE;
}
@Override
public boolean process(Throwable e) {
for (Handler handler : Handler.values()) {
if (handler.process(e)) {
break;
}
}
return true;
}
public enum Handler implements ThrowableHandler {
FullDisk {
@Override
public boolean process(Throwable e) {
if (e.getCause() instanceof DiskSpaceFullException
|| e instanceof DiskSpaceFullException
|| e.getCause().getCause() instanceof DiskSpaceFullException) {
FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine_Design_Template_Save_Failed_By_Full_Disk"),
Toolkit.i18nText("Fine-Design_Basic_Alert"),
JOptionPane.WARNING_MESSAGE,
IOUtils.readIcon("/com/fr/design/images/warnings/warning32.png"));
return true;
}
return false;
}
},
UnLocked {
@Override
public boolean process(Throwable e) {
if (e.getCause() instanceof UnLockedException || e instanceof UnLockedException) {
processByBack(Toolkit.i18nText("Fine_Design_Template_Has_Been_UnLocked"));
return true;
}
return false;
}
},
InconsistentLock {
@Override
public boolean process(Throwable e) {
if (e.getCause() instanceof InconsistentLockException || e instanceof InconsistentLockException) {
processByBack(Toolkit.i18nText("Fine_Design_Template_Save_Failed_By_Lock_Inconsistency"));
return true;
}
return false;
}
},
Other {
@Override
public boolean process(Throwable e) {
boolean minimized = (DesignerContext.getDesignerFrame().getExtendedState() & Frame.ICONIFIED ) != 0;
FineJOptionPane.showMessageDialog(
minimized ? null : DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Design-Basic_Save_Failure"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"),
JOptionPane.ERROR_MESSAGE);
return true;
}
};
protected void processByBack(String tip) {
int option = FineJOptionPane.showOptionDialog(DesignerContext.getDesignerFrame(),
tip,
Toolkit.i18nText("Fine-Design_Basic_Alert"),
JOptionPane.YES_NO_OPTION,
JOptionPane.WARNING_MESSAGE,
IOUtils.readIcon("/com/fr/design/images/warnings/warning32.png"),
new Object[] {Toolkit.i18nText("Fine_Design_Template_SaveAs_Backup"), Toolkit.i18nText("Fine-Design_Basic_Button_Cancel")}, null);
if (option == JOptionPane.YES_OPTION) {
JTemplate<?, ?> template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (template != null) {
TemplateUtils.createAndOpenTemplate(Toolkit.i18nText("Fine_Design_Template_Backup"), new FileNodeFILE(new FileNode(template.getPath(), false)), false);
}
}
}
}
}

11
designer-base/src/main/java/com/fr/design/worker/save/SaveWorker.java

@ -1,8 +1,6 @@
package com.fr.design.worker.save;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.DesignerFrameFileDealerPane;
import com.fr.design.mainframe.EastRegionContainerPane;
@ -10,11 +8,9 @@ import com.fr.design.mainframe.JTemplate;
import com.fr.design.worker.WorkerManager;
import com.fr.general.ComparatorUtils;
import com.fr.log.FineLoggerFactory;
import java.awt.Frame;
import java.util.concurrent.Callable;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import javax.swing.JOptionPane;
import javax.swing.SwingWorker;
/**
@ -55,12 +51,7 @@ public class SaveWorker extends SwingWorker<Boolean, Void> {
} catch (Exception e) {
processResult();
FineLoggerFactory.getLogger().error(e.getMessage(), e);
boolean minimized = (DesignerContext.getDesignerFrame().getExtendedState() & Frame.ICONIFIED ) != 0;
FineJOptionPane.showMessageDialog(
minimized ? null : DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Design-Basic_Save_Failure"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"),
JOptionPane.ERROR_MESSAGE);
SaveFailureHandler.getInstance().process(e);
return;
}
processResult();

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

@ -664,6 +664,16 @@ public class FILEChooserPane extends BasicPane {
fileNameTextField.setFilter(new DefaultCompletionFilter(names));
}
public void disableFileNameTextFiled() {
fileNameTextField.setEditable(false);
fileNameTextField.setEnabled(false);
}
public void enableFileNameTextFiled() {
fileNameTextField.setEditable(true);
fileNameTextField.setEnabled(true);
}
/**
* 移除文件后缀的方法
* 解决cptx文件的另存为操作默认会出现双后缀的bug(xxx.cptx.cpt)

2
designer-base/src/main/java/com/fr/start/BaseDesigner.java

@ -32,6 +32,7 @@ import com.fr.process.engine.core.CarryMessageEvent;
import com.fr.process.engine.core.FineProcessContext;
import com.fr.stable.OperatingSystem;
import com.fr.workspace.base.WorkspaceStatus;
import java.awt.Window;
import java.io.File;
import java.lang.reflect.Method;
@ -84,6 +85,7 @@ public abstract class BaseDesigner extends ToolBarMenuDock {
if (eventPipe != null) {
eventPipe.fire(new CarryMessageEvent(ReportState.STOP.getValue()));
}
EventDispatcher.fire(WorkspaceStatus.Prepared);
collectUserInformation();
}
});

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

5
designer-base/src/main/resources/com/fr/design/images/buttonicon/select_disabled.svg

@ -0,0 +1,5 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M0.5 0.5H1.45833V1H1.5V1.5H0.5V0.5ZM2.375 0.5H3.29167V1.5H2.375V0.5ZM4.20833 0.5H5.125V1.5H4.20833V0.5ZM6.04167 0.5H6.95833V1.5H6.04167V0.5ZM7.875 0.5H8.79167V1.5H7.875V0.5ZM9.70833 0.5H10.625V1.5H9.70833V0.5ZM11.5417 0.5H12.5V1.5H11.5V1H11.5417V0.5ZM0.5 3.5V2.5H1.5V3.5H0.5ZM12.5 2.5V3.5H11.5V2.5H12.5ZM0.5 5.5V4.5H1.5V5.5H0.5ZM12.5 4.5V5.5H11.5V4.5H12.5ZM0.5 7.5V6.5H1.5V7.5H0.5ZM12.5 6.5V7.5H11.5V6.5H12.5ZM0.5 8.5H1.5V9H1.45833V9.5H0.5V8.5ZM3.29167 9.5H2.375V8.5H3.29167V9.5ZM5.125 9.5H4.20833V8.5H5.125V9.5ZM6.95833 9.5H6.04167V8.5H6.95833V9.5ZM8.79167 9.5H7.875V8.5H8.79167V9.5ZM10.625 9.5H9.70833V8.5H10.625V9.5ZM12.5 8.5V9.5H11.5417V9H11.5V8.5H12.5Z" fill="#C2C2C2"/>
<path d="M13.7602 15.0001C13.6857 15.0001 13.6111 15.0001 13.5365 15.0001C13.5351 14.9878 13.5275 14.9838 13.5159 14.9829C13.4597 14.9786 13.407 14.96 13.3549 14.9404C13.171 14.8709 13.0205 14.7576 12.9224 14.5854C12.8273 14.4184 12.7603 14.2374 12.6794 14.0632C12.5792 13.8474 12.4849 13.6289 12.3875 13.4118C12.3159 13.2522 12.243 13.0932 12.1714 12.9336C12.074 12.7165 11.9766 12.4993 11.8808 12.2815C11.8719 12.2612 11.35 12.6864 10.3153 13.5573C10.2385 13.622 10.1238 13.6121 10.0591 13.5353C10.0316 13.5026 10.0165 13.4613 10.0164 13.4186L10.001 7.3649C10.0007 7.26448 10.0819 7.18287 10.1823 7.18262C10.2218 7.18252 10.2603 7.19528 10.2919 7.21898L15.462 11.0966C15.5424 11.1568 15.5587 11.2708 15.4985 11.3512C15.4692 11.3902 15.4254 11.4159 15.377 11.4223C13.9063 11.6183 13.1749 11.723 13.1829 11.7363C13.2803 11.8984 13.3767 12.061 13.4745 12.2229C13.6247 12.4719 13.776 12.7203 13.9265 12.9692C14.0725 13.2107 14.2166 13.4534 14.3643 13.6939C14.4748 13.874 14.5144 14.0685 14.4805 14.275C14.4214 14.635 14.1357 14.9218 13.7808 14.9828C13.7695 14.9847 13.7616 14.9878 13.7602 15.0001Z" fill="#C2C2C2"/>
<path d="M10.1424 7.01206C10.1424 7.05547 10.1424 7.09902 10.1424 7.14242C10.0952 7.14242 10.048 7.14242 10.0008 7.14242C9.98988 6.88542 10.098 7.06584 10.1424 7.01206Z" fill="#C2C2C2"/>
</svg>

After

Width:  |  Height:  |  Size: 2.1 KiB

5
designer-base/src/main/resources/com/fr/design/images/buttonicon/select_normal.svg

@ -0,0 +1,5 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M0.5 0.5H1.45833V1H1.5V1.5H0.5V0.5ZM2.375 0.5H3.29167V1.5H2.375V0.5ZM4.20833 0.5H5.125V1.5H4.20833V0.5ZM6.04167 0.5H6.95833V1.5H6.04167V0.5ZM7.875 0.5H8.79167V1.5H7.875V0.5ZM9.70833 0.5H10.625V1.5H9.70833V0.5ZM11.5417 0.5H12.5V1.5H11.5V1H11.5417V0.5ZM0.5 3.5V2.5H1.5V3.5H0.5ZM12.5 2.5V3.5H11.5V2.5H12.5ZM0.5 5.5V4.5H1.5V5.5H0.5ZM12.5 4.5V5.5H11.5V4.5H12.5ZM0.5 7.5V6.5H1.5V7.5H0.5ZM12.5 6.5V7.5H11.5V6.5H12.5ZM0.5 8.5H1.5V9H1.45833V9.5H0.5V8.5ZM3.29167 9.5H2.375V8.5H3.29167V9.5ZM5.125 9.5H4.20833V8.5H5.125V9.5ZM6.95833 9.5H6.04167V8.5H6.95833V9.5ZM8.79167 9.5H7.875V8.5H8.79167V9.5ZM10.625 9.5H9.70833V8.5H10.625V9.5ZM12.5 8.5V9.5H11.5417V9H11.5V8.5H12.5Z" fill="#8F8F92"/>
<path d="M13.7602 15.0001C13.6857 15.0001 13.6111 15.0001 13.5365 15.0001C13.5351 14.9878 13.5275 14.9838 13.5159 14.9829C13.4597 14.9786 13.407 14.96 13.3549 14.9404C13.171 14.8709 13.0205 14.7576 12.9224 14.5854C12.8273 14.4184 12.7603 14.2374 12.6794 14.0632C12.5792 13.8474 12.4849 13.6289 12.3875 13.4118C12.3159 13.2522 12.243 13.0932 12.1714 12.9336C12.074 12.7165 11.9766 12.4993 11.8808 12.2815C11.8719 12.2612 11.35 12.6864 10.3153 13.5573C10.2385 13.622 10.1238 13.6121 10.0591 13.5353C10.0316 13.5026 10.0165 13.4613 10.0164 13.4186L10.001 7.3649C10.0007 7.26448 10.0819 7.18287 10.1823 7.18262C10.2218 7.18252 10.2603 7.19528 10.2919 7.21898L15.462 11.0966C15.5424 11.1568 15.5587 11.2708 15.4985 11.3512C15.4692 11.3902 15.4254 11.4159 15.377 11.4223C13.9063 11.6183 13.1749 11.723 13.1829 11.7363C13.2803 11.8984 13.3767 12.061 13.4745 12.2229C13.6247 12.4719 13.776 12.7203 13.9265 12.9692C14.0725 13.2107 14.2166 13.4534 14.3643 13.6939C14.4748 13.874 14.5144 14.0685 14.4805 14.275C14.4214 14.635 14.1357 14.9218 13.7808 14.9828C13.7695 14.9847 13.7616 14.9878 13.7602 15.0001Z" fill="#333334"/>
<path d="M10.1424 7.01206C10.1424 7.05547 10.1424 7.09902 10.1424 7.14242C10.0952 7.14242 10.048 7.14242 10.0008 7.14242C9.98988 6.88542 10.098 7.06584 10.1424 7.01206Z" fill="#333334"/>
</svg>

After

Width:  |  Height:  |  Size: 2.1 KiB

BIN
designer-base/src/main/resources/com/fr/design/images/mainframe/lock_template.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

BIN
designer-base/src/main/resources/com/fr/design/images/mainframe/refreh_icon.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

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

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 301 B

BIN
designer-base/src/main/resources/com/fr/design/images/toolbarbtn/lock.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 210 B

BIN
designer-base/src/main/resources/com/fr/design/images/toolbarbtn/unlock.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 208 B

6
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ChartTextAttrPaneWithThemeStyle.java

@ -2,6 +2,7 @@ package com.fr.design.mainframe.chart.gui.style;
import com.fr.chart.base.TextAttr;
import com.fr.design.gui.ibutton.UIButtonGroup;
import com.fr.design.gui.ibutton.UIColorButtonWithAuto;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.TableLayout;
@ -74,6 +75,11 @@ public class ChartTextAttrPaneWithThemeStyle extends ChartTextAttrPane {
textFontPane.setVisible(preButton.getSelectedIndex() == CUSTOM);
}
@Override
protected void initFontColorState() {
setFontColor(new UIColorButtonWithAuto());
}
protected double[] getRowSize() {
double p = TableLayout.PREFERRED;
return new double[]{p, p};

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.mainframe.DesignerContext;
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.general.ComparatorUtils;
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.AttrTooltipSeriesFormat;
import com.fr.plugin.chart.base.format.AttrTooltipValueFormat;
import com.fr.plugin.chart.type.FontAutoType;
import com.fr.stable.StringUtils;
import com.fr.van.chart.designer.TableLayout4VanChartHelper;
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")
});
textAttrPane = new ChartTextAttrPane() {
textAttrPane = new ChartTextAttrPaneWithAuto(FontAutoType.COLOR) {
protected Component[][] getComponents(JPanel buttonPane) {
return new Component[][]{
new Component[]{null, null},

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

@ -25,6 +25,7 @@ import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.FlowLayout;
import java.awt.Point;
import java.awt.Window;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
@ -210,6 +211,16 @@ public abstract class VanChartUIListControlPane extends UIListControlPane implem
public void doCancel() {
setVisible(false);
}
@Override
public void setVisible(boolean b) {
super.setVisible(b);
//把一些可能没隐藏的子弹框隐藏 比如 边框-颜色弹框
for (Window window : getOwnedWindows()) {
window.setVisible(false);
}
}
}
}

14
designer-chart/src/main/java/com/fr/van/chart/funnel/designer/style/VanChartFunnelSeriesPane.java

@ -1,13 +1,13 @@
package com.fr.van.chart.funnel.designer.style;
import com.fr.chart.chartattr.Plot;
import com.fr.design.i18n.Toolkit;
import com.fr.design.gui.ibutton.UIButtonGroup;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.chart.gui.ChartStylePane;
import com.fr.plugin.chart.funnel.FunnelSortType;
import com.fr.plugin.chart.funnel.VanChartFunnelPlot;
import com.fr.van.chart.designer.TableLayout4VanChartHelper;
import com.fr.van.chart.designer.style.series.VanChartAbstractPlotSeriesPane;
@ -51,7 +51,11 @@ public class VanChartFunnelSeriesPane extends VanChartAbstractPlotSeriesPane {
private JPanel createFunnelStylePane() {
useSameSlantAngle = new UIButtonGroup(new String[]{Toolkit.i18nText("Fine-Design_Chart_Use_Same_Slant_Angle"), Toolkit.i18nText("Fine-Design_Chart_Use_Diff_Slant_Angle")});
sort = new UIButtonGroup(new String[]{Toolkit.i18nText("Fine-Design_Chart_Auto_Sort"), Toolkit.i18nText("Fine-Design_Chart_Origin")});
sort = new UIButtonGroup(new String[]{
Toolkit.i18nText("Fine-Design_Chart_Ascending_Sort"),
Toolkit.i18nText("Fine-Design_Chart_Descending_Sort"),
Toolkit.i18nText("Fine-Design_Chart_Origin_Sort")
});
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
@ -78,7 +82,7 @@ public class VanChartFunnelSeriesPane extends VanChartAbstractPlotSeriesPane {
if(plot instanceof VanChartFunnelPlot){
useSameSlantAngle.setSelectedIndex(((VanChartFunnelPlot) plot).isUseSameSlantAngle() ? 0 : 1);
sort.setSelectedIndex(((VanChartFunnelPlot) plot).isSort() ? 0 : 1);
sort.setSelectedIndex(((VanChartFunnelPlot) plot).getSortType().getSortType());
}
}
@ -94,7 +98,7 @@ public class VanChartFunnelSeriesPane extends VanChartAbstractPlotSeriesPane {
if(plot instanceof VanChartFunnelPlot){
((VanChartFunnelPlot) plot).setUseSameSlantAngle(useSameSlantAngle.getSelectedIndex() == 0);
((VanChartFunnelPlot) plot).setSort(sort.getSelectedIndex() == 0);
((VanChartFunnelPlot) plot).setSortType(FunnelSortType.parseSortType(sort.getSelectedIndex()));
}
}
}

5
designer-chart/src/main/java/com/fr/van/chart/pie/style/VanChartPieCategoryLabelContentPane.java

@ -1,13 +1,14 @@
package com.fr.van.chart.pie.style;
import com.fr.design.i18n.Toolkit;
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.plugin.chart.base.AttrTooltipContent;
import com.fr.plugin.chart.base.format.AttrTooltipCategoryFormat;
import com.fr.plugin.chart.base.format.AttrTooltipFormat;
import com.fr.plugin.chart.base.format.AttrTooltipSummaryValueFormat;
import com.fr.plugin.chart.pie.attr.PieCategoryLabelContent;
import com.fr.plugin.chart.type.FontAutoType;
import com.fr.van.chart.designer.component.VanChartLabelContentPane;
import com.fr.van.chart.designer.component.format.CategoryNameFormatPaneWithCheckBox;
import com.fr.van.chart.designer.component.format.SummaryValueFormatPaneWithCheckBox;
@ -86,7 +87,7 @@ public class VanChartPieCategoryLabelContentPane extends VanChartLabelContentPan
}
public JPanel createCommonStylePane() {
setTextAttrPane(new ChartTextAttrPane());
setTextAttrPane(new ChartTextAttrPaneWithAuto(FontAutoType.COLOR));
return getTextAttrPane();
}

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;
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.adapters.layout.FRAbsoluteLayoutAdapter;
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.properties.mobile.MobileBooKMarkUsePropertyUI;
import com.fr.design.fit.DesignerUIModeConfig;
import com.fr.design.form.layout.FRAbsoluteLayout;
import com.fr.design.form.util.FormDesignerUtils;
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.BoundsWidget;
import com.fr.form.ui.container.WLayout;
import com.fr.general.FRScreen;
import com.fr.stable.AssistUtils;
import com.fr.stable.Constants;
@ -34,7 +31,6 @@ import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Rectangle;
import java.awt.Toolkit;
import java.awt.event.ContainerEvent;
import java.awt.event.MouseEvent;
import java.beans.IntrospectionException;
@ -51,9 +47,7 @@ public class XWAbsoluteLayout extends XLayoutContainer {
private int minHeight = WLayout.MIN_HEIGHT;
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);
//由于屏幕分辨率不同,界面上的容器大小可能不是默认的100%,此时拖入组件时,保存的大小按照100%时的计算
protected double containerPercent = 1.0;
private static final double DEFAULT_CONTAINER_PERCENT = 1.0D;
private HashMap<Connector, XConnector> xConnectorMap;
@ -73,8 +67,6 @@ public class XWAbsoluteLayout extends XLayoutContainer {
connector = widget.getConnectorIndex(i);
xConnectorMap.put(connector, new XConnector(connector, this));
}
initPercent(widget);
}
/**
@ -87,36 +79,6 @@ public class XWAbsoluteLayout extends XLayoutContainer {
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() {
// adapter那边交叉三等分、删除都要判断是否对齐,所以间隔转为偶数
int interval = (int) (toData().getCompInterval() * containerPercent);
int interval = (int) (toData().getCompInterval() );
int val = interval / 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
*/
public void updateBoundsWidget(XCreator xCreator) {
WAbsoluteLayout layout = this.toData();
if (xCreator.hasTitleStyle()) {
xCreator = (XLayoutContainer) xCreator.getParent();
}
@ -223,32 +169,33 @@ public class XWAbsoluteLayout extends XLayoutContainer {
}
}
/**
* 更新子组件的Bound
* 这边主要用于绝对布局子组件在适应区域选项时
* 涉及到的不同分辨率下缩放
*
* @param minHeight 最小高度
*/
@Override
public void updateChildBound(int minHeight) {
double prevContainerPercent = DesignerUIModeConfig.getInstance().getDesignScreenByDimension(toData().getDesigningResolution()).getValue() / FormArea.DEFAULT_SLIDER;
if (toData().getCompState() == 0 && !AssistUtils.equals(containerPercent, prevContainerPercent)) {
for (int i = 0; i < this.getComponentCount(); i++) {
XCreator creator = getXCreator(i);
Rectangle rec = new Rectangle(creator.getBounds());
rec.x = (int)Math.round (rec.x / prevContainerPercent * containerPercent);
rec.y = (int)Math.round (rec.y / prevContainerPercent * containerPercent);
rec.height = (int)Math.round (rec.height / prevContainerPercent * containerPercent);
rec.width = (int)Math.round (rec.width / prevContainerPercent * containerPercent);
BoundsWidget wgt = (BoundsWidget) toData().getBoundsWidget(creator.toData());
wgt.setBounds(rec);
creator.setBounds(rec);
creator.updateChildBound(minHeight);
/**
* 更新子组件的Bound
* 这边主要用于绝对布局子组件在适应区域选项时
* 涉及到的不同分辨率下缩放
* 兼容方法老的模板中绝对布局带有分辨率参数的兼容处理
*
* @param minHeight 最小高度
*/
@Override
public void updateChildBound(int minHeight) {
double prevContainerPercent = FRScreen.getFRScreenByDimension(toData().getDesigningResolution()).getValue() / FormArea.DEFAULT_SLIDER;
if (!AssistUtils.equals(DEFAULT_CONTAINER_PERCENT, prevContainerPercent)) {
for (int i = 0; i < this.getComponentCount(); i++) {
XCreator creator = getXCreator(i);
Rectangle rec = new Rectangle(creator.getBounds());
rec.x = (int) Math.round(rec.x / prevContainerPercent);
rec.y = (int) Math.round(rec.y / prevContainerPercent);
rec.height = (int) Math.round(rec.height / prevContainerPercent);
rec.width = (int) Math.round(rec.width / prevContainerPercent);
BoundsWidget wgt = (BoundsWidget) toData().getBoundsWidget(creator.toData());
wgt.setBounds(rec);
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.adapters.layout.FRFitLayoutAdapter;
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.creator.cardlayout.XWCardMainBorderLayout;
import com.fr.design.designer.creator.cardlayout.XWTabFitLayout;
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.fun.WidgetPropertyUIProvider;
import com.fr.design.mainframe.FormArea;
import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.WidgetPropertyPane;
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.FRLogger;
import com.fr.stable.ArrayUtils;
import com.fr.stable.AssistUtils;
import javax.swing.JOptionPane;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.Toolkit;
import java.awt.event.ContainerEvent;
import java.util.ArrayList;
import java.util.Arrays;
@ -46,9 +41,6 @@ public class XWFitLayout extends XLayoutContainer {
private static final long serialVersionUID = 8112908607102660176L;
private static final int EACH_ROW_COUNT = 4;
//由于屏幕分辨率不同,界面上的容器大小可能不是默认的100%,此时拖入组件时,保存的大小按照100%时的计算
protected double containerPercent = 1.0;
// 布局缩小的时候,考虑最小宽高,若挨着右侧或底侧边框的控件缩小后达到最小宽或高,此时容器大小微调下
private int needAddWidth = 0;
private int needAddHeight = 0;
@ -64,20 +56,6 @@ public class XWFitLayout extends XLayoutContainer {
public XWFitLayout(WFitLayout widget, Dimension 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
@ -252,19 +230,16 @@ public class XWFitLayout extends XLayoutContainer {
* @return int[] 横坐标数组
*/
public int[] getHors(boolean isActualSize) {
double perc = isActualSize ? containerPercent : 1.0;
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());
int width = this.getWidth() - margin.getLeft() - margin.getRight();
int containW = (int) (width / perc);
posX.add(containW + margin.getLeft());
for (int i=0, len=this.getComponentCount(); i < len; i++) {
posX.add(width + margin.getLeft());
for (int i = 0, len = this.getComponentCount(); i < len; i++) {
int x = this.getComponent(i).getX();
int finalX = (int) (x / perc);
if (!posX.contains(finalX)) {
posX.add(finalX);
if (!posX.contains(x)) {
posX.add(x);
}
}
Collections.sort(posX);
@ -278,19 +253,16 @@ public class XWFitLayout extends XLayoutContainer {
*
*/
public int[] getVeris(boolean isActualSize) {
double perc = isActualSize ? containerPercent : 1.0;
List<Integer> posY = new ArrayList<Integer>();
// 保存实际大小时,组件大小已经去除内边距,此处也判断下
PaddingMargin margin = isActualSize ? new PaddingMargin(0,0,0,0) : toData().getMargin();
posY.add(margin.getTop());
int height = this.getHeight() - margin.getTop() - margin.getBottom();
int containH = (int) (height / perc);
posY.add(containH + margin.getTop());
posY.add(height + margin.getTop());
for (int i=0, len=this.getComponentCount(); i < len; i++) {
int y = this.getComponent(i).getY();
int finalY = (int) (y / perc);
if (!posY.contains(finalY)) {
posY.add(finalY);
if (!posY.contains(y)) {
posY.add(y);
}
}
Collections.sort(posY);
@ -721,34 +693,6 @@ public class XWFitLayout extends XLayoutContainer {
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
*/
@ -774,7 +718,7 @@ public class XWFitLayout extends XLayoutContainer {
XCreator creator = (XCreator) this.getComponent(index);
BoundsWidget wgt = (BoundsWidget) layout.getBoundsWidget(creator.toData());
// 用当前的显示大小计算后调正具体位置
Rectangle wgtBound = dealWidgetBound(creator.getBounds());
Rectangle wgtBound = creator.getBounds();
Rectangle rec = recalculateWidgetBounds(wgtBound, hors, veris);
wgt.setBounds(rec);
creator.toData().updateChildBounds(rec);
@ -814,7 +758,7 @@ public class XWFitLayout extends XLayoutContainer {
//更新的时候一定要带上backupBound
if (creator.getBackupBound() == null && wgt.getBeforeScaleBounds() != null) {
creator.setBackupBound(dealWgtBound(wgt.getBeforeScaleBounds()));
creator.setBackupBound(wgt.getBeforeScaleBounds());
}
((XWAbsoluteLayout) creator).updateBoundsWidget();
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 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
@ -1218,9 +1144,9 @@ public class XWFitLayout extends XLayoutContainer {
*/
public int getAcualInterval() {
// adapter那边交叉三等分、删除都要判断是否对齐,所以间隔转为偶数
int interval = (int) (toData().getCompInterval()*containerPercent);
int val = interval/2;
return val*2;
int interval = toData().getCompInterval();
int val = interval / 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 rec = ComponentUtils.getRelativeBounds(parent);
WFitLayout wFitLayout = parent.toData();
int minHeight = (int)(MINHEIGHT * wFitLayout.getResolutionScaling());
int minWidth = (int)(MINWIDTH * wFitLayout.getResolutionScaling());
int minHeight = MINHEIGHT;
int minWidth = MINWIDTH;
PaddingMargin margin= wFitLayout.getMargin();
switch (row) {
case 0:

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

@ -1,30 +1,10 @@
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.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;
public enum JFormType {
OLD_TYPE(0, new FormPreview()) {
@Override
public void switchUI() {
AdaptiveSwitchUtil.switch2OldUI();
}
@Override
public void switchUIMode() {
AdaptiveSwitchUtil.switch2OldUIMode();
}
OLD_TYPE(0) {
@Override
public ReportFitAttr obtainFitAttr() {
return FormFitConfig.getInstance().getOldFitAttr();
@ -35,23 +15,9 @@ public enum JFormType {
FormFitConfig.getInstance().setOldFitAttr(attr);
}
@Override
public BasicBeanPane obtainAttrPane(NewJForm newJForm) {
return new ReportFitAttrPane();
}
},
NEW_TYPE(1, new FormAdaptivePreview()) {
@Override
public void switchUI() {
AdaptiveSwitchUtil.switch2NewUI();
}
@Override
public void switchUIMode() {
AdaptiveSwitchUtil.switch2NewUIMode();
}
NEW_TYPE(1) {
@Override
public ReportFitAttr obtainFitAttr() {
return FormFitConfig.getInstance().getNewFitAttr();
@ -62,80 +28,35 @@ public enum JFormType {
FormFitConfig.getInstance().setNewFitAttr(attr);
}
@Override
public BasicBeanPane obtainAttrPane(NewJForm newJForm) {
return new FormFitAttrPane(newJForm);
}
};
private int type;
private boolean newType;
private PreviewProvider defaultPreviewType;
private final int type;
private final boolean newType;
JFormType(int type, PreviewProvider defaultPreviewType) {
JFormType(int type) {
this.type = type;
this.newType = (type == 1);
this.defaultPreviewType = defaultPreviewType;
}
public int getType() {
return type;
}
public boolean isNewType() {
return newType;
}
public PreviewProvider getDefaultPreviewType() {
return defaultPreviewType;
public static JFormType parseFormType(int type) {
for (JFormType formType : values()) {
if (formType.getType() == type) {
return formType;
}
}
return JFormType.OLD_TYPE;
}
public abstract void switchUI();
public abstract void switchUIMode();
public boolean isNewType() {
return newType;
}
public abstract ReportFitAttr obtainFitAttr();
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.Parameter;
import com.fr.design.actions.TemplateParameterAction;
import com.fr.design.designer.beans.AdapterBus;
import com.fr.design.designer.beans.LayoutAdapter;
import com.fr.design.designer.beans.adapters.layout.FRFitLayoutAdapter;
import com.fr.design.designer.beans.events.DesignerEditListener;
import com.fr.design.designer.beans.events.DesignerEvent;
import com.fr.design.designer.creator.*;
import com.fr.design.fit.common.AdaptiveSwitchUtil;
import com.fr.design.fit.common.LayoutTool;
import com.fr.form.fit.NewFormMarkAttr;
import com.fr.design.fit.common.TemplateTool;
import com.fr.design.actions.NewFormMobileAttrAction;
import com.fr.design.designer.creator.XComponent;
import com.fr.design.designer.creator.XCreatorUtils;
import com.fr.design.designer.creator.XElementCase;
import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.creator.XWTitleLayout;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.mainframe.DesignerUIModeConfig;
import com.fr.design.preview.DeveloperPreview;
import com.fr.design.preview.FormAdaptivePreview;
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.JForm;
import com.fr.design.mainframe.WidgetPropertyPane;
import com.fr.design.menu.ShortCut;
import com.fr.design.preview.FormPreview;
import com.fr.design.preview.MobilePreview;
import com.fr.design.utils.ComponentUtils;
import com.fr.file.FILE;
import com.fr.form.FormElementCaseProvider;
import com.fr.form.fit.NewFormMarkAttr;
import com.fr.form.main.Form;
import com.fr.form.main.mobile.FormMobileAttr;
import com.fr.form.ui.ElementCaseEditor;
import com.fr.stable.ArrayUtils;
@ -49,13 +47,13 @@ public class NewJForm extends JForm {
public NewJForm() {
super();
init();
changePaneSize();
}
public NewJForm(Form form) {
super(form);
init();
changePaneSize();
//新建的模板都要加上新表单标志attr
form.addAttrMark(NewFormMarkAttr.createNewFormAttr());
}
public NewJForm(Form form, FILE file, Parameter[] parameters) {
@ -64,51 +62,7 @@ public class NewJForm extends JForm {
public NewJForm(Form form, FILE file) {
super(form, file);
if (DesignerUIModeConfig.getInstance().newUIMode()) {
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);
}
}
init();
}
public JFormType getJFormType() {
@ -119,22 +73,6 @@ public class NewJForm extends JForm {
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() {
this.getFormDesign().addDesignerEditListener(new DesignerEditListener() {
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()};
}
public boolean mobileForm() {
FormMobileAttr mobileAttr = this.getTarget().getFormMobileAttr();
if (mobileAttr.isMobileOnly() && mobileAttr.isAdaptivePropertyAutoMatch()) {
return true;
}
return false;
}
private SwitchAction switchAction;
public UIButton[] createExtraButtons() {
UIButton[] extraButtons = super.createExtraButtons();
return addAdaptiveSwitchButton(extraButtons);
}
private UIButton[] addAdaptiveSwitchButton(UIButton[] extraButtons) {
switchAction = new SwitchAction();
return ArrayUtils.addAll(extraButtons, new UIButton[]{switchAction.getToolBarButton()});
SwitchAction switchAction = new SwitchAction(this);
return ArrayUtils.addAll(extraButtons, switchAction.getToolBarButton());
}
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;
import com.fr.design.data.DesignTableDataManager;
import com.fr.design.fit.DesignerUIModeConfig;
import com.fr.design.fit.NewJForm;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.JForm;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.preview.FormAdaptivePreview;
import com.fr.design.preview.FormPreview;
import com.fr.file.FILE;
import com.fr.file.MemFILE;
import com.fr.form.fit.NewFormMarkAttr;
import com.fr.form.main.Form;
import com.fr.form.main.WidgetGather;
import com.fr.form.ui.Widget;
@ -33,25 +32,10 @@ public class AdaptiveSwitchUtil {
}
public static void switch2NewUI() {
switch2NewUIMode();
reload();
}
public static void switch2NewUIMode() {
DesignerUIModeConfig.getInstance().setNewUIMode();
}
public static void switch2OldUI() {
switch2OldUIMode();
reload();
}
public static void switch2OldUIMode() {
DesignerUIModeConfig.getInstance().setOldUIMode();
}
public static void reload() {
/**
* 新老表单转换的方法
*/
public static void switchReload() {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
@ -61,15 +45,15 @@ public class AdaptiveSwitchUtil {
return;
}
JTemplate<?, ?> old = TemplateTool.getCurrentEditingTemplate();
if (old == null || !(old instanceof JForm)) {
if (!(old instanceof NewJForm)) {
return;
}
JTemplate<?, ?> template = createNewJTemplate(old);
JTemplate<?, ?> template = createNewJTemplate((NewJForm) old);
if (template != null) {
DesignTableDataManager.closeTemplate(old);
TemplateTool.resetTabPaneEditingTemplate(template);
TemplateTool.activeAndResizeTemplate(template);
setPreviewType();
setPreviewType(template);
}
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage());
@ -83,14 +67,12 @@ public class AdaptiveSwitchUtil {
/**
* @Description: 设置预览方式
* @return: 新创建的模板
* @Author: Henry.Wang
* @date: 2020/10/13 14:08
*/
private static void setPreviewType() {
JTemplate jTemplate = TemplateTool.getCurrentEditingTemplate();
private static void setPreviewType(JTemplate jTemplate) {
if (jTemplate != null) {
if (DesignerUIModeConfig.getInstance().newUIMode()) {
if (TemplateTool.isNewJForm(jTemplate)) {
jTemplate.setPreviewType(new FormAdaptivePreview());
} else {
jTemplate.setPreviewType(new FormPreview());
@ -99,29 +81,30 @@ public class AdaptiveSwitchUtil {
}
/**
* @param oldForm 以前的模板
* @Description: 创建模板
* @param old 以前的模板
* @return: 新创建的模板
* @Author: Henry.Wang
* @date: 2020/9/6 14:08
*/
public static JTemplate<?, ?> createNewJTemplate(JTemplate<?, ?> old) {
JTemplate<?, ?> template;
template = createNewJTemplateInternal(old);
if (template instanceof NewJForm) {
NewJForm jForm = ((NewJForm) template);
//如果是从旧的设计模板转化为新的设计模式,并且不是全局配置的模板。则更新新模板的Pc端自适应属性
if (DesignerUIModeConfig.getInstance().newUIMode() && jForm.getTarget().getReportFitAttr() != null && isSwitchJFromIng()) {
jForm.getTarget().setReportFitAttr(shiftReportFitAttr(old, jForm.getTarget().getReportFitAttr().isFitFont()));
}
processAbsoluteLayoutCompatible(jForm.getTarget());
TemplateTool.saveForm(jForm);
public static JTemplate<?, ?> createNewJTemplate(NewJForm oldForm) {
NewJForm newJForm = createNewJTemplateInternal(oldForm);
if (newJForm == null) {
return null;
}
//如果是从旧的设计模板转化为新的设计模式,并且不是全局配置的模板。则更新新模板的Pc端自适应属性
if (newJForm.getTarget().getReportFitAttr() != null && newJForm.isNewJFrom()) {
//修改自适应属性
newJForm.getTarget().setReportFitAttr(shiftReportFitAttr(oldForm, newJForm.getTarget().getReportFitAttr().isFitFont()));
//修改绝对布局中的缩放属性
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() {
@Override
public void dealWith(Widget widget) {
@ -141,25 +124,28 @@ public class AdaptiveSwitchUtil {
}
/**
* @Description: 创建模板核心方法
* @param old 以前的方法
* @Description: 创建模板核心方法
* @return: 新创建的模板
* @Author: Henry.Wang
* @date: 2020/9/6 14:09
*/
private static JTemplate<?, ?> createNewJTemplateInternal(JTemplate<?, ?> old) {
private static NewJForm createNewJTemplateInternal(JTemplate<?, ?> old) {
FILE file = old.getEditingFILE();
if ((file instanceof MemFILE) || !old.isSaved()) {
if (old instanceof NewJForm) {
TemplateTool.resetAbsoluteBodySize((NewJForm) old);
}
TemplateTool.saveForm(old);
}
if (old.getTarget() instanceof Form) {
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) {
FineLoggerFactory.getLogger().error(e, e.getMessage());
return null;
@ -170,46 +156,43 @@ public class AdaptiveSwitchUtil {
}
/**
* @Description: 老模板切换到新模板的属性配置转换
* 1绝对布局-适应区域--双向自适应
* 2自适应布局-双向自适应--双向自适应
* 3自适应布局-横向自适应--横向自适应
* 4绝对布局-固定大小--不自适应
*
* @param old
* @param fitFont 字体是否自适应
* @Description: 老模板切换到新模板的属性配置转换
* 1绝对布局-适应区域--双向自适应
* 2自适应布局-双向自适应--双向自适应
* 3自适应布局-横向自适应--横向自适应
* 4绝对布局-固定大小--不自适应
*
* @return:
* @Author: Henry.Wang
* @date: 2020/9/6 14:01
*/
private static ReportFitAttr shiftReportFitAttr(JTemplate old, boolean fitFont) {
if (old instanceof JForm && DesignerUIModeConfig.getInstance().newUIMode()) {
JForm jForm = (JForm) old;
try {
int layoutType = LayoutTool.getFormLayoutType(jForm);
int compState = -1;
//自适应布局
if (layoutType == 0) {
compState = ((WFitLayout) jForm.getFormDesign().getRootComponent().toData()).getCompState();
if (compState == WFitLayout.STATE_FULL) {
return new ReportFitAttr(2, fitFont);
} else if (compState == WFitLayout.STATE_ORIGIN) {
return new ReportFitAttr(1, fitFont);
}
} else if (layoutType == 1) {//绝对布局
Widget widget = ((CRBoundsWidget) jForm.getFormDesign().getRootComponent().toData().getWidget(0)).getWidget();
if (widget instanceof WAbsoluteLayout) {
compState = ((WAbsoluteLayout) widget).getCompState();
}
if (compState == WAbsoluteLayout.STATE_FIT) {
return new ReportFitAttr(2, fitFont);
} else if (compState == WAbsoluteLayout.STATE_FIXED) {
return new ReportFitAttr(3, fitFont);
}
private static ReportFitAttr shiftReportFitAttr(NewJForm old, boolean fitFont) {
try {
int layoutType = LayoutTool.getFormLayoutType(old);
int compState = -1;
//自适应布局
if (layoutType == 0) {
compState = ((WFitLayout) old.getFormDesign().getRootComponent().toData()).getCompState();
if (compState == WFitLayout.STATE_FULL) {
return new ReportFitAttr(2, 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();
if (widget instanceof WAbsoluteLayout) {
compState = ((WAbsoluteLayout) widget).getCompState();
}
if (compState == WAbsoluteLayout.STATE_FIT) {
return new ReportFitAttr(2, 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;
}

1266
designer-form/src/main/java/com/fr/design/fit/common/BaseUtils.java

File diff suppressed because it is too large Load Diff

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.XWCardMainBorderLayout;
import com.fr.design.fit.NewJForm;
import com.fr.design.mainframe.FormArea;
import com.fr.design.mainframe.JForm;
import com.fr.design.utils.gui.LayoutUtils;
import com.fr.form.ui.container.WAbsoluteBodyLayout;
import com.fr.form.ui.container.WFitLayout;
import com.fr.form.ui.container.WLayout;
import com.fr.form.ui.widget.CRBoundsWidget;
import com.fr.general.FRScreen;
import com.fr.log.FineLoggerFactory;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.Toolkit;
/**
* @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;
}
}

2030
designer-form/src/main/java/com/fr/design/fit/common/NewFormStyle.java

File diff suppressed because it is too large Load Diff

20
designer-form/src/main/java/com/fr/design/fit/common/NewUIModeAutoChangeLine.java

@ -0,0 +1,20 @@
package com.fr.design.fit.common;
import com.fr.base.DefaultAutoChangeLine;
import com.fr.base.Style;
import com.fr.stable.unit.UNIT;
import java.awt.Font;
import java.util.List;
public class NewUIModeAutoChangeLine extends DefaultAutoChangeLine {
@Override
public List<String> textAutoChangeLine(String text, Font font, Style style, UNIT unitWidth, int resolution) {
return autoChangeLine(text, font, style, unitWidth, resolution);
}
protected double calculateShowWidth(double paintWidth, Style style, int resolution) {
return paintWidth - style.getPaddingLeft() - style.getPaddingRight() - style.getBorderLeftWidth();
}
}

69
designer-form/src/main/java/com/fr/design/fit/common/NewUIModeRotationDraw.java

@ -0,0 +1,69 @@
package com.fr.design.fit.common;
import com.fr.base.BaseUtils;
import com.fr.base.DefaultRotationTextDrawProvider;
import com.fr.base.GraphHelper;
import com.fr.base.Style;
import com.fr.design.mainframe.PX;
import com.fr.stable.Constants;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics2D;
import java.util.List;
public class NewUIModeRotationDraw extends DefaultRotationTextDrawProvider {
@Override
public void drawRotationText(Graphics2D g2d, String text, Style style, Font rfont, int width, int height, int horizontalAlignment, int resolution) {
FontMetrics cellFM = GraphHelper.getFontMetrics(rfont);
List lineTextList = BaseUtils.getLineTextList(text, style, rfont, height, width, resolution, new NewUIModeAutoChangeLine());
drawRotationText(g2d, lineTextList, style, cellFM, width, height, horizontalAlignment, resolution);
}
protected int calculateTextWidth(int width, Style style) {
return width - style.getPaddingRight();
}
protected double calculateTextX(Style style, int width, int textWidth, int horizontalAlignment, int resolution) {
double textX = padding2PixExcludeRight(style.getPaddingLeft(), resolution);
if (horizontalAlignment == Constants.CENTER) {
textX += (width - textWidth - textX) / 2f;
} else if (horizontalAlignment == Constants.RIGHT) {
textX = width - style.getPaddingRight() - textWidth;
}
return textX;
}
protected int toPXWithResolution(double pt, int resolution) {
return (int) PX.toPixWithResolution(pt, resolution);
}
protected double padding2PixExcludeRight(int padding, int resolution) {
return PX.toPixWithResolution(padding, resolution);
}
protected int calculateTextY(Style style, int height, int textHeight, int textAscent, List lineTextList, int resolution) {
// 计算Y的高度.
int textY = 0;
int textAllHeight = textHeight * lineTextList.size();
double spacingBefore = toPXWithResolution(style.getSpacingBefore(), resolution);
double spacingAfter = toPXWithResolution(style.getSpacingAfter(), resolution);
double lineSpacing = toPXWithResolution(style.getLineSpacing(), resolution);
textAllHeight += spacingBefore + spacingAfter + lineSpacing * lineTextList.size();
if (style.getVerticalAlignment() == Constants.TOP) {
} else if (style.getVerticalAlignment() == Constants.CENTER) {
if (height > textAllHeight) {// 如果所有文本的高度小于当前可以绘区域的高度,就从0开始画字符.
textY = (height - textAllHeight) / 2;
}
} else if (style.getVerticalAlignment() == Constants.BOTTOM) {
if (height > textAllHeight) {
textY = height - textAllHeight;
}
}
textY += textAscent;// 在绘画的时候,必须添加Ascent的高度.
textY += spacingBefore + lineSpacing;//james:加上"段前间距"+“行间距”
return textY;
}
}

835
designer-form/src/main/java/com/fr/design/fit/common/PaintUtils.java

@ -1,835 +0,0 @@
/*
* Copyright(c) 2001-2010, FineReport Inc, All Rights Reserved.
*/
package com.fr.design.fit.common;
import com.fr.base.AutoChangeLineAndDrawManager;
import com.fr.base.BaseFormula;
import com.fr.base.BaseUtils;
import com.fr.base.GraphHelper;
import com.fr.base.ImageProvider;
import com.fr.base.Painter;
import com.fr.base.Style;
import com.fr.base.Utils;
import com.fr.base.background.ColorBackground;
import com.fr.base.chart.BaseChartCollection;
import com.fr.base.chart.result.WebChartIDInfo;
import com.fr.code.BarcodeImpl;
import com.fr.code.bar.BarcodeException;
import com.fr.code.bar.core.BarCodeUtils;
import com.fr.code.bar.core.BarcodeAttr;
import com.fr.data.DataUtils;
import com.fr.data.PresentationType;
import com.fr.data.condition.ListCondition;
import com.fr.file.ResultChangeWhenExport;
import com.fr.form.ui.Widget;
import com.fr.general.Background;
import com.fr.general.ComparatorUtils;
import com.fr.general.FRFont;
import com.fr.general.ImageWithSuffix;
import com.fr.log.FineLoggerFactory;
import com.fr.plugin.ExtraClassManager;
import com.fr.report.cell.CellElement;
import com.fr.report.cell.FloatElement;
import com.fr.report.cell.TemplateCellElement;
import com.fr.report.cell.cellattr.CellExpandAttr;
import com.fr.report.cell.cellattr.CellGUIAttr;
import com.fr.report.cell.cellattr.core.CellUtils;
import com.fr.report.cell.cellattr.core.ResultSubReport;
import com.fr.report.cell.cellattr.core.group.DSColumn;
import com.fr.report.core.Html2ImageUtils;
import com.fr.report.core.ReportUtils;
import com.fr.script.Calculator;
import com.fr.stable.Constants;
import com.fr.stable.CoreConstants;
import com.fr.stable.StringUtils;
import com.fr.stable.bridge.ObjectHolder;
import com.fr.stable.fun.AutoChangeLineAndDrawProcess;
import com.fr.stable.fun.FontProcessor;
import com.fr.stable.html.Tag;
import com.fr.stable.unit.FU;
import com.fr.stable.unit.PT;
import com.fr.stable.unit.UNIT;
import com.fr.stable.web.Repository;
import javax.swing.ImageIcon;
import java.awt.AlphaComposite;
import java.awt.Color;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.Paint;
import java.awt.Rectangle;
import java.awt.font.TextAttribute;
import java.awt.geom.GeneralPath;
import java.awt.image.BufferedImage;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;
/**
* The util for paint.
*/
public class PaintUtils {
// Add by Denny
public static final int CELL_MARK_SIZE = 6;
public static final Color CELL_HIGHT_LIGHT_MARK_COLOR = new Color(255, 0, 55);
public static final Color CELL_PRESENT_MARK_COLOR = new Color(0, 255, 200);
public static final Color CELL_PAGINATION_MARK_COLOR = new Color(55, 255, 0);
public static final Color CELL_RESULT_MARK_COLOR = new Color(200, 0, 255);
public static final Color CELL_CONDITION_FILTER_MARK_COLOR = new Color(255, 200, 0);
public static final Color CELL_PARAMETER_FILTER_MARK_CONLR = new Color(0, 55, 255);
public static final Color CELL_DIRECTION_MARK_COLOR = Color.gray;
private static final int UNIT_SIZE = 4;
//原值是15,矩形线条会缺失,加1px绘制没问题。这地方有水印,但是貌似不是水印影响,未找到线条被挡住的原因
private static final int WIDGET_WIDTH = 16;
private static final int WIDGET_HEIGHT = 16;
// Suppresses default constructor, ensuring non-instantiability.
private PaintUtils() {
}
// font attributes map cache
private static Hashtable fontAttributeMapCache = new Hashtable();
/*
* 用于在Grid里面画CellElement的Content + Background
*
* 不画Border,是因为在Grid里面先画所有单元格的Content + Background,再画所有单元格的Border(peter认为这可以提高速度)
*/
public static void paintGridCellContent(Graphics2D g2d, TemplateCellElement cell, int width, int height, int resolution) {
int cell_mark_size = CELL_MARK_SIZE;
// denny_Grid
// 左上角: 条件高亮, 形态
int leftUpCount = 0;
int rightUpCount = 0;
int leftDownCount = 0;
GraphHelper.applyRenderingHints(g2d);
if (paintHighlightGroupMarkWhenExsit(g2d, cell, leftUpCount)) {
leftUpCount++;
}
if (paintPresentMarkWhenExsit(g2d, cell, leftUpCount)) {
leftUpCount++;
}
if (paintPaginationMarkWhenExsit(g2d, cell, width, rightUpCount)) {
rightUpCount++;
}
paintWidgetMarkWhenExsit(g2d, cell, width, height);
paintExpandMarkWhenExsit(g2d, cell);
Object value = cell.getValue();
if (value == null) {// 先判断是否是空.
return;
}
if (paintResultMarkWhenExsit(g2d, value, width, rightUpCount)) {
rightUpCount++;
}
if (paintDSColumnParametermarkWhenExsit(g2d, value, height, leftDownCount)) {
leftDownCount++;
}
if (paintDSColumnConditionmarkWhenExsit(g2d, value, height, leftDownCount)) {
leftDownCount++;
}
// 画value,但因为是在Grid里面画,所以画Formula.content
if (value instanceof BaseFormula) {
value = ((BaseFormula) value).getContent();
}
if (value instanceof ImageWithSuffix) {
value = ((ImageWithSuffix) value).getFineImage();
}
if (value instanceof BaseChartCollection) {
value = ((BaseChartCollection) value).createResultChartPainterWithOutDealFormula(Calculator.createCalculator(), WebChartIDInfo.createEmptyDesignerInfo(), width, height);
}
// Carl:当是子报表时,在格子里画一个子报表的图
/*
* alex:TODO 此处在Grid里面画ChartCollection和SubReport都只画一个图表,这种做法,很不雅
*/
if (value instanceof ResultSubReport) {
value = BaseUtils.readImage("/com/fr/base/images/report/painter/subReport.png");
GraphHelper.paintImage(g2d, width, height, (Image) value, Constants.IMAGE_CENTER,
BaseUtils.getAlignment4Horizontal(cell.getStyle(), value), cell.getStyle().getVerticalAlignment(),
width > 16 ? 16 : width, height > 16 ? 16 : height);
} else {
renderContent(g2d, value, cell.getStyle(), width, height, resolution);
}
}
private static void renderContent(Graphics2D g2d, Object value, Style style, int width, int height, int resolution) {
if (value != null && width != 0 && height != 0) {
if (style == null) {
style = Style.DEFAULT_STYLE.deriveImageLayout(1);
}
if (value instanceof BaseFormula) {
value = ((BaseFormula) value).getResult();
}
if (value instanceof Painter) {
((Painter)value).paint(g2d, width, height, resolution, style);
} else if (value instanceof ImageProvider) {
Style.paintImageContent(g2d, ((ImageProvider) value).getImage(), style, width, height, resolution);
} else if (value instanceof Image) {
Style.paintImageContent(g2d, (Image) value, style, width, height, resolution);
} else {
String var6 = Style.valueToText(value, style.getFormat());
NewFormStyle.paintCellStyleString2(g2d, width, height, var6, style, resolution);
}
}
}
private static boolean paintHighlightGroupMarkWhenExsit(Graphics2D g2d, TemplateCellElement cell, int left_up_count) {
if (cell.getHighlightGroup() != null && cell.getHighlightGroup().size() > 0) {
Paint oldPaint = g2d.getPaint();
g2d.setPaint(CELL_HIGHT_LIGHT_MARK_COLOR);
GeneralPath polyline = new GeneralPath(GeneralPath.WIND_EVEN_ODD, 3);
polyline.moveTo(0, 0);
polyline.lineTo(0, CELL_MARK_SIZE);
polyline.lineTo(CELL_MARK_SIZE, 0);
GraphHelper.fill(g2d, polyline);
g2d.setPaint(oldPaint);
return true;
}
return false;
}
private static boolean paintPresentMarkWhenExsit(Graphics2D g2d, TemplateCellElement cell, int left_up_count) {
if (cell.getPresent() != null) {
Paint oldPaint = g2d.getPaint();
g2d.setPaint(CELL_PRESENT_MARK_COLOR);
GeneralPath polyline = new GeneralPath(GeneralPath.WIND_EVEN_ODD, 3);
polyline.moveTo(0 + left_up_count * CELL_MARK_SIZE, 0);
polyline.lineTo(0 + left_up_count * CELL_MARK_SIZE, 6);
polyline.lineTo(CELL_MARK_SIZE + left_up_count * CELL_MARK_SIZE, 0);
GraphHelper.fill(g2d, polyline);
g2d.setPaint(oldPaint);
return true;
}
return false;
}
private static boolean paintPaginationMarkWhenExsit(Graphics2D g2d, TemplateCellElement cell, int width, int ringt_up_count) {
// 右上角: 标记是否有分页
if (isRightTopMarker(cell)) {
Paint oldPaint = g2d.getPaint();
g2d.setPaint(CELL_PAGINATION_MARK_COLOR);
GeneralPath polyline = new GeneralPath(GeneralPath.WIND_EVEN_ODD, 3);
polyline.moveTo(width - 1 - ringt_up_count * CELL_MARK_SIZE, 0);
polyline.lineTo(width - 1 - ringt_up_count * CELL_MARK_SIZE, CELL_MARK_SIZE);
polyline.lineTo(width - 1 - (ringt_up_count + 1) * CELL_MARK_SIZE, 0);
GraphHelper.fill(g2d, polyline);
g2d.setPaint(oldPaint);
return true;
}
return false;
}
private static boolean isRightTopMarker(TemplateCellElement cell) {
return cell.getCellPageAttr() != null && (cell.getCellPageAttr().isPageAfterColumn()
|| cell.getCellPageAttr().isPageBeforeColumn()
|| cell.getCellPageAttr().isPageAfterRow()
|| cell.getCellPageAttr().isPageBeforeRow());
}
private static boolean paintResultMarkWhenExsit(Graphics2D g2d, Object value, int width, int ringt_up_count) {
//右上角标记是否自定义显示
if (value instanceof DSColumn && ((DSColumn) value).getResult() != null) {
if (!ComparatorUtils.equals(((DSColumn) value).getResult(), "$$$")) {
Paint oldPaint = g2d.getPaint();
g2d.setPaint(CELL_RESULT_MARK_COLOR);
GeneralPath polyline = new GeneralPath(GeneralPath.WIND_EVEN_ODD, 3);
polyline.moveTo(width - ringt_up_count * CELL_MARK_SIZE - 1, 0);
polyline.lineTo(width - ringt_up_count * CELL_MARK_SIZE - 1, CELL_MARK_SIZE);
polyline.lineTo(width - (ringt_up_count + 1) * CELL_MARK_SIZE - 1, 0);
GraphHelper.fill(g2d, polyline);
g2d.setPaint(oldPaint);
return true;
}
}
return false;
}
private static void paintWidgetMarkWhenExsit(Graphics2D g2d, TemplateCellElement cell, int width, int height) {
// 右下角:是否填报, 设置为4时,三角太小了,不知何故,设置为6
if (cell.getWidget() != null) {
Widget widget = cell.getWidget();
Image img = ((ImageIcon) ReportUtils.createWidgetIcon(widget.getClass())).getImage();
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, 0.67f));
g2d.drawImage(img, width - 15, height - 15, WIDGET_WIDTH, WIDGET_HEIGHT, null);
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER));
}
}
private static void paintExpandMarkWhenExsit(Graphics2D g2d, TemplateCellElement cell) {
CellExpandAttr cellExpandAttr = cell.getCellExpandAttr();
if (cellExpandAttr != null) {
if (cellExpandAttr.getDirection() == Constants.TOP_TO_BOTTOM) {
Paint oldPaint = g2d.getPaint();
g2d.setPaint(CELL_DIRECTION_MARK_COLOR);
GraphHelper.drawLine(g2d, 2, 0, 2, 5);
GraphHelper.drawLine(g2d, 2, 5, 0, 2);
GraphHelper.drawLine(g2d, 2, 5, 4, 2);
g2d.setPaint(oldPaint);
} else if (cellExpandAttr.getDirection() == Constants.LEFT_TO_RIGHT) {
Paint oldPaint = g2d.getPaint();
g2d.setPaint(CELL_DIRECTION_MARK_COLOR);
GraphHelper.drawLine(g2d, 0, 2, 5, 2);
GraphHelper.drawLine(g2d, 5, 2, 2, 0);
GraphHelper.drawLine(g2d, 5, 2, 2, 4);
g2d.setPaint(oldPaint);
}
}
}
private static boolean paintDSColumnConditionmarkWhenExsit(Graphics2D g2d, Object value, int height, int left_dowm_count) {
// 左下角:数据列(DSColumn)相关:比如条件过滤
if (value instanceof DSColumn && ((DSColumn) value).getCondition() != null) {
if (((DSColumn) value).getCondition() instanceof ListCondition &&
((ListCondition) ((DSColumn) value).getCondition()).getJoinConditionCount() == 0) {
// do nothing
} else {
Paint oldPaint = g2d.getPaint();
g2d.setPaint(CELL_CONDITION_FILTER_MARK_COLOR);
GeneralPath polyline = new GeneralPath(GeneralPath.WIND_EVEN_ODD, 3);
polyline.moveTo(0 + left_dowm_count * CELL_MARK_SIZE, height - 1);
polyline.lineTo((left_dowm_count + 1) * CELL_MARK_SIZE + 1, height - 1);
polyline.lineTo(0 + left_dowm_count * CELL_MARK_SIZE, height - 2 - CELL_MARK_SIZE);
GraphHelper.fill(g2d, polyline);
g2d.setPaint(oldPaint);
return true;
}
}
return false;
}
private static boolean paintDSColumnParametermarkWhenExsit(Graphics2D g2d, Object value, int height, int left_dowm_count) {
// 左下角:动态注入参数
if (value instanceof DSColumn && ((DSColumn) value).getParameters() != null) {
if (((DSColumn) value).getParameters().length > 0) {
Paint oldPaint = g2d.getPaint();
g2d.setPaint(CELL_PARAMETER_FILTER_MARK_CONLR);
GeneralPath polyline = new GeneralPath(GeneralPath.WIND_EVEN_ODD, 3);
polyline.moveTo(0 + left_dowm_count * CELL_MARK_SIZE, height - 1);
polyline.lineTo((left_dowm_count + 1) * CELL_MARK_SIZE + 1, height - 1);
polyline.lineTo(0 + left_dowm_count * CELL_MARK_SIZE, height - 2 - CELL_MARK_SIZE);
GraphHelper.fill(g2d, polyline);
g2d.setPaint(oldPaint);
return true;
}
}
return false;
}
/*
* 画悬浮元素
*
* 仅根据宽度 + 高度画
*/
//b:此方法在grid和tohtml的时候都被调用,所以对formula会有冲突,暂时这么改,应该考虑分开的,也可以根据result来判断,但是那么写好像不妥
public static void paintFloatElement(Graphics2D g2d, FloatElement flotEl, int width, int height, int resolution) {
Style.paintBackground(g2d, flotEl.getStyle(), width, height);
Object value = flotEl.getValue();
if (value instanceof BaseFormula) {
value = ((BaseFormula) value).getContent();
}
if (value instanceof BaseChartCollection) {
value = ((BaseChartCollection) value).createResultChartPainterWithOutDealFormula(Calculator.createCalculator(), WebChartIDInfo.createEmptyDesignerInfo(), width, height);
}
//图片需要切割一下
if (value instanceof Image) {
value = CellUtils.value2ImageWithBackground(value, resolution, flotEl.getStyle(), width, height);
}
Style.paintContent(g2d, value, flotEl.getStyle(), width, height, resolution);
Style.paintBorder(g2d, flotEl.getStyle(), width, height);
}
/*
* 画悬浮元素flotEl
*
* 也就是画三个东西:背景 + 内容 + 边框
*/
public static void paintFloatElement(Graphics2D g2d, FloatElement flotEl, Rectangle paintRectangle, Rectangle clipRectangle, int resolution) {
// 画悬浮元素的背景
Style.paintBackground(g2d, flotEl.getStyle(), paintRectangle, clipRectangle);
Object value = flotEl.getValue();
if (value instanceof ResultChangeWhenExport) {
value = ((ResultChangeWhenExport) value).changeThis();
}
// 画悬浮元素的内容
Style.paintContent(g2d, value, resolution, flotEl.getStyle(), paintRectangle, clipRectangle);
// 画悬浮元素的边框
Style.paintBorder(g2d, flotEl.getStyle(), paintRectangle, clipRectangle);
}
public static void paintHTMLContent(Graphics2D g2d, String value, int resolution, Style style, Rectangle paintRectangle, Rectangle clipRectangle) {
Style.paintContent(g2d, createHTMLContentBufferedImage(value, paintRectangle, 0, 0, style), resolution, style, paintRectangle, clipRectangle);
}
public static void paintTag(Painter painter, Repository repo, int width, int height, Style style, Tag tag) {
painter.paintTag(repo, width, height, style, tag);
}
/**
* 如果用户希望以HTML方式展示String这个时候先value变成图片
*
* @param value
* @param paintRectangle 绘制范围
* @param x x坐标
* @param y y坐标
* @param style 当前格子样式
* @return BufferedImage 返回图片.
*/
public static BufferedImage createHTMLContentBufferedImage(String value, Rectangle paintRectangle, int x, int y, Style style) {
return Html2ImageUtils.createHTMLContentBufferedImage(value, paintRectangle, x, y, style);
}
/**
* see <code>BaseUtils.getLineTextList</code>, 等于BaseUtils.getLineTextList().size()
* Denny: 为了提高速度和性能才单独拿出来的
* TODO: 重构
*
* @param text 文本
* @param style 样式
* @param paintWidth 单元格宽度
* @return paintWidth 单位为PT
*/
public static int getLineTextCount(String text, Style style, UNIT paintWidth) {
if (style.getRotation() != 0) {
return 1;
}
if (style.getTextStyle() != Style.TEXTSTYLE_WRAPTEXT) {
return dealNotWrapTextCount(text.toCharArray());
} else {// 自动换行
return dealWrapTextCount(text, style, paintWidth);
}
}
private static int dealNotWrapTextCount(char[] text_chars) {
boolean remain_chars = false;
int count = 0;
for (int t = 0; t < text_chars.length; t++) {
if (text_chars[t] == '\\') {// 判断是否是 "\n"
if (t + 1 < text_chars.length && text_chars[t + 1] == 'n') {
// 是"\n"字符串,但不是换行符.
t++;
count++;
if (remain_chars) {
remain_chars = false;
}
} else {
if (!remain_chars) {
remain_chars = true;
}
}
} else if (text_chars[t] == '\n' || (text_chars[t] == '\r' && t + 1 < text_chars.length - 1 && text_chars[t + 1] != '\n')) {
count++;
if (remain_chars) {
remain_chars = false;
}
} else {
if (!remain_chars) {
remain_chars = true;
}
}
}
// 最后一个
if (remain_chars) {
count++;
}
return count;
}
// 自动换行
//neil:style里面, 默认值padding right = 2时, 默认不生效, 这边算行高时也不要计算入内
//临时处理, 去掉左边框线, 因为浏览器计算时需要考虑左边框线宽度, 但这边还是存在问题的
//同样需要考虑的是导出和web端展示, padding计算方式也不一致.
private static int dealWrapTextCount(String text, Style style, UNIT unitWidth) {
AutoChangeLineAndDrawProcess process = AutoChangeLineAndDrawManager.getProcess();
if (process != null) {
return process.getAutoChangeLineCount(text, new ObjectHolder(style), unitWidth);
}
int count = 0;
char[] text_chars = text.toCharArray();
FontMetrics fontMetrics = getFontMetrics(style);
double paintWidth = unitWidth.toPixD(Constants.FR_PAINT_RESOLUTION);
double width = paintWidth - style.getPaddingLeft() - (style.getPaddingRight() == Style.DEFAULT_PADDING ? 0 : style.getPaddingRight()) - style.getBorderLeftWidth();
boolean remain_lineText = false;
int lineTextWidth = 0;
int wordWidth = 0;
for (int t = 0, len = text_chars.length; t < len; t++) {
if (t != 0 && BaseUtils.isNumOrLetter(text_chars[t]) && BaseUtils.isNumOrLetter(text_chars[t - 1])) {
if (wordWidth + fontMetrics.charWidth(text_chars[t]) > width) {
if (lineTextWidth > 0) {
count++;
remain_lineText = false;
lineTextWidth = 0;
}
count++;
wordWidth = 0;
}
wordWidth += fontMetrics.charWidth(text_chars[t]);
} else if (isSwitchLine(text_chars, t) || isLN(text_chars, t)) {// 判断是否是 "\n"
if (isLN(text_chars, t)) {
t++;// 忽略'n'字符.// 是"\n"字符串,但不是换行符,依然需要换行.
}
if (lineTextWidth + wordWidth > width && remain_lineText) {
count += 2;
} else {
count++;
}
remain_lineText = false;
lineTextWidth = 0;
wordWidth = 0;
} else {
if (text_chars[t] == '\\' && t + 1 < text_chars.length && text_chars[t + 1] == '\\') {// 判断是否是转义字符'\'
t++;// _denny: 增加了转义字符'\\'用来表示\,使"\n"可以输入
}
if (lineTextWidth + wordWidth > width && remain_lineText) {
count++;
lineTextWidth = isPunctuationAtLineHead(t, text_chars) ? dealLineWidthWithPunctuation(t, text_chars, fontMetrics) : 0;
}
remain_lineText = true;
lineTextWidth += wordWidth;
wordWidth = fontMetrics.charWidth(text_chars[t]);
}
}
if (lineTextWidth + wordWidth > width && remain_lineText) {
count += 2;
} else {
count++;
}
return count;
}
/**
* 标点符号是否在换行后的行首
*/
private static boolean isPunctuationAtLineHead(int t, char[] text_chars) {
if (t > 1 && BaseUtils.isPunctuation(text_chars[t - 1])) {
return true;
}
return false;
}
/**
* 防止有连续多个标点符号要找一个非标点符号字符
*
* @date 2014-4-17
*/
private static int dealLineWidthWithPunctuation(int t, char[] text_chars, FontMetrics fontMetrics) {
if (t < 2) {
return 0;
}
int lineWidth = 0;
for (int index = t - 2; index >= 0; index--) {
lineWidth += fontMetrics.charWidth(text_chars[index]);
if (!BaseUtils.isPunctuation(text_chars[index])) {
break;
}
}
return lineWidth;
}
private static boolean isSwitchLine(char[] text_chars, int t) {
return text_chars[t] == '\n' || (text_chars[t] == '\r' && t + 1 < text_chars.length - 1 && text_chars[t + 1] != '\n');
}
private static boolean isLN(char[] text_chars, int t) {
return text_chars[t] == '\\' && t + 1 < text_chars.length && text_chars[t + 1] == 'n';
}
/**
* Gets the preferred width.
*/
public static UNIT getPreferredWidth(CellElement cell, UNIT height) {
if (cell == null) {
return UNIT.ZERO;
}
Object value = cell.getShowValue();
// 只接受Text,Number,和SeparatorPainter
// got the text
if (value instanceof BaseFormula) {
if (((BaseFormula) value).getResult() != null) {
value = ((BaseFormula) value).getResult();
} else {
value = StringUtils.EMPTY;
}
}
Style style = cell.getStyle();
if (style == null) {
style = Style.DEFAULT_STYLE;
}
CellGUIAttr cg = cell.getCellGUIAttr() == null ? new CellGUIAttr() : cell.getCellGUIAttr();
value = Utils.resolveOtherValue(value, cg.isShowAsImage(), PresentationType.EXPORT);
String text = Style.valueToText(value, style.getFormat());
FontMetrics cellFM = getFontMetrics(style);
//bug 12151 有边框线的单元格 自动调整列宽 会多一行
UNIT padding = new PT(style.getPaddingLeft() + style.getPaddingRight());
if (cg.isShowAsHTML()) {
return Html2ImageUtils.getHtmlWidth(text, height, style);
}
return FU.valueOfPix(cellFM.stringWidth(text) + UNIT_SIZE, Constants.FR_PAINT_RESOLUTION).add(padding);
}
private static FontMetrics getFontMetrics(Style style) {
Font font = style.getFRFont().applyResolutionNP(Constants.FR_PAINT_RESOLUTION);
FontProcessor processor = ExtraClassManager.getInstance().getSingle(FontProcessor.MARK_STRING);
if (processor != null) {
font = processor.readExtraFont(font);
}
return GraphHelper.getFontMetrics(font);
}
/**
* Preferred height. (Got the shrink preferred height of CellElement).
* 单位格的预计算高度
*
* @param cellElement 单元格内容
* @param paintWidth 画的宽度
* @return UNIT 单位
*/
public static UNIT analyzeCellElementPreferredHeight(CellElement cellElement, UNIT paintWidth) {
// 计算高度用显示值
Object value = cellElement.getShowValue();
// 只接受Text,Number,和SeparatorPainter
Style style = cellElement.getStyle();
// got the text
if (value instanceof BaseFormula) {
if (((BaseFormula) value).getResult() != null) {
value = ((BaseFormula) value).getResult();
} else {
value = StringUtils.EMPTY;
}
}
CellGUIAttr cg = cellElement.getCellGUIAttr() == null ? new CellGUIAttr() : cellElement.getCellGUIAttr();
if (!(value instanceof String) && !(value instanceof Integer)) {
value = DataUtils.resolveOtherValue(value, cg.isShowAsImage(), cg.isShowAsDownload(), null, true);
}
String text = Style.valueToText(value, style.getFormat());
if (cg.isShowAsHTML()) {
return Html2ImageUtils.getHtmlHeight(text, paintWidth, style);
}
return PaintUtils.analyzeCellElementPreferredHeight(text, style, paintWidth, cg.isShowAsHTML());
}
/**
* 单位格的预计算高度
* 单位PT
*
* @param text 文本
* @param style 格式
* @param paintWidth 画的宽度
* @param isShowAsHtml 是否以html展示
* @return 返回 单位
*/
private static UNIT analyzeCellElementPreferredHeight(String text, Style style, UNIT paintWidth, boolean isShowAsHtml) {
if (style == null) {
//peter:获取默认的Style.
style = Style.DEFAULT_STYLE;
}
// got the text
if (text == null || text.length() <= 0) {
return PT.valueOf(0);
}
// 变成Line Text List.
if (style.getRotation() != 0) { // more easy to paint.
// attribute map.
return PT.valueOf((float) GraphHelper.stringDimensionWithRotation(text, style.getFRFont(), -style.getRotation(),
CoreConstants.DEFAULT_FRC).getHeight());
}
// 先获得FontMetics.
int lineCount = getLineTextCount(text, style, paintWidth);
AutoChangeLineAndDrawProcess process = AutoChangeLineAndDrawManager.getProcess();
if (process != null) {
//算了这两个接口分开做
return process.getLinedTextHeight(lineCount, new ObjectHolder(style));
}
// carl:和paint那边一致,添上段前段后和行间距
PT lineSpacing = PT.valueOf(style.getSpacingAfter() + style.getSpacingBefore() + style.getLineSpacing() * lineCount);
FontMetrics fontMetrics = getFontMetrics(style);
int textHeight = fontMetrics.getHeight();
FU allTextHeight = FU.valueOfPix(textHeight * lineCount, Constants.FR_PAINT_RESOLUTION);
return lineSpacing.add(allTextHeight);// 需要给底部添加Leading.
}
/**
* 截取文字只考虑了垂直方向水平方向没意义且难度大.
*
* @param value 画的值
* @param style 字体样式格式.
* @param blockArea 冻结的范围
* @param resolution 分辨率
* @return 返回的字符串
*/
public static String clipBlockValue(Object value, Style style, Rectangle primitiveArea, Rectangle blockArea, int resolution, boolean isShowAsHTML) {
if (value == null) {
return null;
}
if (value instanceof BaseFormula) {
value = ((BaseFormula) value).getResult();
}
if (blockArea.y >= primitiveArea.height || blockArea.y + blockArea.height <= 0) {
return null;
}
//截取位置,相对于clipArea
int startY = blockArea.y > 0 ? blockArea.y : 0;
int endY = blockArea.y + blockArea.height < primitiveArea.height ? blockArea.y + blockArea.height : primitiveArea.height;
if (blockArea.x >= primitiveArea.width || blockArea.x + blockArea.width <= 0) {
return null;
}
if (isShowAsHTML) {
return Html2ImageUtils.clipHtmlContent(value, style, primitiveArea, resolution, startY, endY);
}
List lineList = BaseUtils.getLineTextList((String) value, style, style.getFRFont().applyResolutionNP(resolution), primitiveArea.width, resolution);
if (lineList.isEmpty()) {
return null;
}
double spacingBefore = PT.pt2pix(style.getSpacingBefore(), resolution);
double spacingAfter = PT.pt2pix(style.getSpacingAfter(), resolution);
double lineSpacing = PT.pt2pix(style.getLineSpacing(), resolution);
double lineHeight = lineSpacing + GraphHelper.getFontMetrics(style.getFRFont().applyResolutionNP(resolution)).getHeight();
int textAllHeight = (int) (lineHeight * lineList.size() + spacingBefore + spacingAfter);
//第一行文字距区域高度
int textStartY = (int) spacingBefore;
if (style.getVerticalAlignment() == Constants.BOTTOM) {
textStartY += (primitiveArea.height - textAllHeight);
}
if (endY <= textStartY || startY >= textStartY + lineHeight * lineList.size()) {
return null;
}
int lineStart = getLineStart(lineList, lineHeight, textStartY, startY);//截取区域起始行
int lineEnd = getLineEnd(lineList, lineHeight, endY, textStartY);//截取区域结束行
String text = "";
for (; lineStart <= lineEnd; lineStart++) {
text += lineList.get(lineStart);
}
return text;
}
private static int getLineStart(List lineList, double lineHeight, int textStartY, int startY) {
int lineStart = 0;
for (int i = 0; i < lineList.size(); i++) {
if (textStartY + lineHeight * (i) <= startY && textStartY + lineHeight * (i + 1) > startY) {//压线
if (startY - textStartY - lineHeight * (i) > lineHeight / 2) {
lineStart = i + 1;
} else {
lineStart = i;
}
}
}
return lineStart;
}
private static int getLineEnd(List lineList, double lineHeight, int endY, int textStartY) {
int lineEnd = lineList.size() - 1;
for (int i = 0; i < lineList.size(); i++) {
if (textStartY + lineHeight * (i) < endY && textStartY + lineHeight * (i + 1) >= endY) {//压线
//neil:仿宋,12号字, 行间距8为例, 转为px的行间距大小为10.666, 这边算出的应该有31.98行, 因此要进位
if (endY - textStartY - lineHeight * (i) >= lineHeight / 2) {
lineEnd = i;
} else {
lineEnd = i - 1;
}
}
}
return lineEnd;
}
/**
* paintBarcode
*/
public static void paintBarcode(Graphics2D g2d, int width, int height, String text, Style style, BarcodeAttr barcodeAttr) {
BarcodeImpl barcodeImpl;
try {
barcodeImpl = BarCodeUtils.getBarcodeImpl(barcodeAttr, text);
} catch (BarcodeException exp) {
try {
//设置默认值.
barcodeImpl = BarCodeUtils.getBarcodeImpl(new BarcodeAttr(), null);
} catch (BarcodeException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
return;
}
}
//字体
if (style.getFRFont() != null) {
barcodeImpl.setFont(style.getFRFont());
barcodeImpl.setForeground(style.getFRFont().getForeground());
}
//背景
Background background = style.getBackground();
if (background != null && background instanceof ColorBackground) {
barcodeImpl.setBackground(((ColorBackground) background).getColor());
}
//根据宽度和高度来确定起始点
int pointX = (width - barcodeImpl.getWidth()) / 2;
int pointY = (height - barcodeImpl.getHeight()) / 2;
barcodeImpl.draw(g2d, pointX, pointY);
}
/**
* create font attribute map, 创建属性map
*
* @param font 字体
* @return map 返回字体创建的Map
*/
public static Map createFontAttributeMap(Font font) {
Map returnFontAttributeMap = (Map) fontAttributeMapCache.get(font);
if (returnFontAttributeMap == null) {// create
// returnFontAttributeMap.
returnFontAttributeMap = font.getAttributes();
fontAttributeMapCache.put(font, returnFontAttributeMap);
}
if (font instanceof FRFont) {
FRFont frFont = (FRFont) font;
// Strikethrough
if (frFont.isStrikethrough()) {
returnFontAttributeMap.put(TextAttribute.STRIKETHROUGH, TextAttribute.STRIKETHROUGH_ON);
}
}
return returnFontAttributeMap;
}
}

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

@ -1,30 +1,16 @@
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.MutilTempalteTabPane;
import com.fr.design.fit.DesignerUIModeConfig;
import com.fr.design.fit.JFormType;
import com.fr.design.fit.NewJForm;
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.event.Event;
import com.fr.event.Listener;
import com.fr.file.MemFILE;
import com.fr.file.StashedFILE;
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 java.awt.Rectangle;
import java.util.List;
/**
@ -33,31 +19,20 @@ import java.util.List;
* @create: 2020/09/03 14:19
*/
public class TemplateTool {
//和转换有关的所有代码都在这个监听器中
//在判断新老模式时,统一使用FormUIModeConfig.getInstance().newUIMode()进行判断
private static Listener<JTemplate> switchListener = new Listener<JTemplate>() {
private static final Listener<JTemplate> switchListener = new Listener<JTemplate>() {
@Override
public void on(Event event, JTemplate jTemplate) {
if (!(jTemplate instanceof JForm)) {
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);
jTemplate.setDesignerUIMode();
}
};
private static boolean isNewJForm(JTemplate jTemplate) {
public static Listener<JTemplate> getSwitchListener() {
return switchListener;
}
public static boolean isNewJForm(JTemplate jTemplate) {
if (jTemplate instanceof NewJForm) {
NewJForm newJForm = (NewJForm) jTemplate;
if (LightTool.containNewFormFlag(newJForm.getTarget()) || newJForm.getTarget().getTemplateID() == null) {
@ -67,8 +42,8 @@ public class TemplateTool {
return false;
}
public static Listener<JTemplate> getSwitchListener() {
return switchListener;
public static boolean isCurrentEditingNewJForm(){
return isNewJForm(HistoryTemplateListCache.getInstance().getCurrentEditingTemplate());
}
/**
@ -79,8 +54,7 @@ public class TemplateTool {
* @date: 2020/9/6 14:17
*/
public static JTemplate getCurrentEditingTemplate() {
JTemplate jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
return jTemplate;
return HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
}
/**
@ -168,55 +142,7 @@ public class TemplateTool {
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());
}
}
}
}

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

@ -3,7 +3,8 @@ package com.fr.design.fit.toolbar;
import com.fr.design.actions.UpdateAction;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.file.TemplateTreePane;
import com.fr.design.fit.DesignerUIModeConfig;
import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.JForm;
import com.fr.design.fit.NewJForm;
import com.fr.design.fit.common.AdaptiveSwitchUtil;
import com.fr.design.fit.common.TemplateTool;
@ -11,7 +12,6 @@ import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.BaseJForm;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.menu.MenuKeySet;
import com.fr.design.utils.LoadingUtils;
@ -62,11 +62,11 @@ public class SwitchAction extends UpdateAction {
}
};
public SwitchAction() {
initMenuStyle();
public SwitchAction(JForm jForm) {
initMenuStyle(jForm);
}
private void initMenuStyle() {
private void initMenuStyle(JForm jForm) {
this.setMenuKeySet(SWITCH_ATTR);
this.setName(getMenuKeySet().getMenuKeySetName());
this.setMnemonic(getMenuKeySet().getMnemonic());
@ -78,7 +78,7 @@ public class SwitchAction extends UpdateAction {
Font oldFont = switchBtn.getFont();
switchBtn.setFont(new Font(oldFont.getName(),oldFont.getStyle(),12));
switchBtn.setForeground(new Color(0x33, 0x33, 0x34));
freshSwitchButton();
freshSwitchButton(jForm);
}
@Override
@ -90,11 +90,7 @@ public class SwitchAction extends UpdateAction {
if (confirmSwitchDialog() && backUpOldModeJTemplate()) {
AdaptiveSwitchUtil.setSwitchJFromIng(1);
showLoadingJPanel();
if (DesignerUIModeConfig.getInstance().newUIMode()) {
AdaptiveSwitchUtil.switch2OldUI();
} else {
AdaptiveSwitchUtil.switch2NewUI();
}
AdaptiveSwitchUtil.switchReload();
}
}
@ -171,7 +167,7 @@ public class SwitchAction extends UpdateAction {
*/
private boolean backUpOldModeJTemplate() {
JTemplate<?, ?> jTemplate = TemplateTool.getCurrentEditingTemplate();
if (jTemplate != null && !DesignerUIModeConfig.getInstance().newUIMode()) {
if (jTemplate != null && !TemplateTool.isNewJForm(jTemplate)) {
FILE editingFILE = jTemplate.getEditingFILE();
if (editingFILE != null && editingFILE.exists()) {
try {
@ -233,7 +229,7 @@ public class SwitchAction extends UpdateAction {
* @date: 2020/9/18 11:20
*/
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(
DesignerContext.getDesignerFrame(),
message,
@ -265,8 +261,8 @@ public class SwitchAction extends UpdateAction {
* @Author: Henry.Wang
* @date: 2020/8/31 16:39
*/
public UIButton freshSwitchButton() {
if (DesignerUIModeConfig.getInstance().newUIMode()) {
public UIButton freshSwitchButton(JForm jForm) {
if (TemplateTool.isNewJForm(jForm)) {
switchBtn.setToolTipText(Toolkit.i18nText("Fine-Designer_Fit_Switch_To_Old_UI"));
switchBtn.setText(Toolkit.i18nText("Fine-Designer_Fit_Switch_To_Old_Version"));
} else {
@ -277,7 +273,7 @@ public class SwitchAction extends UpdateAction {
}
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.XWBorderLayout;
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.UIButtonUI;
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.gui.GUIPaintUtils;
import com.fr.design.utils.gui.LayoutUtils;
import com.fr.form.fit.NewFormMarkAttr;
import com.fr.form.main.mobile.FormMobileAttr;
import com.fr.form.ui.container.WBodyLayoutType;
import com.fr.form.ui.container.WBorderLayout;
import com.fr.form.ui.container.WFitLayout;
import com.fr.general.FRScreen;
import com.fr.general.IOUtils;
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;
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_MINUS_COMMAND = "scale_minus";
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;
public static final int SHOWVALMAX = 400;
public static final int SHOWVALMIN = 10;
@ -90,21 +87,9 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
private UINumberField heightPane;
private JFormSliderPane slidePane;
private boolean isValid = true;
// 初始时滑块值为100,托动后的值设为START_VALUE;
private double START_VALUE = DEFAULT_SLIDER;
private double screenValue;
private UIButton fixLayoutSwitchButton;
private boolean isFixLayoutEditState;
public FormScrollBar getHorScrollBar() {
return horScrollBar;
}
public void setHorScrollBar(FormScrollBar horScrollBar) {
this.horScrollBar = horScrollBar;
}
public FormArea(FormDesigner designer) {
this(designer, true);
}
@ -243,7 +228,6 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
heightPane.setPreferredSize(new Dimension(60, 0));
slidePane = JFormSliderPane.getInstance();
JPanel resizePane = TableLayoutHelper.createCommonTableLayoutPane(
new JComponent[][]{{tipsPane, layoutSwitchPane, widthPane,
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);
initCalculateSize();
slidePane.addValueChangeListener(showValSpinnerChangeListener);
slidePane.setShowValue(FRScreen.getFRScreenByDimension(Toolkit.getDefaultToolkit().getScreenSize()).getValue().intValue());
}
public void undoFixLayoutState(boolean isFixLayout) {
@ -309,41 +294,10 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
this.designer.repaint();
}
/**
* 返回当前的屏幕分辨率对应的百分比值
*
* @return 缩放的百分比值
*/
public double getScreenValue() {
return screenValue;
}
/**
* 设置屏幕分辨率对应的百分比值
*
* @param screenValue 百分比值
*/
public void setScreenValue(double screenValue) {
this.screenValue = screenValue;
}
private void initCalculateSize() {
Toolkit toolkit = Toolkit.getDefaultToolkit();
Dimension scrnsize = toolkit.getScreenSize();
this.screenValue = DesignerUIModeConfig.getInstance().getDesignScreenByDimension(scrnsize).getValue();
XLayoutContainer root = FormArea.this.designer.getRootComponent();
// 7.1.1不放缩放滑块,但表单大小仍按屏幕分辨率调整
// slidePane.populateBean(screenValue);
if (root.acceptType(XWFitLayout.class)) {
XWFitLayout layout = (XWFitLayout) root;
if ( !AssistUtils.equals(screenValue, DEFAULT_SLIDER) ) {
reCalculateRoot(screenValue, true);
} else {
// 组件间隔啊
// REPORT-2585 原有的逻辑导致嵌套的tab中的间隔加不上去,会在后续拖动的过程中出问题
reCalculateDefaultRoot(screenValue, true);
}
reCalculateDefaultRoot();
}
LayoutUtils.layoutContainer(root);
updateCreatorsBackupBound(root);
@ -380,18 +334,10 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
// 失去焦点时,可以认为输入结束
int width = (int) ((UINumberField) e.getSource()).getValue();
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) {
XWFitLayout layout = (XWFitLayout) designer.getRootComponent();
@ -407,7 +353,6 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
public void actionPerformed(ActionEvent evt) {
int height = (int) ((UINumberField) evt.getSource()).getValue();
changeHeightPaneValue(height);
changeFormMarkAttrHeight(height);
}
});
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) {
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) {
// double value = slidePane.updateBean();
//重置滑块的值为默认值100
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;
}
layout.getParent().setSize(width, height + designer.getParaHeight());
FormArea.this.validate();
}
/**
* 按照界面大小的百分比值调整root大小
*
* @param needCalculateParaHeight 是否需要调整参数界面高度
* @param value
*/
private void reCalculateDefaultRoot(double value, boolean needCalculateParaHeight) {
private void reCalculateDefaultRoot() {
XLayoutContainer root = FormArea.this.designer.getRootComponent();
if (root.acceptType(XWFitLayout.class)) {
XWFitLayout layout = (XWFitLayout) root;
layout.setContainerPercent(1.0);
traverAndAdjust(layout, 0.0);
layout.adjustCreatorsWhileSlide(0.0);
// 拖动滑块,先将内部组件百分比大小计算,再计算容器大小
Dimension d = new Dimension(layout.getWidth(), layout.getHeight());
// 自适应布局的父层是border
if (layout.getParent() != null) {
int paraHeight = designer.getParaHeight();
if (needCalculateParaHeight && paraHeight > 0) {
if (paraHeight > 0) {
designer.setParaHeight(paraHeight);
XWBorderLayout parent = (XWBorderLayout) layout.getParent();
parent.toData().setNorthSize(paraHeight);
@ -885,16 +771,11 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
heightPane.setValue(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();
// 撤销时先refreshRoot了,此处去掉内边距再增加间隔
layout.moveContainerMargin();
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);
}

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.event.DesignerOpenedListener;
import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.fit.DesignerUIModeConfig;
import com.fr.design.form.util.XCreatorConstants;
import com.fr.design.fun.RightSelectionHandlerProvider;
import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus;
@ -151,7 +150,6 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
// 存储被选择组件和剪切板的model
private transient SelectionModel selectionModel;
private int resolution = DesignerUIModeConfig.getInstance().getScreenResolution();
// 编辑状态的事件表
private CreatorEventListenerTable edit;
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() {
return scale;
}

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

@ -1,6 +1,7 @@
package com.fr.design.mainframe;
import com.fr.base.GraphHelper;
import com.fr.base.ScreenResolution;
import com.fr.base.Utils;
import com.fr.base.iofile.attr.WatermarkAttr;
import com.fr.base.vcs.DesignerMode;
@ -132,7 +133,7 @@ public class FormDesignerUI extends ComponentUI {
return;
}
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());
}

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

@ -182,11 +182,10 @@ public class FormSelectionUtils {
if (!childrenList.isEmpty()) {
for (Object aChildrenList : childrenList) {
XWTabFitLayout tabLayout = (XWTabFitLayout) aChildrenList;
double percent = tabLayout.getContainerPercent();
Component[] components = tabLayout.getComponents();
for (Component component : components) {
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));
}
}
}

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

Loading…
Cancel
Save