Browse Source

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

feature/x
lucian 3 years ago
parent
commit
5c73cfbe2e
  1. 1
      build.gradle
  2. 4
      designer-base/src/main/java/com/fr/design/cell/CellStylePreviewPane.java
  3. 20
      designer-base/src/main/java/com/fr/design/data/datapane/connect/DatabaseConnectionPane.java
  4. 18
      designer-base/src/main/java/com/fr/design/gui/style/TextFormatPane.java
  5. 6
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java
  6. 46
      designer-base/src/main/java/com/fr/design/mainframe/DesignerUIModeConfig.java
  7. 4
      designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java
  8. 2
      designer-base/src/main/java/com/fr/design/mainframe/PX.java
  9. 2
      designer-base/src/main/java/com/fr/design/mainframe/PXReportLengthUNIT.java
  10. 27
      designer-base/src/main/java/com/fr/design/mainframe/loghandler/LogEventConverter.java
  11. 37
      designer-base/src/main/java/com/fr/design/mainframe/theme/edit/cell/CellStyleEditPane.java
  12. 4
      designer-base/src/main/java/com/fr/start/server/FineEmbedServerActivator.java
  13. 27
      designer-chart/src/main/resources/com/fr/design/editor/rich_editor.html
  14. 115
      designer-form/src/main/java/com/fr/design/actions/NewFormMobileAttrAction.java
  15. 109
      designer-form/src/main/java/com/fr/design/fit/JFormType.java
  16. 40
      designer-form/src/main/java/com/fr/design/fit/NewJForm.java
  17. 142
      designer-form/src/main/java/com/fr/design/fit/common/AdaptiveSwitchUtil.java
  18. 1266
      designer-form/src/main/java/com/fr/design/fit/common/BaseUtils.java
  19. 2030
      designer-form/src/main/java/com/fr/design/fit/common/NewFormStyle.java
  20. 20
      designer-form/src/main/java/com/fr/design/fit/common/NewUIModeAutoChangeLine.java
  21. 69
      designer-form/src/main/java/com/fr/design/fit/common/NewUIModeRotationDraw.java
  22. 835
      designer-form/src/main/java/com/fr/design/fit/common/PaintUtils.java
  23. 42
      designer-form/src/main/java/com/fr/design/fit/common/TemplateTool.java
  24. 26
      designer-form/src/main/java/com/fr/design/fit/toolbar/SwitchAction.java
  25. 1
      designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java
  26. 4
      designer-form/src/main/java/com/fr/design/mainframe/JForm.java
  27. 4
      designer-form/src/main/java/com/fr/design/parameter/RootDesignDefinePane.java
  28. 10
      designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/ElementEditorDefinePane.java
  29. 6
      designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRAbsoluteBodyLayoutDefinePane.java
  30. 4
      designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRAbsoluteLayoutDefinePane.java
  31. 8
      designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRFitLayoutDefinePane.java
  32. 46
      designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/ScanCodeMobileDefinePane.java
  33. 61
      designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/component/MobileTextFieldInputSettingPane.java
  34. 11
      designer-form/src/test/java/com/fr/design/fit/FormUIModeConfigTest.java
  35. 1
      designer-form/src/test/java/com/fr/design/fit/PXReportLengthUNITTest.java
  36. 1
      designer-form/src/test/java/com/fr/design/fit/PXTest.java
  37. 2
      designer-realize/src/main/java/com/fr/design/actions/columnrow/ColumnRowSizingAction.java
  38. 2
      designer-realize/src/main/java/com/fr/design/condition/WHPane.java
  39. 95
      designer-realize/src/main/java/com/fr/design/dscolumn/DSColumnAdvancedPane.java
  40. 27
      designer-realize/src/main/java/com/fr/design/fit/AdaptiveCellElementPainter.java
  41. 21
      designer-realize/src/main/java/com/fr/design/fit/NewUIModeCellElementPainter.java
  42. 70
      designer-realize/src/main/java/com/fr/design/fit/grid/GridHeaderWithBoundMouseHandler.java
  43. 194
      designer-realize/src/main/java/com/fr/design/fit/grid/GridLimitColumnMouseHandler.java
  44. 190
      designer-realize/src/main/java/com/fr/design/fit/grid/GridLimitRowMouseHandler.java
  45. 201
      designer-realize/src/main/java/com/fr/design/fit/grid/NewFormDesignerGridUI.java
  46. 41
      designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePane.java
  47. 13
      designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellExpandAttrPane.java
  48. 74
      designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellStylePane.java
  49. 59
      designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/StylePane.java
  50. 1
      designer-realize/src/main/java/com/fr/design/mainframe/form/FormElementCaseDesigner.java
  51. 52
      designer-realize/src/main/java/com/fr/design/mainframe/form/FormElementCasePaneDelegate.java
  52. 5
      designer-realize/src/main/java/com/fr/design/mainframe/form/FormReportComponentComposite.java
  53. 2
      designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java
  54. 13
      designer-realize/src/main/java/com/fr/design/report/ReportStylePane.java
  55. 18
      designer-realize/src/main/java/com/fr/design/sort/celldscolumn/CellDSColumnSortGroupPane.java
  56. 9
      designer-realize/src/main/java/com/fr/design/sort/common/AbstractSortGroupPane.java
  57. 32
      designer-realize/src/main/java/com/fr/design/sort/common/AbstractSortPane.java
  58. 165
      designer-realize/src/main/java/com/fr/design/sort/common/SortColumnRowPane.java
  59. 1
      designer-realize/src/main/java/com/fr/design/sort/common/SortUIExpandablePane.java
  60. 6
      designer-realize/src/main/java/com/fr/design/sort/expressionpane/CustomSequencePane.java
  61. 6
      designer-realize/src/main/java/com/fr/design/sort/expressionpane/CustomSequenceSortExpressionPane.java
  62. 4
      designer-realize/src/main/java/com/fr/design/sort/expressionpane/FormulaSortExpressionPane.java
  63. 8
      designer-realize/src/main/java/com/fr/design/sort/header/HeaderAreaPane.java
  64. 78
      designer-realize/src/main/java/com/fr/design/sort/header/HeaderSortRulePane.java
  65. 6
      designer-realize/src/main/java/com/fr/design/sort/header/SortHeaderPane.java
  66. 42
      designer-realize/src/main/java/com/fr/design/widget/ui/mobile/ScanCodeMobilePane.java
  67. 42
      designer-realize/src/main/java/com/fr/grid/AbstractGridHeaderMouseHandler.java
  68. 10
      designer-realize/src/main/java/com/fr/grid/DefaultGridUIProcessor.java
  69. 43
      designer-realize/src/main/java/com/fr/grid/Grid.java
  70. 77
      designer-realize/src/main/java/com/fr/grid/GridColumn.java
  71. 33
      designer-realize/src/main/java/com/fr/grid/GridColumnMouseHandler.java
  72. 2
      designer-realize/src/main/java/com/fr/grid/GridColumnUI.java
  73. 4
      designer-realize/src/main/java/com/fr/grid/GridCorner.java
  74. 73
      designer-realize/src/main/java/com/fr/grid/GridMouseAdapter.java
  75. 105
      designer-realize/src/main/java/com/fr/grid/GridRow.java
  76. 27
      designer-realize/src/main/java/com/fr/grid/GridRowMouseHandler.java
  77. 2
      designer-realize/src/main/java/com/fr/grid/GridRowUI.java
  78. 32
      designer-realize/src/main/java/com/fr/grid/GridUI.java
  79. 2
      designer-realize/src/main/java/com/fr/grid/GridUtils.java
  80. 16
      designer-realize/src/main/java/com/fr/nx/app/designer/menu/CalculateAttrPane.java
  81. 144
      designer-realize/src/main/java/com/fr/quickeditor/cellquick/CellDSColumnEditor.java
  82. 41
      designer-realize/src/test/java/com/fr/design/mainframe/app/DesignerAppUtilsTest.java

1
build.gradle

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

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

@ -123,7 +123,9 @@ public class CellStylePreviewPane extends JPanel {
Style.paintContent(g2d, paintText, style, width, height, resolution);
Style.paintBorder(g2d, style, width, height);
Style.paintBorder(g2d, style,
width - GraphHelper.getLineStyleSize(style.getBorderRight()) / 2F,
height - GraphHelper.getLineStyleSize(style.getBorderBottom()) / 2F);
}
@Override

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

@ -14,6 +14,7 @@ import com.fr.data.solution.processor.SolutionProcessor;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.ilable.ActionLabel;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
@ -33,6 +34,7 @@ import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.ScrollPaneConstants;
import javax.swing.SwingUtilities;
import javax.swing.SwingWorker;
import javax.swing.UIManager;
@ -59,6 +61,8 @@ import java.util.concurrent.ExecutionException;
* Database Connection pane.
*/
public abstract class DatabaseConnectionPane<E extends com.fr.data.impl.Connection> extends BasicBeanPane<com.fr.data.impl.Connection> {
private static int MAX_MAIN_PANEL_HEIGHT = 430;
private static int MAX_MAIN_PANEL_WIDTH = 675;
private UILabel message;
private UIButton okButton;
@ -333,11 +337,11 @@ public abstract class DatabaseConnectionPane<E extends com.fr.data.impl.Connecti
// Center
mainPanel = mainPanel();
mainPanel.setPreferredSize(new Dimension(675, 280));
northPane.add(mainPanel, BorderLayout.CENTER);
JPanel advancedPanel = FRGUIPaneFactory.createTopVerticalTitledBorderPane(Toolkit.i18nText("Fine-Design_Basic_Advanced"));
advancedPanel.setPreferredSize(new Dimension(675, 210));
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() {
@Override
@ -359,6 +363,16 @@ public abstract class DatabaseConnectionPane<E extends com.fr.data.impl.Connecti
} else {
//非jdbc配置布局保持不变
advancedPanel.setPreferredSize(new Dimension(MAX_MAIN_PANEL_WIDTH, 60));
if (mainPanel.getPreferredSize().height > MAX_MAIN_PANEL_HEIGHT || mainPanel.getPreferredSize().width > MAX_MAIN_PANEL_WIDTH) {
UIScrollPane jp = new
UIScrollPane(mainPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
jp.setPreferredSize(new Dimension(MAX_MAIN_PANEL_WIDTH, MAX_MAIN_PANEL_HEIGHT));
northPane.add(jp, BorderLayout.CENTER);
} else {
mainPanel.setPreferredSize(new Dimension(MAX_MAIN_PANEL_WIDTH, MAX_MAIN_PANEL_HEIGHT));
northPane.add(mainPanel, BorderLayout.CENTER);
}
// ChartSet
String[] defaultEncode = new String[]{Toolkit.i18nText("Fine-Design_Encode_Auto")};
charSetComboBox = new UIComboBox(ArrayUtils.addAll(defaultEncode, EncodeConstants.ENCODING_ARRAY));

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

@ -372,10 +372,20 @@ public class TextFormatPane extends AbstractBasicStylePane implements GlobalName
* update
*/
public Style update(Style style) {
if (ComparatorUtils.equals(globalNameListener.getGlobalName(), "textField")
|| ComparatorUtils.equals(globalNameListener.getGlobalName(), "typeComboBox")
|| ComparatorUtils.equals(globalNameListener.getGlobalName(), "roundingBox")) {
return style.deriveFormat(this.update());
return updateByGlobalNamedSetting(style);
}
private Style updateByGlobalNamedSetting(Style style) {
if (globalNameListener != null) {
String[] alterSettingNames = new String[] {"typeComboBox", "textField", "roundingBox"};
String globalSettingName = globalNameListener.getGlobalName();
if (StringUtils.isNotEmpty(globalSettingName)) {
for (String alterSettingName : alterSettingNames) {
if (ComparatorUtils.equals(alterSettingName, globalSettingName)) {
return style.deriveFormat(this.update());
}
}
}
}
return style;
}

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -1,5 +1,7 @@
package com.fr.design.mainframe.theme.edit.cell;
import com.fr.base.CellBorderStyle;
import com.fr.base.Style;
import com.fr.base.theme.settings.ThemedCellStyle;
import com.fr.design.cell.CellRectangleStylePreviewPane;
import com.fr.design.constants.UIConstants;
@ -87,12 +89,35 @@ public class CellStyleEditPane extends MultiTabPane<ThemedCellStyle> {
@Override
public ThemedCellStyle updateBean() {
AbstractBasicStylePane basicStylePane = (AbstractBasicStylePane) paneList.get(tabPane.getSelectedIndex());
this.cellStyle.setStyle(basicStylePane.update(this.cellStyle.getStyle()));
Style style = basicStylePane.update(this.cellStyle.getStyle());
CellBorderStyle borderStyle = createDefaultBorderStyleFromStyle(style);
if (ThemedFeatureController.isCellStyleSupportInnerBorder() && basicStylePane instanceof BorderPane) {
this.cellStyle.setCellBorderStyle(((BorderPane) basicStylePane).update());
borderStyle = ((BorderPane) basicStylePane).update();
}
this.cellStyle.setStyle(style);
this.cellStyle.setCellBorderStyle(borderStyle);
return this.cellStyle;
}
private CellBorderStyle createDefaultBorderStyleFromStyle(Style style) {
CellBorderStyle cellBorderStyle = new CellBorderStyle();
cellBorderStyle.setTopStyle(style.getBorderTop());
cellBorderStyle.setTopColor(style.getBorderTopColor());
cellBorderStyle.setBottomStyle(style.getBorderBottom());
cellBorderStyle.setBottomColor(style.getBorderBottomColor());
cellBorderStyle.setLeftStyle(style.getBorderLeft());
cellBorderStyle.setLeftColor(style.getBorderLeftColor());
cellBorderStyle.setRightStyle(style.getBorderRight());
cellBorderStyle.setRightColor(style.getBorderRightColor());
return cellBorderStyle;
}
@Override
public boolean accept(Object ob) {
@ -117,9 +142,11 @@ public class CellStyleEditPane extends MultiTabPane<ThemedCellStyle> {
JPanel previewPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
previewArea = new CellRectangleStylePreviewPane(true);
previewArea.setPreferredSize(new Dimension(223, 60));
previewPane.setBorder(BorderUtils.createTitleBorder(i18nText("Fine-Design_Basic_Preview")));
previewPane.add(previewArea, BorderLayout.CENTER);
previewArea.setPreferredSize(new Dimension(215, 48));
previewPane.setBorder(BorderFactory.createCompoundBorder(
BorderUtils.createTitleBorder(i18nText("Fine-Design_Basic_Preview")),
BorderFactory.createEmptyBorder(4, 4, 4, 4)));
previewPane.add(previewArea, BorderLayout.NORTH);
this.add(previewPane, BorderLayout.NORTH);

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

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

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

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

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

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

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

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

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

@ -2,19 +2,18 @@ package com.fr.design.fit;
import com.fr.base.DynamicUnitList;
import com.fr.base.Parameter;
import com.fr.design.actions.TemplateParameterAction;
import com.fr.design.designer.beans.AdapterBus;
import com.fr.design.designer.beans.LayoutAdapter;
import com.fr.design.designer.beans.adapters.layout.FRFitLayoutAdapter;
import com.fr.design.designer.beans.events.DesignerEditListener;
import com.fr.design.designer.beans.events.DesignerEvent;
import com.fr.design.actions.NewFormMobileAttrAction;
import com.fr.design.designer.creator.XComponent;
import com.fr.design.designer.creator.XCreatorUtils;
import com.fr.design.designer.creator.XElementCase;
import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.creator.XWTitleLayout;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.mainframe.DesignerUIModeConfig;
import com.fr.design.preview.DeveloperPreview;
import com.fr.design.preview.FormAdaptivePreview;
import com.fr.design.fit.toolbar.SwitchAction;
@ -22,12 +21,12 @@ import com.fr.design.fun.PreviewProvider;
import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.JForm;
import com.fr.design.mainframe.WidgetPropertyPane;
import com.fr.design.menu.ShortCut;
import com.fr.design.preview.FormPreview;
import com.fr.design.preview.MobilePreview;
import com.fr.design.utils.ComponentUtils;
import com.fr.file.FILE;
import com.fr.form.FormElementCaseProvider;
import com.fr.form.fit.NewFormMarkAttr;
import com.fr.form.main.Form;
import com.fr.form.ui.ElementCaseEditor;
import com.fr.stable.ArrayUtils;
@ -53,6 +52,8 @@ public class NewJForm extends JForm {
public NewJForm(Form form) {
super(form);
init();
//新建的模板都要加上新表单标志attr
form.addAttrMark(NewFormMarkAttr.createNewFormAttr());
}
public NewJForm(Form form, FILE file, Parameter[] parameters) {
@ -61,9 +62,7 @@ public class NewJForm extends JForm {
public NewJForm(Form form, FILE file) {
super(form, file);
if (DesignerUIModeConfig.getInstance().newUIMode()) {
init();
}
init();
}
public JFormType getJFormType() {
@ -74,22 +73,6 @@ public class NewJForm extends JForm {
this.jFormType = jFormType;
}
/**
* 模板菜单
*
* @return 返回菜单
*/
@Override
public ShortCut[] shortcut4TemplateMenu() {
if (this.index == FORM_TAB) {
return ArrayUtils.addAll(new ShortCut[]{new TemplateParameterAction(this), new NewFormMobileAttrAction(this), getReportFitAttrAction()}, new ShortCut[0]);
} else {
return ArrayUtils.addAll(new ShortCut[]{new TemplateParameterAction(this), new NewFormMobileAttrAction(this), getReportFitAttrAction()}, this.getElementCaseDesign().shortcut4TemplateMenu());
}
}
private void init() {
this.getFormDesign().addDesignerEditListener(new DesignerEditListener() {
private Rectangle oldRec;
@ -202,6 +185,13 @@ public class NewJForm extends JForm {
}
});
Form form = this.getTarget();
NewFormMarkAttr newFormMarkAttr = form.getAttrMark(NewFormMarkAttr.XML_TAG);
if (newFormMarkAttr == null) {
newFormMarkAttr = new NewFormMarkAttr();
}
this.setJFormType(JFormType.parseFormType(newFormMarkAttr.getType()));
}
@ -225,16 +215,14 @@ public class NewJForm extends JForm {
return new PreviewProvider[]{new FormPreview(), new MobilePreview()};
}
private SwitchAction switchAction;
public UIButton[] createExtraButtons() {
UIButton[] extraButtons = super.createExtraButtons();
return addAdaptiveSwitchButton(extraButtons);
}
private UIButton[] addAdaptiveSwitchButton(UIButton[] extraButtons) {
switchAction = new SwitchAction();
return ArrayUtils.addAll(extraButtons, new UIButton[]{switchAction.getToolBarButton()});
SwitchAction switchAction = new SwitchAction(this);
return ArrayUtils.addAll(extraButtons, switchAction.getToolBarButton());
}
public boolean isNewJFrom() {

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

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

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

File diff suppressed because it is too large Load Diff

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

File diff suppressed because it is too large Load Diff

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

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

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

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

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

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

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

@ -1,13 +1,9 @@
package com.fr.design.fit.common;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.file.MutilTempalteTabPane;
import com.fr.design.fit.DesignerUIModeConfig;
import com.fr.design.fit.JFormType;
import com.fr.design.fit.NewJForm;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.JForm;
import com.fr.design.mainframe.JTemplate;
import com.fr.event.Event;
import com.fr.event.Listener;
@ -23,31 +19,20 @@ import java.util.List;
* @create: 2020/09/03 14:19
*/
public class TemplateTool {
//和转换有关的所有代码都在这个监听器中
//在判断新老模式时,统一使用FormUIModeConfig.getInstance().newUIMode()进行判断
private static Listener<JTemplate> switchListener = new Listener<JTemplate>() {
private static final Listener<JTemplate> switchListener = new Listener<JTemplate>() {
@Override
public void on(Event event, JTemplate jTemplate) {
if (!(jTemplate instanceof JForm)) {
JFormType.OLD_TYPE.switchUIMode();
return;
}
JFormType currentType = JFormType.OLD_TYPE;
if (AdaptiveSwitchUtil.isSwitchJFromIng()) {
currentType = DesignerUIModeConfig.getInstance().newUIMode() ? JFormType.NEW_TYPE : JFormType.OLD_TYPE;
} else if (isNewJForm(jTemplate)) {
currentType = JFormType.NEW_TYPE;
}
//UI转换
currentType.switchUIMode();
//标志位转换
currentType.updateJFromTemplateType(jTemplate);
//预览方式转换
currentType.updatePreviewType(jTemplate);
jTemplate.setDesignerUIMode();
}
};
private static boolean isNewJForm(JTemplate jTemplate) {
public static Listener<JTemplate> getSwitchListener() {
return switchListener;
}
public static boolean isNewJForm(JTemplate jTemplate) {
if (jTemplate instanceof NewJForm) {
NewJForm newJForm = (NewJForm) jTemplate;
if (LightTool.containNewFormFlag(newJForm.getTarget()) || newJForm.getTarget().getTemplateID() == null) {
@ -57,8 +42,8 @@ public class TemplateTool {
return false;
}
public static Listener<JTemplate> getSwitchListener() {
return switchListener;
public static boolean isCurrentEditingNewJForm(){
return isNewJForm(HistoryTemplateListCache.getInstance().getCurrentEditingTemplate());
}
/**
@ -69,8 +54,7 @@ public class TemplateTool {
* @date: 2020/9/6 14:17
*/
public static JTemplate getCurrentEditingTemplate() {
JTemplate jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
return jTemplate;
return HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
}
/**
@ -159,4 +143,6 @@ public class TemplateTool {
}
}

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

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

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

@ -43,7 +43,6 @@ import com.fr.design.designer.properties.FormWidgetAuthorityEditPane;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.event.DesignerOpenedListener;
import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.fit.DesignerUIModeConfig;
import com.fr.design.form.util.XCreatorConstants;
import com.fr.design.fun.RightSelectionHandlerProvider;
import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus;

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

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

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

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

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

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

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

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

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

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

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

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

46
designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/ScanCodeMobileDefinePane.java

@ -1,24 +1,22 @@
package com.fr.design.widget.ui.designer.mobile;
import com.fr.base.mobile.MobileScanCodeAttr;
import com.fr.base.mobile.TextInputMode;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.foldablepane.UIExpandablePane;
import com.fr.design.gui.frpane.AttributeChangeListener;
import com.fr.design.gui.ibutton.ModeButtonGroup;
import com.fr.design.gui.ibutton.UIRadioButton;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.FormDesigner;
import com.fr.design.widget.ui.designer.mobile.component.MobileTextFieldInputSettingPane;
import com.fr.form.ui.TextEditor;
import java.awt.BorderLayout;
import javax.swing.*;
import java.awt.*;
public class ScanCodeMobileDefinePane extends MobileWidgetDefinePane {
private XCreator xCreator;
private ModeButtonGroup<TextInputMode> buttonGroup;
private MobileTextFieldInputSettingPane settingPane;
public ScanCodeMobileDefinePane(XCreator xCreator) {
this.xCreator = xCreator;
@ -27,39 +25,11 @@ public class ScanCodeMobileDefinePane extends MobileWidgetDefinePane {
@Override
public void initPropertyGroups(Object source) {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
JPanel mobileSettingsPane = getMobileSettingsPane();
this.add(mobileSettingsPane, BorderLayout.NORTH);
settingPane = new MobileTextFieldInputSettingPane();
this.add(new UIExpandablePane(Toolkit.i18nText("Fine-Design_Report_Advanced"), 280, 20, settingPane), BorderLayout.NORTH);
this.repaint();
}
private UIExpandablePane getMobileSettingsPane() {
JPanel panel = FRGUIPaneFactory.createVerticalFlowLayout_Pane(true, FlowLayout.LEADING, 0, 10);
buttonGroup = new ModeButtonGroup<>();
UIRadioButton scanCodeAndManualInput = new UIRadioButton(
com.fr.design.i18n.Toolkit.i18nText("Fine-Design__Mobile_Support_Scan_Code_And_Manual_Input"), true);
UIRadioButton onlyManualInput = new UIRadioButton(
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Only_Support_Manual_Input"), false);
UIRadioButton onlyScanCodeInput = new UIRadioButton(
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Only_Support_Scan_Code_Input"), false);
scanCodeAndManualInput.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
onlyManualInput.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
onlyScanCodeInput.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
buttonGroup.put(TextInputMode.SUPPORT_SCAN_CODE_And_MANUAL, scanCodeAndManualInput);
buttonGroup.put(TextInputMode.ONLY_SUPPORT_MANUAL, onlyManualInput);
buttonGroup.put(TextInputMode.ONLY_SUPPORT_SCAN_CODE, onlyScanCodeInput);
buttonGroup.add(scanCodeAndManualInput);
buttonGroup.add(onlyManualInput);
buttonGroup.add(onlyScanCodeInput);
panel.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0));
panel.add(scanCodeAndManualInput);
panel.add(onlyManualInput);
panel.add(onlyScanCodeInput);
final JPanel panelWrapper = FRGUIPaneFactory.createBorderLayout_S_Pane();
panelWrapper.add(panel, BorderLayout.NORTH);
return new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Advanced"), 280, 20,
panelWrapper);
}
private void bindListeners2Widgets() {
reInitAllListeners();
AttributeChangeListener changeListener = new AttributeChangeListener() {
@ -78,14 +48,14 @@ public class ScanCodeMobileDefinePane extends MobileWidgetDefinePane {
@Override
public void populate(FormDesigner designer) {
MobileScanCodeAttr mobileScanCodeAttr = ((TextEditor) xCreator.toData()).getMobileScanCodeAttr();
buttonGroup.setSelectButton(mobileScanCodeAttr.getTextInputMode());
settingPane.populateBean(mobileScanCodeAttr);
this.bindListeners2Widgets();
}
@Override
public void update() {
MobileScanCodeAttr mobileScanCodeAttr = ((TextEditor) xCreator.toData()).getMobileScanCodeAttr();
mobileScanCodeAttr.setTextInputMode(buttonGroup.getCurrentSelected());
settingPane.updateBean(mobileScanCodeAttr);
DesignerContext.getDesignerFrame().getSelectedJTemplate().fireTargetModified();
}

61
designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/component/MobileTextFieldInputSettingPane.java

@ -0,0 +1,61 @@
package com.fr.design.widget.ui.designer.mobile.component;
import com.fr.base.mobile.MobileScanCodeAttr;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import javax.swing.JPanel;
/**
* @author hades
* @version 11.0
* Created by hades on 2021/12/15
*/
public class MobileTextFieldInputSettingPane extends BasicBeanPane<MobileScanCodeAttr> {
private final UICheckBox manualInputCheckBox;
private final UICheckBox scanCodeCheckBox;
private final UICheckBox nfcInputCheckBox;
public MobileTextFieldInputSettingPane() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
JPanel settingPane = FRGUIPaneFactory.createVerticalFlowLayout_Pane(true, FlowLayout.LEADING, 0, 5);
manualInputCheckBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Mobile_Manual_Input"), true);
scanCodeCheckBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Mobile_Scan_Code_Input"), true);
nfcInputCheckBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Mobile_NFC_Input"), false);
settingPane.add(manualInputCheckBox);
settingPane.add(scanCodeCheckBox);
settingPane.add(nfcInputCheckBox);
this.add(settingPane, BorderLayout.NORTH);
}
@Override
public void populateBean(MobileScanCodeAttr ob) {
manualInputCheckBox.setSelected(ob.isSupportManual());
scanCodeCheckBox.setSelected(ob.isSupportScan());
nfcInputCheckBox.setSelected(ob.isSupportNFC());
}
@Override
public MobileScanCodeAttr updateBean() {
// do nothing
return null;
}
@Override
public void updateBean(MobileScanCodeAttr ob) {
ob.setSupportManual(manualInputCheckBox.isSelected());
ob.setSupportScan(scanCodeCheckBox.isSelected());
ob.setSupportNFC(nfcInputCheckBox.isSelected());
}
@Override
protected String title4PopupWindow() {
return null;
}
}

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

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

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

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

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

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

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

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

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

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

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

@ -13,6 +13,7 @@ import com.fr.design.formula.UIFormula;
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.icontainer.UIScrollPane;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.ispinner.UISpinner;
import com.fr.design.gui.itextfield.UITextField;
@ -20,6 +21,7 @@ import com.fr.design.gui.style.TextFormatPane;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.sort.celldscolumn.CellDSColumnSortPane;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.report.cell.CellElement;
import com.fr.report.cell.TemplateCellElement;
@ -47,14 +49,26 @@ public class DSColumnAdvancedPane extends BasicPane {
private UICheckBox verticalExtendableCheckBox;
private UICheckBox useMultiplyNumCheckBox;
private UISpinner multiNumSpinner;
private JPanel contentPane;
public DSColumnAdvancedPane() {
this(DSColumnPane.SETTING_ALL);
}
public DSColumnAdvancedPane(int setting) {
this.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
this.setLayout(FRGUIPaneFactory.createBorderLayout());
initContentPane(setting);
initScrollPane();
}
private void initScrollPane() {
ScrollPane scrollPane = new ScrollPane(contentPane);
this.add(scrollPane);
}
private void initContentPane(int setting) {
contentPane = new JPanel();
contentPane.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
contentPane.setLayout(FRGUIPaneFactory.createBorderLayout());
sortPane = new SortPane();
sortPane.setBorder(UITitledBorder.createBorderWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Sort_Sort_Order")));
@ -124,7 +138,7 @@ public class DSColumnAdvancedPane extends BasicPane {
TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED};
double[] columnSize = {TableLayout.FILL};
this.add(TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize), BorderLayout.CENTER);
contentPane.add(TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize), BorderLayout.CENTER);
}
@Override
@ -137,7 +151,7 @@ public class DSColumnAdvancedPane extends BasicPane {
return;
}
sortPane.populate(cellElement);
sortPane.populateBean(cellElement);
valuePane.populate(cellElement);
formatAttrPane.populate(cellElement);
@ -187,7 +201,7 @@ public class DSColumnAdvancedPane extends BasicPane {
return;
}
sortPane.update(cellElement);
sortPane.updateBean(cellElement);
valuePane.update(cellElement);
formatAttrPane.update(cellElement);
@ -223,66 +237,25 @@ public class DSColumnAdvancedPane extends BasicPane {
}
}
private static class SortPane extends SortFormulaPane {
private CellElement cellElement;
private static class ScrollPane extends UIScrollPane {
ScrollPane(Component component) {
super(component);
this.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
}
@Override
public void formulaAction() {
if (cellElement == null) {
return;
}
Object value = cellElement.getValue();
if (value == null || !(value instanceof DSColumn)) {
return;
}
String[] displayNames = DesignTableDataManager.getSelectedColumnNames(
DesignTableDataManager.getEditingTableDataSource(), ((DSColumn) value).getDSName());
showFormulaDialog(displayNames);
public Dimension getPreferredSize() {
return new Dimension(DSColumnPane.DEFAULT_DIMENSION.width - 20, DSColumnPane.DEFAULT_DIMENSION.height - 100);
}
}
void populate(CellElement cellElement) {
if (cellElement == null) {
return;
}
this.cellElement = cellElement;
Object value = cellElement.getValue();
if (value == null || !(value instanceof DSColumn)) {
return;
}
DSColumn dSColumn = (DSColumn) value;
int sort = dSColumn.getOrder();
this.sortOrderComboBox.setSortOrder(new SortOrder(sort));
String sortFormula = dSColumn.getSortFormula();
sortFormulaTextField.setText(sortFormula);
private static class SortPane extends CellDSColumnSortPane {
SortPane() {
this.setLayout(new FlowLayout(FlowLayout.LEFT));
}
public void update(CellElement cellElement) {
if (cellElement == null) {
return;
}
Object value = cellElement.getValue();
if (value == null || !(value instanceof DSColumn)) {
return;
}
DSColumn dSColumn = (DSColumn) (cellElement.getValue());
dSColumn.setOrder(this.sortOrderComboBox.getSortOrder().getOrder());
//lance:sort formula
String sText = null;
if (!(sortFormulaTextField.getText() == null || sortFormulaTextField.getText().trim().equals("") || sortFormulaTextField.getText().trim().equals("$$$"))) {
sText = new String(sortFormulaTextField.getText());
}
if (!(sText == null || sText.length() < 1)) {
dSColumn.setSortFormula(sText);
} else {
dSColumn.setSortFormula(null);
}
protected boolean needSortHeaderPane() {
return false;
}
}
@ -540,12 +513,12 @@ public class DSColumnAdvancedPane extends BasicPane {
public static class FormatAttrPane extends TextFormatPane {
protected void initLayout() {
JPanel settingPane = FRGUIPaneFactory.createBoxFlowInnerContainer_S_Pane(0, 4, 0);
JPanel settingPane = FRGUIPaneFactory.createBoxFlowInnerContainer_S_Pane(0, 4, 0);
settingPane.add(typeComboBox);
settingPane.add(textField);
settingPane.add(roundingBox);
addComponents(4, new JComponent[] { settingPane, previewLabel});
addComponents(4, new JComponent[]{settingPane, previewLabel});
}
@Override

27
designer-realize/src/main/java/com/fr/design/fit/AdaptiveCellElementPainter.java

@ -1,27 +0,0 @@
package com.fr.design.fit;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.fit.common.PaintUtils;
import com.fr.design.mainframe.JForm;
import com.fr.grid.CellElementPainter;
import com.fr.report.cell.TemplateCellElement;
import com.fr.report.elementcase.ElementCase;
import java.awt.Graphics2D;
/**
* Created by kerry on 2020-04-21
*/
public class AdaptiveCellElementPainter extends CellElementPainter {
public void paintContent(Graphics2D g2d, ElementCase report, TemplateCellElement ce, int width, int height, int resolution) {
if (HistoryTemplateListCache.getInstance().getCurrentEditingTemplate() instanceof JForm) {
PaintUtils.paintGridCellContent(g2d, ce, width, height, resolution);
}else {
super.paintContent(g2d, report, ce, width, height, resolution);
}
}
}

21
designer-realize/src/main/java/com/fr/design/fit/NewUIModeCellElementPainter.java

@ -0,0 +1,21 @@
package com.fr.design.fit;
import com.fr.design.fit.common.NewUIModeRotationDraw;
import com.fr.grid.CellElementPainter;
import com.fr.report.cell.TemplateCellElement;
import com.fr.report.core.PaintUtils;
import com.fr.report.elementcase.ElementCase;
import java.awt.Graphics2D;
/**
* Created by kerry on 2020-04-21
*/
public class NewUIModeCellElementPainter extends CellElementPainter {
public void paintContent(Graphics2D g2d, ElementCase report, TemplateCellElement ce, int width, int height, int resolution) {
PaintUtils.paintGridCellContent(g2d, ce, width, height, resolution, new NewUIModeRotationDraw());
}
}

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

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

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

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

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

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

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

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

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

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

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

@ -4,7 +4,6 @@ import com.fr.design.constants.LayoutConstants;
import com.fr.design.constants.UIConstants;
import com.fr.design.expand.ExpandLeftFatherPane;
import com.fr.design.expand.ExpandUpFatherPane;
import com.fr.design.expand.SortExpandAttrPane;
import com.fr.design.foldablepane.UIExpandablePane;
import com.fr.design.gui.ibutton.UIButtonGroup;
import com.fr.design.gui.icheckbox.UICheckBox;
@ -39,7 +38,6 @@ public class CellExpandAttrPane extends AbstractCellAttrPane {
private ExpandUpFatherPane rightFatherPane;
private UICheckBox horizontalExpandableCheckBox;
private UICheckBox verticalExpandableCheckBox;
private SortExpandAttrPane sortAfterExpand;
private JPanel layoutPane;
private JPanel basicPane;
private JPanel seniorPane;
@ -64,7 +62,6 @@ public class CellExpandAttrPane extends AbstractCellAttrPane {
rightFatherPane = new ExpandUpFatherPane();
horizontalExpandableCheckBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Report_ExpandD_Horizontal_Extendable"));
verticalExpandableCheckBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Report_ExpandD_Vertical_Extendable"));
sortAfterExpand = new SortExpandAttrPane();
initAllNames();
return layoutPane();
}
@ -124,16 +121,12 @@ public class CellExpandAttrPane extends AbstractCellAttrPane {
private JPanel seniorPane() {
double f = TableLayout.FILL;
double p = TableLayout.PREFERRED;
UILabel expendSort = new UILabel(Toolkit.i18nText("Fine-Design_Report_Expend_Sort"), SwingConstants.LEFT);
JPanel expendSortPane = new JPanel(new BorderLayout());
expendSortPane.add(expendSort, BorderLayout.NORTH);
horizontalExpandableCheckBox.setBorder(UIConstants.CELL_ATTR_ZEROBORDER);
verticalExpandableCheckBox.setBorder(UIConstants.CELL_ATTR_ZEROBORDER);
Component[][] components = new Component[][]{
new Component[]{null, null},
new Component[]{horizontalExpandableCheckBox, null},
new Component[]{verticalExpandableCheckBox, null},
new Component[]{expendSortPane, sortAfterExpand},
};
double[] rowSize = {p, p, p, p, p};
double[] columnSize = {p, f};
@ -174,8 +167,6 @@ public class CellExpandAttrPane extends AbstractCellAttrPane {
}
}
sortAfterExpand.populate(cellExpandAttr);
extraPane.populate(cellElement);
cellExpandSortPane.populateBean(cellElement);
}
@ -223,10 +214,6 @@ public class CellExpandAttrPane extends AbstractCellAttrPane {
}
}
if (ComparatorUtils.equals(getGlobalName(), Toolkit.i18nText("Fine-Design_Basic_ExpandD_Sort_After_Expand"))) {
sortAfterExpand.update(cellExpandAttr);
}
extraPane.update(cellElement);
cellExpandSortPane.updateBean(cellElement);
}

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

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

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

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

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

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

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

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

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

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

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

@ -11,7 +11,6 @@ import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.loghandler.DesignerLogger;
import com.fr.design.mainframe.loghandler.LogEventConverter;
import com.fr.design.mainframe.share.ui.base.MouseClickListener;
import com.fr.design.mainframe.toast.DesignerToastMsgUtil;
import com.fr.design.mainframe.toast.ToastMsgDialog;
@ -34,6 +33,7 @@ import com.fr.workspace.WorkContext;
import com.fr.workspace.Workspace;
import com.fr.workspace.base.WorkspaceConstants;
import com.fr.workspace.connect.WorkspaceConnectionInfo;
import com.fr.workspace.server.socket.LogEventConverter;
import io.socket.client.IO;
import io.socket.client.Socket;
import io.socket.emitter.Emitter;

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

@ -118,13 +118,12 @@ public class ReportStylePane extends BasicPane {
private JPanel createPreviewPane() {
JPanel container = FRGUIPaneFactory.createBorderLayout_S_Pane();
container.setBorder(createTitleBorder(Toolkit.i18nText("Fine-Design_Basic_Preview")));
container.setPreferredSize(new Dimension(container.getPreferredSize().width, 60));
JPanel content = FRGUIPaneFactory.createBorderLayout_S_Pane();
content.setBorder(BorderFactory.createEmptyBorder(4, 4, 2, 2));
previewArea.setPreferredSize(new Dimension(container.getPreferredSize().width, 42));
content.add(previewArea, BorderLayout.NORTH);
container.add(content, BorderLayout.NORTH);
container.setBorder(BorderFactory.createCompoundBorder(
createTitleBorder(Toolkit.i18nText("Fine-Design_Basic_Preview")),
BorderFactory.createEmptyBorder(4, 4, 4, 4)
));
previewArea.setPreferredSize(new Dimension(container.getPreferredSize().width, 40));
container.add(previewArea, BorderLayout.CENTER);
return container;
}

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

@ -15,22 +15,24 @@ public class CellDSColumnSortGroupPane extends AbstractSortGroupPane {
super(sortGroupPaneWidth, sortGroupPaneRightWidth);
}
public void populateDsColumn( DSColumn dsColumn){
public void populateDsColumn(DSColumn dsColumn) {
this.dsColumn = dsColumn;
}
@Override
protected AbstractSortItemPane refreshSortItemPane(int sortItemPaneWidth, int sortItemPaneRightWidth, SortExpression sortExpression) {
CellDSColumnSortItemPane cellDSColumnSortItemPane = new CellDSColumnSortItemPane( sortItemPaneWidth, sortItemPaneRightWidth);
CellDSColumnSortItemPane cellDSColumnSortItemPane = new CellDSColumnSortItemPane(sortItemPaneWidth, sortItemPaneRightWidth);
java.util.Map<String, TableDataWrapper> tableDataWrapperMap =
DesignTableDataManager.getAllEditingDataSet(HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getTarget());
TableDataWrapper tableDataWrapper = tableDataWrapperMap.get(dsColumn.getDSName());
java.util.List<String> columnNameList = tableDataWrapper.calculateColumnNameList();
String[] columnNames = new String[columnNameList.size()];
columnNameList.toArray(columnNames);
cellDSColumnSortItemPane.sortAreaUiComboBox.removeAllItems();
for (String columnName : columnNames) {
cellDSColumnSortItemPane.sortAreaUiComboBox.addItem(columnName);
if (tableDataWrapper != null) {
java.util.List<String> columnNameList = tableDataWrapper.calculateColumnNameList();
String[] columnNames = new String[columnNameList.size()];
columnNameList.toArray(columnNames);
cellDSColumnSortItemPane.sortAreaUiComboBox.removeAllItems();
for (String columnName : columnNames) {
cellDSColumnSortItemPane.sortAreaUiComboBox.addItem(columnName);
}
}
cellDSColumnSortItemPane.populateBean(sortExpression);
return cellDSColumnSortItemPane;

9
designer-realize/src/main/java/com/fr/design/sort/common/AbstractSortGroupPane.java

@ -18,6 +18,8 @@ import java.util.List;
public abstract class AbstractSortGroupPane extends JPanel implements ComponentChangeObserver {
private static final int SECOND_SORT_LENGTH_REDUCTION = 13;
protected int sortGroupPaneWidth;
protected int sortGroupPaneRightWidth;
List<SortExpression> sortExpressions;
@ -95,8 +97,8 @@ public abstract class AbstractSortGroupPane extends JPanel implements ComponentC
int sortItemPaneWidth = sortGroupPaneWidth;
int sortItemPaneRightWidth = sortGroupPaneRightWidth;
if (!mainSort) {
sortItemPaneWidth -= 12;
sortItemPaneRightWidth -= 12;
sortItemPaneWidth -= SECOND_SORT_LENGTH_REDUCTION;
sortItemPaneRightWidth -= SECOND_SORT_LENGTH_REDUCTION;
}
if (sortExpression == null) {
sortExpression = new CellSortExpression(selfSortArea);
@ -131,12 +133,13 @@ public abstract class AbstractSortGroupPane extends JPanel implements ComponentC
AddSortItemBar(AbstractSortGroupPane sortGroupPane) {
init();
this.sortGroupPane = sortGroupPane;
this.setLayout(new FlowLayout(FlowLayout.CENTER, 0, 5));
}
void init() {
uiButton = new UIButton(Toolkit.i18nText("Fine-Design_Sort_Add_Second_Sort"),
IconUtils.readIcon("/com/fr/design/images/sort/add.png"));
uiButton.setPreferredSize(new Dimension(sortGroupPaneWidth - 4, 20));
uiButton.setPreferredSize(new Dimension(sortGroupPaneWidth - 4, AbstractSortPane.PANE_COMPONENT_HEIGHT));
this.add(uiButton);
uiButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {

32
designer-realize/src/main/java/com/fr/design/sort/common/AbstractSortPane.java

@ -34,13 +34,19 @@ public abstract class AbstractSortPane extends JPanel {
private void initComponents() {
initSortGroupPane();
sortHeaderPane = new SortHeaderPane(sortPaneWidth, sortPaneRightWidth + 5);
this.add(sortHeaderPane);
if (needSortHeaderPane()) {
sortHeaderPane = new SortHeaderPane(sortPaneWidth, sortPaneRightWidth + 5);
this.add(sortHeaderPane);
}
}
protected abstract void initSortGroupPane();
protected boolean needSortHeaderPane() {
return true;
}
protected abstract CellSortAttr getCellSortAttr(TemplateCellElement cellElement);
public void populateBean(TemplateCellElement cellElement) {
@ -55,11 +61,13 @@ public abstract class AbstractSortPane extends JPanel {
sortExpressions.add(new CellSortExpression(selfSortArea));
}
sortGroupPane.populateBean(sortExpressions, selfSortArea);
SortHeader sortHeader = null;
if (cellSortAttr != null) {
sortHeader = cellSortAttr.getSortHeader();
if (needSortHeaderPane()) {
SortHeader sortHeader = null;
if (cellSortAttr != null) {
sortHeader = cellSortAttr.getSortHeader();
}
sortHeaderPane.populateBean(sortHeader, defaultHeaderArea);
}
sortHeaderPane.populateBean(sortHeader, defaultHeaderArea);
refresh();
}
@ -67,7 +75,7 @@ public abstract class AbstractSortPane extends JPanel {
int row = cellElement.getRow();
int column = cellElement.getColumn();
selfSortArea = ColumnRow.valueOf(column, row).toString();
if (row > 1) {
if (row > 0) {
defaultHeaderArea = ColumnRow.valueOf(column, row - 1).toString();
} else {
defaultHeaderArea = null;
@ -76,13 +84,15 @@ public abstract class AbstractSortPane extends JPanel {
public void updateBean(TemplateCellElement cellElement) {
List<SortExpression> sortExpressions = sortGroupPane.updateBean();
SortHeader sortHeader = sortHeaderPane.updateBean();
CellSortAttr cellSortAttr = getCellSortAttr(cellElement);
cellSortAttr.setSortExpressions(sortExpressions);
if (sortHeader != null) {
sortHeader.setSortArea(selfSortArea);
if (needSortHeaderPane()) {
SortHeader sortHeader = sortHeaderPane.updateBean();
if (sortHeader != null) {
sortHeader.setSortArea(selfSortArea);
}
cellSortAttr.setSortHeader(sortHeader);
}
cellSortAttr.setSortHeader(sortHeader);
}
protected void refresh() {

165
designer-realize/src/main/java/com/fr/design/sort/common/SortColumnRowPane.java

@ -1,5 +1,7 @@
package com.fr.design.sort.common;
import com.fr.base.Style;
import com.fr.base.background.ColorBackground;
import com.fr.base.svg.IconUtils;
import com.fr.design.designer.TargetComponent;
import com.fr.design.event.UIObserver;
@ -10,9 +12,18 @@ import com.fr.design.gui.ilable.UILabel;
import com.fr.design.mainframe.ElementCasePane;
import com.fr.design.selection.SelectionEvent;
import com.fr.design.selection.SelectionListener;
import com.fr.design.ui.util.UIUtil;
import com.fr.general.Background;
import com.fr.grid.selection.CellSelection;
import com.fr.grid.selection.Selection;
import com.fr.log.FineLoggerFactory;
import com.fr.report.cell.DefaultTemplateCellElement;
import com.fr.report.cell.TemplateCellElement;
import com.fr.report.cell.cellattr.CellExpandAttr;
import com.fr.report.cell.cellattr.core.group.DSColumn;
import com.fr.report.core.sort.common.CellSortable;
import com.fr.report.core.sort.header.SortHeader;
import com.fr.report.elementcase.TemplateElementCase;
import com.fr.stable.ColumnRow;
import com.fr.stable.EssentialUtils;
import com.fr.stable.StringUtils;
@ -21,6 +32,12 @@ import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
public class SortColumnRowPane extends JPanel implements UIObserver {
int paneWidth;
@ -75,7 +92,7 @@ public class SortColumnRowPane extends JPanel implements UIObserver {
void initSelectButton() {
selectButton = new UIButton(IconUtils.readIcon("/com/fr/design/images/buttonicon/select.png"));
selectButton.addActionListener(new SelectActionListener(this));
selectButton.addMouseListener(new SelectActionListener(this));
this.add(selectButton);
}
@ -90,7 +107,7 @@ public class SortColumnRowPane extends JPanel implements UIObserver {
refresh();
}
public void setColumnRow(ColumnRow columnRow){
public void setColumnRow(ColumnRow columnRow) {
populateBean(columnRow);
uiObserverListener.doChange();
}
@ -112,59 +129,145 @@ public class SortColumnRowPane extends JPanel implements UIObserver {
return true;
}
class SelectActionListener implements ActionListener {
class SelectActionListener extends MouseAdapter {
SortColumnRowPane columnRowPane;
Map<ColumnRow, Style> disableHeaderCellsStyleMap = new HashMap<>();
java.util.List<TemplateCellElement> tempHeaderCells = new ArrayList<>();
SelectActionListener(SortColumnRowPane columnRowPane) {
this.columnRowPane = columnRowPane;
}
@Override
public void actionPerformed(ActionEvent e) {
public void mouseClicked(MouseEvent e) {
ElementCasePane elementCasePane = getCurrentElementCase();
if (elementCasePane == null || isAlreadyAddListener) {
return;
}
oldSelection = (CellSelection) elementCasePane.getSelection();
elementCasePane.getGrid().setNotShowingTableSelectPane(false);
elementCasePane.setEditable(false);
elementCasePane.repaint(10);
prepareSelectHeader(elementCasePane);
gridSelectionChangeListener = new SelectionListener() {
@Override
public void selectionChanged(SelectionEvent e) {
Selection selection = elementCasePane.getSelection();
if (selection instanceof CellSelection) {
CellSelection cellselection = (CellSelection) selection;
ColumnRow cr = ColumnRow.valueOf(cellselection.getColumn(), cellselection.getRow());
elementCasePane.setOldSelecton(oldSelection);
columnRowPane.setColumnRow(cr);
}
elementCasePane.removeSelectionChangeListener(gridSelectionChangeListener);
isAlreadyAddListener = false;
elementCasePane.getGrid().setNotShowingTableSelectPane(true);
elementCasePane.setEditable(true);
elementCasePane.repaint();
completeSelectHeader(elementCasePane);
}
};
elementCasePane.addSelectionChangeListener(gridSelectionChangeListener);
isAlreadyAddListener = true;
}
}
private ElementCasePane getCurrentElementCase() {
try {
TargetComponent targetComponent
= HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getCurrentElementCasePane();
if (targetComponent instanceof ElementCasePane) {
return (ElementCasePane) targetComponent;
private void prepareSelectHeader(ElementCasePane elementCasePane) {
ashDisableHeaderCellsStyle(elementCasePane.getEditingElementCase());
oldSelection = (CellSelection) elementCasePane.getSelection();
elementCasePane.getGrid().setNotShowingTableSelectPane(false);
elementCasePane.setEditable(false);
elementCasePane.repaint(10);
}
private void completeSelectHeader(ElementCasePane elementCasePane) {
Selection selection = elementCasePane.getSelection();
if (selection instanceof CellSelection) {
CellSelection cellselection = (CellSelection) selection;
ColumnRow columnRow = ColumnRow.valueOf(cellselection.getColumn(), cellselection.getRow());
elementCasePane.setOldSelecton(oldSelection);
oldSelection.getQuickEditor(elementCasePane);
if (!disableHeaderCellsStyleMap.keySet().contains(columnRow)) {
columnRowPane.setColumnRow(columnRow);
}
restoreDisableHeaderCellsStyle(elementCasePane.getEditingElementCase());
}
elementCasePane.removeSelectionChangeListener(gridSelectionChangeListener);
isAlreadyAddListener = false;
elementCasePane.getGrid().setNotShowingTableSelectPane(true);
elementCasePane.setEditable(true);
elementCasePane.repaint();
}
private void ashDisableHeaderCellsStyle(TemplateElementCase elementCase) {
disableHeaderCellsStyleMap = new HashMap<>();
tempHeaderCells = new ArrayList<>();
Map<ColumnRow, TemplateCellElement> disableHeaderCellsMap = getDisableHeaderCellsMap(elementCase);
for (ColumnRow headerColumnRow : disableHeaderCellsMap.keySet()) {
TemplateCellElement headerCell = disableHeaderCellsMap.get(headerColumnRow);
if (headerCell == null) {
headerCell = new DefaultTemplateCellElement(headerColumnRow.column, headerColumnRow.row);
elementCase.addCellElement(headerCell);
tempHeaderCells.add(headerCell);
}
Style style = headerCell.getStyle();
disableHeaderCellsStyleMap.put(headerColumnRow, style);
style = style.deriveBackground(ColorBackground.getInstance(Color.gray));
headerCell.setStyle(style);
}
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e, e.getMessage());
}
return null;
private void restoreDisableHeaderCellsStyle(TemplateElementCase elementCase) {
try {
for (ColumnRow headerColumnRow : disableHeaderCellsStyleMap.keySet()) {
TemplateCellElement headerTemplateCellElement
= elementCase.getTemplateCellElement(headerColumnRow.column, headerColumnRow.row);
headerTemplateCellElement.setStyle(disableHeaderCellsStyleMap.get(headerColumnRow));
}
for (TemplateCellElement templateCellElement : tempHeaderCells) {
elementCase.removeCellElement(templateCellElement);
}
disableHeaderCellsStyleMap = new HashMap<>();
tempHeaderCells = new ArrayList<>();
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e, e.getMessage());
}
}
private Map<ColumnRow, TemplateCellElement> getDisableHeaderCellsMap(TemplateElementCase elementCase) {
Map<ColumnRow, TemplateCellElement> headerCellsMap = new HashMap<>();
Iterator iterator = elementCase.cellIterator();
while (iterator.hasNext()) {
TemplateCellElement templateCellElement = (TemplateCellElement) iterator.next();
CellExpandAttr cellExpandAttr = templateCellElement.getCellExpandAttr();
if (cellExpandAttr != null) {
handleDisableHeaderCell(elementCase, cellExpandAttr, headerCellsMap);
}
Object value = templateCellElement.getValue();
if (value instanceof DSColumn) {
handleDisableHeaderCell(elementCase, (DSColumn) value, headerCellsMap);
}
}
return headerCellsMap;
}
private void handleDisableHeaderCell(TemplateElementCase elementCase, CellSortable cellSortable, Map<ColumnRow, TemplateCellElement> headerCellsMap) {
if (cellSortable.getCellSortAttr() != null) {
SortHeader sortHeader = cellSortable.getCellSortAttr().getSortHeader();
if (sortHeader != null) {
String headerArea = sortHeader.getHeaderArea();
if (headerArea != null) {
ColumnRow headerColumnRow = ColumnRow.valueOf(headerArea);
ColumnRow columnRow = columnRowPane.updateBean();
if (!headerColumnRow.equals(columnRow)) {
TemplateCellElement headerCell
= elementCase.getTemplateCellElement(headerColumnRow.column, headerColumnRow.row);
headerCellsMap.put(headerColumnRow, headerCell);
}
}
}
}
}
private ElementCasePane getCurrentElementCase() {
try {
TargetComponent targetComponent
= HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getCurrentElementCasePane();
if (targetComponent instanceof ElementCasePane) {
return (ElementCasePane) targetComponent;
}
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e, e.getMessage());
}
return null;
}
}
protected void refresh() {
validate();
repaint();

1
designer-realize/src/main/java/com/fr/design/sort/common/SortUIExpandablePane.java

@ -31,6 +31,7 @@ public class SortUIExpandablePane extends JPanel {
initComponents();
wrapPane.setBorder(BorderFactory.createLineBorder(Color.gray, 1));
wrapPane.setBackground(Color.WHITE);
this.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 5));
}

6
designer-realize/src/main/java/com/fr/design/sort/expressionpane/CustomSequencePane.java

@ -1,6 +1,5 @@
package com.fr.design.sort.expressionpane;
import com.fr.base.BaseUtils;
import com.fr.base.svg.IconUtils;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.gui.ibutton.UIButton;
@ -29,11 +28,10 @@ public class CustomSequencePane extends JPanel {
protected void initComponents(int width) {
textField = new UITextField();
textField.setEditable(false);
textField.setPreferredSize(new Dimension(width - 20, 20));
textField.setPreferredSize(new Dimension(width - 20, AbstractSortPane.PANE_COMPONENT_HEIGHT));
Icon icon = IconUtils.readIcon("/com/fr/design/images/control/refresh.png");
button = new UIButton(icon);
button.setBackground(Color.RED);
button.setPreferredSize(new Dimension(24, 20));
button.setOpaque(false);
button.setCursor(new Cursor(Cursor.HAND_CURSOR));
button.addActionListener(new ActionListener() {
@ -48,7 +46,7 @@ public class CustomSequencePane extends JPanel {
}, new Dimension(700, 400)).setVisible(true);
}
});
button.setPreferredSize(new Dimension(24, AbstractSortPane.PANE_COMPONENT_HEIGHT));
button.setPreferredSize(new Dimension(20, AbstractSortPane.PANE_COMPONENT_HEIGHT));
this.add(textField);
this.add(button);

6
designer-realize/src/main/java/com/fr/design/sort/expressionpane/CustomSequenceSortExpressionPane.java

@ -13,10 +13,8 @@ public class CustomSequenceSortExpressionPane extends SortExpressionPane<CustomS
CustomSequencePane customSequencePane;
public CustomSequenceSortExpressionPane(int width, int rightWidth) {
this.setLayout(new FlowLayout(FlowLayout.RIGHT, 0, 0));
customSequencePane = new CustomSequencePane(rightWidth);
customSequencePane.setPreferredSize(new Dimension(width, AbstractSortPane.PANE_COMPONENT_HEIGHT));
customSequencePane.setBorder(BorderFactory.createEmptyBorder(0,0,0,3));
this.setLayout(new FlowLayout(FlowLayout.RIGHT, 2, 0));
customSequencePane = new CustomSequencePane(rightWidth + 5);
this.add(customSequencePane);
}

4
designer-realize/src/main/java/com/fr/design/sort/expressionpane/FormulaSortExpressionPane.java

@ -12,9 +12,9 @@ public class FormulaSortExpressionPane extends SortExpressionPane<FormulaSortExp
TinyFormulaPane tinyFormulaPane;
public FormulaSortExpressionPane(int width) {
this.setLayout(new FlowLayout(FlowLayout.RIGHT, 0, 1));
this.setLayout(new FlowLayout(FlowLayout.RIGHT, 2, 0));
tinyFormulaPane = new TinyFormulaPane();
tinyFormulaPane.setPreferredSize(new Dimension(width, AbstractSortPane.PANE_COMPONENT_HEIGHT));
tinyFormulaPane.setPreferredSize(new Dimension(width + 5, AbstractSortPane.PANE_COMPONENT_HEIGHT));
this.add(tinyFormulaPane);
}

8
designer-realize/src/main/java/com/fr/design/sort/header/HeaderAreaPane.java

@ -42,8 +42,8 @@ public class HeaderAreaPane extends JPanel {
this.add(areaJLayeredPane);
}
public void populateBean(ColumnRow columnRow) {
areaJLayeredPane.populateBean(columnRow);
public void populateBean(ColumnRow columnRow, boolean showHeaderArea) {
areaJLayeredPane.populateBean(columnRow, showHeaderArea);
}
public ColumnRow updateBean() {
@ -97,8 +97,8 @@ public class HeaderAreaPane extends JPanel {
this.add(jLayeredPane);
}
public void populateBean(ColumnRow columnRow) {
if (SortColumnRowPane.isAvailableColumnRow(columnRow)) {
public void populateBean(ColumnRow columnRow, boolean showHeaderArea) {
if (showHeaderArea) {
uiComboBox.setSelectedIndex(1);
} else {
uiComboBox.setSelectedIndex(0);

78
designer-realize/src/main/java/com/fr/design/sort/header/HeaderSortRulePane.java

@ -10,6 +10,7 @@ import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.theme.edit.ui.ColorListPane;
import com.fr.general.IOUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.report.core.sort.header.SortHeader;
import com.fr.report.core.sort.common.SortRule;
import org.apache.batik.transcoder.TranscoderInput;
@ -21,7 +22,10 @@ import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
public class HeaderSortRulePane extends JPanel {
private static final String ASC_ICON_TEMPLATE_PATH = "/com/fr/design/images/sort/asc.svg";
@ -33,10 +37,11 @@ public class HeaderSortRulePane extends JPanel {
UICheckBox ascUICheckBox;
UICheckBox desUICheckBox;
UICheckBox nosortUICheckBox;
static Map<String, String> originalSvgTextMap = new HashMap<>();
HeaderSortRulePane() {
initComponents();
initState();
initState(true);
this.setBorder(BorderFactory.createEmptyBorder(0, 15, 0, 15));
}
@ -62,12 +67,24 @@ public class HeaderSortRulePane extends JPanel {
double[] columnSize = {80, 30};
JPanel sortRuleItem = TableLayoutHelper.createCommonTableLayoutPane(components, rowSize, columnSize, 0);
this.add(sortRuleItem, BorderLayout.CENTER);
initUICheckBoxChange(ascUICheckBox, ascIconButton);
initUICheckBoxChange(desUICheckBox, desIconButton);
initUICheckBoxChange(nosortUICheckBox, nosortIconButton);
}
void initState() {
ascUICheckBox.setSelected(false);
desUICheckBox.setSelected(false);
nosortUICheckBox.setSelected(false);
void initUICheckBoxChange(UICheckBox uiCheckBox, IconButton iconButton) {
uiCheckBox.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
iconButton.setActiveState(uiCheckBox.isSelected());
}
});
}
void initState(boolean selected) {
ascUICheckBox.setSelected(selected);
desUICheckBox.setSelected(selected);
nosortUICheckBox.setSelected(selected);
ascIconButton.refreshIconLabelColor(new Color(33, 33, 34));
desIconButton.refreshIconLabelColor(new Color(33, 33, 34));
nosortIconButton.refreshIconLabelColor(new Color(33, 33, 34));
@ -81,21 +98,36 @@ public class HeaderSortRulePane extends JPanel {
Color color;
BufferedImage bufferedImage;
UIObserverListener uiObserverListener;
boolean activeState;
UILabel borderUiLabel;
IconButton(String iconTemplatePath) {
this.iconTemplatePath = iconTemplatePath;
initComponents();
}
public boolean isActiveState() {
return activeState;
}
public void setActiveState(boolean activeState) {
if (activeState) {
borderUiLabel.setBorder(BorderFactory.createLineBorder(Color.gray, 1));
colorButton.setVisible(true);
} else {
borderUiLabel.setBorder(null);
colorButton.setVisible(false);
}
this.activeState = activeState;
}
void initComponents() {
jLayeredPane = new JLayeredPane();
iconLabel = getIconLabel(iconTemplatePath);
UILabel emptyUiLabel = new UILabel();
emptyUiLabel.setSize(16, 16);
emptyUiLabel.setOpaque(true);
emptyUiLabel.setBackground(Color.WHITE);
borderUiLabel = new UILabel();
borderUiLabel.setSize(16, 16);
borderUiLabel.setOpaque(true);
borderUiLabel.setBackground(Color.WHITE);
iconLabel.setSize(16, 16);
colorButton = new ColorListPane.ColorButton(Color.CYAN);
colorButton.setSize(16, 16);
@ -110,7 +142,7 @@ public class HeaderSortRulePane extends JPanel {
jLayeredPane.setPreferredSize(new Dimension(16, 16));
jLayeredPane.add(iconLabel, JLayeredPane.POPUP_LAYER);
jLayeredPane.add(emptyUiLabel, JLayeredPane.MODAL_LAYER);
jLayeredPane.add(borderUiLabel, JLayeredPane.MODAL_LAYER);
jLayeredPane.add(colorButton, JLayeredPane.PALETTE_LAYER);
this.add(jLayeredPane);
}
@ -139,19 +171,27 @@ public class HeaderSortRulePane extends JPanel {
Icon getIcon(String iconPath, Color color) {
try {
InputStream inputStream = IOUtils.getResourceAsStream(iconPath, HeaderSortRulePane.class);
String svgText = getSvgText(inputStream);
svgText = svgText.replaceAll("\\{fillColor\\}", shiftColor(color));
InputStream svgInputStream = new ByteArrayInputStream(svgText.getBytes());
String originalSvgText = getOriginalSvgText(iconPath);
String svgText = originalSvgText.replaceAll("\\{fillColor\\}", shiftColor(color));
InputStream svgInputStream = new ByteArrayInputStream(svgText.getBytes(StandardCharsets.UTF_8));
TranscoderInput input = new TranscoderInput(svgInputStream);
bufferedImage = SVGTranscoder.createImage(1.0, input).getImage();
bufferedImage = SVGTranscoder.createImage(SVGIcon.SYSTEM_SCALE, input).getImage();
SVGIcon svgIcon = new SVGIcon(bufferedImage);
return svgIcon;
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e, e.getMessage());
}
return null;
}
String getOriginalSvgText(String iconPath) throws Exception {
String originalSvgText = originalSvgTextMap.get(iconPath);
if (originalSvgText == null) {
InputStream inputStream = IOUtils.getResourceAsStream(iconPath, HeaderSortRulePane.class);
originalSvgText = getSvgText(inputStream);
originalSvgTextMap.put(iconPath, originalSvgText);
}
return originalSvgText;
}
String shiftColor(Color color) {
@ -192,7 +232,7 @@ public class HeaderSortRulePane extends JPanel {
}
public void populateBean(SortHeader.SortItem[] sortItems) {
initState();
initState(sortItems == null);
if (sortItems != null) {
for (SortHeader.SortItem sortItem : sortItems) {
SortRule sortRule = sortItem.getSortRule();

6
designer-realize/src/main/java/com/fr/design/sort/header/SortHeaderPane.java

@ -1,5 +1,6 @@
package com.fr.design.sort.header;
import com.fr.design.sort.common.SortColumnRowPane;
import com.fr.report.core.sort.header.SortHeader;
import com.fr.stable.ColumnRow;
@ -33,16 +34,17 @@ public class SortHeaderPane extends JPanel {
public void populateBean(SortHeader sortHeader, String defaultHeaderArea) {
this.sortHeader = sortHeader;
boolean showHeaderArea = false;
ColumnRow columnRow = null;
SortHeader.SortItem[] sortItems = null;
String headerArea = defaultHeaderArea;
if (sortHeader != null) {
headerArea = sortHeader.getHeaderArea();
sortItems = sortHeader.getSortItems();
showHeaderArea = SortColumnRowPane.isAvailableColumnRow(ColumnRow.valueOf(headerArea));
}
columnRow = ColumnRow.valueOf(headerArea);
headerAreaPane.populateBean(columnRow);
headerAreaPane.populateBean(columnRow, showHeaderArea);
headerSettingPane.populateBean(sortItems);
}

42
designer-realize/src/main/java/com/fr/design/widget/ui/mobile/ScanCodeMobilePane.java

@ -1,63 +1,37 @@
package com.fr.design.widget.ui.mobile;
import com.fr.base.mobile.MobileScanCodeAttr;
import com.fr.base.mobile.TextInputMode;
import com.fr.design.foldablepane.UIExpandablePane;
import com.fr.design.gui.ibutton.ModeButtonGroup;
import com.fr.design.gui.ibutton.UIRadioButton;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.widget.mobile.WidgetMobilePane;
import com.fr.design.widget.ui.designer.mobile.component.MobileTextFieldInputSettingPane;
import com.fr.form.ui.TextEditor;
import com.fr.form.ui.Widget;
import java.awt.BorderLayout;
import javax.swing.*;
import java.awt.*;
public class ScanCodeMobilePane extends WidgetMobilePane {
private ModeButtonGroup<TextInputMode> buttonGroup;
private MobileTextFieldInputSettingPane settingPane;
@Override
protected void init() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.add(getMobileSettingPane(), BorderLayout.NORTH);
}
private UIExpandablePane getMobileSettingPane() {
JPanel panel = FRGUIPaneFactory.createVerticalFlowLayout_Pane(true, FlowLayout.LEADING, 0, 10);
buttonGroup = new ModeButtonGroup<>();
UIRadioButton scanCodeAndManualInput = new UIRadioButton(
com.fr.design.i18n.Toolkit.i18nText("Fine-Design__Mobile_Support_Scan_Code_And_Manual_Input"), true);
UIRadioButton onlyManualInput = new UIRadioButton(
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Only_Support_Manual_Input"), false);
UIRadioButton onlyScanCodeInput = new UIRadioButton(
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Only_Support_Scan_Code_Input"), false);
scanCodeAndManualInput.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
onlyManualInput.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
onlyScanCodeInput.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
buttonGroup.put(TextInputMode.SUPPORT_SCAN_CODE_And_MANUAL, scanCodeAndManualInput);
buttonGroup.put(TextInputMode.ONLY_SUPPORT_MANUAL, onlyManualInput);
buttonGroup.put(TextInputMode.ONLY_SUPPORT_SCAN_CODE, onlyScanCodeInput);
panel.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0));
panel.add(scanCodeAndManualInput);
panel.add(onlyManualInput);
panel.add(onlyScanCodeInput);
final JPanel panelWrapper = FRGUIPaneFactory.createBorderLayout_S_Pane();
panelWrapper.add(panel, BorderLayout.NORTH);
return new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Advanced"), 280, 20,
panelWrapper);
settingPane = new MobileTextFieldInputSettingPane();
this.add(new UIExpandablePane(Toolkit.i18nText("Fine-Design_Report_Advanced"), 280, 20, settingPane), BorderLayout.NORTH);
}
@Override
public void populate(Widget widget) {
MobileScanCodeAttr mobileScanCodeAttr = ((TextEditor) widget).getMobileScanCodeAttr();
buttonGroup.setSelectButton(mobileScanCodeAttr.getTextInputMode());
settingPane.populateBean(mobileScanCodeAttr);
}
@Override
public void update(Widget widget) {
MobileScanCodeAttr mobileScanCodeAttr = ((TextEditor) widget).getMobileScanCodeAttr();
mobileScanCodeAttr.setTextInputMode(buttonGroup.getCurrentSelected());
settingPane.updateBean(mobileScanCodeAttr);
}

42
designer-realize/src/main/java/com/fr/grid/AbstractGridHeaderMouseHandler.java

@ -4,7 +4,7 @@ import com.fr.base.BaseUtils;
import com.fr.base.DynamicUnitList;
import com.fr.base.vcs.DesignerMode;
import com.fr.design.DesignerEnvManager;
import com.fr.design.fit.DesignerUIModeConfig;
import com.fr.design.mainframe.DesignerUIModeConfig;
import com.fr.design.fun.ReportLengthUNITProvider;
import com.fr.design.gui.imenu.UIPopupMenu;
import com.fr.design.mainframe.ElementCasePane;
@ -36,6 +36,7 @@ import java.lang.reflect.Method;
* @since 2012-3-23上午11:54:14
*/
public abstract class AbstractGridHeaderMouseHandler extends MouseInputAdapter {
protected static final int FUZZY_EDGE = 10;
protected static final int SEPARATOR_GAP = 5;
protected GridHeader gHeader;
@ -50,16 +51,12 @@ public abstract class AbstractGridHeaderMouseHandler extends MouseInputAdapter {
private int dragIndex = 0;
private JToolTip tip = null;
private JWindow tipWindow = null;
protected int resolution = DesignerUIModeConfig.getInstance().getScreenResolution();
protected int resolution;
public AbstractGridHeaderMouseHandler(GridHeader gHeader) {
this.gHeader = gHeader;
if (gHeader instanceof GridColumn){
this.resolution = ((GridColumn)gHeader).getResolution();
}else {
this.resolution = ((GridRow)gHeader).getResolution();
}
}
this.resolution = gHeader.getResolution();
}
public void setStartMultiSelectIndex(int index) {
this.startMultiSelectIndex = index;
@ -437,6 +434,35 @@ public abstract class AbstractGridHeaderMouseHandler extends MouseInputAdapter {
tipWindow.repaint();
}
public int getDragIndex(MouseEvent evt) {
ElementCasePane elementCasePane = this.gHeader.getElementCasePane();
DynamicUnitList sizeList = getSizeList(elementCasePane.getEditingElementCase());
int scrollValue = getScrollValue(elementCasePane);
int scrollExtent = getScrollExtent(elementCasePane);
int endValue = scrollValue + scrollExtent + 1;
int beginValue = getBeginValue(elementCasePane);
double tmpSize1 = 0;
double tmpSize2;
double tmpIncreaseSize = 0;
for (int index = beginValue; index < endValue; index++) {
if (index == 0) {
index = scrollValue;
}
tmpSize1 += tmpIncreaseSize;
tmpIncreaseSize = sizeList.get(index).toPixD(resolution);
tmpSize2 = tmpSize1 + Math.max(1, tmpIncreaseSize);
if (isOnSeparatorLineIncludeZero(evt, tmpSize2, tmpIncreaseSize) || isOnNormalSeparatorLine(evt, tmpSize2)) {
return index;
}
}
return -1;
}
@Override
public void mouseMoved(MouseEvent evt) {
if (!gHeader.isEnabled()) {

10
designer-realize/src/main/java/com/fr/grid/DefaultGridUIProcessor.java

@ -1,10 +1,6 @@
package com.fr.grid;
import com.fr.design.fit.DesignerUIModeConfig;
import com.fr.design.fit.grid.NewFormDesignerGridUI;
import com.fr.design.fun.impl.AbstractGridUIProcessor;
import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.WidgetPropertyPane;
import javax.swing.plaf.ComponentUI;
@ -15,11 +11,7 @@ public class DefaultGridUIProcessor extends AbstractGridUIProcessor {
@Override
public ComponentUI appearanceForGrid(int resolution) {
if (DesignerUIModeConfig.getInstance().newUIMode()) {
FormDesigner designer = WidgetPropertyPane.getInstance().getEditingFormDesigner();
return new NewFormDesignerGridUI(designer, resolution);
}
return new GridUI(resolution);
}
}
}

43
designer-realize/src/main/java/com/fr/grid/Grid.java

@ -140,27 +140,46 @@ public class Grid extends BaseGridComponent {
// 是否绘制单元格内容区之外的网格线
private boolean showExtraGridLine = true;
public Grid(int resolution) {
protected int adsorbWidth;
protected int adsorbHeight;
private CellElementPainter cellElementPainter = new CellElementPainter();
public Grid(int resolution, int adsorbWidth, int adsorbHeight) {
this.resolution = resolution;
// 能触发processEvent,不管是否给component增加listener
enableEvents(AWTEvent.KEY_EVENT_MASK | AWTEvent.MOUSE_EVENT_MASK | AWTEvent.MOUSE_MOTION_EVENT_MASK);
GridKeyAction.initGridInputActionMap(this);
gridMouseAdapter = new GridMouseAdapter(this);
this.adsorbWidth = adsorbWidth;
this.adsorbHeight = adsorbHeight;
gridMouseAdapter = new GridMouseAdapter(this, adsorbWidth, adsorbHeight);
this.addMouseListener(gridMouseAdapter);
this.addMouseMotionListener(gridMouseAdapter);
this.addMouseWheelListener(gridMouseAdapter);
this.addKeyListener(new GridKeyListener(this));
// JDK1.4
this.setFocusTraversalKeysEnabled(false);
this.setOpaque(false);
this.updateUI();
}
public Grid(int resolution) {
this(resolution, 0, 0);
}
public CellElementPainter getCellElementPainter() {
return cellElementPainter;
}
public void setCellElementPainter(CellElementPainter cellElementPainter) {
this.cellElementPainter = cellElementPainter;
}
public void setResolution(int resolution) {
this.resolution = resolution;
}
@ -1482,4 +1501,20 @@ public class Grid extends BaseGridComponent {
public void setShowExtraGridLine(boolean showExtraGridLine) {
this.showExtraGridLine = showExtraGridLine;
}
public int getAdsorbWidth() {
return adsorbWidth;
}
public void setAdsorbWidth(int adsorbWidth) {
this.adsorbWidth = adsorbWidth;
}
public int getAdsorbHeight() {
return adsorbHeight;
}
public void setAdsorbHeight(int adsorbHeight) {
this.adsorbHeight = adsorbHeight;
}
}

77
designer-realize/src/main/java/com/fr/grid/GridColumn.java

@ -6,7 +6,7 @@ package com.fr.grid;
import java.awt.Dimension;
import com.fr.base.GraphHelper;
import com.fr.design.fit.DesignerUIModeConfig;
import com.fr.design.mainframe.DesignerUIModeConfig;
import com.fr.design.mainframe.ElementCasePane;
import com.fr.stable.StableUtils;
@ -19,48 +19,49 @@ import com.fr.stable.StableUtils;
public class GridColumn extends GridHeader<String> {
private GridColumnMouseHandler gridColumnMouseHandler;
private GridColumnMouseHandler gridColumnMouseHandler;
private int adsorbWidth;
public GridColumn(int resolution) {
super(resolution);
}
public GridColumn(int resolution) {
this(resolution, 0);
}
@Override
protected void initByConstructor() {
gridColumnMouseHandler = new GridColumnMouseHandler(this);
this.addMouseListener(gridColumnMouseHandler);
this.addMouseMotionListener(gridColumnMouseHandler);
this.updateUI();
}
public GridColumn(int resolution, int adsorbWidth) {
super(resolution);
this.adsorbWidth = adsorbWidth;
}
@Override
protected void initByConstructor() {
this.updateUI();
}
@Override
public String getDisplay(int index) {
return StableUtils.convertIntToABC(index + 1);
}
@Override
public String getDisplay(int index) {
return StableUtils.convertIntToABC(index + 1);
}
@Override
public void updateUI() {
this.removeMouseListener(gridColumnMouseHandler);
this.removeMouseMotionListener(gridColumnMouseHandler);
gridColumnMouseHandler = new GridColumnMouseHandler(this, adsorbWidth);
this.addMouseListener(gridColumnMouseHandler);
this.addMouseMotionListener(gridColumnMouseHandler);
this.setUI(new GridColumnUI(resolution));
}
@Override
public void updateUI() {
this.removeMouseListener(gridColumnMouseHandler);
this.removeMouseMotionListener(gridColumnMouseHandler);
gridColumnMouseHandler = new GridColumnMouseHandler(this);
this.addMouseListener(gridColumnMouseHandler);
this.addMouseMotionListener(gridColumnMouseHandler);
this.setUI(new GridColumnUI(resolution));
}
/**
* Gets the preferred size.
*/
@Override
public Dimension getPreferredSize() {
ElementCasePane reportPane = this.getElementCasePane();
float time = (float) reportPane.getResolution() / DesignerUIModeConfig.getInstance().getScreenResolution();
if (!reportPane.isColumnHeaderVisible()) {
return new Dimension(0, 0);
}
/**
* Gets the preferred size.
*/
@Override
public Dimension getPreferredSize() {
ElementCasePane reportPane = this.getElementCasePane();
float time = (float)reportPane.getResolution()/ DesignerUIModeConfig.getInstance().getScreenResolution();
if (!reportPane.isColumnHeaderVisible()) {
return new Dimension(0, 0);
}
return new Dimension(super.getPreferredSize().width, (int) (GraphHelper.getFontMetrics(this.getFont()).getHeight() * time + SIZE_ADJUST));
}
return new Dimension(super.getPreferredSize().width, (int) (GraphHelper.getFontMetrics(this.getFont()).getHeight() * time + SIZE_ADJUST));
}
}

33
designer-realize/src/main/java/com/fr/grid/GridColumnMouseHandler.java

@ -9,23 +9,34 @@ import java.awt.event.MouseEvent;
import javax.swing.SwingUtilities;
import com.fr.base.DynamicUnitList;
import com.fr.design.gui.imenu.UIPopupMenu;
import com.fr.design.mainframe.DesignerUIModeConfig;
import com.fr.design.mainframe.ElementCasePane;
import com.fr.grid.selection.CellSelection;
import com.fr.grid.selection.Selection;
import com.fr.report.ReportHelper;
import com.fr.report.elementcase.ElementCase;
import com.fr.report.elementcase.TemplateElementCase;
import com.fr.stable.ColumnRow;
import com.fr.stable.unit.FU;
import com.fr.stable.unit.UNIT;
/**
* peter:处理对GridColumn的Mouse事件.
*/
public class GridColumnMouseHandler extends AbstractGridHeaderMouseHandler {
private final int adsorbWidth;
public GridColumnMouseHandler(GridColumn gridColumn) {
super(gridColumn);
this.resolution = gridColumn.resolution;
this(gridColumn, 0);
}
public GridColumnMouseHandler(GridColumn gridColumn, int adsorbWidth) {
super(gridColumn);
this.adsorbWidth = adsorbWidth;
this.resolution = gridColumn.resolution;
}
public void setResolution(int resolution){
this.resolution = resolution;
}
@ -40,6 +51,24 @@ public class GridColumnMouseHandler extends AbstractGridHeaderMouseHandler {
}
}
@Override
public void mouseReleased(MouseEvent e) {
super.mouseReleased(e);
if (this.adsorbWidth <= 0) {
return;
}
ElementCasePane elementCasePane = this.gHeader.getElementCasePane();
TemplateElementCase editingElementCase = elementCasePane.getEditingElementCase();
double adsorbWidthWithResolution = this.adsorbWidth * (resolution * 1D / DesignerUIModeConfig.getInstance().getScreenResolution());
int dragIndex = getDragIndex(e);
if (Math.abs(e.getX() - adsorbWidthWithResolution) < FUZZY_EDGE && dragIndex >= 0) {
UNIT oldValue = editingElementCase.getColumnWidth(dragIndex);
editingElementCase.setColumnWidth(dragIndex, oldValue.add(FU.valueOfPix((int) (adsorbWidthWithResolution- e.getX()), resolution)));
}
elementCasePane.repaint();
}
protected int doChooseFrom() {
return CellSelection.CHOOSE_COLUMN;

2
designer-realize/src/main/java/com/fr/grid/GridColumnUI.java

@ -16,7 +16,7 @@ import com.fr.base.ScreenResolution;
import com.fr.base.vcs.DesignerMode;
import com.fr.cache.list.IntList;
import com.fr.design.constants.UIConstants;
import com.fr.design.fit.DesignerUIModeConfig;
import com.fr.design.mainframe.DesignerUIModeConfig;
import com.fr.design.mainframe.ElementCasePane;
import com.fr.design.roleAuthority.ReportAndFSManagePane;
import com.fr.grid.selection.Selection;

4
designer-realize/src/main/java/com/fr/grid/GridCorner.java

@ -4,9 +4,9 @@
package com.fr.grid;
import com.fr.base.GraphHelper;
import com.fr.base.ScreenResolution;
import com.fr.design.constants.UIConstants;
import com.fr.design.fit.DesignerUIModeConfig;
import com.fr.design.mainframe.DesignerUIModeConfig;
import com.fr.design.mainframe.ElementCasePane;
import javax.swing.event.MouseInputListener;

73
designer-realize/src/main/java/com/fr/grid/GridMouseAdapter.java

@ -2,11 +2,10 @@ package com.fr.grid;
import com.fr.base.BaseUtils;
import com.fr.base.DynamicUnitList;
import com.fr.base.ScreenResolution;
import com.fr.base.vcs.DesignerMode;
import com.fr.common.inputevent.InputEventBaseOnOS;
import com.fr.design.constants.UIConstants;
import com.fr.design.fit.DesignerUIModeConfig;
import com.fr.design.mainframe.DesignerUIModeConfig;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.EastRegionContainerPane;
import com.fr.design.mainframe.ElementCasePane;
@ -78,8 +77,18 @@ public class GridMouseAdapter implements MouseListener, MouseWheelListener, Mous
private int[] resizingBackupBounds = null;
protected GridMouseAdapter(Grid grid) {
private double adsorbWidth = 0D;
private double adsorbHeight = 0D;
private JWindow tipWindow = null;
private JToolTip tip = null;
protected GridMouseAdapter(Grid grid, double adsorbWidth, double adsorbHeight) {
this.grid = grid;
this.adsorbWidth = adsorbWidth;
this.adsorbHeight = adsorbHeight;
}
/**
@ -330,8 +339,63 @@ public class GridMouseAdapter implements MouseListener, MouseWheelListener, Mous
}
lastMouseMoveTime = systemCurrentTime;// 记录最后一次的时间.
mouseMoveOnGrid(evt.getX(), evt.getY());
dealAdsorb(evt);
}
private void dealAdsorb(final MouseEvent e) {
if (adsorbWidth <= 0 || adsorbHeight <= 0) {
return;
}
int verticalValue = grid.getVerticalValue();
int horizontalValue = grid.getHorizontalValue();
ElementCasePane reportPane = grid.getElementCasePane();
TemplateElementCase report = reportPane.getEditingElementCase();
DynamicUnitList columnWidthList = ReportHelper.getColumnWidthList(report);
DynamicUnitList rowHeightList = ReportHelper.getRowHeightList(report);
double width = adsorbWidth * (resolution * 1.0D / DesignerUIModeConfig.getInstance().getScreenResolution())
- columnWidthList.getRangeValue(0, horizontalValue).toPixI(this.grid.getResolution());
double height = adsorbHeight * (resolution * 1.0D / DesignerUIModeConfig.getInstance().getScreenResolution())
- rowHeightList.getRangeValue(0, verticalValue).toPixI(this.grid.getResolution());
if (Math.abs(e.getX() - width) < 5 && e.getY() >= 0 && e.getY() < height) {
Point convertPoint = new Point((int) width, 0);
SwingUtilities.convertPointToScreen(convertPoint, grid);
showToolTip(grid, e, adsorbWidth + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Px"), convertPoint);
return;
} else {
hideToolTip();
}
if (Math.abs(e.getY() - height) < 5 && e.getX() >= 0 && e.getX() < width) {
Point convertPoint = new Point(0, (int) height);
SwingUtilities.convertPointToScreen(convertPoint, grid);
showToolTip(grid, e, adsorbHeight + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Px"), convertPoint);
} else {
hideToolTip();
}
}
private void showToolTip(Grid grid, MouseEvent evt, String text, Point tipLocation) {
if (tipWindow == null) {
tipWindow = new JWindow();
tip = grid.createToolTip();
tip.setBorder(BorderFactory.createEmptyBorder());
tipWindow.getContentPane().add(tip, BorderLayout.CENTER);
}
tip.setTipText(text);
tip.setForeground(Color.decode("#88ACC6"));
tipWindow.setLocation(tipLocation.x, tipLocation.y);
tipWindow.pack();
tipWindow.setVisible(true);
}
private void hideToolTip() {
if (tipWindow != null) {
tipWindow.setVisible(false);
}
}
/**
* @param evt
*/
@ -879,7 +943,7 @@ public class GridMouseAdapter implements MouseListener, MouseWheelListener, Mous
* @param e
*/
public void mouseWheelMoved(MouseWheelEvent e) {
hideToolTip();
}
/**
@ -898,5 +962,6 @@ public class GridMouseAdapter implements MouseListener, MouseWheelListener, Mous
* @param e
*/
public void mouseExited(MouseEvent e) {
hideToolTip();
}
}

105
designer-realize/src/main/java/com/fr/grid/GridRow.java

@ -6,75 +6,74 @@ package com.fr.grid;
import java.awt.Dimension;
import com.fr.base.GraphHelper;
import com.fr.base.ScreenResolution;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.fit.DesignerUIModeConfig;
import com.fr.design.fun.GridUIProcessor;
import com.fr.design.mainframe.DesignerUIModeConfig;
import com.fr.design.mainframe.ElementCasePane;
import javax.swing.plaf.ComponentUI;
/**
* GridRow used to paint and edit grid row.
*
*
* @editor zhou
* @since 2012-3-22下午6:12:03
*/
public class GridRow extends GridHeader<Integer> {
private static final int MAX = 4;
private GridRowMouseHandler gridRowMouseHandler;
private static final int MAX = 4;
private int adsorbHeight;
private GridRowMouseHandler gridRowMouseHandler;
public GridRow(int resolution) {
this(resolution, 0);
}
public GridRow(int resolution, int adsorbHeight) {
super(resolution);
this.adsorbHeight = adsorbHeight;
}
public GridRow(int resolution) {
super(resolution);
}
@Override
protected void initByConstructor() {
gridRowMouseHandler = new GridRowMouseHandler(this);
this.addMouseListener(gridRowMouseHandler);
this.addMouseMotionListener(gridRowMouseHandler);
this.updateUI();
}
@Override
protected void initByConstructor() {
this.updateUI();
}
@Override
public Integer getDisplay(int index) {
return new Integer(index + 1);
}
@Override
public Integer getDisplay(int index) {
return new Integer(index + 1);
}
@Override
public void updateUI() {
this.removeMouseListener(gridRowMouseHandler);
this.removeMouseMotionListener(gridRowMouseHandler);
gridRowMouseHandler = new GridRowMouseHandler(this);
this.addMouseListener(gridRowMouseHandler);
this.addMouseMotionListener(gridRowMouseHandler);
this.setUI(new GridRowUI(resolution));
}
@Override
public void updateUI() {
this.removeMouseListener(gridRowMouseHandler);
this.removeMouseMotionListener(gridRowMouseHandler);
gridRowMouseHandler = new GridRowMouseHandler(this, adsorbHeight);
this.addMouseListener(gridRowMouseHandler);
this.addMouseMotionListener(gridRowMouseHandler);
this.setUI(new GridRowUI(resolution));
}
/**
* Gets the preferred size.
*/
@Override
public Dimension getPreferredSize() {
ElementCasePane reportPane = this.getElementCasePane();
float time = (float)reportPane.getResolution()/ DesignerUIModeConfig.getInstance().getScreenResolution();
if (!(reportPane.isRowHeaderVisible())) {
return new Dimension(0, 0);
}
/**
* Gets the preferred size.
*/
@Override
public Dimension getPreferredSize() {
ElementCasePane reportPane = this.getElementCasePane();
float time = (float) reportPane.getResolution() / DesignerUIModeConfig.getInstance().getScreenResolution();
if (!(reportPane.isRowHeaderVisible())) {
return new Dimension(0, 0);
}
int maxCharNumber = this.caculateMaxCharNumber(reportPane);
return new Dimension((int) (maxCharNumber * GraphHelper.getFontMetrics(this.getFont()).charWidth('M') * time), super.getPreferredSize().height);
}
int maxCharNumber = this.caculateMaxCharNumber(reportPane);
return new Dimension((int) (maxCharNumber * GraphHelper.getFontMetrics(this.getFont()).charWidth('M') * time), super.getPreferredSize().height);
}
/**
* Calculates max char number.
*/
private int caculateMaxCharNumber(ElementCasePane reportPane) {
int maxCharNumber = MAX;
maxCharNumber = Math.max(maxCharNumber, ("" + (reportPane.getGrid().getVerticalValue() + reportPane.getGrid().getVerticalExtent())).length() + 1);
/**
* Calculates max char number.
*/
private int caculateMaxCharNumber(ElementCasePane reportPane) {
int maxCharNumber = MAX;
maxCharNumber = Math.max(maxCharNumber, ("" + (reportPane.getGrid().getVerticalValue() + reportPane.getGrid().getVerticalExtent())).length() + 1);
return maxCharNumber;
}
return maxCharNumber;
}
}

27
designer-realize/src/main/java/com/fr/grid/GridRowMouseHandler.java

@ -9,20 +9,30 @@ import javax.swing.SwingUtilities;
import com.fr.base.DynamicUnitList;
import com.fr.design.gui.imenu.UIPopupMenu;
import com.fr.design.mainframe.DesignerUIModeConfig;
import com.fr.design.mainframe.ElementCasePane;
import com.fr.grid.selection.CellSelection;
import com.fr.grid.selection.Selection;
import com.fr.report.ReportHelper;
import com.fr.report.elementcase.ElementCase;
import com.fr.report.elementcase.TemplateElementCase;
import com.fr.stable.ColumnRow;
import com.fr.stable.unit.FU;
import com.fr.stable.unit.UNIT;
/**
* peter:处理对GridRow的Mouse事件.
*/
public class GridRowMouseHandler extends AbstractGridHeaderMouseHandler {
private final int adsorbHeight;
public GridRowMouseHandler(GridRow gridRow) {
this(gridRow, 0);
}
public GridRowMouseHandler(GridRow gridRow, int adsorbHeight) {
super(gridRow);
this.adsorbHeight = adsorbHeight;
}
@Override
@ -36,6 +46,23 @@ public class GridRowMouseHandler extends AbstractGridHeaderMouseHandler {
}
@Override
public void mouseReleased(MouseEvent e) {
super.mouseReleased(e);
if (this.adsorbHeight <= 0) {
return;
}
ElementCasePane elementCasePane = this.gHeader.getElementCasePane();
TemplateElementCase editingElementCase = elementCasePane.getEditingElementCase();
double adsorbHeightWithResolution = this.adsorbHeight * (resolution * 1D / DesignerUIModeConfig.getInstance().getScreenResolution());
int dragIndex = getDragIndex(e);
if (Math.abs(e.getY() - adsorbHeightWithResolution) < FUZZY_EDGE && dragIndex >= 0) {
UNIT oldValue = editingElementCase.getRowHeight(dragIndex);
editingElementCase.setRowHeight(dragIndex, oldValue.add(FU.valueOfPix((int) (adsorbHeightWithResolution - e.getY()), resolution)));
}
elementCasePane.repaint();
}
protected int doChooseFrom() {
return CellSelection.CHOOSE_ROW;
}

2
designer-realize/src/main/java/com/fr/grid/GridRowUI.java

@ -8,7 +8,7 @@ import javax.swing.JComponent;
import javax.swing.UIManager;
import javax.swing.plaf.ComponentUI;
import com.fr.design.fit.DesignerUIModeConfig;
import com.fr.design.mainframe.DesignerUIModeConfig;
import com.fr.stable.AssistUtils;
import com.fr.base.BaseUtils;
import com.fr.base.DynamicUnitList;

32
designer-realize/src/main/java/com/fr/grid/GridUI.java

@ -14,6 +14,7 @@ import com.fr.design.base.mode.DesignModeContext;
import com.fr.design.constants.UIConstants;
import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.DesignerUIModeConfig;
import com.fr.design.mainframe.ElementCasePane;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.roleAuthority.ReportAndFSManagePane;
@ -48,6 +49,7 @@ import com.fr.report.worksheet.WorkSheet;
import com.fr.stable.AssistUtils;
import com.fr.stable.ColumnRow;
import com.fr.stable.Constants;
import com.fr.stable.GraphDrawHelper;
import com.fr.stable.script.CalculatorUtils;
import com.fr.stable.unit.FU;
import com.fr.stable.unit.UNIT;
@ -92,6 +94,7 @@ public class GridUI extends ComponentUI {
protected int verticalEndValue;
protected int horizontalEndValue;
protected DrawFlowRect drawFlowRect;
// paint的辅助类
protected List paintCellElementList = new ArrayList();
protected List paintCellElementRectangleList = new ArrayList();
@ -1147,6 +1150,7 @@ public class GridUI extends ComponentUI {
Graphics2D g2d = (Graphics2D) g;
Grid grid = (Grid) c;
this.painter = grid.getCellElementPainter();
// 取得ElementCasePane.ElementCase
ElementCasePane elementCasePane = grid.getElementCasePane();
@ -1191,9 +1195,37 @@ public class GridUI extends ComponentUI {
paintWatermark(g2d, ((WorkSheet) elementCase).getBook());
}
//绘制吸附辅助线
paintAdsorbLines(g2d, grid);
grid.ajustEditorComponentBounds(); // refresh size
}
//绘制吸附辅助线
private void paintAdsorbLines(Graphics2D g2d, Grid grid) {
int verticalValue = grid.getVerticalValue();
int horizontalValue = grid.getHorizontalValue();
if (grid.getAdsorbWidth() <= 0 || grid.getAdsorbHeight() <= 0) {
return;
}
int width = (int) (grid.getAdsorbWidth() * (resolution * 1.0D / DesignerUIModeConfig.getInstance().getScreenResolution())
- columnWidthList.getRangeValue(0, horizontalValue).toPixI(resolution));
int height = (int) (grid.getAdsorbHeight() * (resolution * 1.0D / DesignerUIModeConfig.getInstance().getScreenResolution())
- rowHeightList.getRangeValue(0, verticalValue).toPixI(resolution));
drawBoundsLine(g2d, width, height);
}
private void drawBoundsLine(Graphics2D g2d, int width, int height) {
Paint oldPaint = g2d.getPaint();
Stroke oldStroke = g2d.getStroke();
g2d.setPaint(Color.black);
g2d.setStroke(GraphDrawHelper.getStroke(Constants.LINE_DASH_DOT));
g2d.drawLine( 0, height, width, height);
g2d.drawLine( width, 0, width, height);
g2d.setPaint(oldPaint);
g2d.setStroke(oldStroke);
}
// 绘制水印
private void paintWatermark(Graphics2D g2d, FineBook book) {
WatermarkAttr watermark = ReportUtils.getWatermarkAttrFromTemplateAndGlobal(book);

2
designer-realize/src/main/java/com/fr/grid/GridUtils.java

@ -5,7 +5,7 @@ import com.fr.base.ScreenResolution;
import com.fr.design.cell.clipboard.CellElementsClip;
import com.fr.design.cell.clipboard.ElementsTransferable;
import com.fr.design.cell.clipboard.FloatElementsClip;
import com.fr.design.fit.DesignerUIModeConfig;
import com.fr.design.mainframe.DesignerUIModeConfig;
import com.fr.design.mainframe.ElementCasePane;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.ComparatorUtils;

16
designer-realize/src/main/java/com/fr/nx/app/designer/menu/CalculateAttrPane.java

@ -39,6 +39,8 @@ public class CalculateAttrPane extends BasicBeanPane<CalculatorAttrMark> {
private UICheckBox multiSourceMode;
private UICheckBox cursorPage;
private UISpinner treeExpandLayer;
private JPanel treeConfigPanel;
@ -81,9 +83,17 @@ public class CalculateAttrPane extends BasicBeanPane<CalculatorAttrMark> {
multiSourceMode = new UICheckBox(InterProviderFactory.getProvider().getLocText("Fine-Plugin_Engine_Feature_Multi_Source"));
multiSourcePanel.add(multiSourceMode);
JPanel cursorPagePanel = FRGUIPaneFactory.createVerticalFlowLayout_S_Pane(true);
cursorPage = new UICheckBox(InterProviderFactory.getProvider().getLocText("Fine-Plugin_Engine_Calculate_Prefer_Cursor_Pagination"));
UILabel tipLabel = new UILabel(InterProviderFactory.getProvider().getLocText("Fine-Plugin_Engine_Calculate_Prefer_SQL_Pagination_Tip"));
tipLabel.setForeground(Color.GRAY);
cursorPagePanel.add(cursorPage);
cursorPagePanel.add(tipLabel);
// calculateAttrPanel.add(calculatedEndPanel);
calculateAttrPanel.add(queryCachePanel);
calculateAttrPanel.add(multiSourcePanel);
calculateAttrPanel.add(cursorPagePanel);
treeConfigPanel = FRGUIPaneFactory.createTitledBorderPane(
@ -144,6 +154,7 @@ public class CalculateAttrPane extends BasicBeanPane<CalculatorAttrMark> {
treeAsyncQuery.setSelected(attrMark.isTreeAsyncQuery());
treeExpandLayer.setValue(attrMark.getTreeExpandLayer());
multiSourceMode.setSelected(attrMark.isUseMultiSourceMode());
cursorPage.setSelected(!attrMark.isSqlPage());
isEmptyAttr = false;
}
@ -158,7 +169,8 @@ public class CalculateAttrPane extends BasicBeanPane<CalculatorAttrMark> {
return new CalculatorAttrMark(false, queryCache.isSelected())
.treeAsyncQuery(treeAsyncQuery.isSelected())
.treeExpandLayer((int) treeExpandLayer.getValue())
.useMultiSourceMode(multiSourceMode.isSelected());
.useMultiSourceMode(multiSourceMode.isSelected())
.useSqlPage(!cursorPage.isSelected());
}
/**
@ -197,4 +209,4 @@ public class CalculateAttrPane extends BasicBeanPane<CalculatorAttrMark> {
}
});
}
}
}

144
designer-realize/src/main/java/com/fr/quickeditor/cellquick/CellDSColumnEditor.java

@ -316,10 +316,6 @@ public class CellDSColumnEditor extends CellQuickEditor {
class DSColumnAdvancedEditorPane extends AbstractDSCellEditorPane {
/*pane begin*/
/**
* 排列顺序
*/
private ResultSetSortConfigPane sortPane;
/**
* 结果集筛选
*/
@ -377,7 +373,6 @@ public class CellDSColumnEditor extends CellQuickEditor {
@Override
public void update() {
if (cellElement != null) {
sortPane.update(cellElement);
valuePane.update(cellElement);
formatAttrPane.update(cellElement);
filterPane.update(cellElement);
@ -393,7 +388,6 @@ public class CellDSColumnEditor extends CellQuickEditor {
public void populate() {
if (cellElement != null) {
this.removeAttributeChangeListener();
sortPane.populate(cellElement);
valuePane.populate(cellElement);
formatAttrPane.populate(cellElement);
filterPane.populate(cellElement);
@ -500,10 +494,6 @@ public class CellDSColumnEditor extends CellQuickEditor {
protected JPanel createContentPane() {
JPanel contentPane = new JPanel(new BorderLayout());
this.setLayout(FRGUIPaneFactory.createBorderLayout());
//结果集排序
sortPane = new ResultSetSortConfigPane();
//结果筛选
filterPane = new ResultSetFilterConfigPane();
@ -538,7 +528,6 @@ public class CellDSColumnEditor extends CellQuickEditor {
multiNumPane.add(multiPane);
Component[][] components = new Component[][]{
{sortPane},
{filterPane},
{valuePane},
{formatAttrPane},
@ -552,9 +541,8 @@ public class CellDSColumnEditor extends CellQuickEditor {
JPanel advancePropertyPane = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, HGAP, VGAP);
contentPane.add(advancePropertyPane, BorderLayout.NORTH);
UIExpandablePane sortUIExpandablePane =
new UIExpandablePane(Toolkit.i18nText("Fine-Design_Report_Expend_Sort"),
new UIExpandablePane(Toolkit.i18nText("Fine-Design_Sort_Data_Column_Sort"),
223, 24, cellDSColumnSortPane = new CellDSColumnSortPane());
contentPane.add(sortUIExpandablePane, BorderLayout.CENTER);
return contentPane;
}
@ -569,136 +557,6 @@ public class CellDSColumnEditor extends CellQuickEditor {
}
}
/**
* 单元格元素>数据集>高级设置>结果排序设置面板
*
* @see com.fr.design.expand.SortExpandAttrPane
* @see DSColumnAdvancedPane.SortPane
*/
public class ResultSetSortConfigPane extends JPanel {
private static final String DEFAULT_VALUE = "=";
private JPanel contentPane;
private UIButtonGroup sortTypePane;
private JFormulaField formulaField;
private CardLayout cardLayout;
private JPanel centerPane;
public ResultSetSortConfigPane() {
this.setLayout(new BorderLayout());
Icon[] iconArray = {
IOUtils.readIcon("/com/fr/design/images/expand/none16x16.png"),
IOUtils.readIcon("/com/fr/design/images/expand/asc.png"),
IOUtils.readIcon("/com/fr/design/images/expand/des.png")
};
String[] nameArray = {Toolkit.i18nText("Fine-Design_Report_Sort_Original"), Toolkit.i18nText("Fine-Design_Report_Sort_Ascending"), Toolkit.i18nText("Fine-Design_Report_Sort_Descending")};
sortTypePane = new UIButtonGroup(iconArray);
sortTypePane.setAllToolTips(nameArray);
sortTypePane.setGlobalName(Toolkit.i18nText("Fine-Design_Basic_ExpandD_Sort_After_Expand"));
cardLayout = new CardLayout();
centerPane = new JPanel(cardLayout);
formulaField = new JFormulaField(DEFAULT_VALUE);
centerPane.add(new JPanel(), "none");
centerPane.add(formulaField, "content");
UILabel sortLabel = new UILabel(Toolkit.i18nText("Fine-Design_Report_Sort_Sort_Order"));
sortLabel.setPreferredSize(LABEL_DIMENSION);
sortTypePane.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
boolean noContent = sortTypePane.getSelectedIndex() == 0;
cardLayout.show(centerPane, noContent ? "none" : "content");
if (noContent) {
centerPane.setPreferredSize(new Dimension(0, 0));
TableLayoutHelper.modifyTableLayoutIndexVGap(contentPane, 2, 0);
} else {
centerPane.setPreferredSize(new Dimension(165, 20));
TableLayoutHelper.modifyTableLayoutIndexVGap(contentPane, 2, VGAP);
}
}
});
Component[][] components = new Component[][]{
new Component[]{sortLabel, sortTypePane},
new Component[]{null, centerPane}
};
double[] rowSize = {P, P}, columnSize = {P, F};
contentPane = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, HGAP, VGAP);
this.add(contentPane, BorderLayout.CENTER);
}
/**
* 刷新面板信息
*
* @param cellElement 单元格
*/
public void populate(TemplateCellElement cellElement) {
if (cellElement != null) {
Object value = cellElement.getValue();
if (value instanceof DSColumn) {
this.formulaField.populateElement(cellElement);
DSColumn dSColumn = (DSColumn) value;
int sort = dSColumn.getOrder();
this.sortTypePane.setSelectedIndex(sort);
boolean noContent = sortTypePane.getSelectedIndex() == 0;
cardLayout.show(centerPane, noContent ? "none" : "content");
if (noContent) {
centerPane.setPreferredSize(new Dimension(0, 0));
TableLayoutHelper.modifyTableLayoutIndexVGap(contentPane, 2, 0);
} else {
centerPane.setPreferredSize(new Dimension(156, 20));
TableLayoutHelper.modifyTableLayoutIndexVGap(contentPane, 2, VGAP);
}
String sortFormula = dSColumn.getSortFormula();
if (sortFormula != null && sortFormula.length() >= 1) {
this.formulaField.populate(sortFormula);
} else {
this.formulaField.populate(DEFAULT_VALUE);
}
}
}
}
/**
* 保存面板配置信息
*
* @param cellElement 单元格
*/
public void update(CellElement cellElement) {
if (cellElement != null) {
Object value = cellElement.getValue();
if (value instanceof DSColumn) {
DSColumn dSColumn = (DSColumn) value;
dSColumn.setOrder(this.sortTypePane.getSelectedIndex());
dSColumn.setSortFormula(this.formulaField.getFormulaText());
}
}
}
/**
* 添加事件监听器
*
* @param formulaChangeListener 公式输入框改动事件监听器
* @param changeListener 排序类型下拉框改动事件监听器
*/
public void addListener(UIObserverListener formulaChangeListener, ChangeListener changeListener) {
formulaField.addListener(formulaChangeListener);
sortTypePane.addChangeListener(changeListener);
}
/**
* 去除事件监听器
*
* @param changeListener 排序类型下拉框改动事件监听器
*/
public void removeListener(ChangeListener changeListener) {
formulaField.removeListener();
sortTypePane.removeChangeListener(changeListener);
}
}
/**
* 单元格元素>数据集>高级设置>结果集筛选设置面板
*

41
designer-realize/src/test/java/com/fr/design/mainframe/app/DesignerAppUtilsTest.java

@ -3,15 +3,11 @@ package com.fr.design.mainframe.app;
import com.fr.invoke.Reflect;
import com.fr.plugin.context.PluginMarker;
import com.fr.plugin.context.PluginMarkerAdapter;
import com.fr.plugin.engine.remote.PluginRemoteSync;
import com.fr.stable.TemplateIOErrorContextHolder;
import com.fr.third.guava.collect.Multimap;
import org.easymock.EasyMock;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.api.easymock.PowerMock;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import java.util.Collection;
@ -24,13 +20,12 @@ import java.util.HashSet;
* Created by vito on 2021/5/31
*/
@RunWith(PowerMockRunner.class)
@PrepareForTest({PluginRemoteSync.class})
public class DesignerAppUtilsTest {
@Test
public void testDealWithErrorDetailMultiLineAndCache() {
TemplateIOErrorContextHolder.registerPluginNameMap(new HashMap<String, String>() {{
put("2", "好用的插件");
}},new HashSet<>());
}}, new HashSet<>());
TemplateIOErrorContextHolder.addNeedEnablePlugin(PluginMarkerAdapter.create("1", "1.0", "1插件"));
TemplateIOErrorContextHolder.addNeedInstallPlugin(PluginMarker.create("2", "1.0"));
TemplateIOErrorContextHolder.addNeedInstallPlugin(PluginMarker.create("3", "1.0"));
@ -47,7 +42,7 @@ public class DesignerAppUtilsTest {
public void testInvalidatePlugins() {
TemplateIOErrorContextHolder.registerPluginNameMap(new HashMap<String, String>() {{
put("2", "好用的插件");
}},new HashSet<>());
}}, new HashSet<>());
TemplateIOErrorContextHolder.addNeedEnablePlugin(PluginMarkerAdapter.create("1", "1.0", "1插件"));
TemplateIOErrorContextHolder.addNeedInstallPlugin(PluginMarker.create("2", "1.0"));
TemplateIOErrorContextHolder.addNeedInstallPlugin(PluginMarker.create("3", "1.0"));
@ -60,19 +55,19 @@ public class DesignerAppUtilsTest {
}
@Test
public void testRearrange(){
public void testRearrange() {
// 远程插件模拟注册
PluginRemoteSync pluginRemoteSync = EasyMock.createMock(PluginRemoteSync.class);
EasyMock.expect(pluginRemoteSync.getPluginRemoteStatusByIdIndex()).andReturn(new HashMap<String, PluginRemoteSync.PluginStatus>(){{
put("com.fr.plugin1", Reflect.on(PluginRemoteSync.PluginStatus.class).call("create","com.fr.plugin1","1",true).get());
put("com.fr.plugin2", Reflect.on(PluginRemoteSync.PluginStatus.class).call("create","com.fr.plugin2","1",true).get());
put("com.fr.plugin3", Reflect.on(PluginRemoteSync.PluginStatus.class).call("create","com.fr.plugin3","1",false).get());
put("com.fr.plugin4", Reflect.on(PluginRemoteSync.PluginStatus.class).call("create","com.fr.plugin4","1",false).get());
}}).anyTimes();
EasyMock.replay(pluginRemoteSync);
PowerMock.mockStaticPartial(PluginRemoteSync.class, "getInstance");
EasyMock.expect(PluginRemoteSync.getInstance()).andReturn(pluginRemoteSync).anyTimes();
PowerMock.replay(PluginRemoteSync.class);
// PluginRemoteSync pluginRemoteSync = EasyMock.createMock(PluginRemoteSync.class);
// EasyMock.expect(pluginRemoteSync.getPluginRemoteStatusByIdIndex()).andReturn(new HashMap<String, PluginRemoteSync.PluginStatus>(){{
// put("com.fr.plugin1", Reflect.on(PluginRemoteSync.PluginStatus.class).call("create","com.fr.plugin1","1",true).get());
// put("com.fr.plugin2", Reflect.on(PluginRemoteSync.PluginStatus.class).call("create","com.fr.plugin2","1",true).get());
// put("com.fr.plugin3", Reflect.on(PluginRemoteSync.PluginStatus.class).call("create","com.fr.plugin3","1",false).get());
// put("com.fr.plugin4", Reflect.on(PluginRemoteSync.PluginStatus.class).call("create","com.fr.plugin4","1",false).get());
// }}).anyTimes();
// EasyMock.replay(pluginRemoteSync);
// PowerMock.mockStaticPartial(PluginRemoteSync.class, "getInstance");
// EasyMock.expect(PluginRemoteSync.getInstance()).andReturn(pluginRemoteSync).anyTimes();
// PowerMock.replay(PluginRemoteSync.class);
// 本地插件模拟检查
TemplateIOErrorContextHolder.registerPluginNameMap(new HashMap<String, String>() {{
@ -81,7 +76,7 @@ public class DesignerAppUtilsTest {
put("com.fr.plugin3", "好用的插件3");
put("com.fr.plugin4", "好用的插件4");
put("com.fr.plugin5", "好用的插件5");
}},new HashSet<>());
}}, new HashSet<>());
// unknown
TemplateIOErrorContextHolder.addNeedInstallPlugin(PluginMarker.create("com.fr.plugin7", "1"));
// disable
@ -93,14 +88,14 @@ public class DesignerAppUtilsTest {
Multimap<String, PluginMarkerAdapter> pendingPlugins = TemplateIOErrorContextHolder.getPendingPlugin();
Reflect.on(DesignerAppUtils.class).call("rearrange",pendingPlugins).get();
Assert.assertEquals(1,pendingPlugins.get(TemplateIOErrorContextHolder.UNKNOWN_PLUGIN).size());
Reflect.on(DesignerAppUtils.class).call("rearrange", pendingPlugins).get();
Assert.assertEquals(1, pendingPlugins.get(TemplateIOErrorContextHolder.UNKNOWN_PLUGIN).size());
Collection<PluginMarkerAdapter> pluginMarkerAdapters = pendingPlugins.get(TemplateIOErrorContextHolder.DISABLE_PLUGIN);
Assert.assertEquals(2, pluginMarkerAdapters.size());
pluginMarkerAdapters.contains(PluginMarker.create("com.fr.plugin3", "1"));
pluginMarkerAdapters.contains(PluginMarker.create("com.fr.plugin4", "1"));
Collection<PluginMarkerAdapter> pluginMarkerAdapters1 = pendingPlugins.get(TemplateIOErrorContextHolder.NOT_INSTALLED_PLUGIN);
Assert.assertEquals(1, pluginMarkerAdapters1.size());
pluginMarkerAdapters1.contains(PluginMarker.create("com.fr.plugin5","1"));
pluginMarkerAdapters1.contains(PluginMarker.create("com.fr.plugin5", "1"));
}
}
Loading…
Cancel
Save