Browse Source

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

feature/x
fly.li 3 years ago
parent
commit
fea537f331
  1. 7
      build.gradle
  2. 3
      designer-base/src/main/java/com/fr/base/svg/IconUtils.java
  3. 6
      designer-base/src/main/java/com/fr/base/svg/SVGIcon.java
  4. 92
      designer-base/src/main/java/com/fr/base/svg/SVGLoader.java
  5. 181
      designer-base/src/main/java/com/fr/base/svg/SVGTranscoder.java
  6. 101
      designer-base/src/main/java/com/fr/base/svg/SystemScaleUtils.java
  7. 13
      designer-base/src/main/java/com/fr/design/DesignModelAdapter.java
  8. 2
      designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java
  9. 14
      designer-base/src/main/java/com/fr/design/data/datapane/connect/AdvancePane.java
  10. 44
      designer-base/src/main/java/com/fr/design/data/datapane/connect/DatabaseConnectionPane.java
  11. 19
      designer-base/src/main/java/com/fr/design/data/datapane/connect/JDBCDefPane.java
  12. 301
      designer-base/src/main/java/com/fr/design/data/datapane/connect/SshPane.java
  13. 164
      designer-base/src/main/java/com/fr/design/data/datapane/connect/SslPane.java
  14. 109
      designer-base/src/main/java/com/fr/design/data/tabledata/wrapper/StoreProcedureDataWrapper.java
  15. 15
      designer-base/src/main/java/com/fr/design/deeplink/DeepLink.java
  16. 184
      designer-base/src/main/java/com/fr/design/deeplink/DeepLinkCore.java
  17. 33
      designer-base/src/main/java/com/fr/design/editor/editor/NotNegativeIntegerEditor.java
  18. 23
      designer-base/src/main/java/com/fr/design/extra/WebViewDlgHelper.java
  19. 12
      designer-base/src/main/java/com/fr/design/formula/FormulaPane.java
  20. 17
      designer-base/src/main/java/com/fr/design/formula/FunctionConstants.java
  21. 2
      designer-base/src/main/java/com/fr/design/formula/exception/function/MismatchedTokenFunction.java
  22. 43
      designer-base/src/main/java/com/fr/design/gui/icombobox/TableSearchTreeComboBox.java
  23. 14
      designer-base/src/main/java/com/fr/design/gui/ifilechooser/JavaFxNativeFileChooser.java
  24. 12
      designer-base/src/main/java/com/fr/design/javascript/JSContentPane.java
  25. 148
      designer-base/src/main/java/com/fr/design/javascript/JSContentWithDescriptionPane.java
  26. 7
      designer-base/src/main/java/com/fr/design/mainframe/BaseJForm.java
  27. 7
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java
  28. 10
      designer-base/src/main/java/com/fr/design/mainframe/JDashboard.java
  29. 16
      designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java
  30. 12
      designer-base/src/main/java/com/fr/design/mainframe/form/FormECDesignerProvider.java
  31. 186
      designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogHandler.java
  32. 4
      designer-base/src/main/java/com/fr/design/mainframe/share/ComponentShareUtil.java
  33. 37
      designer-base/src/main/java/com/fr/design/mainframe/share/mini/MiniShopDisposingChecker.java
  34. 11
      designer-base/src/main/java/com/fr/design/mainframe/share/mini/MiniShopNativeTask.java
  35. 42
      designer-base/src/main/java/com/fr/design/mainframe/share/mini/MiniShopNativeTaskManager.java
  36. 3
      designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeProfilePane.java
  37. 9
      designer-base/src/main/java/com/fr/design/mainframe/theme/dialog/TemplateThemeGridPagesDialog.java
  38. 2
      designer-base/src/main/java/com/fr/design/mainframe/theme/dialog/TemplateThemeProfileDialog.java
  39. 7
      designer-base/src/main/java/com/fr/design/mainframe/theme/dialog/TemplateThemeUsingDialog.java
  40. 8
      designer-base/src/main/java/com/fr/design/report/fit/FormFitAttrModelType.java
  41. 28
      designer-base/src/main/java/com/fr/design/selection/Selectedable.java
  42. 33
      designer-base/src/main/java/com/fr/design/startup/FineStartupNotificationFactory.java
  43. 14
      designer-base/src/main/java/com/fr/design/startup/FineStartupNotificationProvider.java
  44. 35
      designer-base/src/main/java/com/fr/design/startup/Install4jStartupNotificationProvider.java
  45. 4
      designer-base/src/main/java/com/fr/design/style/AbstractPopBox.java
  46. 14
      designer-base/src/main/java/com/fr/design/ui/compatible/NewModernUIPane.java
  47. 31
      designer-base/src/main/java/com/fr/design/upm/UpmFinder.java
  48. 14
      designer-base/src/main/java/com/fr/design/utils/DesignUtils.java
  49. 2
      designer-base/src/main/java/com/fr/design/utils/LoadingUtils.java
  50. 94
      designer-base/src/main/java/com/fr/file/FILEChooserPane.java
  51. 2
      designer-base/src/main/java/com/fr/file/FILEFactory.java
  52. 11
      designer-base/src/main/java/com/fr/file/filter/ChooseFileFilter.java
  53. 10
      designer-base/src/main/resources/com/fr/design/images/edit/advancedEditor.svg
  54. 19
      designer-base/src/main/resources/com/fr/design/images/sort/asc.svg
  55. 17
      designer-base/src/main/resources/com/fr/design/images/sort/des.svg
  56. 41
      designer-base/src/main/resources/com/fr/design/images/sort/nosort.svg
  57. 1
      designer-base/src/main/resources/com/fr/design/javascript/jsapi/category.json
  58. 8
      designer-base/src/main/resources/com/fr/design/javascript/jsapi/images/connectFailed.svg
  59. 2
      designer-base/src/main/resources/com/fr/design/javascript/jsapi/jsapi.json
  60. 50
      designer-base/src/test/java/com/fr/design/mainframe/loghandler/DesignerLogHandlerTest.java
  61. 66
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChangeConfigPane.java
  62. 9
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/report/CategoryPlotMoreCateReportDataContentPane.java
  63. 14
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/CategoryPlotMoreCateTableDataContentPane.java
  64. 2
      designer-chart/src/main/java/com/fr/van/chart/custom/style/VanChartCustomAxisPane.java
  65. 10
      designer-chart/src/main/java/com/fr/van/chart/custom/style/VanChartCustomAxisTabPane.java
  66. 117
      designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartGanttTimeLinePane.java
  67. 4
      designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartGuideLinesPane.java
  68. 10
      designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartAxisPane.java
  69. 30
      designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartAxisPaneHelper.java
  70. 166
      designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartAxisStyleSettingPane.java
  71. 507
      designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartBaseAxisPane.java
  72. 5
      designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartTimeAxisPane.java
  73. 5
      designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartValueAxisPane.java
  74. 97
      designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/component/VanChartCategoryStylePaneWithCheckBox.java
  75. 35
      designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/gauge/VanChartGaugeDetailAxisPane.java
  76. 15
      designer-chart/src/main/java/com/fr/van/chart/designer/style/background/VanChartGantAreaPane.java
  77. 102
      designer-chart/src/main/java/com/fr/van/chart/designer/style/background/VanChartGantPlotAreaBackgroundPane.java
  78. 6
      designer-chart/src/main/java/com/fr/van/chart/gantt/designer/style/VanChartGanttStylePane.java
  79. 15
      designer-chart/src/main/java/com/fr/van/chart/gantt/designer/style/series/VanChartGanttSeriesPane.java
  80. 2
      designer-chart/src/main/java/com/fr/van/chart/gantt/designer/style/tooltip/VanChartFormatComBoxWithCheckBox.java
  81. 14
      designer-form/src/main/java/com/fr/design/designer/beans/events/AddingWidgetListenerTable.java
  82. 10
      designer-form/src/main/java/com/fr/design/designer/beans/models/DraggingModel.java
  83. 11
      designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java
  84. 4
      designer-form/src/main/java/com/fr/design/designer/creator/XElementCase.java
  85. 7
      designer-form/src/main/java/com/fr/design/designer/creator/XWFitLayout.java
  86. 12
      designer-form/src/main/java/com/fr/design/designer/creator/XWParameterLayout.java
  87. 4
      designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardTagLayout.java
  88. 43
      designer-form/src/main/java/com/fr/design/fit/NewJForm.java
  89. 2
      designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java
  90. 6
      designer-form/src/main/java/com/fr/design/mainframe/FormCreatorDropTarget.java
  91. 56
      designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java
  92. 17
      designer-form/src/main/java/com/fr/design/mainframe/FormDesignerUI.java
  93. 7
      designer-form/src/main/java/com/fr/design/mainframe/FormModelAdapter.java
  94. 12
      designer-form/src/main/java/com/fr/design/mainframe/FormParaWidgetPane.java
  95. 52
      designer-form/src/main/java/com/fr/design/mainframe/JForm.java
  96. 4
      designer-form/src/main/java/com/fr/design/mainframe/share/config/ComponentReuseConfigManager.java
  97. 6
      designer-form/src/main/java/com/fr/design/mainframe/share/sort/OnlineWidgetSortType.java
  98. 1
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/LocalWidgetBlock.java
  99. 68
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/OnlineWidgetBlock.java
  100. 19
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/PreviewWidgetBlock.java
  101. Some files were not shown because too many files have changed in this diff Show More

7
build.gradle

@ -9,6 +9,7 @@ plugins {
//
ext {
frVersion = ""
cbbVersion = ""
outputPath = "build"
ignoreTestFailureSetting = true
languageLevelSetting = 1.8
@ -44,6 +45,9 @@ allprojects {
repositories {
mavenLocal()
maven {
url 'https://maven.ej-technologies.com/repository'
}
}
idea {
@ -57,6 +61,9 @@ allprojects {
}
dependencies {
implementation 'com.fr.essential:fine-essential:' + cbbVersion
implementation 'com.fr.cbb:fine-universal-skeleton:' + cbbVersion
implementation 'com.install4j:install4j-runtime:8.0.4'
implementation 'com.fr.third:jxbrowser:6.23'
implementation 'com.fr.third:jxbrowser-mac:6.23'
implementation 'com.fr.third:jxbrowser-win64:6.23'

3
designer-base/src/main/java/com/fr/base/svg/IconUtils.java

@ -6,8 +6,7 @@ import com.fr.stable.bridge.StableFactory;
import com.fr.stable.fun.ResourcePathTransformer;
import com.fr.stable.plugin.ExtraClassManagerProvider;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.*;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

6
designer-base/src/main/java/com/fr/base/svg/SVGIcon.java

@ -2,10 +2,8 @@ package com.fr.base.svg;
import com.fr.general.IOUtils;
import javax.swing.Icon;
import java.awt.Component;
import java.awt.Graphics;
import java.awt.Graphics2D;
import javax.swing.*;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

92
designer-base/src/main/java/com/fr/base/svg/SVGLoader.java

@ -1,92 +0,0 @@
package com.fr.base.svg;
import com.fr.general.IOUtils;
import org.apache.batik.transcoder.TranscoderException;
import org.apache.batik.transcoder.TranscoderInput;
import org.apache.xmlgraphics.java2d.Dimension2DDouble;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.awt.Image;
import java.io.IOException;
import java.net.URL;
/**
* SVG图标加载器
* @author Yvan
* @version 10.0
* Created by Yvan on 2020/12/17
*/
public class SVGLoader {
public static final int ICON_DEFAULT_SIZE = 16;
public SVGLoader() {
}
@Nullable
public static Image load(@NotNull String url) {
try {
URL resource = IOUtils.getResource(url, SVGLoader.class);
if (resource == null) {
return null;
}
return load(resource, SVGIcon.SYSTEM_SCALE);
} catch (IOException ignore) {
return null;
}
}
@Nullable
public static Image load(@NotNull URL url) throws IOException {
return load(url, SVGIcon.SYSTEM_SCALE);
}
@Nullable
public static Image load(@NotNull URL url, double scale) throws IOException {
try {
String svgUri = url.toString();
TranscoderInput input = new TranscoderInput(svgUri);
return SVGTranscoder.createImage(scale, input).getImage();
} catch (TranscoderException ignore) {
return null;
}
}
@Nullable
public static Image load(@NotNull URL url, double scale, Dimension2DDouble dimension) throws IOException {
try {
String svgUri = url.toString();
TranscoderInput input = new TranscoderInput(svgUri);
return SVGTranscoder.createImage(scale, input,
(float) (dimension.getWidth() * scale), (float) (dimension.getHeight() * scale)).getImage();
} catch (TranscoderException ignore) {
return null;
}
}
@Nullable
public static Image load(@NotNull URL url, double scale, double overriddenWidth, double overriddenHeight) throws IOException {
try {
String svgUri = url.toString();
TranscoderInput input = new TranscoderInput(svgUri);
return SVGTranscoder.createImage(scale, input, (float) (overriddenWidth * scale), (float) (overriddenHeight * scale)).getImage();
} catch (TranscoderException ignore) {
return null;
}
}
@Nullable
public static Image load(@NotNull String url, float width, float height) {
try {
URL resource = IOUtils.getResource(url, SVGLoader.class);
if (resource == null) {
return null;
}
TranscoderInput input = new TranscoderInput(resource.toString());
return SVGTranscoder.createImage(SVGIcon.SYSTEM_SCALE, input, -1, -1, width, height).getImage();
} catch (TranscoderException ignore) {
return null;
}
}
}

181
designer-base/src/main/java/com/fr/base/svg/SVGTranscoder.java

@ -1,181 +0,0 @@
package com.fr.base.svg;
import com.fr.stable.AssistUtils;
import com.fr.value.AtomicNotNullLazyValue;
import org.apache.batik.anim.dom.SAXSVGDocumentFactory;
import org.apache.batik.anim.dom.SVGOMDocument;
import org.apache.batik.bridge.BridgeContext;
import org.apache.batik.bridge.UserAgent;
import org.apache.batik.transcoder.SVGAbstractTranscoder;
import org.apache.batik.transcoder.TranscoderException;
import org.apache.batik.transcoder.TranscoderInput;
import org.apache.batik.transcoder.TranscoderOutput;
import org.apache.batik.transcoder.image.ImageTranscoder;
import org.apache.batik.util.XMLResourceDescriptor;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.w3c.dom.Element;
import org.w3c.dom.svg.SVGDocument;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.Rectangle;
import java.awt.geom.AffineTransform;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.StringReader;
/**
* 可以根据某个缩放倍数scale将SVG图片转化为Image对象
* @author Yvan
* @version 10.0
* Created by Yvan on 2020/12/17
*/
public class SVGTranscoder extends ImageTranscoder {
private static final float DEFAULT_VALUE = -1.0F;
public static final float ICON_DEFAULT_SIZE = 16F;
private float origDocWidth;
private float origDocHeight;
@Nullable
private BufferedImage image;
private final double scale;
@NotNull
private static AtomicNotNullLazyValue<Double> iconMaxSize = new AtomicNotNullLazyValue<Double>() {
@NotNull
@Override
protected Double compute() {
double maxSize = Double.MAX_VALUE;
if (!GraphicsEnvironment.isHeadless()) {
GraphicsDevice defaultScreenDevice = GraphicsEnvironment
.getLocalGraphicsEnvironment()
.getDefaultScreenDevice();
Rectangle bounds = defaultScreenDevice.getDefaultConfiguration().getBounds();
AffineTransform tx = defaultScreenDevice
.getDefaultConfiguration()
.getDefaultTransform();
maxSize = Math.max(bounds.width * tx.getScaleX(), bounds.height * tx.getScaleY());
}
return maxSize;
}
};
public SVGTranscoder(double scale) {
this.scale = scale;
this.width = ICON_DEFAULT_SIZE;
this.height = ICON_DEFAULT_SIZE;
}
public SVGTranscoder(double scale, float width, float height) {
this.scale = scale;
this.width = width;
this.height = height;
}
public final float getOrigDocWidth() {
return this.origDocWidth;
}
public final void setOrigDocWidth(float origDocWidth) {
this.origDocWidth = origDocWidth;
}
public final float getOrigDocHeight() {
return this.origDocHeight;
}
public final void setOrigDocHeight(float origDocHeight) {
this.origDocHeight = origDocHeight;
}
public static double getIconMaxSize() {
return iconMaxSize.getValue();
}
@Nullable
public final BufferedImage getImage() {
return this.image;
}
@NotNull
public static SVGTranscoder createImage(double scale, @NotNull TranscoderInput input) throws TranscoderException {
return createImage(scale, input, -1, -1);
}
@NotNull
public static SVGTranscoder createImage(double scale, @NotNull TranscoderInput input, float overriddenWidth, float overriddenHeight) throws TranscoderException {
return createImage(scale, input, overriddenWidth, overriddenHeight, ICON_DEFAULT_SIZE, ICON_DEFAULT_SIZE);
}
@NotNull
public static SVGTranscoder createImage(double scale, @NotNull TranscoderInput input, float overriddenWidth, float overriddenHeight, float width, float height) throws TranscoderException {
SVGTranscoder transcoder = new SVGTranscoder(scale, width, height);
if (!AssistUtils.equals(overriddenWidth, DEFAULT_VALUE)) {
transcoder.addTranscodingHint(SVGAbstractTranscoder.KEY_WIDTH, overriddenWidth);
}
if (!AssistUtils.equals(overriddenHeight, DEFAULT_VALUE)) {
transcoder.addTranscodingHint(SVGAbstractTranscoder.KEY_HEIGHT, overriddenHeight);
}
double iconMaxSize = SVGTranscoder.iconMaxSize.getValue();
transcoder.addTranscodingHint(SVGAbstractTranscoder.KEY_MAX_WIDTH, (float) iconMaxSize);
transcoder.addTranscodingHint(SVGAbstractTranscoder.KEY_MAX_HEIGHT, (float) iconMaxSize);
transcoder.transcode(input, null);
return transcoder;
}
private static SVGDocument createFallbackPlaceholder() {
try {
String fallbackIcon = "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\">\n" +
" <rect x=\"1\" y=\"1\" width=\"14\" height=\"14\" fill=\"none\" stroke=\"red\" stroke-width=\"2\"/>\n" +
" <line x1=\"1\" y1=\"1\" x2=\"15\" y2=\"15\" stroke=\"red\" stroke-width=\"2\"/>\n" +
" <line x1=\"1\" y1=\"15\" x2=\"15\" y2=\"1\" stroke=\"red\" stroke-width=\"2\"/>\n" +
"</svg>\n";
SAXSVGDocumentFactory factory = new SAXSVGDocumentFactory(XMLResourceDescriptor.getXMLParserClassName());
return (SVGDocument) factory.createDocument(null, new StringReader(fallbackIcon));
} catch (IOException e) {
throw new IllegalStateException(e);
}
}
@Override
protected void setImageSize(float docWidth, float docHeight) {
super.setImageSize((float) (docWidth * this.scale), (float) (docHeight * this.scale));
this.origDocWidth = docWidth;
this.origDocHeight = docHeight;
}
@Override
@NotNull
public BufferedImage createImage(int width, int height) {
return new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
}
@Override
public void writeImage(@NotNull BufferedImage image, @Nullable TranscoderOutput output) {
this.image = image;
}
@Override
@NotNull
protected UserAgent createUserAgent() {
return new SVGAbstractTranscoderUserAgent() {
@Override
@NotNull
public SVGDocument getBrokenLinkDocument(@NotNull Element e, @NotNull String url, @NotNull String message) {
return createFallbackPlaceholder();
}
};
}
/**
* 开放访问权限
*/
@Override
public BridgeContext createBridgeContext(SVGOMDocument doc) {
return super.createBridgeContext(doc);
}
}

101
designer-base/src/main/java/com/fr/base/svg/SystemScaleUtils.java

@ -1,101 +0,0 @@
package com.fr.base.svg;
import com.bulenkov.iconloader.util.UIUtil;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.StableUtils;
import com.fr.stable.os.OperatingSystem;
import org.jetbrains.annotations.NotNull;
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.lang.reflect.Method;
import java.util.concurrent.atomic.AtomicReference;
/**
* 获取系统Scale相关的工具类
* @author Yvan
* @version 10.0
* Created by Yvan on 2020/12/17
*/
public class SystemScaleUtils {
private static final AtomicReference<Boolean> JRE_HIDPI = new AtomicReference<>();
private static final String HI_DPI = "hidpi";
/**
* 判断是否支持高清
* @return
*/
public static boolean isJreHiDPIEnabled() {
if (JRE_HIDPI.get() != null) {
return JRE_HIDPI.get();
}
if (OperatingSystem.isMacos()) {
// 如果是mac os系统,直接返回true
return true;
}
if (OperatingSystem.isWindows() && StableUtils.getMajorJavaVersion() <= 8) {
// 如果是jdk8 + Windows系统,直接返回false
return false;
}
synchronized (JRE_HIDPI) {
if (JRE_HIDPI.get() != null) {
return JRE_HIDPI.get();
}
boolean result = false;
if (getBooleanProperty(HI_DPI, true)) {
try {
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
Class<?> sunGraphicsEnvironmentClass = Class.forName("sun.java2d.SunGraphicsEnvironment");
if (sunGraphicsEnvironmentClass.isInstance(ge)) {
try {
Method method = sunGraphicsEnvironmentClass.getDeclaredMethod("isUIScaleEnabled");
method.setAccessible(true);
result = (Boolean)method.invoke(ge);
}
catch (NoSuchMethodException e) {
FineLoggerFactory.getLogger().error(e.getMessage());
}
}
}
catch (Throwable ignore) {
}
}
JRE_HIDPI.set(result);
return result;
}
}
public static boolean getBooleanProperty(@NotNull final String key, final boolean defaultValue) {
final String value = System.getProperty(key);
return value == null ? defaultValue : Boolean.parseBoolean(value);
}
/**
* 获取系统Scale
* @return
*/
public static float sysScale() {
// 如果检测到是retina,直接返回2
if (UIUtil.isRetina()) {
return 2.0f;
}
float scale = 1.0f;
// 先判断是否支持高清,不支持代表此时是Windows + jdk8 的设计器,返回的scale值为1.0
if (isJreHiDPIEnabled()) {
// 获取屏幕图形设备对象
GraphicsDevice graphicsDevice = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
if (graphicsDevice != null) {
// 获取图形配置对象
GraphicsConfiguration configuration = graphicsDevice.getDefaultConfiguration();
if (configuration != null && configuration.getDevice().getType() != GraphicsDevice.TYPE_PRINTER) {
// 获取屏幕缩放率,Windows+jdk11环境下会得到用户设置的dpi值
scale = (float) configuration.getDefaultTransform().getScaleX();
}
}
}
return scale;
}
}

13
designer-base/src/main/java/com/fr/design/DesignModelAdapter.java

@ -4,6 +4,7 @@ import com.fr.base.Parameter;
import com.fr.base.ParameterConfig;
import com.fr.base.TableData;
import com.fr.base.io.BaseBook;
import com.fr.base.param.ParameterSource;
import com.fr.data.TableDataSource;
import com.fr.data.operator.DataOperator;
import com.fr.design.file.HistoryTemplateListCache;
@ -19,8 +20,8 @@ import com.fr.stable.Filter;
import com.fr.stable.ParameterProvider;
import com.fr.stable.StringUtils;
import com.fr.stable.js.WidgetName;
import com.fr.util.ParameterApplyHelper;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
@ -283,9 +284,9 @@ public abstract class DesignModelAdapter<T extends BaseBook, S extends JTemplate
TableData tableData = this.getBook().getTableData(name);
ParameterProvider[] parameterProviders = DataOperator.getInstance().getTableDataParameters(tableData);
if (filter != null) {
ParameterApplyHelper.addPara2Map(map, parameterProviders, filter);
ParameterApplyHelper.addPara2Map(map, parameterProviders, filter, null, ParameterSource.DEFAULT_SOURCE);
} else {
ParameterApplyHelper.addPara2Map(map, parameterProviders);
ParameterApplyHelper.addPara2Map(map, parameterProviders, null, ParameterSource.TEMPLATE_SOURCE);
}
tableDataParametersMap.put(name, parameterProviders);
}
@ -353,9 +354,9 @@ public abstract class DesignModelAdapter<T extends BaseBook, S extends JTemplate
*/
private void updateParaMap(Map<String, ParameterProvider> map, ParameterProvider[] parameterProviders, Filter<ParameterProvider> filter) {
if (filter != null) {
ParameterApplyHelper.addPara2Map(map, parameterProviders, filter);
ParameterApplyHelper.addPara2Map(map, parameterProviders, filter, null, ParameterSource.DEFAULT_SOURCE);
} else {
ParameterApplyHelper.addPara2Map(map, parameterProviders);
ParameterApplyHelper.addPara2Map(map, parameterProviders, null, ParameterSource.DEFAULT_SOURCE);
}
}
@ -378,7 +379,7 @@ public abstract class DesignModelAdapter<T extends BaseBook, S extends JTemplate
protected void addGlobalParameters(Map<String, ParameterProvider> map) {
// 添加全局参数
Parameter[] glbParas = ParameterConfig.getInstance().getGlobalParameters();
ParameterApplyHelper.addPara2Map(map, glbParas);
ParameterApplyHelper.addPara2Map(map, glbParas, null, ParameterSource.GLOBAL_SOURCE);
}

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

@ -108,7 +108,7 @@ public class PreferencePane extends BasicPane {
private static final int CACHING_DEFAULT = 5;
private static final int CACHING_GAP = 5;
private static final int MEMORY_TIP_LABEL_MAX_WIDTH = 230;
private static final int OFFSET_HEIGHT = 50;
private static final int OFFSET_HEIGHT = 60;
private static final String TYPE = "pressed";
private static final String DISPLAY_TYPE = "+";

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

@ -15,9 +15,9 @@ import com.fr.stable.StringUtils;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
@ -34,13 +34,12 @@ public class AdvancePane extends BasicPane {
public AdvancePane() {
JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane();
DBCP_VALIDATION_QUERY.addFocusListener(new JTextFieldHintListener(DBCP_VALIDATION_QUERY));
;
double p = TableLayout.PREFERRED;
DBCP_VALIDATION_QUERY.setColumns(15);
DBCP_VALIDATION_QUERY.setColumns(20);
double[] rowSizeDbcp = {p, p, p, p};
double[] columnDbcp = {p, p};
double[] columnDbcp = {190, 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},
@ -49,9 +48,8 @@ public class AdvancePane extends BasicPane {
};
JPanel contextPane = TableLayoutHelper.createGapTableLayoutPane(comps, rowSizeDbcp, columnDbcp, 11, 11);
this.add(contextPane);
this.setPreferredSize(new Dimension(630, 120));
this.setLayout(FRGUIPaneFactory.createLeftZeroVgapNormalHgapLayout());
jPanel.add(contextPane, BorderLayout.CENTER);
this.add(jPanel);
}

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

@ -7,6 +7,7 @@ import com.fr.data.impl.Connection;
import com.fr.data.impl.JDBCDatabaseConnection;
import com.fr.data.impl.JNDIDatabaseConnection;
import com.fr.data.operator.DataOperatorProvider;
import com.fr.data.security.ssl.impl.NormalSsl;
import com.fr.data.solution.ExceptionSolutionSelector;
import com.fr.data.solution.entity.DriverPage;
import com.fr.data.solution.processor.ClassNotFoundExceptionSolutionProcessor;
@ -61,7 +62,7 @@ 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_HEIGHT = 410;
private static int MAX_MAIN_PANEL_WIDTH = 675;
private UILabel message;
@ -312,6 +313,15 @@ public abstract class DatabaseConnectionPane<E extends com.fr.data.impl.Connecti
throw new UnsupportedOperationException();
}
protected SslPane getSslPane() {
throw new UnsupportedOperationException();
}
protected SshPane getSshPane() {
throw new UnsupportedOperationException();
}
protected void initComponents() {
message = new UILabel();
uiLabel = new UILabel();
@ -325,7 +335,8 @@ public abstract class DatabaseConnectionPane<E extends com.fr.data.impl.Connecti
cancelButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Cancel"));
this.setLayout(FRGUIPaneFactory.createBorderLayout());
JPanel northPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane();
this.add(northPane, BorderLayout.NORTH);
UIScrollPane uiScrollPane = new UIScrollPane(northPane, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
this.add(uiScrollPane, BorderLayout.CENTER);
// 按钮.
JPanel testPane = FRGUIPaneFactory.createNormalFlowInnerContainer_M_Pane();
@ -339,8 +350,6 @@ public abstract class DatabaseConnectionPane<E extends com.fr.data.impl.Connecti
mainPanel = mainPanel();
JPanel advancedPanel = FRGUIPaneFactory.createTopVerticalTitledBorderPane(Toolkit.i18nText("Fine-Design_Basic_Advanced"));
if (mainPanel instanceof JDBCDefPane) {
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() {
@ -360,7 +369,8 @@ public abstract class DatabaseConnectionPane<E extends com.fr.data.impl.Connecti
advancedPanel.add(advancePane);
}
advancedPanel.add(actionLabelPanel);
northPane.add(getSshPane());
northPane.add(getSslPane());
} else {
//非jdbc配置布局保持不变
advancedPanel.setPreferredSize(new Dimension(MAX_MAIN_PANEL_WIDTH, 60));
@ -427,6 +437,12 @@ public abstract class DatabaseConnectionPane<E extends com.fr.data.impl.Connecti
private static JDBCDefPane jdbcDefPane = new JDBCDefPane();
private static DBCPAttrPane dbcpAttrPane = new DBCPAttrPane();
private static AdvancePane advancePane = new AdvancePane();
private static SslPane sslPane = new SslPane();
private static SshPane sshPane = new SshPane();
static {
jdbcDefPane.addLinkPane(sslPane);
}
@Override
protected JPanel mainPanel() {
@ -447,6 +463,8 @@ public abstract class DatabaseConnectionPane<E extends com.fr.data.impl.Connecti
jdbcDefPane.populate(ob);
dbcpAttrPane.populate(jdbcDefPane.getJDBCDatabase());
advancePane.populate(jdbcDefPane.getJDBCDatabase());
sshPane.populate(jdbcDefPane.getJDBCDatabase());
sslPane.populate(jdbcDefPane.getJDBCDatabase());
}
@Override
@ -454,6 +472,12 @@ public abstract class DatabaseConnectionPane<E extends com.fr.data.impl.Connecti
JDBCDatabaseConnection jdbcDatabaseConnection = jdbcDefPane.update();
dbcpAttrPane.update(jdbcDatabaseConnection);
advancePane.update(jdbcDatabaseConnection);
sshPane.update(jdbcDatabaseConnection);
if (sslPane.isVisible()) {
sslPane.update(jdbcDatabaseConnection);
} else {
jdbcDatabaseConnection.setSsl(new NormalSsl());
}
return jdbcDatabaseConnection;
}
@ -462,6 +486,16 @@ public abstract class DatabaseConnectionPane<E extends com.fr.data.impl.Connecti
return advancePane;
}
@Override
protected SslPane getSslPane() {
return sslPane;
}
@Override
protected SshPane getSshPane() {
return sshPane;
}
@Override
protected String title4PopupWindow() {
return "JDBC";

19
designer-base/src/main/java/com/fr/design/data/datapane/connect/JDBCDefPane.java

@ -4,7 +4,9 @@ import com.fr.base.GraphHelper;
import com.fr.data.driver.DriverLoader;
import com.fr.data.driver.config.DriverLoaderConfig;
import com.fr.data.impl.JDBCDatabaseConnection;
import com.fr.data.solution.entity.DriverClasses;
import com.fr.design.border.UITitledBorder;
import com.fr.design.constants.UIConstants;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.icombobox.UIComboBoxUI;
@ -28,6 +30,7 @@ import com.fr.third.guava.collect.HashBiMap;
import com.fr.workspace.WorkContext;
import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JFileChooser;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
@ -67,6 +70,7 @@ public class JDBCDefPane extends JPanel {
// 编码转换.
private String originalCharSet = null;
private static Map<String, DriverURLName[]> jdbcMap = new HashMap<String, DriverURLName[]>();
private JPanel linkPanel;
static {
jdbcMap.put(OTHER_DB, new DriverURLName[]{new DriverURLName("sun.jdbc.odbc.JdbcOdbcDriver", "jdbc:odbc:"),
@ -193,7 +197,9 @@ public class JDBCDefPane extends JPanel {
userNameTextField = new UITextField(15);
userNameTextField.setName(USER_NAME);
passwordTextField = new UIPasswordFieldWithFixedLength(15);
dbtypeButton = new UIButton(".");
dbtypeButton = new UIButton();
dbtypeButton.setIcon(new ImageIcon(UIConstants.ACCESSIBLE_EDITOR_DOT));
dbtypeButton.setPreferredSize(new Dimension(20, 20));
dbtypeButton.setToolTipText(Toolkit.i18nText("Fine-Design_Basic_Click_Get_Default_URL"));
dbtypeButton.addActionListener(dbtypeButtonActionListener);
@ -477,11 +483,16 @@ public class JDBCDefPane extends JPanel {
}
ActionListener driverListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
linkPanel.setVisible(DriverClasses.MYSQL.toString().equalsIgnoreCase((String) dbtypeComboBox.getSelectedItem())
&& driverComboBox.getSelectedItem() != null
&& ComparatorUtils.equals(DriverClasses.MYSQL.getDriverClass(), driverComboBox.getSelectedItem().toString().trim()));
odbcTipsLink.setVisible(driverComboBox.getSelectedItem() != null
&& ComparatorUtils.equals("sun.jdbc.odbc.JdbcOdbcDriver", driverComboBox.getSelectedItem().toString().trim())); // 选择的如果是ODBC就显示提示
if (driverComboBox.getSelectedItem() == null || ComparatorUtils.equals(driverComboBox.getSelectedItem(), StringUtils.EMPTY)) {
return;
}
odbcTipsLink.setVisible(ComparatorUtils.equals("sun.jdbc.odbc.JdbcOdbcDriver", driverComboBox.getSelectedItem())); // 选择的如果是ODBC就显示提示
Iterator<Entry<String, DriverURLName[]>> jdbc = jdbcMap.entrySet().iterator();
while (jdbc.hasNext()) {
Entry<String, DriverURLName[]> entry = jdbc.next();
@ -494,7 +505,6 @@ public class JDBCDefPane extends JPanel {
}
}
}
};
ActionListener dbtypeButtonActionListener = new ActionListener() {
@ -738,4 +748,7 @@ public class JDBCDefPane extends JPanel {
}
public void addLinkPane(JPanel panel) {
linkPanel = panel;
}
}

301
designer-base/src/main/java/com/fr/design/data/datapane/connect/SshPane.java

@ -0,0 +1,301 @@
package com.fr.design.data.datapane.connect;
import com.fr.data.impl.JDBCDatabaseConnection;
import com.fr.data.security.ssh.BaseSsh;
import com.fr.data.security.ssh.Ssh;
import com.fr.data.security.ssh.SshException;
import com.fr.data.security.ssh.SshType;
import com.fr.data.security.ssh.impl.KeyVerifySsh;
import com.fr.data.security.ssh.impl.NormalSsh;
import com.fr.design.border.UITitledBorder;
import com.fr.design.constants.UIConstants;
import com.fr.design.dialog.BasicPane;
import com.fr.design.editor.editor.NotNegativeIntegerEditor;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.ipasswordfield.UIPasswordFieldWithFixedLength;
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.file.FILE;
import com.fr.file.FILEChooserPane;
import com.fr.file.filter.ChooseFileFilter;
import com.fr.stable.StringUtils;
import com.fr.stable.project.ProjectConstants;
import com.fr.third.guava.collect.HashBiMap;
import javax.swing.ImageIcon;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.SwingConstants;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static com.fr.design.i18n.Toolkit.i18nText;
/**
* @author xiqiu
* @date 2021/12/23
* @description
*/
public class SshPane extends BasicPane {
private static HashBiMap<String, SshType> typeMap;
static {
typeMap = HashBiMap.create();
typeMap.put(Toolkit.i18nText("Fine-Design_Basic_Password"), SshType.NORMAL);
typeMap.put(Toolkit.i18nText("Fine-Design_Basic_Ssh_Public_Key"), SshType.KEY);
}
private UICheckBox usingSsh = new UICheckBox(i18nText("Fine-Design_Basic_Ssh_Using"));
private NotNegativeIntegerEditor port = new NotNegativeIntegerEditor(20);
private UITextField ip = new UITextField(20);
private UIComboBox type = new UIComboBox();
private UITextField user = new UITextField(20);
private JPasswordField password = new UIPasswordFieldWithFixedLength(20);
private JPasswordField secret = new UIPasswordFieldWithFixedLength(20);
private KeyFileUITextField keyPath = new KeyFileUITextField(18);
private JPanel contextPane;
private Component[][] passwordComps;
private Component[][] keyComps;
private double p = TableLayout.PREFERRED;
private double f = TableLayout.FILL;
private JPanel jPanel;
private UIButton fileChooserButton = new UIButton();
private double[] columnSize = new double[]{195, p};
public SshPane() {
fileChooserButton.setIcon(new ImageIcon(UIConstants.ACCESSIBLE_EDITOR_DOT));
this.setBorder(UITitledBorder.createBorderWithTitle(Toolkit.i18nText("Fine-Design_Basic_Ssh_Settings")));
this.setLayout(FRGUIPaneFactory.createLabelFlowLayout());
typeMap.keySet().forEach(key -> type.addItem(key));
type.setSelectedItem(typeMap.inverse().get(SshType.KEY));
jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane();
fileChooserButton.setPreferredSize(new Dimension(20, 20));
type.setEditable(false);
type.setSelectedItem(Toolkit.i18nText("Fine-Design_Basic_Ssh_Private_Key"));
JPanel filePanel = TableLayoutHelper.createCommonTableLayoutPane(new Component[][]{{keyPath, fileChooserButton}}, new double[]{p}, new double[]{f, 20}, 0);
Component[] compIp = {new UILabel(Toolkit.i18nText("Fine-Design_Basic_Host") + ":", SwingConstants.RIGHT), ip};
Component[] compPort = {new UILabel(Toolkit.i18nText("Fine-Design_Basic_Port") + ":", SwingConstants.RIGHT), port};
Component[] compUserName = {new UILabel(Toolkit.i18nText("Fine-Design_Report_UserName") + ":", SwingConstants.RIGHT), user};
Component[] compMethod = {new UILabel(Toolkit.i18nText("Fine-Design_Basic_Ssh_Verify_Method") + ":", SwingConstants.RIGHT), type};
Component[] compPassword = {new UILabel(Toolkit.i18nText("Fine-Design_Basic_Password") + ":", SwingConstants.RIGHT), password};
Component[] compKey = {new UILabel(Toolkit.i18nText("Fine-Design_Basic_Ssh_Private_Key") + ":", SwingConstants.RIGHT), filePanel};
Component[] comSecret = {new UILabel(Toolkit.i18nText("Fine-Design_Basic_Ssh_Secret") + ":", SwingConstants.RIGHT), secret};
passwordComps = new Component[][]{
compIp,
compPort,
compUserName,
compMethod,
compPassword
};
keyComps = new Component[][]{
compIp,
compPort,
compUserName,
compMethod,
compKey,
comSecret
};
usingSsh.setSelected(true);
contextPane = TableLayoutHelper.createGapTableLayoutPane(keyComps, new double[]{p, p, p, p, p, p}, columnSize, 11, 11);
jPanel.add(usingSsh, BorderLayout.NORTH);
jPanel.add(contextPane, BorderLayout.CENTER);
this.add(jPanel);
usingSsh.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
changePane();
}
});
type.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
changePaneForType();
}
});
fileChooserButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
FILEChooserPane fileChooser = FILEChooserPane.getInstanceWithDesignatePath(ProjectConstants.RESOURCES_NAME, new ChooseFileFilter(true));
int type = fileChooser.showOpenDialog(SshPane.this, StringUtils.EMPTY);
if (type == FILEChooserPane.OK_OPTION) {
final FILE file = fileChooser.getSelectedFILE();
if (file == null) {
keyPath.setText(StringUtils.EMPTY);
} else {
keyPath.setText(file.getPath());
}
}
fileChooser.removeAllFilter();
}
});
}
private void changePane() {
contextPane.setVisible(usingSsh.isSelected());
}
private void changePaneForType() {
contextPane.removeAll();
switch (typeMap.get(type.getSelectedItem())) {
case NORMAL:
TableLayoutHelper.addComponent2ResultPane(passwordComps, new double[]{p, p, p, p, p}, columnSize, contextPane);
break;
case KEY:
TableLayoutHelper.addComponent2ResultPane(keyComps, new double[]{p, p, p, p, p, p}, columnSize, contextPane);
break;
default:
throw new SshException("un support ssh type");
}
jPanel.revalidate();
jPanel.repaint();
}
@Override
protected String title4PopupWindow() {
return Toolkit.i18nText("Fine-Design_Basic_Ssh_Settings");
}
public void populate(JDBCDatabaseConnection jdbcDatabase) {
if (jdbcDatabase.getSsh() == null) {
jdbcDatabase.setSsh(new NormalSsh());
}
Ssh ssh = jdbcDatabase.getSsh();
switch (ssh.getSshType()) {
case KEY:
type.setSelectedItem(typeMap.inverse().get(ssh.getSshType()));
KeyVerifySsh keyVerifySsh = (KeyVerifySsh) ssh;
keyPath.setText(keyVerifySsh.getPrivateKeyPath());
secret.setText(keyVerifySsh.getSecret());
password.setText(StringUtils.EMPTY);
setCommonConfig(keyVerifySsh);
break;
case NORMAL:
type.setSelectedItem(typeMap.inverse().get(ssh.getSshType()));
NormalSsh normalSsh = (NormalSsh) ssh;
password.setText(normalSsh.getSecret());
keyPath.setText(StringUtils.EMPTY);
secret.setText(StringUtils.EMPTY);
setCommonConfig(normalSsh);
break;
default:
throw new SshException("un support ssh type");
}
usingSsh.setSelected(ssh.isUsingSsh());
changePane();
}
private void setCommonConfig(BaseSsh baseSsh) {
ip.setText(baseSsh.getIp());
port.setValue(baseSsh.getPort());
user.setText(baseSsh.getUser());
}
public void update(JDBCDatabaseConnection jdbcDatabase) {
Ssh ssh;
switch (typeMap.get(type.getSelectedItem())) {
case NORMAL:
NormalSsh normalSsh = new NormalSsh();
normalSsh.setSecret(new String(password.getPassword()).trim());
getCommonConfig(normalSsh);
ssh = normalSsh;
break;
case KEY:
KeyVerifySsh keyVerifySsh = new KeyVerifySsh();
keyVerifySsh.setPrivateKeyPath(keyPath.getText().trim());
keyVerifySsh.setSecret(new String(secret.getPassword()).trim());
getCommonConfig(keyVerifySsh);
ssh = keyVerifySsh;
break;
default:
throw new SshException("un support ssh type");
}
jdbcDatabase.setSsh(ssh);
}
private void getCommonConfig(BaseSsh baseSsh) {
baseSsh.setUsingSsh(usingSsh.isSelected());
baseSsh.setIp(ip.getText().trim());
baseSsh.setPort(port.getValue());
baseSsh.setUser(user.getText().trim());
}
public static class KeyFileUITextField extends UITextField {
private static final Pattern ERROR_START = Pattern.compile("^([/\\\\.]+).*");
private static final Pattern MUTI_DOT = Pattern.compile("\\.+");
private static final String PREFIX = ProjectConstants.RESOURCES_NAME + "/";
private static final String UPPER = "..";
public KeyFileUITextField(int columns) {
this();
this.setColumns(columns);
}
public KeyFileUITextField() {
super();
this.addKeyListener(new KeyAdapter() {
@Override
public void keyReleased(KeyEvent e) {
String text = KeyFileUITextField.this.getTextOrigin();
if (!StringUtils.isEmpty(text)) {
if (text.contains(UPPER)) {
text = MUTI_DOT.matcher(text).replaceAll(".");
KeyFileUITextField.this.setTextOrigin(text);
}
Matcher matcher = ERROR_START.matcher(text);
if (matcher.matches()) {
text = text.substring(matcher.group(1).length());
KeyFileUITextField.this.setTextOrigin(text);
}
}
}
});
}
public String getTextOrigin() {
return super.getText();
}
public void setTextOrigin(String text) {
super.setText(text);
}
@Override
public String getText() {
// 获取的时候,不为空,给他加上前缀就好了,否则还是空
if (!StringUtils.isEmpty(super.getText())) {
return PREFIX + super.getText();
}
return StringUtils.EMPTY;
}
@Override
public void setText(String text) {
// 设置的时候,不为空,说明文件指定了(文件需要是resource下),替换掉前缀
if (!StringUtils.isEmpty(text) && text.startsWith(PREFIX)) {
super.setText(text.replaceFirst(PREFIX, ""));
} else {
super.setText(text);
}
}
}
}

164
designer-base/src/main/java/com/fr/design/data/datapane/connect/SslPane.java

@ -0,0 +1,164 @@
package com.fr.design.data.datapane.connect;
import com.fr.data.impl.JDBCDatabaseConnection;
import com.fr.data.security.ssl.Ssl;
import com.fr.data.security.ssl.SslException;
import com.fr.data.security.ssl.SslType;
import com.fr.data.security.ssl.impl.NormalSsl;
import com.fr.design.border.UITitledBorder;
import com.fr.design.constants.UIConstants;
import com.fr.design.data.datapane.connect.SshPane.KeyFileUITextField;
import com.fr.design.dialog.BasicPane;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.file.FILE;
import com.fr.file.FILEChooserPane;
import com.fr.file.filter.ChooseFileFilter;
import com.fr.stable.StringUtils;
import com.fr.stable.project.ProjectConstants;
import javax.swing.ImageIcon;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import static com.fr.design.i18n.Toolkit.i18nText;
/**
* @author xiqiu
* @date 2022/1/4
* @description
*/
public class SslPane extends BasicPane {
UICheckBox usingSsl = new UICheckBox(i18nText("Fine-Design_Basic_Ssl_Using"));
private KeyFileUITextField keyPathCa = new KeyFileUITextField(18);
private UIButton fileChooserButtonCa = new UIButton();
private KeyFileUITextField keyPathClientCert = new KeyFileUITextField(18);
private UIButton fileChooserButtonClientCert = new UIButton();
private KeyFileUITextField keyPathClientKey = new KeyFileUITextField(18);
private UIButton fileChooserButtonClientKey = new UIButton();
private UICheckBox verifyCa = new UICheckBox(i18nText("Fine-Design_Basic_Ssl_Verify_Ca"));
// private UITextField cipher = new UITextField(20);
private JPanel jPanel;
private Component[][] usingComps;
private double p = TableLayout.PREFERRED;
private double f = TableLayout.FILL;
private JPanel contextPane;
private double[] columnSize = new double[]{195, p};
public SslPane() {
fileChooserButtonCa.setIcon(new ImageIcon(UIConstants.ACCESSIBLE_EDITOR_DOT));
fileChooserButtonClientCert.setIcon(new ImageIcon(UIConstants.ACCESSIBLE_EDITOR_DOT));
fileChooserButtonClientKey.setIcon(new ImageIcon(UIConstants.ACCESSIBLE_EDITOR_DOT));
this.setBorder(UITitledBorder.createBorderWithTitle(Toolkit.i18nText("Fine-Design_Basic_Ssl_Settings")));
this.setLayout(FRGUIPaneFactory.createLabelFlowLayout());
jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane();
Dimension dimension = new Dimension(20, 20);
fileChooserButtonCa.setPreferredSize(dimension);
fileChooserButtonClientCert.setPreferredSize(dimension);
fileChooserButtonClientKey.setPreferredSize(dimension);
JPanel filePanelCa = TableLayoutHelper.createCommonTableLayoutPane(new Component[][]{{keyPathCa, fileChooserButtonCa}}, new double[]{p}, new double[]{f, 20}, 0);
Component[] compCa = {new UILabel(Toolkit.i18nText("Fine-Design_Basic_Ssl_Ca") + ":", SwingConstants.RIGHT), filePanelCa};
Component[] compVerifyCa = {null, verifyCa};
JPanel filePanelClientCert = TableLayoutHelper.createCommonTableLayoutPane(new Component[][]{{keyPathClientCert, fileChooserButtonClientCert}}, new double[]{p}, new double[]{f, 20}, 0);
Component[] compClientCert = {new UILabel(Toolkit.i18nText("Fine-Design_Basic_Ssl_Client_Cert") + ":", SwingConstants.RIGHT), filePanelClientCert};
JPanel filePanelClientKey = TableLayoutHelper.createCommonTableLayoutPane(new Component[][]{{keyPathClientKey, fileChooserButtonClientKey}}, new double[]{p}, new double[]{f, 20}, 0);
Component[] compClientKey = {new UILabel(Toolkit.i18nText("Fine-Design_Basic_Ssl_Client_Key") + ":", SwingConstants.RIGHT), filePanelClientKey};
// Component[] comCipher = {new UILabel(Toolkit.i18nText("Fine-Design_Basic_Ssl_Cipher") + ":", SwingConstants.RIGHT), cipher};
usingComps = new Component[][]{
compCa,
compVerifyCa,
compClientCert,
compClientKey,
// comCipher
};
usingSsl.setSelected(true);
contextPane = TableLayoutHelper.createGapTableLayoutPane(usingComps, new double[]{p, p, p, p}, columnSize, 11, 11);
jPanel.add(usingSsl, BorderLayout.NORTH);
jPanel.add(contextPane, BorderLayout.CENTER);
this.add(jPanel);
usingSsl.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
changePane();
}
});
fileChooserButtonCa.addActionListener(new TextFieldActionListener(keyPathCa));
fileChooserButtonClientCert.addActionListener(new TextFieldActionListener(keyPathClientCert));
fileChooserButtonClientKey.addActionListener(new TextFieldActionListener(keyPathClientKey));
}
private void changePane() {
contextPane.setVisible(usingSsl.isSelected());
}
@Override
protected String title4PopupWindow() {
return Toolkit.i18nText("Fine-Design_Basic_Ssl_Settings");
}
public void populate(JDBCDatabaseConnection jdbcDatabase) {
Ssl ssl = jdbcDatabase.getSsl();
if (ssl == null) {
ssl = new NormalSsl();
jdbcDatabase.setSsl(ssl);
}
if (ssl.getSslType() == SslType.NORMAL) {
NormalSsl normalSsl = (NormalSsl) ssl;
keyPathCa.setText(normalSsl.getCaCertificate());
keyPathClientCert.setText(normalSsl.getClientCertificate());
keyPathClientKey.setText(normalSsl.getClientPrivateKey());
verifyCa.setSelected(normalSsl.isVerifyCa());
// cipher.setText(normalSsl.getCipher());
} else {
throw new SslException("un support ssl type");
}
usingSsl.setSelected(ssl.isUsingSsl());
changePane();
}
public void update(JDBCDatabaseConnection jdbcDatabase) {
NormalSsl normalSsl = new NormalSsl();
// normalSsl.setCipher(cipher.getText().trim());
normalSsl.setVerifyCa(verifyCa.isSelected());
normalSsl.setCaCertificate(keyPathCa.getText().trim());
normalSsl.setClientCertificate(keyPathClientCert.getText().trim());
normalSsl.setClientPrivateKey(keyPathClientKey.getText().trim());
normalSsl.setUsingSsl(usingSsl.isSelected());
jdbcDatabase.setSsl(normalSsl);
}
private class TextFieldActionListener implements ActionListener {
private UITextField textField;
public TextFieldActionListener(UITextField textField) {
this.textField = textField;
}
@Override
public void actionPerformed(ActionEvent e) {
FILEChooserPane fileChooser = FILEChooserPane.getInstanceWithDesignatePath(ProjectConstants.RESOURCES_NAME, new ChooseFileFilter(true));
int type = fileChooser.showOpenDialog(SslPane.this, StringUtils.EMPTY);
if (type == FILEChooserPane.OK_OPTION) {
final FILE file = fileChooser.getSelectedFILE();
if (file == null) {
textField.setText(StringUtils.EMPTY);
} else {
textField.setText(file.getPath());
}
}
fileChooser.removeAllFilter();
}
}
}

109
designer-base/src/main/java/com/fr/design/data/tabledata/wrapper/StoreProcedureDataWrapper.java

@ -63,26 +63,27 @@ public final class StoreProcedureDataWrapper implements TableDataWrapper {
public StoreProcedureDataWrapper(Component component, StoreProcedure storeProcedure, String storeprocedureName, String dsName) {
this(component, storeProcedure, storeprocedureName, dsName, true);
}
/**
* @param: component loadingBar的父弹框如果不设置父弹框的话可能出现loadingBar隐藏在一个弹框后的情况
* @param: storeProcedure 存储过程
* @param: storeprocedureName 存储过程的名字(某些情况下可以为空)
* @param: dsName 存储过程一个返回数据集的名字
* @param: needLoad 是否要加载
* @param component loadingBar的父弹框如果不设置父弹框的话可能出现loadingBar隐藏在一个弹框后的情况
* @param storeProcedure 存储过程
* @param storeprocedureName 存储过程的名字(某些情况下可以为空)
* @param dsName 存储过程一个返回数据集的名字
* @param needLoad 是否要加载
**/
public StoreProcedureDataWrapper(Component component, StoreProcedure storeProcedure, String storeprocedureName, String dsName, boolean needLoad) {
this.dsName = dsName;
this.storeProcedure = storeProcedure;
this.storeProcedure.setCalculating(false);
this.storeprocedureName = storeprocedureName;
if (needLoad) {
setWorker();
}
if (component == null) {
component = new JFrame();
}
if (needLoad) {
setWorker(component);
}
loadingBar = new AutoProgressBar(component, Toolkit.i18nText("Fine-Design_Basic_Loading_Data"), "", 0, 100) {
@Override
public void doMonitorCanceled() {
getWorker().cancel(true);
}
@ -93,16 +94,17 @@ public final class StoreProcedureDataWrapper implements TableDataWrapper {
* 数据集执行结果返回的所有字段
*
* @return 数据集执行结果返回的所有字段
*
*
* @date 2014-12-3-下午7:43:17
*
*/
* @date 2014-12-3-下午7:43:17
*/
@Override
public List<String> calculateColumnNameList() {
if (columnNameList != null) {
return columnNameList;
}
if (!createStore(false)) {
try {
createStore(false);
} catch (Exception e) {
FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Engine_No_TableData"));
return new ArrayList<String>();
}
@ -114,11 +116,9 @@ public final class StoreProcedureDataWrapper implements TableDataWrapper {
* 生成子节点
*
* @return 节点数组
*
*
* @date 2014-12-3-下午7:06:47
*
*/
* @date 2014-12-3-下午7:06:47
*/
@Override
public ExpandMutableTreeNode[] load() {
List<String> namelist;
if (storeProcedure.isCalculating()) {
@ -134,23 +134,16 @@ public final class StoreProcedureDataWrapper implements TableDataWrapper {
return res;
}
private boolean createStore(boolean needLoadingBar) {
try {
dataModels = DesignTableDataManager.createLazyDataModel(storeProcedure, needLoadingBar);
if (dataModels == null || dataModels.length == 0) {
return false;
}
for (int i = 0; i < dataModels.length; i++) {
if (ComparatorUtils.equals(this.dsName, storeprocedureName + "_" + dataModels[i].getName())) {
procedureDataModel = dataModels[i];
private void createStore(boolean needLoadingBar) throws Exception {
dataModels = DesignTableDataManager.createLazyDataModel(storeProcedure, needLoadingBar);
if (dataModels != null && dataModels.length != 0) {
for (ProcedureDataModel dataModel : dataModels) {
if (ComparatorUtils.equals(this.dsName, storeprocedureName + "_" + dataModel.getName())) {
procedureDataModel = dataModel;
break;
}
}
return true;
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
return false;
}
@Override
@ -159,17 +152,15 @@ public final class StoreProcedureDataWrapper implements TableDataWrapper {
}
/**
* 预览数据
*
* @param previewModel 预览模式, 全部还是一个
*
*
* @date 2014-12-3-下午7:05:50
*
*/
* 预览数据
*
* @param previewModel 预览模式, 全部还是一个
* @date 2014-12-3-下午7:05:50
*/
public void previewData(final int previewModel) {
this.previewModel = previewModel;
connectionBar = new AutoProgressBar(new JFrame(), Toolkit.i18nText("Fine-Design_Basic_Utils_Now_Create_Connection"), "", 0, 100) {
@Override
public void doMonitorCanceled() {
connectionBar.close();
worker.cancel(true);
@ -178,8 +169,9 @@ public final class StoreProcedureDataWrapper implements TableDataWrapper {
worker.execute();
}
private void setWorker() {
private void setWorker(final Component parent) {
worker = new SwingWorker<Void, Void>() {
@Override
protected Void doInBackground() throws Exception {
loadingBar.close();
PreviewTablePane.resetPreviewTable();
@ -195,6 +187,7 @@ public final class StoreProcedureDataWrapper implements TableDataWrapper {
return null;
}
@Override
public void done() {
try {
get();
@ -206,13 +199,15 @@ public final class StoreProcedureDataWrapper implements TableDataWrapper {
case StoreProcedureDataWrapper.PREVIEW_ONE:
previewData();
break;
default:
break;
}
} catch (Exception e) {
loadingBar.close();
if (!(e instanceof CancellationException)) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), e.getMessage());
FineJOptionPane.showMessageDialog(parent, e.getMessage());
}
loadingBar.close();
}
}
};
@ -227,10 +222,9 @@ public final class StoreProcedureDataWrapper implements TableDataWrapper {
/**
* 预览返回的一个数据集
*
*
* @date 2014-12-3-下午7:42:53
*
*/
* @date 2014-12-3-下午7:42:53
*/
@Override
public void previewData() {
previewData(-1, -1);
}
@ -240,13 +234,11 @@ public final class StoreProcedureDataWrapper implements TableDataWrapper {
/**
* 预览返回的一个数据集带有显示值和实际值的标记结果
*
* @param keyIndex 实际值
* @param valueIndex 显示值
*
*
* @date 2014-12-3-下午7:42:27
*
*/
* @param keyIndex 实际值
* @param valueIndex 显示值
* @date 2014-12-3-下午7:42:27
*/
@Override
public void previewData(final int keyIndex, final int valueIndex) {
PreviewTablePane.previewStoreData(procedureDataModel, keyIndex, valueIndex);
}
@ -257,7 +249,9 @@ public final class StoreProcedureDataWrapper implements TableDataWrapper {
*/
public void previewAllTable() {
if (procedureDataModel == null) {
if (!createStore(true)) {
try {
createStore(true);
} catch (Exception e) {
return;
}
}
@ -269,6 +263,7 @@ public final class StoreProcedureDataWrapper implements TableDataWrapper {
return dsName;
}
@Override
public TableData getTableData() {
return storeProcedure;
}
@ -282,10 +277,12 @@ public final class StoreProcedureDataWrapper implements TableDataWrapper {
*
* @return 是否异常
*/
@Override
public boolean isUnusual() {
return false;
}
@Override
public boolean equals(Object obj) {
return obj instanceof StoreProcedureDataWrapper
&& ComparatorUtils.equals(this.dsName, ((StoreProcedureDataWrapper) obj).getTableDataName())

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

@ -0,0 +1,15 @@
package com.fr.design.deeplink;
import java.util.Map;
/**
* @author Starryi
* @version 1.0
* Created by Starryi on 2022/1/6
*/
public abstract class DeepLink {
public abstract boolean accept(String url, String host, String path, Map<String, Object> params);
public abstract void run(String url, String host, String path, Map<String, Object> params);
}

184
designer-base/src/main/java/com/fr/design/deeplink/DeepLinkCore.java

@ -0,0 +1,184 @@
package com.fr.design.deeplink;
import com.fr.design.constants.DesignerLaunchStatus;
import com.fr.design.startup.FineStartupNotificationFactory;
import com.fr.design.startup.FineStartupNotificationProvider;
import com.fr.event.Event;
import com.fr.event.EventDispatcher;
import com.fr.event.Listener;
import com.fr.event.Null;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils;
import com.fr.stable.os.OperatingSystem;
import com.fr.third.org.apache.http.NameValuePair;
import com.fr.web.URLUtils;
import javax.swing.SwingUtilities;
import java.awt.Color;
import java.awt.Frame;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLStreamHandler;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author Starryi
* @version 1.0
* Created by Starryi on 2022/1/6
*/
public class DeepLinkCore {
protected DeepLinkCore(){}
private static final DeepLinkCore instance = new DeepLinkCore();
public static DeepLinkCore getInstance(){
return instance;
}
private String pendingURL;
private final List<DeepLink> deepLinkList = new ArrayList<>();
private boolean isDesignerStartupCompleted = false;
public void register(DeepLink deepLink) {
if (deepLink != null) {
deepLinkList.add(deepLink);
}
}
public void start(String[] args) {
if (OperatingSystem.isWindows()) {
if (args.length > 0) {
receiveDeeplink(args[0]);
}
}
if (OperatingSystem.isWindows() && args.length > 0) {
receiveDeeplink(args[0]);
}
FineStartupNotificationFactory.getNotification()
.registerStartupListener(new FineStartupNotificationProvider.Listener() {
@Override
public void startupPerformed(String parameters) {
receiveDeeplink(parameters);
}
});
EventDispatcher.listen(DesignerLaunchStatus.STARTUP_COMPLETE, new Listener<Null>() {
@Override
public void on(Event event, Null param) {
EventDispatcher.stopListen(this);
isDesignerStartupCompleted = true;
if (canConsumePendingURL()) {
consumePendingURL();
}
}
});
}
public void receiveDeeplink(String url) {
if (canAcceptNewURL()) {
acceptNewURL(url);
if (canConsumePendingURL()) {
consumePendingURL();
}
}
}
public void receiveDeeplink2(String url) {
if (canAcceptNewURL()) {
acceptNewURL(url);
if (canConsumePendingURL()) {
consumePendingURL();
} else {
Frame frame = new Frame("can not ConsumePendingURL");
frame.setSize(400, 400);
frame.setBackground(Color.BLACK);
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent windowEvent){
frame.dispose();
}
});
frame.setVisible(true);
}
} else {
Frame frame = new Frame("can not AcceptNewURL");
frame.setSize(400, 400);
frame.setBackground(Color.BLACK);
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent windowEvent){
frame.dispose();
}
});
frame.setVisible(true);
}
}
private boolean canAcceptNewURL() {
return StringUtils.isEmpty(this.pendingURL);
}
private void acceptNewURL(String url) {
this.pendingURL = url;
}
private boolean canConsumePendingURL() {
return StringUtils.isNotEmpty(this.pendingURL) && isDesignerStartupCompleted;
}
private void consumePendingURL() {
String host = null;
String path = null;
Map<String, Object> params = new HashMap<>();
URL url = null;
try {
url = new URL(null, this.pendingURL, new URLStreamHandler() {
@Override
protected URLConnection openConnection(URL u) throws IOException {
return null;
}
});
} catch (MalformedURLException ignored) {}
if (url != null) {
host = url.getHost();
path = url.getPath();
List<NameValuePair> pairs = URLUtils.parse(url.getQuery());
for (NameValuePair pair: pairs) {
params.put(pair.getName(), pair.getValue());
}
}
FineLoggerFactory.getLogger().info("consume deep link: " + this.pendingURL);
performDeepLinks(this.pendingURL, host, path, params);
markPendingURLConsumed();
}
private void performDeepLinks(String url, String host, String path, Map<String, Object> params) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
for (DeepLink deepLink: deepLinkList) {
if (deepLink.accept(url, host, path, params)) {
deepLink.run(url, host, path, params);
}
}
}
});
}
private void markPendingURLConsumed() {
this.pendingURL = null;
}
}

33
designer-base/src/main/java/com/fr/design/editor/editor/NotNegativeIntegerEditor.java

@ -0,0 +1,33 @@
package com.fr.design.editor.editor;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
/**
* @author xiqiu
* @date 2022/1/10
* @description 一个简单的非负整数框
*/
public class NotNegativeIntegerEditor extends IntegerEditor {
private static final String NEG = "-";
public NotNegativeIntegerEditor(int columns) {
this();
this.setColumns(columns);
}
public NotNegativeIntegerEditor() {
super();
this.numberField.addKeyListener(new KeyAdapter() {
@Override
public void keyReleased(KeyEvent evt) {
char keyChar = evt.getKeyChar();
if (NEG.equals(keyChar + "")) {
numberField.setText(numberField.getTextValue().replace(NEG, ""));
}
}
});
}
}

23
designer-base/src/main/java/com/fr/design/extra/WebViewDlgHelper.java

@ -1,6 +1,6 @@
package com.fr.design.extra;
import com.fr.base.FRContext;
import com.fr.decision.webservice.v10.plugin.helper.category.impl.PluginResourceLoader;
import com.fr.design.dialog.BasicPane;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.dialog.UIDialog;
@ -15,12 +15,12 @@ import com.fr.general.IOUtils;
import com.fr.general.http.HttpToolbox;
import com.fr.json.JSONObject;
import com.fr.log.FineLoggerFactory;
import com.fr.plugin.PluginStoreConfig;
import com.fr.plugin.PluginStoreConstants;
import com.fr.stable.CommonUtils;
import com.fr.stable.EnvChangedListener;
import com.fr.stable.ProductConstants;
import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils;
import javax.swing.JOptionPane;
import javax.swing.SwingWorker;
@ -44,15 +44,15 @@ public class WebViewDlgHelper {
private static final String LATEST = "latest";
private static final String SHOP_SCRIPTS = "shop_scripts";
private static final int VERSION_8 = 8;
private static String installHome = FRContext.getCommonOperator().getWebRootPath();
private static String installHome = PluginStoreConstants.getLocalInstallHome();
private static final String MAIN_JS_PATH = "/scripts/plugin.html";
private static final String ENV_VERSION = "ENV_VERSION";
static {
GeneralContext.addEnvChangedListener(new EnvChangedListener() {
@Override
public void envChanged() {
installHome = FRContext.getCommonOperator().getWebRootPath();
installHome = PluginStoreConstants.getLocalInstallHome();
PluginResourceLoader.INSTANCE.checkOldShopFile();
}
});
}
@ -74,8 +74,11 @@ public class WebViewDlgHelper {
}
return;
}
String jar_version = PluginStoreConstants.getProps(ENV_VERSION, StringUtils.EMPTY);
if (ComparatorUtils.equals(jar_version, ProductConstants.VERSION)) {
// 检测更新前先刷新一下版本号
PluginStoreConstants.refreshProps();
String jarVersion = PluginStoreConfig.getInstance().getEnvVersion();
if (ComparatorUtils.equals(jarVersion, ProductConstants.VERSION)) {
updateShopScripts(SHOP_SCRIPTS);
showPluginDlg();
} else {
@ -133,7 +136,7 @@ public class WebViewDlgHelper {
*
* @param filePath 待删除文件路径
*/
private static void deleteExtraFile(String filePath){
private static void deleteExtraFile(String filePath) {
CommonIOUtils.deleteFile(new File(filePath));
}
@ -259,7 +262,7 @@ public class WebViewDlgHelper {
try {
if (get()) {
File scriptZip = new File(StableUtils.pathJoin(PluginConstants.DOWNLOAD_PATH, PluginConstants.TEMP_FILE));
if(scriptZip.exists()){
if (scriptZip.exists()) {
IOUtils.unzip(scriptZip, installHome);
CommonUtils.deleteFile(scriptZip);
}
@ -283,7 +286,7 @@ public class WebViewDlgHelper {
protected Void doInBackground() throws Exception {
String url = CloudCenter.getInstance().acquireUrlByKind("shop.plugin.update");
if (url != null) {
String text = HttpToolbox.get(url + "?" + PluginUtils.FR_VERSION + "=" + ProductConstants.VERSION + "&version=" + PluginStoreConstants.getProps("VERSION"));
String text = HttpToolbox.get(url + "?" + PluginUtils.FR_VERSION + "=" + ProductConstants.VERSION + "&version=" + PluginStoreConfig.getInstance().getVersion());
JSONObject resultJSONObject = new JSONObject(text);
String isLatest = resultJSONObject.optString("result");
if (!ComparatorUtils.equals(isLatest, LATEST)) {

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

@ -815,10 +815,11 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula {
String formulaText = formulaTextArea.getText().trim();
String unSupportFormula = containsUnsupportedSimulationFormulas(formulaText);
if (unSupportFormula != null) {
showMessageDialog(Toolkit.i18nText("Fine-Design_Basic_Formula_Unsupported_Formulas") + ":" + unSupportFormula, false);
showMessageDialog(Toolkit.i18nText("Fine-Design_Basic_Formula_Unsupported_Formulas") + ":" + unSupportFormula, false, true);
return;
}
boolean calException = false;
String messageTips;
FormulaCheckResult checkResult = FormulaChecker.check(formulaText);
if (checkResult.grammarValid()) {
@ -847,6 +848,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula {
} catch (Exception ce) {
//模拟计算如果出现错误,则抛出错误
calResult = ce.getMessage();
calException = true;
FineLoggerFactory.getLogger().error(ce.getMessage(), ce);
messageTips = messageTips + Toolkit.i18nText("Fine-Design_Basic_Formula_Cal_Error") + ":" + calResult;
}
@ -855,7 +857,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula {
messageTips = checkResult.getTips();
}
if (checkResult.isValid()) {
showMessageDialog(messageTips, checkResult.isValid());
showMessageDialog(messageTips, checkResult.isValid(), calException);
} else {
confirmCheckResult(checkResult, messageTips);
}
@ -872,7 +874,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula {
private boolean confirmCheckResult(FormulaCheckResult checkResult, String messageTips) {
if (checkResult.isValid()) {
showMessageDialog(checkResult.getTips(), checkResult.isValid());
showMessageDialog(checkResult.getTips(), checkResult.isValid(), false);
} else {
int columns = checkResult.getFormulaCoordinates().getColumns();
String position = StringUtils.EMPTY;
@ -898,8 +900,8 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula {
return true;
}
private void showMessageDialog(String message, boolean formulaValid) {
if (formulaValid) {
private void showMessageDialog(String message, boolean formulaValid, boolean calException) {
if (formulaValid && !calException) {
FineJOptionPane.showMessageDialog(
FormulaPane.this,
message);

17
designer-base/src/main/java/com/fr/design/formula/FunctionConstants.java

@ -36,6 +36,7 @@ import java.util.Comparator;
import java.util.Enumeration;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
@ -46,6 +47,7 @@ public final class FunctionConstants {
public static NameAndFunctionList COMMON = getCommonFunctionList();
public static NameAndTypeAndFunctionList[] EMBFUNCTIONS = getEmbededFunctionListArray();
public static FunctionGroup ALL = getAllFunctionGroup();
public static List<String> abandonFormulas = Arrays.asList("CIRCULAR", "CROSSLAYERTOTAL", "HIERARCHY", "LAYERTOTAL");
static {
loadEmbededFunctions();
@ -54,7 +56,8 @@ public final class FunctionConstants {
/**
* Don't let anyone instantiate this class.
*/
private FunctionConstants() {}
private FunctionConstants() {
}
private static void loadEmbededFunctions() {
String pkgName = "com.fr.function";
@ -88,7 +91,10 @@ public final class FunctionConstants {
Class<?> cls = Class.forName(pkgName + "." + fileName.substring(0, fileName.length() - 6));
if (StableUtils.classInstanceOf(cls, iface)) {
Function inst;
inst = (Function)cls.newInstance();
inst = (Function) cls.newInstance();
if (abandonFormulas.contains(inst.getClass().getSimpleName())) {
continue;
}
for (NameAndTypeAndFunctionList EMBFUNCTION : EMBFUNCTIONS) {
if (EMBFUNCTION.test(inst)) {
break;
@ -300,11 +306,12 @@ public final class FunctionConstants {
Collections.addAll(all, CUSTOM.getDescriptions());
//hugh:自定义函数分组
Set<Mutable> containers = ExtraClassManager.getInstance().getArray(FunctionDefContainer.MARK_STRING);
if(!containers.isEmpty()){
for(Mutable container : containers){
Collections.addAll(all,createFunctionGroup(((FunctionDefContainer)container)).getDescriptions());
if (!containers.isEmpty()) {
for (Mutable container : containers) {
Collections.addAll(all, createFunctionGroup(((FunctionDefContainer) container)).getDescriptions());
}
}
all = all.stream().filter(n -> !abandonFormulas.contains(n.getName())).collect(Collectors.toList());
Collections.sort(all, new Comparator<NameAndDescription>() {
@Override

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

@ -90,6 +90,8 @@ public class MismatchedTokenFunction implements Function<Exception, FormulaCheck
private String tokenName(int tokenType, MismatchedTokenException exception) {
if (tokenType == 0) {
return "<Set of tokens>";
} else if (tokenType == 33 || tokenType == 26 || tokenType == 31) {
return Toolkit.i18nText("Fine-Design_Basic_Formula_Right_Closing_Symbol");
} else {
String[] tokenNames = (String[]) getFieldValue(exception, "tokenNames");
return tokenType >= 0 && tokenType < tokenNames.length ? TranslateTokenUtils.translateToken(tokenNames[tokenType]) : "<" + tokenType + ">";

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

@ -16,12 +16,13 @@ import com.fr.stable.StringUtils;
import javax.swing.JOptionPane;
import javax.swing.JTree;
import javax.swing.SwingWorker;
import javax.swing.event.PopupMenuEvent;
import javax.swing.event.PopupMenuListener;
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;
/**
@ -40,7 +41,7 @@ public class TableSearchTreeComboBox extends FRTreeComboBox {
public TableSearchTreeComboBox(ChoosePane parent, JTree tree, TreeCellRenderer renderer) {
super(tree, renderer);
this.parent = parent;
setUI(new TableSearchTreeComboBoxUI());
initPopupListener();
}
protected UIComboBoxEditor createEditor() {
@ -158,12 +159,6 @@ public class TableSearchTreeComboBox extends FRTreeComboBox {
}
}
private static final TableNameFilter EMPTY_FILTER = new TableNameFilter() {
public boolean accept(TableProcedure procedure) {
return true;
}
};
/**
* 表名模糊搜索实现
*/
@ -184,15 +179,31 @@ public class TableSearchTreeComboBox extends FRTreeComboBox {
}
}
/**
* 重写FRTreeComboBoxUI实现点击下拉时触发模糊搜索
*/
private class TableSearchTreeComboBoxUI extends FRTreeComboBoxUI {
@Override
public void mouseClicked(MouseEvent e) {
searchExecute();
private static final TableNameFilter EMPTY_FILTER = new TableNameFilter() {
public boolean accept(TableProcedure procedure) {
return true;
}
};
private void initPopupListener() {
// 点击下拉时触发模糊搜索
this.addPopupMenuListener(new PopupMenuListener() {
@Override
public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
searchExecute();
}
@Override
public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
}
@Override
public void popupMenuCanceled(PopupMenuEvent e) {
}
});
}
/**

14
designer-base/src/main/java/com/fr/design/gui/ifilechooser/JavaFxNativeFileChooser.java

@ -197,7 +197,9 @@ public class JavaFxNativeFileChooser implements FileChooserProvider {
private File currentDirectory;
public Builder fileSelectionMode(FileSelectionMode fileSelectionMode) {
this.fileSelectionMode = fileSelectionMode;
if (fileSelectionMode != null) {
this.fileSelectionMode = fileSelectionMode;
}
return this;
}
@ -209,13 +211,17 @@ public class JavaFxNativeFileChooser implements FileChooserProvider {
}
public Builder filters(FileChooser.ExtensionFilter[] filters) {
this.filters = filters;
if (filters != null) {
this.filters = filters;
}
return this;
}
public Builder filters(ExtensionFilter[] filters) {
for (ExtensionFilter filter : filters) {
this.filters = ArrayUtils.add(this.filters, new FileChooser.ExtensionFilter(filter.getDes(), filter.getExtensions()));
if (filters != null) {
for (ExtensionFilter filter : filters) {
this.filters = ArrayUtils.add(this.filters, new FileChooser.ExtensionFilter(filter.getDes(), filter.getExtensions()));
}
}
return this;
}

12
designer-base/src/main/java/com/fr/design/javascript/JSContentPane.java

@ -1,5 +1,6 @@
package com.fr.design.javascript;
import com.fr.base.svg.IconUtils;
import com.fr.design.DesignerEnvManager;
import com.fr.design.border.UIRoundedBorder;
import com.fr.design.constants.KeyWords;
@ -16,6 +17,7 @@ import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.syntax.ui.rsyntaxtextarea.RSyntaxTextArea;
import com.fr.design.gui.syntax.ui.rsyntaxtextarea.SyntaxConstants;
import com.fr.design.i18n.Toolkit;
import com.fr.design.javascript.beautify.JavaScriptFormatHelper;
import com.fr.design.javascript.jsapi.JSImplPopulateAction;
import com.fr.design.javascript.jsapi.JSImplUpdateAction;
@ -92,7 +94,7 @@ public class JSContentPane extends BasicPane {
private void addNewPaneLabel(){
UILabel advancedEditorLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Advanced_Editor"), SwingConstants.LEFT);
UILabel advancedEditorLabel = new UILabel(Toolkit.i18nText("Fine-Design_Advanced_Editor"), IconUtils.readIcon("com/fr/design/images/edit/advancedEditor.svg"), SwingConstants.LEFT);
advancedEditorLabel.setCursor(new Cursor(Cursor.HAND_CURSOR));
advancedEditorLabel.addMouseListener(new MouseAdapter() {
@ -104,7 +106,7 @@ public class JSContentPane extends BasicPane {
jsImplUpdateAction.update(javaScript);
newJavaScriptImplPane.populate(javaScript);
if(advancedEditorDialog == null || !advancedEditorDialog.isVisible()) {
advancedEditorDialog = newJavaScriptImplPane.showWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() {
advancedEditorDialog = newJavaScriptImplPane.showWindowWithCustomSize(DesignerContext.getDesignerFrame(), new DialogActionAdapter() {
@Override
public void doOk() {
if (javaScript != null) {
@ -117,7 +119,7 @@ public class JSContentPane extends BasicPane {
public void doCancel() {
super.doCancel();
}
});
},new Dimension(900,800));
advancedEditorDialog.setModal(modal);
advancedEditorDialog.setResizable(true);
advancedEditorDialog.pack();
@ -126,7 +128,7 @@ public class JSContentPane extends BasicPane {
advancedEditorDialog.requestFocus();
}
});
labelPane.add(advancedEditorLabel,BorderLayout.CENTER);
labelPane.add(advancedEditorLabel,BorderLayout.EAST);
}
protected UIScrollPane createContentTextAreaPanel(){
@ -181,7 +183,7 @@ public class JSContentPane extends BasicPane {
}
});
labelPane.add(label,BorderLayout.EAST);
labelPane.add(label,BorderLayout.CENTER);
JPanel jsParaPane = new JPanel(new BorderLayout(4, 4));
jsParaPane.setPreferredSize(new Dimension(300, 80));
UIScrollPane scrollPane = new UIScrollPane(funNameLabel);

148
designer-base/src/main/java/com/fr/design/javascript/JSContentWithDescriptionPane.java

@ -1,5 +1,6 @@
package com.fr.design.javascript;
import com.fr.base.svg.IconUtils;
import com.fr.design.border.UIRoundedBorder;
import com.fr.design.constants.UIConstants;
import com.fr.design.gui.autocomplete.AutoCompleteExtraRefreshComponent;
@ -12,7 +13,7 @@ import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itextarea.UITextArea;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.gui.itextfield.PlaceholderTextField;
import com.fr.design.i18n.Toolkit;
import com.fr.design.javascript.jsapi.JSAPITreeHelper;
import com.fr.design.javascript.jsapi.JSAPIUserObject;
@ -26,8 +27,10 @@ import com.fr.json.JSONObject;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Cursor;
import java.awt.Desktop;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
@ -69,7 +72,7 @@ import javax.swing.tree.TreePath;
public class JSContentWithDescriptionPane extends JSContentPane implements KeyListener {
//搜索关键词输入框
private UITextField keyWordTextField = new UITextField(16);
private PlaceholderTextField keyWordTextField = new PlaceholderTextField(16);
//搜索出的提示列表
private JList tipsList;
private DefaultListModel tipsListModel = new DefaultListModel();
@ -105,10 +108,15 @@ public class JSContentWithDescriptionPane extends JSContentPane implements KeyLi
private static final String URL_FOR_TEST_NETWORK = "https://www.baidu.com";
private static final String DOCUMENT_SEARCH_URL = CloudCenter.getInstance().acquireUrlByKind("af.doc_search");
private static final String DOCUMENT_SEARCH_URL = "https://help.fanruan.com/finereport/api-helpdoc-title-";
private String currentValue;
private static CardLayout card;
private static final String RELOAD_CARD = "reloadCard";
private static final String DOC_LIST_CARD = "docListCard";
public JSContentWithDescriptionPane(String[] args) {
this.setLayout(new BorderLayout());
//===============================
@ -156,6 +164,14 @@ public class JSContentWithDescriptionPane extends JSContentPane implements KeyLi
this.add(functionNameAndDescriptionPanel, BorderLayout.SOUTH);
}
public void populate(String js) {
contentTextArea.setText(js);
ifHasBeenWriten = 1;
currentPosition = contentTextArea.getCaretPosition();
beginPosition = getBeginPosition();
insertPosition = beginPosition;
}
private void initContextAreaListener() {
contentTextArea.addKeyListener(new KeyAdapter() {
@Override
@ -186,6 +202,27 @@ public class JSContentWithDescriptionPane extends JSContentPane implements KeyLi
uninstallAutoCompletion();
}
});
contentTextArea.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
insertPosition = contentTextArea.getCaretPosition();
if (ifHasBeenWriten == 0) {
contentTextArea.setText(StringUtils.EMPTY);
ifHasBeenWriten = 1;
contentTextArea.setForeground(Color.black);
insertPosition = 0;
}
}
@Override
public void mouseReleased(MouseEvent e) {
currentPosition = contentTextArea.getCaretPosition();
if (currentPosition == insertPosition) {
beginPosition = getBeginPosition();
insertPosition = beginPosition;
}
}
});
}
@Override
@ -281,9 +318,9 @@ public class JSContentWithDescriptionPane extends JSContentPane implements KeyLi
String value = ((JSAPIUserObject) userObject).getValue();
if (StringUtils.equals(value, directCategory)) {
moduleTree.setSelectionPath(new TreePath(treeModel.getPathToRoot(node)));
moduleTree.scrollPathToVisible(moduleTree.getSelectionPath());
return true;
}
return false;
}
for (int i = 0; i < node.getChildCount(); i++) {
if (setModuleTreeSelection(node.getChildAt(i), directCategory, treeModel)) {
@ -315,7 +352,7 @@ public class JSContentWithDescriptionPane extends JSContentPane implements KeyLi
private void doHelpDocumentSearch() {
Object value = interfaceNameList.getSelectedValue();
if (value != null) {
String url = DOCUMENT_SEARCH_URL + value.toString();
String url = CloudCenter.getInstance().acquireUrlByKind("af.doc_search", DOCUMENT_SEARCH_URL) + value.toString();
try {
String result = HttpToolbox.get(url);
JSONObject jsonObject = new JSONObject(result);
@ -340,39 +377,60 @@ public class JSContentWithDescriptionPane extends JSContentPane implements KeyLi
}
private void initHelpDocumentPane(JPanel descriptionAndDocumentPanel) {
UIScrollPane helpDOCScrollPane;
card = new CardLayout();
JPanel mainPane = new JPanel(card);
initHelpDocumentList();
UIScrollPane helpDOCScrollPane = new UIScrollPane(helpDOCList);
helpDOCScrollPane.setPreferredSize(new Dimension(200, 200));
helpDOCScrollPane.setBorder(null);
mainPane.add(helpDOCScrollPane, DOC_LIST_CARD);
UILabel imageLabel = new UILabel();
imageLabel.setIcon(IconUtils.readIcon("com/fr/design/javascript/jsapi/images/connectFailed.svg"));
imageLabel.setPreferredSize(new Dimension(180, 65));
JPanel imagePane = FRGUIPaneFactory.createBorderLayout_S_Pane();
imagePane.setBorder(BorderFactory.createEmptyBorder(0, 42, 0, 0));
imagePane.add(imageLabel);
imagePane.setBackground(Color.WHITE);
UILabel failedLabel = new UILabel(Toolkit.i18nText("Fine-Design_Net_Connect_Failed"), 0);
failedLabel.setPreferredSize(new Dimension(180, 20));
UILabel reloadLabel = new UILabel(Toolkit.i18nText("Fine-Design_Basic_Reload"), 0);
reloadLabel.setCursor(new Cursor(Cursor.HAND_CURSOR));
reloadLabel.setPreferredSize(new Dimension(180, 20));
reloadLabel.setForeground(Color.blue);
JPanel labelPane = FRGUIPaneFactory.createVerticalFlowLayout_Pane(true, 0, 0, 0);
labelPane.setBorder(BorderFactory.createEmptyBorder(35, 45, 0, 0));
labelPane.setBackground(Color.WHITE);
labelPane.add(imagePane);
labelPane.add(failedLabel);
labelPane.add(reloadLabel);
JPanel containerPanel = FRGUIPaneFactory.createBorderLayout_S_Pane();
containerPanel.add(labelPane, BorderLayout.CENTER);
reloadLabel.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if (isNetworkOk()) {
doHelpDocumentSearch();
card.show(mainPane, DOC_LIST_CARD);
}
}
});
mainPane.add(containerPanel, RELOAD_CARD);
if (isNetworkOk()) {
helpDOCList = new JList(new DefaultListModel());
initHelpDOCListRender();
initHelpDOCListListener();
helpDOCScrollPane = new UIScrollPane(helpDOCList);
doHelpDocumentSearch();
card.show(mainPane, DOC_LIST_CARD);
} else {
UILabel label1 = new UILabel(Toolkit.i18nText("Fine-Design_Net_Connect_Failed"), 0);
label1.setPreferredSize(new Dimension(180, 20));
UILabel label2 = new UILabel(Toolkit.i18nText("Fine-Design_Basic_Reload"), 0);
label2.setPreferredSize(new Dimension(180, 20));
label2.setForeground(Color.blue);
JPanel labelPane = FRGUIPaneFactory.createVerticalFlowLayout_Pane(true, 0, 0, 0);
labelPane.setBackground(Color.WHITE);
labelPane.add(label1);
labelPane.add(label2);
JPanel containerPanel = FRGUIPaneFactory.createBorderLayout_S_Pane();
containerPanel.add(labelPane, BorderLayout.CENTER);
helpDOCScrollPane = new UIScrollPane(containerPanel);
label2.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
descriptionAndDocumentPanel.removeAll();
initHelpDocumentPane(descriptionAndDocumentPanel);
}
});
card.show(mainPane, RELOAD_CARD);
}
helpDOCScrollPane.setPreferredSize(new Dimension(200, 200));
helpDOCScrollPane.setBorder(null);
descriptionAndDocumentPanel.add(this.createNamePane(Toolkit.i18nText("Fine-Design_Relevant_Cases"), helpDOCScrollPane), BorderLayout.EAST);
descriptionAndDocumentPanel.add(this.createNamePane(Toolkit.i18nText("Fine-Design_Relevant_Cases"), mainPane), BorderLayout.EAST);
}
private void initHelpDocumentList() {
helpDOCList = new JList(new DefaultListModel());
initHelpDOCListRender();
initHelpDOCListListener();
}
private void initHelpDOCListListener() {
@ -383,19 +441,21 @@ public class JSContentWithDescriptionPane extends JSContentPane implements KeyLi
Object value = helpDOCList.getSelectedValue();
if (value instanceof HelpDocument) {
String url = ((HelpDocument) value).getDocumentUrl();
try {
Desktop.getDesktop().browse(new URI(url));
} catch (IOException ex) {
FineLoggerFactory.getLogger().error(ex.getMessage(), ex);
} catch (URISyntaxException ex) {
FineLoggerFactory.getLogger().error(ex.getMessage(), ex);
}
browse(url);
}
}
}
});
}
private void browse(String url){
try {
Desktop.getDesktop().browse(new URI(url));
} catch (IOException | URISyntaxException ex) {
FineLoggerFactory.getLogger().error(ex.getMessage(), ex);
}
}
private void initHelpDOCListRender() {
helpDOCList.setCellRenderer(new DefaultListCellRenderer() {
@Override
@ -558,7 +618,12 @@ public class JSContentWithDescriptionPane extends JSContentPane implements KeyLi
}
private void initInterfaceNameModule() {
moduleTree.setSelectionPath(moduleTree.getPathForRow(0));
DefaultTreeModel defaultTreeModel = (DefaultTreeModel) moduleTree.getModel();
TreeNode root = (TreeNode) defaultTreeModel.getRoot();
while (root.getChildCount() > 0){
root = root.getChildAt(0);
}
moduleTree.setSelectionPath(new TreePath(defaultTreeModel.getPathToRoot(root)));
}
private void setDescription(String interfaceName) {
@ -652,6 +717,7 @@ public class JSContentWithDescriptionPane extends JSContentPane implements KeyLi
tipsPane.setBorder(BorderFactory.createEmptyBorder(30, 2, 0, 0));
JPanel searchPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
searchPane.setLayout(new BorderLayout(4, 4));
keyWordTextField.setPlaceholder(Toolkit.i18nText("Fine-Design_Search_Interface"));
searchPane.add(keyWordTextField, BorderLayout.CENTER);
//搜索按钮

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

@ -10,7 +10,7 @@ import javax.swing.JComponent;
* Date: 13-7-15
* Time: 上午10:28
*/
public interface BaseJForm<T> extends JTemplateProvider<T> {
public interface BaseJForm<T> extends JTemplateProvider<T>, JDashboard {
String XML_TAG = "JForm";
int FORM_TAB = 0;
@ -58,4 +58,9 @@ public interface BaseJForm<T> extends JTemplateProvider<T> {
* @param ecContainer ElementCase所在container
*/
void tabChanged(int index, FormElementCaseContainerProvider ecContainer);
@Override
default void switchToDashBoardEditor() {
tabChanged(FORM_TAB);
}
}

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

@ -28,6 +28,8 @@ import com.fr.design.fun.impl.AbstractTemplateTreeShortCutProvider;
import com.fr.design.gui.iprogressbar.ProgressDialog;
import com.fr.design.gui.iscrollbar.UIScrollBar;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.share.mini.MiniShopDisposingChecker;
import com.fr.design.mainframe.share.mini.MiniShopNativeTaskManager;
import com.fr.design.mainframe.toolbar.ToolBarMenuDock;
import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus;
import com.fr.design.mainframe.vcs.common.VcsHelper;
@ -157,6 +159,11 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
@Override
public void windowClosing(WindowEvent e) {
// 检查mini商城是否存在未结束的后台任务
if (!MiniShopDisposingChecker.check()) {
return;
}
// 关闭前check
if (!TemplateSavingChecker.check()) {
return;

10
designer-base/src/main/java/com/fr/design/mainframe/JDashboard.java

@ -0,0 +1,10 @@
package com.fr.design.mainframe;
/**
* @author Starryi
* @version 1.0
* Created by Starryi on 2022/3/1
*/
public interface JDashboard {
void switchToDashBoardEditor();
}

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

@ -2,6 +2,7 @@ package com.fr.design.mainframe;
import com.fr.base.BaseUtils;
import com.fr.base.Parameter;
import com.fr.base.TRL;
import com.fr.base.extension.FileExtension;
import com.fr.base.io.BaseBook;
import com.fr.base.iofile.attr.DesignBanCopyAttrMark;
@ -105,9 +106,9 @@ import javax.swing.JOptionPane;
import javax.swing.SwingConstants;
import javax.swing.undo.UndoManager;
import java.awt.BorderLayout;
import java.io.ByteArrayOutputStream;
import java.awt.Dimension;
import java.awt.FontMetrics;
import java.io.ByteArrayOutputStream;
import java.util.Set;
import java.util.concurrent.Callable;
@ -1000,7 +1001,7 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
return true;
}
public boolean isNewCreateTpl(){
public boolean isNewCreateTpl() {
return isNewCreateTpl;
}
@ -1543,7 +1544,7 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
/**
* 设置新引擎后有不支持的功能时设计器中模板的标题需要加上兼容模式或者不支持分页引擎来提示用户
* */
*/
private String compatibilityTip() {
if (!CptAndCptxCompatibilityUtil.isEngineXEnable(this.getTarget(), getEditingFILE().getPath())) {
return StringUtils.EMPTY;
@ -1888,6 +1889,15 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
templateThemeButton.setToolTipText(name);
}
/**
* 定位
*
* @param trl
*/
public void navigate(TRL trl) {
}
public void generateForBiddenTemplate() {
}

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

@ -1,10 +1,6 @@
package com.fr.design.mainframe.form;
import java.awt.Dimension;
import java.awt.image.BufferedImage;
import javax.swing.JComponent;
import com.fr.base.TRL;
import com.fr.design.designer.TargetComponent;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.menu.MenuDef;
@ -12,6 +8,10 @@ import com.fr.design.menu.ShortCut;
import com.fr.design.menu.ToolBarDef;
import com.fr.form.FormElementCaseProvider;
import javax.swing.JComponent;
import java.awt.Dimension;
import java.awt.image.BufferedImage;
public interface FormECDesignerProvider {
String XML_TAG = "FormElementCaseDesigner";
@ -92,4 +92,6 @@ public interface FormECDesignerProvider {
void refreshPropertyPane();
void removeSelection();
default void navigate(TRL trl) {}
}

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

@ -1,31 +1,46 @@
package com.fr.design.mainframe.loghandler;
import com.finebi.cbb.base.tuple.Pair;
import com.fr.base.BaseUtils;
import com.fr.base.TRL;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.imenu.UIMenuItem;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.ui.util.UIUtil;
import com.fr.file.FILEFactory;
import com.fr.general.ComparatorUtils;
import com.fr.general.log.Log4jConfig;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils;
import com.fr.stable.project.ProjectConstants;
import com.fr.third.apache.logging.log4j.Level;
import com.fr.third.apache.logging.log4j.core.LogEvent;
import com.fr.third.guava.base.Splitter;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.AbstractAction;
import javax.swing.ActionMap;
import javax.swing.InputMap;
import javax.swing.JCheckBoxMenuItem;
import javax.swing.JComponent;
import javax.swing.JEditorPane;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JTextPane;
import javax.swing.KeyStroke;
import javax.swing.text.AttributeSet;
import javax.swing.text.BadLocationException;
import javax.swing.text.DefaultEditorKit;
import javax.swing.text.Document;
import javax.swing.text.Element;
import javax.swing.text.SimpleAttributeSet;
import javax.swing.text.StyleConstants;
import javax.swing.text.html.HTML;
import javax.swing.text.html.HTMLDocument;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
@ -36,8 +51,14 @@ import java.awt.event.ItemListener;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Date;
import java.util.Deque;
import java.util.List;
import java.util.regex.Pattern;
import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER;
@ -61,6 +82,8 @@ public class DesignerLogHandler {
private static final String ACTION_MAP_KEY = "clear";
private static final Pattern pattern = Pattern.compile("\\([^(]*.(?>cpt|frm|cptx)[^)]*\\)");
public static DesignerLogHandler getInstance() {
return HOLDER.singleton;
@ -215,13 +238,61 @@ public class DesignerLogHandler {
popup.show(jTextArea, event.getX(), event.getY());
checkEnabled();
}
if (event.getButton() == MouseEvent.BUTTON1) {
String url = findTplLinkFromMouseEvent(event);
if (StringUtils.isNotEmpty(url)) {
navigate(url);
}
}
}
});
}
/**
* 将模板定位链接导航到指定的位置
*
* @param href 模板定位链接
*/
private void navigate(String href) {
if (!href.startsWith(TRL.PREFIX)) {
return;
}
TRL trl = new TRL(href);
DesignerContext.getDesignerFrame().openTemplate(FILEFactory.createFILE(ProjectConstants.REPORTLETS_NAME + FILEFactory.SEPARATOR + trl.getTemplatePath()));
JTemplate<?, ?> currentEditingTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (currentEditingTemplate != null) {
currentEditingTemplate.navigate(trl);
}
}
/**
* 鼠标事件中定位到模板链接
*
* @param event 鼠标事件
* @return 模板链接
*/
private String findTplLinkFromMouseEvent(MouseEvent event) {
JEditorPane editor = (JEditorPane) event.getSource();
int pos = editor.getUI().viewToModel(editor, event.getPoint());
if (pos >= 0 && editor.getDocument() instanceof HTMLDocument) {
HTMLDocument hdoc = (HTMLDocument) editor.getDocument();
Element elem = hdoc.getCharacterElement(pos);
Object a = elem.getAttributes().getAttribute(HTML.Tag.A);
if (a instanceof AttributeSet) {
AttributeSet set = (AttributeSet) a;
String url = (String) set.getAttribute(HTML.Attribute.HREF);
if (StringUtils.isNotEmpty(url)) {
return url;
}
}
}
return StringUtils.EMPTY;
}
private JTextPane initLogJTextArea() {
final JTextPane resultPane = new JTextPane();
resultPane.setContentType("text/html");
InputMap inputMap = resultPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_C, DEFAULT_MODIFIER), DefaultEditorKit.copyAction);
inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_A, DEFAULT_MODIFIER), DefaultEditorKit.selectAllAction);
@ -294,6 +365,9 @@ public class DesignerLogHandler {
SimpleAttributeSet attrSet = new SimpleAttributeSet();
if (style == DesignerLogger.ERROR_INT) {
if (renderLink(str)) {
return;
}
StyleConstants.setForeground(attrSet, Color.RED);
StyleConstants.setBold(attrSet, true);
} else if (style == DesignerLogger.WARN_INT) {
@ -314,6 +388,86 @@ public class DesignerLogHandler {
}
}
/**
* 渲染模板链接
*
* @param str 可能包含模板链接字符串
* @return 是否处理成功
*/
private boolean renderLink(String str) {
Document doc = jTextArea.getStyledDocument();
if (doc instanceof HTMLDocument) {
String[] tplLink = findTplLink(str);
return tplLink != null
&& tplLink.length > 0
&& link2Html(str, tplLink);
}
return false;
}
/**
* 处理模板链接
*
* @param s 含有模板链接
* @param tplLink 模板链接
* @return 是否处理成功
*/
private boolean link2Html(String s, String[] tplLink) {
List<String> lineSeg = splitLineSeg(s, tplLink);
String html = buildHtml(lineSeg, tplLink);
try {
Document doc = jTextArea.getStyledDocument();
HTMLDocument htmlDocument = (HTMLDocument) doc;
htmlDocument.insertAfterEnd(htmlDocument.getCharacterElement(doc.getLength()), html);
} catch (BadLocationException | IOException ignored) {
// 这里出问题不记录日志否则会导致死循环
return false;
}
return true;
}
@NotNull
private String buildHtml(List<String> lineSeg, String[] tplLink) {
StringBuilder sb = new StringBuilder("<span style=\"font-weight: bold;font-size:" + jTextArea.getFont().getSize() + "\">");
for (int i = 0; i < tplLink.length; i++) {
sb.append("<span style=\"color:red;\">")
.append(lineSeg.get(i))
.append("</span><a href=\"tpl://")
.append(tplLink[i], 1, tplLink[i].length() - 1)
.append("\">")
.append(tplLink[i])
.append("</a>");
}
if (lineSeg.size() > tplLink.length) {
sb.append("<span style=\"color:red;\">").append(lineSeg.get(lineSeg.size() - 1)).append("</span>");
}
sb.append("</span>");
return sb.toString();
}
/**
* 将非公式部分切割为数组
*/
@NotNull
private List<String> splitLineSeg(String s, String[] tplLink) {
String seg = s.replaceAll("\\n", "<br/>");
List<String> lineSeg = new ArrayList<>(2);
List<String> lineSegTmp = new ArrayList<>();
String tmp = seg;
for (String link : tplLink) {
lineSegTmp = Splitter.on(link).omitEmptyStrings().splitToList(tmp);
lineSeg.add(lineSegTmp.get(0));
if (lineSegTmp.size() > 1) {
tmp = lineSegTmp.get(1);
}
}
if (lineSegTmp.size() > 1) {
lineSeg.add(lineSegTmp.get(1));
}
return lineSeg;
}
private String appendLocaleMark(String str, int style) {
if (style == DesignerLogger.ERROR_INT) {
@ -375,4 +529,34 @@ public class DesignerLogHandler {
};
}
/**
* 尝试找到模板链接
*
* @param s 可能含有模板链接的字符串
* @return 模板链接
*/
@Nullable
public static String[] findTplLink(String s) {
List<String> list = new ArrayList<>();
// 栈配对
Deque<Pair<Character, Integer>> stack = new ArrayDeque<>();
for (int i = 0; i < s.length(); i++) {
char c = s.charAt(i);
if (c == '(') {
stack.push(new Pair<>(c, i));
} else if (c == ')') {
Pair<Character, Integer> left = stack.peek();
if (left != null && left.getFirst() == '(') {
Pair<Character, Integer> pop = stack.pop();
String link = s.substring(pop.getSecond(), i + 1);
if (link.contains(ProjectConstants.CPT_SUFFIX)
|| link.contains(ProjectConstants.FRM_SUFFIX)) {
list.add(link);
}
}
}
}
return list.toArray(new String[0]);
}
}

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

@ -34,6 +34,10 @@ public class ComponentShareUtil {
return localeMark.getValue();
}
public static boolean isShowMiniShopWindow() {
return isShowOnlineWidgetRepoPane();
}
/**
* 判断是否可触达
*

37
designer-base/src/main/java/com/fr/design/mainframe/share/mini/MiniShopDisposingChecker.java

@ -0,0 +1,37 @@
package com.fr.design.mainframe.share.mini;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext;
import javax.swing.JOptionPane;
import java.awt.Component;
/**
* @author Starryi
* @version 1.0
* Created by Starryi on 2022/1/8
*/
public class MiniShopDisposingChecker {
public static boolean check() {
return check(DesignerContext.getDesignerFrame());
}
public static boolean check(Component optionParentComponent) {
if (MiniShopNativeTaskManager.getInstance().hasExecutingTasks()) {
int result = FineJOptionPane.showConfirmDialog(
optionParentComponent,
Toolkit.i18nText("Fine-Design_Share_Online_Mini_Shop_Close_Tip"),
"",
FineJOptionPane.YES_NO_OPTION
);
if (result == JOptionPane.YES_OPTION) {
MiniShopNativeTaskManager.getInstance().cancelAllExecutingTasks();
return true;
}
return false;
}
return true;
}
}

11
designer-base/src/main/java/com/fr/design/mainframe/share/mini/MiniShopNativeTask.java

@ -0,0 +1,11 @@
package com.fr.design.mainframe.share.mini;
/**
* @author Starryi
* @version 1.0
* Created by Starryi on 2022/1/8
*/
public interface MiniShopNativeTask {
void execute();
void cancel();
}

42
designer-base/src/main/java/com/fr/design/mainframe/share/mini/MiniShopNativeTaskManager.java

@ -0,0 +1,42 @@
package com.fr.design.mainframe.share.mini;
import java.util.HashSet;
import java.util.Set;
/**
* @author Starryi
* @version 1.0
* Created by Starryi on 2022/1/8
*/
public class MiniShopNativeTaskManager {
private MiniShopNativeTaskManager() {
}
private static class HOLDER {
private static final MiniShopNativeTaskManager singleton = new MiniShopNativeTaskManager();
}
public static MiniShopNativeTaskManager getInstance() {
return MiniShopNativeTaskManager.HOLDER.singleton;
}
private static final Set<MiniShopNativeTask> executingTasks = new HashSet<>();
public void addStartedTask(MiniShopNativeTask task) {
executingTasks.add(task);
}
public void removeCompletedTask(MiniShopNativeTask task) {
executingTasks.remove(task);
}
public boolean hasExecutingTasks() {
return !executingTasks.isEmpty();
}
public void cancelAllExecutingTasks() {
for (MiniShopNativeTask executingTask: executingTasks) {
executingTask.cancel();
}
executingTasks.clear();
}
}

3
designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeProfilePane.java

@ -206,7 +206,7 @@ public abstract class TemplateThemeProfilePane<T extends TemplateTheme> extends
});
}
public UIButton createSaveButton() {
public UIButton createSaveButton(final TemplateThemeProfileDialog<T> profileDialog) {
saveButton = new UIButton();
saveButton.setText(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Profile_Pane_Save"));
saveButton.setEnabled(false);
@ -224,6 +224,7 @@ public abstract class TemplateThemeProfilePane<T extends TemplateTheme> extends
@Override
public void run() {
DesignerToastMsgUtil.toastPrompt(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Profile_Pane_Save_Successfully"));
profileDialog.exit();
}
});
}

9
designer-base/src/main/java/com/fr/design/mainframe/theme/dialog/TemplateThemeGridPagesDialog.java

@ -7,6 +7,7 @@ import com.fr.design.mainframe.theme.TemplateThemeGridPagesPane;
import com.fr.design.mainframe.theme.TemplateThemeGridPane;
import javax.swing.JPanel;
import java.awt.Window;
/**
* @author Starryi
@ -19,13 +20,17 @@ public class TemplateThemeGridPagesDialog extends TemplateThemeDialog implements
protected TemplateThemeGridPagesPane overallPane;
public TemplateThemeGridPagesDialog() {
super(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Using_Dialog_Title"), CONTENT_WIDTH, CONTENT_HEIGHT);
public TemplateThemeGridPagesDialog(Window parentWindow) {
super(parentWindow, Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Using_Dialog_Title"), CONTENT_WIDTH, CONTENT_HEIGHT);
setupContentPane();
setupActionButtons();
}
public TemplateThemeGridPagesDialog() {
this(DesignerContext.getDesignerFrame());
}
@Override
protected JPanel createContentPane() {
overallPane = new TemplateThemeGridPagesPane(this);

2
designer-base/src/main/java/com/fr/design/mainframe/theme/dialog/TemplateThemeProfileDialog.java

@ -90,7 +90,7 @@ public class TemplateThemeProfileDialog<T extends TemplateTheme> extends Templat
}));
}
uiButtonList.add(profilePane.createSaveButton());
uiButtonList.add(profilePane.createSaveButton(TemplateThemeProfileDialog.this));
uiButtonList.add(profilePane.createSaveAsButton(TemplateThemeProfileDialog.this));
uiButtonList.add(createCancelButton());

7
designer-base/src/main/java/com/fr/design/mainframe/theme/dialog/TemplateThemeUsingDialog.java

@ -1,11 +1,18 @@
package com.fr.design.mainframe.theme.dialog;
import java.awt.Window;
/**
* @author Starryi
* @version 1.0
* Created by Starryi on 2021/8/13
*/
public class TemplateThemeUsingDialog extends TemplateThemeGridPagesDialog {
public TemplateThemeUsingDialog(Window parentWindow) {
super(parentWindow);
overallPane.showThemeUsingPane();
}
public TemplateThemeUsingDialog() {
super();
overallPane.showThemeUsingPane();

8
designer-base/src/main/java/com/fr/design/report/fit/FormFitAttrModelType.java

@ -27,8 +27,8 @@ public enum FormFitAttrModelType {
@Override
public Item[] getAbsoluteLayoutSaleAttr() {
return new Item[]{
new Item(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Scaling_Mode_Fit"), WAbsoluteLayout.STATE_FIT),
new Item(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Scaling_Mode_Fixed"), WAbsoluteLayout.STATE_FIXED)
new Item(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Attr_Bidirectional_Adaptive"), WAbsoluteLayout.STATE_FIT),
new Item(com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit-No"), WAbsoluteLayout.STATE_FIXED)
};
}
@ -73,7 +73,7 @@ public enum FormFitAttrModelType {
return new Item[]{
new Item(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Attr_Bidirectional_Adaptive"), WFitLayout.STATE_FULL),
new Item(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Attr_Horizontal_Adaptive"), WFitLayout.STATE_ORIGIN),
new Item(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Scaling_Mode_Fixed"), 2)};
new Item(com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit-No"), 2)};
}
@Override
@ -81,7 +81,7 @@ public enum FormFitAttrModelType {
return new Item[]{
new Item(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Attr_Bidirectional_Adaptive"), WFitLayout.STATE_FULL),
new Item(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Attr_Horizontal_Adaptive"), WFitLayout.STATE_ORIGIN),
new Item(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Scaling_Mode_Fixed"), 2)};
new Item(com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit-No"), 2)};
}

28
designer-base/src/main/java/com/fr/design/selection/Selectedable.java

@ -1,25 +1,29 @@
package com.fr.design.selection;
import com.fr.base.TRL;
/**
*
* @author zhou
* @since 2012-7-26上午10:20:32
*/
public interface Selectedable<S extends SelectableElement> {
public S getSelection();
S getSelection();
void setSelection(S selectElement);
public void setSelection(S selectElement);
/**
* Adds a <code>ChangeListener</code> to the listener list.
*/
void addSelectionChangeListener(SelectionListener selectionListener);
/**
* Adds a <code>ChangeListener</code> to the listener list.
*/
public void addSelectionChangeListener(SelectionListener selectionListener);
/**
* removes a <code>ChangeListener</code> from the listener list.
*/
void removeSelectionChangeListener(SelectionListener selectionListener);
/**
* removes a <code>ChangeListener</code> from the listener list.
*/
public void removeSelectionChangeListener(SelectionListener selectionListener);
// august:这儿就不要加fireSelectionChangeListener方法了。因为这个方法一般要定义成私有的,不然外部随即的调用!
default void navigate(TRL trl) {
// august:这儿就不要加fireSelectionChangeListener方法了。因为这个方法一般要定义成私有的,不然外部随即的调用!
}
}

33
designer-base/src/main/java/com/fr/design/startup/FineStartupNotificationFactory.java

@ -0,0 +1,33 @@
package com.fr.design.startup;
import org.jetbrains.annotations.NotNull;
/**
* @author Starryi
* @version 1.0
* Created by Starryi on 2022/1/11
*/
public class FineStartupNotificationFactory {
private static final FineStartupNotificationProvider DEFAULT = Install4jStartupNotificationProvider.getInstance();
private static FineStartupNotificationProvider provider;
public FineStartupNotificationFactory() {
}
public static FineStartupNotificationProvider getNotification() {
return provider;
}
public static void setLogger(@NotNull FineStartupNotificationProvider provider) {
FineStartupNotificationFactory.provider = provider;
}
public static void reset() {
provider = DEFAULT;
}
static {
provider = DEFAULT;
}
}

14
designer-base/src/main/java/com/fr/design/startup/FineStartupNotificationProvider.java

@ -0,0 +1,14 @@
package com.fr.design.startup;
/**
* @author Starryi
* @version 1.0
* Created by Starryi on 2022/1/11
*/
public interface FineStartupNotificationProvider {
void registerStartupListener(Listener listener);
interface Listener {
void startupPerformed(String parameters);
}
}

35
designer-base/src/main/java/com/fr/design/startup/Install4jStartupNotificationProvider.java

@ -0,0 +1,35 @@
package com.fr.design.startup;
import com.install4j.api.launcher.StartupNotification;
/**
* @author Starryi
* @version 1.0
* Created by Starryi on 2022/1/11
*/
public class Install4jStartupNotificationProvider implements FineStartupNotificationProvider {
private Install4jStartupNotificationProvider() {
}
private static final Install4jStartupNotificationProvider INSTANCE = new Install4jStartupNotificationProvider();
public static Install4jStartupNotificationProvider getInstance() {
return INSTANCE;
}
@Override
public void registerStartupListener(Listener listener) {
boolean supported = false;
try {
supported = Class.forName("com.install4j.api.launcher.StartupNotification") != null;
} catch (Throwable ignored) {}
if (supported) {
StartupNotification.registerStartupListener(new StartupNotification.Listener() {
@Override
public void startupPerformed(String parameters) {
listener.startupPerformed(parameters);
}
});
}
}
}

4
designer-base/src/main/java/com/fr/design/style/AbstractPopBox.java

@ -10,8 +10,6 @@ import javax.swing.JWindow;
import javax.swing.SwingUtilities;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.util.ArrayList;
import java.util.List;
import java.awt.AWTEvent;
import java.awt.Dimension;
import java.awt.Point;
@ -21,6 +19,8 @@ import java.awt.Window;
import java.awt.event.AWTEventListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.List;
/**
* @author kunsnat E-mail:kunsnat@gmail.com

14
designer-base/src/main/java/com/fr/design/ui/compatible/NewModernUIPane.java

@ -17,8 +17,11 @@ import com.teamdev.jxbrowser.engine.EngineOptions;
import com.teamdev.jxbrowser.engine.RenderingMode;
import com.teamdev.jxbrowser.event.Observer;
import com.teamdev.jxbrowser.js.JsObject;
import com.teamdev.jxbrowser.net.Network;
import com.teamdev.jxbrowser.net.Scheme;
import com.teamdev.jxbrowser.net.callback.VerifyCertificateCallback;
import com.teamdev.jxbrowser.view.swing.BrowserView;
import org.jetbrains.annotations.Nullable;
import java.awt.BorderLayout;
@ -108,6 +111,17 @@ public class NewModernUIPane<T> extends ModernUIPane<T> {
}
Engine engine = Engine.newInstance(builder.build());
if (DesignerEnvManager.getEnvManager().isOpenDebug()) {
// 调试模式下,禁止HTTPS证书验证,使得可以正常访问商城测试服务器等
Network network = engine.network();
network.set(VerifyCertificateCallback.class, new VerifyCertificateCallback() {
@Nullable
@Override
public Response on(Params params) {
return VerifyCertificateCallback.Response.valid();
}
});
}
browser = engine.newBrowser();
// 初始化的时候,就把命名空间对象初始化好,确保window.a.b.c("a.b.c"为命名空间)对象都是初始化过的

31
designer-base/src/main/java/com/fr/design/upm/UpmFinder.java

@ -1,6 +1,6 @@
package com.fr.design.upm;
import com.fr.base.FRContext;
import com.fr.decision.webservice.v10.plugin.helper.category.impl.BaseResourceLoader;
import com.fr.decision.webservice.v10.plugin.helper.category.impl.UpmResourceLoader;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.dialog.UIDialog;
@ -12,8 +12,11 @@ import com.fr.design.update.ui.dialog.UpdateMainDialog;
import com.fr.event.Event;
import com.fr.event.EventDispatcher;
import com.fr.event.Listener;
import com.fr.general.CommonIOUtils;
import com.fr.general.GeneralContext;
import com.fr.general.IOUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.plugin.PluginStoreConstants;
import com.fr.stable.StableUtils;
import com.fr.workspace.Workspace;
import com.fr.workspace.WorkspaceEvent;
@ -33,7 +36,7 @@ public class UpmFinder {
private static final String MAIN_RESOURCE_PATH = UPM_DIR + "/plugin_design.html";
private static final String JXBROWSER = "com.teamdev.jxbrowser.browser.Browser";
public static String installHome = FRContext.getCommonOperator().getWebRootPath();
public static String installHome = PluginStoreConstants.getLocalInstallHome();
private static UIDialog dialog = null;
@ -41,7 +44,8 @@ public class UpmFinder {
EventDispatcher.listen(WorkspaceEvent.AfterSwitch, new Listener<Workspace>() {
@Override
public void on(Event event, Workspace param) {
installHome = FRContext.getCommonOperator().getWebRootPath();
installHome = PluginStoreConstants.getLocalInstallHome();
UpmResourceLoader.INSTANCE.checkOldShopFile();
}
});
}
@ -75,24 +79,24 @@ public class UpmFinder {
}
private static void showUpmPane() {
if (!checkUPMResourcesExist()){
if (!checkUPMResourcesExist()) {
// upm下载
int val = FineJOptionPane.showConfirmDialog(null, Toolkit.i18nText("Fine-Design_Basic_Plugin_Shop_Need_Install"),
Toolkit.i18nText("Fine-Design_Basic_Confirm"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE);
if (val == JOptionPane.OK_OPTION){
if (val == JOptionPane.OK_OPTION) {
try {
UpmResourceLoader.INSTANCE.download();
UpmResourceLoader.INSTANCE.install();
installUpmResource();
FineJOptionPane.showMessageDialog(null, Toolkit.i18nText("Fine-Design_Basic_Plugin_Shop_Installed"),
Toolkit.i18nText("Fine-Design_Basic_Message"), JOptionPane.INFORMATION_MESSAGE);
} catch (Exception e){
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
FineJOptionPane.showMessageDialog(null, Toolkit.i18nText("Fine-Design_Updater_Download_Failed"),
Toolkit.i18nText("Fine-Design_Basic_Message"), JOptionPane.INFORMATION_MESSAGE);
}
}
}
else {
} else {
UpmShowPane upmPane = new UpmShowPane();
if (dialog == null) {
dialog = new UpmShowDialog(DesignerContext.getDesignerFrame(), upmPane);
@ -102,6 +106,15 @@ public class UpmFinder {
}
}
private static void installUpmResource() {
String installHome = PluginStoreConstants.getLocalInstallHome();
File scriptZip = new File(BaseResourceLoader.SCRIPT_DOWNLOAD_PATH);
if (scriptZip.exists()) {
IOUtils.unzip(scriptZip, installHome);
CommonIOUtils.deleteFile(scriptZip);
}
}
private static void showUpdatePane() {
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Update_Info_Plugin_Message"));
if (!GeneralContext.getLocale().equals(Locale.JAPANESE) && !GeneralContext.getLocale().equals(Locale.JAPAN)

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

@ -5,6 +5,7 @@ import com.fr.base.ServerConfig;
import com.fr.concurrent.NamedThreadFactory;
import com.fr.design.DesignerEnvManager;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.deeplink.DeepLinkCore;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.fun.DesignerEnvProcessor;
import com.fr.design.gui.UILookAndFeel;
@ -26,10 +27,15 @@ import com.fr.start.ServerStarter;
import com.fr.value.NotNullLazyValue;
import com.fr.workspace.WorkContext;
import org.jetbrains.annotations.NotNull;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import java.awt.Color;
import java.awt.Desktop;
import java.awt.Font;
import java.awt.Frame;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
@ -213,6 +219,14 @@ public class DesignUtils {
DesignerContext.getDesignerFrame().openTemplate(new FileFILE(f));
}
});
} else {
String url = line;
UIUtil.invokeLaterIfNeeded(new Runnable() {
@Override
public void run() {
DeepLinkCore.getInstance().receiveDeeplink2(url);
}
});
}
}
}

2
designer-base/src/main/java/com/fr/design/utils/LoadingUtils.java

@ -21,7 +21,7 @@ public class LoadingUtils {
public static JPanel createLoadingPane() {
JPanel jPanel = new JPanel();
UILabel loadingLabel = new UILabel(LOADING_ICON);
UILabel tipLabel = new UILabel(Toolkit.i18nText("Fine-Design_Open_Template_Loading"));
UILabel tipLabel = new UILabel(Toolkit.i18nText("Fine-Design_Loading"));
tipLabel.setForeground(TIP_COLOR);
jPanel.setLayout(new LayoutManager() {
@Override

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

@ -47,9 +47,9 @@ import com.fr.stable.StringUtils;
import com.fr.stable.os.windows.WindowsDetector;
import com.fr.stable.project.ProjectConstants;
import com.fr.workspace.WorkContext;
import com.fr.workspace.Workspace;
import com.fr.workspace.WorkspaceEvent;
import javax.swing.AbstractAction;
import javax.swing.AbstractListModel;
import javax.swing.ActionMap;
@ -202,6 +202,16 @@ public class FILEChooserPane extends BasicPane {
return INSTANCE;
}
public static FILEChooserPane getInstanceWithDesignatePath(String path, FILEFilter filter) {
INSTANCE.showLoc = false;
INSTANCE.showEnv = false;
INSTANCE.showWebReport = false;
INSTANCE.setDesignateModel(path);
INSTANCE.removeAllFilter();
INSTANCE.addChooseFILEFilter(filter, 0);
return INSTANCE;
}
public static FILEChooserPane getMultiEnvInstance(boolean showLoc, boolean showWebReport) {
INSTANCE.showEnv = true;
INSTANCE.showLoc = showLoc;
@ -499,7 +509,7 @@ public class FILEChooserPane extends BasicPane {
}
private String calProperFileName(String fileName, ChooseFileFilter fileFilter) {
if(fileFilter == null){
if (fileFilter == null) {
return fileName;
}
String filterExtension = fileFilter.getExtensionString();
@ -516,10 +526,10 @@ public class FILEChooserPane extends BasicPane {
return fileNameWithOutExtension + filterExtension;
}
private boolean isMapping(String fromExtension, String toExtension){
if(FileExtension.CPTX.matchExtension(fromExtension)){
private boolean isMapping(String fromExtension, String toExtension) {
if (FileExtension.CPTX.matchExtension(fromExtension)) {
return FileExtension.CPT.matchExtension(toExtension);
}else if(FileExtension.CPT.matchExtension(fromExtension)){
} else if (FileExtension.CPT.matchExtension(fromExtension)) {
return FileExtension.CPTX.matchExtension(toExtension);
}
return false;
@ -678,7 +688,7 @@ public class FILEChooserPane extends BasicPane {
* 移除文件后缀的方法
* 解决cptx文件的另存为操作默认会出现双后缀的bug(xxx.cptx.cpt)
**/
private String removeSuffix(String text){
private String removeSuffix(String text) {
return FileExtension.CPTX.matchExtension(text) ? text.substring(0, text.length() - FileExtension.CPTX.getSuffix().length()) : text;
}
@ -783,7 +793,7 @@ public class FILEChooserPane extends BasicPane {
ChooseFileFilter supportedTypes = new ChooseFileFilter(FRContext.getFileNodes().getSupportedTypes(), appName + Toolkit.i18nText("Fine-Design_Report_Template_File"));
Set<ReportSupportedFileProvider> providers = ExtraReportClassManager.getInstance().getArray(ReportSupportedFileProvider.XML_TAG);
for (ReportSupportedFileProvider provider : providers) {
for (FileExtension fileExtension : provider.getFileExtensions()){
for (FileExtension fileExtension : provider.getFileExtensions()) {
supportedTypes.addExtension(fileExtension.getExtension());
}
}
@ -884,7 +894,7 @@ public class FILEChooserPane extends BasicPane {
saveDictionary();
dialogExit();
} else {
FineJOptionPane.showMessageDialog(this, Toolkit.i18nText("Fine-Design_Basic_App_Template_Report_Not_Exist"));
FineJOptionPane.showMessageDialog(this, Toolkit.i18nText("Fine-Design_Basic_App_File_Not_Exist"));
return;
}
}
@ -915,7 +925,7 @@ public class FILEChooserPane extends BasicPane {
if (access(selectedFile) && access(currentDirectory)) {
if (selectedFile.exists()) {
int selVal = FineJOptionPane.showConfirmDialog(dialog, Toolkit.i18nText("Fine-Design_Basic_Utils_Would_You_Like_To_Cover_The_Current_File") + " ?",
Toolkit.i18nText("Fine-Design_Basic_Confirm"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
Toolkit.i18nText("Fine-Design_Basic_Confirm"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
if (selVal == JOptionPane.YES_OPTION) {
option = JOPTIONPANE_OK_OPTION;
saveDictionary();
@ -1031,6 +1041,14 @@ public class FILEChooserPane extends BasicPane {
setPlaceListModel(new PlaceListModel());
}
private void setDesignateModel(String path) {
if (placesList == null) {
return;
}
setPlaceListModel(new DesignateRemotePlaceListModel(path));
}
private void setMultiPlaceListModel() {
if (placesList == null) {
return;
@ -1125,6 +1143,7 @@ public class FILEChooserPane extends BasicPane {
private abstract class AbstractPlaceListModel extends AbstractListModel<FILE> {
private static final long serialVersionUID = 8473695327688235386L;
protected List<FileFILE> filesOfSystem = new ArrayList<FileFILE>();
protected void processSystemFile() {
@ -1157,7 +1176,8 @@ public class FILEChooserPane extends BasicPane {
protected void setCD(final FILE lastDirectory) {
for (int i = 0; i < this.getSize(); i++) {
FILE file = this.getElementAt(i);
if (ComparatorUtils.equals(lastDirectory.prefix(), file.prefix())) {
//前缀相同不代表能用啊,比如说 repolets 和 resource ,都是 env下的,但就不该去显示resource下的文件呀
if (ComparatorUtils.equals(lastDirectory.prefix(), file.prefix()) && lastDirectory.getPath() != null && lastDirectory.getPath().startsWith(file.getPath())) {
setCurrentDirectory(lastDirectory);
return;
}
@ -1166,7 +1186,60 @@ public class FILEChooserPane extends BasicPane {
}
}
/**
* 一个简单的指定远程目录的 placelistmodel
*/
private class DesignateRemotePlaceListModel extends AbstractPlaceListModel {
private static final long serialVersionUID = -6340666958714469249L;
private FileNodeFILE envFILE;
public DesignateRemotePlaceListModel(String path) {
envFILE = new DesignateFileNodeFILE(new FileNode(path, true)) {
@Override
public String getName() {
return Toolkit.i18nText("Fine-Design_Basic_Utils_Report_Env_Directory_Designate");
}
};
}
@Override
public FILE getElementAt(int index) {
if (index < 1) {
return envFILE;
}
throw new IndexOutOfBoundsException();
}
@Override
public int getSize() {
return 1;
}
@Override
protected void setCD(FILE lastDirectory) {
setCurrentDirectory(envFILE);
}
/**
* 简单的重写了标签的FileNodeFILE
*/
private class DesignateFileNodeFILE extends FileNodeFILE {
public DesignateFileNodeFILE(FileNode node) {
super(node);
}
@Override
public Icon getIcon() {
return BaseUtils.readIcon("/com/fr/base/images/oem/logo.png");
}
}
}
private class PlaceListModel extends AbstractPlaceListModel {
private static final long serialVersionUID = 6138969918807381364L;
private FileNodeFILE envFILE;
private FileNodeFILE webReportFILE;
@ -1217,6 +1290,7 @@ public class FILEChooserPane extends BasicPane {
private class MultiLocalEnvPlaceListModel extends AbstractPlaceListModel {
private static final long serialVersionUID = 6300018896958532154L;
private List<FileFILE> envFiles = new ArrayList<FileFILE>();
private FileNodeFILE webReportFILE;

2
designer-base/src/main/java/com/fr/file/FILEFactory.java

@ -1,6 +1,5 @@
package com.fr.file;
import com.fr.base.FRContext;
import com.fr.design.file.NodeAuthProcessor;
import com.fr.file.filetree.FileNode;
import com.fr.workspace.WorkContext;
@ -10,6 +9,7 @@ public class FILEFactory {
public static final String FILE_PREFIX = "file://";
public static final String ENV_PREFIX = "env://";
public static final String WEBREPORT_PREFIX = "webreport://";
public static final String SEPARATOR = "/";
private FILEFactory() {
}

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

@ -31,6 +31,15 @@ public class ChooseFileFilter extends FileFilter implements FILEFilter, java.io.
this(extension, null);
}
public ChooseFileFilter(boolean noRestrict) {
if (noRestrict) {
this.filters = null;
this.fullDescription = FileExtension.ALL.getExtension();
} else {
this.filters = new ArrayList<>();
}
}
public ChooseFileFilter(String extension, String description) {
this();
if (extension != null) {
@ -314,4 +323,4 @@ public class ChooseFileFilter extends FileFilter implements FILEFilter, java.io.
return (o instanceof ChooseFileFilter)
&& ComparatorUtils.equals(((ChooseFileFilter) o).getDescription(), getDescription());
}
}
}

10
designer-base/src/main/resources/com/fr/design/images/edit/advancedEditor.svg

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="15px" height="15px" viewBox="0 0 15 15" 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="高级编辑" fill-rule="nonzero">
<path d="M13.8797,5.91875 C13.5781,5.91875 13.3328,6.16406 13.3328,6.46562 L13.3328,10.6375 L3.87502,10.6375 L3.87502,2.17188 L7.23596,2.17188 C7.53752,2.17188 7.78284,1.92656 7.78284,1.625 C7.78284,1.32344 7.53752,1.07812 7.23596,1.07812 L3.32815,1.07812 C3.02659,1.07812 2.78127,1.32344 2.78127,1.625 L2.78127,3.73594 L1.50159,3.73594 C1.20002,3.73594 0.954712,3.98125 0.954712,4.28281 L0.954712,13.5031 C0.954712,13.8047 1.20002,14.05 1.50159,14.05 L12.0547,14.05 C12.3563,14.05 12.6016,13.8047 12.6016,13.5031 L12.6016,11.7312 L13.8813,11.7312 C14.1828,11.7312 14.4282,11.4859 14.4282,11.1844 L14.4282,6.46562 C14.4266,6.16406 14.1813,5.91875 13.8797,5.91875 Z M11.5063,12.9578 L2.04846,12.9578 L2.04846,4.83125 L2.78127,4.83125 L2.78127,11.1844 C2.78127,11.4859 3.02659,11.7312 3.32815,11.7312 L11.5063,11.7312 L11.5063,12.9578 Z" id="形状" fill="#333334"></path>
<path d="M6.35444,5.79122 C6.34516,5.80296 6.33589,5.81533 6.33172,5.83022 L5.61566,8.44127 C5.57391,8.59329 5.61668,8.7571 5.72983,8.87257 C5.81446,8.9548 5.92597,9 6.04474,9 C6.08396,9 6.12326,8.99533 6.16194,8.98511 L8.76858,8.27801 C8.77277,8.27801 8.77479,8.28165 8.77794,8.28165 C8.80789,8.28165 8.83731,8.27081 8.85952,8.24823 L14.2794,2.80158 C14.4864,2.59539 14.6,2.31452 14.6,2.00894 C14.6,1.66268 14.4523,1.31656 14.1937,1.06006 L13.5355,0.40431 C13.2773,0.14713 12.9288,0 12.5808,0 C12.2736,0 11.9912,0.11295 11.7837,0.31861 L6.36482,5.76711 C6.35758,5.77373 6.35961,5.78352 6.35444,5.79122 Z M13.5974,2.12274 L12.905,2.81081 L11.7827,1.67681 L12.4652,0.99796 C12.573,0.89011 12.7822,0.90584 12.9061,1.02954 L13.5648,1.68529 C13.6335,1.75355 13.6727,1.84442 13.6727,1.93427 C13.6723,2.00792 13.6459,2.07475 13.5974,2.12274 Z M7.59405,5.90013 L11.0733,2.38229 L12.1962,3.51705 L8.72632,7.02506 L7.59405,5.90013 Z M6.67769,7.92832 L7.04115,6.60144 L8.01068,7.56581 L6.67769,7.92832 Z" id="形状" fill="#2F8EF1"></path>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.3 KiB

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

@ -1,19 +0,0 @@
<?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>

Before

Width:  |  Height:  |  Size: 1.5 KiB

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

@ -1,17 +0,0 @@
<?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>

Before

Width:  |  Height:  |  Size: 2.1 KiB

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

@ -1,41 +0,0 @@
<?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>

Before

Width:  |  Height:  |  Size: 3.3 KiB

1
designer-base/src/main/resources/com/fr/design/javascript/jsapi/category.json

@ -41,7 +41,6 @@
},
"Fine-Design_JSAPI_Form": {
"Fine-Design_JSAPI_Form_Component_Get": {},
"Fine-Design_JSAPI_Form_Component_Universal": {},
"Fine-Design_JSAPI_Form_Component_Tab": {}
}
}

8
designer-base/src/main/resources/com/fr/design/javascript/jsapi/images/connectFailed.svg

@ -0,0 +1,8 @@
<svg width="96" height="96" viewBox="0 0 96 96" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M47.5858 80.0834L56.4953 71.1738C51.5747 66.2532 43.5968 66.2532 38.6762 71.1738L47.5858 80.0834Z" fill="#D6D6D9"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M72.3345 55.3345C58.6662 41.6661 36.5054 41.6661 22.837 55.3345L29.7667 62.2641C39.6079 52.4229 55.5637 52.4229 65.4049 62.2641L72.3345 55.3345Z" fill="#E5E5E7"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M87.1838 40.4854C65.3144 18.616 29.8572 18.616 7.98779 40.4854L14.9174 47.415C32.9597 29.3728 62.2119 29.3728 80.2541 47.415L87.1838 40.4854Z" fill="#E8E8E8"/>
<circle cx="68.5" cy="66.5" r="17.5" fill="#F5F5F7"/>
<circle cx="68.5" cy="66.5" r="14.5" fill="#D6D6D9"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M74.5104 62.6107C75.0962 62.0249 75.0962 61.0752 74.5104 60.4894C73.9246 59.9036 72.9749 59.9036 72.3891 60.4894L68.5 64.3785L64.6109 60.4894C64.0251 59.9036 63.0754 59.9036 62.4896 60.4894C61.9038 61.0752 61.9038 62.0249 62.4896 62.6107L66.3787 66.4998L62.4896 70.3889C61.9038 70.9747 61.9038 71.9244 62.4896 72.5102C63.0754 73.096 64.0251 73.096 64.6109 72.5102L68.5 68.6211L72.3891 72.5102C72.9749 73.096 73.9246 73.096 74.5104 72.5102C75.0962 71.9244 75.0962 70.9747 74.5104 70.3889L70.6213 66.4998L74.5104 62.6107Z" fill="white"/>
</svg>

After

Width:  |  Height:  |  Size: 1.3 KiB

2
designer-base/src/main/resources/com/fr/design/javascript/jsapi/jsapi.json

@ -29,5 +29,5 @@
"importExcel_Append", "importExcel_Cover", "stash", "clear"],
"Fine-Design_JSAPI_Cpt_View_Preview_Report_Location":["centerReport"],
"Fine-Design_JSAPI_Form_Component_Get":["getAllWidgets"],
"Fine-Design_JSAPI_Form_Component_Tab":["showCardByIndex", "showCardByIndex", "getShowIndex", "setTitleVisible"]
"Fine-Design_JSAPI_Form_Component_Tab":["showCardByIndex", "getShowIndex", "setTitleVisible"]
}

50
designer-base/src/test/java/com/fr/design/mainframe/loghandler/DesignerLogHandlerTest.java

@ -0,0 +1,50 @@
package com.fr.design.mainframe.loghandler;
import org.junit.Assert;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* @author vito
* @version 10.0
* Created by vito on 2022/1/25
*/
public class DesignerLogHandlerTest {
@Test
public void findTplLink() {
Assert.assertArrayEquals(
new String[]{"(公式定位测试/单sheet2(1).cpt:0:A1)", "(公式定位测试/单sheet2(2).cpt:0:A1)"},
DesignerLogHandler.findTplLink("错误代码:11300310 公式计算错误:(公式定位测试/单sheet2(1).cpt:0:A1),出错公式(公式定位测试/单sheet2(2).cpt:0:A1),的飞机啊")
);
Assert.assertArrayEquals(
new String[]{"(公式定位测试/单sheet2(1).frm:0:A1)", "(公式定位测试/单sheet2(2).frm:0:A1)"},
DesignerLogHandler.findTplLink("错误代码:11300310 公式计算错误:(公式定位测试/单sheet2(1).frm:0:A1),出错公式(公式定位测试/单sheet2(2).frm:0:A1),的飞机啊")
);
Assert.assertArrayEquals(
new String[]{"(公式定位测试/单sheet2(1).cpt:0:A1)"},
DesignerLogHandler.findTplLink("错误代码:11300310 公式计算错误:(公式定位测试/单sheet2(1).cpt:0:A1)的飞机啊")
);
Assert.assertArrayEquals(
new String[]{"(公式定位测试/单sheet2(1).cpt:0:A1)"},
DesignerLogHandler.findTplLink("错误代码:11300310 公式(计算错误:(公式定位测试/单sheet2(1).cpt:0:A1)的飞机啊")
);
Assert.assertArrayEquals(
new String[]{"(公式定位测试/单sheet2(1).cpt:0:A1)"},
DesignerLogHandler.findTplLink("错误代码:11300310 公式)计算错误:(公式定位测试/单sheet2(1).cpt:0:A1)的飞机啊")
);
Assert.assertArrayEquals(
new String[]{"(公式定位测试/单sheet2(1).cpt:0:A1)"},
DesignerLogHandler.findTplLink("错误代码:11300310 公式计算错误:(公式定位测试/单sheet2(1).cpt:0:A1)的飞机)啊")
);
Assert.assertArrayEquals(
new String[]{"(公式定位测试/单sheet2(1).cpt:0:A1)"},
DesignerLogHandler.findTplLink("错误代码:11300310 公式计算错误:(公式定位测试/单sheet2(1).cpt:0:A1)的飞机(啊")
);
Assert.assertArrayEquals(
new String[]{"(公式定位测试/单sheet2(1).cpt:0:A1)"},
DesignerLogHandler.findTplLink("错误代码:11300310 公式(0fdasf)计算错误:(公式定位测试/单sheet2(1).cpt:0:A1)的飞机啊")
);
}
}

66
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChangeConfigPane.java

@ -10,7 +10,9 @@ import com.fr.chart.base.AttrChangeConfig;
import com.fr.chart.base.AttrChangeType;
import com.fr.chart.chartattr.Chart;
import com.fr.chart.chartattr.ChartCollection;
import com.fr.chart.chartattr.SwitchTitle;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.dialog.AttrScrollPane;
import com.fr.design.foldablepane.UIExpandablePane;
import com.fr.design.formula.TinyFormulaPane;
import com.fr.design.gui.ibutton.UIButtonGroup;
@ -22,6 +24,7 @@ import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPane;
import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils;
import com.fr.van.chart.designer.TableLayout4VanChartHelper;
import javax.swing.BorderFactory;
@ -77,11 +80,26 @@ public class ChangeConfigPane extends BasicBeanPane<ChartCollection> {
private int selectedChart; // 设置面板里面选取的图表,不是真正切换的图表
public ChangeConfigPane(){
init();
this.setLayout(new BorderLayout());
this.setBorder(BorderFactory.createEmptyBorder(10, 15, 10, 15));
this.add(createScrollPane(), BorderLayout.CENTER);
}
private JPanel createScrollPane() {
return new AttrScrollPane() {
@Override
protected JPanel createContentPane() {
return contentPane;
}
};
}
private void init() {
initButtonGroup();
configPane = createConfigPane();
contentPane = createContentPane();
contentPane.setBorder(BorderFactory.createEmptyBorder(CONSTANT_TEN, CONSTANT_THIRTY, CONSTANT_TEN, CONSTANT_THIRTY));
this.add(contentPane, BorderLayout.CENTER);
}
private JPanel createContentPane() {
@ -172,19 +190,20 @@ public class ChangeConfigPane extends BasicBeanPane<ChartCollection> {
chartTypesPane = new JPanel();
chartTypesPane.setLayout(new BoxLayout(chartTypesPane, BoxLayout.Y_AXIS));
chartTypesPane.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0));
switchTitlePane.setLayout(new CardLayout());
buttonContentPane.add(chartTypesPane, BorderLayout.NORTH);
buttonContentPane.add(
TableLayout4VanChartHelper.createGapTableLayoutPane(
Toolkit.i18nText("Fine-Design_Chart_Switch_Title_Label"),
switchTitlePane,
EDIT_AREA_WIDTH
),
BorderLayout.CENTER
JPanel titleEditPane = TableLayout4VanChartHelper.createGapTableLayoutPane(
Toolkit.i18nText("Fine-Design_Chart_Switch_Title_Label"),
switchTitlePane,
EDIT_AREA_WIDTH
);
titleEditPane.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 0));
buttonContentPane.add(chartTypesPane, BorderLayout.NORTH);
buttonContentPane.add(titleEditPane, BorderLayout.CENTER);
UIExpandablePane expandablePane = new UIExpandablePane(Toolkit.i18nText("Fine-Design_Chart_Button_Content"), 20, buttonContentPane) {
UIExpandablePane expandablePane = new UIExpandablePane(Toolkit.i18nText("Fine-Design_Chart_Button_And_Rotation_Content"), 20, buttonContentPane) {
protected void setcontentPanelontentPanelBorder() {
}
@ -212,6 +231,7 @@ public class ChangeConfigPane extends BasicBeanPane<ChartCollection> {
populateSwitchTitlePane(i, collection);
}
showSwitchTitleCard(collection.getChartName(select));
chartTypesPane.revalidate();
switchTitlePane.revalidate();
selectedChart = select;
@ -219,18 +239,16 @@ public class ChangeConfigPane extends BasicBeanPane<ChartCollection> {
private void populateSwitchTitlePane(int chartIndex, ChartCollection collection) {
Chart chart = collection.getChart(chartIndex, Chart.class);
Object switchTitle = chart.getSwitchTitle();
String result;
if (switchTitle != null) {
if (switchTitle instanceof BaseFormula) {
result = ((BaseFormula) switchTitle).getContent();
SwitchTitle switchTitle = chart.getSwitchTitle();
Object content = switchTitle.getContent();
String result = StringUtils.EMPTY;
if (content != null) {
if (content instanceof BaseFormula) {
result = ((BaseFormula) content).getContent();
} else {
result = Utils.objectToString(switchTitle);
result = Utils.objectToString(content);
}
} else {
result = collection.getChartName(chartIndex);
}
TinyFormulaPane title = new TinyFormulaPane();
title.populateBean(result);
switchTitles.add(title);
@ -329,7 +347,7 @@ public class ChangeConfigPane extends BasicBeanPane<ChartCollection> {
} else {
titleObj = titleString;
}
collection.getChart(i, Chart.class).setSwitchTitle(titleObj);
collection.getChart(i, Chart.class).setSwitchTitle(new SwitchTitle(titleObj));
}
}
@ -357,8 +375,7 @@ public class ChangeConfigPane extends BasicBeanPane<ChartCollection> {
@Override
public void mouseClicked(MouseEvent e) {
resetChangeChartButtons();
CardLayout cardLayout = (CardLayout) switchTitlePane.getLayout();
cardLayout.show(switchTitlePane, collection.getChartName(buttonIndex));
showSwitchTitleCard(collection.getChartName(buttonIndex));
ChangeChartButton.this.setSelected(true);
selectedChart = buttonIndex;
}
@ -375,4 +392,9 @@ public class ChangeConfigPane extends BasicBeanPane<ChartCollection> {
changeChartButton.setSelected(false);
}
}
private void showSwitchTitleCard(String chartName) {
CardLayout cardLayout = (CardLayout) switchTitlePane.getLayout();
cardLayout.show(switchTitlePane, chartName);
}
}

9
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/report/CategoryPlotMoreCateReportDataContentPane.java

@ -19,14 +19,14 @@ import com.fr.van.chart.designer.TableLayout4VanChartHelper;
import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.JPanel;
import java.util.ArrayList;
import java.util.List;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.List;
/**
@ -40,7 +40,7 @@ public class CategoryPlotMoreCateReportDataContentPane extends CategoryPlotRepor
private JPanel boxPane;
private UIButton addButton;
private ArrayList<TinyFormulaPane> formualList = new ArrayList<TinyFormulaPane>();
private List<TinyFormulaPane> formualList = new ArrayList<TinyFormulaPane>();
private UIObserverListener uiobListener = null;
public List<TinyFormulaPane> getFormualList() {
@ -190,10 +190,9 @@ public class CategoryPlotMoreCateReportDataContentPane extends CategoryPlotRepor
Plot plot = collection.getSelectedChart().getPlot();
if (definition instanceof NormalReportDataDefinition) {
NormalReportDataDefinition reportDefinition = (NormalReportDataDefinition) definition;
reportDefinition.clearMoreCate();
updateMoreCate(reportDefinition, plot);
collection.updateAxisCategoryStyles();
}
}

14
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/CategoryPlotMoreCateTableDataContentPane.java

@ -15,9 +15,13 @@ import com.fr.design.gui.ilable.UILabel;
import com.fr.design.mainframe.chart.gui.ChartDataPane;
import com.fr.design.utils.gui.GUICoreUtils;
import javax.swing.*;
import java.awt.*;
import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
@ -39,7 +43,7 @@ public class CategoryPlotMoreCateTableDataContentPane extends CategoryPlotTableD
private JPanel boxPane;
private ArrayList<UIComboBox> boxList = new ArrayList<UIComboBox>();
private List<UIComboBox> boxList = new ArrayList<UIComboBox>();
private UIButton addButton;
private UIObserverListener uiobListener = null;
@ -242,6 +246,7 @@ public class CategoryPlotMoreCateTableDataContentPane extends CategoryPlotTableD
normal.clearMoreCate();
updateMoreCate(normal, plot);
}
collection.updateAxisCategoryStyles();
}
protected void updateMoreCate(NormalTableDataDefinition normal, Plot plot) {
@ -252,5 +257,4 @@ public class CategoryPlotMoreCateTableDataContentPane extends CategoryPlotTableD
}
}
}
}

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

@ -54,7 +54,7 @@ public class VanChartCustomAxisPane extends BasicScrollPane<Chart> {
}
if(axisPane != null) {
axisPane.populateBean((VanChartCustomPlot) chart.getPlot());
axisPane.populateBean((VanChart) chart);
}
}

10
designer-chart/src/main/java/com/fr/van/chart/custom/style/VanChartCustomAxisTabPane.java

@ -87,11 +87,16 @@ public class VanChartCustomAxisTabPane extends VanChartCustomPlotTabPane<VanChar
}
@Override
public void populateBean(VanChartCustomPlot plot) {
}
/**
* 标准坐标轴属性存在最外层的customPlot的坐标轴变量中
* 不使用标准坐标轴的坐标轴属性存在相应的plot中的坐标轴变量中
*/
public void populateBean(VanChartCustomPlot plot) {
public void populateBean(VanChart chart) {
VanChartCustomPlot plot = (VanChartCustomPlot) chart.getPlot();
List<VanChartPlot> customPlotList = plot.getCustomPlotList();
ArrayList<Integer> plotOrder = plot.getDiffAxisOrder();
@ -100,12 +105,13 @@ public class VanChartCustomAxisTabPane extends VanChartCustomPlotTabPane<VanChar
//先更新标准坐标轴界面
//获取相应点的属性,并更新界面
VanChartPlot vanChartPlot = customPlotList.get(plotOrder.get(i));
((VanChartAxisPane)paneList.get(i)).setChart(chart);
((VanChartAxisPane)paneList.get(i)).populateBean(vanChartPlot);
}
if (plot.isHaveStandardAxis()){
((VanChartAxisPane)paneList.get(paneList.size() - 1)).setChart(chart);
((VanChartAxisPane)paneList.get(paneList.size() - 1)).populateBean(plot);
}
}

117
designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartGanttTimeLinePane.java

@ -0,0 +1,117 @@
package com.fr.van.chart.designer.component;
import com.fr.chart.chartattr.Plot;
import com.fr.design.gui.frpane.UINumberDragPaneWithPercent;
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.mainframe.chart.gui.ColorSelectBoxWithOutTransparent;
import com.fr.plugin.chart.gantt.VanChartGanttPlot;
import com.fr.van.chart.designer.TableLayout4VanChartHelper;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
public class VanChartGanttTimeLinePane extends JPanel {
private UIButtonGroup<String> switchButton;
private ColorSelectBoxWithOutTransparent colorSelect;
private UINumberDragPaneWithPercent opacity;
private JPanel centerPane;
public VanChartGanttTimeLinePane() {
this.setLayout(new BorderLayout());
this.add(createSwitchButtonPane(), BorderLayout.NORTH);
this.add(createCenterPane(), BorderLayout.CENTER);
}
private JPanel createSwitchButtonPane() {
double[] columnSize = {TableLayout.PREFERRED, TableLayout.FILL};
double[] rowSize = {TableLayout.PREFERRED, TableLayout.PREFERRED};
String[] array = new String[]{Toolkit.i18nText("Fine-Design_Chart_Guide_Line_Not_Show"), Toolkit.i18nText("Fine-Design_Chart_Guide_Line_Show")};
switchButton = new UIButtonGroup<>(array);
switchButton.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
setCenterPaneVisibility();
}
});
UILabel text = new UILabel(Toolkit.i18nText("Fine-Design_Chart_Guide_Line_Current_Line"), SwingConstants.LEFT);
return TableLayout4VanChartHelper.createGapTableLayoutPane(new Component[][] {
new Component[]{null, null},
new Component[] {text, switchButton}
}, rowSize, columnSize);
}
private JPanel createCenterPane() {
double[] columnSize = {TableLayout.FILL, TableLayout4VanChartHelper.EDIT_AREA_WIDTH};
double[] rowSize = {TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED};
colorSelect = new ColorSelectBoxWithOutTransparent(100);
opacity = new UINumberDragPaneWithPercent(0, 100);
centerPane = TableLayout4VanChartHelper.createGapTableLayoutPane(new Component[][] {
new Component[]{null, null},
new Component[] {new UILabel(Toolkit.i18nText("Fine-Design_Chart_Color")), colorSelect},
new Component[] {new UILabel(Toolkit.i18nText("Fine-Design_Report_Alpha")), opacity}
}, rowSize, columnSize);
centerPane.setVisible(false);
return centerPane;
}
public void populateBean(Plot plot) {
if (plot instanceof VanChartGanttPlot) {
VanChartGanttPlot ganttPlot = (VanChartGanttPlot) plot;
setShowTimeLine(ganttPlot.isShowTimeLine());
setTimeLineColor(ganttPlot.getTimeLineColor());
setTimeLineOpacity(ganttPlot.getTimeLineOpacity());
centerPane.setVisible(ganttPlot.isShowTimeLine());
}
}
public void updateBean(Plot plot) {
if (plot instanceof VanChartGanttPlot) {
VanChartGanttPlot ganttPlot = (VanChartGanttPlot) plot;
ganttPlot.setShowTimeLine(isShowTimeLine());
ganttPlot.setTimeLineColor(getTimeLineColor());
ganttPlot.setTimeLineOpacity(getTimeLineOpacity());
}
}
private void setCenterPaneVisibility() {
centerPane.setVisible(switchButton.getSelectedIndex() == 1);
}
public boolean isShowTimeLine() {
return switchButton.getSelectedIndex() == 1;
}
public void setShowTimeLine(boolean showTimeLine) {
switchButton.setSelectedIndex(showTimeLine ? 1 : 0);
}
public Color getTimeLineColor() {
return colorSelect.getSelectObject();
}
public void setTimeLineColor(Color timeLineColor) {
colorSelect.setSelectObject(timeLineColor);
}
public double getTimeLineOpacity() {
return opacity.updateBean();
}
public void setTimeLineOpacity(double timeLineOpacity) {
opacity.populateBean(timeLineOpacity);
}
}

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

@ -1,4 +0,0 @@
package com.fr.van.chart.designer.component;
public class VanChartGuideLinesPane {
}

10
designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartAxisPane.java

@ -1,5 +1,6 @@
package com.fr.van.chart.designer.style.axis;
import com.fr.chart.chartattr.Chart;
import com.fr.chart.chartattr.Plot;
import com.fr.chart.chartglyph.ConditionAttr;
import com.fr.chart.chartglyph.ConditionCollection;
@ -41,6 +42,7 @@ public class VanChartAxisPane extends BasicBeanPane<VanChart> {
protected VanChartAxisPlot editingPlot;
protected VanChartStylePane parent;
private Chart chart;
public VanChartAxisPane(VanChartAxisPlot plot, VanChartStylePane parent){
this.editingPlot = plot;
@ -188,6 +190,7 @@ public class VanChartAxisPane extends BasicBeanPane<VanChart> {
if(chart == null){
return;
}
this.chart = chart;
Plot plot = chart.getPlot();
populateBean(plot);
@ -208,10 +211,12 @@ public class VanChartAxisPane extends BasicBeanPane<VanChart> {
}
for(VanChartAxis axis : editingPlot.getXAxisList()){
axis.setChart(chart);
VanChartXYAxisPaneInterface axisPane = xAxisPaneMap.get(axis.getAxisName());
axisPane.populate(axis);
}
for(VanChartAxis axis : editingPlot.getYAxisList()){
axis.setChart(chart);
VanChartXYAxisPaneInterface axisPane = yAxisPaneMap.get(axis.getAxisName());
axisPane.populate(axis);
}
@ -237,6 +242,7 @@ public class VanChartAxisPane extends BasicBeanPane<VanChart> {
if(chart == null){
return;
}
this.chart = chart;
Plot plot = chart.getPlot();
@ -281,4 +287,8 @@ public class VanChartAxisPane extends BasicBeanPane<VanChart> {
public VanChart updateBean() {
return null;
}
public void setChart(Chart chart) {
this.chart = chart;
}
}

30
designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartAxisPaneHelper.java

@ -0,0 +1,30 @@
package com.fr.van.chart.designer.style.axis;
import com.fr.design.layout.TableLayout;
import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPane;
import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPaneWithThemeStyle;
import com.fr.design.mainframe.chart.mode.ChartEditContext;
import com.fr.van.chart.designer.TableLayout4VanChartHelper;
import javax.swing.JPanel;
public class VanChartAxisPaneHelper {
public static ChartTextAttrPane createAxisTextAttrPane() {
return ChartEditContext.supportTheme() ? new ChartTextAttrPaneWithThemeStyle() {
protected double getEdithAreaWidth() {
return TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH;
}
} : new ChartTextAttrPane() {
@Override
protected JPanel getContentPane(JPanel buttonPane) {
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double e = TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH;
double[] columnSize = {f, e};
double[] rowSize = {p, p, p};
return TableLayout4VanChartHelper.createGapTableLayoutPane(getComponents(buttonPane), rowSize, columnSize);
}
};
}
}

166
designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartAxisStyleSettingPane.java

@ -0,0 +1,166 @@
package com.fr.van.chart.designer.style.axis;
import com.fr.base.BaseFormula;
import com.fr.chart.base.TextAttr;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.gui.frpane.UINumberDragPane;
import com.fr.design.gui.ibutton.UIButtonGroup;
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.TableLayout;
import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPane;
import com.fr.design.utils.gui.UIComponentUtils;
import com.fr.design.widget.FRWidgetFactory;
import com.fr.plugin.chart.attr.axis.VanChartAxisLabelStyle;
import com.fr.van.chart.designer.TableLayout4VanChartHelper;
import com.fr.van.chart.designer.style.axis.component.AxisLabelDisplayComboBox;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class VanChartAxisStyleSettingPane extends BasicBeanPane<VanChartAxisLabelStyle> {
private static final double ROTATION_MAX = 90.0;
private AxisLabelDisplayComboBox labelDisplayComboBox;
private JPanel labelDisplayPane;
private ChartTextAttrPane labelTextAttrPane;
private UINumberDragPane labelTextRotation;
private UIButtonGroup<Integer> labelGapStyle;
private UITextField labelGapValue;
private JPanel labelGapPane;
private JPanel labelGapValuePane;
private JPanel contentPane;
private boolean showLabelDisplayPane = true;
public VanChartAxisStyleSettingPane(boolean showLabelDisplayPane, ChartTextAttrPane textAttrPane) {
this.showLabelDisplayPane = showLabelDisplayPane;
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double s = TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH;
double[] column = {f, s};
double[] row = {p, p, p};
labelDisplayComboBox = new AxisLabelDisplayComboBox();
labelDisplayPane = TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Chart_Axis_Label_Show"), labelDisplayComboBox, TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH);
labelDisplayPane.setVisible(showLabelDisplayPane);
labelTextAttrPane = textAttrPane;
labelTextRotation = new UINumberDragPane(-ROTATION_MAX, ROTATION_MAX);
labelGapStyle = new UIButtonGroup<>(new String[]{Toolkit.i18nText("Fine-Design_Chart_Automatic"), Toolkit.i18nText("Fine-Design_Chart_Fixed")});
labelGapValue = new UITextField();
labelGapPane = createLabelGapPane(row, column);
this.setLayout(new BorderLayout());
contentPane = new JPanel(new BorderLayout());
contentPane.add(labelDisplayPane, BorderLayout.NORTH);
contentPane.add(labelTextAttrPane, BorderLayout.CENTER);
contentPane.add(labelGapPane, BorderLayout.SOUTH);
this.add(contentPane, BorderLayout.NORTH);
initListner();
}
public VanChartAxisStyleSettingPane(ChartTextAttrPane textAttrPane) {
this(true, textAttrPane);
}
@Override
public Dimension getPreferredSize() {
Dimension defaultSize = super.getPreferredSize();
return new Dimension(defaultSize.width, contentPane.getPreferredSize().height);
}
private void initListner() {
labelDisplayComboBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
checkLabelGapPane();
}
});
labelGapStyle.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
checkLabelGapValuePane();
}
});
}
private void checkLabelGapPane() {
if (labelGapPane != null) {
boolean visible = true;
if (showLabelDisplayPane && labelDisplayPane != null && labelDisplayComboBox != null) {
visible = labelDisplayComboBox.getSelectedIndex() == 0;
}
labelGapPane.setVisible(visible);
}
}
private void checkLabelGapValuePane() {
if (labelGapValuePane != null && labelGapStyle != null) {
labelGapValuePane.setVisible(labelGapStyle.getSelectedIndex() == 1);
}
}
@Override
public void populateBean(VanChartAxisLabelStyle style) {
labelDisplayComboBox.populateBean(style.getLabelDisplay());
labelTextAttrPane.populate(style.getTextAttr());
labelTextRotation.populateBean((double) style.getTextAttr().getRotation());
labelGapStyle.setSelectedIndex(style.isAutoLabelGap() ? 0 : 1);
labelGapValue.setText(style.getLabelIntervalNumber().getContent());
checkLabelGapPane();
checkLabelGapValuePane();
}
@Override
public VanChartAxisLabelStyle updateBean() {
VanChartAxisLabelStyle style = new VanChartAxisLabelStyle();
style.setLabelDisplay(labelDisplayComboBox.updateBean());
TextAttr textAttr = style.getTextAttr();
labelTextAttrPane.update(textAttr);
textAttr.setRotation(labelTextRotation.updateBean().intValue());
style.setTextAttr(textAttr);
style.setAutoLabelGap(labelGapStyle.getSelectedIndex() == 0);
if (style.isAutoLabelGap()) {
style.setLabelIntervalNumber(BaseFormula.createFormulaBuilder().build("0"));
} else {
style.setLabelIntervalNumber(BaseFormula.createFormulaBuilder().build(labelGapValue.getText()));
}
return style;
}
@Override
protected String title4PopupWindow() {
return null;
}
private JPanel createLabelGapPane(double[] row, double[] col) {
Component[][] gapComponents = new Component[][]{
new Component[]{null, null},
new Component[]{
FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Chart_TextRotation")),
UIComponentUtils.wrapWithBorderLayoutPane(labelTextRotation)
},
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Label_Interval")), labelGapStyle}
};
JPanel gapDetailPane = TableLayout4VanChartHelper.createGapTableLayoutPane(gapComponents, row, col);
labelGapValuePane = TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText(""), labelGapValue, TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH);
JPanel panel = new JPanel(new BorderLayout());
panel.add(gapDetailPane, BorderLayout.CENTER);
panel.add(labelGapValuePane, BorderLayout.SOUTH);
return panel;
}
}

507
designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartBaseAxisPane.java

@ -3,7 +3,9 @@ package com.fr.van.chart.designer.style.axis;
import com.fr.base.BaseFormula;
import com.fr.base.BaseUtils;
import com.fr.base.Utils;
import com.fr.base.chart.chartdata.TopDefinitionProvider;
import com.fr.chart.base.TextAttr;
import com.fr.chart.chartattr.Chart;
import com.fr.chart.chartattr.Title;
import com.fr.design.beans.FurtherBasicBeanPane;
import com.fr.design.formula.TinyFormulaPane;
@ -13,30 +15,27 @@ import com.fr.design.gui.ibutton.UIButtonGroup;
import com.fr.design.gui.ibutton.UIToggleButton;
import com.fr.design.gui.icombobox.LineComboBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.gui.style.FormatPane;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.chart.PaneTitleConstants;
import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPane;
import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPaneWithThemeStyle;
import com.fr.design.mainframe.chart.gui.style.ColorSelectBoxWithThemeStyle;
import com.fr.design.mainframe.chart.mode.ChartEditContext;
import com.fr.design.utils.gui.UIComponentUtils;
import com.fr.design.widget.FRWidgetFactory;
import com.fr.plugin.chart.attr.axis.VanChartAxis;
import com.fr.plugin.chart.attr.axis.VanChartAxisLabelStyle;
import com.fr.plugin.chart.base.OverlapHandleType;
import com.fr.plugin.chart.base.VanChartConstants;
import com.fr.plugin.chart.type.AxisTickLineType;
import com.fr.stable.Constants;
import com.fr.stable.CoreConstants;
import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils;
import com.fr.van.chart.designer.TableLayout4VanChartHelper;
import com.fr.van.chart.designer.component.VanChartHtmlLabelPane;
import com.fr.van.chart.designer.style.VanChartStylePane;
import com.fr.van.chart.designer.style.axis.component.AxisLabelDisplayComboBox;
import com.fr.van.chart.designer.style.axis.component.VanChartCategoryStylePaneWithCheckBox;
import javax.swing.BorderFactory;
import javax.swing.Icon;
@ -47,16 +46,21 @@ import javax.swing.event.ChangeListener;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.List;
/**
* 坐标轴的基础配置项分类时间值等公共的部分
*/
public class VanChartBaseAxisPane extends FurtherBasicBeanPane<VanChartAxis> {
private static final long serialVersionUID = -5717246802333308973L;
private static final double ROTATION_MAX = 90.0;
private static final String WHOLE_DISPLAY = "wholeDisplay"; // 整体显示
private static final String LAYER_DISPLAY = "layerDisplay"; // 分层显示
protected UIButtonGroup showTitle;
protected TinyFormulaPane titleContent;
protected UIButtonGroup<Integer> titleAlignPane;
@ -66,24 +70,19 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane<VanChartAxis> {
protected JPanel titlePane;
protected UIButtonGroup showLabel;
protected ChartTextAttrPane labelTextAttrPane;
protected UINumberDragPane labelTextRotation;
private AxisLabelDisplayComboBox labelDisplayComboBox;
//轴标签缩略间隔显示 恢复用注释。下面6行删除。
protected UITextField labelGapValue;
protected UIButtonGroup showLogic;
private UIButtonGroup<OverlapHandleType> overlapHandleTypeGroup;
protected UIButtonGroup<Integer> labelGapStyle;
//轴标签缩略间隔显示 恢复用注释。取消注释。
//protected UISpinner labelGapValue;
protected JPanel labelPanel;
private JPanel labelGapPane;
private JPanel labelGapStylePane;
private JPanel labelGapValuePane;
private JPanel labelDisplayPane;
protected JPanel labelContentPane;
private VanChartAxisStyleSettingPane labelPane;
private JPanel showLogicPane;
private JPanel labelStylePane;
private JPanel categoryStylePane;
private VanChartAxisStyleSettingPane wholeDisplayLabelPanel;
private List<VanChartCategoryStylePaneWithCheckBox> categoryStyles = new ArrayList<>();
protected LineComboBox axisLineStyle;
@ -107,6 +106,8 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane<VanChartAxis> {
protected JPanel centerPane;
private VanChartHtmlLabelPane htmlLabelPane;
private VanChartStylePane parent;
public VanChartBaseAxisPane() {
this(true);
}
@ -117,6 +118,7 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane<VanChartAxis> {
}
public void setParentPane(VanChartStylePane parent) {
this.parent = parent;
htmlLabelPane.setParent(parent);
}
@ -214,189 +216,102 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane<VanChartAxis> {
protected JPanel createLabelPane(double[] row, double[] col) {
initLabelComponents();
labelGapPane = createLabelGapPane(row, col);
labelPanel = createLabelDetailPanel();
labelPane = new VanChartAxisStyleSettingPane(showLabelDisplay(), getChartTextAttrPane());
wholeDisplayLabelPanel = new VanChartAxisStyleSettingPane(showLabelDisplay(), getChartTextAttrPane());
wholeDisplayLabelPanel.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 10));
addComponentsListener();
JPanel showLabelPane = TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Chart_Axis_Label"), showLabel);
JPanel labelContentPane = createLabelContentPane();
JPanel labelPane = new JPanel(new BorderLayout());
labelPane.add(showLabelPane, BorderLayout.NORTH);
labelPane.add(labelPanel, BorderLayout.CENTER);
labelPane.add(labelContentPane, BorderLayout.CENTER);
return TableLayout4VanChartHelper.createExpandablePaneWithTitle(PaneTitleConstants.CHART_STYLE_LABEL_TITLE, labelPane);
}
private void initLabelComponents() {
showLabel = new UIButtonGroup(new String[]{Toolkit.i18nText("Fine-Design_Chart_Use_Show"), Toolkit.i18nText("Fine-Design_Chart_Hidden")});
labelDisplayComboBox = new AxisLabelDisplayComboBox();
labelDisplayPane = TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Chart_Axis_Label_Show"), labelDisplayComboBox, TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH);
labelDisplayPane.setVisible(showLabelDisplay());
labelTextAttrPane = getChartTextAttrPane();
labelTextRotation = new UINumberDragPane(-ROTATION_MAX, ROTATION_MAX);
labelGapStyle = new UIButtonGroup<>(new String[]{Toolkit.i18nText("Fine-Design_Chart_Automatic"), Toolkit.i18nText("Fine-Design_Chart_Fixed")});
labelGapValue = new UITextField();
}
private JPanel createLabelGapPane(double[] row, double[] col) {
Component[][] gapComponents = new Component[][]{
new Component[]{null, null},
new Component[]{
FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Chart_TextRotation")),
UIComponentUtils.wrapWithBorderLayoutPane(labelTextRotation)
},
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Label_Interval")), labelGapStyle}
};
JPanel gapDetailPane = TableLayout4VanChartHelper.createGapTableLayoutPane(gapComponents, row, col);
labelGapValuePane = TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText(""), labelGapValue, TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH);
JPanel panel = new JPanel(new BorderLayout());
panel.add(gapDetailPane, BorderLayout.CENTER);
panel.add(labelGapValuePane, BorderLayout.SOUTH);
return panel;
}
private JPanel createLabelDetailPanel() {
JPanel panel = new JPanel(new BorderLayout());
panel.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 0));
panel.add(labelDisplayPane, BorderLayout.NORTH);
panel.add(labelTextAttrPane, BorderLayout.CENTER);
panel.add(labelGapPane, BorderLayout.SOUTH);
return panel;
showLogic = new UIButtonGroup(new String[]{Toolkit.i18nText("Fine-Design_Chart_Axis_Style_Whole_Display"), Toolkit.i18nText("Fine-Design_Chart_Axis_Style_Layer_Display")});
initButtonGroupListener();
}
private void addComponentsListener() {
// 显示/隐藏
showLabel.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
checkLabelPane();
}
});
// 间隔/缩略/换行
labelDisplayComboBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
checkLabelGapPane();
}
});
// 自动/固定
labelGapStyle.addActionListener(new ActionListener() {
private void initButtonGroupListener() {
showLogic.addChangeListener(new ChangeListener() {
@Override
public void actionPerformed(ActionEvent e) {
checkLabelGapValuePane();
public void stateChanged(ChangeEvent e) {
showLabelStyleCard();
}
});
}
// protected JPanel createLabelPane(double[] row, double[] col){
// double p = TableLayout.PREFERRED;
// showLabel = new UIButtonGroup(new String[]{Toolkit.i18nText("Fine-Design_Chart_Use_Show"), Toolkit.i18nText("Fine-Design_Chart_Hidden")});
// labelTextAttrPane = getChartTextAttrPane();
//
// JPanel rotationPane = createLabelRotationPane(col);
// JPanel overlapPane = createLabelOverlapPane();
//
//
// Component[][] components = new Component[][]{
// new Component[]{labelTextAttrPane, null},
// new Component[]{rotationPane, null},
// new Component[]{overlapPane, null},
// };
//
// JPanel showLabelPane = TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Chart_Axis_Label"),showLabel);
// labelPanel = TableLayout4VanChartHelper.createGapTableLayoutPane(components, new double[]{p, p, p}, col);
// labelPanel.setBorder(BorderFactory.createEmptyBorder(0,10,0,0));
// showLabel.addActionListener(new ActionListener() {
// @Override
// public void actionPerformed(ActionEvent e) {
// checkLabelPane();
// }
// });
// JPanel jPanel = new JPanel(new BorderLayout());
// jPanel.add(showLabelPane, BorderLayout.NORTH);
// jPanel.add(labelPanel, BorderLayout.CENTER);
// return TableLayout4VanChartHelper.createExpandablePaneWithTitle(PaneTitleConstants.CHART_STYLE_LABEL_TITLE, jPanel);
// }
private JPanel createLabelRotationPane(double[] col) {
labelTextRotation = new UINumberDragPane(-ROTATION_MAX, ROTATION_MAX);
Component[][] gapComponents = new Component[][]{
new Component[]{
FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Chart_TextRotation")),
UIComponentUtils.wrapWithBorderLayoutPane(labelTextRotation)
}
};
return TableLayout4VanChartHelper.createGapTableLayoutPane(gapComponents, new double[]{TableLayout.PREFERRED}, col);
private void showLabelStyleCard() {
CardLayout layout = (CardLayout) labelStylePane.getLayout();
if (showLogic.getSelectedIndex() == 0) {
layout.show(labelStylePane, WHOLE_DISPLAY);
} else {
layout.show(labelStylePane, LAYER_DISPLAY);
}
labelStylePane.revalidate();
}
private JPanel createLabelOverlapPane() {
labelGapStyle = new UIButtonGroup<Integer>(new String[]{Toolkit.i18nText("Fine-Design_Chart_Automatic"), Toolkit.i18nText("Fine-Design_Chart_Fixed")});
labelGapStylePane = TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Chart_Label_Interval"), labelGapStyle, TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH);
//轴标签缩略间隔显示 恢复用注释。取消注释。
//labelGapValue = new UISpinner(0, Integer.MAX_VALUE, 1, 1);
labelGapValuePane = TableLayout4VanChartHelper.createGapTableLayoutPane(StringUtils.EMPTY, labelGapValue, TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH);
JPanel panel = new JPanel(new BorderLayout(0, 0));
addOverlapGroupButton(panel);
panel.add(labelGapStylePane, BorderLayout.CENTER);
panel.add(labelGapValuePane, BorderLayout.SOUTH);
labelGapStyle.addActionListener(new ActionListener() {
/**
* 创建显示逻辑以及其下面面板
*
* @return
*/
private JPanel createLabelContentPane() {
labelContentPane = new JPanel(new BorderLayout());
showLogicPane = new JPanel(new BorderLayout());
labelStylePane = new JPanel(new CardLayout()) {
@Override
public void actionPerformed(ActionEvent e) {
checkLabelGapValuePane();
public Dimension getPreferredSize() {
switch (showLogic.getSelectedIndex()) {
case 0:
return wholeDisplayLabelPanel.getPreferredSize();
case 1:
return categoryStylePane.getPreferredSize();
case -1:
default:
return super.getPreferredSize();
}
}
});
return panel;
};
labelStylePane.add(wholeDisplayLabelPanel, WHOLE_DISPLAY);
labelStylePane.add(createCategoryStylePane(), LAYER_DISPLAY);
showLogicPane.add(TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Chart_Axis_Label_Show_Logic"), showLogic), BorderLayout.NORTH);
showLogicPane.add(labelStylePane, BorderLayout.CENTER);
showLogicPane.setVisible(false);
labelContentPane.add(labelPane, BorderLayout.NORTH);
labelContentPane.add(showLogicPane, BorderLayout.CENTER);
return labelContentPane;
}
protected void addOverlapGroupButton(JPanel panel) {
overlapHandleTypeGroup = new UIButtonGroup<OverlapHandleType>(new String[]{Toolkit.i18nText("Fine-Design_Chart_Label_OverlapAbbreviate"), Toolkit.i18nText("Fine-Design_Chart_Label_OverlapInterval")},
new OverlapHandleType[]{OverlapHandleType.ABBREVIATE, OverlapHandleType.INTERVAL});
JPanel north = TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Chart_Label_WhenOverlap"), overlapHandleTypeGroup, TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH);
panel.add(north, BorderLayout.NORTH);
/**
* 创建多分类轴标签设置面板
*
* @return
*/
private JPanel createCategoryStylePane() {
categoryStylePane = new JPanel(new BorderLayout());
categoryStylePane.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 10));
return categoryStylePane;
}
overlapHandleTypeGroup.addChangeListener(new ChangeListener() {
private void addComponentsListener() {
// 显示/隐藏
showLabel.addActionListener(new ActionListener() {
@Override
public void stateChanged(ChangeEvent e) {
checkLabelGapAndStylePane();
public void actionPerformed(ActionEvent e) {
checkLabelPane();
}
});
}
protected ChartTextAttrPane getChartTextAttrPane() {
return ChartEditContext.supportTheme() ? new ChartTextAttrPaneWithThemeStyle() {
protected double getEdithAreaWidth() {
return TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH;
}
} : new ChartTextAttrPane() {
@Override
protected JPanel getContentPane(JPanel buttonPane) {
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double e = TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH;
double[] columnSize = {f, e};
double[] rowSize = {p, p, p};
return TableLayout4VanChartHelper.createGapTableLayoutPane(getComponents(buttonPane), rowSize, columnSize);
}
};
return VanChartAxisPaneHelper.createAxisTextAttrPane();
}
protected JPanel createLineStylePane(double[] row, double[] col) {
@ -537,7 +452,6 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane<VanChartAxis> {
protected void checkAllUse() {
checkCardPane();
checkLabelPane();
checkLabelGapPane();
checkTitlePane();
//区域显示策略 恢复用注释。删除下面一行。
checkMaxProPortionUse();
@ -570,14 +484,8 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane<VanChartAxis> {
protected void checkLabelPane() {
if (showLabel != null) {
boolean enabled = showLabel.getSelectedIndex() == 0;
if (labelPanel != null) {
labelPanel.setVisible(enabled);
}
if (enabled) {
//轴标签缩略间隔显示 恢复用注释。下面1行删除。
checkLabelGapValuePane();
//轴标签缩略间隔显示 恢复用注释。取消注释。
//checkLabelGapAndStylePane();
if (labelContentPane != null) {
labelContentPane.setVisible(enabled);
}
}
}
@ -588,39 +496,6 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane<VanChartAxis> {
}
}
private void checkLabelGapAndStylePane() {
if (overlapHandleTypeGroup != null && labelGapStylePane != null) {
boolean visible = overlapHandleTypeGroup.getSelectedItem() == OverlapHandleType.INTERVAL;
labelGapStylePane.setVisible(visible);
}
checkLabelGapValuePane();
}
protected void checkLabelGapPane() {
if (labelGapPane != null) {
boolean visible = true;
if (showLabelDisplay() && labelDisplayPane != null && labelDisplayComboBox != null) {
visible = labelDisplayComboBox.getSelectedIndex() == 0;
}
labelGapPane.setVisible(visible);
}
}
protected void checkLabelGapValuePane() {
if (labelGapValuePane != null && labelGapStyle != null) {
boolean visible = labelGapStyle.getSelectedIndex() == 1;
//轴标签缩略间隔显示 恢复用注释。取消注释。
// if (overlapHandleTypeGroup != null) {
// visible = visible && overlapHandleTypeGroup.getSelectedItem() == OverlapHandleType.INTERVAL;
// }
labelGapValuePane.setVisible(visible);
}
}
/**
* 是否是指定类型
*
@ -694,33 +569,138 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane<VanChartAxis> {
}
//标签
private void populateLabel(VanChartAxis axis) {
protected void populateLabel(VanChartAxis axis) {
if (showLabel != null) {
showLabel.setSelectedIndex(axis.isShowAxisLabel() ? 0 : 1);
}
TextAttr labelTextAttr = axis.getTextAttr();
if (labelTextAttrPane != null) {
labelTextAttrPane.populate(labelTextAttr);
labelPane.populateBean(getAxisLabelStyle(axis));
populateShowLogicPane(axis);
switchLabelPane(axis);
labelContentPane.validate();
}
/**
* 切换显示是单分类样式设置面板还是多分类样式设置面板
*/
private void switchLabelPane(VanChartAxis axis) {
labelPane.setVisible(!axis.isMultiCategory());
showLogicPane.setVisible(axis.isMultiCategory());
}
private void populateShowLogicPane(VanChartAxis axis) {
if (showLogic != null) {
showLogic.setSelectedIndex(axis.getLabelDisplayMode());
}
if (labelTextRotation != null) {
labelTextRotation.populateBean((double) labelTextAttr.getRotation());
populateWholeDisplayPane(axis);
populateLayerDisplayPane(axis);
showLabelStyleCard();
labelStylePane.revalidate();
}
/**
* populate整体显示那个card面板
*/
private void populateWholeDisplayPane(VanChartAxis axis) {
wholeDisplayLabelPanel.populateBean(getAxisLabelStyle(axis));
}
private VanChartAxisLabelStyle getAxisLabelStyle(VanChartAxis axis) {
VanChartAxisLabelStyle style = new VanChartAxisLabelStyle();
style.setLabelDisplay(axis.getLabelDisplay());
style.setTextAttr(axis.getTextAttr());
style.setAutoLabelGap(axis.isAutoLabelGap());
style.setLabelIntervalNumber(axis.getLabelNumber());
return style;
}
/**
* populate分层显示那个card面板
*
* @param axis
*/
private void populateLayerDisplayPane(VanChartAxis axis) {
Chart chart = axis.getChart();
if (chart == null) {
return;
}
//轴标签缩略间隔显示 恢复用注释。取消注释。
// if (overlapHandleTypeGroup != null) {
// overlapHandleTypeGroup.setSelectedItem(axis.getOverlapHandleType());
// }
if (labelDisplayComboBox != null) {
labelDisplayComboBox.populateBean(axis.getLabelDisplay());
categoryStylePane.removeAll();
categoryStyles.clear();
populateCateLabelStyle(axis);
categoryStylePane.revalidate();
}
/**
* populate分类标签
*
* @param axis
*/
private void populateCateLabelStyle(VanChartAxis axis) {
Chart chart = axis.getChart();
int size;
TopDefinitionProvider definition = chart.getFilterDefinition();
size = definition == null ? 1 : definition.getMoreCateSize() + 1;
for (int i = 0; i < size; i++) {
populateCategoryStyles(axis, i);
}
}
private void populateCategoryStyles(VanChartAxis axis, int index) {
VanChartCategoryStylePaneWithCheckBox pane = new VanChartCategoryStylePaneWithCheckBox(parent, this, Toolkit.i18nText("Fine-Design_Chart_Style_Category") + (index + 1));
VanChartAxisLabelStyle style = populateAxisCategoryStyles(axis, index);
pane.populate(style);
categoryStyles.add(pane);
categoryStylePane.add(createCateLableStylePanel(), BorderLayout.NORTH);
}
private VanChartAxisLabelStyle populateAxisCategoryStyles(VanChartAxis axis, int index) {
VanChartAxisLabelStyle style;
if (axis.getCategoryStylesSize() > index && axis.getCategoryStyle(index) != null) {
style = axis.getCategoryStyle(index);
} else {
style = new VanChartAxisLabelStyle();
axis.addCategoryStyle(style);
}
if (labelGapStyle != null) {
labelGapStyle.setSelectedIndex(axis.isAutoLabelGap() ? 0 : 1);
return style;
}
private JPanel createCateLableStylePanel() {
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH;
double[] row = getCateLableStylePaneRow();
double[] column = {f, p};
JPanel content = TableLayoutHelper.createTableLayoutPane(getCateLabelStyleComponents(), row, column);
Component[][] components = new Component[][]{
new Component[]{null, null},
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Style_Category")), content}
};
return TableLayoutHelper.createTableLayoutPane(components, new double[]{p, p}, new double[]{f, e});
}
private Component[][] getCateLabelStyleComponents() {
Component[][] components = new Component[categoryStyles.size()][];
for (int i = 0; i < categoryStyles.size(); i++) {
components[i] = new Component[2];
components[i][0] = categoryStyles.get(i);
components[i][1] = null;
}
if (labelGapValue != null) {
//轴标签缩略间隔显示 恢复用注释。下面1行删除。
labelGapValue.setText(axis.getLabelNumber().getContent());
//轴标签缩略间隔显示 恢复用注释。取消注释。
//labelGapValue.setValue(axis.getIntervalNumber());
return components;
}
private double[] getCateLableStylePaneRow() {
double[] row = new double[categoryStyles.size()];
for (int i = 0; i < categoryStyles.size(); i++) {
row[i] = TableLayout.PREFERRED;
}
return row;
}
//轴线样式
@ -833,37 +813,54 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane<VanChartAxis> {
}
//标签
private void updateLabel(VanChartAxis axis) {
protected void updateLabel(VanChartAxis axis) {
if (showLabel != null) {
axis.setShowAxisLabel(showLabel.getSelectedIndex() == 0);
}
TextAttr labelTextAttr = axis.getTextAttr();
if (labelTextAttrPane != null) {
labelTextAttrPane.update(labelTextAttr);
}
if (labelTextRotation != null) {
labelTextAttr.setRotation(labelTextRotation.updateBean().intValue());
}
//轴标签缩略间隔显示 恢复用注释。取消注释。
// if (overlapHandleTypeGroup != null) {
// axis.setOverlapHandleType(overlapHandleTypeGroup.getSelectedItem());
// }
if (labelDisplayComboBox != null) {
axis.setLabelDisplay(labelDisplayComboBox.updateBean());
if (!axis.isMultiCategory()) {
axis.setLabelDisplayMode(VanChartAxis.WHOLE_DISPLAY);
updateLabelPaneStyle(axis, labelPane);
} else {
updateShowLogicPane(axis);
}
if (labelGapStyle != null) {
axis.setAutoLabelGap(labelGapStyle.getSelectedIndex() == 0);
switchLabelPane(axis);
}
private void updateShowLogicPane(VanChartAxis axis) {
if (showLogic != null) {
axis.setLabelDisplayMode(showLogic.getSelectedIndex());
}
if (labelGapValue != null) {
//轴标签缩略间隔显示 恢复用注释。下面5行删除。
if (axis.isAutoLabelGap()) {
axis.setLabelIntervalNumber(BaseFormula.createFormulaBuilder().build("1"));
} else {
axis.setLabelIntervalNumber(BaseFormula.createFormulaBuilder().build(labelGapValue.getText()));
}
//轴标签缩略间隔显示 恢复用注释。取消注释。
//axis.setIntervalNumber((int) labelGapValue.getValue());
updateWholeDisplayPane(axis);
updateLayerDisplayPane(axis);
}
/**
* update整体显示那个card面板
*/
private void updateWholeDisplayPane(VanChartAxis axis) {
updateLabelPaneStyle(axis, wholeDisplayLabelPanel);
}
private void updateLabelPaneStyle(VanChartAxis axis, VanChartAxisStyleSettingPane pane) {
VanChartAxisLabelStyle style = pane.updateBean();
axis.setLabelDisplay(style.getLabelDisplay());
axis.setTextAttr(style.getTextAttr());
axis.setAutoLabelGap(style.isAutoLabelGap());
axis.setLabelIntervalNumber(style.getLabelIntervalNumber());
}
/**
* update分层显示那个card面板
*
* @param axis
*/
private void updateLayerDisplayPane(VanChartAxis axis) {
List<VanChartAxisLabelStyle> styles = new ArrayList<>();
for (VanChartCategoryStylePaneWithCheckBox categoryStyle : categoryStyles) {
styles.add(categoryStyle.update());
}
axis.setCategoryStyles(styles);
}
//轴线样式

5
designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartTimeAxisPane.java

@ -85,11 +85,6 @@ public class VanChartTimeAxisPane extends VanChartBaseAxisPane {
return false;
}
@Override
protected void addOverlapGroupButton(JPanel panel) {
//do nothing
}
private JPanel createValueDefinition(){
timeMinMaxValuePane = new TimeMinMaxValuePane();
return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Value_Definition"), timeMinMaxValuePane);

5
designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartValueAxisPane.java

@ -66,11 +66,6 @@ public class VanChartValueAxisPane extends VanChartBaseAxisPane {
return false;
}
@Override
protected void addOverlapGroupButton(JPanel panel) {
//do nothing
}
protected JPanel createMinMaxValuePane(double[] row, double[] col){
JPanel panel = createCommenValuePane(row,col);
return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Value_Definition"), panel);

97
designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/component/VanChartCategoryStylePaneWithCheckBox.java

@ -0,0 +1,97 @@
package com.fr.van.chart.designer.style.axis.component;
import com.fr.design.gui.frpane.AbstractAttrNoScrollPane;
import com.fr.design.gui.frpane.UIBubbleFloatPane;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.i18n.Toolkit;
import com.fr.plugin.chart.attr.axis.VanChartAxisLabelStyle;
import com.fr.stable.Constants;
import com.fr.van.chart.designer.style.axis.VanChartAxisPaneHelper;
import com.fr.van.chart.designer.style.axis.VanChartAxisStyleSettingPane;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Point;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
public class VanChartCategoryStylePaneWithCheckBox extends JPanel {
private UICheckBox checkBox; // 复选框
private UIButton settingButton; // 设置按钮
private VanChartAxisStyleSettingPane settingPane; // 设置弹窗面板
private JPanel showOnPane;
private AbstractAttrNoScrollPane parent;
private VanChartAxisLabelStyle axis;
public VanChartCategoryStylePaneWithCheckBox(AbstractAttrNoScrollPane parent, JPanel showOnPane, String checkBoxName) {
this.parent = parent;
this.showOnPane = showOnPane;
this.setLayout(new BorderLayout());
checkBox = new UICheckBox(checkBoxName);
checkBox.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 0));
checkBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
/* 为什么需要这句话呢因为这个checkBox是动态加上去的没有走最上层父组件ChartStylePane的initAllListener方法
* 所以不会触发update监听下面的bubble弹窗则是不属于ChartStylePane的单独悬浮组件也只能这样触发update监听
*/
if(parent != null){
parent.attributeChanged();
}
}
});
settingButton = new UIButton(Toolkit.i18nText("Fine-Design_Chart_Axis_Style_Setting"));
this.add(checkBox, BorderLayout.CENTER);
this.add(settingButton, BorderLayout.EAST);
initListener();
}
private void initListener() {
if(settingButton != null) {
settingButton.addMouseListener(new MouseAdapter() {
@Override
public void mouseReleased(MouseEvent e) {
if (settingPane == null) {
settingPane = new VanChartAxisStyleSettingPane(VanChartAxisPaneHelper.createAxisTextAttrPane());
}
Point comPoint = settingButton.getLocationOnScreen();
Point arrowPoint = new Point(comPoint.x +settingButton.getWidth() - 25, comPoint.y + settingButton.getHeight());
Dimension size = settingPane.getPreferredSize();
UIBubbleFloatPane<VanChartAxisLabelStyle> pane = new UIBubbleFloatPane(Constants.LEFT, arrowPoint, settingPane, size.width, 230) {
@Override
public void updateContentPane() {
axis = settingPane.updateBean();
if(parent != null){//条件属性没有parent
parent.attributeChanged();
}
}
};
pane.show(showOnPane, axis);
super.mouseReleased(e);
}
});
}
}
public void populate(VanChartAxisLabelStyle style) {
this.axis = style;
checkBox.setSelected(axis.isShowLabel());
}
public VanChartAxisLabelStyle update() {
axis.setShowLabel(checkBox.isSelected());
return axis;
}
}

35
designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/gauge/VanChartGaugeDetailAxisPane.java

@ -1,5 +1,6 @@
package com.fr.van.chart.designer.style.axis.gauge;
import com.fr.chart.base.TextAttr;
import com.fr.design.gui.ibutton.UIButtonGroup;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
@ -35,6 +36,7 @@ public class VanChartGaugeDetailAxisPane extends VanChartValueAxisPane {
private static final long serialVersionUID = -9213466625457882224L;
private ChartTextAttrPane labelTextAttrPane;
private ColorSelectBox mainTickColor;
private ColorSelectBox secTickColor;
@ -83,12 +85,12 @@ public class VanChartGaugeDetailAxisPane extends VanChartValueAxisPane {
protected JPanel createLabelPane(double[] row, double[] col) {
showLabel = new UIButtonGroup(new String[]{Toolkit.i18nText("Fine-Design_Chart_Use_Show"), Toolkit.i18nText("Fine-Design_Chart_Hidden")});
labelTextAttrPane = getChartTextAttrPane();
labelPanel = new JPanel(new BorderLayout());
labelPanel.add(labelTextAttrPane);
labelPanel.setBorder(BorderFactory.createEmptyBorder(0, 15, 0, 0));
labelContentPane = new JPanel(new BorderLayout());
labelContentPane.add(labelTextAttrPane);
labelContentPane.setBorder(BorderFactory.createEmptyBorder(0, 15, 0, 0));
JPanel panel = new JPanel(new BorderLayout(0, 6));
panel.add(TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Chart_Axis_Label"), showLabel), BorderLayout.NORTH);
panel.add(labelPanel, BorderLayout.CENTER);
panel.add(labelContentPane, BorderLayout.CENTER);
showLabel.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
@ -183,23 +185,44 @@ public class VanChartGaugeDetailAxisPane extends VanChartValueAxisPane {
public void populateBean(VanChartAxis axis) {
VanChartGaugeAxis gaugeAxis = (VanChartGaugeAxis) axis;
labelTextAttrPane.populate(axis.getTextAttr());
super.populateBean(gaugeAxis);
}
@Override
protected void populateLabel(VanChartAxis axis) {
VanChartGaugeAxis gaugeAxis = (VanChartGaugeAxis) axis;
if (showLabel != null) {
showLabel.setSelectedIndex(axis.isShowAxisLabel() ? 0 : 1);
}
if (mainTickColor != null) {
mainTickColor.setSelectObject(gaugeAxis.getMainTickColor());
}
if (secTickColor != null) {
secTickColor.setSelectObject(gaugeAxis.getSecTickColor());
}
super.populateBean(gaugeAxis);
}
public void updateBean(VanChartAxis axis) {
VanChartGaugeAxis gaugeAxis = (VanChartGaugeAxis) axis;
TextAttr textAttr = axis.getTextAttr();
labelTextAttrPane.update(textAttr);
super.updateBean(gaugeAxis);
}
@Override
protected void updateLabel(VanChartAxis axis) {
VanChartGaugeAxis gaugeAxis = (VanChartGaugeAxis) axis;
if (showLabel != null) {
axis.setShowAxisLabel(showLabel.getSelectedIndex() == 0);
}
if (mainTickColor != null) {
gaugeAxis.setMainTickColor(mainTickColor.getSelectObject());
}
if (secTickColor != null) {
gaugeAxis.setSecTickColor(secTickColor.getSelectObject());
}
super.updateBean(gaugeAxis);
}
}

15
designer-chart/src/main/java/com/fr/van/chart/designer/style/background/VanChartGantAreaPane.java

@ -0,0 +1,15 @@
package com.fr.van.chart.designer.style.background;
import com.fr.chart.chartattr.Plot;
import com.fr.design.gui.frpane.AbstractAttrNoScrollPane;
import com.fr.van.chart.designer.style.VanChartStylePane;
public class VanChartGantAreaPane extends VanChartAreaPane {
public VanChartGantAreaPane(Plot plot, VanChartStylePane parent) {
super(plot, parent);
}
protected void initPlotPane(boolean b, AbstractAttrNoScrollPane parent) {
plotPane = new VanChartGantPlotAreaBackgroundPane(parent);
}
}

102
designer-chart/src/main/java/com/fr/van/chart/designer/style/background/VanChartGantPlotAreaBackgroundPane.java

@ -0,0 +1,102 @@
package com.fr.van.chart.designer.style.background;
import com.fr.chart.chartattr.Chart;
import com.fr.chart.chartattr.Plot;
import com.fr.design.gui.frpane.AbstractAttrNoScrollPane;
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.ColorSelectBoxWithOutTransparent;
import com.fr.plugin.chart.gantt.VanChartGanttPlot;
import com.fr.van.chart.designer.TableLayout4VanChartHelper;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Component;
public class VanChartGantPlotAreaBackgroundPane extends VanChartAreaBackgroundPane {
private ColorSelectBoxWithOutTransparent axisColorPane;
private ColorSelectBoxWithOutTransparent contentColorPane;
public VanChartGantPlotAreaBackgroundPane(AbstractAttrNoScrollPane parent) {
super(true, parent);
}
@Override
protected JPanel createContentPane() {
JPanel contentPane = new JPanel(new BorderLayout());
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double[] columnSize = {f};
double[] rowSize = {p, p};
Component[][] components = new Component[][]{
new Component[]{createAxisBorderPane()},
new Component[]{createContentBorderPane()}
};
contentPane.add(TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize), BorderLayout.CENTER);
return contentPane;
}
@Override
public void updateBean(Chart chart) {
if (chart == null) {
chart = new Chart();
}
Plot plot = chart.getPlot();
if (plot instanceof VanChartGanttPlot) {
VanChartGanttPlot ganttPlot = (VanChartGanttPlot) plot;
ganttPlot.setAxisBorderColor(axisColorPane.getSelectObject());
ganttPlot.setContentBorderColor(contentColorPane.getSelectObject());
}
}
@Override
public void populateBean(Chart chart) {
if (chart == null) {
chart = new Chart();
}
Plot plot = chart.getPlot();
if (plot instanceof VanChartGanttPlot) {
VanChartGanttPlot ganttPlot = (VanChartGanttPlot) plot;
axisColorPane.setSelectObject(ganttPlot.getAxisBorderColor());
contentColorPane.setSelectObject(ganttPlot.getContentBorderColor());
}
}
private JPanel createAxisBorderPane() {
axisColorPane = new ColorSelectBoxWithOutTransparent(100);
return TableLayout4VanChartHelper.createExpandablePaneWithTitle(
Toolkit.i18nText("Fine-Design_Chart_Gant_Axis_Border"),
createBorderPane(axisColorPane)
);
}
private JPanel createContentBorderPane() {
contentColorPane = new ColorSelectBoxWithOutTransparent(100);
return TableLayout4VanChartHelper.createExpandablePaneWithTitle(
Toolkit.i18nText("Fine-Design_Chart_Gant_Content_Border"),
createBorderPane(contentColorPane)
);
}
private JPanel createBorderPane(ColorSelectBoxWithOutTransparent colorPane) {
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double[] columnSize = {f, TableLayout4VanChartHelper.EDIT_AREA_WIDTH};
double[] rowSize = {p, p};
Component[][] components = new Component[][]{
new Component[]{null, null},
new Component[]{
new UILabel(Toolkit.i18nText("Fine-Design_Chart_Color")),
colorPane
}
};
return TableLayout4VanChartHelper.createGapTableLayoutPane(components, rowSize, columnSize);
}
}

6
designer-chart/src/main/java/com/fr/van/chart/gantt/designer/style/VanChartGanttStylePane.java

@ -4,6 +4,8 @@ import com.fr.chart.chartattr.Plot;
import com.fr.design.dialog.BasicPane;
import com.fr.design.gui.frpane.AttributeChangeListener;
import com.fr.van.chart.designer.style.VanChartStylePane;
import com.fr.van.chart.designer.style.background.VanChartAreaPane;
import com.fr.van.chart.designer.style.background.VanChartGantAreaPane;
import com.fr.van.chart.gantt.designer.style.axis.GanttProcessAxisPane;
import com.fr.van.chart.gantt.designer.style.axis.GanttTimeAxisPane;
@ -31,4 +33,8 @@ public class VanChartGanttStylePane extends VanChartStylePane {
private void addProjectAxisPane(List<BasicPane> paneList, Plot plot) {
paneList.add(new GanttProcessAxisPane());
}
protected VanChartAreaPane createVanChartAreaPane() {
return new VanChartGantAreaPane(getChart().getPlot(), VanChartGanttStylePane.this);
}
}

15
designer-chart/src/main/java/com/fr/van/chart/gantt/designer/style/series/VanChartGanttSeriesPane.java

@ -5,6 +5,7 @@ import com.fr.design.beans.BasicBeanPane;
import com.fr.design.gui.ibutton.UIButtonGroup;
import com.fr.design.gui.icombobox.LineComboBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.chart.gui.ChartStylePane;
@ -14,6 +15,7 @@ import com.fr.plugin.chart.gantt.VanChartGanttPlot;
import com.fr.stable.CoreConstants;
import com.fr.van.chart.designer.TableLayout4VanChartHelper;
import com.fr.van.chart.designer.component.VanChartBeautyPane;
import com.fr.van.chart.designer.component.VanChartGanttTimeLinePane;
import com.fr.van.chart.designer.component.VanChartMarkerPane;
import com.fr.van.chart.designer.component.marker.VanChartCommonMarkerPane;
import com.fr.van.chart.designer.style.series.VanChartAbstractPlotSeriesPane;
@ -30,6 +32,8 @@ public class VanChartGanttSeriesPane extends VanChartAbstractPlotSeriesPane {
private LineComboBox lineWidth;//线型
private ColorSelectBoxWithOutTransparent colorSelect;//颜色
private VanChartGanttTimeLinePane timeLinePane;
public VanChartGanttSeriesPane(ChartStylePane parent, Plot plot) {
super(parent, plot);
}
@ -45,7 +49,8 @@ public class VanChartGanttSeriesPane extends VanChartAbstractPlotSeriesPane {
new Component[]{createGanntStylePane()},
new Component[]{createLinkLinePane()},
new Component[]{createMarkerPane()},
new Component[]{createLargeDataModelPane()}
new Component[]{createLargeDataModelPane()},
new Component[]{createGuideLinePane()}
};
contentPane = TableLayoutHelper.createTableLayoutPane(components, row, col);
@ -96,6 +101,11 @@ public class VanChartGanttSeriesPane extends VanChartAbstractPlotSeriesPane {
return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Gannt_Marker"), markerPane);
}
protected JPanel createGuideLinePane() {
timeLinePane = new VanChartGanttTimeLinePane();
return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Guide_Line_Identify"), timeLinePane);
}
@Override
public void populateBean(Plot plot) {
super.populateBean(plot);
@ -104,10 +114,10 @@ public class VanChartGanttSeriesPane extends VanChartAbstractPlotSeriesPane {
VanChartGanttPlot ganttPlot = (VanChartGanttPlot)plot;
seriesNewLine.setSelectedIndex(ganttPlot.isSeriesNewLineEnable() ? 0 : 1);
lineWidth.setSelectedLineStyle(ganttPlot.getLineWidth());
colorSelect.setSelectObject(ganttPlot.getLineColor());
timeLinePane.populateBean(plot);
}
}
@ -121,6 +131,7 @@ public class VanChartGanttSeriesPane extends VanChartAbstractPlotSeriesPane {
ganttPlot.setLineWidth(lineWidth.getSelectedLineStyle());
ganttPlot.setLineColor(colorSelect.getSelectObject());
timeLinePane.updateBean(plot);
}
}

2
designer-chart/src/main/java/com/fr/van/chart/gantt/designer/style/tooltip/VanChartFormatComBoxWithCheckBox.java

@ -53,7 +53,7 @@ public class VanChartFormatComBoxWithCheckBox extends JPanel {
}
});
formatComBox.setPreferredSize(new Dimension(40, 20));
formatComBox.setPreferredSize(new Dimension(55, 20));
if (showSelectBox()) {
this.add(isSelectedBox, BorderLayout.CENTER);

14
designer-form/src/main/java/com/fr/design/designer/beans/events/AddingWidgetListenerTable.java

@ -28,23 +28,13 @@ public class AddingWidgetListenerTable {
public void beforeAdded() {
for (final AddingWidgetListener listener : listeners) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
listener.beforeAdded();
}
});
listener.beforeAdded();
}
}
public void afterAdded(boolean addResult) {
for (final AddingWidgetListener listener : listeners) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
listener.afterAdded(addResult);
}
});
listener.afterAdded(addResult);
}
}

10
designer-form/src/main/java/com/fr/design/designer/beans/models/DraggingModel.java

@ -14,7 +14,6 @@ public class DraggingModel {
private MouseEvent currentDragEvent;
private int creatorLeftTopX = -999; // 隐藏
private int creatorLeftTopY = -999; // 隐藏
private boolean dragNewWidget; // 是否正在拖拽一个新的组件下来
public DraggingModel() {
@ -40,11 +39,6 @@ public class DraggingModel {
return this;
}
public DraggingModel dragNewWidget(boolean dragNewWidget) {
this.dragNewWidget = dragNewWidget;
return this;
}
public FormDesigner getDesigner() {
return designer;
}
@ -79,10 +73,6 @@ public class DraggingModel {
return creatorLeftTopY;
}
public boolean isDragNewWidget() {
return dragNewWidget;
}
public void moveTo(int x, int y) {
XLayoutContainer container = designer.getDraggingHotspotLayout();
LayoutAdapter adapter = container.getLayoutAdapter();

11
designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java

@ -54,6 +54,7 @@ import java.beans.IntrospectionException;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.StringJoiner;
/**
* @author richer
@ -943,4 +944,14 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo
return false;
}
@Override
public String toString() {
return new StringJoiner(", ", XCreator.class.getSimpleName() + "[", "]")
.add("data=" + data)
.add("shareId='" + shareId + "'")
.add("isHelpBtnOnFocus=" + isHelpBtnOnFocus)
.add("selected=" + selected)
.toString();
}
}

4
designer-form/src/main/java/com/fr/design/designer/creator/XElementCase.java

@ -20,6 +20,7 @@ import com.fr.form.FormProvider;
import com.fr.form.ui.ElementCaseEditor;
import com.fr.form.ui.ElementCaseEditorProvider;
import com.fr.report.fit.ReportFitAttr;
import com.fr.report.fit.ReportFitConfig;
import com.fr.stable.ArrayUtils;
import com.fr.stable.CoreGraphHelper;
import com.fr.stable.core.PropertyChangeAdapter;
@ -127,7 +128,8 @@ public class XElementCase extends XBorderStyleWidgetCreator implements FormEleme
private CRPropertyDescriptor getReportFitEditor() {
this.designer = WidgetPropertyPane.getInstance().getEditingFormDesigner();
FitProvider wbTpl = designer.getTarget();
ReportFitAttr fitAttr = wbTpl.getReportFitAttr();
//这边获取到的全局要考虑到服务器的配置
ReportFitAttr fitAttr = wbTpl.getReportFitAttr() == null ? ReportFitConfig.getInstance().getFrmFitAttr() : wbTpl.getReportFitAttr();
ElementCaseEditor editor = this.toData();
//兼容之前报表块(之前三个选项为:默认 横向 双向 现在是:横向 双向 不自适应)
if (editor.getFitStateInPC() == 0) {

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

@ -764,6 +764,7 @@ public class XWFitLayout extends XLayoutContainer {
creator.setBackupBound(creator.getBounds());
}
}
LayoutUtils.layoutContainer(this);
}
private Rectangle recalculateWidgetBounds(Rectangle rec, int[] hors, int[] veris) {
@ -831,11 +832,7 @@ public class XWFitLayout extends XLayoutContainer {
this.remove(oldCreator);
this.add(newCreator);
dealDirections(newCreator, false);
//对于新增的绝对布局的组件,需要更新下内部组件的大小
if (newCreator.acceptType(XWAbsoluteLayout.class)){
((XWAbsoluteLayout) newCreator).updateBoundsWidget();
newCreator.setBackupBound(newCreator.getBounds());
}
this.updateBoundsWidget();
isRefreshing = false;
LayoutUtils.layoutContainer(this);
}

12
designer-form/src/main/java/com/fr/design/designer/creator/XWParameterLayout.java

@ -270,4 +270,16 @@ public class XWParameterLayout extends XWAbsoluteLayout {
public boolean isTopable() {
return false;
}
/**
* 修改form布局的宽度时需要同时修改表单参数界面的布局的宽度
* */
@Override
public void doLayout() {
layout();
if (data != null && data instanceof WParameterLayout) {
((WParameterLayout) data).setDesignWidth(getWidth());
}
}
}

4
designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardTagLayout.java

@ -8,6 +8,7 @@ import com.fr.base.ScreenResolution;
import com.fr.design.designer.beans.AdapterBus;
import com.fr.design.designer.beans.LayoutAdapter;
import com.fr.design.designer.beans.adapters.layout.FRWCardTagLayoutAdapter;
import com.fr.design.designer.beans.models.ModelUtil;
import com.fr.design.designer.beans.models.SelectionModel;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XCreatorUtils;
@ -136,6 +137,9 @@ public class XWCardTagLayout extends XWHorizontalBoxLayout {
WTabFitLayout fitLayout = new WTabFitLayout(widgetName, tabFitIndex, currentCard);
fitLayout.setTabNameIndex(getTabNameIndex());
XWTabFitLayout tabFitLayout = new XWTabFitLayout(fitLayout, new Dimension());
FormDesigner formDesigner = WidgetPropertyPane.getInstance().getEditingFormDesigner();
ModelUtil.renameWidgetName(formDesigner.getTarget(), tabFitLayout);
WCardTagLayout layout = (WCardTagLayout) this.toData();
if(!ComparatorUtils.equals(layout.getTemplateStyle().getStyle(), DefaultTemplateStyle.DEFAULT_TEMPLATE_STYLE)){

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

@ -2,25 +2,27 @@ package com.fr.design.fit;
import com.fr.base.DynamicUnitList;
import com.fr.base.Parameter;
import com.fr.base.TRL;
import com.fr.design.designer.beans.AdapterBus;
import com.fr.design.designer.beans.LayoutAdapter;
import com.fr.design.designer.beans.adapters.layout.FRFitLayoutAdapter;
import com.fr.design.designer.beans.events.DesignerEditListener;
import com.fr.design.designer.beans.events.DesignerEvent;
import com.fr.design.designer.creator.XComponent;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XCreatorUtils;
import com.fr.design.designer.creator.XElementCase;
import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.creator.XWTitleLayout;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.mainframe.DesignerUIModeConfig;
import com.fr.design.preview.DeveloperPreview;
import com.fr.design.preview.FormAdaptivePreview;
import com.fr.design.fit.toolbar.SwitchAction;
import com.fr.design.fun.PreviewProvider;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.mainframe.DesignerUIModeConfig;
import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.JForm;
import com.fr.design.mainframe.WidgetPropertyPane;
import com.fr.design.preview.DeveloperPreview;
import com.fr.design.preview.FormAdaptivePreview;
import com.fr.design.preview.FormPreview;
import com.fr.design.preview.MobilePreview;
import com.fr.design.utils.ComponentUtils;
@ -29,6 +31,7 @@ import com.fr.form.FormElementCaseProvider;
import com.fr.form.fit.NewFormMarkAttr;
import com.fr.form.main.Form;
import com.fr.form.ui.ElementCaseEditor;
import com.fr.general.ComparatorUtils;
import com.fr.stable.ArrayUtils;
import javax.swing.JComponent;
@ -176,11 +179,13 @@ public class NewJForm extends JForm {
FRFitLayoutAdapter layoutAdapter = (FRFitLayoutAdapter) adapter;
layoutAdapter.setEdit(true);
layoutAdapter.calculateBounds(backupBounds, xwTitleLayout.getBounds(), xwTitleLayout, row, difference);
} else {
XLayoutContainer parent = XCreatorUtils.getParentXLayoutContainer(xwTitleLayout);
if (parent != null && parent.toData() != null) {
parent.toData().setBounds(xwTitleLayout.toData(), xwTitleLayout.getBounds());
}
}
XLayoutContainer parent = XCreatorUtils.getParentXLayoutContainer(xwTitleLayout);
if (parent != null && parent.toData() != null) {
parent.toData().setBounds(xwTitleLayout.toData(), xwTitleLayout.getBounds());
}
}
@ -215,6 +220,7 @@ public class NewJForm extends JForm {
return new PreviewProvider[]{new FormPreview(), new MobilePreview()};
}
@Override
public UIButton[] createExtraButtons() {
UIButton[] extraButtons = super.createExtraButtons();
return addAdaptiveSwitchButton(extraButtons);
@ -228,4 +234,25 @@ public class NewJForm extends JForm {
public boolean isNewJFrom() {
return jFormType == null || jFormType.isNewType();
}
@Override
public void navigate(TRL trl) {
String blockName = trl.unescapeNext();
JForm.traversalXCreator(formDesign.getRootComponent(), xCreator -> {
if (!ComparatorUtils.equals(xCreator.toData().getWidgetName(), blockName)) {
return;
}
if (xCreator instanceof XElementCase) {
getFormDesign().getSelectionModel().selectACreator(xCreator);
xCreator.startEditing();
if (getElementCaseDesign() != null) {
getElementCaseDesign().navigate(trl);
}
} else {
tabChanged(FORM_TAB);
getFormDesign().getSelectionModel().reset();
getFormDesign().getSelectionModel().selectACreator(xCreator);
}
}, XCreator.class);
}
}

2
designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java

@ -459,13 +459,11 @@ public class EditingMouseListener extends MouseInputAdapter {
if (isSelectionDrag()) {
stateModel.changeSelection(e);
return;
}
// 调整大小这边单独提出来,不跟后面拖组件混在一起,实在不好管理
if (stateModel.isDraggingSize()) {
stateModel.dragging(e);
return;
}
designer.startDraggingFormWidget(lastXCreator, lastPressEvent, e);

6
designer-form/src/main/java/com/fr/design/mainframe/FormCreatorDropTarget.java

@ -264,11 +264,7 @@ public class FormCreatorDropTarget extends DropTarget {
Point loc = dtde.getLocation();
int x = designer.getRelativeX(loc.x);
int y = designer.getRelativeY(loc.y);
if (model.isDragNewWidget()) {
designer.addNewWidget(creator, x, y);
} else {
designer.changeWidgetPlace(creator, x, y);
}
designer.addWidgetToForm(creator, x, y);
// 放到事件末尾执行
SwingUtilities.invokeLater(new Runnable() {
@Override

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

@ -1248,16 +1248,16 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
* @param currentDragEvent
*/
public void startDraggingNewWidget(XCreator xCreator, MouseEvent startDragEvent, MouseEvent currentDragEvent) {
if (currentDragEvent == null || this.getDropTarget() != null) {
if (currentDragEvent == null) {
return;
}
instantiateCreator(xCreator);
draggingModel = new DraggingModel()
.designer(this)
.creator(xCreator)
.startDragEvent(startDragEvent)
.currentDragEvent(currentDragEvent)
.dragNewWidget(true);
.currentDragEvent(currentDragEvent);
this.setDropTarget(new FormCreatorDropTarget(this, xCreator));
repaint();
}
@ -1270,15 +1270,15 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
* @param currentDragEvent
*/
public void startDraggingFormWidget(XCreator xCreator, MouseEvent startDragEvent, MouseEvent currentDragEvent) {
if (currentDragEvent == null || this.getDropTarget() != null) {
if (currentDragEvent == null) {
return;
}
backUpCreator(xCreator);
draggingModel = new DraggingModel()
.designer(this)
.creator(xCreator)
.startDragEvent(startDragEvent)
.currentDragEvent(currentDragEvent)
.dragNewWidget(false);
.currentDragEvent(currentDragEvent);
XLayoutContainer container = this.getDraggingHotspotLayout();
LayoutAdapter adapter = container.getLayoutAdapter();
adapter.dragging(this.getDraggingModel());
@ -1318,7 +1318,14 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
DraggingModel model = this.draggingModel;
MouseEvent dragEvent = model.getCurrentDragEvent();
XCreator hotspot = this.getComponentAt(dragEvent.getX(), dragEvent.getY());
return XCreatorUtils.getHotspotContainer(hotspot);
XLayoutContainer container = XCreatorUtils.getHotspotContainer(hotspot);
XLayoutContainer topLayout = container.getTopLayout();
// REPORT-66939 Tab比较特殊,它是又多个LayoutContainer组成,直接返回container会导致误判,需要先找到最上层topLayout,取其父layout才是正确结果
if (topLayout != null && container != topLayout) {
return (XLayoutContainer) topLayout.getParent();
} else {
return container;
}
}
/**
@ -1520,7 +1527,10 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
private DesignerBaseOperate getLayoutBaseOperate(){
FormSelection selection = this.getSelectionModel().getSelection();
XCreator creator = selection.getSelectedCreator();
XLayoutContainer container = (XLayoutContainer) creator.getParent();
XLayoutContainer container = null;
if (creator != null) {
container = (XLayoutContainer) creator.getParent();
}
if (container == null) {
return new DefaultDesignerBaseOperate();
}
@ -1987,27 +1997,25 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
return spacingLineDrawer;
}
private void instantiateCreator(XCreator creator) {
ModelUtil.renameWidgetName(this.getTarget(), creator);
creator.addNotify();
ComponentAdapter adapter = new CompositeComponentAdapter(this, creator);
adapter.initialize();
creator.putClientProperty(AdapterBus.CLIENT_PROPERTIES, adapter);
}
public void instantiateCreator(XCreator creator) {
if (creator != null) {
ModelUtil.renameWidgetName(this.getTarget(), creator);
creator.addNotify();
public void addNewWidget(XCreator creator, int x, int y) {
instantiateCreator(creator);
addWidgetToForm(creator, x, y);
ComponentAdapter adapter = new CompositeComponentAdapter(this, creator);
adapter.initialize();
creator.putClientProperty(AdapterBus.CLIENT_PROPERTIES, adapter);
}
}
public void changeWidgetPlace(XCreator creator, int x, int y) {
creator.backupCurrentSize();
creator.backupParent();
addWidgetToForm(creator, x, y);
public void backUpCreator(XCreator creator) {
if (creator != null) {
creator.backupCurrentSize();
creator.backupParent();
}
}
private void addWidgetToForm(XCreator creator, int x, int y) {
public void addWidgetToForm(XCreator creator, int x, int y) {
if(creator == null) {
return;
}

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

@ -116,8 +116,8 @@ public class FormDesignerUI extends ComponentUI {
designer.getPainter().paint(g, designer.getArea().getHorizontalValue(),
designer.getArea().getVerticalValue() + designer.getParaHeight());
}
DraggingModel draggingModel = designer.getDraggingModel();
if (draggingModel != null && draggingModel.getCreator() != null) {
if (needPaintDraggingBean()) {
// 当前正在添加的组件
paintDraggingBean(g);
}
@ -217,6 +217,19 @@ public class FormDesignerUI extends ComponentUI {
ComponentUtils.resetBuffer(dbcomponents);
}
private boolean needPaintDraggingBean() {
DraggingModel draggingModel = designer.getDraggingModel();
if (draggingModel == null || draggingModel.getCreator() == null) {
return false;
}
XCreator creator = draggingModel.getCreator();
int leftTopX = draggingModel.getCreatorLeftTopX();
int leftTopY = draggingModel.getCreatorLeftTopY();
return leftTopX + creator.getWidth() > 0 && leftTopY + creator.getHeight() > 0;
}
private void paintAuthorityCreator(Graphics2D g2d, Rectangle creatorBounds) {
back_or_selection_rect.setRect(creatorBounds.getX(), creatorBounds.getY(),

7
designer-form/src/main/java/com/fr/design/mainframe/FormModelAdapter.java

@ -2,6 +2,7 @@ package com.fr.design.mainframe;
import com.fr.base.Parameter;
import com.fr.base.TableData;
import com.fr.base.param.ParameterSource;
import com.fr.data.TableDataSource;
import com.fr.design.DesignModelAdapter;
import com.fr.design.file.HistoryTemplateListPane;
@ -14,8 +15,8 @@ import com.fr.script.Calculator;
import com.fr.stable.EmbParaFilter;
import com.fr.stable.ParameterProvider;
import com.fr.stable.js.WidgetName;
import com.fr.util.ParameterApplyHelper;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@ -55,7 +56,7 @@ public class FormModelAdapter extends DesignModelAdapter<Form, BaseJForm<Form>>
Map<String, ParameterProvider> map = new HashMap<>();
addGlobalParameters(map);
updateTableDataParameters(oldName, tdName, tableData, map, parameterProvider -> !EmbParaFilter.isFRLayerTypePara(parameterProvider));
ParameterApplyHelper.addPara2Map(map, this.getBook().getTemplateParameters());
ParameterApplyHelper.addPara2Map(map, this.getBook().getTemplateParameters(), null, ParameterSource.DEFAULT_SOURCE);
parameters = map.values().toArray(new Parameter[0]);
jTemplate.populateParameter();
}
@ -158,7 +159,7 @@ public class FormModelAdapter extends DesignModelAdapter<Form, BaseJForm<Form>>
addTableDataParameters(map, parameterProvider -> !EmbParaFilter.isFRLayerTypePara(parameterProvider));
ParameterApplyHelper.addPara2Map(map, this.getBook().getTemplateParameters());
ParameterApplyHelper.addPara2Map(map, this.getBook().getTemplateParameters(), null, ParameterSource.DEFAULT_SOURCE);
return map.values().toArray(new Parameter[0]);
}

12
designer-form/src/main/java/com/fr/design/mainframe/FormParaWidgetPane.java

@ -18,6 +18,10 @@ import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.imenu.UIPopupMenu;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.share.ComponentShareUtil;
import com.fr.design.mainframe.share.ui.online.OnlineWidgetRepoPane;
import com.fr.design.mainframe.share.ui.online.mini.MiniComponentShopDialog;
import com.fr.design.mainframe.share.util.OnlineShopUtils;
import com.fr.design.module.DesignModuleFactory;
import com.fr.design.ui.util.UIUtil;
import com.fr.design.utils.gui.LayoutUtils;
@ -262,7 +266,13 @@ public class FormParaWidgetPane extends JPanel {
jPanel.addMouseListener(new MouseListener() {
@Override
public void mouseClicked(MouseEvent e) {
FormWidgetDetailPane.getInstance().enterWidgetLib();
if (OnlineShopUtils.testConnection() && ComponentShareUtil.isShowMiniShopWindow()) {
MiniComponentShopDialog.getInstance().show();
} else {
OnlineWidgetRepoPane.getInstance().switch2InternetErrorPane();
FormWidgetDetailPane.getInstance().switch2Local();
FormWidgetDetailPane.getInstance().enterWidgetLib();
}
}
@Override

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

@ -96,6 +96,7 @@ import com.fr.stable.ProductConstants;
import com.fr.stable.StringUtils;
import com.fr.stable.bridge.StableFactory;
import com.fr.web.controller.ViewRequestConstants;
import org.jetbrains.annotations.Nullable;
import javax.swing.BorderFactory;
import javax.swing.Icon;
@ -125,7 +126,7 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm<F
private static final int TOOLBARPANEDIMHEIGHT_FORM = 60;
//表单设计器
private FormDesigner formDesign;
protected FormDesigner formDesign;
//格子设计器
private FormECDesignerProvider elementCaseDesign;
@ -134,7 +135,7 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm<F
private CardLayout cardLayout;
//当前编辑的组件对象
private JComponent editingComponent;
private FormECCompositeProvider reportComposite;
protected FormECCompositeProvider reportComposite;
//FORM_TAB代表是否点击编辑,用于点击编辑前后菜单的显示
protected int index = FORM_TAB;
@ -742,7 +743,7 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm<F
*/
public JComponent[] toolBarButton4Form() {
return this.index == FORM_TAB ?
formDesign.getBasicActionComponent():
formDesign.getBasicActionComponent() :
elementCaseDesign.toolBarButton4Form();
}
@ -928,6 +929,9 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm<F
* @param index 切换位置
*/
public void tabChanged(int index) {
if (this.index == index) {
return;
}
this.index = index;
if (index == ELEMENTCASE_TAB) {
formDesign.setReportBlockEditing(true);
@ -1050,6 +1054,42 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm<F
return creator.toData();
}
/**
* 选中组件
*
* @param widgetName 组件名称
*/
public void selectElementCase(String widgetName) {
XCreator elementCase = findElementCase(formDesign.getRootComponent(), widgetName);
if (elementCase == null) {
return;
}
formDesign.getSelectionModel().reset();
formDesign.getSelectionModel().setSelectedCreator(elementCase);
elementCase.startEditing();
}
@Nullable
public XCreator findElementCase(XLayoutContainer container, String name) {
if (StringUtils.equals(container.toData().getWidgetName(), name)) {
return container;
}
for (Component component : container.getComponents()) {
if (component instanceof XLayoutContainer) {
XCreator xCreator = findElementCase((XLayoutContainer) component, name);
if (xCreator != null) {
return xCreator;
}
} else if (component instanceof XCreator) {
XCreator xCreator = (XCreator) component;
if (StringUtils.equals(xCreator.toData().getWidgetName(), name)) {
return xCreator;
}
}
}
return null;
}
/**
* 支持的预览模式
*
@ -1107,7 +1147,7 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm<F
}
Iterator tdIterator = sharableEditor.getTableDataSource().getTableDataNameIterator();
while (tdIterator.hasNext()) {
String tdName = bindInfo.getName() + TableDataConstants.SEPARATOR + tdIterator.next();
String tdName = bindInfo.getName() + TableDataConstants.SEPARATOR + tdIterator.next();
TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter()).removeTableData(tdName);
}
}
@ -1230,11 +1270,11 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm<F
DesignerContext.getDesignerFrame().getCenterTemplateCardPane().showForbiddenStatus();
}
public void setDesignerUIMode(){
public void setDesignerUIMode() {
DesignerUIModeConfig.getInstance().setSimulateWebUIMode();
}
public XLayoutContainer getRootComponent(){
public XLayoutContainer getRootComponent() {
return this.formDesign.getRootComponent();
}
}

4
designer-form/src/main/java/com/fr/design/mainframe/share/config/ComponentReuseConfigManager.java

@ -22,6 +22,7 @@ public class ComponentReuseConfigManager {
private static final String PROPERTIES_FILE_NAME = "reuse.properties";
private static final String MINI_SHOP_URL = "MINI_SHOP_URL";
private static final String WEB_MINI_SHOP_URL = "WEB_MINI_SHOP_URL";
private static final String COMPONENT_UPLOAD_URL = "COMPONENT_UPLOAD_URL";
private static final String MARKET_LOGIN_URL = "MARKET_LOGIN_URL";
private static final String UPLOAD_REU_SUPPORT = "UPLOAD_REU_SUPPORT";
@ -61,6 +62,9 @@ public class ComponentReuseConfigManager {
return p;
}
public String getWebMiniShopUrl() {
return loadAttribute(WEB_MINI_SHOP_URL, DesignerCloudURLManager.getInstance().acquireUrlByKind("component.miniShop"));
}
public String getMiniShopUrl() {
return loadAttribute(MINI_SHOP_URL, DesignerCloudURLManager.getInstance().acquireUrlByKind("af.reuseInfo"));

6
designer-form/src/main/java/com/fr/design/mainframe/share/sort/OnlineWidgetSortType.java

@ -27,7 +27,11 @@ public enum OnlineWidgetSortType implements SortType<OnlineShareWidget> {
public int compare(OnlineShareWidget o1, OnlineShareWidget o2) {
double t1 = getSortValue(o1, parameterMap);
double t2 = getSortValue(o2, parameterMap);
return ComparatorUtils.compareCommonType(t2, t1);
// Comparator中比较double/float相等时,不允许误差. 否则会违背 "若x = y , y = z, 则x = z"的约定。
// 因为允许误差的情况下,x和y间的误差在允许范围内,被判定相等,y和z间的误差在允许范围内,被判定相等,
// 但x和z间的误差可能超出允许范围,从而不相等,因此会违背上述约定。
// 产生IllegalArgumentException: Comparison method violates its general contract!
return Double.compare(t2, t1);
}
});
}

1
designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/LocalWidgetBlock.java

@ -250,6 +250,7 @@ public class LocalWidgetBlock extends PreviewWidgetBlock<DefaultSharableWidget>
ShareUIUtils.showErrorMessageDialog(Toolkit.i18nText("Fine-Design_Share_Drag_Error_Info"));
return null;
}
compatibleProcessAbsoluteLayoutResolution(creatorSource);
creatorSource.setWidgetID(UUID.randomUUID().toString());
((AbstractBorderStyleWidget) creatorSource).addWidgetAttrMark(new SharableAttrMark(true));
//tab布局WCardMainBorderLayout通过反射出来的大小是960*480

68
designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/OnlineWidgetBlock.java

@ -194,6 +194,7 @@ public class OnlineWidgetBlock extends AbstractOnlineWidgetBlock {
ShareUIUtils.showErrorMessageDialog(Toolkit.i18nText("Fine-Design_Share_Drag_Error_Info"));
return;
}
compatibleProcessAbsoluteLayoutResolution(creatorSource);
creatorSource.setWidgetID(UUID.randomUUID().toString());
((AbstractBorderStyleWidget) creatorSource).addWidgetAttrMark(new SharableAttrMark(true));
SharableWidgetProvider bindInfo = ShareUtils.getElCaseBindInfoById(shareId);
@ -336,41 +337,42 @@ public class OnlineWidgetBlock extends AbstractOnlineWidgetBlock {
null,
this
);
return;
}
//如果鼠标移动到布局内且布局不可编辑,画出编辑蒙层
if (!isRightClickPopupMenuVisible() && (isMouseEnter || downloading)) {
Graphics2D g2d = (Graphics2D) g;
Composite oldComposite = g2d.getComposite();
//画白色的编辑层
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 20 / 100.0F));
g2d.setColor(COVER_COLOR);
g2d.fillRect(x, y, w, h);
g2d.setComposite(oldComposite);
//画编辑按钮图标
BufferedImage image = (process > 0 || downloading) ? WIDGET_DOWNLOADING_ICON : WIDGET_DOWNLOAD_ICON;
g2d.drawImage(
image,
(x + w / 2 - 12),
(y + h / 2 - 16),
image.getWidth(),
image.getHeight(),
null,
this
);
Stroke oldStroke = g2d.getStroke();
g2d.setStroke(XCreatorConstants.STROKE);
g2d.setColor(Color.decode("#419BF9"));
double arcAngle = downloading ? (36 + 360 * 0.9 * process) : 0.0;
g2d.drawArc(x + w / 2 - 12, y + h / 2 - 16, 24, 24, 90, -(int) arcAngle);
g2d.setColor(Color.WHITE);
g2d.setStroke(oldStroke);
}
} else {
//如果鼠标移动到布局内且布局不可编辑,画出编辑蒙层
if (!isRightClickPopupMenuVisible() && (isMouseEnter || downloading)) {
Graphics2D g2d = (Graphics2D) g;
Composite oldComposite = g2d.getComposite();
//画白色的编辑层
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 20 / 100.0F));
g2d.setColor(COVER_COLOR);
g2d.fillRect(x, y, w, h);
g2d.setComposite(oldComposite);
//画编辑按钮图标
BufferedImage image = (process > 0 || downloading) ? WIDGET_DOWNLOADING_ICON : WIDGET_DOWNLOAD_ICON;
g2d.drawImage(
image,
(x + w / 2 - 12),
(y + h / 2 - 16),
image.getWidth(),
image.getHeight(),
null,
this
);
Stroke oldStroke = g2d.getStroke();
g2d.setStroke(XCreatorConstants.STROKE);
g2d.setColor(Color.decode("#419BF9"));
double arcAngle = downloading ? (36 + 360 * 0.9 * process) : 0.0;
g2d.drawArc(x + w / 2 - 12, y + h / 2 - 16, 24, 24, 90, -(int) arcAngle);
g2d.setColor(Color.WHITE);
g2d.setStroke(oldStroke);
}
boolean isUnusable = !getWidget().isCompatibleWithCurrentEnv();
if (isUnusable) {
paintUnusableMask((Graphics2D) g);
boolean isUnusable = !getWidget().isCompatibleWithCurrentEnv();
if (isUnusable) {
paintUnusableMask((Graphics2D) g);
}
}
if (this.parentPane != null) {
this.parentPane.refreshShowPaneUI();
}

19
designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/PreviewWidgetBlock.java

@ -12,7 +12,12 @@ import com.fr.design.mainframe.share.collect.ComponentCollector;
import com.fr.design.mainframe.share.ui.online.CarouselStateManger;
import com.fr.design.mainframe.share.ui.online.embed.AnimatePopupDialog;
import com.fr.design.mainframe.share.ui.online.embed.FirstDragAnimateStateManager;
import com.fr.form.main.Form;
import com.fr.form.main.WidgetGather;
import com.fr.form.share.constants.ShareComponentConstants;
import com.fr.form.ui.Widget;
import com.fr.form.ui.container.WAbsoluteLayout;
import com.fr.general.FRScreen;
import com.fr.module.ModuleContext;
import org.jetbrains.annotations.NotNull;
import javax.swing.ImageIcon;
@ -285,4 +290,18 @@ public abstract class PreviewWidgetBlock<T> extends JPanel implements MouseListe
}
protected void compatibleProcessAbsoluteLayoutResolution(Widget widget) {
Form.traversalWidget(widget, new WidgetGather() {
@Override
public void dealWith(Widget widget) {
((WAbsoluteLayout) widget).setDesigningResolution(FRScreen.p1440.getDimension());
}
@Override
public boolean dealWithAllCards() {
return true;
}
}, WAbsoluteLayout.class);
}
}

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

Loading…
Cancel
Save