Browse Source

Pull request #3548: REPORT-47034 FRM新前端&新自适应合入主JAR

Merge in DESIGN/design from ~KERRY/design_10.0:feature/x to feature/x

* commit '1bc69b0b2448de3f74a32e36b305d17ae9fc435b':
  添加单元测试
  REPORT-47034 FRM新前端&新自适应合入主JAR
research/11.0
ju|剧浩宇 4 years ago
parent
commit
95492ec5d8
  1. 83
      designer-form/src/main/java/com/fr/design/actions/FormFitAttrAction.java
  2. 115
      designer-form/src/main/java/com/fr/design/actions/NewFormMobileAttrAction.java
  3. 6
      designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteLayout.java
  4. 4
      designer-form/src/main/java/com/fr/design/designer/creator/XWFitLayout.java
  5. 124
      designer-form/src/main/java/com/fr/design/fit/DesignerUIModeConfig.java
  6. 36
      designer-form/src/main/java/com/fr/design/fit/FitStateCompatible.java
  7. 133
      designer-form/src/main/java/com/fr/design/fit/JFormType.java
  8. 285
      designer-form/src/main/java/com/fr/design/fit/NewJForm.java
  9. 27
      designer-form/src/main/java/com/fr/design/fit/PX.java
  10. 32
      designer-form/src/main/java/com/fr/design/fit/PXReportLengthUNIT.java
  11. 91
      designer-form/src/main/java/com/fr/design/fit/attrpane/ElementEditorExtendDefinePane.java
  12. 161
      designer-form/src/main/java/com/fr/design/fit/attrpane/FRAbsoluteBodyLayoutExtendDefinePane.java
  13. 27
      designer-form/src/main/java/com/fr/design/fit/attrpane/FRAbsoluteLayoutExtendDefinePane.java
  14. 246
      designer-form/src/main/java/com/fr/design/fit/attrpane/FRFitLayoutExtendDefinePane.java
  15. 107
      designer-form/src/main/java/com/fr/design/fit/attrpane/PcFitExpandablePane.java
  16. 303
      designer-form/src/main/java/com/fr/design/fit/attrpane/RootDesignExtendDefinePane.java
  17. 225
      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. 45
      designer-form/src/main/java/com/fr/design/fit/common/FormDesignerUtil.java
  20. 177
      designer-form/src/main/java/com/fr/design/fit/common/LayoutTool.java
  21. 2030
      designer-form/src/main/java/com/fr/design/fit/common/NewFormStyle.java
  22. 835
      designer-form/src/main/java/com/fr/design/fit/common/PaintUtils.java
  23. 214
      designer-form/src/main/java/com/fr/design/fit/common/TemplateTool.java
  24. 303
      designer-form/src/main/java/com/fr/design/fit/menupane/BrowserFitAttrPane.java
  25. 76
      designer-form/src/main/java/com/fr/design/fit/menupane/FitPreviewPane.java
  26. 80
      designer-form/src/main/java/com/fr/design/fit/menupane/FitRadioGroup.java
  27. 17
      designer-form/src/main/java/com/fr/design/fit/menupane/FontRadioGroup.java
  28. 58
      designer-form/src/main/java/com/fr/design/fit/menupane/FormFitAttrPane.java
  29. 287
      designer-form/src/main/java/com/fr/design/fit/toolbar/SwitchAction.java
  30. 4
      designer-form/src/main/java/com/fr/design/mainframe/CoverReportPane.java
  31. 28
      designer-form/src/main/java/com/fr/design/mainframe/FormArea.java
  32. 3
      designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java
  33. 53
      designer-form/src/main/java/com/fr/design/preview/DeveloperPreview.java
  34. 54
      designer-form/src/main/java/com/fr/design/preview/FormAdaptivePreview.java
  35. BIN
      designer-form/src/main/resources/com/fr/design/form/images/developer_preview.png
  36. BIN
      designer-form/src/main/resources/com/fr/design/form/images/developer_preview24.png
  37. BIN
      designer-form/src/main/resources/com/fr/design/form/images/icon_form_tab.png
  38. BIN
      designer-form/src/main/resources/com/fr/design/form/images/icon_switch.png
  39. BIN
      designer-form/src/main/resources/com/fr/design/form/images/icon_switch_disable.png
  40. BIN
      designer-form/src/main/resources/com/fr/design/form/images/icon_switch_new_ui.png
  41. BIN
      designer-form/src/main/resources/com/fr/design/form/images/icon_switch_old_ui.png
  42. BIN
      designer-form/src/main/resources/com/fr/design/form/images/loading.png
  43. 24
      designer-form/src/test/java/com/fr/design/fit/FitStateCompatibleTest.java
  44. 22
      designer-form/src/test/java/com/fr/design/fit/FormUIModeConfigTest.java
  45. 49
      designer-form/src/test/java/com/fr/design/fit/PXReportLengthUNITTest.java
  46. 64
      designer-form/src/test/java/com/fr/design/fit/PXTest.java
  47. 38
      designer-form/src/test/java/com/fr/design/fit/common/FormDesignerUtilTest.java
  48. 28
      designer-form/src/test/java/com/fr/design/preview/DeveloperPreviewTest.java
  49. 30
      designer-form/src/test/java/com/fr/design/preview/FormAdaptivePreviewTest.java
  50. 7
      designer-realize/src/main/java/com/fr/design/actions/columnrow/ColumnRowSizingAction.java
  51. 10
      designer-realize/src/main/java/com/fr/design/condition/WHPane.java
  52. 27
      designer-realize/src/main/java/com/fr/design/fit/AdaptiveCellElementPainter.java
  53. 123
      designer-realize/src/main/java/com/fr/design/fit/grid/AdaptiveGridListener.java
  54. 186
      designer-realize/src/main/java/com/fr/design/fit/grid/ElementCasePaneUtil.java
  55. 70
      designer-realize/src/main/java/com/fr/design/fit/grid/GridHeaderWithBoundMouseHandler.java
  56. 194
      designer-realize/src/main/java/com/fr/design/fit/grid/GridLimitColumnMouseHandler.java
  57. 190
      designer-realize/src/main/java/com/fr/design/fit/grid/GridLimitRowMouseHandler.java
  58. 190
      designer-realize/src/main/java/com/fr/design/fit/grid/NewFormDesignerGridUI.java
  59. 9
      designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePane.java
  60. 4
      designer-realize/src/main/java/com/fr/design/mainframe/form/FormElementCaseDesigner.java
  61. 9
      designer-realize/src/main/java/com/fr/grid/AbstractGridHeaderMouseHandler.java
  62. 10
      designer-realize/src/main/java/com/fr/grid/DefaultGridUIProcessor.java
  63. 27
      designer-realize/src/main/java/com/fr/grid/GridColumn.java
  64. 4
      designer-realize/src/main/java/com/fr/grid/GridColumnMouseHandler.java
  65. 7
      designer-realize/src/main/java/com/fr/grid/GridColumnUI.java
  66. 3
      designer-realize/src/main/java/com/fr/grid/GridCorner.java
  67. 3
      designer-realize/src/main/java/com/fr/grid/GridHeader.java
  68. 3
      designer-realize/src/main/java/com/fr/grid/GridMouseAdapter.java
  69. 18
      designer-realize/src/main/java/com/fr/grid/GridRow.java
  70. 8
      designer-realize/src/main/java/com/fr/grid/GridRowUI.java
  71. 5
      designer-realize/src/main/java/com/fr/grid/GridUtils.java
  72. 15
      designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java

83
designer-form/src/main/java/com/fr/design/actions/FormFitAttrAction.java

@ -0,0 +1,83 @@
package com.fr.design.actions;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.dialog.UIDialog;
import com.fr.design.fit.DesignerUIModeConfig;
import com.fr.design.fit.NewJForm;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.menu.MenuKeySet;
import com.fr.report.fit.FitProvider;
import com.fr.report.fit.ReportFitAttr;
import javax.swing.KeyStroke;
import java.awt.event.ActionEvent;
/**
* Created by Administrator on 2015/7/6 0006.
*/
public class FormFitAttrAction extends JTemplateAction {
private static final MenuKeySet REPORT_FIT_ATTR_ELEMENTCASE = new MenuKeySet() {
@Override
public char getMnemonic() {
return 'T';
}
@Override
public String getMenuName() {
return DesignerUIModeConfig.getInstance().newUIMode() ?
com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit_PC_Adaptive_Attr") :
com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_PC_Element_Case_Fit_Attr");
}
@Override
public KeyStroke getKeyStroke() {
return null;
}
};
public FormFitAttrAction(JTemplate jTemplate) {
super(jTemplate);
initMenuStyle();
}
private void initMenuStyle() {
this.setMenuKeySet(REPORT_FIT_ATTR_ELEMENTCASE);
this.setName(getMenuKeySet().getMenuKeySetName() + "...");
this.setMnemonic(getMenuKeySet().getMnemonic());
this.setSmallIcon(DesignerUIModeConfig.getInstance().newUIMode() ?
"/com/fr/design/images/reportfit/fit.png":
"/com/fr/design/images/reportfit/fit");
}
/**
* Action触发事件
*
* @param e 事件
*/
@Override
public void actionPerformed(ActionEvent e) {
final JTemplate jwb = getEditingComponent();
if (jwb == null || !(jwb instanceof NewJForm)) {
return;
}
final FitProvider wbTpl = (FitProvider) jwb.getTarget();
ReportFitAttr fitAttr = wbTpl.getReportFitAttr();
NewJForm newJForm = (NewJForm) jwb;
BasicBeanPane attrPane = newJForm.getJFormType().obtainAttrPane(newJForm);
showFitDialog(fitAttr, jwb, wbTpl, attrPane);
}
private void showFitDialog(ReportFitAttr fitAttr, final JTemplate jwb, final FitProvider wbTpl, final BasicBeanPane<ReportFitAttr> attrPane) {
attrPane.populateBean(fitAttr);
UIDialog dialog = attrPane.showMediumWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() {
@Override
public void doOk() {
wbTpl.setReportFitAttr(attrPane.updateBean());
jwb.fireTargetModified();
}
});
dialog.setVisible(true);
}
}

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

@ -0,0 +1,115 @@
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);
}
}

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

@ -14,6 +14,7 @@ import com.fr.design.designer.beans.location.Direction;
import com.fr.design.designer.beans.models.SelectionModel; import com.fr.design.designer.beans.models.SelectionModel;
import com.fr.design.designer.creator.cardlayout.XWTabFitLayout; import com.fr.design.designer.creator.cardlayout.XWTabFitLayout;
import com.fr.design.designer.properties.mobile.MobileBooKMarkUsePropertyUI; import com.fr.design.designer.properties.mobile.MobileBooKMarkUsePropertyUI;
import com.fr.design.fit.DesignerUIModeConfig;
import com.fr.design.form.layout.FRAbsoluteLayout; import com.fr.design.form.layout.FRAbsoluteLayout;
import com.fr.design.form.util.FormDesignerUtils; import com.fr.design.form.util.FormDesignerUtils;
import com.fr.design.form.util.XCreatorConstants; import com.fr.design.form.util.XCreatorConstants;
@ -30,7 +31,6 @@ import com.fr.form.ui.Widget;
import com.fr.form.ui.container.WAbsoluteLayout; import com.fr.form.ui.container.WAbsoluteLayout;
import com.fr.form.ui.container.WAbsoluteLayout.BoundsWidget; import com.fr.form.ui.container.WAbsoluteLayout.BoundsWidget;
import com.fr.form.ui.container.WLayout; import com.fr.form.ui.container.WLayout;
import com.fr.general.FRScreen;
import com.fr.general.IOUtils; import com.fr.general.IOUtils;
import com.fr.share.ShareConstants; import com.fr.share.ShareConstants;
@ -111,7 +111,7 @@ public class XWAbsoluteLayout extends XLayoutContainer {
private void initPercent(WAbsoluteLayout widget) { private void initPercent(WAbsoluteLayout widget) {
Toolkit toolkit = Toolkit.getDefaultToolkit(); Toolkit toolkit = Toolkit.getDefaultToolkit();
Dimension scrnsize = toolkit.getScreenSize(); Dimension scrnsize = toolkit.getScreenSize();
double screenValue = FRScreen.getDesignScreenByDimension(scrnsize).getValue(); double screenValue = DesignerUIModeConfig.getInstance().getDesignScreenByDimension(scrnsize).getValue();
if (!AssistUtils.equals(screenValue, FormArea.DEFAULT_SLIDER)) { if (!AssistUtils.equals(screenValue, FormArea.DEFAULT_SLIDER)) {
this.setContainerPercent(screenValue / FormArea.DEFAULT_SLIDER); this.setContainerPercent(screenValue / FormArea.DEFAULT_SLIDER);
} }
@ -247,7 +247,7 @@ public class XWAbsoluteLayout extends XLayoutContainer {
*/ */
@Override @Override
public void updateChildBound(int minHeight) { public void updateChildBound(int minHeight) {
double prevContainerPercent = FRScreen.getDesignScreenByDimension(toData().getDesigningResolution()).getValue() / FormArea.DEFAULT_SLIDER; double prevContainerPercent = DesignerUIModeConfig.getInstance().getDesignScreenByDimension(toData().getDesigningResolution()).getValue() / FormArea.DEFAULT_SLIDER;
if (toData().getCompState() == 0 && !AssistUtils.equals(containerPercent, prevContainerPercent)) { if (toData().getCompState() == 0 && !AssistUtils.equals(containerPercent, prevContainerPercent)) {
for (int i = 0; i < this.getComponentCount(); i++) { for (int i = 0; i < this.getComponentCount(); i++) {
XCreator creator = getXCreator(i); XCreator creator = getXCreator(i);

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

@ -6,6 +6,7 @@ import com.fr.design.designer.beans.location.Direction;
import com.fr.design.designer.creator.cardlayout.XWCardMainBorderLayout; import com.fr.design.designer.creator.cardlayout.XWCardMainBorderLayout;
import com.fr.design.designer.creator.cardlayout.XWTabFitLayout; import com.fr.design.designer.creator.cardlayout.XWTabFitLayout;
import com.fr.design.designer.properties.mobile.BodyMobilePropertyUI; import com.fr.design.designer.properties.mobile.BodyMobilePropertyUI;
import com.fr.design.fit.DesignerUIModeConfig;
import com.fr.design.form.layout.FRFitLayout; import com.fr.design.form.layout.FRFitLayout;
import com.fr.design.fun.WidgetPropertyUIProvider; import com.fr.design.fun.WidgetPropertyUIProvider;
import com.fr.design.mainframe.FormArea; import com.fr.design.mainframe.FormArea;
@ -20,7 +21,6 @@ import com.fr.form.ui.container.WFitLayout;
import com.fr.form.ui.container.WLayout; import com.fr.form.ui.container.WLayout;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.FRLogger; import com.fr.general.FRLogger;
import com.fr.general.FRScreen;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
import com.fr.stable.AssistUtils; import com.fr.stable.AssistUtils;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
@ -72,7 +72,7 @@ public class XWFitLayout extends XLayoutContainer {
private void initPercent(){ private void initPercent(){
Toolkit toolkit = Toolkit.getDefaultToolkit(); Toolkit toolkit = Toolkit.getDefaultToolkit();
Dimension scrnsize = toolkit.getScreenSize(); Dimension scrnsize = toolkit.getScreenSize();
double screenValue = FRScreen.getDesignScreenByDimension(scrnsize).getValue(); double screenValue = DesignerUIModeConfig.getInstance().getDesignScreenByDimension(scrnsize).getValue();
if (!AssistUtils.equals(FormArea.DEFAULT_SLIDER, screenValue)) { if (!AssistUtils.equals(FormArea.DEFAULT_SLIDER, screenValue)) {
this.setContainerPercent(screenValue / FormArea.DEFAULT_SLIDER); this.setContainerPercent(screenValue / FormArea.DEFAULT_SLIDER);
} }

124
designer-form/src/main/java/com/fr/design/fit/DesignerUIModeConfig.java

@ -0,0 +1,124 @@
package com.fr.design.fit;
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 static class DesignerUIModeConfigHolder {
private static final DesignerUIModeConfig designerUIModeConfig = new DesignerUIModeConfig();
}
private DesignerUIModeConfig() {
}
public static DesignerUIModeConfig getInstance() {
return DesignerUIModeConfigHolder.designerUIModeConfig;
}
/**
* 判断是否是新ui模式
*
* @return boolean
*/
public boolean newUIMode() {
return ComparatorUtils.equals(DesignerUIMode.NEW_UI_MODE, mode);
}
/**
* 设置新ui模式
*/
public void setNewUIMode() {
this.mode = DesignerUIMode.NEW_UI_MODE;
}
/**
* 设置老ui模式
*/
public void setOldUIMode() {
this.mode = DesignerUIMode.OLD_UI_MODE;
}
/**
* 解析不同模式下的尺寸单位
*
* @param unitType 尺寸类型
* @return ReportLengthUNITProvider对象
*/
public ReportLengthUNITProvider parseLengthUNIT(int unitType) {
return mode.parseLengthUNIT(unitType);
}
/**
* 获取不同模式下的屏幕分辨率
*
* @return 分辨率
*/
public int getScreenResolution() {
return mode.getScreenResolution();
}
/**
* 根据屏幕尺寸获取设计时的FRScreen
*
* @param screen 屏幕尺寸
* @return FRScreen
*/
public FRScreen getDesignScreenByDimension(Dimension screen) {
return mode.getDesignScreenByDimension(screen);
}
private enum DesignerUIMode {
OLD_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 {
@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();
}
}

36
designer-form/src/main/java/com/fr/design/fit/FitStateCompatible.java

@ -0,0 +1,36 @@
package com.fr.design.fit;
/**
* Created by kerry on 2020-04-27
*/
public enum FitStateCompatible {
DOUBLE_FIT(2, 0),
HOR_FIT(1, 1),
NO_FIT(3, 2);
private final int newType;
private final int oldType;
FitStateCompatible(int oldType, int newType) {
this.oldType = oldType;
this.newType = newType;
}
public static int getNewTypeFromOld(int oldValue) {
for (FitStateCompatible compatible : values()) {
if (compatible.oldType == oldValue) {
return compatible.newType;
}
}
return DOUBLE_FIT.newType;
}
public static int getOldTypeFromNew(int newValue) {
for (FitStateCompatible compatible : values()) {
if (compatible.newType == newValue) {
return compatible.oldType;
}
}
return DOUBLE_FIT.oldType;
}
}

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

@ -0,0 +1,133 @@
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();
}
@Override
public ReportFitAttr obtainFitAttr() {
return FormFitConfig.getInstance().getOldFitAttr();
}
@Override
public void updateFitAttr(ReportFitAttr attr) {
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();
}
@Override
public ReportFitAttr obtainFitAttr() {
return FormFitConfig.getInstance().getNewFitAttr();
}
@Override
public void updateFitAttr(ReportFitAttr attr) {
FormFitConfig.getInstance().setNewFitAttr(attr);
}
@Override
public BasicBeanPane obtainAttrPane(NewJForm newJForm) {
return new FormFitAttrPane(newJForm);
}
};
private int type;
private boolean newType;
private PreviewProvider previewType;
JFormType(int type, PreviewProvider previewType) {
this.type = type;
this.newType = (type == 1);
this.previewType = previewType;
}
public int getType() {
return type;
}
public boolean isNewType() {
return newType;
}
public PreviewProvider getPreviewType() {
return previewType;
}
public abstract void switchUI();
public abstract void switchUIMode();
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) {
jTemplate.setPreviewType(this.getPreviewType());
}
}

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

@ -0,0 +1,285 @@
package com.fr.design.fit;
import com.fr.base.DynamicUnitList;
import com.fr.design.actions.TemplateParameterAction;
import com.fr.design.designer.beans.AdapterBus;
import com.fr.design.designer.beans.LayoutAdapter;
import com.fr.design.designer.beans.adapters.layout.FRFitLayoutAdapter;
import com.fr.design.designer.beans.events.DesignerEditListener;
import com.fr.design.designer.beans.events.DesignerEvent;
import com.fr.design.designer.creator.*;
import com.fr.design.fit.common.AdaptiveSwitchUtil;
import com.fr.design.fit.common.LayoutTool;
import com.fr.form.fit.NewFormMarkAttr;
import com.fr.design.fit.common.TemplateTool;
import com.fr.design.actions.FormFitAttrAction;
import com.fr.design.actions.NewFormMobileAttrAction;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.preview.DeveloperPreview;
import com.fr.design.preview.FormAdaptivePreview;
import com.fr.design.fit.toolbar.SwitchAction;
import com.fr.design.fun.PreviewProvider;
import com.fr.design.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.main.Form;
import com.fr.form.main.mobile.FormMobileAttr;
import com.fr.form.ui.ElementCaseEditor;
import com.fr.stable.ArrayUtils;
import javax.swing.JComponent;
import java.awt.Dimension;
import java.awt.Rectangle;
/**
* Created by kerry on 2020-05-31
*/
public class NewJForm extends JForm {
private static final int FUZZY_EDGE = 10;
private static final int TITLE_HEIGHT = 36;
private JFormType jFormType;
public NewJForm() {
super();
init();
changePaneSize();
}
public NewJForm(Form form, FILE file) {
super(form, file);
if (DesignerUIModeConfig.getInstance().newUIMode()) {
init();
}
changePaneSize();
}
/**
* @Description:改变body的大小主要针对新模式下打开老模板出现截断的情况
* @param
* @return:
* @Author: Henry.Wang
* @date: 2020/9/13 23:23
*/
private void changePaneSize() {
if (mobileForm())
return;
NewFormMarkAttr newFormMarkAttr = this.getTarget().getAttrMark(NewFormMarkAttr.XML_TAG);
if (newFormMarkAttr.isNotSetOriginSize()) {
newFormMarkAttr.setBodyHeight(LayoutTool.getBodyHeight(this));
newFormMarkAttr.setBodyWidth(LayoutTool.getBodyWidth(this));
return;
}
//这种是针对body为绝对布局时,可能出现截断的情况
if (LayoutTool.absoluteLayoutForm(this)) {
int bodyHeight = newFormMarkAttr.getBodyHeight();
int bodyWidth = newFormMarkAttr.getBodyWidth();
Rectangle rectangle = LayoutTool.getAbsoluteBodySize(this);
if (!isNewJFrom() && (rectangle.width != bodyWidth || rectangle.height != bodyHeight)) {
TemplateTool.onlyChangeAbsoluteBodySize(bodyHeight, bodyWidth, this);
} else if(isNewJFrom()){
if (rectangle.width > bodyWidth && rectangle.height > bodyHeight) {
TemplateTool.onlyChangeAbsoluteBodySize(rectangle.height, rectangle.width, this);
} else if (rectangle.width > bodyWidth) {
TemplateTool.onlyChangeAbsoluteBodySize(bodyHeight, rectangle.width, this);
} else if (rectangle.height > bodyHeight) {
TemplateTool.onlyChangeAbsoluteBodySize(rectangle.height, bodyWidth, this);
}
}
} else if (AdaptiveSwitchUtil.isSwitchJFromIng()) {
//这种是针对body中有绝对画布块,导致截断的情况
double scale = LayoutTool.getContainerPercent();
if (isNewJFrom()) {
LayoutTool.scaleAbsoluteBlockComponentsBounds(this.getFormDesign().getRootComponent(), 1 / scale);
} else {
LayoutTool.scaleAbsoluteBlockComponentsBounds(this.getFormDesign().getRootComponent(), scale);
}
}
}
public JFormType getJFormType() {
return this.jFormType;
}
public void setJFormType(JFormType jFormType) {
this.jFormType = jFormType;
}
/**
* 模板菜单
*
* @return 返回菜单
*/
@Override
public ShortCut[] shortcut4TemplateMenu() {
if (this.index == FORM_TAB) {
return ArrayUtils.addAll(new ShortCut[]{new TemplateParameterAction(this), new NewFormMobileAttrAction(this), new FormFitAttrAction(this)}, new ShortCut[0]);
} else {
return ArrayUtils.addAll(new ShortCut[]{new TemplateParameterAction(this), new NewFormMobileAttrAction(this), new FormFitAttrAction(this)}, this.getElementCaseDesign().shortcut4TemplateMenu());
}
}
private void init() {
this.getFormDesign().addDesignerEditListener(new DesignerEditListener() {
private Rectangle oldRec;
@Override
public void fireCreatorModified(DesignerEvent evt) {
if (evt.getAffectedCreator() == null) {
return;
}
if (evt.getCreatorEventID() == DesignerEvent.CREATOR_RESIZED) {
XComponent affectedCreator = evt.getAffectedCreator();
if (isElementCase((JComponent) affectedCreator)) {
processAbsorbingEffect((XWTitleLayout) affectedCreator);
}
}
if (evt.getCreatorEventID() == DesignerEvent.CREATOR_SELECTED) {
XComponent affectedCreator = evt.getAffectedCreator();
oldRec = new Rectangle(affectedCreator.getBounds());
}
}
private boolean isElementCase(JComponent component) {
return component.getComponents().length > 0 && component.getComponent(0) instanceof XElementCase;
}
private void processAbsorbingEffect(XWTitleLayout xwTitleLayout) {
NewJForm.this.getFormDesign().repaint();
Dimension bound = new Dimension(xwTitleLayout.getSize());
ElementCaseEditor elementCaseEditor = (ElementCaseEditor) xwTitleLayout.toData().getBodyBoundsWidget().getWidget();
FormElementCaseProvider elementCase = elementCaseEditor.getElementCase();
if (oldRec.width != bound.width) {
processColumnAbsorbingEffect(xwTitleLayout, elementCase.getColumnWidthList_DEC(), bound);
oldRec.width = bound.width;
}
if (oldRec.height != bound.height) {
processRowAbsorbingEffect(xwTitleLayout, elementCase.getRowHeightList_DEC(), bound);
oldRec.height = bound.height;
}
NewJForm.this.getFormDesign().refreshDesignerUI();
}
private boolean hasTitle(XWTitleLayout xwTitleLayout) {
return xwTitleLayout.getComponentCount() > 1;
}
private void processColumnAbsorbingEffect(XWTitleLayout xwTitleLayout, DynamicUnitList columnUnitList, Dimension bound) {
int temp = 0;
int resolution = DesignerUIModeConfig.getInstance().getScreenResolution();;
int difference = 0;
int i = 0;
while (true) {
if (i < columnUnitList.size()) {
temp += columnUnitList.get(i++).toPixI(resolution);
} else {
//在处理吸附效果时,columnUnitList数组长度可能比实际显示的列数少,所以用默认值来补充
temp += columnUnitList.getDefaultUnit().toPixI(resolution);
}
if (bound.width - temp < 0) {
break;
}
if (bound.width - temp < FUZZY_EDGE) {
difference = bound.width - temp;
bound.width = temp;
break;
}
}
fixLayout(xwTitleLayout, bound, difference, 0);
}
private void processRowAbsorbingEffect(XWTitleLayout xwTitleLayout, DynamicUnitList rowUnitList, Dimension bound) {
int temp = hasTitle(xwTitleLayout) ? TITLE_HEIGHT : 0;
int resolution =DesignerUIModeConfig.getInstance().getScreenResolution();
int difference = 0;
int i = 0;
while (true) {
if (i < rowUnitList.size()) {
temp += rowUnitList.get(i++).toPixI(resolution);
} else {
//在处理吸附效果时,rowUnitList数组长度可能比实际显示的行数少,所以用默认值来补充
temp += rowUnitList.getDefaultUnit().toPixI(resolution);
}
if (bound.height - temp < 0) {
break;
}
if (bound.height - temp < FUZZY_EDGE) {
difference = bound.height - temp;
bound.height = temp;
break;
}
}
fixLayout(xwTitleLayout, bound, difference, 1);
}
private void fixLayout(XWTitleLayout xwTitleLayout, Dimension bound, int difference, int row) {
Rectangle backupBounds = getBound(xwTitleLayout);
xwTitleLayout.setSize(bound);
FormDesigner formDesigner = WidgetPropertyPane.getInstance().getEditingFormDesigner();
LayoutAdapter adapter = AdapterBus.searchLayoutAdapter(formDesigner, xwTitleLayout);
if (adapter instanceof FRFitLayoutAdapter) {
FRFitLayoutAdapter layoutAdapter = (FRFitLayoutAdapter) adapter;
layoutAdapter.setEdit(true);
layoutAdapter.calculateBounds(backupBounds, xwTitleLayout.getBounds(), xwTitleLayout, row, difference);
}
XLayoutContainer parent = XCreatorUtils.getParentXLayoutContainer(xwTitleLayout);
if (parent != null && parent.toData() != null) {
parent.toData().setBounds(xwTitleLayout.toData(), xwTitleLayout.getBounds());
}
}
});
}
public Rectangle getBound(XWTitleLayout creator) {
Rectangle bounds = new Rectangle(creator.getBounds());
if (creator.getParent() == null) {
return bounds;
}
Rectangle rec = ComponentUtils.getRelativeBounds(creator.getParent());
bounds.x += rec.x;
bounds.y += rec.y;
return bounds;
}
@Override
public PreviewProvider[] supportPreview() {
if (isNewJFrom()) {
return new PreviewProvider[]{new FormAdaptivePreview(), new DeveloperPreview(), new MobilePreview()};
}
return new PreviewProvider[]{new FormPreview(), new MobilePreview()};
}
public boolean mobileForm() {
FormMobileAttr mobileAttr = this.getTarget().getFormMobileAttr();
if (mobileAttr.isMobileOnly() && mobileAttr.isAdaptivePropertyAutoMatch()) {
return true;
}
return false;
}
private SwitchAction switchAction;
public UIButton[] createExtraButtons() {
UIButton[] extraButtons = super.createExtraButtons();
switchAction = new SwitchAction();
return ArrayUtils.addAll(extraButtons, new UIButton[]{switchAction.getToolBarButton()});
}
public boolean isNewJFrom() {
return jFormType == null || jFormType.isNewType();
}
}

27
designer-form/src/main/java/com/fr/design/fit/PX.java

@ -0,0 +1,27 @@
package com.fr.design.fit;
import com.fr.stable.Constants;
import com.fr.stable.unit.LEN_UNIT;
public class PX extends LEN_UNIT {
private static final long FU_SCALE = 36576L;
public PX(float var1) {
super(var1);
}
public boolean equals(Object var1) {
return var1 instanceof PX && super.equals(var1);
}
protected long getMoreFUScale() {
int dpi = DesignerUIModeConfig.getInstance().getScreenResolution();
return FU_SCALE / dpi;
}
public static double toPixWithResolution(double value, int resolution) {
return value * resolution / Constants.FR_PAINT_RESOLUTION;
}
}

32
designer-form/src/main/java/com/fr/design/fit/PXReportLengthUNIT.java

@ -0,0 +1,32 @@
package com.fr.design.fit;
import com.fr.design.fun.impl.AbstractReportLengthUNITProvider;
import com.fr.stable.unit.UNIT;
/**
* Created by kerry on 2020-04-09
*/
public class PXReportLengthUNIT extends AbstractReportLengthUNITProvider {
public static final short UNIT_TYPE = 4;
@Override
public String unitText() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Px");
}
@Override
public int unitType() {
return UNIT_TYPE;
}
@Override
public float unit2Value4Scale(UNIT value) {
int resolution = DesignerUIModeConfig.getInstance().getScreenResolution();
return value.toPixF(resolution);
}
@Override
public UNIT float2UNIT(float value) {
return new PX(value);
}
}

91
designer-form/src/main/java/com/fr/design/fit/attrpane/ElementEditorExtendDefinePane.java

@ -0,0 +1,91 @@
package com.fr.design.fit.attrpane;
import com.fr.design.designer.IntervalConstants;
import com.fr.design.designer.creator.CRPropertyDescriptor;
import com.fr.design.designer.creator.PropertyGroupPane;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XElementCase;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.widget.accessibles.AccessibleElementCaseToolBarEditor;
import com.fr.design.widget.ui.designer.component.PaddingBoundPane;
import com.fr.design.widget.ui.designer.layout.WTitleLayoutDefinePane;
import com.fr.form.ui.ElementCaseEditor;
import com.fr.form.web.FormToolBarManager;
import com.fr.general.ComparatorUtils;
import com.fr.report.fit.ReportFitAttr;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Component;
import java.util.ArrayList;
import java.util.List;
/**
* Created by kerry on 2020-04-09
*/
public class ElementEditorExtendDefinePane extends WTitleLayoutDefinePane<ElementCaseEditor> {
private PaddingBoundPane paddingBoundPane;
private AccessibleElementCaseToolBarEditor elementCaseToolBarEditor;
private PropertyGroupPane extraPropertyGroupPane;
private PcFitExpandablePane pcFitExpandablePane;
private static final String FIT_STATE_PC = "fitStateInPC";
public ElementEditorExtendDefinePane(XCreator xCreator) {
super(xCreator);
}
protected JPanel createCenterPane() {
JPanel centerPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
paddingBoundPane = new PaddingBoundPane();
elementCaseToolBarEditor = new AccessibleElementCaseToolBarEditor();
Component[][] components = new Component[][]{
new Component[]{paddingBoundPane, null},
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_EC_Toolbar")), elementCaseToolBarEditor},
};
JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W0, IntervalConstants.INTERVAL_L1);
panel.setBorder(BorderFactory.createEmptyBorder(5, 0, 10, 0));
CRPropertyDescriptor[] extraTableEditor = removeOldFitEditor(((XElementCase) creator).getExtraTableEditor());
extraPropertyGroupPane = new PropertyGroupPane(extraTableEditor, creator);
centerPane.add(panel, BorderLayout.NORTH);
if (extraTableEditor.length > 0) {
centerPane.add(extraPropertyGroupPane, BorderLayout.CENTER);
}
pcFitExpandablePane = new PcFitExpandablePane(this);
centerPane.add(pcFitExpandablePane, BorderLayout.SOUTH);
return centerPane;
}
private CRPropertyDescriptor[] removeOldFitEditor(CRPropertyDescriptor[] extraTableEditor) {
List<CRPropertyDescriptor> list = new ArrayList<CRPropertyDescriptor>();
for (CRPropertyDescriptor crPropertyDescriptor : extraTableEditor) {
if (!ComparatorUtils.equals(FIT_STATE_PC, crPropertyDescriptor.getName())) {
list.add(crPropertyDescriptor);
}
}
return list.toArray(new CRPropertyDescriptor[list.size()]);
}
protected ElementCaseEditor updateSubBean() {
ElementCaseEditor elementCaseEditor = (ElementCaseEditor) creator.toData();
if (ComparatorUtils.equals(getGlobalName(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Layout_Padding_Duplicate"))) {
paddingBoundPane.update(elementCaseEditor);
}
elementCaseEditor.setToolBars((FormToolBarManager[]) elementCaseToolBarEditor.getValue());
ReportFitAttr fitAttr = pcFitExpandablePane.update();
elementCaseEditor.setReportFitAttr(fitAttr);
return elementCaseEditor;
}
protected void populateSubBean(ElementCaseEditor ob) {
paddingBoundPane.populate(ob);
elementCaseToolBarEditor.setValue(ob.getToolBars());
extraPropertyGroupPane.populate(ob);
pcFitExpandablePane.populate(ob.getReportFitAttr());
}
}

161
designer-form/src/main/java/com/fr/design/fit/attrpane/FRAbsoluteBodyLayoutExtendDefinePane.java

@ -0,0 +1,161 @@
package com.fr.design.fit.attrpane;
import com.fr.base.io.IOFile;
import com.fr.base.iofile.attr.WatermarkAttr;
import com.fr.design.data.DataCreatorUI;
import com.fr.design.designer.IntervalConstants;
import com.fr.design.designer.creator.XCreator;
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.foldablepane.UIExpandablePane;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.WidgetPropertyPane;
import com.fr.design.mainframe.widget.accessibles.AccessibleBodyWatermarkEditor;
import com.fr.design.mainframe.widget.accessibles.AccessibleWLayoutBorderStyleEditor;
import com.fr.design.utils.gui.UIComponentUtils;
import com.fr.design.widget.FRWidgetFactory;
import com.fr.design.widget.ui.designer.layout.FRAbsoluteLayoutDefinePane;
import com.fr.form.ui.LayoutBorderStyle;
import com.fr.form.ui.container.WAbsoluteBodyLayout;
import com.fr.form.ui.container.WAbsoluteLayout;
import com.fr.form.ui.container.WBodyLayoutType;
import com.fr.report.core.ReportUtils;
import javax.swing.BorderFactory;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Component;
/**
* Created by kerry on 2020-04-22
*/
public class FRAbsoluteBodyLayoutExtendDefinePane extends FRAbsoluteLayoutDefinePane {
private static final int MAX_LABEL_WIDTH = 80;
private AccessibleWLayoutBorderStyleEditor borderStyleEditor;
private AccessibleBodyWatermarkEditor watermarkEditor;
private UIComboBox layoutCombox;
private WBodyLayoutType layoutType = WBodyLayoutType.ABSOLUTE;
public FRAbsoluteBodyLayoutExtendDefinePane(XCreator xCreator) {
super(xCreator);
}
public void initComponent() {
initCenterPane();
JPanel centerPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
borderStyleEditor = new AccessibleWLayoutBorderStyleEditor();
watermarkEditor = new AccessibleBodyWatermarkEditor();
JPanel jPanel = TableLayoutHelper.createGapTableLayoutPane(
new Component[][]{
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style")), borderStyleEditor},
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_WaterMark")), watermarkEditor}
}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W3, IntervalConstants.INTERVAL_L1);
JPanel borderPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
jPanel.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0));
borderPane.add(jPanel, BorderLayout.CENTER);
UIExpandablePane advancedPane = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Advanced"), 280, 20, borderPane);
centerPane.add(advancedPane, BorderLayout.NORTH);
this.add(centerPane, BorderLayout.NORTH);
}
private void initCenterPane(){
this.setLayout(FRGUIPaneFactory.createBorderLayout());
initUIComboBox();
JPanel thirdPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
JPanel jPanel = createThirdPane();
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_Layout"), 280, 20, thirdPane);
this.add(layoutExpandablePane, BorderLayout.CENTER);
}
public JPanel createThirdPane() {
initLayoutComboBox();
JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane();
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double[] rowSize = {p};
double[] colSize = {p, f};
UILabel layoutTypeLabel = FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Attr_Layout_Type"));
JPanel northPane = TableLayoutHelper.createGapTableLayoutPane(
new Component[][]{
new Component[]{layoutTypeLabel, UIComponentUtils.wrapWithBorderLayoutPane(layoutCombox)}},
rowSize, colSize, IntervalConstants.INTERVAL_W1, IntervalConstants.INTERVAL_L1);
jPanel.add(northPane, BorderLayout.NORTH);
return jPanel;
}
public void initLayoutComboBox() {
Item[] items = FRLayoutTypeItems.ITEMS;
DefaultComboBoxModel model = new DefaultComboBoxModel();
for (Item item : items) {
model.addElement(item);
}
layoutCombox = new UIComboBox(model);
layoutCombox.setSelectedIndex(1);
}
@Override
public String title4PopupWindow() {
return "absoluteBodyLayout";
}
public void populateSubPane(WAbsoluteLayout ob) {
layoutCombox.setSelectedIndex(1);
borderStyleEditor.setValue(ob.getBorderStyle());
watermarkEditor.setValue(ReportUtils.getWatermarkAttrFromTemplate(getCurrentIOFile()));
}
public WAbsoluteBodyLayout updateSubPane() {
WAbsoluteBodyLayout layout = (WAbsoluteBodyLayout) creator.toData();
Item item = (Item) layoutCombox.getSelectedItem();
Object value = item.getValue();
int state = 0;
if (value instanceof Integer) {
state = (Integer) value;
}
if (layoutType == WBodyLayoutType.ABSOLUTE) {
((XWFitLayout) creator.getBackupParent()).toData().resetStyle();
if (state == WBodyLayoutType.FIT.getTypeValue()) {
XWFitLayout xwFitLayout = ((XWFitLayout)creator.getBackupParent());
xwFitLayout.switch2FitBodyLayout(creator);
copyLayoutAttr(layout, xwFitLayout.toData());
}
}
layout.setBorderStyle((LayoutBorderStyle) borderStyleEditor.getValue());
updateWatermark();
return layout;
}
private void updateWatermark() {
WatermarkAttr watermark = (WatermarkAttr) watermarkEditor.getValue();
if (watermark != null) {
IOFile ioFile = getCurrentIOFile();
ioFile.addAttrMark(watermark);
}
}
private IOFile getCurrentIOFile() {
return WidgetPropertyPane.getInstance().getEditingFormDesigner().getTarget();
}
@Override
public DataCreatorUI dataUI() {
return null;
}
}

27
designer-form/src/main/java/com/fr/design/fit/attrpane/FRAbsoluteLayoutExtendDefinePane.java

@ -0,0 +1,27 @@
package com.fr.design.fit.attrpane;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.widget.ui.designer.layout.AbstractFRLayoutDefinePane;
import com.fr.form.ui.container.WAbsoluteLayout;
/**
* Created by kerry on 2020-04-22
*/
public class FRAbsoluteLayoutExtendDefinePane extends AbstractFRLayoutDefinePane<WAbsoluteLayout> {
public FRAbsoluteLayoutExtendDefinePane(XCreator xCreator) {
super(xCreator);
this.setLayout(FRGUIPaneFactory.createBorderLayout());
}
@Override
public void populateBean(WAbsoluteLayout ob) {
}
@Override
public WAbsoluteLayout updateBean() {
WAbsoluteLayout wAbsoluteLayout = (WAbsoluteLayout) creator.toData();
return wAbsoluteLayout;
}
}

246
designer-form/src/main/java/com/fr/design/fit/attrpane/FRFitLayoutExtendDefinePane.java

@ -0,0 +1,246 @@
package com.fr.design.fit.attrpane;
import com.fr.base.io.IOFile;
import com.fr.base.iofile.attr.WatermarkAttr;
import com.fr.design.data.DataCreatorUI;
import com.fr.design.designer.IntervalConstants;
import com.fr.design.designer.creator.XCreator;
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.designer.creator.XWScaleLayout;
import com.fr.design.designer.properties.items.FRLayoutTypeItems;
import com.fr.design.designer.properties.items.Item;
import com.fr.design.foldablepane.UIExpandablePane;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.ispinner.UISpinner;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
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.mainframe.widget.accessibles.AccessibleWLayoutBorderStyleEditor;
import com.fr.design.utils.gui.UIComponentUtils;
import com.fr.design.widget.FRWidgetFactory;
import com.fr.design.widget.ui.designer.component.PaddingBoundPane;
import com.fr.design.widget.ui.designer.layout.AbstractFRLayoutDefinePane;
import com.fr.form.ui.LayoutBorderStyle;
import com.fr.form.ui.Widget;
import com.fr.form.ui.container.WAbsoluteBodyLayout;
import com.fr.form.ui.container.WAbsoluteLayout;
import com.fr.form.ui.container.WBodyLayoutType;
import com.fr.form.ui.container.WFitLayout;
import com.fr.general.ComparatorUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.report.core.ReportUtils;
import javax.swing.BorderFactory;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
/**
* Created by kerry on 2020-04-22
*/
public class FRFitLayoutExtendDefinePane extends AbstractFRLayoutDefinePane<WFitLayout> {
private static final int ADAPT_LABEL_MAX_WIDTH = 80;
private XWFitLayout xWFitLayout;
private WFitLayout wFitLayout;
private UIComboBox layoutComboBox;
private UISpinner componentIntervel;
private PaddingBoundPane paddingBound;
private AccessibleWLayoutBorderStyleEditor stylePane;
private AccessibleBodyWatermarkEditor watermarkEditor;
public FRFitLayoutExtendDefinePane(XCreator xCreator) {
super(xCreator);
this.xWFitLayout = (XWFitLayout) xCreator;
wFitLayout = xWFitLayout.toData();
initComponent();
}
public void initComponent() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
JPanel advancePane = createAdvancePane();
UIExpandablePane advanceExpandablePane = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Advanced"), 280, 20, advancePane);
this.add(advanceExpandablePane, BorderLayout.NORTH);
UIExpandablePane layoutExpandablePane = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Layout"), 280, 20, createLayoutPane());
this.add(layoutExpandablePane, BorderLayout.CENTER);
}
public JPanel createAdvancePane() {
JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane();
stylePane = new AccessibleWLayoutBorderStyleEditor();
watermarkEditor = new AccessibleBodyWatermarkEditor();
paddingBound = new PaddingBoundPane();
JPanel jp2 = TableLayoutHelper.createGapTableLayoutPane(
new Component[][]{
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style")), stylePane},
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_WaterMark")), watermarkEditor}
}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W3, IntervalConstants.INTERVAL_L1);
jp2.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0));
jPanel.add(paddingBound, BorderLayout.CENTER);
jPanel.add(jp2, BorderLayout.NORTH);
return jPanel;
}
public JPanel createLayoutPane() {
JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane();
jPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
layoutComboBox = initUIComboBox(FRLayoutTypeItems.ITEMS);
componentIntervel = new UISpinner(0, Integer.MAX_VALUE, 1, 0);
JPanel componentIntervelPane = UIComponentUtils.wrapWithBorderLayoutPane(componentIntervel);
UILabel intervalLabel = FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Component_Interval"));
double f = TableLayout.FILL;
double p = TableLayout.PREFERRED;
double[] rowSize = {p, p};
double[] columnSize = {p, f};
int[][] rowCount = {{1, 1}, {1, 1}};
Component[][] components = new Component[][]{
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Attr_Layout_Type")), layoutComboBox},
new Component[]{intervalLabel, componentIntervelPane}
};
JPanel centerPane = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, IntervalConstants.INTERVAL_W1, IntervalConstants.INTERVAL_L1);
centerPane.setBorder(BorderFactory.createEmptyBorder(IntervalConstants.INTERVAL_L1, 0, 0, 0));
jPanel.add(centerPane, BorderLayout.CENTER);
return jPanel;
}
public UIComboBox initUIComboBox(Item[] items) {
DefaultComboBoxModel model = new DefaultComboBoxModel();
for (Item item : items) {
model.addElement(item);
}
return new UIComboBox(model);
}
@Override
public String title4PopupWindow() {
return "fitLayout";
}
@Override
public void populateBean(WFitLayout ob) {
FormDesigner formDesigner = WidgetPropertyPane.getInstance().getEditingFormDesigner();
XLayoutContainer rootLayout = selectedBodyLayout(formDesigner);
if (rootLayout != formDesigner.getRootComponent()
&& formDesigner.getSelectionModel().getSelection().getSelectedCreator() == formDesigner.getRootComponent()) {
formDesigner.getSelectionModel().setSelectedCreators(
FormSelectionUtils.rebuildSelection(xWFitLayout, new Widget[]{selectedBodyLayout(formDesigner).toData()}));
}
paddingBound.populate(ob);
layoutComboBox.setSelectedIndex(ob.getBodyLayoutType().getTypeValue());
componentIntervel.setValue(ob.getCompInterval());
stylePane.setValue(ob.getBorderStyle());
watermarkEditor.setValue(ReportUtils.getWatermarkAttrFromTemplate(getCurrentIOFile()));
}
private XLayoutContainer selectedBodyLayout(FormDesigner formDesigner) {
XLayoutContainer rootLayout = formDesigner.getRootComponent();
if (rootLayout.getComponentCount() == 1 && rootLayout.getXCreator(0).acceptType(XWAbsoluteBodyLayout.class)) {
rootLayout = (XWAbsoluteBodyLayout) rootLayout.getXCreator(0);
}
return rootLayout;
}
@Override
public WFitLayout updateBean() {
WFitLayout layout = (WFitLayout) creator.toData();
if (ComparatorUtils.equals(getGlobalName(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Layout_Padding_Duplicate"))) {
paddingBound.update(layout);
}
LayoutBorderStyle borderStyle = (LayoutBorderStyle) stylePane.getValue();
if (borderStyle != null) {
layout.setBorderStyle(borderStyle);
}
updateWatermark();
Item item = (Item) layoutComboBox.getSelectedItem();
Object value = item.getValue();
int state = 0;
if (value instanceof Integer) {
state = (Integer) value;
}
//todo 验证下
layout.setLayoutType(WBodyLayoutType.parse(state));
try {
if (state == WBodyLayoutType.ABSOLUTE.getTypeValue()) {
WAbsoluteBodyLayout wAbsoluteBodyLayout = new WAbsoluteBodyLayout("body");
wAbsoluteBodyLayout.setCompState(WAbsoluteLayout.STATE_FIXED);
Component[] components = xWFitLayout.getComponents();
xWFitLayout.removeAll();
layout.resetStyle();
XWAbsoluteBodyLayout xwAbsoluteBodyLayout = xWFitLayout.getBackupParent() == null ? new XWAbsoluteBodyLayout(wAbsoluteBodyLayout, new Dimension(0, 0)) : (XWAbsoluteBodyLayout) xWFitLayout.getBackupParent();
xWFitLayout.getLayoutAdapter().addBean(xwAbsoluteBodyLayout, 0, 0);
for (Component component : components) {
XCreator xCreator = (XCreator) component;
//部分控件被ScaleLayout包裹着,绝对布局里面要放出来
if (xCreator.acceptType(XWScaleLayout.class)) {
if (xCreator.getComponentCount() > 0 && ((XCreator) xCreator.getComponent(0)).shouldScaleCreator()) {
component = xCreator.getComponent(0);
component.setBounds(xCreator.getBounds());
}
}
xwAbsoluteBodyLayout.add(component);
}
copyLayoutAttr(wFitLayout, wAbsoluteBodyLayout);
xWFitLayout.setBackupParent(xwAbsoluteBodyLayout);
FormDesigner formDesigner = WidgetPropertyPane.getInstance().getEditingFormDesigner();
formDesigner.getSelectionModel().setSelectedCreators(
FormSelectionUtils.rebuildSelection(xWFitLayout, new Widget[]{wAbsoluteBodyLayout}));
}
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
int intervelValue = (int) componentIntervel.getValue();
if (xWFitLayout.canAddInterval(intervelValue)) {
// 设置完间隔后,要同步处理界面组件,容器刷新后显示出对应效果
setLayoutGap(intervelValue);
}
return layout;
}
private void updateWatermark() {
WatermarkAttr watermark = (WatermarkAttr) watermarkEditor.getValue();
if (watermark != null) {
IOFile ioFile = getCurrentIOFile();
ioFile.addAttrMark(watermark);
}
}
private IOFile getCurrentIOFile() {
return WidgetPropertyPane.getInstance().getEditingFormDesigner().getTarget();
}
private void setLayoutGap(int value) {
int interval = wFitLayout.getCompInterval();
if (value != interval) {
xWFitLayout.moveContainerMargin();
xWFitLayout.moveCompInterval(xWFitLayout.getAcualInterval());
wFitLayout.setCompInterval(value);
xWFitLayout.addCompInterval(xWFitLayout.getAcualInterval());
}
}
@Override
public DataCreatorUI dataUI() {
return null;
}
}

107
designer-form/src/main/java/com/fr/design/fit/attrpane/PcFitExpandablePane.java

@ -0,0 +1,107 @@
package com.fr.design.fit.attrpane;
import com.fr.design.designer.IntervalConstants;
import com.fr.design.fit.FitStateCompatible;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.widget.DataModify;
import com.fr.report.fit.FitAttrState;
import com.fr.report.fit.ReportFitAttr;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
/**
* Created by kerry on 2020-04-22
*/
public class PcFitExpandablePane extends JPanel {
UIComboBox comboBox = new UIComboBox(
new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit_Ec_Double_Fit"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit_Ec_Hor_Fit"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit_Ec_No_Fit")});
UILabel tipLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit_Ec_No_Fit_Tip"));
public PcFitExpandablePane(DataModify attrPane) {
init(attrPane);
}
public void init(final DataModify attrPane) {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
JPanel pcFitPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
final JPanel borderPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
borderPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 0));
tipLabel.setForeground(Color.gray);
comboBox.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
tipLabel.setText(ScaleTipType.getScaleTip(comboBox.getSelectedIndex()).getTip());
}
});
Component[][] components = new Component[][]{
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit_Ec_Content_Display_Type")), comboBox},
new Component[]{tipLabel, null},
};
JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W0, IntervalConstants.INTERVAL_W0);
panel.setBorder(BorderFactory.createEmptyBorder(5, 0, 10, 0));
borderPane.add(panel, BorderLayout.CENTER);
borderPane.add(tipLabel, BorderLayout.SOUTH);
pcFitPane.add(borderPane, BorderLayout.CENTER);
this.add(pcFitPane, BorderLayout.CENTER);
}
public ReportFitAttr update() {
ReportFitAttr fitAttr = getReportFitAttr();
fitAttr.setFitStateInPC(FitStateCompatible.getOldTypeFromNew(comboBox.getSelectedIndex()));
return fitAttr;
}
public void populate(ReportFitAttr fitAttr) {
if (fitAttr == null) {
fitAttr = getReportFitAttr();
}
int selectIndex = FitStateCompatible.getNewTypeFromOld(fitAttr.fitStateInPC());
comboBox.setSelectedIndex(selectIndex);
tipLabel.setText(ScaleTipType.getScaleTip(selectIndex).getTip());
}
private ReportFitAttr getReportFitAttr() {
ReportFitAttr fitAttr = new ReportFitAttr();
fitAttr.setFitStateInPC(FitAttrState.NOT_FIT.getState());
return fitAttr;
}
private enum ScaleTipType {
EC_DOUBLE_FIT(0, com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit_Ec_Double_Fit_Tip")),
EC_HOR_FIT(1, com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit_Ec_Hor_Fit_Tip")),
EC_NO_FIT(2, com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit_Ec_No_Fit_Tip"));
private int index;
private String tip;
ScaleTipType(int index, String tip) {
this.index = index;
this.tip = tip;
}
public String getTip() {
return tip;
}
public static ScaleTipType getScaleTip(int selectIndex) {
for (ScaleTipType tipType : values()) {
if (selectIndex == tipType.index) {
return tipType;
}
}
return EC_NO_FIT;
}
}
}

303
designer-form/src/main/java/com/fr/design/fit/attrpane/RootDesignExtendDefinePane.java

@ -0,0 +1,303 @@
package com.fr.design.fit.attrpane;
import com.fr.base.BaseUtils;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.data.DataCreatorUI;
import com.fr.design.designer.IntervalConstants;
import com.fr.design.designer.creator.CRPropertyDescriptor;
import com.fr.design.designer.creator.PropertyGroupPane;
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;
import com.fr.design.gui.ibutton.UIButtonGroup;
import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.ispinner.UISpinner;
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.FormDesigner;
import com.fr.design.mainframe.FormSelection;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.mainframe.widget.accessibles.AccessibleBackgroundEditor;
import com.fr.design.utils.gui.LayoutUtils;
import com.fr.design.utils.gui.UIComponentUtils;
import com.fr.design.widget.ui.designer.AbstractDataModify;
import com.fr.design.widget.ui.designer.component.UIBoundSpinner;
import com.fr.form.ui.container.WParameterLayout;
import com.fr.general.Background;
import com.fr.report.stable.FormConstants;
import javax.swing.BorderFactory;
import javax.swing.Icon;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Rectangle;
import java.util.Set;
public class RootDesignExtendDefinePane extends AbstractDataModify<WParameterLayout> {
private XWParameterLayout root;
private UISpinner designerWidth;
private UISpinner paraHeight;
private UICheckBox displayReport;
private UICheckBox useParamsTemplate;
private AccessibleBackgroundEditor background;
private UIButtonGroup hAlignmentPane;
private UITextField labelNameTextField;
//是否是新设计模式下决策报表
private boolean newForm;
private PropertyGroupPane extraPropertyGroupPane;
public RootDesignExtendDefinePane(XCreator xCreator) {
super(xCreator);
newForm = TemplateTool.getCurrentEditingNewJForm() != null && DesignerUIModeConfig.getInstance().newUIMode();
this.root = (XWParameterLayout) xCreator;
initComponent();
}
public void initComponent() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
if (newForm) {
paraHeight = new UIBoundSpinner(0, Integer.MAX_VALUE, 1, 0);
} else {
designerWidth = new UIBoundSpinner(1, Integer.MAX_VALUE, 1);
}
JPanel advancePane = createAdvancePane();
UIExpandablePane advanceExpandablePane = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Advanced"), 280, 20, advancePane);
this.add(advanceExpandablePane, BorderLayout.NORTH);
JPanel layoutPane = createBoundsPane();
UIExpandablePane layoutExpandablePane = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Size"), 280, 20, layoutPane);
this.add(layoutExpandablePane, BorderLayout.CENTER);
this.addExtraUIExpandablePaneFromPlugin();
}
private void addExtraUIExpandablePaneFromPlugin() {
Set<ParameterExpandablePaneUIProvider> pluginCreators = ExtraDesignClassManager.getInstance().getArray(ParameterExpandablePaneUIProvider.XML_TAG);
JPanel panel = FRGUIPaneFactory.createYBoxEmptyBorderPane();
for (ParameterExpandablePaneUIProvider provider : pluginCreators) {
UIExpandablePane uiExpandablePane = provider.createUIExpandablePane();
PropertyTab propertyTab = provider.addToWhichPropertyTab();
if (uiExpandablePane != null && propertyTab == PropertyTab.ATTR) {
panel.add(uiExpandablePane);
}
}
this.add(panel, BorderLayout.SOUTH);
}
public JPanel createBoundsPane() {
double f = TableLayout.FILL;
double p = TableLayout.PREFERRED;
double[] rowSize = {p};
double[] columnSize = {p, f};
int[][] rowCount = {{1, 1}};
Component[] component = newForm ? new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit_Design_Height")), paraHeight} :
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Desin_Width")), designerWidth};
Component[][] components = new Component[][]{component};
JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, IntervalConstants.INTERVAL_W1, IntervalConstants.INTERVAL_L1);
JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane();
panel.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0));
jPanel.add(panel);
return jPanel;
}
public JPanel createAdvancePane() {
if (newForm) {
return getNewFormAdvancePane();
} else {
return getTemplateAdvancePane();
}
}
/**
* @Description: 获取的非新决策报表AdvancePane
* @param
* @return:
* @Author: Henry.Wang
* @date: 2020/11/05 15:36
*/
private JPanel getTemplateAdvancePane() {
JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane();
labelNameTextField = new UITextField();
displayReport = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Display_Nothing_Before_Query"));
UIComponentUtils.setLineWrap(displayReport);
useParamsTemplate = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Use_Params_Template"));
background = new AccessibleBackgroundEditor();
Icon[] hAlignmentIconArray = {BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_left_normal.png"),
BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_center_normal.png"),
BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_right_normal.png"),};
Integer[] hAlignment = new Integer[]{FormConstants.LEFTPOSITION, FormConstants.CENTERPOSITION, FormConstants.RIGHTPOSITION};
hAlignmentPane = new UIButtonGroup<Integer>(hAlignmentIconArray, hAlignment);
hAlignmentPane.setAllToolTips(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_StyleAlignment_Left")
, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_StyleAlignment_Center"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_StyleAlignment_Right")});
double f = TableLayout.FILL;
double p = TableLayout.PREFERRED;
double[] rowSize = {p, p, p, p, p};
double[] columnSize = {p, f};
int[][] rowCount = {{1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}};
Component[][] components = new Component[][]{
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Label_Name")), labelNameTextField},
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Base_Background")), background},
new Component[]{displayReport, null},
new Component[]{useParamsTemplate, null},
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Display_Position")), hAlignmentPane}
};
JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, IntervalConstants.INTERVAL_W0, IntervalConstants.INTERVAL_L1);
panel.setBorder(BorderFactory.createEmptyBorder(IntervalConstants.INTERVAL_L1, 0, IntervalConstants.INTERVAL_L1, 0));
CRPropertyDescriptor[] extraTableEditor = new CRPropertyDescriptor[0];
extraTableEditor = root.getExtraTableEditor();
extraPropertyGroupPane = new PropertyGroupPane(extraTableEditor, root);
jPanel.add(panel, BorderLayout.NORTH);
jPanel.add(extraPropertyGroupPane, BorderLayout.CENTER);
return jPanel;
}
/**
* @Description: 获取新决策报表的AdvancePane
* @param
* @return:
* @Author: Henry.Wang
* @date: 2020/11/05 15:36
*/
private JPanel getNewFormAdvancePane() {
JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane();
labelNameTextField = new UITextField();
displayReport = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Display_Nothing_Before_Query"));
UIComponentUtils.setLineWrap(displayReport);
useParamsTemplate = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Use_Params_Template"));
background = new AccessibleBackgroundEditor();
double f = TableLayout.FILL;
double p = TableLayout.PREFERRED;
double[] rowSize = {p, p, p, p};
double[] columnSize = {p, f};
int[][] rowCount = {{1, 1}, {1, 1}, {1, 1}, {1, 1}};
Component[][] components = new Component[][]{
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Label_Name")), labelNameTextField},
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Base_Background")), background},
new Component[]{displayReport, null},
new Component[]{useParamsTemplate, null}
};
JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, IntervalConstants.INTERVAL_W0, IntervalConstants.INTERVAL_L1);
panel.setBorder(BorderFactory.createEmptyBorder(IntervalConstants.INTERVAL_L1, 0, IntervalConstants.INTERVAL_L1, 0));
jPanel.add(panel, BorderLayout.NORTH);
return jPanel;
}
@Override
public String title4PopupWindow() {
return "parameter";
}
@Override
public void populateBean(WParameterLayout ob) {
labelNameTextField.setText(ob.getLabelName());
background.setValue(ob.getBackground());
displayReport.setSelected(ob.isDelayDisplayContent());
useParamsTemplate.setSelected(ob.isUseParamsTemplate());
if (newForm) {
FormDesigner designer = TemplateTool.getCurrentEditingNewJForm().getFormDesign();
paraHeight.setValue(designer.getParaHeight());
} else {
designerWidth.setValue(ob.getDesignWidth());
hAlignmentPane.setSelectedItem(ob.getPosition());
if (extraPropertyGroupPane != null) {
extraPropertyGroupPane.populate(ob);
}
}
}
@Override
public WParameterLayout updateBean() {
if (newForm) {
return updateNewFormBean();
} else {
return updateTemplateBean();
}
}
/**
* @Description: 更新非新决策报表的bean
* @param
* @return:
* @Author: Henry.Wang
* @date: 2020/11/05 15:36
*/
private WParameterLayout updateTemplateBean() {
WParameterLayout wParameterLayout = (WParameterLayout) creator.toData();
wParameterLayout.setLabelName(labelNameTextField.getText());
if (isCompsOutOfDesignerWidth((int) designerWidth.getValue())) {
designerWidth.setValue(wParameterLayout.getDesignWidth());
} else {
wParameterLayout.setDesignWidth((int) designerWidth.getValue());
}
wParameterLayout.setDelayDisplayContent(displayReport.isSelected());
wParameterLayout.setUseParamsTemplate(useParamsTemplate.isSelected());
JTemplate jTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate();
jTemplate.needAddTemplateIdAttr(useParamsTemplate.isSelected());
wParameterLayout.setBackground((Background) background.getValue());
wParameterLayout.setPosition((Integer) hAlignmentPane.getSelectedItem());
return wParameterLayout;
}
/**
* @Description: 更新新决策报表的bean
* @param
* @return:
* @Author: Henry.Wang
* @date: 2020/11/05 15:36
*/
private WParameterLayout updateNewFormBean() {
WParameterLayout wParameterLayout = (WParameterLayout) creator.toData();
wParameterLayout.setLabelName(labelNameTextField.getText());
wParameterLayout.setDelayDisplayContent(displayReport.isSelected());
wParameterLayout.setUseParamsTemplate(useParamsTemplate.isSelected());
JTemplate jTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate();
jTemplate.needAddTemplateIdAttr(useParamsTemplate.isSelected());
wParameterLayout.setBackground((Background) background.getValue());
//设置参数模板面板的高度
int height = (int) paraHeight.getTextField().getValue();
FormDesigner designer = TemplateTool.getCurrentEditingNewJForm().getFormDesign();
FormSelection selection = designer.getSelectionModel().getSelection();
XCreator creator = designer.getParaComponent();
Rectangle rectangle = creator.getBounds();
Rectangle newRectangle = new Rectangle(rectangle.x, rectangle.y, rectangle.width, height);
creator.setBounds(newRectangle);
if (paraHeight.getValue() != newRectangle.height)
paraHeight.setValue(newRectangle.height);
designer.setParaHeight(newRectangle.height);
designer.getArea().doLayout();
LayoutUtils.layoutContainer(creator);
selection.fixCreator(designer);
designer.repaint();
return wParameterLayout;
}
private boolean isCompsOutOfDesignerWidth(int designerWidth) {
for (int i = 0; i < root.getComponentCount(); i++) {
Component comp = root.getComponent(i);
if (comp.getX() + comp.getWidth() > designerWidth) {
return true;
}
}
return false;
}
@Override
public DataCreatorUI dataUI() {
return null;
}
}

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

@ -0,0 +1,225 @@
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.fit.attrpane.ElementEditorExtendDefinePane;
import com.fr.design.fit.attrpane.FRAbsoluteBodyLayoutExtendDefinePane;
import com.fr.design.fit.attrpane.FRAbsoluteLayoutExtendDefinePane;
import com.fr.design.fit.attrpane.FRFitLayoutExtendDefinePane;
import com.fr.design.fit.attrpane.RootDesignExtendDefinePane;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.JForm;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.mainframe.JTemplateFactory;
import com.fr.design.parameter.RootDesignDefinePane;
import com.fr.design.preview.FormAdaptivePreview;
import com.fr.design.preview.FormPreview;
import com.fr.design.widget.Appearance;
import com.fr.design.widget.FormWidgetDefinePaneFactoryBase;
import com.fr.design.widget.ui.designer.layout.ElementEditorDefinePane;
import com.fr.design.widget.ui.designer.layout.FRAbsoluteBodyLayoutDefinePane;
import com.fr.design.widget.ui.designer.layout.FRAbsoluteLayoutDefinePane;
import com.fr.design.widget.ui.designer.layout.FRFitLayoutDefinePane;
import com.fr.file.FILE;
import com.fr.file.MemFILE;
import com.fr.form.ui.ElementCaseEditor;
import com.fr.form.ui.Widget;
import com.fr.form.ui.container.WAbsoluteBodyLayout;
import com.fr.form.ui.container.WAbsoluteLayout;
import com.fr.form.ui.container.WFitLayout;
import com.fr.form.ui.container.WParameterLayout;
import com.fr.form.ui.widget.CRBoundsWidget;
import com.fr.log.FineLoggerFactory;
import com.fr.report.fit.ReportFitAttr;
import javax.swing.SwingUtilities;
/**
* Created by kerry on 2020-06-02
*/
public class AdaptiveSwitchUtil {
private static int switchJFromIng = 0;
private AdaptiveSwitchUtil() {
}
public static void switch2NewUI() {
switch2NewUIMode();
reload();
}
public static void switch2NewUIMode() {
DesignerUIModeConfig.getInstance().setNewUIMode();
FormWidgetDefinePaneFactoryBase.registerDefinePane(ElementCaseEditor.class,
new Appearance(ElementEditorExtendDefinePane.class, "elementCaseEditor"));
FormWidgetDefinePaneFactoryBase.registerDefinePane(WFitLayout.class,
new Appearance(FRFitLayoutExtendDefinePane.class, "wFitLayout"));
FormWidgetDefinePaneFactoryBase.registerDefinePane(WAbsoluteBodyLayout.class,
new Appearance(FRAbsoluteBodyLayoutExtendDefinePane.class, "wAbsoluteBodyLayout"));
FormWidgetDefinePaneFactoryBase.registerDefinePane(WAbsoluteLayout.class,
new Appearance(FRAbsoluteLayoutExtendDefinePane.class, "wAbsoluteLayout"));
FormWidgetDefinePaneFactoryBase.registerDefinePane(WParameterLayout.class,
new Appearance(RootDesignExtendDefinePane.class, "wParameterLayout"));
}
public static void switch2OldUI() {
switch2OldUIMode();
reload();
}
public static void switch2OldUIMode() {
DesignerUIModeConfig.getInstance().setOldUIMode();
FormWidgetDefinePaneFactoryBase.registerDefinePane(WAbsoluteLayout.class,
new Appearance(FRAbsoluteLayoutDefinePane.class, "wAbsoluteLayout"));
FormWidgetDefinePaneFactoryBase.registerDefinePane(ElementCaseEditor.class,
new Appearance(ElementEditorDefinePane.class, "elementCaseEditor"));
FormWidgetDefinePaneFactoryBase.registerDefinePane(WAbsoluteBodyLayout.class,
new Appearance(FRAbsoluteBodyLayoutDefinePane.class, "wAbsoluteBodyLayout"));
FormWidgetDefinePaneFactoryBase.registerDefinePane(WFitLayout.class,
new Appearance(FRFitLayoutDefinePane.class, "wFitLayout"));
FormWidgetDefinePaneFactoryBase.registerDefinePane(WParameterLayout.class,
new Appearance(RootDesignDefinePane.class, "wParameterLayout"));
}
public static void reload() {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
synchronized (AdaptiveSwitchUtil.class) {
try {
if (DesignerContext.getDesignerFrame() == null) {
return;
}
JTemplate<?, ?> old = TemplateTool.getCurrentEditingTemplate();
if (old == null || !(old instanceof JForm)) {
return;
}
JTemplate<?, ?> template = createNewJTemplate(old);
if (template != null) {
DesignTableDataManager.closeTemplate(old);
TemplateTool.resetTabPaneEditingTemplate(template);
TemplateTool.activeAndResizeTemplate(template);
setPreviewType();
}
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage());
} finally {
switchJFromIng = 0;
}
}
}
});
}
/**
* @Description: 设置预览方式
* @return: 新创建的模板
* @Author: Henry.Wang
* @date: 2020/10/13 14:08
*/
private static void setPreviewType() {
JTemplate jTemplate = TemplateTool.getCurrentEditingTemplate();
if (jTemplate != null) {
if (DesignerUIModeConfig.getInstance().newUIMode()) {
jTemplate.setPreviewType(new FormAdaptivePreview());
} else {
jTemplate.setPreviewType(new FormPreview());
}
}
}
/**
* @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()));
}
TemplateTool.saveForm(jForm);
}
return template;
}
/**
* @Description: 创建模板核心方法
* @param old 以前的方法
* @return: 新创建的模板
* @Author: Henry.Wang
* @date: 2020/9/6 14:09
*/
private static JTemplate<?, ?> createNewJTemplateInternal(JTemplate<?, ?> old) {
FILE file = old.getEditingFILE();
if ((file instanceof MemFILE) || !old.isSaved()) {
if (old instanceof NewJForm) {
TemplateTool.resetAbsoluteBodySize((NewJForm) old);
}
TemplateTool.saveForm(old);
}
return JTemplateFactory.createJTemplate(old.getEditingFILE());
}
/**
* @Description: 老模板切换到新模板的属性配置转换
* 1绝对布局-适应区域--双向自适应
* 2自适应布局-双向自适应--双向自适应
* 3自适应布局-横向自适应--横向自适应
* 4绝对布局-固定大小--不自适应
*
* @param old
* @param fitFont 字体是否自适应
* @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);
}
}
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
return null;
}
public static void setSwitchJFromIng(int switchJFromIng) {
AdaptiveSwitchUtil.switchJFromIng = switchJFromIng;
}
public static boolean isSwitchJFromIng() {
return switchJFromIng == 1;
}
}

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

File diff suppressed because it is too large Load Diff

45
designer-form/src/main/java/com/fr/design/fit/common/FormDesignerUtil.java

@ -0,0 +1,45 @@
package com.fr.design.fit.common;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XElementCase;
import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.form.FormElementCaseProvider;
import com.fr.form.ui.ElementCaseEditor;
import java.util.Iterator;
import java.util.List;
/**
* Created by kerry on 2020-06-12
*/
public class FormDesignerUtil {
private FormDesignerUtil(){
}
public static XElementCase getXelementCase(XLayoutContainer rootContainer, FormElementCaseProvider elementCaseProvider) {
for (int i = 0; i < rootContainer.getComponentCount(); i++) {
XCreator creator = rootContainer.getXCreator(i);
if (creator instanceof XElementCase && elementCaseProvider == ((ElementCaseEditor) creator.toData()).getElementCase()) {
return (XElementCase) creator;
}
if (creator instanceof XLayoutContainer) {
XElementCase temp = getXelementCase((XLayoutContainer) creator, elementCaseProvider);
if (temp != null) {
return temp;
}
}
}
return null;
}
public static void removeDeletedEC(List currentECList, List waitToProcessECList) {
Iterator iterator = waitToProcessECList.iterator();
while (iterator.hasNext()) {
Object editor = iterator.next();
if (!currentECList.contains(editor)) {
iterator.remove();
}
}
}
}

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

@ -0,0 +1,177 @@
package com.fr.design.fit.common;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.creator.XWAbsoluteBodyLayout;
import com.fr.design.designer.creator.XWAbsoluteLayout;
import com.fr.design.designer.creator.cardlayout.XWCardLayout;
import com.fr.design.designer.creator.cardlayout.XWCardMainBorderLayout;
import com.fr.design.fit.NewJForm;
import com.fr.design.mainframe.FormArea;
import com.fr.design.mainframe.JForm;
import com.fr.design.utils.gui.LayoutUtils;
import com.fr.form.ui.container.WAbsoluteBodyLayout;
import com.fr.form.ui.container.WFitLayout;
import com.fr.form.ui.container.WLayout;
import com.fr.form.ui.widget.CRBoundsWidget;
import com.fr.general.FRScreen;
import com.fr.log.FineLoggerFactory;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.Toolkit;
/**
* @description:布局工具类
* @author: Henry.Wang
* @create: 2020/09/03 14:18
*/
public class LayoutTool {
/**
* @Description: 获取布局类型
* @param jForm
* @return:
* @Author: Henry.Wang
* @date: 2020/9/6 14:31
*/
public static int getFormLayoutType(JForm jForm) {
JForm tempJForm = jForm;
if (tempJForm == null)
tempJForm = TemplateTool.getCurrentEditingNewJForm();
if (tempJForm == null || tempJForm.getFormDesign().getRootComponent() == null)
return -1;
return ((WFitLayout) tempJForm.getFormDesign().getRootComponent().toData()).getBodyLayoutType().getTypeValue();
}
/**
* @Description: 是否为绝对布局
* @param jForm
* @return:
* @Author: Henry.Wang
* @date: 2020/9/6 14:31
*/
public static boolean absoluteLayoutForm(NewJForm jForm) {
if (getFormLayoutType(jForm) == 1)
return true;
return false;
}
/**
* @Description: 如果为绝对布局则获取XWAbsoluteBodyLayout否则返回null
* @param jForm
* @return:
* @Author: Henry.Wang
* @date: 2020/9/6 14:26
*/
public static XWAbsoluteBodyLayout getXWAbsoluteBodyLayout(NewJForm jForm) {
NewJForm tempJForm = jForm;
if (tempJForm == null)
tempJForm = TemplateTool.getCurrentEditingNewJForm();
if (tempJForm != null) {
if (absoluteLayoutForm(tempJForm)) {
XLayoutContainer xLayoutContainer = tempJForm.getFormDesign().getRootComponent();
if (xLayoutContainer != null && xLayoutContainer.getComponentCount() > 0) {
Component component = xLayoutContainer.getComponent(0);
if (component instanceof XWAbsoluteBodyLayout) {
return (XWAbsoluteBodyLayout) component;
}
}
}
}
return null;
}
/**
* @Description: 通过子组件的位置获取绝对布局body的尺寸为什么不直接调用getRootComponent().toData().getContentHeight()因为在截断的情况下就不不一致了
* @param newJForm
* @return:
* @Author: Henry.Wang
* @date: 2020/9/11 15:24
*/
public static Rectangle getAbsoluteBodySize(NewJForm newJForm) {
int width = 0;
int height = 0;
XWAbsoluteBodyLayout xwAbsoluteBodyLayout = LayoutTool.getXWAbsoluteBodyLayout(newJForm);
if (xwAbsoluteBodyLayout != null) {
WAbsoluteBodyLayout wAbsoluteBodyLayout = xwAbsoluteBodyLayout.toData();
if (wAbsoluteBodyLayout.getWidgetCount() > 0) {
for (int i = 0; i < wAbsoluteBodyLayout.getWidgetCount(); i++) {
Rectangle rectangle = ((CRBoundsWidget) wAbsoluteBodyLayout.getWidget(i)).getBounds();
if (rectangle.x + rectangle.width > width)
width = rectangle.x + rectangle.width;
if (rectangle.y + rectangle.height > height)
height = rectangle.y + rectangle.height;
}
}
}
return new Rectangle(0, 0, width, height);
}
public static int getBodyHeight(NewJForm newJForm) {
return newJForm.getFormDesign().getRootComponent().toData().getContentHeight();
}
public static int getBodyWidth(NewJForm newJForm) {
return newJForm.getFormDesign().getRootComponent().toData().getContentWidth();
}
/**
* @Description: 对绝对画布块里的组件进行缩放
* @param xCreator
* @param scale 缩放比例
* @return:
* @Author: Henry.Wang
* @date: 2020/10/26 20:39
*/
public static void scaleAbsoluteBlockComponentsBounds(XCreator xCreator, Double scale) {
try {
Component[] components = xCreator.getComponents();
for (Component component : components) {
if (component instanceof XWCardMainBorderLayout) {
XWCardLayout xwCardLayout = ((XWCardMainBorderLayout)component).getCardPart();
for (Component tabComponent : xwCardLayout.getComponents()) {
scaleAbsoluteBlockComponentsBounds((XCreator) tabComponent, scale);
scaleAbsoluteBlockComponentsBoundsInternal((XCreator) tabComponent, scale);
}
} else if (component instanceof XWAbsoluteLayout) {
scaleAbsoluteBlockComponentsBounds((XCreator) component, scale);
scaleAbsoluteBlockComponentsBoundsInternal((XCreator) component, scale);
}
}
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage());
}
}
public static void scaleAbsoluteBlockComponentsBoundsInternal(XCreator parentXCreator, Double scale) {
if (parentXCreator instanceof XWAbsoluteLayout) {
XWAbsoluteLayout xwAbsoluteLayout = (XWAbsoluteLayout) parentXCreator;
Component[] absoluteComponents = xwAbsoluteLayout.getComponents();
for (Component absoluteComponent : absoluteComponents) {
XCreator xCreator = (XCreator) absoluteComponent;
Rectangle bounds = new Rectangle(absoluteComponent.getBounds());
Rectangle newBounds = new Rectangle((int) (bounds.x * scale), (int) (bounds.y * scale), (int) (bounds.width * scale), (int) (bounds.height * scale));
WLayout wAbsoluteLayout = xwAbsoluteLayout.toData();
wAbsoluteLayout.setBounds(xCreator.toData(), newBounds);
xCreator.setBounds(newBounds);
LayoutUtils.layoutContainer(xCreator);
}
}
}
/**
* @Description: 获取老预览时的缩放比例
* @return:
* @Author: Henry.Wang
* @date: 2020/10/26 20:39
*/
public static double getContainerPercent(){
Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
double screenValue = FRScreen.getFRScreenByDimension(screen).getValue();
return screenValue / FormArea.DEFAULT_SLIDER;
}
}

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

File diff suppressed because it is too large Load Diff

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

@ -0,0 +1,835 @@
/*
* 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;
}
}

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

@ -0,0 +1,214 @@
package com.fr.design.fit.common;
import com.fr.design.designer.beans.events.DesignerEvent;
import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.creator.XWAbsoluteBodyLayout;
import com.fr.design.designer.creator.XWFitLayout;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.file.MutilTempalteTabPane;
import com.fr.design.fit.DesignerUIModeConfig;
import com.fr.design.fit.JFormType;
import com.fr.design.fit.NewJForm;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.FormArea;
import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.JTemplate;
import com.fr.event.Event;
import com.fr.event.Listener;
import com.fr.file.MemFILE;
import com.fr.file.StashedFILE;
import com.fr.form.fit.common.LightTool;
import com.fr.form.fit.NewFormMarkAttr;
import com.fr.form.ui.Widget;
import com.fr.form.ui.widget.CRBoundsWidget;
import com.fr.general.ComparatorUtils;
import java.awt.Rectangle;
import java.util.List;
/**
* @description:模板工具类
* @author: Henry.Wang
* @create: 2020/09/03 14:19
*/
public class TemplateTool {
//和转换有关的所有代码都在这个监听器中
//在判断新老模式时,统一使用FormUIModeConfig.getInstance().newUIMode()进行判断
private static Listener<JTemplate> switchListener = new Listener<JTemplate>() {
@Override
public void on(Event event, JTemplate jTemplate) {
JFormType currentType = JFormType.OLD_TYPE;
if (AdaptiveSwitchUtil.isSwitchJFromIng()) {
currentType = DesignerUIModeConfig.getInstance().newUIMode() ? JFormType.NEW_TYPE : JFormType.OLD_TYPE;
} else {
if (jTemplate instanceof NewJForm) {
NewJForm newJForm = (NewJForm) jTemplate;
if (newJForm.mobileForm()) {
currentType = JFormType.OLD_TYPE;
} else if (LightTool.containNewFormFlag(newJForm.getTarget()) || newJForm.getTarget().getTemplateID() == null) {
currentType = JFormType.NEW_TYPE;
}
}
}
//UI转换
currentType.switchUIMode();
//标志位转换
currentType.updateJFromTemplateType(jTemplate);
//预览方式转换
currentType.updatePreviewType(jTemplate);
}
};
public static Listener<JTemplate> getSwitchListener() {
return switchListener;
}
/**
* @param
* @Description: 获取当前模板
* @return:
* @Author: Henry.Wang
* @date: 2020/9/6 14:17
*/
public static JTemplate getCurrentEditingTemplate() {
JTemplate jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
return jTemplate;
}
/**
* @param
* @Description: 获取当前NewJForm类型的模板
* @return:
* @Author: Henry.Wang
* @date: 2020/9/6 14:17
*/
public static NewJForm getCurrentEditingNewJForm() {
JTemplate jTemplate = getCurrentEditingTemplate();
if (jTemplate instanceof NewJForm)
return (NewJForm) jTemplate;
return null;
}
/**
* @param newJTemplate
* @Description: 每次切换设计模式都会生成新的JForm对象但是TabPane关联的还是老的JForm对象所以要重置关联的对象
* @return:
* @Author: Henry.Wang
* @date: 2020/9/6 14:15
*/
public static void resetTabPaneEditingTemplate(JTemplate newJTemplate) {
if (newJTemplate == null)
return;
List<JTemplate<?, ?>> jTemplateList = HistoryTemplateListCache.getInstance().getHistoryList();
for (int i = 0; i < jTemplateList.size(); i++) {
JTemplate oldJTemplate = jTemplateList.get(i);
if (oldJTemplate != null && ComparatorUtils.equals(oldJTemplate.getEditingFILE(), newJTemplate.getEditingFILE())) {
jTemplateList.set(i, newJTemplate);
MutilTempalteTabPane.getInstance().refreshOpenedTemplate(jTemplateList);
return;
}
}
}
/**
* @param jTemplate
* @Description: 是否是新建的且没有操作的模板
* @return:
* @Author: Henry.Wang
* @date: 2020/9/14 20:41
*/
public static boolean isNewTemplateWithoutModify(JTemplate jTemplate) {
return ((jTemplate.getEditingFILE() instanceof MemFILE) && jTemplate.isSaved()) ? true : false;
}
/**
* @param template
* @Description: 激活模板
* @return:
* @Author: Henry.Wang
* @date: 2020/9/6 14:16
*/
public static void activeAndResizeTemplate(JTemplate template) {
DesignerContext.getDesignerFrame().addAndActivateJTemplate(template);
DesignerContext.getDesignerFrame().setVisible(true);
DesignerContext.getDesignerFrame().resizeFrame();
}
/**
* @param jTemplate
* @Description:保存模板
* @return:
* @Author: Henry.Wang
* @date: 2020/9/6 14:32
*/
public static void saveForm(JTemplate<?, ?> jTemplate) {
//为空不保存
if (jTemplate == null)
return;
//不是NewJForm的模板不保存
if (!(jTemplate instanceof NewJForm))
return;
//切换环境时产生的模板不保存
if (jTemplate.getEditingFILE() instanceof StashedFILE)
return;
//新建的且没有操作的模板不保存
if (TemplateTool.isNewTemplateWithoutModify(jTemplate))
return;
jTemplate.stopEditing();
jTemplate.saveTemplate();
jTemplate.requestFocus();
}
/**
* @param height
* @param width
* @param newJForm
* @Description: 只改变绝对布局body的尺寸
* @return:
* @Author: Henry.Wang
* @date: 2020/9/11 15:14
*/
public static void onlyChangeAbsoluteBodySize(int height, int width, NewJForm newJForm) {
FormDesigner formDesigner = newJForm.getFormDesign();
FormArea formArea = formDesigner.getArea();
XLayoutContainer root = formDesigner.getRootComponent();
XWAbsoluteBodyLayout xwAbsoluteBodyLayout = LayoutTool.getXWAbsoluteBodyLayout(newJForm);
if (root.acceptType(XWFitLayout.class) && xwAbsoluteBodyLayout != null) {
XWFitLayout layout = (XWFitLayout) root;
if (height == layout.toData().getContainerHeight() && width == layout.toData().getContainerWidth())
return;
formArea.setWidthPaneValue(width);
formArea.setHeightPaneValue(height);
layout.setSize(width, height);
xwAbsoluteBodyLayout.setSize(width, height);
Widget widget = layout.toData().getWidget(0);
if (widget instanceof CRBoundsWidget) {
((CRBoundsWidget) widget).setBounds(new Rectangle(0, 0, width, height));
}
layout.toData().setContainerWidth(width);
layout.toData().setContainerHeight(height);
formArea.doReCalculateRoot(width, height, layout);
}
formDesigner.getEditListenerTable().fireCreatorModified(DesignerEvent.CREATOR_EDITED);
}
/**
* @param newJForm
* @Description: 因为新老模板切换有截断的问题所以body的尺寸会在调用onlyChangeAbsoluteBodySize之后发生改变为了使模板文件中的尺寸不发生要在模板保存时调用此函数
* @return:
* @Author: Henry.Wang
* @date: 2020/9/11 15:20
*/
public static void resetAbsoluteBodySize(NewJForm newJForm) {
if (LayoutTool.absoluteLayoutForm(newJForm)) {
NewFormMarkAttr newFormMarkAttr = newJForm.getTarget().getAttrMark(NewFormMarkAttr.XML_TAG);
XLayoutContainer root = newJForm.getFormDesign().getRootComponent();
if (newFormMarkAttr != null && root instanceof XWFitLayout) {
((XWFitLayout) root).toData().setContainerWidth(newFormMarkAttr.getBodyWidth());
((XWFitLayout) root).toData().setContainerHeight(newFormMarkAttr.getBodyHeight());
}
}
}
}

303
designer-form/src/main/java/com/fr/design/fit/menupane/BrowserFitAttrPane.java

@ -0,0 +1,303 @@
package com.fr.design.fit.menupane;
import com.fr.config.Configuration;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.fit.FitStateCompatible;
import com.fr.design.fit.JFormType;
import com.fr.form.fit.FitType;
import com.fr.form.fit.config.FormFitConfig;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ibutton.UIRadioButton;
import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.report.fit.ReportFitAttr;
import com.fr.stable.StringUtils;
import com.fr.transaction.Configurations;
import com.fr.transaction.Worker;
import javax.swing.BorderFactory;
import javax.swing.ButtonGroup;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Cursor;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
/**
* Created by Administrator on 2016/5/5/0005.
*/
public class BrowserFitAttrPane extends BasicBeanPane<ReportFitAttr> {
protected FontRadioGroup fontRadioGroup;
protected FitRadioGroup fitRadionGroup;
protected UICheckBox globalCheck;
protected FitPreviewPane fitPreviewPane;
protected ReportFitAttr localFitAttr;
protected UIRadioButton horizonRadio;
protected UIRadioButton doubleRadio;
protected UIRadioButton notFitRadio;
protected UIRadioButton fontFitRadio;
protected UIRadioButton fontNotFitRadio;
private UIButton editGlobalOps;
private JPanel borderPane;
private JPanel globalOpsPane;
private JPanel fitOpsPane;
private final JFormType jFormType;
public BrowserFitAttrPane(JFormType jFormType, ReportFitAttr fitAttr) {
this.jFormType = jFormType;
if (fitAttr == null) {
initComponents(jFormType.obtainFitAttr());
} else {
initComponents(fitAttr);
}
}
protected void initComponents(ReportFitAttr globalFitAttr) {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
globalOpsPane = initGlobalOpsPane(globalFitAttr);
this.add(globalOpsPane, BorderLayout.NORTH);
fitOpsPane = initFitOpsPane();
}
protected void initBorderPane(String title) {
borderPane = FRGUIPaneFactory.createTitledBorderPaneCenter(title);
borderPane.setLayout(new FlowLayout(FlowLayout.LEFT, 10, 0));
borderPane.add(fitOpsPane, BorderLayout.WEST);
fitPreviewPane = new FitPreviewPane();
borderPane.add(fitPreviewPane, BorderLayout.SOUTH);
borderPane.add(getHintUILabel());
this.add(borderPane, BorderLayout.CENTER);
}
/**
* @Description: 获取提示信息
* @param
* @return:
* @Author: Henry.Wang
* @date: 2020/9/9 16:09
*/
private UILabel getHintUILabel() {
String hint = globalCheck.isSelected() ? getFillBlank(3) + Toolkit.i18nText("Fine-Designer_Fit_Attr_Pane_Hint") : StringUtils.EMPTY;
UILabel hintUILabel = new UILabel(hint);
hintUILabel.setForeground(new Color(143, 143, 146));
return hintUILabel;
}
/**
* @Description: 获取空字符串
* @param n
* @return:
* @Author: Henry.Wang
* @date: 2020/9/9 16:09
*/
private String getFillBlank(int n) {
String s = "";
for (int i = 0; i < n; i++) {
s = s + " ";
}
return s;
}
private JPanel initFitOpsPane() {
double p = TableLayout.PREFERRED;
double[] rowSize = {p, p};
double[] columnSize = {p, p, p, p, p};
ActionListener actionListener = getPreviewActionListener();
fontRadioGroup = new FontRadioGroup();
fontFitRadio = new UIRadioButton(Toolkit.i18nText("Fine-Designer_Fit") + getFillBlank(4));
fontFitRadio.setSelected(true);
fontNotFitRadio = new UIRadioButton(Toolkit.i18nText("Fine-Designer_Fit-No") + getFillBlank(2));
addRadioToGroup(fontRadioGroup, fontFitRadio, fontNotFitRadio);
fontRadioGroup.addActionListener(actionListener);
fitRadionGroup = new FitRadioGroup();
horizonRadio = new UIRadioButton(FitType.HORIZONTAL_FIT.description());
doubleRadio = new UIRadioButton(FitType.DOUBLE_FIT.description());
notFitRadio = new UIRadioButton(FitType.NOT_FIT.description());
addRadioToGroup(fitRadionGroup, doubleRadio, horizonRadio, notFitRadio);
fitRadionGroup.addActionListener(actionListener);
JPanel fitOpsPane = TableLayoutHelper.createTableLayoutPane(initFitComponents(), rowSize, columnSize);
fitOpsPane.setBorder(BorderFactory.createEmptyBorder(10, 13, 10, 10));
return fitOpsPane;
}
protected Component[][] initFitComponents() {
UILabel fitFontLabel = new UILabel(Toolkit.i18nText("Fine-Designer_Fit-Font"));
fitFontLabel.setHorizontalAlignment(SwingConstants.RIGHT);
UILabel reportFitLabel = new UILabel(Toolkit.i18nText("Fine-Designer_Fit_Report_Scale_Method"));
reportFitLabel.setHorizontalAlignment(SwingConstants.RIGHT);
Component[][] components = new Component[][]{
new Component[]{fitFontLabel, createFontRadioGroupPane()},
new Component[]{reportFitLabel, createFitAttrRadioGroupPane()}
};
return components;
}
private JPanel createFontRadioGroupPane() {
JPanel panel = FRGUIPaneFactory.createLeftFlowZeroGapBorderPane();
panel.setLayout(new FlowLayout(FlowLayout.LEFT, 30, 0));
panel.add(fontFitRadio);
panel.add(fontNotFitRadio);
return panel;
}
private JPanel createFitAttrRadioGroupPane() {
JPanel panel = FRGUIPaneFactory.createLeftFlowZeroGapBorderPane();
panel.setLayout(new FlowLayout(FlowLayout.LEFT, 30, 0));
panel.add(doubleRadio);
panel.add(horizonRadio);
panel.add(notFitRadio);
return panel;
}
private void addRadioToGroup(ButtonGroup buttonGroup, UIRadioButton... radios) {
for (UIRadioButton radio : radios) {
buttonGroup.add(radio);
}
}
private JPanel initGlobalOpsPane(final ReportFitAttr globalFitAttr) {
final JPanel globalOpsPane = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane();
globalCheck = new UICheckBox(Toolkit.i18nText("Fine-Designer_Fit-UseGlobal"));
globalOpsPane.add(globalCheck);
globalCheck.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
boolean isLocalConfig = !globalCheck.isSelected();
//勾选全局时,采用全局保存的自适应属性更新界面
if (!isLocalConfig) {
ReportFitAttr attr = globalFitAttr;
populateAttrPane(attr);
remove(BrowserFitAttrPane.this.borderPane);
initBorderPane(Toolkit.i18nText("Fine-Designer_Fit-Global"));
} else {
ReportFitAttr attr = localFitAttr;
populateAttrPane(attr);
remove(BrowserFitAttrPane.this.borderPane);
initBorderPane(Toolkit.i18nText("Fine-Designer_Fit-Local"));
}
fontRadioGroup.setEnabled(isLocalConfig);
fitRadionGroup.setEnabled(isLocalConfig);
editGlobalOps.setVisible(!isLocalConfig);
String fitOptions = getCurrentFitOptions();
fitPreviewPane.refreshPreview(fitOptions, fitRadionGroup.isEnabled());
}
});
editGlobalOps = new UIButton(Toolkit.i18nText("Fine-Designer_Fit-EditGlobal"));
editGlobalOps.setVisible(false);
editGlobalOps.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent evt) {
fontRadioGroup.setEnabled(true);
fitRadionGroup.setEnabled(true);
String fitOptions = getCurrentFitOptions();
fitPreviewPane.refreshPreview(fitOptions, fitRadionGroup.isEnabled());
}
public void mouseEntered(MouseEvent e) {
setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
}
public void mouseExited(MouseEvent e) {
setCursor(Cursor.getDefaultCursor());
}
});
globalOpsPane.add(editGlobalOps);
return globalOpsPane;
}
@Override
protected String title4PopupWindow() {
return Toolkit.i18nText("Fine-Designer_Fit-AttrSet");
}
@Override
public void populateBean(ReportFitAttr attr) {
if (attr == null) {
//如果为空, 就用全局的
attr = this.jFormType.obtainFitAttr();
populateGlobalComponents();
} else {
initBorderPane(Toolkit.i18nText("Fine-Designer_Fit-Local"));
}
this.localFitAttr = attr;
populateAttrPane(attr);
}
private void populateAttrPane(ReportFitAttr attr) {
fontRadioGroup.selectFontFit((attr).isFitFont());
int fitState = FitStateCompatible.getNewTypeFromOld(attr.fitStateInPC());
fitRadionGroup.selectIndexButton(fitState);
fitPreviewPane.refreshPreview(getCurrentFitOptions(), fitRadionGroup.isEnabled());
}
protected void populateGlobalComponents() {
globalCheck.setSelected(true);
fontRadioGroup.setEnabled(false);
fitRadionGroup.setEnabled(false);
editGlobalOps.setVisible(true);
initBorderPane(Toolkit.i18nText("Fine-Designer_Fit-Global"));
}
//有八种组合, 不过有意义的就是6种, 以此为key去缓存里找对应的预览图片
public String getCurrentFitOptions() {
return fitRadionGroup.getSelectRadioIndex() + "" + fontRadioGroup.getSelectRadioIndex();
}
private ActionListener getPreviewActionListener() {
return new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
String fitOptions = getCurrentFitOptions();
fitPreviewPane.refreshPreview(fitOptions, fontRadioGroup.isEnabled());
}
};
}
@Override
public ReportFitAttr updateBean() {
ReportFitAttr attr = new ReportFitAttr();
attr.setFitFont(fontRadioGroup.isFontFit());
int fitState = FitStateCompatible.getOldTypeFromNew(fitRadionGroup.getSelectRadioIndex());
attr.setFitStateInPC(fitState);
// 直接用全局的
if (globalCheck.isSelected()) {
updateGlobalConfig(attr);
return null;
}
this.localFitAttr = attr;
return attr;
}
private void updateGlobalConfig(final ReportFitAttr attr) {
Configurations.update(new Worker() {
@Override
public void run() {
jFormType.updateFitAttr(attr);
}
@Override
public Class<? extends Configuration>[] targets() {
return new Class[]{FormFitConfig.class};
}
});
}
}

76
designer-form/src/main/java/com/fr/design/fit/menupane/FitPreviewPane.java

@ -0,0 +1,76 @@
package com.fr.design.fit.menupane;
import com.fr.design.dialog.BasicPane;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.general.IOUtils;
import javax.swing.ImageIcon;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.util.HashMap;
import java.util.Map;
/**
* Created by Administrator on 2016/5/5/0005.
*/
public class FitPreviewPane extends BasicPane {
private static final String DEFAULT_FONT_TAG = "00";
private static final String DEFAULT_TAG = "01";
private static final String HORIZON_FONT_TAG = "10";
private static final String HORIZON_TAG = "11";
private static final String DOUBLE_FONT_TAG = "20";
private static final String DOUBLE_TAG = "21";
private static final String NOT_FONT_TAG = "30";
private static final String NOT_TAG = "31";
private UILabel imageLabel;
private Map<String, ImageIcon> cachedPreviewImage = new HashMap<String, ImageIcon>();
private Map<String, ImageIcon> globalCachedPreviewImage = new HashMap<String, ImageIcon>();
public FitPreviewPane() {
//初始化缓存图片, 有些无意义的组合.
initCacheImage();
//初始化组件
initComponents();
this.setPreferredSize(new Dimension(540, 170));
}
//默认和不自适应时,字体自适应不起效,只有6张图
private void initCacheImage() {
globalCachedPreviewImage.put(DEFAULT_FONT_TAG, new ImageIcon(IOUtils.readImage("/com/fr/design/images/reportfit/preview/gray/" + DOUBLE_FONT_TAG + ".png")));
globalCachedPreviewImage.put(DEFAULT_TAG, new ImageIcon(IOUtils.readImage("/com/fr/design/images/reportfit/preview/gray/" + DOUBLE_TAG + ".png")));
globalCachedPreviewImage.put(HORIZON_FONT_TAG, new ImageIcon(IOUtils.readImage("/com/fr/design/images/reportfit/preview/gray/" + HORIZON_FONT_TAG + ".png")));
globalCachedPreviewImage.put(HORIZON_TAG, new ImageIcon(IOUtils.readImage("/com/fr/design/images/reportfit/preview/gray/" + HORIZON_TAG + ".png")));
globalCachedPreviewImage.put(DOUBLE_FONT_TAG, new ImageIcon(IOUtils.readImage("/com/fr/design/images/reportfit/preview/gray/" + NOT_FONT_TAG + ".png")));
globalCachedPreviewImage.put(DOUBLE_TAG, new ImageIcon(IOUtils.readImage("/com/fr/design/images/reportfit/preview/gray/" + NOT_FONT_TAG + ".png")));
cachedPreviewImage.put(DEFAULT_FONT_TAG, new ImageIcon(IOUtils.readImage("/com/fr/design/images/reportfit/preview/" + DOUBLE_FONT_TAG + ".png")));
cachedPreviewImage.put(DEFAULT_TAG, new ImageIcon(IOUtils.readImage("/com/fr/design/images/reportfit/preview/" + DOUBLE_TAG + ".png")));
cachedPreviewImage.put(HORIZON_FONT_TAG, new ImageIcon(IOUtils.readImage("/com/fr/design/images/reportfit/preview/" + HORIZON_FONT_TAG + ".png")));
cachedPreviewImage.put(HORIZON_TAG, new ImageIcon(IOUtils.readImage("/com/fr/design/images/reportfit/preview/" + HORIZON_TAG + ".png")));
cachedPreviewImage.put(DOUBLE_FONT_TAG, new ImageIcon(IOUtils.readImage("/com/fr/design/images/reportfit/preview/" + NOT_FONT_TAG + ".png")));
cachedPreviewImage.put(DOUBLE_TAG, new ImageIcon(IOUtils.readImage("/com/fr/design/images/reportfit/preview/" + NOT_FONT_TAG + ".png")));
}
private void initComponents() {
this.setLayout(FRGUIPaneFactory.createCenterFlowLayout());
imageLabel = new UILabel();
ImageIcon image = cachedPreviewImage.get(DEFAULT_TAG);
imageLabel.setIcon(image);
this.add(imageLabel, BorderLayout.CENTER);
}
public void refreshPreview(String index, boolean isEditedable) {
ImageIcon newImageIcon = isEditedable ? cachedPreviewImage.get(index) : globalCachedPreviewImage.get(index);
imageLabel.setIcon(newImageIcon);
}
@Override
protected String title4PopupWindow() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit-Preview");
}
}

80
designer-form/src/main/java/com/fr/design/fit/menupane/FitRadioGroup.java

@ -0,0 +1,80 @@
package com.fr.design.fit.menupane;
import com.fr.design.gui.ibutton.UIRadioButton;
import javax.swing.AbstractButton;
import javax.swing.ButtonGroup;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.List;
/**
* 自适应四个按钮选项的group
* <p>
* Created by Administrator on 2016/5/5/0005.
*/
public class FitRadioGroup extends ButtonGroup {
private List<UIRadioButton> radioButtons = new ArrayList<UIRadioButton>();
@Override
public void add(AbstractButton button) {
super.add(button);
UIRadioButton radioButton = (UIRadioButton) button;
radioButtons.add(radioButton);
}
/**
* 设置按钮状态
*/
public boolean isEnabled() {
return radioButtons.get(0).isEnabled();
}
/**
* 设置按钮状态
*/
public void setEnabled(boolean enabled) {
for (UIRadioButton radioButton : radioButtons) {
radioButton.setEnabled(enabled);
}
}
/**
* 获取当前选中的按钮index
*
* @return 按钮index
*/
public int getSelectRadioIndex() {
for (int i = 0, len = radioButtons.size(); i < len; i++) {
if (radioButtons.get(i).isSelected()) {
return i;
}
}
return 0;
}
/**
* 选中指定index的按钮
*/
public void selectIndexButton(int index) {
if (index < 0 || index > radioButtons.size() - 1) {
return;
}
UIRadioButton button = radioButtons.get(index);
button.setSelected(true);
}
/**
* 给所有的按钮加上监听
*/
public void addActionListener(ActionListener actionListener) {
for (UIRadioButton radioButton : radioButtons) {
radioButton.addActionListener(actionListener);
}
}
}

17
designer-form/src/main/java/com/fr/design/fit/menupane/FontRadioGroup.java

@ -0,0 +1,17 @@
package com.fr.design.fit.menupane;
/**
* 字体的两个选项组成的group
* <p>
* Created by Administrator on 2016/5/5/0005.
*/
public class FontRadioGroup extends FitRadioGroup {
public void selectFontFit(boolean isFontFit) {
selectIndexButton(isFontFit ? 0 : 1);
}
public boolean isFontFit() {
return getSelectRadioIndex() == 0;
}
}

58
designer-form/src/main/java/com/fr/design/fit/menupane/FormFitAttrPane.java

@ -0,0 +1,58 @@
package com.fr.design.fit.menupane;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.fit.NewJForm;
import com.fr.report.fit.ReportFitAttr;
import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
/**
* Created by Administrator on 2015/7/6 0006.
*/
public class FormFitAttrPane extends BasicBeanPane<ReportFitAttr> {
private BrowserFitAttrPane attrPane;
private NewJForm newJForm;
public FormFitAttrPane(NewJForm newJForm) {
this.newJForm = newJForm;
initComponents();
}
private void initComponents() {
this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
this.setBorder(BorderFactory.createEmptyBorder(10, 10, 2, 10));
attrPane = new BrowserFitAttrPane(this.newJForm.getJFormType(),this.newJForm.getTarget().getReportFitAttr());
this.add(attrPane);
}
/**
* 展示界面
*
* @param fitAttr 自适应属性
*/
public void populateBean(ReportFitAttr fitAttr) {
attrPane.populateBean(fitAttr);
}
/**
* 提交数据
*
* @return 界面上的更新数据
*/
public ReportFitAttr updateBean() {
return attrPane.updateBean();
}
/**
* 标题
*
* @return 标题
*/
protected String title4PopupWindow() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit_PC_Adaptive_Attr");
}
}

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

@ -0,0 +1,287 @@
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;
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.JTemplate;
import com.fr.design.menu.MenuKeySet;
import com.fr.file.FILE;
import com.fr.file.FILEChooserPane;
import com.fr.file.FileFILE;
import com.fr.file.FileNodeFILE;
import com.fr.file.MemFILE;
import com.fr.file.filetree.FileNode;
import com.fr.general.IOUtils;
import com.fr.log.FineLoggerFactory;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.KeyStroke;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.nio.file.Paths;
import static javax.swing.JOptionPane.OK_CANCEL_OPTION;
import static javax.swing.JOptionPane.WARNING_MESSAGE;
import static javax.swing.JOptionPane.YES_NO_OPTION;
/**
* Created by kerry on 2020-06-02
*/
public class SwitchAction extends UpdateAction {
private UIButton switchBtn;
private static final Icon SWITCH_ICON = IOUtils.readIcon("/com/fr/design/form/images/icon_switch.png");
private static final String LOADING_ICON_PATH = "/com/fr/design/form/images/loading.png";
private static final MenuKeySet SWITCH_ATTR = new MenuKeySet() {
@Override
public char getMnemonic() {
return 'C';
}
@Override
public String getMenuName() {
return Toolkit.i18nText("Fine-Designer_Fit_Switch_To_Old_UI");
}
@Override
public KeyStroke getKeyStroke() {
return null;
}
};
public SwitchAction() {
initMenuStyle();
}
private void initMenuStyle() {
this.setMenuKeySet(SWITCH_ATTR);
this.setName(getMenuKeySet().getMenuKeySetName());
this.setMnemonic(getMenuKeySet().getMnemonic());
this.setSmallIcon(SWITCH_ICON);
this.setAccelerator(getMenuKeySet().getKeyStroke());
switchBtn = (UIButton) this.createToolBarComponent();
switchBtn.set4ToolbarButton();
switchBtn.setIcon(SWITCH_ICON);
Font oldFont = switchBtn.getFont();
switchBtn.setFont(new Font(oldFont.getName(),oldFont.getStyle(),12));
switchBtn.setForeground(new Color(0x33, 0x33, 0x34));
freshSwitchButton();
}
@Override
public void actionPerformed(ActionEvent e) {
//如果此时模板还在切换中,则直接返回
if (AdaptiveSwitchUtil.isSwitchJFromIng() || !saveCurrentEditingTemplate())
return;
backToFormTab();
if (confirmSwitchDialog() && backUpOldModeJTemplate()) {
AdaptiveSwitchUtil.setSwitchJFromIng(1);
showLoadingJPanel();
if (DesignerUIModeConfig.getInstance().newUIMode()) {
AdaptiveSwitchUtil.switch2OldUI();
} else {
AdaptiveSwitchUtil.switch2NewUI();
}
}
}
/**
* @Description: 对未存储在磁盘的模板进行界面切换
* @return:
* @Author: Henry.Wang
* @date: 2020/10/22 17:26
*/
public boolean saveCurrentEditingTemplate() {
JTemplate jTemplate = TemplateTool.getCurrentEditingTemplate();
if (!(jTemplate.getEditingFILE() instanceof FileNodeFILE) || !jTemplate.getEditingFILE().exists()) {
int returnVal = FineJOptionPane.showConfirmDialog(
DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Design_Basic_Web_Preview_Message"),
Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"),
OK_CANCEL_OPTION,
WARNING_MESSAGE);
if (returnVal == JOptionPane.YES_OPTION) {
jTemplate.stopEditing();
if ((jTemplate.getEditingFILE() instanceof MemFILE) || !jTemplate.getEditingFILE().exists()) {
return jTemplate.saveTemplate();
} else if (jTemplate.getEditingFILE() instanceof FileFILE) {
return jTemplate.saveAsTemplate2Env();
}
}
return false;
}
return true;
}
/**
* @Description: 显示加载中界面
* @param
* @return:
* @Author: Henry.Wang
* @date: 2020/9/30 15:18
*/
public void showLoadingJPanel() {
JComponent area = TemplateTool.getCurrentEditingNewJForm().getFormDesign().getArea();
JComponent formDesigner = TemplateTool.getCurrentEditingNewJForm().getFormDesign();
area.remove(formDesigner);
JPanel loadingJPanel = new JPanel(new BorderLayout());
loadingJPanel.setBackground(Color.WHITE);
loadingJPanel.setBounds(formDesigner.getBounds());
JLabel jLabel = new JLabel(new ImageIcon(this.getClass().getResource(LOADING_ICON_PATH)), JLabel.CENTER);
loadingJPanel.add(jLabel, BorderLayout.CENTER);
area.setLayout(null);
area.add(loadingJPanel);
DesignerContext.getDesignerFrame().setVisible(true);
}
/**
* @Description: 如果是在报表块编辑状态进行切换时会先回到表单页
* @param
* @return:
* @Author: Henry.Wang
* @date: 2020/9/30 15:20
*/
private void backToFormTab() {
NewJForm newJForm = TemplateTool.getCurrentEditingNewJForm();
if (newJForm != null && newJForm.getEditingReportIndex() != BaseJForm.FORM_TAB) {
newJForm.tabChanged(BaseJForm.FORM_TAB);
}
}
/**
* @param
* @Description: 备份老设计模式下的模板文件
* @return:
* @Author: Henry.Wang
* @date: 2020/9/23 16:24
*/
private boolean backUpOldModeJTemplate() {
JTemplate<?, ?> jTemplate = TemplateTool.getCurrentEditingTemplate();
if (jTemplate != null && !DesignerUIModeConfig.getInstance().newUIMode()) {
FILE editingFILE = jTemplate.getEditingFILE();
if (editingFILE != null && editingFILE.exists()) {
try {
//待备份的文件名称
String fileName = editingFILE.getName().substring(0, editingFILE.getName().length() - jTemplate.suffix().length()) + "_bak";
//生成要备份的文件对象
FILE backUpFile = null;
FileNodeFILE directory = getFileParentDirectory(jTemplate.getEditingFILE());
if (directory != null)
backUpFile = new FileNodeFILE(directory, fileName + jTemplate.suffix(), false);
//要备份的文件存在
if (backUpFile != null && backUpFile.exists()) {
if (!confirmCoverFileDialog()) {
FILEChooserPane fileChooser = FILEChooserPane.getInstance(true, true);
fileChooser.setFileNameTextField(fileName, jTemplate.suffix());
fileChooser.setCurrentDirectory(directory);
int chooseResult = fileChooser.showSaveDialog(DesignerContext.getDesignerFrame(), jTemplate.suffix());
if ((chooseResult == FILEChooserPane.CANCEL_OPTION) ||
(chooseResult == FILEChooserPane.JOPTIONPANE_CANCEL_OPTION)) {
return false;
}
backUpFile = fileChooser.getSelectedFILE();
}
}
jTemplate.getTarget().export(backUpFile.asOutputStream());
TemplateTreePane.getInstance().refresh();
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage());
return false;
}
return true;
}
}
return true;
}
/**
* @param file
* @Description: 获得当前文件的父目录
* @return:
* @Author: Henry.Wang
* @date: 2020/9/23 16:50
*/
public static FileNodeFILE getFileParentDirectory(FILE file) {
FileNodeFILE fileParent = null;
if (file instanceof FileNodeFILE) {
FileNodeFILE fileNodeFILE = (FileNodeFILE) file;
FileNode fileNode = new FileNode(Paths.get(fileNodeFILE.getPath()).getParent().toString(), true);
fileParent = new FileNodeFILE(fileNode, fileNodeFILE.getEnvPath());
}
return fileParent;
}
/**
* @param
* @Description: 确认是否弹出框
* @return: 点击确定返回true
* @Author: Henry.Wang
* @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");
int returnVal = FineJOptionPane.showConfirmDialog(
DesignerContext.getDesignerFrame(),
message,
Toolkit.i18nText("Fine-Design_Basic_Confirm"),
YES_NO_OPTION);
return returnVal == JOptionPane.YES_OPTION;
}
/**
* @param
* @Description: 是否覆盖文件
* @return:
* @Author: Henry.Wang
* @date: 2020/9/23 17:00
*/
private boolean confirmCoverFileDialog() {
int returnVal = FineJOptionPane.showConfirmDialog(
DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Designer_Fit_Cover_File_Switch"),
Toolkit.i18nText("Fine-Design_Basic_Confirm"),
YES_NO_OPTION);
return returnVal == JOptionPane.YES_OPTION;
}
/**
* @param
* @Description:更新按钮的状态
* @return:
* @Author: Henry.Wang
* @date: 2020/8/31 16:39
*/
public UIButton freshSwitchButton() {
if (DesignerUIModeConfig.getInstance().newUIMode()) {
switchBtn.setToolTipText(Toolkit.i18nText("Fine-Designer_Fit_Switch_To_Old_UI"));
switchBtn.setText(Toolkit.i18nText("Fine-Designer_Fit_Switch_To_Old_Version"));
} else {
switchBtn.setToolTipText(Toolkit.i18nText("Fine-Designer_Fit_Switch_To_New_UI"));
switchBtn.setText(Toolkit.i18nText("Fine-Designer_Fit_Switch_To_New_Version"));
}
return switchBtn;
}
public UIButton getToolBarButton() {
return freshSwitchButton();
}
}

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

@ -1,10 +1,10 @@
package com.fr.design.mainframe; package com.fr.design.mainframe;
import com.fr.design.constants.UIConstants; import com.fr.design.constants.UIConstants;
import com.fr.design.fit.DesignerUIModeConfig;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.icon.IconPathConstants; import com.fr.design.icon.IconPathConstants;
import com.fr.share.ShareConstants; import com.fr.share.ShareConstants;
import com.fr.general.FRScreen;
import com.fr.general.IOUtils; import com.fr.general.IOUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
@ -63,7 +63,7 @@ public class CoverReportPane extends CoverPane implements HelpDialogHandler{
// controlMode = IOUtils.readIcon(IconPathConstants.TD_EL_SHARE_CLOSE_ICON_PATH); // controlMode = IOUtils.readIcon(IconPathConstants.TD_EL_SHARE_CLOSE_ICON_PATH);
controlButton.setVisible(false); controlButton.setVisible(false);
helpDialog = new WidgetHelpDialog(DesignerContext.getDesignerFrame(), helpMsg); helpDialog = new WidgetHelpDialog(DesignerContext.getDesignerFrame(), helpMsg);
double screenValue = FRScreen.getDesignScreenByDimension(Toolkit.getDefaultToolkit().getScreenSize()).getValue(); double screenValue = DesignerUIModeConfig.getInstance().getDesignScreenByDimension(Toolkit.getDefaultToolkit().getScreenSize()).getValue();
int offsetX = 0; int offsetX = 0;
if (screenValue < FormArea.DEFAULT_SLIDER) { if (screenValue < FormArea.DEFAULT_SLIDER) {
offsetX = (int) ((1 - screenValue / FormArea.DEFAULT_SLIDER) offsetX = (int) ((1 - screenValue / FormArea.DEFAULT_SLIDER)

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

@ -1,14 +1,13 @@
package com.fr.design.mainframe; package com.fr.design.mainframe;
import com.fr.base.ScreenResolution;
import com.fr.common.inputevent.InputEventBaseOnOS; import com.fr.common.inputevent.InputEventBaseOnOS;
import com.fr.design.designer.beans.events.DesignerEditListener;
import com.fr.design.designer.beans.events.DesignerEvent; import com.fr.design.designer.beans.events.DesignerEvent;
import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XLayoutContainer; import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.creator.XWBorderLayout; import com.fr.design.designer.creator.XWBorderLayout;
import com.fr.design.designer.creator.XWFitLayout; import com.fr.design.designer.creator.XWFitLayout;
import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.fit.DesignerUIModeConfig;
import com.fr.form.fit.NewFormMarkAttr;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itextfield.UINumberField; import com.fr.design.gui.itextfield.UINumberField;
import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayout;
@ -79,7 +78,6 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
private boolean isValid = true; private boolean isValid = true;
// 初始时滑块值为100,托动后的值设为START_VALUE; // 初始时滑块值为100,托动后的值设为START_VALUE;
private double START_VALUE = DEFAULT_SLIDER; private double START_VALUE = DEFAULT_SLIDER;
private int resolution = ScreenResolution.getScreenResolution();
private double screenValue; private double screenValue;
@ -253,7 +251,7 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
private void initCalculateSize() { private void initCalculateSize() {
Toolkit toolkit = Toolkit.getDefaultToolkit(); Toolkit toolkit = Toolkit.getDefaultToolkit();
Dimension scrnsize = toolkit.getScreenSize(); Dimension scrnsize = toolkit.getScreenSize();
this.screenValue = FRScreen.getDesignScreenByDimension(scrnsize).getValue(); this.screenValue = DesignerUIModeConfig.getInstance().getDesignScreenByDimension(scrnsize).getValue();
XLayoutContainer root = FormArea.this.designer.getRootComponent(); XLayoutContainer root = FormArea.this.designer.getRootComponent();
// 7.1.1不放缩放滑块,但表单大小仍按屏幕分辨率调整 // 7.1.1不放缩放滑块,但表单大小仍按屏幕分辨率调整
// slidePane.populateBean(screenValue); // slidePane.populateBean(screenValue);
@ -285,10 +283,19 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
// 失去焦点时,可以认为输入结束 // 失去焦点时,可以认为输入结束
int width = (int) ((UINumberField) e.getSource()).getValue(); int width = (int) ((UINumberField) e.getSource()).getValue();
changeWidthPaneValue(width); changeWidthPaneValue(width);
changeFormMarkAttrWidth(width);
} }
}); });
} }
private void changeFormMarkAttrWidth(int width) {
NewFormMarkAttr newFormMarkAttr = designer.getTarget().getAttrMark(NewFormMarkAttr.XML_TAG);
if (newFormMarkAttr != null) {
newFormMarkAttr.setBodyWidth(width);
}
}
private void changeWidthPaneValue(int width) { private void changeWidthPaneValue(int width) {
XWFitLayout layout = (XWFitLayout) designer.getRootComponent(); XWFitLayout layout = (XWFitLayout) designer.getRootComponent();
if (width != layout.toData().getContainerWidth()) { if (width != layout.toData().getContainerWidth()) {
@ -303,6 +310,7 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
public void actionPerformed(ActionEvent evt) { public void actionPerformed(ActionEvent evt) {
int height = (int) ((UINumberField) evt.getSource()).getValue(); int height = (int) ((UINumberField) evt.getSource()).getValue();
changeHeightPaneValue(height); changeHeightPaneValue(height);
changeFormMarkAttrHeight(height);
} }
}); });
heightPane.addFocusListener( heightPane.addFocusListener(
@ -315,6 +323,14 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
}); });
} }
private void changeFormMarkAttrHeight(int height){
NewFormMarkAttr newFormMarkAttr = designer.getTarget().getAttrMark(NewFormMarkAttr.XML_TAG);
if (newFormMarkAttr != null) {
newFormMarkAttr.setBodyHeight(height);
}
}
private void changeHeightPaneValue(int height) { private void changeHeightPaneValue(int height) {
XWFitLayout layout = (XWFitLayout) designer.getRootComponent(); XWFitLayout layout = (XWFitLayout) designer.getRootComponent();
if (height != layout.toData().getContainerHeight()) { if (height != layout.toData().getContainerHeight()) {
@ -383,7 +399,7 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
/** /**
* 修改大小后再根据屏幕分辨率调整下 * 修改大小后再根据屏幕分辨率调整下
*/ */
private void doReCalculateRoot(int width, int height, XWFitLayout layout) { public void doReCalculateRoot(int width, int height, XWFitLayout layout) {
// double value = slidePane.updateBean(); // double value = slidePane.updateBean();
//重置滑块的值为默认值100 //重置滑块的值为默认值100
START_VALUE = DEFAULT_SLIDER; START_VALUE = DEFAULT_SLIDER;

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

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

53
designer-form/src/main/java/com/fr/design/preview/DeveloperPreview.java

@ -0,0 +1,53 @@
package com.fr.design.preview;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.fun.impl.AbstractPreviewProvider;
import com.fr.design.mainframe.JForm;
import com.fr.design.mainframe.JTemplate;
import com.fr.general.web.ParameterConstants;
import java.util.HashMap;
import java.util.Map;
/**
* Created by kerry on 2020-04-23
*/
public class DeveloperPreview extends AbstractPreviewProvider {
private static final int PREVIEW_TYPE = 7;
@Override
public String nameForPopupItem() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit_Developer_Preview");
}
@Override
public String iconPathForPopupItem() {
return "com/fr/design/form/images/developer_preview.png";
}
@Override
public String iconPathForLarge() {
return "com/fr/design/form/images/developer_preview24.png";
}
@Override
public int previewTypeCode() {
return PREVIEW_TYPE;
}
@Override
public Map<String, Object> parametersForPreview() {
Map<String, Object> map = new HashMap<String, Object>();
map.put(ParameterConstants.OP, "developer_preview");
return map;
}
@Override
public boolean accept(JTemplate jTemplate) {
if (jTemplate == null) {
jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
}
return jTemplate instanceof JForm;
}
}

54
designer-form/src/main/java/com/fr/design/preview/FormAdaptivePreview.java

@ -0,0 +1,54 @@
package com.fr.design.preview;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.fun.impl.AbstractPreviewProvider;
import com.fr.design.mainframe.JForm;
import com.fr.design.mainframe.JTemplate;
import com.fr.general.web.ParameterConstants;
import java.util.HashMap;
import java.util.Map;
/**
* Created by kerry on 2020-04-23
*/
public class FormAdaptivePreview extends AbstractPreviewProvider {
private static final int PREVIEW_TYPE = 6;
public static final String PREVIEW_OP = "form_adaptive";
@Override
public String nameForPopupItem() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit_New_Form_Preview");
}
@Override
public String iconPathForPopupItem() {
return "com/fr/design/images/buttonicon/runs.png";
}
@Override
public String iconPathForLarge() {
return "com/fr/design/images/buttonicon/run24.png";
}
@Override
public int previewTypeCode() {
return PREVIEW_TYPE;
}
@Override
public Map<String, Object> parametersForPreview() {
Map<String, Object> map = new HashMap<String, Object>();
map.put(ParameterConstants.OP, PREVIEW_OP);
return map;
}
@Override
public boolean accept(JTemplate jTemplate) {
if (jTemplate == null) {
jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
}
return jTemplate instanceof JForm;
}
}

BIN
designer-form/src/main/resources/com/fr/design/form/images/developer_preview.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 542 B

BIN
designer-form/src/main/resources/com/fr/design/form/images/developer_preview24.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 862 B

BIN
designer-form/src/main/resources/com/fr/design/form/images/icon_form_tab.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 130 B

BIN
designer-form/src/main/resources/com/fr/design/form/images/icon_switch.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 304 B

BIN
designer-form/src/main/resources/com/fr/design/form/images/icon_switch_disable.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 296 B

BIN
designer-form/src/main/resources/com/fr/design/form/images/icon_switch_new_ui.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 413 B

BIN
designer-form/src/main/resources/com/fr/design/form/images/icon_switch_old_ui.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 417 B

BIN
designer-form/src/main/resources/com/fr/design/form/images/loading.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.5 KiB

24
designer-form/src/test/java/com/fr/design/fit/FitStateCompatibleTest.java

@ -0,0 +1,24 @@
package com.fr.design.fit;
import org.junit.Assert;
import org.junit.Test;
/**
* Created by kerry on 2020-04-27
*/
public class FitStateCompatibleTest {
@Test
public void testGetNewTypeFromOld() {
Assert.assertEquals(0, FitStateCompatible.getNewTypeFromOld(0));
Assert.assertEquals(1, FitStateCompatible.getNewTypeFromOld(1));
Assert.assertEquals(0, FitStateCompatible.getNewTypeFromOld(2));
Assert.assertEquals(2, FitStateCompatible.getNewTypeFromOld(3));
}
@Test
public void testGetOldTypeFromNew() {
Assert.assertEquals(2, FitStateCompatible.getOldTypeFromNew(0));
Assert.assertEquals(1, FitStateCompatible.getOldTypeFromNew(1));
Assert.assertEquals(3, FitStateCompatible.getOldTypeFromNew(2));
}
}

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

@ -0,0 +1,22 @@
package com.fr.design.fit;
import org.junit.Assert;
import org.junit.Test;
/**
* Created by kerry on 2020-06-05
*/
public class FormUIModeConfigTest {
@Test
public void testSetNewUIMode(){
DesignerUIModeConfig.getInstance().setNewUIMode();
Assert.assertTrue(DesignerUIModeConfig.getInstance().newUIMode());
}
@Test
public void testSetOldUIMode(){
Assert.assertTrue(DesignerUIModeConfig.getInstance().newUIMode());
DesignerUIModeConfig.getInstance().setOldUIMode();
Assert.assertFalse(DesignerUIModeConfig.getInstance().newUIMode());
}
}

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

@ -0,0 +1,49 @@
package com.fr.design.fit;
import com.fr.base.ScreenResolution;
import com.fr.stable.unit.FU;
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;
/**
* Created by kerry on 2020-04-24
*/
@RunWith(PowerMockRunner.class)
@PrepareForTest(ScreenResolution.class)
public class PXReportLengthUNITTest {
@Test
public void testUnitText() {
PXReportLengthUNIT pxReportLengthUNIT = new PXReportLengthUNIT();
Assert.assertEquals(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Px"), pxReportLengthUNIT.unitText());
}
@Test
public void testUnitType() {
PXReportLengthUNIT pxReportLengthUNIT = new PXReportLengthUNIT();
Assert.assertEquals(4, pxReportLengthUNIT.unitType());
}
@Test
public void testUnit2Value4Scale() {
PXReportLengthUNIT pxReportLengthUNIT = new PXReportLengthUNIT();
PowerMock.mockStatic(ScreenResolution.class);
EasyMock.expect(ScreenResolution.getScreenResolution()).andReturn(96).once();
PowerMock.replayAll();
Assert.assertEquals(12, (int) pxReportLengthUNIT.unit2Value4Scale(FU.getInstance(457200L)));
}
@Test
public void testFloat2UNIT() {
PowerMock.mockStatic(ScreenResolution.class);
EasyMock.expect(ScreenResolution.getScreenResolution()).andReturn(96).once();
PowerMock.replayAll();
PXReportLengthUNIT pxReportLengthUNIT = new PXReportLengthUNIT();
Assert.assertEquals(457200L, pxReportLengthUNIT.float2UNIT(12.0F).toFU());
}
}

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

@ -0,0 +1,64 @@
package com.fr.design.fit;
import com.fr.base.ScreenResolution;
import com.fr.invoke.Reflect;
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.math.BigDecimal;
/**
* Created by kerry on 2020-04-26
*/
@RunWith(PowerMockRunner.class)
@PrepareForTest(ScreenResolution.class)
public class PXTest {
@Test
public void testGetScaleNumber(){
PowerMock.mockStatic(ScreenResolution.class);
EasyMock.expect(ScreenResolution.getScreenResolution()).andReturn(96).once();
PowerMock.replayAll();
PX px = new PX(100F);
BigDecimal scaleNumber = Reflect.on(px).call("getScaleNumber").get();
Assert.assertEquals(100L, scaleNumber.longValue());
}
@Test
public void testGetMoreFUScale() {
PowerMock.mockStatic(ScreenResolution.class);
EasyMock.expect(ScreenResolution.getScreenResolution()).andReturn(96).times(2);
PowerMock.replayAll();
PX px = new PX(100F);
long fuScale = Reflect.on(px).call("getMoreFUScale").get();
Assert.assertEquals(381L, fuScale);
}
@Test
public void testToPixI(){
PowerMock.mockStatic(ScreenResolution.class);
EasyMock.expect(ScreenResolution.getScreenResolution()).andReturn(96).times(2);
PowerMock.replayAll();
PX px = new PX(100F);
Assert.assertEquals(100, px.toPixI(96));
px = new PX(19.5F);
Assert.assertEquals(19.5F, px.toPixF(96), 0.0F);
}
@Test
public void testToPixWithResolution(){
Assert.assertEquals(100D, PX.toPixWithResolution(100D, 96), 0.0D);
Assert.assertEquals(19.5D, PX.toPixWithResolution(19.5D, 96), 0.0D);
Assert.assertEquals(150D, PX.toPixWithResolution(100D, 144), 0.0D);
Assert.assertEquals(29.25D, PX.toPixWithResolution(19.5D, 144), 0.0D);
}
}

38
designer-form/src/test/java/com/fr/design/fit/common/FormDesignerUtilTest.java

@ -0,0 +1,38 @@
package com.fr.design.fit.common;
import org.junit.Assert;
import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
/**
* Created by kerry on 2020-06-12
*/
public class FormDesignerUtilTest {
@Test
public void testRemoveDeletedEC(){
List<String> list1 = new ArrayList<String>();
List<String> list2 = new ArrayList<String>();
list2.add("test2");
list2.add("test3");
list2.add("test4");
FormDesignerUtil.removeDeletedEC(list1, list2);
Assert.assertEquals(0, list2.size());
list1.add("test1");
list1.add("test3");
list2.add("test2");
list2.add("test3");
list2.add("test4");
FormDesignerUtil.removeDeletedEC(list1, list2);
Assert.assertEquals(1, list2.size());
Assert.assertEquals("test3", list2.get(0));
list1.remove("test3");
FormDesignerUtil.removeDeletedEC(list1, list2);
Assert.assertEquals(0, list2.size());
}
}

28
designer-form/src/test/java/com/fr/design/preview/DeveloperPreviewTest.java

@ -0,0 +1,28 @@
package com.fr.design.preview;
import com.fr.design.mainframe.JForm;
import com.fr.general.web.ParameterConstants;
import org.easymock.EasyMock;
import org.junit.Assert;
import org.junit.Test;
import java.util.Map;
/**
* Created by kerry on 2020-04-24
*/
public class DeveloperPreviewTest {
@Test
public void testParametersForPreview() {
DeveloperPreview formPreview = new DeveloperPreview();
Map<String, Object> map = formPreview.parametersForPreview();
Assert.assertEquals(1, map.size());
Assert.assertEquals("developer_preview", map.get(ParameterConstants.OP));
}
@Test
public void testAccept() {
DeveloperPreview formPreview = new DeveloperPreview();
Assert.assertTrue(formPreview.accept(EasyMock.mock(JForm.class)));
}
}

30
designer-form/src/test/java/com/fr/design/preview/FormAdaptivePreviewTest.java

@ -0,0 +1,30 @@
package com.fr.design.preview;
import com.fr.design.mainframe.JForm;
import com.fr.design.mainframe.JWorkBook;
import com.fr.general.web.ParameterConstants;
import org.easymock.EasyMock;
import org.junit.Assert;
import org.junit.Test;
import java.util.Map;
/**
* Created by kerry on 2020-04-24
*/
public class FormAdaptivePreviewTest {
@Test
public void testParametersForPreview() {
FormAdaptivePreview formPreview = new FormAdaptivePreview();
Map<String, Object> map = formPreview.parametersForPreview();
Assert.assertEquals(1, map.size());
Assert.assertEquals("form_adaptive", map.get(ParameterConstants.OP));
}
@Test
public void testAccept() {
FormAdaptivePreview formPreview = new FormAdaptivePreview();
Assert.assertTrue(formPreview.accept(EasyMock.mock(JForm.class)));
Assert.assertFalse(formPreview.accept(EasyMock.mock(JWorkBook.class)));
}
}

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

@ -4,6 +4,7 @@
package com.fr.design.actions.columnrow; package com.fr.design.actions.columnrow;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.fit.DesignerUIModeConfig;
import com.fr.design.fun.ReportLengthUNITProvider; import com.fr.design.fun.ReportLengthUNITProvider;
import com.fr.design.gui.frpane.UnitInputPane; import com.fr.design.gui.frpane.UnitInputPane;
import com.fr.design.gui.frpane.UnitInputPane.ValueNotChangeException; import com.fr.design.gui.frpane.UnitInputPane.ValueNotChangeException;
@ -11,8 +12,6 @@ import com.fr.design.mainframe.DesignerContext;
import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.mainframe.ElementCasePane; import com.fr.design.mainframe.ElementCasePane;
import com.fr.design.fun.ReportLengthUNITProvider;
import com.fr.design.unit.UnitConvertUtil;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.grid.selection.CellSelection; import com.fr.grid.selection.CellSelection;
import com.fr.report.elementcase.ElementCase; import com.fr.report.elementcase.ElementCase;
@ -51,7 +50,7 @@ public abstract class ColumnRowSizingAction extends AbstractColumnRowIndexAction
try { try {
float newHeight = (float) uPane.update(); float newHeight = (float) uPane.update();
int unitType = DesignerEnvManager.getEnvManager().getReportLengthUnit(); int unitType = DesignerEnvManager.getEnvManager().getReportLengthUnit();
ReportLengthUNITProvider lengthUNIT = UnitConvertUtil.parseLengthUNIT(unitType); ReportLengthUNITProvider lengthUNIT = DesignerUIModeConfig.getInstance().parseLengthUNIT(unitType);
UNIT newLen = lengthUNIT.float2UNIT(newHeight); UNIT newLen = lengthUNIT.float2UNIT(newHeight);
if (!ComparatorUtils.equals(oldLen, newLen)) { if (!ComparatorUtils.equals(oldLen, newLen)) {
updateAction(report, newLen, finalCS); updateAction(report, newLen, finalCS);
@ -68,7 +67,7 @@ public abstract class ColumnRowSizingAction extends AbstractColumnRowIndexAction
protected void populateNumberDialog(final UnitInputPane uPane, UNIT unit) { protected void populateNumberDialog(final UnitInputPane uPane, UNIT unit) {
int unitType = DesignerEnvManager.getEnvManager().getReportLengthUnit(); int unitType = DesignerEnvManager.getEnvManager().getReportLengthUnit();
ReportLengthUNITProvider lengthUNIT = UnitConvertUtil.parseLengthUNIT(unitType); ReportLengthUNITProvider lengthUNIT = DesignerUIModeConfig.getInstance().parseLengthUNIT(unitType);
float va = lengthUNIT.unit2Value4Scale(unit); float va = lengthUNIT.unit2Value4Scale(unit);
uPane.setUnitText(lengthUNIT.unitText()); uPane.setUnitText(lengthUNIT.unitText());
uPane.populate(va); uPane.populate(va);

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

@ -1,10 +1,10 @@
package com.fr.design.condition; package com.fr.design.condition;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.fit.DesignerUIModeConfig;
import com.fr.design.fun.ReportLengthUNITProvider;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.ispinner.UIBasicSpinner; import com.fr.design.gui.ispinner.UIBasicSpinner;
import com.fr.design.fun.ReportLengthUNITProvider;
import com.fr.design.unit.UnitConvertUtil;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.report.cell.cellattr.highlight.HighlightAction; import com.fr.report.cell.cellattr.highlight.HighlightAction;
@ -47,7 +47,7 @@ public abstract class WHPane extends ConditionAttrSingleConditionPane<HighlightA
public void populate(HighlightAction ha, JSpinner sp) { public void populate(HighlightAction ha, JSpinner sp) {
int unitType = DesignerEnvManager.getEnvManager().getReportLengthUnit(); int unitType = DesignerEnvManager.getEnvManager().getReportLengthUnit();
UNIT width = getUnit(ha); UNIT width = getUnit(ha);
ReportLengthUNITProvider lengthUNIT = UnitConvertUtil.parseLengthUNIT(unitType); ReportLengthUNITProvider lengthUNIT = DesignerUIModeConfig.getInstance().parseLengthUNIT(unitType);
double va = lengthUNIT.unit2Value4Scale(width); double va = lengthUNIT.unit2Value4Scale(width);
unitLabel.setText(lengthUNIT.unitText()); unitLabel.setText(lengthUNIT.unitText());
// 只保留两位 // 只保留两位
@ -59,7 +59,7 @@ public abstract class WHPane extends ConditionAttrSingleConditionPane<HighlightA
protected String getUnitString() { protected String getUnitString() {
int unitType = DesignerEnvManager.getEnvManager().getReportLengthUnit(); int unitType = DesignerEnvManager.getEnvManager().getReportLengthUnit();
ReportLengthUNITProvider lengthUNIT = UnitConvertUtil.parseLengthUNIT(unitType); ReportLengthUNITProvider lengthUNIT = DesignerUIModeConfig.getInstance().parseLengthUNIT(unitType);
return lengthUNIT.unitText(); return lengthUNIT.unitText();
} }
@ -68,7 +68,7 @@ public abstract class WHPane extends ConditionAttrSingleConditionPane<HighlightA
// 只保留两位 // 只保留两位
newWidth = new Float(new BigDecimal(newWidth + "").setScale(2, BigDecimal.ROUND_DOWN).floatValue()); newWidth = new Float(new BigDecimal(newWidth + "").setScale(2, BigDecimal.ROUND_DOWN).floatValue());
int unitType = DesignerEnvManager.getEnvManager().getReportLengthUnit(); int unitType = DesignerEnvManager.getEnvManager().getReportLengthUnit();
ReportLengthUNITProvider lengthUNIT = UnitConvertUtil.parseLengthUNIT(unitType); ReportLengthUNITProvider lengthUNIT = DesignerUIModeConfig.getInstance().parseLengthUNIT(unitType);
UNIT width = lengthUNIT.float2UNIT(newWidth); UNIT width = lengthUNIT.float2UNIT(newWidth);
return returnAction(width); return returnAction(width);
} }

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

@ -0,0 +1,27 @@
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);
}
}
}

123
designer-realize/src/main/java/com/fr/design/fit/grid/AdaptiveGridListener.java

@ -0,0 +1,123 @@
package com.fr.design.fit.grid;
import com.fr.grid.Grid;
import javax.swing.BorderFactory;
import javax.swing.JToolTip;
import javax.swing.JWindow;
import javax.swing.SwingUtilities;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Point;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import java.awt.event.MouseWheelEvent;
import java.awt.event.MouseWheelListener;
/**
* Created by kerry on 2020-04-23
*/
public class AdaptiveGridListener implements MouseMotionListener, MouseListener, MouseWheelListener {
private JWindow tipWindow = null;
private JToolTip tip = null;
private Grid grid;
private int width;
private int height;
private int actualWidth;
private int actualHeight;
public AdaptiveGridListener(Grid grid, int width, int height, int actualWidth, int actualHeight) {
this.grid = grid;
this.width = width;
this.height = height;
this.actualWidth = actualWidth;
this.actualHeight = actualHeight;
}
@Override
public void mouseDragged(MouseEvent e) {
}
public void resetBoundInfo(int width, int height, int actualWidth, int actualHeight) {
this.width = width;
this.height = height;
this.actualWidth = actualWidth;
this.actualHeight = actualHeight;
}
@Override
public void mouseMoved(MouseEvent e) {
if (Math.abs(e.getX() - width) < 5 && e.getY() >= 0 && e.getY() < height) {
Point convertPoint = new Point(width, 0);
SwingUtilities.convertPointToScreen(convertPoint, grid);
showToolTip(grid, e, actualWidth + 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, height);
SwingUtilities.convertPointToScreen(convertPoint, grid);
showToolTip(grid, e, actualHeight + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Px"), convertPoint);
return;
} 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);
}
}
@Override
public void mouseClicked(MouseEvent e) {
}
@Override
public void mousePressed(MouseEvent e) {
}
@Override
public void mouseReleased(MouseEvent e) {
}
@Override
public void mouseEntered(MouseEvent e) {
}
@Override
public void mouseExited(MouseEvent e) {
hideToolTip();
}
@Override
public void mouseWheelMoved(MouseWheelEvent e) {
hideToolTip();
}
}

186
designer-realize/src/main/java/com/fr/design/fit/grid/ElementCasePaneUtil.java

@ -0,0 +1,186 @@
package com.fr.design.fit.grid;
import com.fr.base.vcs.DesignerMode;
import com.fr.design.actions.cell.CleanAuthorityAction;
import com.fr.design.actions.columnrow.CancelColumnAction;
import com.fr.design.actions.columnrow.CancelRowAction;
import com.fr.design.actions.columnrow.ColumnHideAction;
import com.fr.design.actions.columnrow.ColumnWidthAction;
import com.fr.design.actions.columnrow.DeleteColumnAction;
import com.fr.design.actions.columnrow.DeleteRowAction;
import com.fr.design.actions.columnrow.FootColumnAction;
import com.fr.design.actions.columnrow.FootRowAction;
import com.fr.design.actions.columnrow.HeadColumnAction;
import com.fr.design.actions.columnrow.HeadRowAction;
import com.fr.design.actions.columnrow.InsertColumnAction;
import com.fr.design.actions.columnrow.InsertRowAction;
import com.fr.design.actions.columnrow.ResetColumnHideAction;
import com.fr.design.actions.columnrow.ResetRowHideAction;
import com.fr.design.actions.columnrow.RowHeightAction;
import com.fr.design.actions.columnrow.RowHideAction;
import com.fr.design.gui.imenu.UIPopupMenu;
import com.fr.design.mainframe.ElementCasePane;
import com.fr.grid.GridUtils;
import com.fr.grid.selection.CellSelection;
import com.fr.page.ReportPageAttrProvider;
import com.fr.report.elementcase.ElementCase;
import com.fr.stable.ColumnRow;
import javax.swing.JPopupMenu;
import java.awt.event.MouseEvent;
/**
* Created by kerry on 2020-04-28
*/
public class ElementCasePaneUtil {
public static UIPopupMenu createColumnPopupMenu(ElementCasePane reportPane, MouseEvent evt, int selectedColumn) {
UIPopupMenu popupMenu = new UIPopupMenu();
if (DesignerMode.isAuthorityEditing()) {
popupMenu.add(new CleanAuthorityAction(reportPane).createMenuItem());
return popupMenu;
}
InsertColumnAction insertColumnAction = new InsertColumnAction(reportPane, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Utils_Insert_Column"));
DeleteColumnAction deleteColumnAction = new DeleteColumnAction(reportPane, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Utils_Delete_Column"));
ColumnWidthAction columnWidthAction = new ColumnWidthAction(reportPane, selectedColumn);
ColumnHideAction columnHideAction = new ColumnHideAction(reportPane, selectedColumn);
ResetColumnHideAction resetRowHideAction = new ResetColumnHideAction(reportPane, selectedColumn);
popupMenu.add(insertColumnAction.createMenuItem());
popupMenu.add(deleteColumnAction.createMenuItem());
popupMenu.addSeparator();
popupMenu.add(columnWidthAction.createMenuItem());
CellSelection cs = (CellSelection) reportPane.getSelection();
addColumnMenu(reportPane, popupMenu, evt, cs.getColumn(), cs.getColumn() + cs.getColumnSpan() - 1);
popupMenu.add(columnHideAction.createMenuItem());
popupMenu.add(resetRowHideAction.createMenuItem());
return popupMenu;
}
private static void addColumnMenu(ElementCasePane reportPane, UIPopupMenu popupMenu, MouseEvent evt, int selectedColumnsFrom, int selectedColumnsTo) {
HeadColumnAction headcolumnAction = new HeadColumnAction(reportPane);
FootColumnAction footcolumnAction = new FootColumnAction(reportPane);
ColumnRow selectedCellPoint = GridUtils.getAdjustEventColumnRow_withresolution(reportPane, evt.getX(), evt.getY(), reportPane.getResolution());
ElementCase elementCase = reportPane.getEditingElementCase();
boolean cancel = false;
ReportPageAttrProvider reportPageAttr = elementCase.getReportPageAttr();
if (reportPageAttr != null) {
popupMenu.addSeparator();
popupMenu.add(headcolumnAction.createMenuItem());
popupMenu.add(footcolumnAction.createMenuItem());
int from = reportPageAttr.getRepeatHeaderColumnFrom();
int to = reportPageAttr.getRepeatHeaderColumnTo();
int from2 = reportPageAttr.getRepeatFooterColumnFrom();
int to2 = reportPageAttr.getRepeatFooterColumnTo();
int column = selectedCellPoint.getColumn();
if (column >= selectedColumnsFrom && column <= selectedColumnsTo) {
cancel = isCancel(elementCase, selectedColumnsFrom, selectedColumnsTo, from, to, from2, to2);
} else {
if (elementCase.getReportPageAttr() != null) {
if (column == from || column == to || column == from2 || column == to2) {
cancel = true;
}
}
}
if (cancel) {
CancelColumnAction cancelAction = new CancelColumnAction(reportPane);
popupMenu.add(cancelAction.createMenuItem());
}
}
}
private static boolean isCancel(ElementCase report, int selectedColumnsFrom, int selectedColumnsTo, int from, int to, int from2, int to2) {
boolean cancel = false;
if (report.getReportPageAttr() != null) {
if (from == selectedColumnsFrom && to == selectedColumnsTo) {
cancel = true;
}
if (from2 == selectedColumnsFrom && to2 == selectedColumnsTo) {
cancel = true;
}
}
return cancel;
}
public static UIPopupMenu createRowPopupMenu(ElementCasePane reportPane, MouseEvent evt, int selectedRows) {
UIPopupMenu popupMenu = new UIPopupMenu();
if (DesignerMode.isAuthorityEditing()) {
popupMenu.add(new CleanAuthorityAction(reportPane).createMenuItem());
return popupMenu;
}
InsertRowAction insertRowAction = new InsertRowAction(reportPane, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Utils_Insert_Row"));
DeleteRowAction deleteRowAction = new DeleteRowAction(reportPane, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Utils_Delete_Row"));
RowHeightAction rowHeightAction = new RowHeightAction(reportPane, selectedRows);
RowHideAction rowHideAction = new RowHideAction(reportPane, selectedRows);
ResetRowHideAction resetRowHideAction = new ResetRowHideAction(reportPane, selectedRows);
popupMenu.add(insertRowAction.createMenuItem());
popupMenu.add(deleteRowAction.createMenuItem());
popupMenu.addSeparator();
popupMenu.add(rowHeightAction.createMenuItem());
CellSelection cs = (CellSelection) reportPane.getSelection();
addRowMenu(reportPane, popupMenu, evt, cs.getRow(), cs.getRow() + cs.getRowSpan() - 1);
popupMenu.add(rowHideAction.createMenuItem());
popupMenu.add(resetRowHideAction.createMenuItem());
return popupMenu;
}
private static void addRowMenu(ElementCasePane reportPane, JPopupMenu popupMenu, MouseEvent evt, int selectedRowsFrom, int selectedRowsTo) {
HeadRowAction headrowAction = new HeadRowAction(reportPane);
FootRowAction footrowAction = new FootRowAction(reportPane);
ElementCase elementCase = reportPane.getEditingElementCase();
boolean cancel = false;
ColumnRow selectedCellPoint = GridUtils.getAdjustEventColumnRow_withresolution(reportPane, evt.getX(), evt.getY(), reportPane.getResolution());
ReportPageAttrProvider reportPageAttr = elementCase.getReportPageAttr();
ElementCase report = reportPane.getEditingElementCase();
if (reportPageAttr != null) {
popupMenu.addSeparator();
popupMenu.add(headrowAction.createMenuItem());
popupMenu.add(footrowAction.createMenuItem());
int from = report.getReportPageAttr().getRepeatHeaderRowFrom();
int to = report.getReportPageAttr().getRepeatHeaderRowTo();
int from2 = report.getReportPageAttr().getRepeatFooterRowFrom();
int to2 = report.getReportPageAttr().getRepeatFooterRowTo();
if (selectedCellPoint.getRow() >= selectedRowsFrom && selectedCellPoint.getRow() <= selectedRowsTo) {
cancel = isCancel(report, selectedRowsFrom, selectedRowsTo, from, to, from2, to2);
} else {
int row = selectedCellPoint.getRow();
if (report.getReportPageAttr() != null) {
if (row == from || row == to || row == from2 || row == to2) {
cancel = true;
}
}
}
if (cancel) {
CancelRowAction cancelAction = new CancelRowAction(reportPane);
popupMenu.add(cancelAction.createMenuItem());
}
}
}
}

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

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

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

@ -0,0 +1,190 @@
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();
}
}

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

@ -0,0 +1,190 @@
package com.fr.design.fit.grid;
import com.fr.design.designer.creator.XElementCase;
import com.fr.design.fit.AdaptiveCellElementPainter;
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 = rectangle.width - columnWidthList.getRangeValue(0, horizontalValue).toPixI(resolution);
int height = rectangle.height - rowHeightList.getRangeValue(0, verticalValue).toPixI(resolution);
drawBoundsLine(g2d, width, height);
addListener(grid, elementCasePane, width, height, rectangle.width, rectangle.height);
}
/**
* 获取需要画线的矩形大小
*/
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);
}
}

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

@ -67,6 +67,7 @@ import com.fr.design.constants.UIConstants;
import com.fr.design.designer.EditingState; import com.fr.design.designer.EditingState;
import com.fr.design.designer.TargetComponent; import com.fr.design.designer.TargetComponent;
import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.fit.DesignerUIModeConfig;
import com.fr.design.fun.ElementUIProvider; import com.fr.design.fun.ElementUIProvider;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.imenu.UIPopupMenu; import com.fr.design.gui.imenu.UIPopupMenu;
@ -225,7 +226,7 @@ public abstract class ElementCasePane<T extends TemplateElementCase> extends Tar
//todo 直接修改分辨率 //todo 直接修改分辨率
if (this.resolution == 0) { if (this.resolution == 0) {
this.resolution = ScreenResolution.getScreenResolution(); this.resolution = DesignerUIModeConfig.getInstance().getScreenResolution();
} }
this.initGridComponent(); this.initGridComponent();
@ -351,10 +352,10 @@ public abstract class ElementCasePane<T extends TemplateElementCase> extends Tar
this.grid = new Grid(this.resolution); this.grid = new Grid(this.resolution);
} }
if (this.gridColumn == null) { if (this.gridColumn == null) {
this.gridColumn = new GridColumn(); this.gridColumn = new GridColumn(this.resolution);
} }
if (this.gridRow == null) { if (this.gridRow == null) {
this.gridRow = new GridRow(); this.gridRow = new GridRow(this.resolution);
} }
if (this.gridCorner == null) { if (this.gridCorner == null) {
this.gridCorner = new GridCorner(); this.gridCorner = new GridCorner();
@ -1375,7 +1376,7 @@ public abstract class ElementCasePane<T extends TemplateElementCase> extends Tar
protected Selection selection; protected Selection selection;
protected int verticalValue = 0; protected int verticalValue = 0;
protected int horizontalValue = 0; protected int horizontalValue = 0;
protected int resolution = ScreenResolution.getScreenResolution(); protected int resolution = DesignerUIModeConfig.getInstance().getScreenResolution();
protected ElementCaseEditingState(Selection selection, int verticalValue, int horizontalValue, int resolution) { protected ElementCaseEditingState(Selection selection, int verticalValue, int horizontalValue, int resolution) {
try { try {

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

@ -13,6 +13,7 @@ import com.fr.design.designer.EditingState;
import com.fr.design.designer.TargetComponent; import com.fr.design.designer.TargetComponent;
import com.fr.design.event.TargetModifiedEvent; import com.fr.design.event.TargetModifiedEvent;
import com.fr.design.event.TargetModifiedListener; import com.fr.design.event.TargetModifiedListener;
import com.fr.design.fit.DesignerUIModeConfig;
import com.fr.design.gui.frpane.HyperlinkGroupPane; import com.fr.design.gui.frpane.HyperlinkGroupPane;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.AuthorityEditPane; import com.fr.design.mainframe.AuthorityEditPane;
@ -137,6 +138,9 @@ public class FormElementCaseDesigner
g.setColor(Color.WHITE); g.setColor(Color.WHITE);
g.fillRect(0, 0, size.width, size.height); g.fillRect(0, 0, size.width, size.height);
g.setColor(oldColor); g.setColor(oldColor);
if (DesignerUIModeConfig.getInstance().newUIMode()) {
g.translate(-elementCasePane.getGridCorner().getWidth(), -elementCasePane.getGridCorner().getHeight());
}
this.elementCasePane.paintComponents(g); this.elementCasePane.paintComponents(g);

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

@ -2,13 +2,12 @@ package com.fr.grid;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.base.DynamicUnitList; import com.fr.base.DynamicUnitList;
import com.fr.base.ScreenResolution;
import com.fr.base.vcs.DesignerMode; import com.fr.base.vcs.DesignerMode;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.fit.DesignerUIModeConfig;
import com.fr.design.fun.ReportLengthUNITProvider; import com.fr.design.fun.ReportLengthUNITProvider;
import com.fr.design.gui.imenu.UIPopupMenu; import com.fr.design.gui.imenu.UIPopupMenu;
import com.fr.design.mainframe.ElementCasePane; import com.fr.design.mainframe.ElementCasePane;
import com.fr.design.unit.UnitConvertUtil;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.grid.selection.CellSelection; import com.fr.grid.selection.CellSelection;
import com.fr.grid.selection.FloatSelection; import com.fr.grid.selection.FloatSelection;
@ -39,7 +38,7 @@ import java.lang.reflect.Method;
public abstract class AbstractGridHeaderMouseHandler extends MouseInputAdapter { public abstract class AbstractGridHeaderMouseHandler extends MouseInputAdapter {
protected static final int SEPARATOR_GAP = 5; protected static final int SEPARATOR_GAP = 5;
private GridHeader gHeader; protected GridHeader gHeader;
private int dragType = GridUtils.DRAG_NONE; private int dragType = GridUtils.DRAG_NONE;
//james 是否为选定多行的drag //james 是否为选定多行的drag
private boolean isMultiSelectDragPermited = false; private boolean isMultiSelectDragPermited = false;
@ -51,7 +50,7 @@ public abstract class AbstractGridHeaderMouseHandler extends MouseInputAdapter {
private int dragIndex = 0; private int dragIndex = 0;
private JToolTip tip = null; private JToolTip tip = null;
private JWindow tipWindow = null; private JWindow tipWindow = null;
protected int resolution = ScreenResolution.getScreenResolution(); protected int resolution = DesignerUIModeConfig.getInstance().getScreenResolution();
public AbstractGridHeaderMouseHandler(GridHeader gHeader) { public AbstractGridHeaderMouseHandler(GridHeader gHeader) {
this.gHeader = gHeader; this.gHeader = gHeader;
@ -307,7 +306,7 @@ public abstract class AbstractGridHeaderMouseHandler extends MouseInputAdapter {
// int resolution = ScreenResolution.getScreenResolution(); // int resolution = ScreenResolution.getScreenResolution();
FU ulen = FU.valueOfPix((int) doubleValue, resolution); FU ulen = FU.valueOfPix((int) doubleValue, resolution);
FU tulen = FU.valueOfPix((int) totalDoubleValue, resolution); FU tulen = FU.valueOfPix((int) totalDoubleValue, resolution);
ReportLengthUNITProvider lengthUNIT = UnitConvertUtil.parseLengthUNIT(unitType); ReportLengthUNITProvider lengthUNIT = DesignerUIModeConfig.getInstance().parseLengthUNIT(unitType);
String unit = lengthUNIT.unitText(); String unit = lengthUNIT.unitText();
double len = lengthUNIT.unit2Value4Scale(ulen); double len = lengthUNIT.unit2Value4Scale(ulen);
double tlen = lengthUNIT.unit2Value4Scale(tulen); double tlen = lengthUNIT.unit2Value4Scale(tulen);

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

@ -1,16 +1,24 @@
package com.fr.grid; 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.fun.impl.AbstractGridUIProcessor;
import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.WidgetPropertyPane;
import javax.swing.plaf.ComponentUI; import javax.swing.plaf.ComponentUI;
/** /**
* Created by Administrator on 2016/6/28/0028. * Created by Administrator on 2016/6/28/0028.
*/ */
public class DefaultGridUIProcessor extends AbstractGridUIProcessor{ public class DefaultGridUIProcessor extends AbstractGridUIProcessor {
@Override @Override
public ComponentUI appearanceForGrid(int resolution) { public ComponentUI appearanceForGrid(int resolution) {
if (DesignerUIModeConfig.getInstance().newUIMode()) {
FormDesigner designer = WidgetPropertyPane.getInstance().getEditingFormDesigner();
return new NewFormDesignerGridUI(designer, resolution);
}
return new GridUI(resolution); return new GridUI(resolution);
} }

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

@ -6,14 +6,10 @@ package com.fr.grid;
import java.awt.Dimension; import java.awt.Dimension;
import com.fr.base.GraphHelper; import com.fr.base.GraphHelper;
import com.fr.base.ScreenResolution; import com.fr.design.fit.DesignerUIModeConfig;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.fun.GridUIProcessor;
import com.fr.design.mainframe.ElementCasePane; import com.fr.design.mainframe.ElementCasePane;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
import javax.swing.plaf.ComponentUI;
/** /**
* GridColumn used to paint and edit grid column. * GridColumn used to paint and edit grid column.
* *
@ -22,20 +18,23 @@ import javax.swing.plaf.ComponentUI;
*/ */
public class GridColumn extends GridHeader<String> { public class GridColumn extends GridHeader<String> {
public int resolution = ScreenResolution.getScreenResolution();
private GridColumnMouseHandler gridColumnMouseHandler; private GridColumnMouseHandler gridColumnMouseHandler;
public GridColumn(int resolution) {
super(resolution);
}
@Override @Override
protected void initByConstructor() { protected void initByConstructor() {
resolution = ScreenResolution.getScreenResolution();
this.setResolution(resolution);
gridColumnMouseHandler = new GridColumnMouseHandler(this); gridColumnMouseHandler = new GridColumnMouseHandler(this);
this.addMouseListener(gridColumnMouseHandler); this.addMouseListener(gridColumnMouseHandler);
this.addMouseMotionListener(gridColumnMouseHandler); this.addMouseMotionListener(gridColumnMouseHandler);
this.updateUI(); this.updateUI();
} }
@Override @Override
public String getDisplay(int index) { public String getDisplay(int index) {
return StableUtils.convertIntToABC(index + 1); return StableUtils.convertIntToABC(index + 1);
@ -48,26 +47,16 @@ public class GridColumn extends GridHeader<String> {
gridColumnMouseHandler = new GridColumnMouseHandler(this); gridColumnMouseHandler = new GridColumnMouseHandler(this);
this.addMouseListener(gridColumnMouseHandler); this.addMouseListener(gridColumnMouseHandler);
this.addMouseMotionListener(gridColumnMouseHandler); this.addMouseMotionListener(gridColumnMouseHandler);
// gridColumnMouseHandler.setResolution(resolution);
this.setUI(new GridColumnUI(resolution)); this.setUI(new GridColumnUI(resolution));
} }
public void setResolution(int resolution) {
this.resolution = resolution;
}
@Override
public int getResolution() {
return this.resolution;
}
/** /**
* Gets the preferred size. * Gets the preferred size.
*/ */
@Override @Override
public Dimension getPreferredSize() { public Dimension getPreferredSize() {
ElementCasePane reportPane = this.getElementCasePane(); ElementCasePane reportPane = this.getElementCasePane();
float time = (float)reportPane.getResolution()/ ScreenResolution.getScreenResolution(); float time = (float)reportPane.getResolution()/ DesignerUIModeConfig.getInstance().getScreenResolution();
if (!reportPane.isColumnHeaderVisible()) { if (!reportPane.isColumnHeaderVisible()) {
return new Dimension(0, 0); return new Dimension(0, 0);
} }

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

@ -7,9 +7,7 @@ import java.awt.Toolkit;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
import com.fr.base.DynamicUnitList; import com.fr.base.DynamicUnitList;
import com.fr.base.ScreenResolution;
import com.fr.design.gui.imenu.UIPopupMenu; import com.fr.design.gui.imenu.UIPopupMenu;
import com.fr.design.mainframe.ElementCasePane; import com.fr.design.mainframe.ElementCasePane;
import com.fr.grid.selection.CellSelection; import com.fr.grid.selection.CellSelection;
@ -23,8 +21,6 @@ import com.fr.stable.ColumnRow;
*/ */
public class GridColumnMouseHandler extends AbstractGridHeaderMouseHandler { public class GridColumnMouseHandler extends AbstractGridHeaderMouseHandler {
private int resolution;
public GridColumnMouseHandler(GridColumn gridColumn) { public GridColumnMouseHandler(GridColumn gridColumn) {
super(gridColumn); super(gridColumn);
this.resolution = gridColumn.resolution; this.resolution = gridColumn.resolution;

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

@ -16,6 +16,7 @@ import com.fr.base.ScreenResolution;
import com.fr.base.vcs.DesignerMode; import com.fr.base.vcs.DesignerMode;
import com.fr.cache.list.IntList; import com.fr.cache.list.IntList;
import com.fr.design.constants.UIConstants; import com.fr.design.constants.UIConstants;
import com.fr.design.fit.DesignerUIModeConfig;
import com.fr.design.mainframe.ElementCasePane; import com.fr.design.mainframe.ElementCasePane;
import com.fr.design.roleAuthority.ReportAndFSManagePane; import com.fr.design.roleAuthority.ReportAndFSManagePane;
import com.fr.grid.selection.Selection; import com.fr.grid.selection.Selection;
@ -33,7 +34,7 @@ public class GridColumnUI extends ComponentUI {
public GridColumnUI(int resolution){ public GridColumnUI(int resolution){
if (resolution == 0){ if (resolution == 0){
resolution = ScreenResolution.getScreenResolution(); resolution = DesignerUIModeConfig.getInstance().getScreenResolution();
} }
this.resolution = resolution; this.resolution = resolution;
} }
@ -49,7 +50,7 @@ public class GridColumnUI extends ComponentUI {
Grid gird = reportPane.getGrid(); Grid gird = reportPane.getGrid();
// size // size
Dimension size = gridColumn.getSize(); Dimension size = gridColumn.getSize();
float time = (float)resolution/ScreenResolution.getScreenResolution(); float time = (float)resolution/DesignerUIModeConfig.getInstance().getScreenResolution();
g2d.setFont(gridColumn.getFont().deriveFont(gridColumn.getFont().getSize2D() * time)); g2d.setFont(gridColumn.getFont().deriveFont(gridColumn.getFont().getSize2D() * time));
ElementCase elementCase = reportPane.getEditingElementCase(); ElementCase elementCase = reportPane.getEditingElementCase();
@ -161,7 +162,7 @@ public class GridColumnUI extends ComponentUI {
columnContent += "(FR)"; columnContent += "(FR)";
} }
} }
float time = (float)resolution/ScreenResolution.getScreenResolution(); float time = (float)resolution/DesignerUIModeConfig.getInstance().getScreenResolution();
double stringWidth = gridColumn.getFont().getStringBounds(columnContent, fontRenderContext).getWidth() * time; double stringWidth = gridColumn.getFont().getStringBounds(columnContent, fontRenderContext).getWidth() * time;
if (stringWidth > tmpIncreaseWidth) { if (stringWidth > tmpIncreaseWidth) {

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

@ -6,6 +6,7 @@ package com.fr.grid;
import com.fr.base.GraphHelper; import com.fr.base.GraphHelper;
import com.fr.base.ScreenResolution; import com.fr.base.ScreenResolution;
import com.fr.design.constants.UIConstants; import com.fr.design.constants.UIConstants;
import com.fr.design.fit.DesignerUIModeConfig;
import com.fr.design.mainframe.ElementCasePane; import com.fr.design.mainframe.ElementCasePane;
import javax.swing.event.MouseInputListener; import javax.swing.event.MouseInputListener;
@ -35,7 +36,7 @@ public class GridCorner extends BaseGridComponent {
Graphics2D g2d = (Graphics2D) g; Graphics2D g2d = (Graphics2D) g;
ElementCasePane reportPane = this.getElementCasePane(); ElementCasePane reportPane = this.getElementCasePane();
float time = (float) reportPane.getResolution() / ScreenResolution.getScreenResolution(); float time = (float) reportPane.getResolution() / DesignerUIModeConfig.getInstance().getScreenResolution();
//size //size
Dimension size = this.getSize(); Dimension size = this.getSize();
Rectangle2D rect2D = new Rectangle2D.Double(0, 0, size.getWidth(), size.getHeight()); Rectangle2D rect2D = new Rectangle2D.Double(0, 0, size.getWidth(), size.getHeight());

3
designer-realize/src/main/java/com/fr/grid/GridHeader.java

@ -15,7 +15,8 @@ public abstract class GridHeader<T> extends BaseGridComponent {
protected int resolution; protected int resolution;
public GridHeader() { public GridHeader(int resolution) {
this.resolution = resolution;
//清除所有的Key Action. //清除所有的Key Action.
this.getInputMap().clear(); this.getInputMap().clear();
this.getActionMap().clear(); this.getActionMap().clear();

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

@ -6,6 +6,7 @@ import com.fr.base.ScreenResolution;
import com.fr.base.vcs.DesignerMode; import com.fr.base.vcs.DesignerMode;
import com.fr.common.inputevent.InputEventBaseOnOS; import com.fr.common.inputevent.InputEventBaseOnOS;
import com.fr.design.constants.UIConstants; import com.fr.design.constants.UIConstants;
import com.fr.design.fit.DesignerUIModeConfig;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.EastRegionContainerPane; import com.fr.design.mainframe.EastRegionContainerPane;
import com.fr.design.mainframe.ElementCasePane; import com.fr.design.mainframe.ElementCasePane;
@ -73,7 +74,7 @@ public class GridMouseAdapter implements MouseListener, MouseWheelListener, Mous
private int ECBlockGap = 40; private int ECBlockGap = 40;
private int resolution = ScreenResolution.getScreenResolution(); private int resolution = DesignerUIModeConfig.getInstance().getScreenResolution();
protected GridMouseAdapter(Grid grid) { protected GridMouseAdapter(Grid grid) {
this.grid = grid; this.grid = grid;

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

@ -8,6 +8,7 @@ import java.awt.Dimension;
import com.fr.base.GraphHelper; import com.fr.base.GraphHelper;
import com.fr.base.ScreenResolution; import com.fr.base.ScreenResolution;
import com.fr.design.ExtraDesignClassManager; import com.fr.design.ExtraDesignClassManager;
import com.fr.design.fit.DesignerUIModeConfig;
import com.fr.design.fun.GridUIProcessor; import com.fr.design.fun.GridUIProcessor;
import com.fr.design.mainframe.ElementCasePane; import com.fr.design.mainframe.ElementCasePane;
@ -22,13 +23,14 @@ import javax.swing.plaf.ComponentUI;
public class GridRow extends GridHeader<Integer> { public class GridRow extends GridHeader<Integer> {
private static final int MAX = 4; private static final int MAX = 4;
private int resolution = ScreenResolution.getScreenResolution();
private GridRowMouseHandler gridRowMouseHandler; private GridRowMouseHandler gridRowMouseHandler;
public GridRow(int resolution) {
super(resolution);
}
@Override @Override
protected void initByConstructor() { protected void initByConstructor() {
resolution = ScreenResolution.getScreenResolution();
this.setResolution(resolution);
gridRowMouseHandler = new GridRowMouseHandler(this); gridRowMouseHandler = new GridRowMouseHandler(this);
this.addMouseListener(gridRowMouseHandler); this.addMouseListener(gridRowMouseHandler);
this.addMouseMotionListener(gridRowMouseHandler); this.addMouseMotionListener(gridRowMouseHandler);
@ -50,14 +52,6 @@ public class GridRow extends GridHeader<Integer> {
this.setUI(new GridRowUI(resolution)); this.setUI(new GridRowUI(resolution));
} }
public void setResolution(int resolution) {
this.resolution = resolution;
}
public int getResolution() {
return this.resolution;
}
/** /**
* Gets the preferred size. * Gets the preferred size.
@ -65,7 +59,7 @@ public class GridRow extends GridHeader<Integer> {
@Override @Override
public Dimension getPreferredSize() { public Dimension getPreferredSize() {
ElementCasePane reportPane = this.getElementCasePane(); ElementCasePane reportPane = this.getElementCasePane();
float time = (float)reportPane.getResolution()/ ScreenResolution.getScreenResolution(); float time = (float)reportPane.getResolution()/ DesignerUIModeConfig.getInstance().getScreenResolution();
if (!(reportPane.isRowHeaderVisible())) { if (!(reportPane.isRowHeaderVisible())) {
return new Dimension(0, 0); return new Dimension(0, 0);
} }

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

@ -7,6 +7,8 @@ import java.awt.geom.Rectangle2D;
import javax.swing.JComponent; import javax.swing.JComponent;
import javax.swing.UIManager; import javax.swing.UIManager;
import javax.swing.plaf.ComponentUI; import javax.swing.plaf.ComponentUI;
import com.fr.design.fit.DesignerUIModeConfig;
import com.fr.stable.AssistUtils; import com.fr.stable.AssistUtils;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.base.DynamicUnitList; import com.fr.base.DynamicUnitList;
@ -32,7 +34,7 @@ public class GridRowUI extends ComponentUI {
GridRowUI(int resolution){ GridRowUI(int resolution){
if (resolution == 0){ if (resolution == 0){
resolution = ScreenResolution.getScreenResolution(); resolution = DesignerUIModeConfig.getInstance().getScreenResolution();
} }
this.resolution = resolution; this.resolution = resolution;
} }
@ -47,7 +49,7 @@ public class GridRowUI extends ComponentUI {
ElementCasePane reportPane = gridRow.getElementCasePane(); ElementCasePane reportPane = gridRow.getElementCasePane();
// size // size
Dimension size = gridRow.getSize(); Dimension size = gridRow.getSize();
float time = (float)resolution/ScreenResolution.getScreenResolution(); float time = (float)resolution/DesignerUIModeConfig.getInstance().getScreenResolution();
g2d.setFont(gridRow.getFont().deriveFont(gridRow.getFont().getSize2D() * time)); g2d.setFont(gridRow.getFont().deriveFont(gridRow.getFont().getSize2D() * time));
ElementCase elementCase = reportPane.getEditingElementCase(); ElementCase elementCase = reportPane.getEditingElementCase();
@ -156,7 +158,7 @@ public class GridRowUI extends ComponentUI {
, ElementCase elementCase, Dimension size, double tmpHeight1) { , ElementCase elementCase, Dimension size, double tmpHeight1) {
// FontMetrics // FontMetrics
FontRenderContext fontRenderContext = g2d.getFontRenderContext(); FontRenderContext fontRenderContext = g2d.getFontRenderContext();
float time = (float)resolution/ScreenResolution.getScreenResolution(); float time = (float)resolution/DesignerUIModeConfig.getInstance().getScreenResolution();
float fmAscent = GraphHelper.getFontMetrics(gridRow.getFont()).getAscent() * time; float fmAscent = GraphHelper.getFontMetrics(gridRow.getFont()).getAscent() * time;
double stringWidth = gridRow.getFont().getStringBounds(paintText, fontRenderContext).getWidth() * time; double stringWidth = gridRow.getFont().getStringBounds(paintText, fontRenderContext).getWidth() * time;
double stringHeight = gridRow.getFont().getStringBounds(paintText, fontRenderContext).getHeight() * time; double stringHeight = gridRow.getFont().getStringBounds(paintText, fontRenderContext).getHeight() * time;

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

@ -5,6 +5,7 @@ import com.fr.base.ScreenResolution;
import com.fr.design.cell.clipboard.CellElementsClip; import com.fr.design.cell.clipboard.CellElementsClip;
import com.fr.design.cell.clipboard.ElementsTransferable; import com.fr.design.cell.clipboard.ElementsTransferable;
import com.fr.design.cell.clipboard.FloatElementsClip; import com.fr.design.cell.clipboard.FloatElementsClip;
import com.fr.design.fit.DesignerUIModeConfig;
import com.fr.design.mainframe.ElementCasePane; import com.fr.design.mainframe.ElementCasePane;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
@ -124,7 +125,7 @@ public class GridUtils {
*/ */
public static double[] caculateFloatElementLocations(FloatElement floatElement, DynamicUnitList columnWidthList, DynamicUnitList rowHeightList, public static double[] caculateFloatElementLocations(FloatElement floatElement, DynamicUnitList columnWidthList, DynamicUnitList rowHeightList,
int verticalValue, int horizentalValue) { int verticalValue, int horizentalValue) {
int resolution = ScreenResolution.getScreenResolution(); int resolution = DesignerUIModeConfig.getInstance().getScreenResolution();
double floatX = columnWidthList.getRangeValue(horizentalValue, 0).toPixD(resolution) + floatElement.getLeftDistance().toPixD(resolution); double floatX = columnWidthList.getRangeValue(horizentalValue, 0).toPixD(resolution) + floatElement.getLeftDistance().toPixD(resolution);
double floatY = rowHeightList.getRangeValue(verticalValue, 0).toPixD(resolution) + floatElement.getTopDistance().toPixD(resolution); double floatY = rowHeightList.getRangeValue(verticalValue, 0).toPixD(resolution) + floatElement.getTopDistance().toPixD(resolution);
@ -177,7 +178,7 @@ public class GridUtils {
private static int cc_selected_column_or_row(double mouseEvtPosition, int beginValue, int value, DynamicUnitList sizeList) { private static int cc_selected_column_or_row(double mouseEvtPosition, int beginValue, int value, DynamicUnitList sizeList) {
double tmpIntIndex = 0; double tmpIntIndex = 0;
int selectedCellIndex = 0; int selectedCellIndex = 0;
int resolution = ScreenResolution.getScreenResolution(); int resolution = DesignerUIModeConfig.getInstance().getScreenResolution();
if (mouseEvtPosition < 0) { if (mouseEvtPosition < 0) {
selectedCellIndex = value; selectedCellIndex = value;
for (; true; selectedCellIndex--) { for (; true; selectedCellIndex--) {

15
designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java

@ -27,6 +27,8 @@ import com.fr.design.actions.insert.flot.ImageFloatAction;
import com.fr.design.actions.insert.flot.TextBoxFloatAction; import com.fr.design.actions.insert.flot.TextBoxFloatAction;
import com.fr.design.bridge.DesignToolbarProvider; import com.fr.design.bridge.DesignToolbarProvider;
import com.fr.design.constants.DesignerLaunchStatus; import com.fr.design.constants.DesignerLaunchStatus;
import com.fr.design.fit.NewJForm;
import com.fr.design.fit.common.TemplateTool;
import com.fr.design.form.parameter.FormParaDesigner; import com.fr.design.form.parameter.FormParaDesigner;
import com.fr.design.fun.ElementUIProvider; import com.fr.design.fun.ElementUIProvider;
import com.fr.design.gui.controlpane.NameObjectCreator; import com.fr.design.gui.controlpane.NameObjectCreator;
@ -42,7 +44,7 @@ import com.fr.design.mainframe.BaseJForm;
import com.fr.design.mainframe.ElementCaseThumbnail; import com.fr.design.mainframe.ElementCaseThumbnail;
import com.fr.design.mainframe.FormHierarchyTreePane; import com.fr.design.mainframe.FormHierarchyTreePane;
import com.fr.design.mainframe.InformationCollector; import com.fr.design.mainframe.InformationCollector;
import com.fr.design.mainframe.JForm; import com.fr.design.mainframe.JTemplateEvent;
import com.fr.design.mainframe.WidgetPropertyPane; import com.fr.design.mainframe.WidgetPropertyPane;
import com.fr.design.mainframe.WidgetToolBarPane; import com.fr.design.mainframe.WidgetToolBarPane;
import com.fr.design.mainframe.alphafine.AlphaFineHelper; import com.fr.design.mainframe.alphafine.AlphaFineHelper;
@ -62,6 +64,7 @@ import com.fr.design.parameter.WorkBookParameterReader;
import com.fr.design.update.actions.RecoverForDesigner; import com.fr.design.update.actions.RecoverForDesigner;
import com.fr.design.update.push.DesignerPushUpdateManager; import com.fr.design.update.push.DesignerPushUpdateManager;
import com.fr.design.widget.ui.btn.FormSubmitButtonDetailPane; import com.fr.design.widget.ui.btn.FormSubmitButtonDetailPane;
import com.fr.event.EventDispatcher;
import com.fr.form.stable.ElementCaseThumbnailProcessor; import com.fr.form.stable.ElementCaseThumbnailProcessor;
import com.fr.general.GeneralContext; import com.fr.general.GeneralContext;
import com.fr.general.xml.GeneralXMLTools; import com.fr.general.xml.GeneralXMLTools;
@ -395,9 +398,15 @@ public class DesignerActivator extends Activator {
DesignModuleFactory.registerButtonDetailPaneClass(FormSubmitButtonDetailPane.class); DesignModuleFactory.registerButtonDetailPaneClass(FormSubmitButtonDetailPane.class);
DesignModuleFactory.registerParameterReader(new FormParameterReader()); DesignModuleFactory.registerParameterReader(new FormParameterReader());
StableFactory.registerMarkedClass(BaseJForm.XML_TAG, JForm.class); StableFactory.registerMarkedClass(BaseJForm.XML_TAG, NewJForm.class);
StableFactory.registerMarkedObject(ElementCaseThumbnailProcessor.MARK_STRING, new ElementCaseThumbnail()); StableFactory.registerMarkedObject(ElementCaseThumbnailProcessor.MARK_STRING, new ElementCaseThumbnail());
registerJTemplateEvent();
}
private static void registerJTemplateEvent(){
EventDispatcher.listen(JTemplateEvent.BEFORE_TEMPLATE_INIT, TemplateTool.getSwitchListener());
EventDispatcher.listen(JTemplateEvent.BEFORE_TEMPLATE_ACTIVE, TemplateTool.getSwitchListener());
} }
private static void storePassport() { private static void storePassport() {

Loading…
Cancel
Save