Browse Source

Merge branch 'feature/x' of https://code.fineres.com/scm/~yuan.wang/design into feature/x

feature/x
Yuan.Wang 3 years ago
parent
commit
b652f05153
  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. 2
      designer-base/src/main/java/com/fr/design/actions/community/BugAction.java
  5. 2
      designer-base/src/main/java/com/fr/design/actions/community/NeedAction.java
  6. 17
      designer-base/src/main/java/com/fr/design/actions/community/StudyPlanAction.java
  7. 5
      designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java
  8. 104
      designer-base/src/main/java/com/fr/design/cell/CellRectangleStylePreviewPane.java
  9. 62
      designer-base/src/main/java/com/fr/design/cell/CellStylePreviewPane.java
  10. 52
      designer-base/src/main/java/com/fr/design/config/DesignerProperties.java
  11. 5
      designer-base/src/main/java/com/fr/design/constants/TableDataConstants.java
  12. 16
      designer-base/src/main/java/com/fr/design/data/BasicTableDataTreePane.java
  13. 7
      designer-base/src/main/java/com/fr/design/data/BasicTableDataUtils.java
  14. 112
      designer-base/src/main/java/com/fr/design/data/datapane/ChoosePane.java
  15. 2
      designer-base/src/main/java/com/fr/design/data/datapane/ChoosePaneSupportFormula.java
  16. 7
      designer-base/src/main/java/com/fr/design/data/datapane/TableDataTreePane.java
  17. 147
      designer-base/src/main/java/com/fr/design/data/datapane/connect/AdvancePane.java
  18. 35
      designer-base/src/main/java/com/fr/design/data/datapane/connect/DBCPAttrPane.java
  19. 44
      designer-base/src/main/java/com/fr/design/data/datapane/connect/DatabaseConnectionPane.java
  20. 7
      designer-base/src/main/java/com/fr/design/event/ComponentChangeListener.java
  21. 6
      designer-base/src/main/java/com/fr/design/event/ComponentChangeObserver.java
  22. 29
      designer-base/src/main/java/com/fr/design/extra/PluginInstalledPane.java
  23. 12
      designer-base/src/main/java/com/fr/design/extra/PluginOperateUtils.java
  24. 4
      designer-base/src/main/java/com/fr/design/file/MutilTempalteTabPane.java
  25. 36
      designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java
  26. 118
      designer-base/src/main/java/com/fr/design/formula/FormulaPane.java
  27. 9
      designer-base/src/main/java/com/fr/design/formula/exception/function/MismatchedCharFunction.java
  28. 38
      designer-base/src/main/java/com/fr/design/formula/exception/function/MismatchedTokenFunction.java
  29. 96
      designer-base/src/main/java/com/fr/design/formula/exception/function/TranslateTokenUtils.java
  30. 4
      designer-base/src/main/java/com/fr/design/gui/controlpane/UIListGroupControlPane.java
  31. 11
      designer-base/src/main/java/com/fr/design/gui/frpane/AbstractAttrNoScrollPane.java
  32. 20
      designer-base/src/main/java/com/fr/design/gui/frpane/JTreeAutoBuildPane.java
  33. 4
      designer-base/src/main/java/com/fr/design/gui/ibutton/UIButtonGroup.java
  34. 6
      designer-base/src/main/java/com/fr/design/gui/icheckbox/UICheckBox.java
  35. 2
      designer-base/src/main/java/com/fr/design/gui/icombobox/ColorSchemeComboBox.java
  36. 4
      designer-base/src/main/java/com/fr/design/gui/icombobox/FRTreeComboBox.java
  37. 207
      designer-base/src/main/java/com/fr/design/gui/icombobox/SearchFRTreeComboBox.java
  38. 77
      designer-base/src/main/java/com/fr/design/gui/icombobox/SearchPreTaskTreeComboBox.java
  39. 8
      designer-base/src/main/java/com/fr/design/gui/iprogressbar/ProgressDialog.java
  40. 7
      designer-base/src/main/java/com/fr/design/gui/itextfield/UIAutoCompletionField.java
  41. 106
      designer-base/src/main/java/com/fr/design/gui/style/BorderPane.java
  42. 235
      designer-base/src/main/java/com/fr/design/gui/style/TextFormatPane.java
  43. 111
      designer-base/src/main/java/com/fr/design/lock/LockInfoDialog.java
  44. 18
      designer-base/src/main/java/com/fr/design/lock/LockInfoUtils.java
  45. 11
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java
  46. 68
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java
  47. 46
      designer-base/src/main/java/com/fr/design/mainframe/DesignerUIModeConfig.java
  48. 12
      designer-base/src/main/java/com/fr/design/mainframe/DesktopCardPane.java
  49. 181
      designer-base/src/main/java/com/fr/design/mainframe/ForbiddenPane.java
  50. 37
      designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java
  51. 4
      designer-base/src/main/java/com/fr/design/mainframe/NorthRegionContainerPane.java
  52. 2
      designer-base/src/main/java/com/fr/design/mainframe/PX.java
  53. 2
      designer-base/src/main/java/com/fr/design/mainframe/PXReportLengthUNIT.java
  54. 17
      designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/ColorBackgroundQuickPane.java
  55. 42
      designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogAppender.java
  56. 22
      designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogHandler.java
  57. 41
      designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogger.java
  58. 22
      designer-base/src/main/java/com/fr/design/mainframe/share/collect/ComponentCollector.java
  59. 77
      designer-base/src/main/java/com/fr/design/mainframe/theme/ThemedCellStyleListPane.java
  60. 17
      designer-base/src/main/java/com/fr/design/mainframe/theme/ThemedFeatureController.java
  61. 22
      designer-base/src/main/java/com/fr/design/mainframe/theme/dialog/TemplateThemeDialog.java
  62. 18
      designer-base/src/main/java/com/fr/design/mainframe/theme/edit/CellStyleListEditPane.java
  63. 56
      designer-base/src/main/java/com/fr/design/mainframe/theme/edit/cell/CellStyleEditPane.java
  64. 3
      designer-base/src/main/java/com/fr/design/mainframe/theme/edit/chart/ChartFontPane.java
  65. 2
      designer-base/src/main/java/com/fr/design/mainframe/theme/edit/ui/ColorListPane.java
  66. 5
      designer-base/src/main/java/com/fr/design/mainframe/theme/preview/ReportThemePreviewPane.java
  67. 17
      designer-base/src/main/java/com/fr/design/mainframe/theme/preview/ecpreview/cell/AbstractPreviewCell.java
  68. 2
      designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java
  69. 7
      designer-base/src/main/java/com/fr/design/os/impl/SupportOSImpl.java
  70. 135
      designer-base/src/main/java/com/fr/design/utils/TemplateUtils.java
  71. 10
      designer-base/src/main/java/com/fr/design/worker/open/OpenWorker.java
  72. 112
      designer-base/src/main/java/com/fr/design/worker/save/SaveFailureHandler.java
  73. 11
      designer-base/src/main/java/com/fr/design/worker/save/SaveWorker.java
  74. 10
      designer-base/src/main/java/com/fr/file/FILEChooserPane.java
  75. 4
      designer-base/src/main/java/com/fr/start/server/FineEmbedServerActivator.java
  76. BIN
      designer-base/src/main/resources/com/fr/design/images/bbs/studyPlan.png
  77. 1
      designer-base/src/main/resources/com/fr/design/images/bbs/studyPlan_normal.svg
  78. BIN
      designer-base/src/main/resources/com/fr/design/images/mainframe/lock_template.png
  79. BIN
      designer-base/src/main/resources/com/fr/design/images/mainframe/refreh_icon.png
  80. BIN
      designer-base/src/main/resources/com/fr/design/images/sort/add.png
  81. 19
      designer-base/src/main/resources/com/fr/design/images/sort/asc.svg
  82. 17
      designer-base/src/main/resources/com/fr/design/images/sort/des.svg
  83. BIN
      designer-base/src/main/resources/com/fr/design/images/sort/down_arrow.png
  84. BIN
      designer-base/src/main/resources/com/fr/design/images/sort/left_arrow.png
  85. 41
      designer-base/src/main/resources/com/fr/design/images/sort/nosort.svg
  86. BIN
      designer-base/src/main/resources/com/fr/design/images/toolbarbtn/lock.png
  87. BIN
      designer-base/src/main/resources/com/fr/design/images/toolbarbtn/unlock.png
  88. 10
      designer-chart/src/main/java/com/fr/design/chart/ChartTypePane.java
  89. 12
      designer-chart/src/main/java/com/fr/design/chart/series/SeriesCondition/impl/ChartHyperPoplinkPane.java
  90. 9
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java
  91. 9
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ChartTextAttrPane.java
  92. 13
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ChartTextAttrPaneWithAuto.java
  93. 6
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ChartTextAttrPaneWithThemeStyle.java
  94. 69
      designer-chart/src/main/java/com/fr/van/chart/config/DefaultStyleConstants.java
  95. 66
      designer-chart/src/main/java/com/fr/van/chart/config/DefaultStyleHelper4Van.java
  96. 4
      designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartTooltipContentPane.java
  97. 15
      designer-chart/src/main/java/com/fr/van/chart/designer/type/AbstractVanChartTypePane.java
  98. 14
      designer-chart/src/main/java/com/fr/van/chart/funnel/designer/style/VanChartFunnelSeriesPane.java
  99. 5
      designer-chart/src/main/java/com/fr/van/chart/pie/style/VanChartPieCategoryLabelContentPane.java
  100. 27
      designer-chart/src/main/resources/com/fr/design/editor/rich_editor.html
  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);

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

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

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

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

17
designer-base/src/main/java/com/fr/design/actions/community/StudyPlanAction.java

@ -0,0 +1,17 @@
package com.fr.design.actions.community;
import com.fr.design.i18n.Toolkit;
import com.fr.design.login.AbstractDesignerSSO;
import com.fr.general.CloudCenter;
public class StudyPlanAction extends AbstractDesignerSSO {
public StudyPlanAction() {
this.setName(Toolkit.i18nText("Fine-Design_Study_Plan"));
this.setSmallIcon("/com/fr/design/images/bbs/studyPlan");
}
@Override
public String getJumpUrl() {
return CloudCenter.getInstance().acquireUrlByKind("bbs.studyPlan", "https://edu.fanruan.com/studypath/finereport");
}
}

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

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

@ -0,0 +1,5 @@
package com.fr.design.constants;
public class TableDataConstants {
public static final String SEPARATOR = "_";
}

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

@ -36,8 +36,6 @@ import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils;
import com.fr.workspace.WorkContext;
import java.util.HashSet;
import java.util.Set;
import javax.swing.AbstractButton;
import javax.swing.Action;
import javax.swing.DefaultCellEditor;
@ -55,8 +53,10 @@ import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.util.EventObject;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
/**
* Coder: zack
@ -83,6 +83,7 @@ public abstract class BasicTableDataTreePane extends DockingView implements Resp
protected String[] allDSNames;
protected ConnectionTableAction connectionTableAction;
protected ToolBarDef toolbarDef;
protected TableDataTreePaneListener listener = null;
private String type = "";
@ -142,6 +143,17 @@ public abstract class BasicTableDataTreePane extends DockingView implements Resp
public abstract void dgEdit(final AbstractTableDataPane<?> uPanel, String originalName, boolean isUpdate);
public void showEditPane(final AbstractTableDataPane<?> tableDataPane, String originalName, TableDataTreePaneListener listener) {
this.listener = listener;
dgEdit(tableDataPane, originalName);
}
public interface TableDataTreePaneListener {
void doOk();
void doCancel();
}
protected void doPropertyChange(BasicDialog dg, BasicPane.NamePane nPanel, final String oldName) {
type = dg.getTitle();
nPanel.setShowText(StringUtils.BLANK);

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

@ -1,6 +1,7 @@
package com.fr.design.data;
import com.fr.data.TableDataSource;
import com.fr.design.constants.TableDataConstants;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.i18n.Toolkit;
import com.fr.stable.StringUtils;
@ -11,8 +12,6 @@ import com.fr.stable.StringUtils;
* Created by hades on 2020/4/27
*/
public abstract class BasicTableDataUtils {
private static final String SEPARATOR = "_";
private static final int LEN = 2;
@ -38,10 +37,10 @@ public abstract class BasicTableDataUtils {
public static String getTableDataName(boolean isCover, TableDataSource tds, String tdName, String srcName, boolean isDsNameRepeaded) {
if (isCover) {
return srcName + SEPARATOR + tdName;
return srcName + TableDataConstants.SEPARATOR + tdName;
}
if (tds.getTableData(tdName) != null || isDsNameRepeaded) {//如果有同名的就拼上来源名称
tdName = srcName + SEPARATOR + tdName;
tdName = srcName + TableDataConstants.SEPARATOR + tdName;
}
int i = 0;
while (tds.getTableData(tdName) != null) {

112
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.SearchFRTreeComboBox;
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 SearchFRTreeComboBox 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 SearchFRTreeComboBox(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,10 +472,14 @@ 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
}

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());
// 没有选中的列表项 那么看看是不是手输值

7
designer-base/src/main/java/com/fr/design/data/datapane/TableDataTreePane.java

@ -361,11 +361,18 @@ public class TableDataTreePane extends BasicTableDataTreePane {
//单独编辑数据集关闭,修改缓存配置状态,刷新下一键开启/关闭按钮
checkButtonEnabled();
if (listener != null) {
listener.doOk();
}
}
@Override
public void doCancel() {
super.doCancel();
if (listener != null) {
listener.doCancel();
}
}
});
tdNamePanel.addPropertyChangeListener(new PropertyChangeAdapter() {

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

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

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

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

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

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 += " *";
}

36
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;
@ -113,6 +120,7 @@ public class TemplateTreePane extends JPanel implements FileOperations {
if (toolBarStateChangeListener != null) {
toolBarStateChangeListener.stateChange();
}
DesignerFrameFileDealerPane.getInstance().refreshRightToolBarBy(reportletsTree.getSelectedFileNode());
}
};
// lx: add mouse listener
@ -216,15 +224,36 @@ public class TemplateTreePane extends JPanel implements FileOperations {
if (node == null) {
return;
}
String reportPath = reportletsTree.getSelectedTemplatePath();
final String selectedFilePath = StableUtils.pathJoin(ProjectConstants.REPORTLETS_NAME, reportPath);
if (hasOpenedTemplate(selectedFilePath)) {
FineLoggerFactory.getLogger().info("{} has been opened in designer tab", selectedFilePath);
return;
}
String lock = node.getLock();
if (lock != null && !lock.equals(node.getUserID())) {
boolean showLockInfo = LockInfoUtils.isCompatibleOperator() ? (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());
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 boolean hasOpenedTemplate(String path) {
for (JTemplate<?, ?> template : HistoryTemplateListCache.getInstance().getHistoryList()) {
if (ComparatorUtils.equals(template.getEditingFILE().getPath(), path)) {
return true;
}
}
return false;
}
/**
* 打开文件夹
*/
@ -248,6 +277,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") + "!");
}

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

@ -46,6 +46,7 @@ import com.fr.parser.BlockIntervalLiteral;
import com.fr.parser.ColumnRowRangeInPage;
import com.fr.parser.NumberLiteral;
import com.fr.parser.SheetIntervalLiteral;
import com.fr.record.analyzer.EnableMetrics;
import com.fr.report.core.namespace.SimpleCellValueNameSpace;
import com.fr.script.Calculator;
import com.fr.script.ScriptConstants;
@ -54,7 +55,6 @@ import com.fr.stable.EncodeConstants;
import com.fr.stable.EssentialUtils;
import com.fr.stable.ParameterProvider;
import com.fr.stable.StringUtils;
import com.fr.stable.UtilEvalError;
import com.fr.stable.script.CRAddress;
import com.fr.stable.script.ColumnRowRange;
import com.fr.stable.script.Expression;
@ -122,6 +122,7 @@ import java.util.Set;
* @editor zhou
* @since 2012-3-29下午1:50:53
*/
@EnableMetrics
public class FormulaPane extends BasicPane implements KeyListener, UIFormula {
public static final int DEFUAL_FOMULA_LENGTH = 103;
public static final String ELLIPSIS = "...";
@ -139,6 +140,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula {
protected static UICheckBox autoCompletionCheck;
protected static UICheckBox checkBeforeColse;
private JList tipsList;
private JPopupMenu popupMenu;
protected DefaultListModel listModel = new DefaultListModel();
private int ifHasBeenWriten = 0;
private DefaultListModel functionTypeListModel = new DefaultListModel();
@ -340,11 +342,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula {
public void focusGained(FocusEvent e) {
// 获得焦点时 安装
if (autoCompletion == null && autoCompletionCheck.isSelected()) {
CompletionProvider provider = createCompletionProvider();
autoCompletion = new FormulaPaneAutoCompletion(provider);
autoCompletion.setListCellRenderer(new CompletionCellRenderer());
autoCompletion.install(formulaTextArea);
autoCompletion.installVariableTree(variableTreeAndDescriptionArea);
installAutoCompletion();
}
}
@ -408,6 +406,14 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula {
}
}
private void installAutoCompletion() {
CompletionProvider provider = createCompletionProvider();
autoCompletion = new FormulaPaneAutoCompletion(provider);
autoCompletion.setListCellRenderer(new CompletionCellRenderer());
autoCompletion.install(formulaTextArea);
autoCompletion.installVariableTree(variableTreeAndDescriptionArea);
}
protected void extendCheckBoxPane(JPanel checkBoxPane) {
@ -457,6 +463,9 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula {
if (ComparatorUtils.equals((String) listModel.getElementAt(index), doublePressContent)) {
doubleClickActuator(doublePressContent);
}
if (popupMenu != null) {
popupMenu.setVisible(false);
}
}
}
}
@ -616,7 +625,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula {
}
private void popTips() {
JPopupMenu popupMenu = new JPopupMenu();
popupMenu = new JPopupMenu();
JScrollPane tipsScrollPane = new JScrollPane(tipsList);
popupMenu.add(tipsScrollPane);
tipsScrollPane.setPreferredSize(new Dimension(240, 146));
@ -790,53 +799,62 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula {
}
};
private void calculateFormula() {
String formulaText = formulaTextArea.getText().trim();
String unSupportFormula = containsUnsupportedSimulationFormulas(formulaText);
if (unSupportFormula != null) {
showMessageDialog(Toolkit.i18nText("Fine-Design_Basic_Formula_Unsupported_Formulas") + ":" + unSupportFormula, false);
return;
}
private final ActionListener calculateActionListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
String formulaText = formulaTextArea.getText().trim();
String unSupportFormula = containsUnsupportedSimulationFormulas(formulaText);
if (unSupportFormula != null) {
showMessageDialog(Toolkit.i18nText("Fine-Design_Basic_Formula_Unsupported_Formulas") + ":" + unSupportFormula, false);
return;
String messageTips;
FormulaCheckResult checkResult = FormulaChecker.check(formulaText);
if (checkResult.grammarValid()) {
messageTips = checkResult.getTips() + NEWLINE;
Map<String, Object> paramsMap = setParamsIfExist(formulaText);
Calculator calculator = Calculator.createCalculator();
ParameterMapNameSpace parameterMapNameSpace = ParameterMapNameSpace.create(paramsMap);
calculator.pushNameSpace(parameterMapNameSpace);
JTemplate<?, ?> currentEditingTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (currentEditingTemplate != null) {
IOFile file = (IOFile) currentEditingTemplate.getTarget();
calculator.setAttribute(TableDataSource.KEY, file);
calculator.pushNameSpace(TableDataNameSpace.getInstance());
calculator.pushNameSpace(SimpleCellValueNameSpace.getInstance());
}
String messageTips;
FormulaCheckResult checkResult = FormulaChecker.check(formulaText);
if (checkResult.grammarValid()) {
messageTips = checkResult.getTips() + NEWLINE;
Map<String, Object> paramsMap = setParamsIfExist(formulaText);
Calculator calculator = Calculator.createCalculator();
ParameterMapNameSpace parameterMapNameSpace = ParameterMapNameSpace.create(paramsMap);
calculator.pushNameSpace(parameterMapNameSpace);
JTemplate<?, ?> currentEditingTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (currentEditingTemplate != null) {
IOFile file = (IOFile) currentEditingTemplate.getTarget();
calculator.setAttribute(TableDataSource.KEY, file);
calculator.pushNameSpace(TableDataNameSpace.getInstance());
calculator.pushNameSpace(SimpleCellValueNameSpace.getInstance());
}
BaseFormula baseFormula = BaseFormula.createFormulaBuilder().build(formulaText);
try {
Object value = calculator.evalValue(baseFormula);
String objectToString = EssentialUtils.objectToString(value);
String result = objectToString.length() > DEFUAL_FOMULA_LENGTH ?
objectToString.substring(0, DEFUAL_FOMULA_LENGTH - ELLIPSIS.length()) + ELLIPSIS : objectToString;
messageTips = messageTips + Toolkit.i18nText("Fine-Design_Basic_Formula_Cal_Result") + ":" + result;
FineLoggerFactory.getLogger().info("value:{}", value);
} catch (UtilEvalError utilEvalError) {
FineLoggerFactory.getLogger().error(utilEvalError.getMessage(), utilEvalError);
}
} else {
messageTips = checkResult.getTips();
}
if (checkResult.isValid()) {
showMessageDialog(messageTips, checkResult.isValid());
} else {
confirmCheckResult(checkResult, messageTips);
BaseFormula baseFormula = BaseFormula.createFormulaBuilder().build(formulaText);
Object calResult;
try {
calResult = calculator.evalValue(baseFormula);
String objectToString = EssentialUtils.objectToString(calResult);
String result = objectToString.length() > DEFUAL_FOMULA_LENGTH ?
objectToString.substring(0, DEFUAL_FOMULA_LENGTH - ELLIPSIS.length()) + ELLIPSIS : objectToString;
messageTips = messageTips + Toolkit.i18nText("Fine-Design_Basic_Formula_Cal_Result") + ":" + result;
} catch (Exception ce) {
//模拟计算如果出现错误,则抛出错误
calResult = ce.getMessage();
FineLoggerFactory.getLogger().error(ce.getMessage(), ce);
messageTips = messageTips + Toolkit.i18nText("Fine-Design_Basic_Formula_Cal_Error") + ":" + calResult;
}
FineLoggerFactory.getLogger().info("value:{}", calResult);
} else {
messageTips = checkResult.getTips();
}
if (checkResult.isValid()) {
showMessageDialog(messageTips, checkResult.isValid());
} else {
confirmCheckResult(checkResult, messageTips);
}
}
private final ActionListener calculateActionListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
calculateFormula();
}
};

9
designer-base/src/main/java/com/fr/design/formula/exception/function/MismatchedCharFunction.java

@ -35,10 +35,6 @@ public class MismatchedCharFunction implements Function<Exception, FormulaCheckR
case 1:
sb.append(Toolkit.i18nText("Fine-Design_Basic_Formula_Check_Expecting") + ": ");
appendCharName(sb, charException.expecting);
sb.append(FormulaCheckConstants.COMMON)
.append(FormulaCheckConstants.BLANK)
.append(Toolkit.i18nText("Fine-Design_Basic_Formula_Check_Found"));
appendCharName(sb, charException.foundChar);
break;
case 2:
sb.append(Toolkit.i18nText("Fine-Design_Basic_Formula_Check_Expecting_Anything") + ": ")
@ -58,8 +54,6 @@ public class MismatchedCharFunction implements Function<Exception, FormulaCheckR
appendCharName(sb, charException.expecting);
sb.append("..");
appendCharName(sb, charException.upper);
sb.append(", ").append(Toolkit.i18nText("Fine-Design_Basic_Formula_Check_Found"));
appendCharName(sb, charException.foundChar);
break;
case 5:
case 6:
@ -71,9 +65,6 @@ public class MismatchedCharFunction implements Function<Exception, FormulaCheckR
for (int i = 0; i < elems.length; ++i) {
appendCharName(sb, elems[i]);
}
sb.append("), ").append(Toolkit.i18nText("Fine-Design_Basic_Formula_Check_Found"));
appendCharName(sb, charException.foundChar);
break;
default:
sb.append(Toolkit.i18nText("Fine-Design_Basic_Formula_Check_Mismatched_Char"));

38
designer-base/src/main/java/com/fr/design/formula/exception/function/MismatchedTokenFunction.java

@ -40,11 +40,7 @@ public class MismatchedTokenFunction implements Function<Exception, FormulaCheck
switch (exception.mismatchType) {
case 1:
sb.append(Toolkit.i18nText("Fine-Design_Basic_Formula_Check_Expecting") + ": ")
.append(tokenName(exception.expecting, exception))
.append(", ")
.append(Toolkit.i18nText("Fine-Design_Basic_Formula_Check_Found"))
.append(FormulaCheckConstants.BLANK + FormulaCheckConstants.SINGLE_QUOTES)
.append(tokenText).append("'");
.append(tokenName(exception.expecting, exception));
break;
case 2:
sb.append(Toolkit.i18nText("Fine-Design_Basic_Formula_Check_Expecting_Anything") + ": ")
@ -59,9 +55,7 @@ public class MismatchedTokenFunction implements Function<Exception, FormulaCheck
.append(": ")
.append(tokenName(exception.expecting, exception))
.append("..")
.append(tokenName(exception.upper, exception))
.append(", ").append(Toolkit.i18nText("Fine-Design_Basic_Formula_Check_Found"))
.append("'").append(tokenText).append("'");
.append(tokenName(exception.upper, exception));
break;
case 4:
sb.append(Toolkit.i18nText("Fine-Design_Basic_Formula_Check_Expecting") + ": ")
@ -71,12 +65,7 @@ public class MismatchedTokenFunction implements Function<Exception, FormulaCheck
.append(": ")
.append(tokenName(exception.expecting, exception))
.append("..")
.append(tokenName(exception.upper, exception))
.append(",").
append(Toolkit.i18nText("Fine-Design_Basic_Formula_Check_Found"))
.append(" '")
.append(tokenText)
.append("'");
.append(tokenName(exception.upper, exception));
break;
case 5:
case 6:
@ -90,11 +79,6 @@ public class MismatchedTokenFunction implements Function<Exception, FormulaCheck
sb.append(tokenName(elms[i], exception));
}
sb.append("),")
.append(Toolkit.i18nText("Fine-Design_Basic_Formula_Check_Found"))
.append("'")
.append(tokenText)
.append("'");
break;
default:
sb.append(Toolkit.i18nText("Fine-Design_Basic_Formula_Check_Mismatched_Token"));
@ -108,24 +92,10 @@ public class MismatchedTokenFunction implements Function<Exception, FormulaCheck
return "<Set of tokens>";
} else {
String[] tokenNames = (String[]) getFieldValue(exception, "tokenNames");
return tokenType >= 0 && tokenType < tokenNames.length ? translateToken(tokenNames[tokenType]) : "<" + tokenType + ">";
return tokenType >= 0 && tokenType < tokenNames.length ? TranslateTokenUtils.translateToken(tokenNames[tokenType]) : "<" + tokenType + ">";
}
}
private String translateToken(String token) {
switch (token) {
case ("RPAREN"):
return ")";
case ("LPAREN"):
return "(";
case ("COMMA"):
return ",";
case ("COLON"):
return ":";
default:
return token;
}
}
private Object getFieldValue(Object object, String fieldName) {
try {

96
designer-base/src/main/java/com/fr/design/formula/exception/function/TranslateTokenUtils.java

@ -0,0 +1,96 @@
package com.fr.design.formula.exception.function;
import com.fr.design.i18n.Toolkit;
/**
* @author Hoky
* @date 2021/11/30
*/
public class TranslateTokenUtils {
public static String translateToken(String token) {
switch (token) {
case ("RPAREN"):
return ")";
case ("LPAREN"):
return "(";
case ("COMMA"):
return ",";
case ("COLON"):
return ":";
case ("EOF"):
return Toolkit.i18nText("Fine-Design_Basic_Formula_Check_Mismatched_EOF");
case ("DOT"):
return ".";
case ("FLOT_NUM"):
return Toolkit.i18nText("Fine-Design_Basic_Formula_Float_Number");
case ("LOR"):
return "||";
case ("LAND"):
return "&&";
case ("EQUAL"):
return "=";
case ("EQUAL2"):
return "=";
case ("NOT_EQUAL"):
return "!=";
case ("NOT_EQUAL2"):
return "!=";
case ("GE"):
return ">=";
case ("LE"):
return "<=";
case ("LT"):
return "<";
case ("PLUS"):
return "+";
case ("MINUS"):
return "-";
case ("STAR"):
return "*";
case ("DIV"):
return "/";
case ("MOD"):
return "%";
case ("POWER"):
return "^";
case ("LNOT"):
return "!";
case ("WAVE"):
return "~";
case ("LBRACK"):
return "[";
case ("SEMI"):
return ";";
case ("RBRACK"):
return "]";
case ("LCURLY"):
return "{";
case ("RCURLY"):
return "}";
case ("DCOLON"):
return ";";
case ("INT_NUM"):
return Toolkit.i18nText("Fine-Design_Basic_Formula_Integer");
case ("CR_ADRESS"):
return "\n";
case ("SHARP"):
return "#";
case ("AT"):
return "@";
case ("QUESTION"):
return "?";
case ("BOR"):
return "||";
case ("BAND"):
return "&&";
case ("Char"):
return Toolkit.i18nText("Fine-Design_Basic_Formula_Character");
case ("DIGIT"):
return Toolkit.i18nText("Fine-Design_Basic_Formula_Digital");
case ("XDIGIT"):
return Toolkit.i18nText("Fine-Design_Basic_Formula_Hexadecimal_Digital");
default:
return token;
}
}
}

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

@ -125,7 +125,9 @@ public abstract class UIListGroupControlPane extends UIControlPane implements Li
for (int i = 0, size = widget.getListenerSize(); i < size; i++) {
Listener listener = widget.getListener(i);
if (!listener.isDefault()) {
nameObjectList.add(i, new NameObject(switchLang(listener.getEventName()) + (i + 1), listener));
String eventName = switchLang(listener.getEventName()) + (nameObjectList.size() + 1);
NameObject nameObject = new NameObject(eventName, listener);
nameObjectList.add(nameObject);
}
}
populate(getHelper().processCatalog(nameObjectList));

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

20
designer-base/src/main/java/com/fr/design/gui/frpane/JTreeAutoBuildPane.java

@ -242,12 +242,22 @@ public class JTreeAutoBuildPane extends BasicPane implements PreviewLabel.Previe
rtd = treeTableDataComboBox.getSelcetedTableData();
name = treeTableDataComboBox.getSelectedItem().getTableDataName();
}
final String tableDataName = name;
AbstractTableDataWrapper atdw = new TemplateTableDataWrapper(rtd, "");
tdtp.dgEdit(atdw.creatTableDataPane(), name);
treeTableDataComboBox.refresh();
treeTableDataComboBox.setSelectedTableDataByName(name);
textPane.populate(1);
valuePane.populate(1);
tdtp.showEditPane(atdw.creatTableDataPane(), name, new BasicTableDataTreePane.TableDataTreePaneListener() {
@Override
public void doOk() {
// 去除缓存列,后面刷新会重新选中
DesignTableDataManager.removeSelectedColumnNames(tableDataName);
treeTableDataComboBox.refresh();
treeTableDataComboBox.setSelectedTableDataByName(tableDataName);
}
@Override
public void doCancel() {
}
});
}
}

4
designer-base/src/main/java/com/fr/design/gui/ibutton/UIButtonGroup.java

@ -389,9 +389,9 @@ public class UIButtonGroup<T> extends JPanel implements GlobalNameObserver, UIOb
* @param l
*/
public void addChangeListener(ChangeListener l) {
listenerList.add(ChangeListener.class, l);
for (int i = 0; i < labelButtonList.size(); i++) {
labelButtonList.get(i).addChangeListener(l);
listenerList.add(ChangeListener.class, l);
}
}
@ -399,9 +399,9 @@ public class UIButtonGroup<T> extends JPanel implements GlobalNameObserver, UIOb
* @param l
*/
public void removeChangeListener(ChangeListener l) {
listenerList.remove(ChangeListener.class, l);
for (int i = 0; i < labelButtonList.size(); i++) {
labelButtonList.get(i).removeChangeListener(l);
listenerList.remove(ChangeListener.class, l);
}
}

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;

2
designer-base/src/main/java/com/fr/design/gui/icombobox/ColorSchemeComboBox.java

@ -153,7 +153,7 @@ public class ColorSchemeComboBox extends UIComboBox {
if (selectedIndex == itemCount - 2) {
return SelectType.COMBINATION_COLOR;
}
if (selectedIndex == 0) {
if (selectedIndex == 0 && ChartEditContext.supportTheme()) {
return SelectType.DEFAULT;
}
return SelectType.NORMAL;

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

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

@ -0,0 +1,207 @@
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 SearchFRTreeComboBox extends FRTreeComboBox {
private static final String DOT = ".";
// 持有父容器,需要实时获取其他组件值
private final ChoosePane parent;
public SearchFRTreeComboBox(ChoosePane parent, JTree tree, TreeCellRenderer renderer) {
super(tree, renderer);
this.parent = parent;
setUI(new SearchFRTreeComboBoxUI());
}
protected UIComboBoxEditor createEditor() {
return new SearchFRComboBoxEditor(this);
}
/**
* 执行模糊搜索
*/
private void searchExecute() {
UIComboBoxEditor searchEditor = (UIComboBoxEditor) this.getEditor();
new SwingWorker<Void, Void>() {
@Override
protected Void doInBackground() {
processTableDataNames(
parent.getDSName(),
parent.getConnection(),
parent.getSchema(),
createFilter((String) searchEditor.getItem(), parent.getSchema()));
return null;
}
@Override
protected void done() {
expandTree();
// 输入框获取焦点
searchEditor.getEditorComponent().requestFocus();
}
}.execute();
}
private TableNameFilter createFilter(String text, String schema) {
return StringUtils.isEmpty(text) ? EMPTY_FILTER : new TableNameFilter(text, schema);
}
/**
* 查询数据库表并构建节点目录
*
* @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, String schema) {
// 有模式的截掉,不参与模糊搜索
if (StringUtils.isNotEmpty(schema) && searchFilter.startsWith(schema + DOT)) {
searchFilter = searchFilter.substring(schema.length() + 1);
}
this.searchFilter = searchFilter.toLowerCase().trim();
}
// 表名匹配
@Override
public boolean accept(TableProcedure procedure) {
return procedure.getName().toLowerCase().contains(searchFilter);
}
}
/**
* 重写FRTreeComboBoxUI实现点击下拉时触发模糊搜索
*/
private class SearchFRTreeComboBoxUI extends FRTreeComboBoxUI {
@Override
public void mouseClicked(MouseEvent e) {
searchExecute();
}
}
/**
* 重写输入框编辑器实现输入框模糊搜索逻辑
*/
private class SearchFRComboBoxEditor extends FrTreeSearchComboBoxEditor {
public SearchFRComboBoxEditor(FRTreeComboBox comboBox) {
super(comboBox);
}
@Override
protected void changeHandler() {
if (isSetting()) {
return;
}
setPopupVisible(true);
this.item = textField.getText();
searchExecute();
}
}
}

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

8
designer-base/src/main/java/com/fr/design/gui/iprogressbar/ProgressDialog.java

@ -31,22 +31,22 @@ public class ProgressDialog extends UIDialog {
super(parent);
setUndecorated(true);
setSize(parent.getSize());
setLocationRelativeTo(null);
setLocation(parent.getLocation());
OSSupportCenter.buildAction(new OSBasedAction() {
@Override
public void execute(Object... objects) {
setOpacity(0.5f);
}
}, SupportOSImpl.OPACITY);
initComponent();
initComponent(parent);
}
private void initComponent() {
private void initComponent(Frame parent) {
centerDialog = new JDialog(this);
centerDialog.setSize(new Dimension(482, 124));
centerDialog.setUndecorated(true);
GUICoreUtils.centerWindow(centerDialog);
centerDialog.setLocationRelativeTo(parent);
JPanel panel = new JPanel();
panel.setBorder(new UIProgressBorder(3, UIConstants.DEFAULT_BG_RULER, 14, 46, 47, 37, 47));
panel.setLayout(new BorderLayout(4, 15));

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

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

@ -4,7 +4,6 @@ package com.fr.design.gui.style;
* Copyright(c) 2001-2010, FineReport Inc, All Rights Reserved.
*/
import com.fr.base.BaseUtils;
import com.fr.base.CellBorderStyle;
import com.fr.base.Style;
import com.fr.design.constants.LayoutConstants;
@ -17,14 +16,20 @@ 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.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 +43,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 +54,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 +82,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 +103,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 +131,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 +175,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,9 +196,42 @@ 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
@ -213,7 +247,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 +287,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;
}

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

@ -0,0 +1,111 @@
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.utils.TemplateUtils;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.file.FileNodeFILE;
import com.fr.file.filetree.FileNode;
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;
import javax.swing.UIManager;
/**
* @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));
UILabel iconLabel = new UILabel(UIManager.getIcon("OptionPane.warningIcon"));
panel.add(iconLabel, BorderLayout.WEST);
panel.add(createContentPane(userInfo), BorderLayout.CENTER);
panel.add(createControlPane(), BorderLayout.SOUTH);
this.getContentPane().add(panel);
this.setTitle(Toolkit.i18nText("Fine-Design_Basic_Alert"));
this.setSize(400, 180);
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(15, 0, 0, 0));
contentPanel.add(new UILabel(Toolkit.i18nText("Fine-Design_Template_Lock_And_SaveAs_Tip")), BorderLayout.NORTH);
JPanel detailInfoPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_S_Pane();
detailInfoPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 0,0));
if (userInfo != null && StringUtils.isNotEmpty(userInfo.getUserName())) {
detailInfoPane.add(createLabel(Toolkit.i18nText("Fine-Design_Template_Lock_Holder", userInfo.getUserName())));
}
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(5, 0, 0, 0));
return label;
}
private JPanel createControlPane() {
JPanel controlPane = new JPanel(new FlowLayout(FlowLayout.RIGHT));
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) {
new LockInfoDialog(userInfo);
}
}

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

@ -0,0 +1,18 @@
package com.fr.design.lock;
import com.fr.report.lock.DefaultLockInfoOperator;
import com.fr.report.lock.LockInfoOperator;
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;
}
}

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

68
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,11 +57,13 @@ 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;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import javax.swing.UIManager;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import java.awt.BorderLayout;
@ -127,6 +130,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 +153,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 +191,54 @@ 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);
rightToolBar.add(new UILabel(Toolkit.i18nText("Fine_Design_Template_Lock_Status")));
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,
UIManager.getIcon("OptionPane.warningIcon"),
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 +598,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

@ -30,12 +30,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 OpenLoadingPane loadingPane = new OpenLoadingPane();
private OpenFailedPane failedPane = new OpenFailedPane();
private ForbiddenPane forbiddenPane = new ForbiddenPane();
Map<Component, Boolean> backUpToolbarComponentState = new HashMap<>();
@ -52,6 +54,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);
}
@ -93,6 +96,8 @@ public class DesktopCardPane extends BasicPane implements TargetModifiedListener
showOpenStatus();
} else if (jt.isOpenFailed()) {
showOpenFailedCover(jt.getTemplateOpenFailedTip());
} else if (jt.isForbidden()) {
showForbiddenStatus();
} else {
hideCover();
}
@ -138,6 +143,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();

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

@ -0,0 +1,181 @@
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.Graphics;
import java.awt.LayoutManager;
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 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 - Y_GAP;
int refreshButtonWidth = refreshButton.getPreferredSize().width;
int refreshButtonHeight = refreshButton.getPreferredSize().height;
int refreshButtonX = (width - refreshButtonWidth) / 2 + X_GAP;
int refreshButtonY = tipLabelY + refreshButtonHeight;
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"));
tipLabel.setForeground(TIP_COLOR);
refreshButton = new JButton(Toolkit.i18nText("Fine-Design_Basic_Refresh")) {
@Override
public void paintComponent(Graphics g)
{
g.setColor(BUTTON_COLOR);
g.fillRect(0, 0, getSize().width, getSize().height);
super.paintComponent(g);
}
};
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) {
}
}
}

22
designer-base/src/main/java/com/fr/design/mainframe/share/collect/ComponentCollector.java

@ -343,21 +343,12 @@ public class ComponentCollector implements XMLable {
}
public void clickComponentSetting() {
if (!ComponentShareUtil.needShowEmbedFilterPane()) {
return;
}
boolean changed = false;
int firstShowReact = ComponentReuseNotificationInfo.getInstance().isWidgetLibHasRefreshed() ? 2 : -1;
if (this.firstShowReact != firstShowReact) {
this.firstShowReact = firstShowReact;
changed = true;
collectFirstShowReact(firstShowReact);
}
if (this.embededFilterReact == 0 && ComponentReuseNotificationInfo.getInstance().isWidgetLibHasRefreshed()) {
this.embededFilterReact = -1;
changed = true;
}
if (changed) {
saveInfo();
collectEmbededFilterReact(-1);
}
}
@ -374,11 +365,16 @@ public class ComponentCollector implements XMLable {
return;
}
if (System.currentTimeMillis() - ComponentReuseNotificationInfo.getInstance().getFirstDragEndTime() <= ONE_MINUTE) {
this.dynamicEffectReact = 1;
saveInfo();
collectDynamicEffectReactFlag(1);
}
}
public void collectDynamicEffectReactFlag(int flag) {
this.dynamicEffectReact = flag;
saveInfo();
}
public void clearSortType() {
sortType = JSONFactory.createJSON(JSON.ARRAY);
}

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

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

@ -1,12 +1,15 @@
package com.fr.design.mainframe.theme.preview.ecpreview.cell;
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;
@ -19,7 +22,19 @@ public abstract class AbstractPreviewCell extends JComponent {
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);

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

@ -17,6 +17,7 @@ import com.fr.design.actions.community.FacebookFansAction;
import com.fr.design.actions.community.NeedAction;
import com.fr.design.actions.community.QuestionAction;
import com.fr.design.actions.community.SignAction;
import com.fr.design.actions.community.StudyPlanAction;
import com.fr.design.actions.community.TechSolutionAction;
import com.fr.design.actions.community.TechSupportAction;
import com.fr.design.actions.community.TemplateStoreAction;
@ -601,6 +602,7 @@ public abstract class ToolBarMenuDock {
shortCuts.add(new TutorialAction());
}
}, SupportLocaleImpl.TUTORIAL_COMMUNITY);
shortCuts.add(new StudyPlanAction());
shortCuts.add(new QuestionAction());
shortCuts.add(new TechSolutionAction());

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

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

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

@ -0,0 +1,112 @@
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.report.UnLockedException;
import com.fr.workspace.exception.DiskSpaceFullException;
import com.fr.report.InconsistentLockException;
import java.awt.Frame;
import javax.swing.JOptionPane;
import javax.swing.UIManager;
/**
* @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);
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,
UIManager.getIcon("OptionPane.warningIcon"),
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)

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

BIN
designer-base/src/main/resources/com/fr/design/images/bbs/studyPlan.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

1
designer-base/src/main/resources/com/fr/design/images/bbs/studyPlan_normal.svg

@ -0,0 +1 @@
<svg id="图层_1" data-name="图层 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><title>l</title><path d="M8.77.94A7.13,7.13,0,0,0,3.27,2.8,7.2,7.2,0,0,0,8.14,15.3a7.11,7.11,0,0,0,3.23-.77l-.54-1a6,6,0,1,1,2.34-2.08.59.59,0,0,0,1,.65A7.2,7.2,0,0,0,8.77.94Z"/><path d="M6.35,8.54h3.73a1.66,1.66,0,0,0,0-3.31H6.79a1.08,1.08,0,0,0-2.06.47A1.08,1.08,0,0,0,5.81,6.78a1.1,1.1,0,0,0,1-.61h3.29a.72.72,0,0,1,0,1.43H6.35a1.82,1.82,0,0,0,0,3.63H9.73a.87.87,0,0,0,.69.35.86.86,0,1,0-.73-1.29H6.35a.88.88,0,0,1,0-1.75ZM6.19,5.71a.38.38,0,1,1-.38-.38A.38.38,0,0,1,6.19,5.71ZM10.42,11a.28.28,0,0,1-.27-.28.27.27,0,0,1,.54,0A.28.28,0,0,1,10.42,11Z"/></svg>

After

Width:  |  Height:  |  Size: 655 B

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/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

10
designer-chart/src/main/java/com/fr/design/chart/ChartTypePane.java

@ -11,10 +11,9 @@ import com.fr.design.ChartTypeInterfaceManager;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.chart.info.ChartInfoCollector;
import com.fr.design.mainframe.chart.mode.ChartEditContext;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.plugin.chart.vanchart.VanChart;
import com.fr.van.chart.config.DefaultStyleHelper4Van;
import javax.swing.BorderFactory;
import javax.swing.DefaultListCellRenderer;
@ -155,12 +154,7 @@ public class ChartTypePane extends ChartCommonWizardPane implements CallbackEven
}
}
if (!ChartEditContext.supportTheme() && chart4Update instanceof VanChart) {
//主题中有的属性 界面上屏蔽不跟随主题 属性全部设置成自定义
((VanChart) chart4Update).setThemeCustom();
// //主题中没有的 根据主题深浅色自动 的属性 默认自动
// ((VanChart) chart4Update).setAutoThemeCustom();
}
DefaultStyleHelper4Van.checkChartDefaultStyle4Duchamp(chart4Update);
update(chart4Update);
}

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

@ -12,14 +12,13 @@ import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.hyperlink.AbstractHyperLinkPane;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.chart.ChartHyperEditPane;
import com.fr.design.mainframe.chart.mode.ChartEditContext;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.plugin.chart.vanchart.VanChart;
import com.fr.van.chart.config.DefaultStyleHelper4Van;
import java.util.HashMap;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.util.HashMap;
/**
* 类说明: 图表超链 -- 弹出 悬浮窗.
@ -73,12 +72,7 @@ public class ChartHyperPoplinkPane extends AbstractHyperLinkPane<ChartHyperPopli
if (chart != null) {
try {
ChartProvider clone = (ChartProvider) chart.clone();
if (!ChartEditContext.supportTheme() && clone instanceof VanChart) {
//主题中有的属性 界面上屏蔽不跟随主题 属性全部设置成自定义
((VanChart) clone).setThemeCustom();
// //主题中没有的 根据主题深浅色自动 的属性 默认自动
// ((VanChart) chart4Update).setAutoThemeCustom();
}
DefaultStyleHelper4Van.checkChartDefaultStyle4Duchamp(clone);
cc.addChart(clone);
} catch (CloneNotSupportedException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);

9
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java

@ -18,11 +18,11 @@ import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.chart.gui.ChartTypePane.ComboBoxPane;
import com.fr.design.mainframe.chart.info.ChartInfoCollector;
import com.fr.design.mainframe.chart.mode.ChartEditContext;
import com.fr.general.ComparatorUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.plugin.chart.vanchart.VanChart;
import com.fr.stable.StringUtils;
import com.fr.van.chart.config.DefaultStyleHelper4Van;
import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
@ -155,12 +155,7 @@ public class ChartTypeButtonPane extends BasicBeanPane<ChartCollection> implemen
addButton.addActionListener((e) -> {
String name = getNewChartName();
ChartProvider chart = getChangeStateNewChart();
if (!ChartEditContext.supportTheme() && chart instanceof VanChart) {
//主题中有的属性 界面上屏蔽不跟随主题 属性全部设置成自定义
((VanChart) chart).setThemeCustom();
// //主题中没有的 根据主题深浅色自动 的属性 默认自动
// ((VanChart) chart4Update).setAutoThemeCustom();
}
DefaultStyleHelper4Van.checkChartDefaultStyle4Duchamp(chart);
checkInForm(chart);
addNewChart(chart, name, editingCollection.getChartCount());
});

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

@ -13,6 +13,7 @@ import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.TableLayout;
import com.fr.design.mainframe.chart.mode.ChartEditContext;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.FRFont;
import com.fr.general.GeneralUtils;
@ -29,17 +30,21 @@ public class ChartTextAttrPane extends BasicPane {
private static final long serialVersionUID = 6731679928019436869L;
public static final int FONT_START = 6;
public static final int FONT_END = 72;
public static final int FONT_END_4_DUCHAMP = 200;
private UIComboBox fontNameComboBox;
private UIComboBox fontSizeComboBox;
private UIToggleButton bold;
private UIToggleButton italic;
private UIColorButton fontColor;
public static Integer[] FONT_SIZES = new Integer[FONT_END - FONT_START + 1];
private static Integer[] FONT_SIZES_4_DUCHAMP = new Integer[FONT_END_4_DUCHAMP - FONT_START + 1];
static {
for (int i = FONT_START; i <= FONT_END; i++) {
FONT_SIZES[i - FONT_START] = i;
}
for (int i = FONT_START; i <= FONT_END_4_DUCHAMP; i++) {
FONT_SIZES_4_DUCHAMP[i - FONT_START] = i;
}
}
public ChartTextAttrPane() {
@ -181,7 +186,7 @@ public class ChartTextAttrPane extends BasicPane {
}
protected Object[] getFontSizeComboBoxModel() {
return FONT_SIZES;
return ChartEditContext.duchampMode() ? FONT_SIZES_4_DUCHAMP : FONT_SIZES;
}
protected void initState() {

13
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ChartTextAttrPaneWithAuto.java

@ -4,23 +4,30 @@ import com.fr.chart.base.ChartConstants;
import com.fr.design.gui.ibutton.UIColorButton;
import com.fr.design.gui.ibutton.UIColorButtonWithAuto;
import com.fr.design.i18n.Toolkit;
import com.fr.plugin.chart.type.FontAutoType;
import com.fr.design.mainframe.chart.mode.ChartEditContext;
import com.fr.general.ComparatorUtils;
import com.fr.general.FRFont;
import com.fr.general.GeneralUtils;
import com.fr.plugin.chart.type.FontAutoType;
public class ChartTextAttrPaneWithAuto extends ChartTextAttrPane {
private static final String AUTO = Toolkit.i18nText("Fine-Design_Basic_ChartF_Auto");
private FontAutoType type;
public static String[] FONT_SIZES_WITH_AUTO = new String[FONT_END - FONT_START + 2];
private static String[] FONT_SIZES_WITH_AUTO_4_DUCHAMP = new String[FONT_END_4_DUCHAMP - FONT_START + 2];
static {
FONT_SIZES_WITH_AUTO[0] = AUTO;
FONT_SIZES_WITH_AUTO_4_DUCHAMP[0] = AUTO;
for (int i = 1; i < FONT_SIZES_WITH_AUTO.length; i++) {
FONT_SIZES_WITH_AUTO[i] = FONT_START + i - 1 + "";
}
for (int i = 1; i < FONT_SIZES_WITH_AUTO_4_DUCHAMP.length; i++) {
FONT_SIZES_WITH_AUTO_4_DUCHAMP[i] = FONT_START + i - 1 + "";
}
}
public ChartTextAttrPaneWithAuto(FontAutoType type) {
@ -42,7 +49,9 @@ public class ChartTextAttrPaneWithAuto extends ChartTextAttrPane {
}
protected Object[] getFontSizeComboBoxModel() {
return isFontSizeAuto() ? FONT_SIZES_WITH_AUTO : FONT_SIZES;
return isFontSizeAuto()
? (ChartEditContext.duchampMode() ? FONT_SIZES_WITH_AUTO_4_DUCHAMP : FONT_SIZES_WITH_AUTO)
: super.getFontSizeComboBoxModel();
}
protected float updateFontSize() {

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

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

@ -18,35 +18,35 @@ import java.awt.Font;
* Created by shine on 2021/6/25
*/
public class DefaultStyleConstants {
static final FRFont TITLE = FRFont.getInstance(ChartBaseUtils.getLocalDefaultFont("Microsoft YaHei"), Font.BOLD, 14, new Color(241, 246, 255));
static final FRFont LEGEND = FRFont.getInstance(ChartBaseUtils.getLocalDefaultFont("Microsoft YaHei"), Font.PLAIN, 9, new Color(159, 173, 191));
static final FRFont TITLE = FRFont.getInstance(ChartBaseUtils.getLocalDefaultFont("Microsoft YaHei"), Font.BOLD, 19, new Color(241, 246, 255));
static final FRFont LEGEND = FRFont.getInstance(ChartBaseUtils.getLocalDefaultFont("Microsoft YaHei"), Font.PLAIN, 12, new Color(159, 173, 191));
static final FRFont AXIS_LABEL = FRFont.getInstance(ChartBaseUtils.getLocalDefaultFont("Microsoft YaHei"), Font.PLAIN, 9, new Color(159, 173, 191));
static final FRFont AXIS_TITLE = FRFont.getInstance(ChartBaseUtils.getLocalDefaultFont("Microsoft YaHei"), Font.PLAIN, 9, new Color(200, 211, 228));
static final FRFont AXIS_LABEL = FRFont.getInstance(ChartBaseUtils.getLocalDefaultFont("Microsoft YaHei"), Font.PLAIN, 12, new Color(159, 173, 191));
static final FRFont AXIS_TITLE = FRFont.getInstance(ChartBaseUtils.getLocalDefaultFont("Microsoft YaHei"), Font.PLAIN, 12, new Color(200, 211, 228));
static final Color AXIS_LINE = new Color(46, 75, 102);
static final Color GRID_LINE = new Color(30, 55, 78);
static final FRFont ALERT_FONT = FRFont.getInstance(ChartBaseUtils.getLocalDefaultFont("Microsoft YaHei"), Font.PLAIN, 9, new Color(255, 0, 0));
static final FRFont ALERT_FONT = FRFont.getInstance(ChartBaseUtils.getLocalDefaultFont("Microsoft YaHei"), Font.PLAIN, 12, new Color(255, 0, 0));
static final FRFont DATA_SHEET = FRFont.getInstance(ChartBaseUtils.getLocalDefaultFont("Microsoft YaHei"), Font.PLAIN, 9, new Color(159, 173, 191));
static final FRFont DATA_SHEET = FRFont.getInstance(ChartBaseUtils.getLocalDefaultFont("Microsoft YaHei"), Font.PLAIN, 12, new Color(159, 173, 191));
static final Color DATA_SHEET_BORDER = new Color(46, 75, 102);
static final Color BORDER = Color.BLACK;
static final int BORDER_WIDTH = Constants.LINE_NONE;
static final int SPECIAL_BORDER_WIDTH = Constants.LINE_THIN;
static final FRFont PIE_CATEGORY_LABEL = FRFont.getInstance(ChartBaseUtils.getLocalDefaultFont("Microsoft YaHei"), Font.PLAIN, 10, new Color(232, 232, 232));
static final FRFont PIE_CATEGORY_LABEL = FRFont.getInstance(ChartBaseUtils.getLocalDefaultFont("Microsoft YaHei"), Font.PLAIN, 13, new Color(232, 232, 232));
static final Color GAUGE_PANE_BACK_COLOR = null;
static final Color GAUGE_HINGE = null;
static final Color GAUGE_PANE_BACK_COLOR_4_RING = new Color(72, 73, 79);
static final Color GAUGE_SLOT_BACKGROUND_COLOR = new Color(72, 73, 79);
private static final String FONT_NAME = ChartBaseUtils.getLocalDefaultFont("verdana");
static final FRFont THERMOMETER_LABEL_FONT = FRFont.getInstance(FONT_NAME, Font.BOLD, 9, new Color(232, 232, 232));//试管仪表盘标签的默认样式
static final FRFont THERMOMETER_AXIS_LABEL = FRFont.getInstance(FONT_NAME, Font.PLAIN, 8, new Color(159, 173, 191));
static final FRFont THERMOMETER_LABEL_FONT = FRFont.getInstance(FONT_NAME, Font.BOLD, 12, new Color(232, 232, 232));//试管仪表盘标签的默认样式
static final FRFont THERMOMETER_AXIS_LABEL = FRFont.getInstance(FONT_NAME, Font.PLAIN, 11, new Color(159, 173, 191));
static final FRFont RING_VALUE_LABEL_FONT = FRFont.getInstance(FONT_NAME, Font.PLAIN, ChartConstants.AUTO_FONT_SIZE, new Color(232, 232, 232));//百分比圆环仪表盘值标签的默认样式
static final FRFont POINTER_VALUE_LABEL_FONT = FRFont.getInstance(FONT_NAME, Font.PLAIN, ChartConstants.AUTO_FONT_SIZE, new Color(232, 232, 232));//多指针仪表盘值标签的默认样式
static final FRFont POINTER_CATE_LABEL_FONT = FRFont.getInstance(FONT_NAME, Font.PLAIN, 10, new Color(232, 232, 232));//多指针仪表盘分类标签的默认样式
static final FRFont POINTER_CATE_LABEL_FONT = FRFont.getInstance(FONT_NAME, Font.PLAIN, 13, new Color(232, 232, 232));//多指针仪表盘分类标签的默认样式
static final Color MAP_NULL_VALUE_COLOR = new Color(168, 168, 168);
static final Color MAP_BORDER = Color.BLACK;
@ -56,36 +56,41 @@ public class DefaultStyleConstants {
static final Color DRILL_MAP_DRILL_TOOLS_BACK = Color.BLACK;
static final float DRILL_MAP_DRILL_TOOLS_BACK_OPACITY = 0.8f;
//todo vancharts
private static final Color GANTT_OUT_LINE = GRID_LINE;
private static final FRFont GANTT_LABEL = FRFont.getInstance(ChartBaseUtils.getLocalDefaultFont("Microsoft YaHei"), Font.PLAIN, 8, new Color(217, 217, 217));
private static final Color GANTT_BORDER_LINE = new Color(30, 36, 58);
private static final Color GAUGE_TICK = new Color(39, 49, 71);
static final Background BACK = null;
//新特新
public static String COLOR_NAME_1;
//经典高亮
private static String COLOR_NAME_2;
static {
try {
COLOR_NAME_1 = CodeUtils.cjkDecode("\u65b0\u7279\u6027");
COLOR_NAME_2 = CodeUtils.cjkDecode("\u7ecf\u5178\u9ad8\u4eae");
} catch (Exception e) {
e.printStackTrace();
}
}
static String COLORS = null;
static {
ChartPreStyleConfig config = ChartPreStyleConfig.getInstance();
try {
DefaultStyleConstants.COLORS = CodeUtils.cjkDecode("\u7ecf\u5178\u9ad8\u4eae");
// 没有经典高亮, 用新特性
if (config.getPreStyle(DefaultStyleConstants.COLORS) == null) {
DefaultStyleConstants.COLORS = CodeUtils.cjkDecode("\u65b0\u7279\u6027");
}
// 没有新特性, 用第一个配色
if (config.getPreStyle(DefaultStyleConstants.COLORS) == null) {
if (config.names().hasNext()) {
String name = GeneralUtils.objectToString(config.names().next());
if (config.getPreStyle(name) != null) {
DefaultStyleConstants.COLORS = name;
}
COLORS = COLOR_NAME_2;
// 没有经典高亮, 用新特性
if (config.getPreStyle(COLORS) == null) {
COLORS = COLOR_NAME_1;
}
// 没有新特性, 用第一个配色
if (config.getPreStyle(COLORS) == null) {
if (config.names().hasNext()) {
String name = GeneralUtils.objectToString(config.names().next());
if (config.getPreStyle(name) != null) {
COLORS = name;
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}

66
designer-chart/src/main/java/com/fr/van/chart/config/DefaultStyleHelper4Van.java

@ -1,11 +1,14 @@
package com.fr.van.chart.config;
import com.fr.base.ChartColorMatching;
import com.fr.base.ChartPreStyleConfig;
import com.fr.chart.base.AttrBorder;
import com.fr.chart.base.AttrFillStyle;
import com.fr.chart.base.ChartConstants;
import com.fr.chart.chartattr.Plot;
import com.fr.chart.chartglyph.ConditionAttr;
import com.fr.chart.chartglyph.DataSheet;
import com.fr.chartx.attr.ChartProvider;
import com.fr.config.predefined.ColorFillStyle;
import com.fr.design.mainframe.chart.mode.ChartEditContext;
import com.fr.plugin.chart.PiePlot4VanChart;
@ -19,6 +22,7 @@ import com.fr.plugin.chart.custom.type.CustomPlotType;
import com.fr.plugin.chart.gauge.VanChartGaugePlot;
import com.fr.plugin.chart.map.VanChartMapPlot;
import com.fr.plugin.chart.type.GaugeStyle;
import com.fr.plugin.chart.vanchart.VanChart;
/**
* @author shine
@ -28,8 +32,27 @@ import com.fr.plugin.chart.type.GaugeStyle;
*/
public class DefaultStyleHelper4Van {
private static boolean duchampMode() {
try {
return ChartEditContext.duchampMode();
} catch (Throwable e) {
//tomcat预览 默认数据的图表
return true;
}
}
public static void checkChartDefaultStyle4Duchamp(ChartProvider chartProvider) {
if (!ChartEditContext.supportTheme() && chartProvider instanceof VanChart) {
//主题中有的属性 界面上屏蔽不跟随主题 属性全部设置成自定义
((VanChart) chartProvider).setThemeCustom();
dealChartColor((VanChart) chartProvider);
// //主题中没有的 根据主题深浅色自动 的属性 默认自动
// ((VanChart) chart4Update).setAutoThemeCustom();
}
}
public static void dealVanPlot4Custom(VanChartPlot plot, CustomPlotType customPlotType) {
if (!ChartEditContext.duchampMode()) {
if (!duchampMode()) {
return;
}
dealVanPlotCommonAttr(plot);
@ -60,7 +83,7 @@ public class DefaultStyleHelper4Van {
}
public static VanChartAxis dealAxisDefault(VanChartAxis axis) {
if (!ChartEditContext.duchampMode()) {
if (!duchampMode()) {
return axis;
}
axis.getTitle().getTextAttr().setFRFont(DefaultStyleConstants.AXIS_TITLE);
@ -71,28 +94,20 @@ public class DefaultStyleHelper4Van {
}
public static void dealAxisAlert(VanChartAlertValue vanChartAlertValue) {
if (!ChartEditContext.duchampMode()) {
if (!duchampMode()) {
return;
}
vanChartAlertValue.setAlertFont(DefaultStyleConstants.ALERT_FONT);
}
static void dealVanPlotCommonAttr(Plot plot) {
if (!ChartEditContext.duchampMode()) {
if (!duchampMode()) {
return;
}
if (plot instanceof VanChartPlot) {
VanChartPlot vanChartPlot = (VanChartPlot) plot;
ColorFillStyle colorFillStyle = new ColorFillStyle();
colorFillStyle.setColorStyle(ChartConstants.COLOR_ACC);
colorFillStyle.setFillStyleName(DefaultStyleConstants.COLORS);
AttrFillStyle plotFillStyle = vanChartPlot.getPlotFillStyle();
if (plotFillStyle == null) {
plotFillStyle = new AttrFillStyle();
vanChartPlot.setPlotFillStyle(plotFillStyle);
}
plotFillStyle.setColorFillStyle(colorFillStyle);
dealChartColor(vanChartPlot);
if (vanChartPlot.getLegend() != null) {
vanChartPlot.getLegend().setFRFont(DefaultStyleConstants.LEGEND);
@ -118,6 +133,31 @@ public class DefaultStyleHelper4Van {
}
private static void dealChartColor(VanChart vanChart) {
dealChartColor(vanChart.getPlot());
}
private static void dealChartColor(VanChartPlot vanChartPlot) {
ChartPreStyleConfig manager = ChartPreStyleConfig.getInstance();
Object preStyle = manager.getPreStyle(DefaultStyleConstants.COLORS);
if (preStyle instanceof ChartColorMatching) {
ColorFillStyle colorFillStyle = new ColorFillStyle();
//default是默认的意思,为服务器默认配色方案
//acc为多个颜色组合
//gradient为渐变颜色
colorFillStyle.setColorStyle(ChartConstants.COLOR_ACC);
colorFillStyle.setFillStyleName(DefaultStyleConstants.COLORS);
colorFillStyle.setColorList(((ChartColorMatching) preStyle).getColorList());
AttrFillStyle plotFillStyle = vanChartPlot.getPlotFillStyle();
if (plotFillStyle == null) {
plotFillStyle = new AttrFillStyle();
vanChartPlot.setPlotFillStyle(plotFillStyle);
}
plotFillStyle.setColorFillStyle(colorFillStyle);
}
}
private static void dealBorder(VanChartPlot vanChartPlot) {
ConditionAttr defaultAttr = vanChartPlot.getConditionCollection().getDefaultAttr();
AttrBorder attrBorder = defaultAttr.getExisted(AttrBorder.class);

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},

15
designer-chart/src/main/java/com/fr/van/chart/designer/type/AbstractVanChartTypePane.java

@ -32,6 +32,7 @@ import com.fr.plugin.chart.attr.plot.VanChartPlot;
import com.fr.plugin.chart.base.VanChartTools;
import com.fr.plugin.chart.base.VanChartZoom;
import com.fr.plugin.chart.vanchart.VanChart;
import com.fr.van.chart.config.DefaultStyleHelper4Van;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
@ -145,12 +146,7 @@ public abstract class AbstractVanChartTypePane extends AbstractChartTypePane<Van
chart.setPlot(cloneOldPlot2New(oldPlot, newPlot));
resetChartAttr4SamePlot(chart);
ChartInfoCollector.getInstance().updateChartMiniType(chart);
if (!ChartEditContext.supportTheme()) {
//主题中有的属性 界面上屏蔽不跟随主题 属性全部设置成自定义
chart.setThemeCustom();
// //主题中没有的 根据主题深浅色自动 的属性 默认自动
// ((VanChart) chart4Update).setAutoThemeCustom();
}
DefaultStyleHelper4Van.checkChartDefaultStyle4Duchamp(chart);
} else if (!samePlot) {
//不同的图表类型切換
resetChartAttr(chart, newPlot);
@ -158,12 +154,7 @@ public abstract class AbstractVanChartTypePane extends AbstractChartTypePane<Van
newPlot.setCategoryNum(oldPlot.getCategoryNum());
//切换类型埋点
ChartInfoCollector.getInstance().updateChartTypeTime(chart, oldPlot.getPlotID());
if (!ChartEditContext.supportTheme()) {
//主题中有的属性 界面上屏蔽不跟随主题 属性全部设置成自定义
chart.setThemeCustom();
// //主题中没有的 根据主题深浅色自动 的属性 默认自动
// ((VanChart) chart4Update).setAutoThemeCustom();
}
DefaultStyleHelper4Van.checkChartDefaultStyle4Duchamp(chart);
}
if (!ChartEditContext.supportTheme()) {
chart.setAutoThemeCustom();

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

27
designer-chart/src/main/resources/com/fr/design/editor/rich_editor.html

@ -20,6 +20,33 @@
<script src="script/editor.service.js"></script>
<script>
window.onload = function () {
BI.config("bi.constant.materials.rich_editor.font_size", function (items) {
return [
{
value: 9,
text: 9
},
{
value: 10,
text: 10
},
{
value: 11,
text: 11
},
].concat(items);
});
BI.config("bi.constant.materials.rich_editor.font_size_range", function (range) {
return {
MIN: 9,
MAX: 128
};
});
var content = Pool.data.getContent();
var isAuto = Pool.data.isAuto();
var params = Pool.data.getParams();

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

Loading…
Cancel
Save