Browse Source

解决冲突

research/11.0
fly.li 3 years ago
parent
commit
9d8b68ca72
  1. 2
      designer-chart/src/main/java/com/fr/design/ChartTypeInterfaceManager.java
  2. 2
      designer-chart/src/main/java/com/fr/design/chart/ChartTypePane.java
  3. 10
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypePane.java
  4. 45
      designer-chart/src/main/java/com/fr/design/module/ChartPreStyleListPane.java
  5. 3
      designer-chart/src/main/java/com/fr/van/chart/custom/other/VanChartCustomInteractivePane.java
  6. 16
      designer-chart/src/main/java/com/fr/van/chart/designer/other/VanChartInteractivePane.java
  7. 3
      designer-chart/src/main/java/com/fr/van/chart/gauge/VanChartGaugeSeriesPane.java
  8. 3
      designer-chart/src/main/java/com/fr/van/chart/map/designer/other/VanChartMapInteractivePane.java
  9. 10
      designer-form/src/main/java/com/fr/design/actions/NewFormAction.java
  10. 37
      designer-form/src/main/java/com/fr/design/designer/beans/LayoutAdapter.java
  11. 35
      designer-form/src/main/java/com/fr/design/designer/beans/PredefinedLayout.java
  12. 1
      designer-form/src/main/java/com/fr/design/designer/beans/actions/CutAction.java
  13. 7
      designer-form/src/main/java/com/fr/design/designer/beans/actions/PasteAction.java
  14. 16
      designer-form/src/main/java/com/fr/design/designer/beans/actions/behavior/PasteEnable.java
  15. 9
      designer-form/src/main/java/com/fr/design/designer/beans/adapters/component/CompositeComponentAdapter.java
  16. 8
      designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/AbstractLayoutAdapter.java
  17. 23
      designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/DefaultDesignerBaseOperate.java
  18. 33
      designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/DesignerBaseOperate.java
  19. 29
      designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRCardMainBorderLayoutAdapter.java
  20. 71
      designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRFitLayoutAdapter.java
  21. 138
      designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRFixLayoutAdapter.java
  22. 116
      designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRNoFixLayoutAdapter.java
  23. 63
      designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FROccupiedLayoutAdapter.java
  24. 9
      designer-form/src/main/java/com/fr/design/designer/beans/models/AddingModel.java
  25. 2
      designer-form/src/main/java/com/fr/design/designer/beans/models/ModelUtil.java
  26. 57
      designer-form/src/main/java/com/fr/design/designer/beans/models/NewFormModel.java
  27. 20
      designer-form/src/main/java/com/fr/design/designer/beans/models/SelectionModel.java
  28. 130
      designer-form/src/main/java/com/fr/design/designer/beans/painters/FRFixLayoutPainter.java
  29. 56
      designer-form/src/main/java/com/fr/design/designer/beans/painters/FROccupiedLayoutPainter.java
  30. 48
      designer-form/src/main/java/com/fr/design/designer/creator/XBorderStyleWidgetCreator.java
  31. 6
      designer-form/src/main/java/com/fr/design/designer/creator/XChartEditor.java
  32. 36
      designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java
  33. 11
      designer-form/src/main/java/com/fr/design/designer/creator/XCreatorUtils.java
  34. 9
      designer-form/src/main/java/com/fr/design/designer/creator/XElementCase.java
  35. 20
      designer-form/src/main/java/com/fr/design/designer/creator/XLayoutContainer.java
  36. 81
      designer-form/src/main/java/com/fr/design/designer/creator/XOccupiedLayout.java
  37. 8
      designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteBodyLayout.java
  38. 2
      designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteLayout.java
  39. 32
      designer-form/src/main/java/com/fr/design/designer/creator/XWFitLayout.java
  40. 12
      designer-form/src/main/java/com/fr/design/designer/creator/XWParameterLayout.java
  41. 6
      designer-form/src/main/java/com/fr/design/designer/creator/XWTitleLayout.java
  42. 10
      designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardLayout.java
  43. 2
      designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java
  44. 4
      designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWTabFitLayout.java
  45. 29
      designer-form/src/main/java/com/fr/design/designer/creator/operate/DefaultXCreatorBaseOperate.java
  46. 15
      designer-form/src/main/java/com/fr/design/designer/creator/operate/XCreatorBaseOperate.java
  47. 11
      designer-form/src/main/java/com/fr/design/designer/treeview/ComponentTreeCellRenderer.java
  48. 29
      designer-form/src/main/java/com/fr/design/designer/treeview/DefaultXCreatorTreeCellRender.java
  49. 8
      designer-form/src/main/java/com/fr/design/designer/treeview/XCreatorTreeCellRender.java
  50. 6
      designer-form/src/main/java/com/fr/design/fit/NewJForm.java
  51. 114
      designer-form/src/main/java/com/fr/design/fit/attrpane/ElementEditorExtendDefinePane.java
  52. 200
      designer-form/src/main/java/com/fr/design/fit/attrpane/FRAbsoluteBodyLayoutExtendDefinePane.java
  53. 27
      designer-form/src/main/java/com/fr/design/fit/attrpane/FRAbsoluteLayoutExtendDefinePane.java
  54. 282
      designer-form/src/main/java/com/fr/design/fit/attrpane/FRFitLayoutExtendDefinePane.java
  55. 303
      designer-form/src/main/java/com/fr/design/fit/attrpane/RootDesignExtendDefinePane.java
  56. 35
      designer-form/src/main/java/com/fr/design/fit/common/AdaptiveSwitchUtil.java
  57. 19
      designer-form/src/main/java/com/fr/design/form/util/XCreatorConstants.java
  58. 17
      designer-form/src/main/java/com/fr/design/mainframe/ComponentTree.java
  59. 31
      designer-form/src/main/java/com/fr/design/mainframe/DesignerScaleMouseWheelHandler.java
  60. 279
      designer-form/src/main/java/com/fr/design/mainframe/DesignerTranslateMouseWheelHandler.java
  61. 2
      designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java
  62. 148
      designer-form/src/main/java/com/fr/design/mainframe/FormArea.java
  63. 75
      designer-form/src/main/java/com/fr/design/mainframe/FormAreaMouseWheelHandler.java
  64. 1
      designer-form/src/main/java/com/fr/design/mainframe/FormCreatorDropTarget.java
  65. 92
      designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java
  66. 6
      designer-form/src/main/java/com/fr/design/mainframe/FormDesignerUI.java
  67. 10
      designer-form/src/main/java/com/fr/design/mainframe/FormUndoState.java
  68. 29
      designer-form/src/main/java/com/fr/design/mainframe/JForm.java
  69. 2
      designer-form/src/main/java/com/fr/design/mainframe/ToolBarButton.java
  70. 3
      designer-form/src/main/java/com/fr/design/mainframe/TopXCreator.java
  71. 7
      designer-form/src/main/java/com/fr/design/mainframe/share/action/CreateComponentAction.java
  72. 2
      designer-form/src/main/java/com/fr/design/mainframe/share/util/ShareComponentUtils.java
  73. 137
      designer-form/src/main/java/com/fr/design/parameter/RootDesignDefinePane.java
  74. 36
      designer-form/src/main/java/com/fr/design/widget/ui/designer/EmptyLayoutPane.java
  75. 291
      designer-form/src/main/java/com/fr/design/widget/ui/designer/NewFormPane.java
  76. 117
      designer-form/src/main/java/com/fr/design/widget/ui/designer/PredefinedLayoutPane.java
  77. 28
      designer-form/src/main/java/com/fr/design/widget/ui/designer/component/PaddingBoundPane.java
  78. 36
      designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/ElementEditorDefinePane.java
  79. 32
      designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRAbsoluteBodyLayoutDefinePane.java
  80. 3
      designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRAbsoluteLayoutDefinePane.java
  81. 73
      designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRFitLayoutDefinePane.java
  82. BIN
      designer-form/src/main/resources/com/fr/design/form/images/fix_layout_icon.png
  83. BIN
      designer-form/src/main/resources/com/fr/design/form/images/new_form.png
  84. BIN
      designer-form/src/main/resources/com/fr/design/form/images/no_fix_layout_icon.png
  85. BIN
      designer-form/src/main/resources/com/fr/design/form/images/occupied_layout.png
  86. 100
      designer-form/src/main/resources/com/fr/design/form/layouts/config.json
  87. BIN
      designer-form/src/main/resources/com/fr/design/form/layouts/images/real_style_1.png
  88. BIN
      designer-form/src/main/resources/com/fr/design/form/layouts/images/real_style_10.png
  89. BIN
      designer-form/src/main/resources/com/fr/design/form/layouts/images/real_style_11.png
  90. BIN
      designer-form/src/main/resources/com/fr/design/form/layouts/images/real_style_12.png
  91. BIN
      designer-form/src/main/resources/com/fr/design/form/layouts/images/real_style_13.png
  92. BIN
      designer-form/src/main/resources/com/fr/design/form/layouts/images/real_style_14.png
  93. BIN
      designer-form/src/main/resources/com/fr/design/form/layouts/images/real_style_15.png
  94. BIN
      designer-form/src/main/resources/com/fr/design/form/layouts/images/real_style_16.png
  95. BIN
      designer-form/src/main/resources/com/fr/design/form/layouts/images/real_style_17.png
  96. BIN
      designer-form/src/main/resources/com/fr/design/form/layouts/images/real_style_18.png
  97. BIN
      designer-form/src/main/resources/com/fr/design/form/layouts/images/real_style_2.png
  98. BIN
      designer-form/src/main/resources/com/fr/design/form/layouts/images/real_style_3.png
  99. BIN
      designer-form/src/main/resources/com/fr/design/form/layouts/images/real_style_4.png
  100. BIN
      designer-form/src/main/resources/com/fr/design/form/layouts/images/real_style_5.png
  101. Some files were not shown because too many files have changed in this diff Show More

2
designer-chart/src/main/java/com/fr/design/ChartTypeInterfaceManager.java

@ -149,7 +149,7 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr
public static WidgetOption[] initWidgetOption() { public static WidgetOption[] initWidgetOption() {
String[] chartIDs = ChartTypeManager.getInstance().getAllChartIDs(); String[] chartIDs = ChartTypeManager.getInstance().getChartIDs4Create();
ChartWidgetOption[] child = new ChartWidgetOption[chartIDs.length]; ChartWidgetOption[] child = new ChartWidgetOption[chartIDs.length];
int index = 0; int index = 0;

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

@ -31,7 +31,7 @@ import java.awt.Component;
public class ChartTypePane extends ChartCommonWizardPane implements CallbackEvent { public class ChartTypePane extends ChartCommonWizardPane implements CallbackEvent {
private static final long serialVersionUID = -1175602484968520546L; private static final long serialVersionUID = -1175602484968520546L;
private String[] chartIDs = ChartTypeManager.getInstanceWithCheck().getAllChartIDs(); private String[] chartIDs = ChartTypeManager.getInstanceWithCheck().getChartIDs4Create();
private JList mainTypeList = null; private JList mainTypeList = null;
private JList iconViewList = null; private JList iconViewList = null;

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

@ -4,6 +4,7 @@ import com.fr.chart.chartattr.ChartCollection;
import com.fr.chart.charttypes.ChartTypeManager; import com.fr.chart.charttypes.ChartTypeManager;
import com.fr.chartx.attr.ChartProvider; import com.fr.chartx.attr.ChartProvider;
import com.fr.design.ChartTypeInterfaceManager; import com.fr.design.ChartTypeInterfaceManager;
import com.fr.design.base.mode.DesignModeContext;
import com.fr.design.beans.FurtherBasicBeanPane; import com.fr.design.beans.FurtherBasicBeanPane;
import com.fr.design.dialog.BasicScrollPane; import com.fr.design.dialog.BasicScrollPane;
import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.dialog.DialogActionAdapter;
@ -18,6 +19,7 @@ import com.fr.design.mainframe.chart.gui.item.FlexibleComboBox;
import com.fr.design.mainframe.chart.gui.item.ItemEventType; import com.fr.design.mainframe.chart.gui.item.ItemEventType;
import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane; import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane;
import com.fr.design.mainframe.chart.mode.ChartEditContext; import com.fr.design.mainframe.chart.mode.ChartEditContext;
import com.fr.design.mainframe.chart.mode.ChartEditMode;
import com.fr.design.module.DesignModuleFactory; import com.fr.design.module.DesignModuleFactory;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
@ -173,7 +175,7 @@ public class ChartTypePane extends AbstractChartAttrPane {
Map<Integer, Map<String, FurtherBasicBeanPane<? extends ChartProvider>>> allChartTypePane, Map<Integer, Map<String, FurtherBasicBeanPane<? extends ChartProvider>>> allChartTypePane,
ActionListener autoButtonListener) { ActionListener autoButtonListener) {
String[] chartIDs = ChartTypeManager.getInstance().getAllChartIDsIncludeDisabled(); String[] chartIDs = ChartTypeManager.getInstance().getAllChartIDs();
for (String id : chartIDs) { for (String id : chartIDs) {
@ -288,9 +290,11 @@ public class ChartTypePane extends AbstractChartAttrPane {
Map.Entry<String, FurtherBasicBeanPane<? extends ChartProvider>> entry = iterator.next(); Map.Entry<String, FurtherBasicBeanPane<? extends ChartProvider>> entry = iterator.next();
String plotID = entry.getKey(); String plotID = entry.getKey();
if (ignore || ChartTypeManager.enabledChart(plotID)) { if (ignore || ChartTypeManager.enabledChart(plotID)) {
if (ChartTypeManager.getInstance().isShowInDesigner(plotID)) {
cards.add(entry.getValue()); cards.add(entry.getValue());
} }
} }
}
} }
@ -310,7 +314,9 @@ public class ChartTypePane extends AbstractChartAttrPane {
//第一步就是重构cards //第一步就是重构cards
cards.clear(); cards.clear();
if (enabledChart) { if (ChartEditContext.duchampMode()) {
addOnePlotIDCards(priority, chartID);
} else if (enabledChart) {
if (collection.getChartCount() == 1) { if (collection.getChartCount() == 1) {
addAllCards(); addAllCards();
} else { } else {

45
designer-chart/src/main/java/com/fr/design/module/ChartPreStyleListPane.java

@ -4,16 +4,25 @@ import com.fr.base.ChartColorMatching;
import com.fr.base.ChartPreStyleConfig; import com.fr.base.ChartPreStyleConfig;
import com.fr.base.Utils; import com.fr.base.Utils;
import com.fr.design.beans.BasicBeanPane; import com.fr.design.beans.BasicBeanPane;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.gui.controlpane.JListControlPane; import com.fr.design.gui.controlpane.JListControlPane;
import com.fr.design.gui.controlpane.NameObjectCreator; import com.fr.design.gui.controlpane.NameObjectCreator;
import com.fr.design.gui.controlpane.NameableCreator; import com.fr.design.gui.controlpane.NameableCreator;
import com.fr.design.gui.controlpane.ShortCut4JControlPane; import com.fr.design.gui.controlpane.ShortCut4JControlPane;
import com.fr.design.gui.ilist.JNameEdList;
import com.fr.design.i18n.Toolkit;
import com.fr.design.menu.ShortCut; import com.fr.design.menu.ShortCut;
import com.fr.general.ComparatorUtils;
import com.fr.general.NameObject; import com.fr.general.NameObject;
import com.fr.stable.Nameable; import com.fr.stable.Nameable;
import com.fr.stable.StringUtils;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator; import java.util.Iterator;
import java.util.List;
/** /**
* @author Bjorn * @author Bjorn
@ -22,6 +31,42 @@ import java.util.Iterator;
*/ */
public class ChartPreStyleListPane extends JListControlPane { public class ChartPreStyleListPane extends JListControlPane {
public ChartPreStyleListPane() {
super();
addModNameActionListener((int index, String oldName, String newName) -> {
if (ComparatorUtils.equals(oldName, newName)) {
return;
}
String[] allNames = nameableList.getAllNames();
allNames[index] = StringUtils.EMPTY;
if (StringUtils.isEmpty(newName)) {
showTipDialog(Toolkit.i18nText("Fine-Design_Chart_Fill_Style_Empty_Name_Tip"));
nameableList.setNameAt(oldName, index);
return;
}
if (isNameRepeated(new List[]{Arrays.asList(allNames)}, newName)) {
showTipDialog(Toolkit.i18nText("Fine-Design_Chart_Fill_Style_Exist_Name_Tip", newName));
nameableList.setNameAt(oldName, index);
return;
}
populateSelectedValue();
});
}
private void showTipDialog(String content) {
FineJOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(ChartPreStyleListPane.this),
content,
Toolkit.i18nText("Fine-Design_Basic_Alert"),
JOptionPane.WARNING_MESSAGE);
}
@Override
protected JNameEdList createJNameList() {
JNameEdList jNameList = super.createJNameList();
jNameList.setReplaceEmptyName(false);
return jNameList;
}
/** /**
* 创建有名字的creator * 创建有名字的creator
* *

3
designer-chart/src/main/java/com/fr/van/chart/custom/other/VanChartCustomInteractivePane.java

@ -44,6 +44,9 @@ public class VanChartCustomInteractivePane extends VanChartInteractivePane {
@Override @Override
protected void updateHyperlink(Plot plot){ protected void updateHyperlink(Plot plot){
if (hyperlinkPane == null) {
return;
}
hyperlinkPane.updateBean(chart); hyperlinkPane.updateBean(chart);
} }

16
designer-chart/src/main/java/com/fr/van/chart/designer/other/VanChartInteractivePane.java

@ -471,7 +471,11 @@ public class VanChartInteractivePane extends AbstractVanChartScrollPane<Chart> {
} }
protected Component[][] createToolBarComponents() { protected Component[][] createToolBarComponents() {
return new Component[][]{ return ChartEditContext.duchampMode() ? new Component[][]{
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Content")), isSort},
new Component[]{null, fullScreenDisplay},
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Layout")), collapse},
} : new Component[][]{
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Content")), isSort}, new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Content")), isSort},
new Component[]{null, exportImages}, new Component[]{null, exportImages},
new Component[]{null, fullScreenDisplay}, new Component[]{null, fullScreenDisplay},
@ -480,7 +484,10 @@ public class VanChartInteractivePane extends AbstractVanChartScrollPane<Chart> {
} }
protected Component[][] createToolBarComponentsWithOutSort() { protected Component[][] createToolBarComponentsWithOutSort() {
return new Component[][]{ return ChartEditContext.duchampMode() ? new Component[][]{
new Component[]{null, fullScreenDisplay},
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Layout")), collapse}
} : new Component[][]{
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Content")), exportImages}, new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Content")), exportImages},
new Component[]{null, fullScreenDisplay}, new Component[]{null, fullScreenDisplay},
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Layout")), collapse} new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Layout")), collapse}
@ -685,8 +692,10 @@ public class VanChartInteractivePane extends AbstractVanChartScrollPane<Chart> {
} }
protected void updateHyperlink(Plot plot) { protected void updateHyperlink(Plot plot) {
if (superLink != null) {
superLink.update(plot); superLink.update(plot);
} }
}
private void updateChartTools(VanChart chart) { private void updateChartTools(VanChart chart) {
VanChartTools vanChartTools = new VanChartTools(); VanChartTools vanChartTools = new VanChartTools();
@ -734,6 +743,9 @@ public class VanChartInteractivePane extends AbstractVanChartScrollPane<Chart> {
private void updateAutoRefresh(VanChart chart) { private void updateAutoRefresh(VanChart chart) {
if (autoRefreshPane == null) {
return;
}
RefreshMoreLabel refreshMoreLabel = chart.getRefreshMoreLabel(); RefreshMoreLabel refreshMoreLabel = chart.getRefreshMoreLabel();
if (refreshMoreLabel == null) { if (refreshMoreLabel == null) {

3
designer-chart/src/main/java/com/fr/van/chart/gauge/VanChartGaugeSeriesPane.java

@ -16,6 +16,7 @@ import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.chart.gui.ChartStylePane; import com.fr.design.mainframe.chart.gui.ChartStylePane;
import com.fr.design.mainframe.chart.gui.style.series.ColorPickerPaneWithMaxMin; import com.fr.design.mainframe.chart.gui.style.series.ColorPickerPaneWithMaxMin;
import com.fr.design.mainframe.chart.gui.style.series.UIColorPickerPane; import com.fr.design.mainframe.chart.gui.style.series.UIColorPickerPane;
import com.fr.design.mainframe.chart.mode.ChartEditContext;
import com.fr.design.style.color.ColorSelectBox; import com.fr.design.style.color.ColorSelectBox;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.plugin.chart.attr.GaugeDetailStyle; import com.fr.plugin.chart.attr.GaugeDetailStyle;
@ -198,7 +199,9 @@ public class VanChartGaugeSeriesPane extends VanChartMultiColorSeriesPane {
if (attrLabelDetail == null || attrLabelDetail.getTextAttr() == null) { if (attrLabelDetail == null || attrLabelDetail.getTextAttr() == null) {
return; return;
} }
if (!ChartEditContext.duchampMode()) {
attrLabelDetail.getTextAttr().setFRFont(VanChartGaugePlot.THERMOMETER_LABEL_FONT); attrLabelDetail.getTextAttr().setFRFont(VanChartGaugePlot.THERMOMETER_LABEL_FONT);
}
if (gaugeLayout.getSelectedIndex() == 0) { if (gaugeLayout.getSelectedIndex() == 0) {
attrLabel.getAttrLabelDetail().setPosition(Constants.LEFT); attrLabel.getAttrLabelDetail().setPosition(Constants.LEFT);
attrLabel.getGaugeValueLabelDetail().setPosition(Constants.LEFT); attrLabel.getGaugeValueLabelDetail().setPosition(Constants.LEFT);

3
designer-chart/src/main/java/com/fr/van/chart/map/designer/other/VanChartMapInteractivePane.java

@ -35,6 +35,9 @@ public class VanChartMapInteractivePane extends VanChartInteractivePaneWithMapZo
@Override @Override
protected void updateHyperlink(Plot plot) { protected void updateHyperlink(Plot plot) {
if (hyperlinkPane == null) {
return;
}
hyperlinkPane.updateBean(plot); hyperlinkPane.updateBean(plot);
} }

10
designer-form/src/main/java/com/fr/design/actions/NewFormAction.java

@ -1,13 +1,8 @@
package com.fr.design.actions; package com.fr.design.actions;
import com.fr.base.svg.IconUtils;
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.design.menu.MenuKeySet;
import com.fr.design.widget.ui.designer.NewFormPane;
import com.fr.stable.bridge.StableFactory;
import javax.swing.KeyStroke; import javax.swing.KeyStroke;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
@ -31,8 +26,7 @@ public class NewFormAction extends UpdateAction {
* @param e 事件 * @param e 事件
*/ */
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
BaseJForm jform = StableFactory.getMarkedInstanceObjectFromClass(BaseJForm.XML_TAG, BaseJForm.class); new NewFormPane().showWindow();
DesignerContext.getDesignerFrame().addAndActivateJTemplate((JTemplate<?, ?>) jform);
} }

37
designer-form/src/main/java/com/fr/design/designer/beans/LayoutAdapter.java

@ -1,7 +1,12 @@
package com.fr.design.designer.beans; package com.fr.design.designer.beans;
import com.fr.design.beans.GroupModel; import com.fr.design.beans.GroupModel;
import com.fr.design.designer.beans.adapters.layout.DefaultDesignerBaseOperate;
import com.fr.design.designer.beans.adapters.layout.DesignerBaseOperate;
import com.fr.design.designer.beans.models.SelectionModel;
import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.treeview.DefaultXCreatorTreeCellRender;
import com.fr.design.designer.treeview.XCreatorTreeCellRender;
/** /**
* 该接口是LayoutManager的BeanInfo类标准Java平台没有提供布局管理器的BeanInfo类 * 该接口是LayoutManager的BeanInfo类标准Java平台没有提供布局管理器的BeanInfo类
@ -104,4 +109,36 @@ public interface LayoutAdapter {
* @param initHeight 组件之前高度 * @param initHeight 组件之前高度
*/ */
void removeBean(XCreator creator, int initWidth, int initHeight); void removeBean(XCreator creator, int initWidth, int initHeight);
/**
* 获取布局下控件树render
* @param creator
* @return
*/
default XCreatorTreeCellRender getLayoutTreeCellRender(XCreator creator) {
return new DefaultXCreatorTreeCellRender(creator);
}
/**
* 获取布局下支持的设计器基本操作
* @return
*/
default DesignerBaseOperate getDesignerBaseOperate() {
return new DefaultDesignerBaseOperate();
}
/**
* 是否支持修改间距
* @return
*/
default boolean supportModifyInsert() {
return true;
}
void dragStart(XCreator xCreator, SelectionModel selectionModel);
default void dragOver(XCreator xCreator, SelectionModel selectionModel, int x, int y) {
};
} }

35
designer-form/src/main/java/com/fr/design/designer/beans/PredefinedLayout.java

@ -0,0 +1,35 @@
package com.fr.design.designer.beans;
import java.io.Serializable;
public class PredefinedLayout implements Serializable {
private static final String IMAGE_PATH = "/com/fr/design/form/layouts/images/";
private static final String TEMPLATE_PATH = "/com/fr/design/form/layouts/templates/";
private String template;
private String realStyle;
private String simpleStyle;
public String getTemplate() {
return TEMPLATE_PATH + template;
}
public void setTemplate(String template) {
this.template = template;
}
public String getRealStyle() {
return IMAGE_PATH + realStyle;
}
public void setRealStyle(String realStyle) {
this.realStyle = realStyle;
}
public String getSimpleStyle() {
return IMAGE_PATH + simpleStyle;
}
public void setSimpleStyle(String simpleStyle) {
this.simpleStyle = simpleStyle;
}
}

1
designer-form/src/main/java/com/fr/design/designer/beans/actions/CutAction.java

@ -2,7 +2,6 @@ package com.fr.design.designer.beans.actions;
import com.fr.design.base.mode.DesignModeContext; import com.fr.design.base.mode.DesignModeContext;
import com.fr.design.designer.beans.actions.behavior.ComponentEnable;
import com.fr.design.designer.beans.actions.behavior.CutableEnable; import com.fr.design.designer.beans.actions.behavior.CutableEnable;
import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.FormDesigner;

7
designer-form/src/main/java/com/fr/design/designer/beans/actions/PasteAction.java

@ -1,6 +1,7 @@
package com.fr.design.designer.beans.actions; package com.fr.design.designer.beans.actions;
import com.fr.design.base.mode.DesignModeContext; import com.fr.design.base.mode.DesignModeContext;
import com.fr.design.designer.beans.actions.behavior.PasteEnable;
import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.FormDesigner;
import javax.swing.KeyStroke; import javax.swing.KeyStroke;
@ -15,6 +16,7 @@ public class PasteAction extends FormWidgetEditAction {
this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_M_Edit_Paste")); this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_M_Edit_Paste"));
this.setMnemonic('P'); this.setMnemonic('P');
this.setSmallIcon("/com/fr/design/images/m_edit/paste"); this.setSmallIcon("/com/fr/design/images/m_edit/paste");
this.setUpdateBehavior(new PasteEnable());
this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, DEFAULT_MODIFIER)); this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, DEFAULT_MODIFIER));
} }
@ -23,9 +25,4 @@ public class PasteAction extends FormWidgetEditAction {
return DesignModeContext.doPaste(getEditingComponent()); return DesignModeContext.doPaste(getEditingComponent());
} }
@Override
public void update() {
this.setEnabled(true);
}
} }

16
designer-form/src/main/java/com/fr/design/designer/beans/actions/behavior/PasteEnable.java

@ -0,0 +1,16 @@
package com.fr.design.designer.beans.actions.behavior;
import com.fr.design.designer.beans.actions.FormWidgetEditAction;
import com.fr.design.mainframe.FormDesigner;
public class PasteEnable implements UpdateBehavior<FormWidgetEditAction> {
@Override
public void doUpdate(FormWidgetEditAction action) {
FormDesigner designer = action.getEditingComponent();
if (designer == null) {
action.setEnabled(false);
return;
}
action.setEnabled(designer.isCurrentComponentPastable());
}
}

9
designer-form/src/main/java/com/fr/design/designer/beans/adapters/component/CompositeComponentAdapter.java

@ -29,6 +29,7 @@ import java.awt.Dimension;
import java.awt.Graphics; import java.awt.Graphics;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.awt.image.BufferedImage;
import java.beans.IntrospectionException; import java.beans.IntrospectionException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
@ -66,11 +67,13 @@ public class CompositeComponentAdapter implements ComponentAdapter {
public void paintComponentMascot(Graphics g) { public void paintComponentMascot(Graphics g) {
//自适应交叉点渲染有点问题,拖拽的控件设置成半透明 //自适应交叉点渲染有点问题,拖拽的控件设置成半透明
Graphics2D g2d = (Graphics2D) g; Graphics2D g2d = (Graphics2D) g;
AlphaComposite composite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER,.5f); AlphaComposite composite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, .5f);
g2d.setComposite(composite); g2d.setComposite(composite);
xCreator.paint(g2d); BufferedImage im = new BufferedImage(xCreator.getWidth(), xCreator.getHeight(), BufferedImage.TYPE_INT_ARGB);
xCreator.paint(im.getGraphics());
g.drawImage(im, 0, 0, xCreator.initEditorSize().width - 1, xCreator.initEditorSize().height - 1, null);
g.setColor(XCreatorConstants.RESIZE_BOX_BORDER_COLOR); g.setColor(XCreatorConstants.RESIZE_BOX_BORDER_COLOR);
g.drawRect(0, 0, xCreator.getWidth() - 1, xCreator.getHeight() - 1); g.drawRect(0, 0, xCreator.initEditorSize().width - 1, xCreator.initEditorSize().height - 1);
} }
@Override @Override

8
designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/AbstractLayoutAdapter.java

@ -4,6 +4,7 @@ import com.fr.design.beans.GroupModel;
import com.fr.design.designer.beans.ConstraintsGroupModel; import com.fr.design.designer.beans.ConstraintsGroupModel;
import com.fr.design.designer.beans.HoverPainter; import com.fr.design.designer.beans.HoverPainter;
import com.fr.design.designer.beans.LayoutAdapter; import com.fr.design.designer.beans.LayoutAdapter;
import com.fr.design.designer.beans.models.SelectionModel;
import com.fr.design.designer.beans.painters.NullPainter; import com.fr.design.designer.beans.painters.NullPainter;
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;
@ -203,4 +204,11 @@ public abstract class AbstractLayoutAdapter implements LayoutAdapter {
public XLayoutContainer getContainer() { public XLayoutContainer getContainer() {
return this.container; return this.container;
} }
public void dragStart(XCreator xCreator, SelectionModel selectionModel){
selectionModel.removeCreator(xCreator, xCreator.getWidth(), xCreator.getHeight());
selectionModel.setSelectedCreator(container);
}
} }

23
designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/DefaultDesignerBaseOperate.java

@ -0,0 +1,23 @@
package com.fr.design.designer.beans.adapters.layout;
public class DefaultDesignerBaseOperate implements DesignerBaseOperate{
@Override
public boolean supportCopyAction() {
return true;
}
@Override
public boolean supportCutAction() {
return true;
}
@Override
public boolean supportPasteAction() {
return true;
}
@Override
public boolean supportDeleteAction() {
return true;
}
}

33
designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/DesignerBaseOperate.java

@ -0,0 +1,33 @@
package com.fr.design.designer.beans.adapters.layout;
public interface DesignerBaseOperate {
/**
* 是否支持复制
*
* @return boolean
*/
boolean supportCopyAction();
/**
* 是否支持剪切
*
* @return boolean
*/
boolean supportCutAction();
/**
* 是否支持粘贴
*
* @return boolean
*/
boolean supportPasteAction();
/**
* 是否支持删除
*
* @return boolean
*/
boolean supportDeleteAction();
}

29
designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRCardMainBorderLayoutAdapter.java

@ -7,8 +7,6 @@ import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.form.layout.FRBorderLayout; import com.fr.design.form.layout.FRBorderLayout;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import javax.swing.JOptionPane;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Rectangle; import java.awt.Rectangle;
@ -46,18 +44,27 @@ public class FRCardMainBorderLayoutAdapter extends FRBorderLayoutAdapter {
Rectangle rectangle = creator.getBounds(); Rectangle rectangle = creator.getBounds();
//不能超出控件边界 //不能超出控件边界
if (ComparatorUtils.equals(constraints, BorderLayout.NORTH) || ComparatorUtils.equals(constraints, BorderLayout.SOUTH)) { if (ComparatorUtils.equals(constraints, BorderLayout.NORTH) || ComparatorUtils.equals(constraints, BorderLayout.SOUTH)) {
int containerHeight = container.getHeight(); return isBeyondMinConstraint(rectangle.height, container.getHeight());
if (rectangle.height > containerHeight) {
FineJOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Beyond_Tablayout_Bounds"));
return true;
}
} else if (ComparatorUtils.equals(constraints, BorderLayout.EAST) || ComparatorUtils.equals(constraints, BorderLayout.WEST)) { } else if (ComparatorUtils.equals(constraints, BorderLayout.EAST) || ComparatorUtils.equals(constraints, BorderLayout.WEST)) {
int containerWidth = container.getWidth(); return isBeyondMinConstraint(rectangle.width, container.getWidth());
if (rectangle.width > containerWidth) {
FineJOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Beyond_Tablayout_Bounds"));
return true;
} }
return false;
} }
/**
* 是否超出最小限制
*
* @param minConstraint 最小限制
* @param value 数值
* @return 是否超出最小限制
*/
private boolean isBeyondMinConstraint(int minConstraint, int value) {
if (minConstraint > value) {
FineJOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Beyond_Tablayout_Bounds"));
container.setSize(container.getBackupBound().getSize());
return true;
} else {
return false; return false;
} }
}
} }

71
designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRFitLayoutAdapter.java

@ -7,7 +7,8 @@ import com.fr.design.ExtraDesignClassManager;
import com.fr.design.beans.GroupModel; import com.fr.design.beans.GroupModel;
import com.fr.design.designer.beans.ConstraintsGroupModel; import com.fr.design.designer.beans.ConstraintsGroupModel;
import com.fr.design.designer.beans.HoverPainter; import com.fr.design.designer.beans.HoverPainter;
import com.fr.design.designer.beans.painters.FRFitLayoutPainter; import com.fr.design.designer.beans.LayoutAdapter;
import com.fr.design.designer.beans.models.SelectionModel;
import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XCreatorUtils; import com.fr.design.designer.creator.XCreatorUtils;
import com.fr.design.designer.creator.XLayoutContainer; import com.fr.design.designer.creator.XLayoutContainer;
@ -19,6 +20,7 @@ import com.fr.design.designer.creator.cardlayout.XWCardTitleLayout;
import com.fr.design.designer.creator.cardlayout.XWTabFitLayout; import com.fr.design.designer.creator.cardlayout.XWTabFitLayout;
import com.fr.design.designer.properties.FRFitLayoutConstraints; import com.fr.design.designer.properties.FRFitLayoutConstraints;
import com.fr.design.designer.properties.FRFitLayoutPropertiesGroupModel; import com.fr.design.designer.properties.FRFitLayoutPropertiesGroupModel;
import com.fr.design.designer.treeview.XCreatorTreeCellRender;
import com.fr.design.fun.FormWidgetOptionProvider; import com.fr.design.fun.FormWidgetOptionProvider;
import com.fr.design.utils.ComponentUtils; import com.fr.design.utils.ComponentUtils;
import com.fr.form.ui.LayoutBorderStyle; import com.fr.form.ui.LayoutBorderStyle;
@ -43,8 +45,6 @@ import java.util.Set;
* @date 2014-6-24 * @date 2014-6-24
*/ */
public class FRFitLayoutAdapter extends FRBodyLayoutAdapter { public class FRFitLayoutAdapter extends FRBodyLayoutAdapter {
public static final String WIDGETPANEICONPATH = "/com/fr/web/images/form/resources/layout_absolute.png";
private static final int DEPENDING_SCOPE = 3; private static final int DEPENDING_SCOPE = 3;
private HoverPainter painter; private HoverPainter painter;
//区分拖拽和编辑宽高 //区分拖拽和编辑宽高
@ -58,6 +58,8 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter {
isEdit = edit; isEdit = edit;
} }
private LayoutAdapter frLayoutState;
/** /**
* 构造函数 * 构造函数
* *
@ -65,10 +67,18 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter {
*/ */
public FRFitLayoutAdapter(XLayoutContainer container) { public FRFitLayoutAdapter(XLayoutContainer container) {
super(container); super(container);
painter = new FRFitLayoutPainter(container);
initMinSize(); initMinSize();
this.frLayoutState = new FRNoFixLayoutAdapter(this, container, minHeight);
painter = this.frLayoutState.getPainter();
} }
public void setFrLayoutState(LayoutAdapter frLayoutState){
this.frLayoutState = frLayoutState;
painter = this.frLayoutState.getPainter();
}
private void initMinSize() { private void initMinSize() {
XWFitLayout layout = (XWFitLayout) container; XWFitLayout layout = (XWFitLayout) container;
minWidth = layout.getActualMinWidth(); minWidth = layout.getActualMinWidth();
@ -100,16 +110,7 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter {
*/ */
@Override @Override
public void addComp(XCreator child, int x, int y) { public void addComp(XCreator child, int x, int y) {
fix(child, x, y); frLayoutState.addBean(child, x, y);
if (child.shouldScaleCreator() || child.hasTitleStyle()) {
addParentCreator(child);
} else {
container.add(child, child.toData().getWidgetName());
}
XWFitLayout layout = (XWFitLayout) container;
// 更新对应的BoundsWidget
layout.updateBoundsWidget();
updateCreatorBackBound();
} }
public void updateCreatorBackBound() { public void updateCreatorBackBound() {
@ -130,11 +131,6 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter {
} }
private void addParentCreator(XCreator child) {
XLayoutContainer parentPanel = child.initCreatorWrapper(minHeight);
container.add(parentPanel, child.toData().getWidgetName());
}
/** /**
* 能否对应位置放置当前组件 * 能否对应位置放置当前组件
* *
@ -206,7 +202,7 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter {
* @param y 纵坐标 * @param y 纵坐标
* @return 是否在组件边缘 * @return 是否在组件边缘
*/ */
public boolean matchEdge(int x, int y) { private boolean matchEdge(int x, int y) {
if (intersectsEdge(x, y, container)) { if (intersectsEdge(x, y, container)) {
//寻找最近的fit, 在边缘地段添加的控件, 将其送给该fit //寻找最近的fit, 在边缘地段添加的控件, 将其送给该fit
XLayoutContainer parent = container.findNearestFit(); XLayoutContainer parent = container.findNearestFit();
@ -760,15 +756,9 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter {
super.fixTrisect(currentComp, child, x, y); super.fixTrisect(currentComp, child, x, y);
} }
/** public void removeBean(XCreator creator, int creatorWidth, int creatorHeight) {
* 删除组件或者重新拖动时其它组件重新计算位置大小 frLayoutState.removeBean(creator, creatorWidth, creatorHeight);
*/
protected void delete(XCreator creator, int creatorWidth, int creatorHeight) {
int x = creator.getX();
int y = creator.getY();
recalculateChildrenSize(x, y, creatorWidth, creatorHeight, true);
} }
/** /**
* 重新计算内部组件大小 * 重新计算内部组件大小
* *
@ -1216,11 +1206,11 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter {
/** /**
* 删除或拉伸上边框 调整上方的组件位置大小 * 删除或拉伸上边框 调整上方的组件位置大小
*/ */
protected boolean calculateUpRelatComponent(int objHeight) { private boolean calculateUpRelatComponent(int objHeight) {
return calculateUpRelatComponent(objHeight, false); return calculateUpRelatComponent(objHeight, false);
} }
protected boolean calculateUpRelatComponent(int objHeight, boolean isDel) { private boolean calculateUpRelatComponent(int objHeight, boolean isDel) {
if (!isDel && isBeyondAdjustHeightScope(objHeight)) { if (!isDel && isBeyondAdjustHeightScope(objHeight)) {
return false; return false;
} }
@ -1248,4 +1238,25 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter {
public ConstraintsGroupModel getLayoutConstraints(XCreator creator) { public ConstraintsGroupModel getLayoutConstraints(XCreator creator) {
return new FRFitLayoutConstraints((XWFitLayout) container, creator); return new FRFitLayoutConstraints((XWFitLayout) container, creator);
} }
public XCreatorTreeCellRender getLayoutTreeCellRender(XCreator creator){
return frLayoutState.getLayoutTreeCellRender(creator);
}
@Override
public DesignerBaseOperate getDesignerBaseOperate() {
return frLayoutState.getDesignerBaseOperate();
}
public boolean supportModifyInsert() {
return frLayoutState.supportModifyInsert();
}
public void dragStart(XCreator xCreator, SelectionModel selectionModel){
frLayoutState.dragStart(xCreator, selectionModel);
}
public void dragOver(XCreator xCreator, SelectionModel selectionModel,int x, int y) {
frLayoutState.dragOver(xCreator, selectionModel,x,y);
};
} }

138
designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRFixLayoutAdapter.java

@ -0,0 +1,138 @@
package com.fr.design.designer.beans.adapters.layout;
import com.fr.base.svg.IconUtils;
import com.fr.design.designer.beans.HoverPainter;
import com.fr.design.designer.beans.models.ModelUtil;
import com.fr.design.designer.beans.models.SelectionModel;
import com.fr.design.designer.beans.painters.FRFixLayoutPainter;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.creator.XOccupiedLayout;
import com.fr.design.designer.treeview.DefaultXCreatorTreeCellRender;
import com.fr.design.designer.treeview.XCreatorTreeCellRender;
import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.WidgetPropertyPane;
import com.fr.form.ui.container.OccupiedLayout;
import javax.swing.Icon;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Graphics;
public class FRFixLayoutAdapter extends AbstractLayoutAdapter {
private static final Icon OCCUPIED_ICON = IconUtils.readIcon("/com/fr/design/form/images/occupied_layout.png");
public FRFixLayoutAdapter( XLayoutContainer container) {
super(container);
}
public void addComp(XCreator child, int x, int y) {
Component component = container.getComponentAt(x, y);
if (component == container) {
return;
}
child.setLocation(component.getX(), component.getY());
child.setSize(component.getWidth(), component.getHeight());
if (child.shouldScaleCreator() || child.hasTitleStyle()) {
XLayoutContainer parentPanel = child.initCreatorWrapper(21);
container.replaceXcreator(parentPanel, (XCreator) component);
} else {
container.replaceXcreator(child, (XCreator) component);
}
if (child.getBackupRectangle() != null && child.getParent() == container) {
Component origin = container.getComponentAt(child.getBackupRectangle().x + 5, child.getBackupRectangle().y + 5);
if (origin == container) {
return;
}
if (origin instanceof XOccupiedLayout) {
((XOccupiedLayout) origin).getLayoutAdapter().addBean((XCreator) component, child.getBackupRectangle().x + 5, child.getBackupRectangle().y + 5);
}
}
}
@Override
public void delete(XCreator creator, int creatorWidth, int creatorHeight) {
//固定布局下不支持移除占位块组件
if (creator.acceptType(XOccupiedLayout.class)){
return;
}
OccupiedLayout occupiedLayout = new OccupiedLayout();
FormDesigner formDesigner = WidgetPropertyPane.getInstance().getEditingFormDesigner();
XOccupiedLayout xoccupiedLayout = new XOccupiedLayout(occupiedLayout, new Dimension());
ModelUtil.renameWidgetName(formDesigner.getTarget(), xoccupiedLayout);
xoccupiedLayout.setLocation(creator.getX(), creator.getY());
xoccupiedLayout.setSize(creatorWidth, creatorHeight);
container.replaceXcreator(xoccupiedLayout,creator);
}
@Override
public XCreatorTreeCellRender getLayoutTreeCellRender(XCreator creator) {
return new DefaultXCreatorTreeCellRender(creator) {
@Override
public void paint(Graphics g, Component c) {
if (!getxCreator().acceptType(XOccupiedLayout.class)) {
OCCUPIED_ICON.paintIcon(c, g, 0, 0);
}
super.paint(g, c);
}
};
}
@Override
public boolean supportModifyInsert() {
return false;
}
@Override
public DesignerBaseOperate getDesignerBaseOperate() {
return new DesignerBaseOperate() {
@Override
public boolean supportCopyAction() {
return false;
}
@Override
public boolean supportCutAction() {
return false;
}
@Override
public boolean supportPasteAction() {
return false;
}
@Override
public boolean supportDeleteAction() {
return true;
}
};
}
@Override
public boolean accept(XCreator creator, int x, int y) {
return true;
}
@Override
public HoverPainter getPainter() {
return new FRFixLayoutPainter(container);
}
@Override
public void dragStart(XCreator xCreator, SelectionModel selectionModel) {
//do nothing
}
public void dragOver(XCreator xCreator, SelectionModel selectionModel, int x, int y) {
//当鼠标移出被拖拽的组件时,才将组件从selectionmodel 中移出
if (xCreator.getBackupRectangle()!= null && !xCreator.getBackupRectangle().contains(x, y)
&& selectionModel.getSelection().contains(xCreator.toData())) {
selectionModel.removeCreator(xCreator, xCreator.getWidth(), xCreator.getHeight());
selectionModel.setSelectedCreator(container);
}
}
;
}

116
designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRNoFixLayoutAdapter.java

@ -0,0 +1,116 @@
package com.fr.design.designer.beans.adapters.layout;
import com.fr.design.designer.beans.models.SelectionModel;
import com.fr.design.designer.beans.painters.AbstractPainter;
import com.fr.design.designer.beans.painters.FRFitLayoutPainter;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.creator.XWFitLayout;
import com.fr.design.designer.creator.cardlayout.XWTabFitLayout;
import java.awt.Component;
import java.util.ArrayList;
public class FRNoFixLayoutAdapter extends AbstractLayoutAdapter {
private int minHeight;
private FRBodyLayoutAdapter parentLayoutAdapter;
public FRNoFixLayoutAdapter(FRBodyLayoutAdapter parentLayoutAdapter, XLayoutContainer container, int minHeight) {
super(container);
this.parentLayoutAdapter = parentLayoutAdapter;
this.minHeight = minHeight;
}
@Override
public void addComp(XCreator child, int x, int y) {
fix(child, x, y);
if (child.shouldScaleCreator() || child.hasTitleStyle()) {
addParentCreator(child);
} else {
container.add(child, child.toData().getWidgetName());
}
XWFitLayout layout = (XWFitLayout) container;
// 更新对应的BoundsWidget
layout.updateBoundsWidget();
updateCreatorBackBound();
}
private void updateCreatorBackBound() {
for (int i = 0, size = container.getComponentCount(); i < size; i++) {
XCreator creator = (XCreator) container.getComponent(i);
creator.updateChildBound(minHeight);
creator.setBackupBound(creator.getBounds());
//tab布局用到
ArrayList<?> childrenList = creator.getTargetChildrenList();
for (int j = 0; j < childrenList.size(); j++) {
XWTabFitLayout tabLayout = (XWTabFitLayout) childrenList.get(j);
for (int m = 0; m < tabLayout.getComponentCount(); m++) {
XCreator childCreator = tabLayout.getXCreator(m);
childCreator.setBackupBound(childCreator.getBounds());
}
}
}
}
private void addParentCreator(XCreator child) {
XLayoutContainer parentPanel = child.initCreatorWrapper(minHeight);
container.add(parentPanel, child.toData().getWidgetName());
}
private void fix(XCreator child, int x, int y) {
Component parentComp = container.getComponentAt(x, y);
if (container.getComponentCount() == 0) {
child.setLocation(0, 0);
child.setSize(parentComp.getWidth(), parentComp.getHeight());
} else if (parentLayoutAdapter.isCrossPointArea(parentComp, x, y)) {
//交叉区域插入组件时,根据具体位置进行上下或者左右或者相邻三个组件的位置大小插入
parentLayoutAdapter.fixCrossPointArea(parentComp, child, x, y);
return;
} else if (parentLayoutAdapter.isTrisectionArea(parentComp, x, y)) {
// 在边界三等分区域,就不再和组件二等分了
parentLayoutAdapter.fixTrisect(parentComp, child, x, y);
return;
} else {
parentLayoutAdapter.fixHalve(parentComp, child, x, y);
}
}
@Override
public void delete(XCreator creator, int creatorWidth, int creatorHeight) {
int x = creator.getX();
int y = creator.getY();
((FRFitLayoutAdapter)parentLayoutAdapter).recalculateChildrenSize(x, y, creatorWidth, creatorHeight, true);
}
@Override
public boolean supportModifyInsert() {
return true;
}
@Override
public DesignerBaseOperate getDesignerBaseOperate() {
return new DefaultDesignerBaseOperate() {
@Override
public boolean supportCutAction() {
return container.getComponentCount() > 1;
}
};
}
@Override
public boolean accept(XCreator creator, int x, int y) {
return true;
}
@Override
public AbstractPainter getPainter() {
return new FRFitLayoutPainter(container);
}
@Override
public void dragStart(XCreator xCreator, SelectionModel selectionModel) {
selectionModel.removeCreator(xCreator, xCreator.getWidth(), xCreator.getHeight());
selectionModel.setSelectedCreator(container);
}
}

63
designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FROccupiedLayoutAdapter.java

@ -0,0 +1,63 @@
package com.fr.design.designer.beans.adapters.layout;
import com.fr.design.designer.beans.HoverPainter;
import com.fr.design.designer.beans.painters.FROccupiedLayoutPainter;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.treeview.DefaultXCreatorTreeCellRender;
import com.fr.design.designer.treeview.XCreatorTreeCellRender;
import com.fr.design.utils.gui.LayoutUtils;
import java.awt.Color;
import java.awt.Component;
import java.awt.Graphics;
public class FROccupiedLayoutAdapter extends AbstractLayoutAdapter {
public FROccupiedLayoutAdapter(XLayoutContainer container) {
super(container);
painter = new FROccupiedLayoutPainter(container);
}
private HoverPainter painter;
@Override
protected void addComp(XCreator creator, int x, int y) {
if (container.getComponentCount() == 0) {
creator.setLocation(container.getLocation().x, container.getLocation().y);
creator.setSize(container.getWidth(), container.getHeight());
XLayoutContainer parent = (XLayoutContainer) container.getParent();
if (creator.shouldScaleCreator() || creator.hasTitleStyle()) {
XLayoutContainer parentPanel = creator.initCreatorWrapper(21);
parent.replaceXcreator(parentPanel, container);
} else {
parent.replaceXcreator(creator, container);
}
LayoutUtils.layoutContainer(parent);
}
}
@Override
public HoverPainter getPainter() {
return painter;
}
@Override
public boolean accept(XCreator creator, int x, int y) {
return container.getComponentCount() == 0;
}
public XCreatorTreeCellRender getLayoutTreeCellRender(XCreator creator) {
return new DefaultXCreatorTreeCellRender(creator) {
@Override
public void paint(Graphics g, Component c) {
super.paint(g, c);
Color oldColor = g.getColor();
g.setColor(Color.RED);
g.drawRect(0, 0, 16, 16);
g.setColor(oldColor);
}
};
}
}

9
designer-form/src/main/java/com/fr/design/designer/beans/models/AddingModel.java

@ -51,9 +51,8 @@ public class AddingModel {
this.creator = xCreator; this.creator = xCreator;
this.creator.backupCurrentSize(); this.creator.backupCurrentSize();
this.creator.backupParent(); this.creator.backupParent();
this.creator.setSize(xCreator.initEditorSize()); currentX = x - (xCreator.initEditorSize().width / 2);
currentX = x - (xCreator.getWidth() / 2); currentY = y - (xCreator.initEditorSize().height / 2);
currentY = y - (xCreator.getHeight() / 2);
} }
/** /**
@ -93,8 +92,8 @@ public class AddingModel {
* @param y 坐标 * @param y 坐标
*/ */
public void moveTo(int x, int y) { public void moveTo(int x, int y) {
currentX = x - (this.creator.getWidth() / 2); currentX = x - (this.creator.initEditorSize().width / 2);
currentY = y - (this.creator.getHeight() / 2); currentY = y - (this.creator.initEditorSize().height / 2);
} }
public XCreator getXCreator() { public XCreator getXCreator() {

2
designer-form/src/main/java/com/fr/design/designer/beans/models/ModelUtil.java

@ -18,7 +18,7 @@ import java.util.Set;
/** /**
* created by Harrison on 2020/06/05 * created by Harrison on 2020/06/05
**/ **/
abstract class ModelUtil { public abstract class ModelUtil {
public static void renameWidgetName(Form form, XCreator xCreator) { public static void renameWidgetName(Form form, XCreator xCreator) {

57
designer-form/src/main/java/com/fr/design/designer/beans/models/NewFormModel.java

@ -0,0 +1,57 @@
package com.fr.design.designer.beans.models;
import com.fr.design.designer.beans.PredefinedLayout;
import com.fr.general.IOUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils;
import com.fr.third.fasterxml.jackson.databind.ObjectMapper;
import java.io.InputStream;
import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class NewFormModel implements Serializable {
private static final String CONFIG_FILE_PATH = "/com/fr/design/form/layouts/config.json";
private static NewFormModel holder = null;
private Map<String, List<PredefinedLayout>> config = new HashMap<>();
public static NewFormModel getInstance() {
if (holder == null) {
try {
holder = new ObjectMapper().readValue(readConfigFile(), NewFormModel.class);
} catch (Exception e) {
holder = new NewFormModel();
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
return holder;
}
private NewFormModel() {
}
private synchronized static String readConfigFile() {
String result = StringUtils.EMPTY;
InputStream is = null;
try {
is = IOUtils.readResource(CONFIG_FILE_PATH);
result = IOUtils.inputStream2String(is);
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
} finally {
IOUtils.close(is);
}
return result;
}
public Map<String, List<PredefinedLayout>> getConfig() {
return config;
}
public void setConfig(Map<String, List<PredefinedLayout>> config) {
this.config = config;
}
}

20
designer-form/src/main/java/com/fr/design/designer/beans/models/SelectionModel.java

@ -140,11 +140,28 @@ public class SelectionModel {
if (cutSelection != null) { if (cutSelection != null) {
cutSelection.cut2ClipBoard(clipboard); cutSelection.cut2ClipBoard(clipboard);
designer.getEditListenerTable().fireCreatorModified(DesignerEvent.CREATOR_CUTED); designer.getEditListenerTable().fireCreatorModified(DesignerEvent.CREATOR_CUTED);
setSelectedCreator(hasSelectedParaComponent() ? designer.getParaComponent() : designer.getRootComponent());
designer.repaint(); designer.repaint();
} }
} }
} }
/**
* 判断是否选中参数面板中的组件
* @return boolean
*/
private boolean hasSelectedParaComponent() {
XCreator[] roots = selection.getSelectedCreators();
if (roots.length > 0) {
for (XCreator creator : roots) {
if ((creator.getParent() instanceof XWParameterLayout)) {
return true;
}
}
}
return false;
}
/** /**
* 复制当前选中的组件到剪切板 * 复制当前选中的组件到剪切板
*/ */
@ -320,8 +337,7 @@ public class SelectionModel {
} }
designer.getEditListenerTable().fireCreatorModified(DesignerEvent.CREATOR_DELETED); designer.getEditListenerTable().fireCreatorModified(DesignerEvent.CREATOR_DELETED);
setSelectedCreator(isInPara ? designer.getParaComponent() : designer.getRootComponent()); setSelectedCreator(isInPara? designer.getParaComponent() : designer.getRootComponent());
// 触发事件 // 触发事件
designer.repaint(); designer.repaint();

130
designer-form/src/main/java/com/fr/design/designer/beans/painters/FRFixLayoutPainter.java

@ -0,0 +1,130 @@
package com.fr.design.designer.beans.painters;
import com.fr.design.designer.beans.painters.AbstractPainter;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.creator.XOccupiedLayout;
import com.fr.design.form.util.XCreatorConstants;
import java.awt.AlphaComposite;
import java.awt.Color;
import java.awt.Component;
import java.awt.Composite;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.Stroke;
public class FRFixLayoutPainter extends AbstractPainter {
/**
* 构造函数
*
* @param container
*/
public FRFixLayoutPainter(XLayoutContainer container) {
super(container);
}
/**
* 组件渲染
*
* @param g 画图类
* @param startX 开始位置x
* @param startY 开始位置y
*/
@Override
public void paint(Graphics g, int startX, int startY) {
super.paint(g, startX, startY);
int x = hotspot.x - hotspot_bounds.x;
int y = hotspot.y - hotspot_bounds.y;
Component currentComp = container.getComponentAt(x, y);
if (currentComp == null) {
return;
}
boolean accept = currentComp != container;
if (accept) {
OperateState state = OperateState.DEFAULT;
if (currentComp == creator) {
state = OperateState.COMPONENT_DRAG_OUT;
} else if (!((XCreator) currentComp).acceptType(XOccupiedLayout.class)) {
state = OperateState.COMPONENT_REPLACE;
}
state.paint(g, creator.getBackupRectangle(), currentComp.getBounds(), new Rectangle(x, y, creator.initEditorSize().width, ((XCreator) currentComp).initEditorSize().height));
} else {
Color bColor = XCreatorConstants.LAYOUT_FORBIDDEN_COLOR;
int[] hot_rec = new int[]{x, y, 0, 0};
drawHotspot(g, x, y, hot_rec[2], hot_rec[3], bColor, false, false);
}
}
enum OperateState {
COMPONENT_REPLACE {
@Override
void paint(Graphics g, Rectangle oriRectangle, Rectangle currentRectangle, Rectangle hotspot_bounds) {
Graphics2D g2d = (Graphics2D) g;
Color color = g2d.getColor();
Stroke backup = g2d.getStroke();
Composite backupComp = g2d.getComposite();
g2d.setColor(XCreatorConstants.REPLACE_OCCUPIED_LAYOUT_COLOR);
g2d.setStroke(XCreatorConstants.DASH_STROKE);
//绘制当前组件的边框
g2d.drawRect(currentRectangle.x, currentRectangle.y, currentRectangle.width, currentRectangle.height);
//底色透明度0.2
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.2f));
//绘制进行替换的时候,被替换的组件的底色
g2d.fillRect(currentRectangle.x, currentRectangle.y, currentRectangle.width, currentRectangle.height);
//绘制原组件位置处的占位块
if (oriRectangle != null) {
g2d.setColor(XCreatorConstants.DRAG_OUT_OCCUPIED_LAYOUT_COLOR);
//如果是从其他占位块上拖过来的,绘制下其他占位块的状态
g2d.drawRect(oriRectangle.x + 1, oriRectangle.y + 1, oriRectangle.width - 2, oriRectangle.height - 2);
//底色透明度0.2
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.2f));
//绘制进行替换的时候,被替换的组件的底色
g2d.fillRect(oriRectangle.x, oriRectangle.y, oriRectangle.width, oriRectangle.height);
}
//还原
g2d.setComposite(backupComp);
g2d.setStroke(backup);
g2d.setColor(color);
}
},
COMPONENT_DRAG_OUT {
@Override
void paint(Graphics g, Rectangle oriRectangle, Rectangle currentRectangle, Rectangle hotspot_bounds) {
Graphics2D g2d = (Graphics2D) g;
Color color = g2d.getColor();
Stroke backup = g2d.getStroke();
Composite backupComp = g2d.getComposite();
// 设置线条的样式
g2d.setStroke(XCreatorConstants.DASH_STROKE);
g2d.setColor(XCreatorConstants.DRAG_OUT_OCCUPIED_LAYOUT_COLOR);
//如果是从其他占位块上拖过来的,绘制下其他占位块的状态
g2d.drawRect(oriRectangle.x, oriRectangle.y, oriRectangle.width, oriRectangle.height);
//底色透明度0.2
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.2f));
//绘制进行替换的时候,被替换的组件的底色
g2d.fillRect(oriRectangle.x, oriRectangle.y, oriRectangle.width, oriRectangle.height);
g2d.setComposite(backupComp);
g2d.setStroke(backup);
g2d.setColor(color);
}
},
DEFAULT {
@Override
void paint(Graphics g, Rectangle oriRectangle, Rectangle currentRectangle, Rectangle hotspot_bounds) {
}
};
abstract void paint(Graphics g, Rectangle oriRectangle, Rectangle currentRectangle, Rectangle hotspot_bounds);
}
}

56
designer-form/src/main/java/com/fr/design/designer/beans/painters/FROccupiedLayoutPainter.java

@ -0,0 +1,56 @@
package com.fr.design.designer.beans.painters;
import com.fr.design.designer.beans.adapters.layout.FROccupiedLayoutAdapter;
import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.form.util.XCreatorConstants;
import java.awt.AlphaComposite;
import java.awt.Color;
import java.awt.Component;
import java.awt.Composite;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Stroke;
public class FROccupiedLayoutPainter extends AbstractPainter {
/**
* 构造函数
*
* @param container 容器
*/
public FROccupiedLayoutPainter(XLayoutContainer container) {
super(container);
}
@Override
public void paint(Graphics g, int startX, int startY) {
int x = hotspot.x - hotspot_bounds.x;
int y = hotspot.y - hotspot_bounds.y;
FROccupiedLayoutAdapter adapter = (FROccupiedLayoutAdapter) container.getLayoutAdapter();
Component currentComp = container.getComponentAt(x, y);
if (currentComp == null) {
return;
}
boolean accept = adapter.accept(creator, x, y);
if (accept) {
Color backupColor = g.getColor();
Graphics2D g2d = (Graphics2D) g;
Stroke backupStroke = g2d.getStroke();
Composite backupComposite = g2d.getComposite();
g2d.setColor(XCreatorConstants.DRAG_IN_OCCUPIED_LAYOUT_COLOR);
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.05f));
g2d.fillRect(container.getX(), container.getY(), container.getWidth(), container.getHeight());
g2d.setStroke(XCreatorConstants.DASH_STROKE);
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.2f));
g2d.drawRect(container.getX() + 1, container.getY() + 1, container.getWidth() - 2, container.getHeight() - 2);
g2d.setStroke(backupStroke);
g2d.setComposite(backupComposite);
g2d.setColor(backupColor);
}
}
}

48
designer-form/src/main/java/com/fr/design/designer/creator/XBorderStyleWidgetCreator.java

@ -21,6 +21,8 @@ import com.fr.stable.StringUtils;
import javax.swing.*; import javax.swing.*;
import javax.swing.border.Border; import javax.swing.border.Border;
import javax.swing.border.LineBorder; import javax.swing.border.LineBorder;
import javax.swing.plaf.PanelUI;
import javax.swing.plaf.basic.BasicPanelUI;
import java.awt.*; import java.awt.*;
import java.awt.geom.Rectangle2D; import java.awt.geom.Rectangle2D;
import java.awt.geom.RoundRectangle2D; import java.awt.geom.RoundRectangle2D;
@ -42,6 +44,7 @@ public class XBorderStyleWidgetCreator extends XWidgetCreator{
public XBorderStyleWidgetCreator(Widget widget, Dimension initSize) { public XBorderStyleWidgetCreator(Widget widget, Dimension initSize) {
super(widget, initSize); super(widget, initSize);
setUI(new NoBackgroundPaneUI());
setOpaque(false); setOpaque(false);
setBackupBound(null); setBackupBound(null);
@ -51,6 +54,13 @@ public class XBorderStyleWidgetCreator extends XWidgetCreator{
} }
} }
@Override
public void setUI(PanelUI ui) {
if (ui instanceof NoBackgroundPaneUI) {
super.setUI(ui);
}
}
public Background getBackground4Painting() { public Background getBackground4Painting() {
return this.background4Painting; return this.background4Painting;
} }
@ -91,12 +101,21 @@ public class XBorderStyleWidgetCreator extends XWidgetCreator{
super.addToWrapper(parentPanel, width, minHeight); super.addToWrapper(parentPanel, width, minHeight);
// REPORT-53175: 新创建的图表组件默认显示标题 since 10.0.18 // REPORT-53175: 新创建的图表组件默认显示标题 since 10.0.18
// 将当前对象添加到父容器后,初始化默认样式的效果 // 将当前对象添加到父容器后,初始化默认样式的效果
initStyle(); refreshStylePreviewEffect();
} }
/**
* @deprecated 该方法在样式数据模型发生变化如主题更新/body布局类型切换等均会被调用并不仅限于初始化
* 因此原方法名称废弃不应当被继续使用
* @link {{@link #refreshStylePreviewEffect()}}
*/
protected void initStyle() { protected void initStyle() {
refreshStylePreviewEffect();
}
public void refreshStylePreviewEffect() {
BorderPacker style = toData().getBorderStyle(); BorderPacker style = toData().getBorderStyle();
initBorderAndBackgroundStyle(); refreshBorderAndBackgroundStylePreviewEffect();
if (ComparatorUtils.equals(style.getType(), LayoutBorderStyle.TITLE)) { if (ComparatorUtils.equals(style.getType(), LayoutBorderStyle.TITLE)) {
initTitleStyle(style); initTitleStyle(style);
} else { } else {
@ -107,7 +126,16 @@ public class XBorderStyleWidgetCreator extends XWidgetCreator{
reshuffleBorderAndBackgroundPaintingEffectIfTitleExists(); reshuffleBorderAndBackgroundPaintingEffectIfTitleExists();
} }
/**
* @deprecated 该方法在样式数据模型发生变化如主题更新/图表默认开启标题等时均会被调用并不仅限于初始化
* 因此原方法名称废弃不应当被继续使用
* @link {{@link #refreshBorderAndBackgroundStylePreviewEffect()} ()}}
*/
protected void initBorderAndBackgroundStyle() { protected void initBorderAndBackgroundStyle() {
refreshBorderAndBackgroundStylePreviewEffect();
}
public void refreshBorderAndBackgroundStylePreviewEffect() {
BorderPacker style = toData().getBorderStyle(); BorderPacker style = toData().getBorderStyle();
LineBorder DEFAULT_LINE_BORDER = (LineBorder) DEFALUTBORDER; LineBorder DEFAULT_LINE_BORDER = (LineBorder) DEFALUTBORDER;
@ -288,6 +316,11 @@ public class XBorderStyleWidgetCreator extends XWidgetCreator{
// 设计器预览界面中绘制组件背景效果 // 设计器预览界面中绘制组件背景效果
public void paintBackground(Graphics2D g2d) { public void paintBackground(Graphics2D g2d) {
if (isOpaque()) {
g2d.setColor(getBackground());
g2d.fillRect(0, 0, getWidth(), getHeight());
}
Background background4Painting = getBackground4Painting(); Background background4Painting = getBackground4Painting();
if (background4Painting != null) { if (background4Painting != null) {
Composite oldComposite = g2d.getComposite(); Composite oldComposite = g2d.getComposite();
@ -311,12 +344,12 @@ public class XBorderStyleWidgetCreator extends XWidgetCreator{
} }
public void paintForeground(Graphics2D g2d) { public void paintForeground(Graphics2D g2d) {
super.paint(g2d); super.paintComponent(g2d);
super.paintBorder(g2d); super.paintBorder(g2d);
} }
@Override @Override
public void paint(Graphics g) { public void paintComponent(Graphics g) {
this.clipByRoundedBorder((Graphics2D) g); this.clipByRoundedBorder((Graphics2D) g);
this.paintBackground((Graphics2D) g); this.paintBackground((Graphics2D) g);
this.paintBorderImage((Graphics2D) g); this.paintBorderImage((Graphics2D) g);
@ -378,4 +411,11 @@ public class XBorderStyleWidgetCreator extends XWidgetCreator{
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
} }
} }
public static class NoBackgroundPaneUI extends BasicPanelUI {
@Override
public void update(Graphics g, JComponent c) {
paint(g, c);
}
}
} }

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

@ -122,7 +122,7 @@ public class XChartEditor extends XBorderStyleWidgetCreator {
@Override @Override
public void propertyChange() { public void propertyChange() {
initStyle(); refreshStylePreviewEffect();
} }
}), }),
}; };
@ -165,7 +165,7 @@ public class XChartEditor extends XBorderStyleWidgetCreator {
@Override @Override
protected void initXCreatorProperties() { protected void initXCreatorProperties() {
super.initXCreatorProperties(); super.initXCreatorProperties();
initBorderAndBackgroundStyle(); refreshBorderAndBackgroundStylePreviewEffect();
BaseChartCollection collection = ((BaseChartEditor) data).getChartCollection(); BaseChartCollection collection = ((BaseChartEditor) data).getChartCollection();
isRefreshing = true; isRefreshing = true;
((MiddleChartComponent) designerEditor.getEditorTarget()).populate(collection); ((MiddleChartComponent) designerEditor.getEditorTarget()).populate(collection);
@ -345,7 +345,7 @@ public class XChartEditor extends XBorderStyleWidgetCreator {
* data属性改变触发其他操作 * data属性改变触发其他操作
*/ */
public void firePropertyChange() { public void firePropertyChange() {
initStyle(); refreshStylePreviewEffect();
} }
@Override @Override

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

@ -9,6 +9,10 @@ import com.fr.design.ExtraDesignClassManager;
import com.fr.design.actions.UpdateAction; import com.fr.design.actions.UpdateAction;
import com.fr.design.designer.beans.events.DesignerEditor; import com.fr.design.designer.beans.events.DesignerEditor;
import com.fr.design.designer.beans.models.SelectionModel; import com.fr.design.designer.beans.models.SelectionModel;
import com.fr.design.designer.creator.operate.XCreatorBaseOperate;
import com.fr.design.designer.creator.operate.DefaultXCreatorBaseOperate;
import com.fr.design.designer.treeview.DefaultXCreatorTreeCellRender;
import com.fr.design.designer.treeview.XCreatorTreeCellRender;
import com.fr.design.designer.ui.SelectedPopupDialog; import com.fr.design.designer.ui.SelectedPopupDialog;
import com.fr.design.fun.ShareWidgetUIProcessor; import com.fr.design.fun.ShareWidgetUIProcessor;
import com.fr.design.fun.WidgetPropertyUIProvider; import com.fr.design.fun.WidgetPropertyUIProvider;
@ -62,7 +66,7 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo
protected static final Dimension MIDDLE_PREFERRED_SIZE = new Dimension(80, 50); protected static final Dimension MIDDLE_PREFERRED_SIZE = new Dimension(80, 50);
protected static final Dimension BIG_PREFERRED_SIZE = new Dimension(80, 80); protected static final Dimension BIG_PREFERRED_SIZE = new Dimension(80, 80);
// barry: 拖拽控件时,控件要恢复原始大小,就先把控件当前大小备份到这里。 // barry: 拖拽控件时,控件要恢复原始大小,就先把控件当前大小备份到这里。
protected Dimension backupSize; protected Rectangle backupRectangle;
protected XLayoutContainer backupParent; protected XLayoutContainer backupParent;
protected Widget data; protected Widget data;
@ -107,11 +111,15 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo
* 应用备份的大小 * 应用备份的大小
*/ */
public void useBackupSize() { public void useBackupSize() {
if (this.backupSize != null) { if (this.backupRectangle != null) {
setSize(this.backupSize); setSize(new Dimension(this.backupRectangle.width, this.backupRectangle.height));
} }
} }
public Rectangle getBackupRectangle(){
return this.backupRectangle;
}
/** /**
* 初始化组件大小 * 初始化组件大小
*/ */
@ -128,7 +136,7 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo
* 备份当前大小 * 备份当前大小
*/ */
public void backupCurrentSize() { public void backupCurrentSize() {
this.backupSize = getSize(); this.backupRectangle = getBounds();
} }
public XLayoutContainer getBackupParent() { public XLayoutContainer getBackupParent() {
@ -904,4 +912,24 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo
} }
return ((XCreator) this.getParent()).getLevel() + 1; return ((XCreator) this.getParent()).getLevel() + 1;
} }
/**
* 获取组件在组件树中的显示方式
* @return
*/
public XCreatorTreeCellRender getComponentTreeCellRender(){
if (this.getBackupParent()!= null){
return this.getBackupParent().getLayoutAdapter().getLayoutTreeCellRender(this);
}
return new DefaultXCreatorTreeCellRender(this);
}
/**
* 获取组件支持的基本操作
* @return
*/
public XCreatorBaseOperate getXCreatorBaseOperate() {
return new DefaultXCreatorBaseOperate();
}
} }

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

@ -28,6 +28,7 @@ import com.fr.design.utils.gui.LayoutUtils;
import com.fr.form.main.Form; import com.fr.form.main.Form;
import com.fr.form.main.WidgetGather; import com.fr.form.main.WidgetGather;
import com.fr.form.parameter.FormSubmitButton; import com.fr.form.parameter.FormSubmitButton;
import com.fr.form.ui.AbstractBorderStyleWidget;
import com.fr.form.ui.Button; import com.fr.form.ui.Button;
import com.fr.form.ui.CardAddButton; import com.fr.form.ui.CardAddButton;
import com.fr.form.ui.CardSwitchButton; import com.fr.form.ui.CardSwitchButton;
@ -54,6 +55,7 @@ import com.fr.form.ui.TreeComboBoxEditor;
import com.fr.form.ui.TreeEditor; import com.fr.form.ui.TreeEditor;
import com.fr.form.ui.Widget; import com.fr.form.ui.Widget;
import com.fr.form.ui.WidgetErrorMarker; import com.fr.form.ui.WidgetErrorMarker;
import com.fr.form.ui.container.OccupiedLayout;
import com.fr.form.ui.container.WAbsoluteBodyLayout; import com.fr.form.ui.container.WAbsoluteBodyLayout;
import com.fr.form.ui.container.WAbsoluteLayout; import com.fr.form.ui.container.WAbsoluteLayout;
import com.fr.form.ui.container.WBorderLayout; import com.fr.form.ui.container.WBorderLayout;
@ -137,6 +139,7 @@ public class XCreatorUtils {
xLayoutMap.put(WBorderLayout.class, XWBorderLayout.class); xLayoutMap.put(WBorderLayout.class, XWBorderLayout.class);
xLayoutMap.put(WCardLayout.class, XWCardLayout.class); xLayoutMap.put(WCardLayout.class, XWCardLayout.class);
xLayoutMap.put(WVerticalBoxLayout.class, XWVerticalBoxLayout.class); xLayoutMap.put(WVerticalBoxLayout.class, XWVerticalBoxLayout.class);
xLayoutMap.put(OccupiedLayout.class, XOccupiedLayout.class);
xLayoutMap.put(WFitLayout.class, XWFitLayout.class); xLayoutMap.put(WFitLayout.class, XWFitLayout.class);
xLayoutMap.put(WScaleLayout.class, XWScaleLayout.class); xLayoutMap.put(WScaleLayout.class, XWScaleLayout.class);
@ -232,7 +235,7 @@ public class XCreatorUtils {
JTemplate<?,?> template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); JTemplate<?,?> template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
TemplateTheme theme = template.getTemplateTheme(); TemplateTheme theme = template.getTemplateTheme();
if (theme instanceof FormTheme) { if (theme instanceof FormTheme) {
setupTemplateTheme(creator, (FormTheme) theme, TemplateThemeCompatible.NONE); setupTemplateTheme(creator, true, (FormTheme) theme, TemplateThemeCompatible.NONE);
} }
return creator; return creator;
} }
@ -378,12 +381,16 @@ public class XCreatorUtils {
return null; return null;
} }
public static void setupTemplateTheme(XCreator container, final FormTheme currentTemplateUsingTheme, TemplateThemeCompatible compatible) {
public static void setupTemplateTheme(XCreator container, final boolean forceFollowingTheme, final FormTheme currentTemplateUsingTheme, TemplateThemeCompatible compatible) {
FineColorGather colorGather = new FineColorManager.FineColorReplaceByTheme(currentTemplateUsingTheme, compatible); FineColorGather colorGather = new FineColorManager.FineColorReplaceByTheme(currentTemplateUsingTheme, compatible);
Form.traversalWidget(container.toData(), new WidgetGather() { Form.traversalWidget(container.toData(), new WidgetGather() {
@Override @Override
public void dealWith(Widget widget) { public void dealWith(Widget widget) {
TemplateThemeAware<FormTheme> themedWidget = (TemplateThemeAware) widget; TemplateThemeAware<FormTheme> themedWidget = (TemplateThemeAware) widget;
if (forceFollowingTheme && widget instanceof AbstractBorderStyleWidget) {
((AbstractBorderStyleWidget) widget).setBorderStyleFollowingTheme(true);
}
themedWidget.onTemplateUsingThemeChange(currentTemplateUsingTheme, compatible); themedWidget.onTemplateUsingThemeChange(currentTemplateUsingTheme, compatible);
} }

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

@ -50,15 +50,14 @@ public class XElementCase extends XBorderStyleWidgetCreator implements FormEleme
public XElementCase(ElementCaseEditor widget, Dimension initSize) { public XElementCase(ElementCaseEditor widget, Dimension initSize) {
super(widget, initSize); super(widget, initSize);
widget.getElementCaseImage().adjustImageSize(initSize.width, initSize.height, false);
} }
protected void initXCreatorProperties() { protected void initXCreatorProperties() {
super.initXCreatorProperties(); super.initXCreatorProperties();
// 报表块初始化时要加载对应的borderStyle // 报表块初始化时要加载对应的borderStyle
initBorderAndBackgroundStyle(); refreshBorderAndBackgroundStylePreviewEffect();
} }
/** /**
@ -94,7 +93,7 @@ public class XElementCase extends XBorderStyleWidgetCreator implements FormEleme
@Override @Override
public void propertyChange() { public void propertyChange() {
initStyle(); refreshStylePreviewEffect();
} }
}), }),
new CRPropertyDescriptor("margin", this.data.getClass()).setEditorClass(PaddingMarginEditor.class) new CRPropertyDescriptor("margin", this.data.getClass()).setEditorClass(PaddingMarginEditor.class)
@ -344,7 +343,7 @@ public class XElementCase extends XBorderStyleWidgetCreator implements FormEleme
* *
*/ */
public void firePropertyChange() { public void firePropertyChange() {
initStyle(); refreshStylePreviewEffect();
} }
/** /**

20
designer-form/src/main/java/com/fr/design/designer/creator/XLayoutContainer.java

@ -52,6 +52,8 @@ public abstract class XLayoutContainer extends XBorderStyleWidgetCreator impleme
private volatile boolean dragInAble; private volatile boolean dragInAble;
protected boolean isFixLayout = false;
public void setMouseEnter(boolean mouseEnter) { public void setMouseEnter(boolean mouseEnter) {
isMouseEnter = mouseEnter; isMouseEnter = mouseEnter;
} }
@ -61,6 +63,10 @@ public abstract class XLayoutContainer extends XBorderStyleWidgetCreator impleme
this.addContainerListener(this); this.addContainerListener(this);
} }
public void setFixLayout(boolean isFixLayout){
this.isFixLayout = isFixLayout;
}
/** /**
* 得到属性名 * 得到属性名
* *
@ -77,7 +83,7 @@ public abstract class XLayoutContainer extends XBorderStyleWidgetCreator impleme
@Override @Override
public void propertyChange() { public void propertyChange() {
initStyle(); refreshStylePreviewEffect();
} }
}), }),
new CRPropertyDescriptor("margin", this.data.getClass()).setEditorClass(PaddingMarginEditor.class) new CRPropertyDescriptor("margin", this.data.getClass()).setEditorClass(PaddingMarginEditor.class)
@ -120,7 +126,7 @@ public abstract class XLayoutContainer extends XBorderStyleWidgetCreator impleme
@Override @Override
protected void initXCreatorProperties() { protected void initXCreatorProperties() {
super.initXCreatorProperties(); super.initXCreatorProperties();
initBorderAndBackgroundStyle(); refreshBorderAndBackgroundStylePreviewEffect();
this.initLayoutManager(); this.initLayoutManager();
this.convert(); this.convert();
} }
@ -549,7 +555,7 @@ public abstract class XLayoutContainer extends XBorderStyleWidgetCreator impleme
* *
*/ */
public void firePropertyChange(){ public void firePropertyChange(){
initStyle(); refreshStylePreviewEffect();
} }
/** /**
@ -598,4 +604,12 @@ public abstract class XLayoutContainer extends XBorderStyleWidgetCreator impleme
editingMouseListener.refreshTopXCreator(editing); editingMouseListener.refreshTopXCreator(editing);
designer.repaint(); designer.repaint();
} }
public boolean supportFixLayout(){
return false;
}
public void replaceXcreator(XCreator newCreator, XCreator oldCreator){
}
} }

81
designer-form/src/main/java/com/fr/design/designer/creator/XOccupiedLayout.java

@ -0,0 +1,81 @@
package com.fr.design.designer.creator;
import com.fr.design.designer.beans.LayoutAdapter;
import com.fr.design.designer.beans.adapters.layout.FROccupiedLayoutAdapter;
import com.fr.design.designer.creator.operate.DefaultXCreatorBaseOperate;
import com.fr.design.designer.creator.operate.XCreatorBaseOperate;
import com.fr.design.form.layout.FRFitLayout;
import com.fr.design.form.util.XCreatorConstants;
import com.fr.form.ui.container.OccupiedLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Stroke;
public class XOccupiedLayout extends XLayoutContainer {
public XOccupiedLayout() {
this(new OccupiedLayout(), new Dimension());
}
public XOccupiedLayout(OccupiedLayout widget, Dimension initSize) {
super(widget, initSize);
initLayoutManager();
}
public String createDefaultName() {
return "box";
}
@Override
protected void initLayoutManager() {
this.setLayout(new FRFitLayout());
}
@Override
public LayoutAdapter getLayoutAdapter() {
return new FROccupiedLayoutAdapter(this);
}
public String getIconPath() {
return "/com/fr/design/form/images/occupied_layout.png";
}
@Override
public boolean isComponentTreeLeaf() {
//在控件树上表现为叶子节点(组件放置到占位块中的时候,会删除占位块,只展示组件)
return true;
}
public XCreatorBaseOperate getXCreatorBaseOperate() {
return new DefaultXCreatorBaseOperate() {
@Override
public boolean supportSelected() {
return false;
}
};
}
@Override
public void paint(Graphics g) {
drawOccupiedComponentBounds(g);
}
private void drawOccupiedComponentBounds(Graphics g) {
Graphics2D g2d = (Graphics2D) g;
Color color = g2d.getColor();
Stroke backup = g2d.getStroke();
// 设置线条的样式
g2d.setStroke(XCreatorConstants.DASH_STROKE);
g2d.setColor(XCreatorConstants.EMPTY_OCCUPIED_LAYOUT_COLOR);
g2d.drawRect(1, 1, this.getWidth() - 2, this.getHeight() - 2);
g2d.setStroke(backup);
g2d.setColor(color);
}
}

8
designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteBodyLayout.java

@ -78,7 +78,7 @@ public class XWAbsoluteBodyLayout extends XWAbsoluteLayout {
@Override @Override
public void propertyChange() { public void propertyChange() {
initStyle(); XWAbsoluteBodyLayout.this.refreshStylePreviewEffect();
} }
}) })
}; };
@ -105,8 +105,8 @@ public class XWAbsoluteBodyLayout extends XWAbsoluteLayout {
} }
@Override @Override
protected void initStyle() { public void refreshStylePreviewEffect() {
initBorderAndBackgroundStyle(); refreshBorderAndBackgroundStylePreviewEffect();
} }
/** /**
@ -114,7 +114,7 @@ public class XWAbsoluteBodyLayout extends XWAbsoluteLayout {
* *
*/ */
public void firePropertyChange(){ public void firePropertyChange(){
initStyle(); this.refreshStylePreviewEffect();
} }
@Override @Override

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

@ -305,7 +305,7 @@ public class XWAbsoluteLayout extends XLayoutContainer {
} }
@Override @Override
protected void initStyle() { public void refreshStylePreviewEffect() {
// do nothing // do nothing
} }

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

@ -2,6 +2,8 @@ package com.fr.design.designer.creator;
import com.fr.design.designer.beans.LayoutAdapter; import com.fr.design.designer.beans.LayoutAdapter;
import com.fr.design.designer.beans.adapters.layout.FRFitLayoutAdapter; import com.fr.design.designer.beans.adapters.layout.FRFitLayoutAdapter;
import com.fr.design.designer.beans.adapters.layout.FRFixLayoutAdapter;
import com.fr.design.designer.beans.adapters.layout.FRNoFixLayoutAdapter;
import com.fr.design.designer.beans.location.Direction; import com.fr.design.designer.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;
@ -80,7 +82,12 @@ public class XWFitLayout extends XLayoutContainer {
@Override @Override
public LayoutAdapter getLayoutAdapter() { public LayoutAdapter getLayoutAdapter() {
return new FRFitLayoutAdapter(this); FRFitLayoutAdapter layoutAdapter = new FRFitLayoutAdapter(this);
if (isFixLayout) {
layoutAdapter.setFrLayoutState(new FRFixLayoutAdapter(this));
}
return layoutAdapter;
} }
@Override @Override
@ -867,7 +874,22 @@ public class XWFitLayout extends XLayoutContainer {
BoundsWidget bw = (BoundsWidget) wlayout.getBoundsWidget(wgt); BoundsWidget bw = (BoundsWidget) wlayout.getBoundsWidget(wgt);
wlayout.removeWidget(bw); wlayout.removeWidget(bw);
updateBoundsWidget(); updateBoundsWidget();
((FRFitLayoutAdapter)getLayoutAdapter()).updateCreatorBackBound(); ((FRFitLayoutAdapter) getLayoutAdapter()).updateCreatorBackBound();
}
public void replaceXcreator(XCreator newCreator, XCreator oldCreator) {
WFitLayout wlayout = this.toData();
Widget wgt = oldCreator.toData();
BoundsWidget bw = (BoundsWidget) wlayout.getBoundsWidget(wgt);
wlayout.removeWidget(bw);
wlayout.addWidget(new BoundsWidget(newCreator.toData(), bw.getBounds()));
newCreator.setBackupParent(this);
isRefreshing = true;
this.remove(oldCreator);
this.add(newCreator);
this.updateBoundsWidget();
isRefreshing = false;
LayoutUtils.layoutContainer(this);
} }
/** /**
@ -1005,7 +1027,7 @@ public class XWFitLayout extends XLayoutContainer {
* @return 默认返回true * @return 默认返回true
*/ */
public boolean canAddInterval(int interval) { public boolean canAddInterval(int interval) {
int val = interval/2; int val = (interval - this.toData().getCompInterval())/2;
for (int i=0, len=this.getComponentCount(); i<len; i++) { for (int i=0, len=this.getComponentCount(); i<len; i++) {
XCreator comp = (XCreator) this.getComponent(i); XCreator comp = (XCreator) this.getComponent(i);
Rectangle rec = comp.getBounds(); Rectangle rec = comp.getBounds();
@ -1293,6 +1315,7 @@ public class XWFitLayout extends XLayoutContainer {
xfl.toData().setLayoutType(WBodyLayoutType.FIT); xfl.toData().setLayoutType(WBodyLayoutType.FIT);
FormDesigner formDesigner = WidgetPropertyPane.getInstance().getEditingFormDesigner(); FormDesigner formDesigner = WidgetPropertyPane.getInstance().getEditingFormDesigner();
formDesigner.getSelectionModel().setSelectedCreator(xfl); formDesigner.getSelectionModel().setSelectedCreator(xfl);
formDesigner.switchBodyLayout(this);
return true; return true;
} catch (Exception e) { } catch (Exception e) {
FRLogger.getLogger().error(e.getMessage()); FRLogger.getLogger().error(e.getMessage());
@ -1367,4 +1390,7 @@ public class XWFitLayout extends XLayoutContainer {
} }
} }
public boolean supportFixLayout(){
return true;
}
} }

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

@ -43,6 +43,16 @@ public class XWParameterLayout extends XWAbsoluteLayout {
super(widget, initSize); super(widget, initSize);
} }
@Override
public void refreshBorderAndBackgroundStylePreviewEffect() {
WParameterLayout data = toData();
if (data != null) {
Background background = data.getBackground();
setBackground4Painting(background, 1.0);
repaint();
}
}
/** /**
* 初始化尺寸 * 初始化尺寸
* @return 尺寸 * @return 尺寸
@ -235,7 +245,7 @@ public class XWParameterLayout extends XWAbsoluteLayout {
* *
*/ */
public void firePropertyChange(){ public void firePropertyChange(){
refreshBorderAndBackgroundStylePreviewEffect();
} }
@Override @Override

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

@ -63,7 +63,7 @@ public class XWTitleLayout extends DedicateLayoutContainer {
} }
@Override @Override
protected void initBorderAndBackgroundStyle() { public void refreshBorderAndBackgroundStylePreviewEffect() {
setBorder(null); setBorder(null);
setBorderImage4Painting(null, 0.0); setBorderImage4Painting(null, 0.0);
setBackground4Painting(null, 0.0); setBackground4Painting(null, 0.0);
@ -76,7 +76,7 @@ public class XWTitleLayout extends DedicateLayoutContainer {
// 初始化后(如打开旧模版),需要重新调整组件/标题/边框的显示效果 // 初始化后(如打开旧模版),需要重新调整组件/标题/边框的显示效果
XCreator xCreator = getBodyCreator(); XCreator xCreator = getBodyCreator();
if (xCreator instanceof XBorderStyleWidgetCreator) { if (xCreator instanceof XBorderStyleWidgetCreator) {
((XBorderStyleWidgetCreator) xCreator).initStyle(); ((XBorderStyleWidgetCreator) xCreator).refreshStylePreviewEffect();
} }
} }
@ -237,7 +237,7 @@ public class XWTitleLayout extends DedicateLayoutContainer {
} }
// 刷新时重置下样式 // 刷新时重置下样式
if (bodyCreator != null) { if (bodyCreator != null) {
bodyCreator.initStyle(); bodyCreator.refreshStylePreviewEffect();
} }
isRefreshing = false; isRefreshing = false;
} }

10
designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardLayout.java

@ -160,7 +160,7 @@ public class XWCardLayout extends XLayoutContainer {
*/ */
@Override @Override
protected XLayoutContainer getCreatorWrapper(String widgetName) { protected XLayoutContainer getCreatorWrapper(String widgetName) {
initStyle(); refreshStylePreviewEffect();
Dimension dimension = new Dimension(); Dimension dimension = new Dimension();
//主结构是一个borderlayout, 标签部分是north, card部分为center //主结构是一个borderlayout, 标签部分是north, card部分为center
WCardMainBorderLayout border = new WCardMainBorderLayout(); WCardMainBorderLayout border = new WCardMainBorderLayout();
@ -389,7 +389,7 @@ public class XWCardLayout extends XLayoutContainer {
@Override @Override
public void propertyChange() { public void propertyChange() {
initStyle(); refreshStylePreviewEffect();
} }
}) })
}; };
@ -397,10 +397,10 @@ public class XWCardLayout extends XLayoutContainer {
//初始化样式 //初始化样式
@Override @Override
protected void initStyle() { public void refreshStylePreviewEffect() {
BorderPacker style = toData().getBorderStyle(); BorderPacker style = toData().getBorderStyle();
initBorderTitleStyle(style); initBorderTitleStyle(style);
initBorderAndBackgroundStyle(); refreshBorderAndBackgroundStylePreviewEffect();
clearOrShowTitleLayout(ComparatorUtils.equals(style.getType(), LayoutBorderStyle.TITLE)); clearOrShowTitleLayout(ComparatorUtils.equals(style.getType(), LayoutBorderStyle.TITLE));
} }
@ -479,7 +479,7 @@ public class XWCardLayout extends XLayoutContainer {
*/ */
@Override @Override
public void firePropertyChange() { public void firePropertyChange() {
initStyle(); refreshStylePreviewEffect();
} }
public void resetTabBackground(TemplateStyle templateStyle) { public void resetTabBackground(TemplateStyle templateStyle) {

2
designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java

@ -405,7 +405,7 @@ public class XWCardMainBorderLayout extends XWBorderLayout {
public void firePropertyChange(){ public void firePropertyChange(){
XWCardLayout cardLayout = this.getCardPart(); XWCardLayout cardLayout = this.getCardPart();
if (cardLayout != null && cardLayout.toData() != null) { if (cardLayout != null && cardLayout.toData() != null) {
cardLayout.initStyle(); cardLayout.refreshStylePreviewEffect();
} }
} }

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

@ -639,4 +639,8 @@ public class XWTabFitLayout extends XWFitLayout {
public boolean isTopable() { public boolean isTopable() {
return true; return true;
} }
public boolean supportFixLayout(){
return false;
}
} }

29
designer-form/src/main/java/com/fr/design/designer/creator/operate/DefaultXCreatorBaseOperate.java

@ -0,0 +1,29 @@
package com.fr.design.designer.creator.operate;
public class DefaultXCreatorBaseOperate implements XCreatorBaseOperate {
@Override
public boolean supportSelected() {
return true;
}
@Override
public boolean supportCopyAction() {
return true;
}
@Override
public boolean supportCutAction() {
return true;
}
@Override
public boolean supportPasteAction() {
return true;
}
@Override
public boolean supportDeleteAction() {
return true;
}
}

15
designer-form/src/main/java/com/fr/design/designer/creator/operate/XCreatorBaseOperate.java

@ -0,0 +1,15 @@
package com.fr.design.designer.creator.operate;
import com.fr.design.designer.beans.adapters.layout.DesignerBaseOperate;
public interface XCreatorBaseOperate extends DesignerBaseOperate {
/**
* 是否支持选中
*
* @return boolean
*/
boolean supportSelected();
}

11
designer-form/src/main/java/com/fr/design/designer/treeview/ComponentTreeCellRenderer.java

@ -4,7 +4,6 @@ import com.fr.base.BaseUtils;
import com.fr.design.constants.UIConstants; import com.fr.design.constants.UIConstants;
import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XCreatorUtils; import com.fr.design.designer.creator.XCreatorUtils;
import com.fr.design.mainframe.share.util.ShareComponentUtils;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
@ -15,8 +14,7 @@ import java.awt.Component;
import java.awt.Graphics; import java.awt.Graphics;
public class ComponentTreeCellRenderer extends DefaultTreeCellRenderer { public class ComponentTreeCellRenderer extends DefaultTreeCellRenderer {
private boolean needAddShareIcon = false; private XCreatorTreeCellRender treeCellRender;
private static final Icon SHARE_ICON = BaseUtils.readIcon("/com/fr/design/images/toast/reuse_icon.png");
public ComponentTreeCellRenderer() { public ComponentTreeCellRenderer() {
} }
@ -36,9 +34,8 @@ public class ComponentTreeCellRenderer extends DefaultTreeCellRenderer {
} }
if (icon != null) { if (icon != null) {
setIcon(icon); setIcon(icon);
this.needAddShareIcon = ShareComponentUtils.isShareWidgetWithChild((XCreator) value);
} }
this.treeCellRender = ((XCreator) value).getComponentTreeCellRender();
} }
this.setBorder(BorderFactory.createEmptyBorder(1, 0, 1, 0)); this.setBorder(BorderFactory.createEmptyBorder(1, 0, 1, 0));
this.setBackgroundNonSelectionColor(UIConstants.TREE_BACKGROUND); this.setBackgroundNonSelectionColor(UIConstants.TREE_BACKGROUND);
@ -48,9 +45,7 @@ public class ComponentTreeCellRenderer extends DefaultTreeCellRenderer {
public void paint(Graphics g) { public void paint(Graphics g) {
super.paint(g); super.paint(g);
if (needAddShareIcon) { treeCellRender.paint(g, this);
SHARE_ICON.paintIcon(this, g, 10, 0);
}
} }
@Override @Override

29
designer-form/src/main/java/com/fr/design/designer/treeview/DefaultXCreatorTreeCellRender.java

@ -0,0 +1,29 @@
package com.fr.design.designer.treeview;
import com.fr.base.BaseUtils;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.mainframe.share.util.ShareComponentUtils;
import javax.swing.Icon;
import java.awt.Component;
import java.awt.Graphics;
public class DefaultXCreatorTreeCellRender implements XCreatorTreeCellRender {
private static final Icon SHARE_ICON = BaseUtils.readIcon("/com/fr/design/images/toast/reuse_icon.png");
private XCreator xCreator;
public DefaultXCreatorTreeCellRender(XCreator creator) {
this.xCreator = creator;
}
public XCreator getxCreator(){
return xCreator;
}
@Override
public void paint(Graphics g, Component c) {
if (ShareComponentUtils.isShareWidgetWithChild( xCreator)) {
SHARE_ICON.paintIcon(c, g, 10, 0);
}
}
}

8
designer-form/src/main/java/com/fr/design/designer/treeview/XCreatorTreeCellRender.java

@ -0,0 +1,8 @@
package com.fr.design.designer.treeview;
import java.awt.Component;
import java.awt.Graphics;
public interface XCreatorTreeCellRender {
void paint(Graphics g, Component c);
}

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

@ -53,6 +53,12 @@ public class NewJForm extends JForm {
changePaneSize(); changePaneSize();
} }
public NewJForm(Form form) {
super(form);
init();
changePaneSize();
}
public NewJForm(Form form, FILE file, Parameter[] parameters) { public NewJForm(Form form, FILE file, Parameter[] parameters) {
this(form, file); this(form, file);
} }

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

@ -1,114 +0,0 @@
package com.fr.design.fit.attrpane;
import com.fr.base.theme.FormTheme;
import com.fr.base.theme.TemplateTheme;
import com.fr.base.theme.settings.ThemedComponentStyle;
import com.fr.design.designer.IntervalConstants;
import com.fr.design.designer.creator.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.gui.style.FollowingThemePane;
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.main.Form;
import com.fr.form.ui.ElementCaseEditor;
import com.fr.form.ui.PaddingMargin;
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 final 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);
paddingBoundPane = new PaddingBoundPane();
themePane.addFollowThemePane(paddingBoundPane, new FollowingThemePane.FollowingThemeActionChangeListener() {
@Override
public void onFollowingTheme(boolean following) {
paddingBoundPane.setVisible(!following);
if (following) {
TemplateTheme theme = themePane.getUsingTheme();
if (theme instanceof FormTheme) {
ThemedComponentStyle style = ((FormTheme) theme).getComponentStyle();
int top = style.getPaddingTop();
int bottom = style.getPaddingBottom();
int left = style.getPaddingLeft();
int right = style.getPaddingRight();
paddingBoundPane.populateBean(new PaddingMargin(top, left, bottom, right));
}
}
}
});
}
protected JPanel createCenterPane() {
JPanel centerPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
elementCaseToolBarEditor = new AccessibleElementCaseToolBarEditor();
Component[][] components = new Component[][]{
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 (themePane.isFollowingTheme() || 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());
}
}

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

@ -1,200 +0,0 @@
package com.fr.design.fit.attrpane;
import com.fr.base.io.IOFile;
import com.fr.base.iofile.attr.WatermarkAttr;
import com.fr.base.theme.FormTheme;
import com.fr.base.theme.TemplateTheme;
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.gui.style.FollowingThemePane;
import com.fr.design.gui.xpane.LayoutStylePane;
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.design.mainframe.WidgetPropertyPane;
import com.fr.design.mainframe.widget.accessibles.AccessibleBodyWatermarkEditor;
import com.fr.design.utils.gui.UIComponentUtils;
import com.fr.design.widget.FRWidgetFactory;
import com.fr.design.widget.ui.designer.component.WidgetBoundPane;
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.general.act.BorderPacker;
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;
protected FollowingThemePane themePane;
private LayoutStylePane stylePane;
private AccessibleBodyWatermarkEditor watermarkEditor;
private UIComboBox layoutCombox;
private WBodyLayoutType layoutType = WBodyLayoutType.ABSOLUTE;
public FRAbsoluteBodyLayoutExtendDefinePane(XCreator xCreator) {
super(xCreator);
}
public void initComponent() {
initUIComboBox();
this.setLayout(FRGUIPaneFactory.createBorderLayout());
JPanel panel1 = FRGUIPaneFactory.createBorderLayout_S_Pane();
this.add(panel1, BorderLayout.CENTER);
UIExpandablePane scalePane = new UIExpandablePane(
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Area_Scaling"),
280, 20,
createAreaScalePane()
);
panel1.add(scalePane, BorderLayout.NORTH);
UIExpandablePane advancedPane = new UIExpandablePane(
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Advanced"),
280, 20,
this.createAdvancePane());
panel1.add(advancedPane, BorderLayout.CENTER);
}
public JPanel createAdvancePane() {
JPanel advancedContentPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
themePane = new FollowingThemePane(Toolkit.i18nText("Fine-Design_Form_Body_Style_Setting"));
stylePane = new LayoutStylePane();
themePane.addFollowThemePane(stylePane, new FollowingThemePane.FollowingThemeActionChangeListener() {
@Override
public void onFollowingTheme(boolean following) {
stylePane.supportBodyStyle(!following);
BorderPacker style = stylePane.updateBean();
if (following) {
TemplateTheme theme = themePane.getUsingTheme();
if (theme instanceof FormTheme) {
style = ((FormTheme) theme).getBodyStyle().merge(style);
}
}
stylePane.populateBean((LayoutBorderStyle) style);
}
});
advancedContentPane.add(themePane, BorderLayout.NORTH);
watermarkEditor = new AccessibleBodyWatermarkEditor();
JPanel watermarkPane = TableLayoutHelper.createGapTableLayoutPane(
new Component[][]{
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_WaterMark")), watermarkEditor}
}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W3, IntervalConstants.INTERVAL_L1);
watermarkPane.setBorder(BorderFactory.createEmptyBorder(IntervalConstants.INTERVAL_L1, 0, IntervalConstants.INTERVAL_L1, 0));
advancedContentPane.add(watermarkPane, BorderLayout.CENTER);
return advancedContentPane;
}
public JPanel createAreaScalePane() {
initLayoutComboBox();
UILabel layoutTypeLabel = FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Attr_Layout_Type"));
UILabel scaleModeLabel = FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Scaling_Mode"));
JPanel contentPane = TableLayoutHelper.createGapTableLayoutPane(
new Component[][]{
{layoutTypeLabel, layoutCombox},
{scaleModeLabel, comboBox}
},
TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W1, IntervalConstants.INTERVAL_L1);
contentPane.setBorder(BorderFactory.createEmptyBorder(IntervalConstants.INTERVAL_L1, 0, IntervalConstants.INTERVAL_L1, 0));
JPanel containerPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
containerPane.add(contentPane, BorderLayout.CENTER);
containerPane.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0));
return containerPane;
}
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);
themePane.supportFollowingTheme(ob.supportThemed());
themePane.setFollowingTheme(ob.isBorderStyleFollowingTheme());
stylePane.populateBean((LayoutBorderStyle) 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.setBorderStyleFollowingTheme(themePane.isFollowingTheme());
layout.setBorderStyle(stylePane.updateBean());
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

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

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

@ -1,282 +0,0 @@
package com.fr.design.fit.attrpane;
import com.fr.base.io.IOFile;
import com.fr.base.iofile.attr.WatermarkAttr;
import com.fr.base.theme.FormTheme;
import com.fr.base.theme.TemplateTheme;
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.gui.style.FollowingThemePane;
import com.fr.design.gui.xpane.LayoutStylePane;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
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.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.general.act.BorderPacker;
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 FollowingThemePane themePane;
private LayoutStylePane 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());
UIExpandablePane layoutExpandablePane = new UIExpandablePane(
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Layout"),
280, 20,
createLayoutPane()
);
this.add(layoutExpandablePane, BorderLayout.NORTH);
JPanel advancePane = createAdvancePane();
UIExpandablePane advanceExpandablePane = new UIExpandablePane(
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Advanced"),
280, 20,
advancePane
);
this.add(advanceExpandablePane, BorderLayout.CENTER);
}
public JPanel createAdvancePane() {
JPanel contentPane0 = FRGUIPaneFactory.createBorderLayout_S_Pane();
themePane = new FollowingThemePane(Toolkit.i18nText("Fine-Design_Form_Body_Style_Setting"));
stylePane = new LayoutStylePane();
themePane.addFollowThemePane(stylePane, new FollowingThemePane.FollowingThemeActionChangeListener() {
@Override
public void onFollowingTheme(boolean following) {
stylePane.supportBodyStyle(!following);
BorderPacker style = stylePane.updateBean();
if (following) {
TemplateTheme theme = themePane.getUsingTheme();
if (theme instanceof FormTheme) {
style = ((FormTheme) theme).getBodyStyle().merge(style);
}
}
stylePane.populateBean((LayoutBorderStyle) style);
}
});
contentPane0.add(themePane, BorderLayout.NORTH);
JPanel contentPane1 = FRGUIPaneFactory.createBorderLayout_S_Pane();
contentPane0.add(contentPane1, BorderLayout.CENTER);
watermarkEditor = new AccessibleBodyWatermarkEditor();
JPanel waterMarkPane = TableLayoutHelper.createGapTableLayoutPane(
new Component[][]{
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_WaterMark")), watermarkEditor}
}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W3, IntervalConstants.INTERVAL_L1);
waterMarkPane.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0));
contentPane1.add(waterMarkPane, BorderLayout.NORTH);
paddingBound = new PaddingBoundPane();
contentPane1.add(paddingBound, BorderLayout.CENTER);
return contentPane0;
}
public JPanel createLayoutPane() {
JPanel containerPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
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"));
JPanel contentPane = TableLayoutHelper.createGapTableLayoutPane(
new Component[][]{
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Attr_Layout_Type")), layoutComboBox},
{intervalLabel, componentIntervelPane}
},
TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W1, IntervalConstants.INTERVAL_L1);
contentPane.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0));
containerPane.add(contentPane, BorderLayout.CENTER);
return containerPane;
}
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());
themePane.supportFollowingTheme(ob.supportThemed());
themePane.setFollowingTheme(ob.isBorderStyleFollowingTheme());
stylePane.populateBean((LayoutBorderStyle) 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);
}
layout.setBorderStyleFollowingTheme(themePane.isFollowingTheme());
LayoutBorderStyle borderStyle = stylePane.updateBean();
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;
}
}

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

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

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

@ -3,39 +3,24 @@ package com.fr.design.fit.common;
import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.DesignTableDataManager;
import com.fr.design.fit.DesignerUIModeConfig; import com.fr.design.fit.DesignerUIModeConfig;
import com.fr.design.fit.NewJForm; 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.DesignerContext;
import com.fr.design.mainframe.JForm; import com.fr.design.mainframe.JForm;
import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.JTemplate;
import com.fr.design.parameter.RootDesignDefinePane;
import com.fr.design.preview.FormAdaptivePreview; import com.fr.design.preview.FormAdaptivePreview;
import com.fr.design.preview.FormPreview; 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.FILE;
import com.fr.file.MemFILE; import com.fr.file.MemFILE;
import com.fr.form.main.Form; import com.fr.form.main.Form;
import com.fr.form.main.WidgetGather; import com.fr.form.main.WidgetGather;
import com.fr.form.ui.ElementCaseEditor;
import com.fr.form.ui.Widget; import com.fr.form.ui.Widget;
import com.fr.form.ui.container.WAbsoluteBodyLayout; import com.fr.form.ui.container.WAbsoluteBodyLayout;
import com.fr.form.ui.container.WAbsoluteLayout; import com.fr.form.ui.container.WAbsoluteLayout;
import com.fr.form.ui.container.WFitLayout; import com.fr.form.ui.container.WFitLayout;
import com.fr.form.ui.container.WParameterLayout;
import com.fr.form.ui.widget.CRBoundsWidget; import com.fr.form.ui.widget.CRBoundsWidget;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.report.fit.ReportFitAttr; import com.fr.report.fit.ReportFitAttr;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
import java.util.Set;
/** /**
* Created by kerry on 2020-06-02 * Created by kerry on 2020-06-02
@ -55,16 +40,6 @@ public class AdaptiveSwitchUtil {
public static void switch2NewUIMode() { public static void switch2NewUIMode() {
DesignerUIModeConfig.getInstance().setNewUIMode(); 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() { public static void switch2OldUI() {
@ -74,16 +49,6 @@ public class AdaptiveSwitchUtil {
public static void switch2OldUIMode() { public static void switch2OldUIMode() {
DesignerUIModeConfig.getInstance().setOldUIMode(); 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() { public static void reload() {

19
designer-form/src/main/java/com/fr/design/form/util/XCreatorConstants.java

@ -3,10 +3,14 @@
*/ */
package com.fr.design.form.util; package com.fr.design.form.util;
import com.fr.base.GraphHelper;
import com.fr.stable.Constants;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.border.Border; import javax.swing.border.Border;
import java.awt.BasicStroke; import java.awt.BasicStroke;
import java.awt.Color; import java.awt.Color;
import java.awt.Stroke;
/** /**
* @author richer * @author richer
@ -52,4 +56,19 @@ public class XCreatorConstants {
// 不同粗细的线 // 不同粗细的线
public static final BasicStroke STROKE = new BasicStroke(2); public static final BasicStroke STROKE = new BasicStroke(2);
public static final Stroke DASH_STROKE = GraphHelper.getStroke(Constants.LINE_MEDIUM_DASH);
//空占位块
public static final Color EMPTY_OCCUPIED_LAYOUT_COLOR = new Color(217, 218, 221);
//添加组件/未释放
public static final Color DRAG_IN_OCCUPIED_LAYOUT_COLOR = new Color(65, 155, 249);
//固定布局中从占位块中拖出
public static final Color DRAG_OUT_OCCUPIED_LAYOUT_COLOR = new Color(155, 172, 245);
//从占位块中替换
public static final Color REPLACE_OCCUPIED_LAYOUT_COLOR = new Color(247, 181, 0);
} }

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

@ -14,7 +14,6 @@ import com.fr.design.gui.itree.UITreeUI;
import com.fr.design.utils.ComponentUtils; import com.fr.design.utils.ComponentUtils;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import java.awt.Rectangle; import java.awt.Rectangle;
import java.util.Stack; import java.util.Stack;
import java.util.function.Consumer; import java.util.function.Consumer;
@ -96,6 +95,10 @@ public class ComponentTree extends JTree {
public void setSelectionPath(TreePath path) { public void setSelectionPath(TreePath path) {
// 不管点击哪一项,都要先退出编辑状态(图表、报表块、绝对布局、tab块) // 不管点击哪一项,都要先退出编辑状态(图表、报表块、绝对布局、tab块)
Object widget = path.getLastPathComponent();
if(widget == null ||!((XCreator)widget).getXCreatorBaseOperate().supportSelected()){
return;
}
designer.stopEditing(path); designer.stopEditing(path);
super.setSelectionPath(path); super.setSelectionPath(path);
} }
@ -359,7 +362,6 @@ public class ComponentTree extends JTree {
@Override @Override
public void mouseMoved(MouseEvent e) { public void mouseMoved(MouseEvent e) {
Point p = e.getPoint(); Point p = e.getPoint();
int selRow = tree.getRowForLocation(p.x, p.y); int selRow = tree.getRowForLocation(p.x, p.y);
TreeCellRenderer r = tree.getCellRenderer(); TreeCellRenderer r = tree.getCellRenderer();
@ -368,11 +370,13 @@ public class ComponentTree extends JTree {
Point point = tree.getPathBounds(path).getLocation(); Point point = tree.getPathBounds(path).getLocation();
SwingUtilities.convertPointToScreen(point, tree); SwingUtilities.convertPointToScreen(point, tree);
XCreator comp = (XCreator) path.getLastPathComponent(); XCreator comp = (XCreator) path.getLastPathComponent();
if (comp.getXCreatorBaseOperate().supportSelected()) {
popupPreviewPane(point.y, comp); popupPreviewPane(point.y, comp);
} else { return;
hidePreviewPane();
} }
} }
hidePreviewPane();
}
@Override @Override
public void mouseExited(MouseEvent e) { public void mouseExited(MouseEvent e) {
@ -384,7 +388,8 @@ public class ComponentTree extends JTree {
onMouseEvent(e, new Consumer<XCreator>() { onMouseEvent(e, new Consumer<XCreator>() {
@Override @Override
public void accept(XCreator creator) { public void accept(XCreator creator) {
if (e.getClickCount() == 2 && e.getButton() == MouseEvent.BUTTON1 && !designer.isFormParaDesigner()) { if (e.getClickCount() == 2 && e.getButton() == MouseEvent.BUTTON1 && !designer.isFormParaDesigner()
&&creator.getXCreatorBaseOperate().supportSelected()) {
startEditing(creator); startEditing(creator);
} }
} }
@ -397,7 +402,7 @@ public class ComponentTree extends JTree {
onMouseEvent(e, new Consumer<XCreator>() { onMouseEvent(e, new Consumer<XCreator>() {
@Override @Override
public void accept(XCreator creator) { public void accept(XCreator creator) {
if (e.getButton() == MouseEvent.BUTTON1) { if (e.getButton() == MouseEvent.BUTTON1 && creator.getXCreatorBaseOperate().supportSelected()) {
selectedCreator = creator; selectedCreator = creator;
} }
} }

31
designer-form/src/main/java/com/fr/design/mainframe/DesignerScaleMouseWheelHandler.java

@ -0,0 +1,31 @@
package com.fr.design.mainframe;
import java.awt.event.MouseWheelEvent;
import java.awt.event.MouseWheelListener;
/**
* @author Starryi
* @version 1.0
* Created by Starryi on 2021/9/23
*/
public class DesignerScaleMouseWheelHandler implements MouseWheelListener {
private final ScalePane scalePane;
private final int step;
public DesignerScaleMouseWheelHandler(ScalePane scalePane, int step) {
this.scalePane = scalePane;
this.step = step;
}
@Override
public void mouseWheelMoved(MouseWheelEvent e) {
int dir = e.getWheelRotation();
JFormSliderPane slidePane = this.scalePane.getSlidePane();
int old_resolution = slidePane.getShowValue();
slidePane.setShowValue(old_resolution - (dir * step));
}
public interface ScalePane {
JFormSliderPane getSlidePane();
}
}

279
designer-form/src/main/java/com/fr/design/mainframe/DesignerTranslateMouseWheelHandler.java

@ -0,0 +1,279 @@
package com.fr.design.mainframe;
import javax.swing.JScrollBar;
import javax.swing.JViewport;
import javax.swing.Scrollable;
import javax.swing.SwingConstants;
import java.awt.Component;
import java.awt.Rectangle;
import java.awt.event.MouseWheelEvent;
import java.awt.event.MouseWheelListener;
/**
* 实现设计器面板的触摸板滚动移动交互 https://work.fineres.com/browse/REPORT-55989
*
* mouseWheelMoved 的具体实现来自
* @link {javax.swing.plaf.basic.BasicScrollPaneUI.Handler#mouseWheelMoved}
* scrollByUnits 的具体实现来自
* @link {javax.swing.plaf.basic.BasicScrollPaneUI#scrollByUnits}
* scrollByBlock 的具体实现来自
* @link {javax.swing.plaf.basic.BasicScrollPaneUI#scrollByBlock}
*/
public class DesignerTranslateMouseWheelHandler implements MouseWheelListener {
private final ScrollPane scrollpane;
public DesignerTranslateMouseWheelHandler(ScrollPane scrollpane) {
this.scrollpane = scrollpane;
}
@Override
public void mouseWheelMoved(MouseWheelEvent e) {
if (scrollpane.isWheelScrollingEnabled() &&
e.getWheelRotation() != 0) {
JScrollBar toScroll = scrollpane.getVerticalScrollBar();
int direction = e.getWheelRotation() < 0 ? -1 : 1;
int orientation = SwingConstants.VERTICAL;
// find which scrollbar to scroll, or return if none
if (toScroll == null || !toScroll.isVisible()
|| e.isShiftDown()) {
toScroll = scrollpane.getHorizontalScrollBar();
if (toScroll == null || !toScroll.isVisible()) {
return;
}
orientation = SwingConstants.HORIZONTAL;
}
e.consume();
if (e.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL) {
JViewport vp = scrollpane.getViewport();
if (vp == null) { return; }
Component comp = vp.getView();
int units = Math.abs(e.getUnitsToScroll());
// When the scrolling speed is set to maximum, it's possible
// for a single wheel click to scroll by more units than
// will fit in the visible area. This makes it
// hard/impossible to get to certain parts of the scrolling
// Component with the wheel. To make for more accurate
// low-speed scrolling, we limit scrolling to the block
// increment if the wheel was only rotated one click.
boolean limitScroll = Math.abs(e.getWheelRotation()) == 1;
// Check if we should use the visibleRect trick
Object fastWheelScroll = toScroll.getClientProperty(
"JScrollBar.fastWheelScrolling");
if (Boolean.TRUE == fastWheelScroll &&
comp instanceof Scrollable) {
// 5078454: Under maximum acceleration, we may scroll
// by many 100s of units in ~1 second.
//
// BasicScrollBarUI.scrollByUnits() can bog down the EDT
// with repaints in this situation. However, the
// Scrollable interface allows us to pass in an
// arbitrary visibleRect. This allows us to accurately
// calculate the total scroll amount, and then update
// the GUI once. This technique provides much faster
// accelerated wheel scrolling.
Scrollable scrollComp = (Scrollable) comp;
Rectangle viewRect = vp.getViewRect();
int startingX = viewRect.x;
boolean leftToRight =
comp.getComponentOrientation().isLeftToRight();
int scrollMin = toScroll.getMinimum();
int scrollMax = toScroll.getMaximum() -
toScroll.getModel().getExtent();
if (limitScroll) {
int blockIncr =
scrollComp.getScrollableBlockIncrement(viewRect,
orientation,
direction);
if (direction < 0) {
scrollMin = Math.max(scrollMin,
toScroll.getValue() - blockIncr);
}
else {
scrollMax = Math.min(scrollMax,
toScroll.getValue() + blockIncr);
}
}
for (int i = 0; i < units; i++) {
int unitIncr =
scrollComp.getScrollableUnitIncrement(viewRect,
orientation, direction);
// Modify the visible rect for the next unit, and
// check to see if we're at the end already.
if (orientation == SwingConstants.VERTICAL) {
if (direction < 0) {
viewRect.y -= unitIncr;
if (viewRect.y <= scrollMin) {
viewRect.y = scrollMin;
break;
}
}
else { // (direction > 0
viewRect.y += unitIncr;
if (viewRect.y >= scrollMax) {
viewRect.y = scrollMax;
break;
}
}
}
else {
// Scroll left
if ((leftToRight && direction < 0) ||
(!leftToRight && direction > 0)) {
viewRect.x -= unitIncr;
if (leftToRight) {
if (viewRect.x < scrollMin) {
viewRect.x = scrollMin;
break;
}
}
}
// Scroll right
else if ((leftToRight && direction > 0) ||
(!leftToRight && direction < 0)) {
viewRect.x += unitIncr;
if (leftToRight) {
if (viewRect.x > scrollMax) {
viewRect.x = scrollMax;
break;
}
}
}
else {
assert false : "Non-sensical ComponentOrientation / scroll direction";
}
}
}
// Set the final view position on the ScrollBar
if (orientation == SwingConstants.VERTICAL) {
toScroll.setValue(viewRect.y);
}
else {
if (leftToRight) {
toScroll.setValue(viewRect.x);
}
else {
// rightToLeft scrollbars are oriented with
// minValue on the right and maxValue on the
// left.
int newPos = toScroll.getValue() -
(viewRect.x - startingX);
if (newPos < scrollMin) {
newPos = scrollMin;
}
else if (newPos > scrollMax) {
newPos = scrollMax;
}
toScroll.setValue(newPos);
}
}
}
else {
// Viewport's view is not a Scrollable, or fast wheel
// scrolling is not enabled.
scrollByUnits(toScroll, direction,
units, limitScroll);
}
}
else if (e.getScrollType() ==
MouseWheelEvent.WHEEL_BLOCK_SCROLL) {
scrollByBlock(toScroll, direction);
}
}
}
/*
* Method for scrolling by a unit increment.
* Added for mouse wheel scrolling support, RFE 4202656.
*
* If limitByBlock is set to true, the scrollbar will scroll at least 1
* unit increment, but will not scroll farther than the block increment.
* See BasicScrollPaneUI.Handler.mouseWheelMoved().
*/
static void scrollByUnits(JScrollBar scrollbar, int direction,
int units, boolean limitToBlock) {
// This method is called from BasicScrollPaneUI to implement wheel
// scrolling, as well as from scrollByUnit().
int delta;
int limit = -1;
if (limitToBlock) {
if (direction < 0) {
limit = scrollbar.getValue() -
scrollbar.getBlockIncrement(direction);
}
else {
limit = scrollbar.getValue() +
scrollbar.getBlockIncrement(direction);
}
}
for (int i=0; i<units; i++) {
if (direction > 0) {
delta = scrollbar.getUnitIncrement(direction);
}
else {
delta = -scrollbar.getUnitIncrement(direction);
}
int oldValue = scrollbar.getValue();
int newValue = oldValue + delta;
// Check for overflow.
if (delta > 0 && newValue < oldValue) {
newValue = scrollbar.getMaximum();
}
else if (delta < 0 && newValue > oldValue) {
newValue = scrollbar.getMinimum();
}
if (oldValue == newValue) {
break;
}
if (limitToBlock && i > 0) {
assert limit != -1;
if ((direction < 0 && newValue < limit) ||
(direction > 0 && newValue > limit)) {
break;
}
}
scrollbar.setValue(newValue);
}
}
/*
* Method for scrolling by a block increment.
* Added for mouse wheel scrolling support, RFE 4202656.
*/
static void scrollByBlock(JScrollBar scrollbar, int direction) {
// This method is called from BasicScrollPaneUI to implement wheel
// scrolling, and also from scrollByBlock().
int oldValue = scrollbar.getValue();
int blockIncrement = scrollbar.getBlockIncrement(direction);
int delta = blockIncrement * ((direction > 0) ? +1 : -1);
int newValue = oldValue + delta;
// Check for overflow.
if (delta > 0 && newValue < oldValue) {
newValue = scrollbar.getMaximum();
}
else if (delta < 0 && newValue > oldValue) {
newValue = scrollbar.getMinimum();
}
scrollbar.setValue(newValue);
}
public interface ScrollPane {
boolean isWheelScrollingEnabled();
JScrollBar getVerticalScrollBar();
JScrollBar getHorizontalScrollBar();
JViewport getViewport();
}
}

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

@ -636,7 +636,7 @@ public class EditingMouseListener extends MouseInputAdapter {
XCreator oldCreator = creator; XCreator oldCreator = creator;
creator = processTopLayoutMouseClick(creator); creator = processTopLayoutMouseClick(creator);
if (creator != null) { if (creator != null && creator.getXCreatorBaseOperate().supportSelected()) {
// tab块处于未编辑状态 // tab块处于未编辑状态
boolean uneditedTab = designer.getCursor().getType() != Cursor.HAND_CURSOR && creator.acceptType(XWCardMainBorderLayout.class) && !((XWCardMainBorderLayout) creator).isEditable(); boolean uneditedTab = designer.getCursor().getType() != Cursor.HAND_CURSOR && creator.acceptType(XWCardMainBorderLayout.class) && !((XWCardMainBorderLayout) creator).isEditable();
// 点击不在tab块的button中 // 点击不在tab块的button中

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

@ -1,12 +1,21 @@
package com.fr.design.mainframe; package com.fr.design.mainframe;
import com.fr.common.inputevent.InputEventBaseOnOS; import com.fr.common.inputevent.InputEventBaseOnOS;
import com.fr.design.actions.UpdateAction;
import com.fr.design.constants.UIConstants;
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.fit.DesignerUIModeConfig; import com.fr.design.fit.DesignerUIModeConfig;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ibutton.UIButtonUI;
import com.fr.design.gui.imenu.UIPopupMenu;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.share.ui.base.PopupMenuItem;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.design.utils.gui.GUIPaintUtils;
import com.fr.form.fit.NewFormMarkAttr; 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;
@ -20,15 +29,20 @@ import com.fr.design.scrollruler.VerticalRuler;
import com.fr.design.utils.ComponentUtils; import com.fr.design.utils.ComponentUtils;
import com.fr.design.utils.gui.LayoutUtils; import com.fr.design.utils.gui.LayoutUtils;
import com.fr.form.main.mobile.FormMobileAttr; import com.fr.form.main.mobile.FormMobileAttr;
import com.fr.form.ui.container.WBodyLayoutType;
import com.fr.form.ui.container.WBorderLayout; import com.fr.form.ui.container.WBorderLayout;
import com.fr.general.FRScreen; import com.fr.form.ui.container.WFitLayout;
import com.fr.general.IOUtils;
import com.fr.stable.AssistUtils; import com.fr.stable.AssistUtils;
import javax.swing.AbstractAction; import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.BorderFactory;
import javax.swing.JComponent; import javax.swing.JComponent;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.KeyStroke; import javax.swing.KeyStroke;
import javax.swing.SwingConstants;
import javax.swing.border.LineBorder; import javax.swing.border.LineBorder;
import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener; import javax.swing.event.ChangeListener;
@ -38,6 +52,8 @@ import java.awt.Color;
import java.awt.Component; import java.awt.Component;
import java.awt.Container; import java.awt.Container;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Insets; import java.awt.Insets;
import java.awt.Point; import java.awt.Point;
import java.awt.Rectangle; import java.awt.Rectangle;
@ -60,8 +76,8 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
private static final String SCALE_MINUS_COMMAND = "scale_minus"; private static final String SCALE_MINUS_COMMAND = "scale_minus";
public static final double DEFAULT_SLIDER = 100.0; public static final double DEFAULT_SLIDER = 100.0;
private static final int ROTATIONS = 50; private static final int ROTATIONS = 50;
private static final int SHOWVALMAX = 400; public static final int SHOWVALMAX = 400;
private static final int SHOWVALMIN = 10; public static final int SHOWVALMIN = 10;
private static final int RESIZE_PANE_GAP = 8; private static final int RESIZE_PANE_GAP = 8;
private static final int MOBILE_ONLY_WIDTH = 375; private static final int MOBILE_ONLY_WIDTH = 375;
private static final int MOBILE_ONLY_HEIGHT = 560; private static final int MOBILE_ONLY_HEIGHT = 560;
@ -80,6 +96,8 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
// 初始时滑块值为100,托动后的值设为START_VALUE; // 初始时滑块值为100,托动后的值设为START_VALUE;
private double START_VALUE = DEFAULT_SLIDER; private double START_VALUE = DEFAULT_SLIDER;
private double screenValue; private double screenValue;
private UIButton fixLayoutSwitchButton;
private boolean isFixLayoutEditState;
public FormScrollBar getHorScrollBar() { public FormScrollBar getHorScrollBar() {
@ -116,10 +134,24 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
addFormRuler(); addFormRuler();
} }
this.setFocusTraversalKeysEnabled(false); this.setFocusTraversalKeysEnabled(false);
this.designer.addMouseWheelListener(showValSpinnerMouseWheelListener);
this.designer.addMouseWheelListener(new FormAreaMouseWheelHandler(this));
registerShortCutKey(); registerShortCutKey();
} }
public FormScrollBar getVerticalScrollBar() {
return verScrollBar;
}
public FormScrollBar getHorizontalScrollBar() {
return horScrollBar;
}
public JFormSliderPane getSlidePane() {
return slidePane;
}
/** /**
* 注册缩放快捷键 * 注册缩放快捷键
* mac: command + command - * mac: command + command -
@ -153,16 +185,42 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
widthPane.setEnabled(!formMobileAttr.isMobileOnly()); widthPane.setEnabled(!formMobileAttr.isMobileOnly());
} }
MouseWheelListener showValSpinnerMouseWheelListener = new MouseWheelListener() { private UIButton createFixLayoutSwitchButton(){
UIButton button = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Layout_No_Fix_Layout"));
button.setIcon(IOUtils.readIcon("/com/fr/base/images/share/filter_combo.png"));
button.setUI(new UIButtonUI(){
@Override @Override
public void mouseWheelMoved(MouseWheelEvent e) { protected void paintBorder(Graphics g, UIButton b) {
if (InputEventBaseOnOS.isControlDown(e)) {
int dir = e.getWheelRotation();
int old_resolution = slidePane.getShowValue();
slidePane.setShowValue(old_resolution - (dir * SHOWVALMIN));
} }
protected void doExtraPainting(UIButton b, Graphics2D g2d, int w, int h, String selectedRoles) {
if (isPressed(b) && b.isPressedPainted()) {
GUIPaintUtils.fillPressed(g2d, 0, 0, w, h, b.isRoundBorder(), b.getRectDirection(), b.isDoneAuthorityEdited(selectedRoles));
} else if (isRollOver(b)) {
GUIPaintUtils.fillRollOver(g2d, 0, 0, w, h, b.isRoundBorder(), b.getRectDirection(), b.isDoneAuthorityEdited(selectedRoles), b.isPressedPainted());
}
}
});
button.setHorizontalTextPosition(SwingConstants.LEFT);
button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
UIPopupMenu popupMenu = new UIPopupMenu();
popupMenu.setPreferredSize(new Dimension(180, 59));
popupMenu.setOnlyText(true);
popupMenu.setBackground(UIConstants.DEFAULT_BG_RULER);
popupMenu.add(new PopupMenuItem(new Switch2NoFixLayoutAction()));
popupMenu.add(new PopupMenuItem(new Switch2FixLayoutAction()));
GUICoreUtils.showPopupMenu(popupMenu, fixLayoutSwitchButton, 0, -59);
}
});
button.setVisible(!isAbsoluteBodyLayout());
return button;
}
private boolean isAbsoluteBodyLayout() {
return ((WFitLayout) designer.getRootComponent().toData()).getBodyLayoutType() == WBodyLayoutType.ABSOLUTE;
} }
};
@ -175,6 +233,11 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
double[] rowSize = {f}; double[] rowSize = {f};
double[] columnSize = {p, f, p, p, p, p, p, f, p}; double[] columnSize = {p, f, p, p, p, p, p, f, p};
UILabel tipsPane = new UILabel("form"); UILabel tipsPane = new UILabel("form");
fixLayoutSwitchButton = createFixLayoutSwitchButton();
JPanel layoutSwitchPane = FRGUIPaneFactory.createLeftFlowZeroGapBorderPane();
layoutSwitchPane.setBorder(BorderFactory.createEmptyBorder(0, 12, 0, 0));
layoutSwitchPane.add(fixLayoutSwitchButton);
widthPane = new UINumberField(); widthPane = new UINumberField();
widthPane.setPreferredSize(new Dimension(60, 0)); widthPane.setPreferredSize(new Dimension(60, 0));
heightPane = new UINumberField(); heightPane = new UINumberField();
@ -183,7 +246,7 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
slidePane = JFormSliderPane.getInstance(); slidePane = JFormSliderPane.getInstance();
JPanel resizePane = TableLayoutHelper.createCommonTableLayoutPane( JPanel resizePane = TableLayoutHelper.createCommonTableLayoutPane(
new JComponent[][]{{tipsPane, new UILabel(), widthPane, new JComponent[][]{{tipsPane, layoutSwitchPane, widthPane,
new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Indent_Pixel")), new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Indent_Pixel")),
new UILabel("x"), heightPane, new UILabel("x"), heightPane,
new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Indent_Pixel")), new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Indent_Pixel")),
@ -198,6 +261,25 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
slidePane.addValueChangeListener(showValSpinnerChangeListener); slidePane.addValueChangeListener(showValSpinnerChangeListener);
} }
public void undoFixLayoutState(boolean isFixLayout) {
getFormEditor().getRootComponent().setFixLayout(isFixLayout);
this.switchLayout(isFixLayout);
}
public void switchBodyLayout(XLayoutContainer xLayoutContainer) {
this.fixLayoutSwitchButton.setVisible(xLayoutContainer.supportFixLayout());
this.switchLayout(false);
}
private void switchLayout(boolean isFixLayout) {
this.isFixLayoutEditState = isFixLayout;
this.fixLayoutSwitchButton.setText(isFixLayout ? com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Layout_Fix_Layout") :
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Layout_No_Fix_Layout"));
FormMobileAttr formMobileAttr = designer.getTarget().getFormMobileAttr();
widthPane.setEnabled(!isFixLayout && !formMobileAttr.isMobileOnly());
heightPane.setEnabled(!isFixLayout);
}
private void setWidgetsConfig() { private void setWidgetsConfig() {
widthPane.setHorizontalAlignment(widthPane.CENTER); widthPane.setHorizontalAlignment(widthPane.CENTER);
@ -281,8 +363,7 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
if(object instanceof XCreator){ if(object instanceof XCreator){
updateCreatorsBackupBound((XCreator) object); updateCreatorsBackupBound((XCreator) object);
} }
} } }
}
//设置宽度的控件及响应事件 //设置宽度的控件及响应事件
@ -899,4 +980,43 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
} }
public boolean isFixLayout(){
return this.isFixLayoutEditState;
}
class Switch2NoFixLayoutAction extends UpdateAction{
public Switch2NoFixLayoutAction(){
this.putValue(Action.SMALL_ICON, null);
this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Layout_No_Fix_Layout"));
this.setSmallIcon("/com/fr/design/form/images/no_fix_layout_icon.png");
}
@Override
public void actionPerformed(ActionEvent e) {
getFormEditor().getRootComponent().setFixLayout(false);
switchLayout(false);
designer.getEditListenerTable().fireCreatorModified(DesignerEvent.CREATOR_EDITED);
DesignerContext.getDesignerFrame().refresh();
}
}
class Switch2FixLayoutAction extends UpdateAction{
public Switch2FixLayoutAction(){
this.putValue(Action.SMALL_ICON, null);
this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Layout_Fix_Layout"));
this.setSmallIcon("/com/fr/design/form/images/fix_layout_icon.png");
}
@Override
public void actionPerformed(ActionEvent e) {
getFormEditor().getRootComponent().setFixLayout(true);
switchLayout(true);
designer.getEditListenerTable().fireCreatorModified(DesignerEvent.CREATOR_EDITED);
DesignerContext.getDesignerFrame().refresh();
}
}
} }

75
designer-form/src/main/java/com/fr/design/mainframe/FormAreaMouseWheelHandler.java

@ -0,0 +1,75 @@
package com.fr.design.mainframe;
import com.fr.common.inputevent.InputEventBaseOnOS;
import javax.swing.JScrollBar;
import javax.swing.JViewport;
import java.awt.event.MouseWheelEvent;
import java.awt.event.MouseWheelListener;
/**
* @author Starryi
* @version 1.0
* Created by Starryi on 2021/9/24
*/
public class FormAreaMouseWheelHandler implements MouseWheelListener {
private final DesignerTranslateMouseWheelHandler translateMouseWheelHandler;
private final DesignerScaleMouseWheelHandler scaleMouseWheelHandler;
public FormAreaMouseWheelHandler(FormArea formArea) {
translateMouseWheelHandler = new DesignerTranslateMouseWheelHandler(new FormAreaScrollPaneAdapter(formArea));
scaleMouseWheelHandler = new DesignerScaleMouseWheelHandler(new FormAreaScalePaneAdapter(formArea), FormArea.SHOWVALMIN);
}
@Override
public void mouseWheelMoved(MouseWheelEvent e) {
if (InputEventBaseOnOS.isControlDown(e)) {
scaleMouseWheelHandler.mouseWheelMoved(e);
} else {
translateMouseWheelHandler.mouseWheelMoved(e);
}
}
private static class FormAreaScalePaneAdapter implements DesignerScaleMouseWheelHandler.ScalePane {
private final FormArea formArea;
public FormAreaScalePaneAdapter(FormArea formArea) {
this.formArea = formArea;
}
@Override
public JFormSliderPane getSlidePane() {
return formArea.getSlidePane();
}
}
private static class FormAreaScrollPaneAdapter implements DesignerTranslateMouseWheelHandler.ScrollPane {
private final FormArea formArea;
private final JViewport viewport;
public FormAreaScrollPaneAdapter(FormArea formArea) {
this.formArea = formArea;
this.viewport = new JViewport();
}
@Override
public boolean isWheelScrollingEnabled() {
return true;
}
@Override
public JScrollBar getVerticalScrollBar() {
return formArea.getVerticalScrollBar();
}
@Override
public JScrollBar getHorizontalScrollBar() {
return formArea.getHorizontalScrollBar();
}
@Override
public JViewport getViewport() {
return this.viewport;
}
}
}

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

@ -288,6 +288,7 @@ public class FormCreatorDropTarget extends DropTarget {
int y = designer.getRelativeY(loc.y); int y = designer.getRelativeY(loc.y);
hovering(x, y); hovering(x, y);
tabDragInner.canDragIn(designer.getComponentAt(x, y), x, y); tabDragInner.canDragIn(designer.getComponentAt(x, y), x, y);
designer.draggingComponent(x, y);
} }
/** /**

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

@ -1,10 +1,6 @@
package com.fr.design.mainframe; package com.fr.design.mainframe;
import com.fr.base.Parameter; import com.fr.base.Parameter;
import com.fr.base.ScreenResolution;
import com.fr.base.theme.FormTheme;
import com.fr.base.theme.TemplateTheme;
import com.fr.base.theme.TemplateThemeCompatible;
import com.fr.base.vcs.DesignerMode; import com.fr.base.vcs.DesignerMode;
import com.fr.design.DesignModelAdapter; import com.fr.design.DesignModelAdapter;
import com.fr.design.DesignState; import com.fr.design.DesignState;
@ -22,7 +18,9 @@ import com.fr.design.designer.beans.actions.MoveToBottomAction;
import com.fr.design.designer.beans.actions.MoveToTopAction; import com.fr.design.designer.beans.actions.MoveToTopAction;
import com.fr.design.designer.beans.actions.MoveUpAction; import com.fr.design.designer.beans.actions.MoveUpAction;
import com.fr.design.designer.beans.actions.PasteAction; import com.fr.design.designer.beans.actions.PasteAction;
import com.fr.design.designer.beans.adapters.layout.DefaultDesignerBaseOperate;
import com.fr.design.designer.beans.adapters.layout.FRParameterLayoutAdapter; import com.fr.design.designer.beans.adapters.layout.FRParameterLayoutAdapter;
import com.fr.design.designer.beans.adapters.layout.DesignerBaseOperate;
import com.fr.design.designer.beans.events.CreatorEventListenerTable; import com.fr.design.designer.beans.events.CreatorEventListenerTable;
import com.fr.design.designer.beans.events.DesignerEditListener; import com.fr.design.designer.beans.events.DesignerEditListener;
import com.fr.design.designer.beans.events.DesignerEvent; import com.fr.design.designer.beans.events.DesignerEvent;
@ -44,7 +42,6 @@ import com.fr.design.designer.creator.cardlayout.XWCardMainBorderLayout;
import com.fr.design.designer.properties.FormWidgetAuthorityEditPane; 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.HistoryTemplateListCache;
import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.fit.DesignerUIModeConfig; import com.fr.design.fit.DesignerUIModeConfig;
import com.fr.design.form.util.XCreatorConstants; import com.fr.design.form.util.XCreatorConstants;
@ -61,9 +58,7 @@ import com.fr.design.utils.gui.LayoutUtils;
import com.fr.form.FormElementCaseContainerProvider; import com.fr.form.FormElementCaseContainerProvider;
import com.fr.form.FormElementCaseProvider; import com.fr.form.FormElementCaseProvider;
import com.fr.form.main.Form; import com.fr.form.main.Form;
import com.fr.form.main.WidgetGather;
import com.fr.form.parameter.FormSubmitButton; import com.fr.form.parameter.FormSubmitButton;
import com.fr.form.ui.AbstractBorderStyleWidget;
import com.fr.form.ui.EditorHolder; import com.fr.form.ui.EditorHolder;
import com.fr.form.ui.PaddingMargin; import com.fr.form.ui.PaddingMargin;
import com.fr.form.ui.Widget; import com.fr.form.ui.Widget;
@ -160,6 +155,7 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
// 编辑状态的事件表 // 编辑状态的事件表
private CreatorEventListenerTable edit; private CreatorEventListenerTable edit;
protected List<UpdateAction> designerActions; protected List<UpdateAction> designerActions;
protected List<UpdateAction> basicActions;
private FormDesignerModeForSpecial<?> desigerMode; private FormDesignerModeForSpecial<?> desigerMode;
private Action switchAction; private Action switchAction;
private FormElementCaseContainerProvider elementCaseContainer; private FormElementCaseContainerProvider elementCaseContainer;
@ -227,7 +223,7 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
public Parameter[] getNoRepeatParas(Parameter[] paras) { public Parameter[] getNoRepeatParas(Parameter[] paras) {
List<Parameter> paraList = new ArrayList<Parameter>(); List<Parameter> paraList = new ArrayList<Parameter>();
java.util.Set set = new java.util.HashSet(); Set set = new java.util.HashSet();
for (Parameter p : paras) { for (Parameter p : paras) {
if (!set.contains(p.getName().toLowerCase())) { if (!set.contains(p.getName().toLowerCase())) {
paraList.add(p); paraList.add(p);
@ -252,7 +248,7 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
public void refreshParameter() { public void refreshParameter() {
XLayoutContainer rootContainer = this.getParaComponent(); XLayoutContainer rootContainer = this.getParaComponent();
if (rootContainer != null) { if (rootContainer != null) {
java.util.List<String> namelist = new ArrayList<String>(); List<String> namelist = new ArrayList<String>();
rootContainer.getAllXCreatorNameList(rootContainer, namelist); rootContainer.getAllXCreatorNameList(rootContainer, namelist);
// parameterArray是报表的所有参数, nameList是已经在参数面板添加过控件的参数名 // parameterArray是报表的所有参数, nameList是已经在参数面板添加过控件的参数名
// 与已有的参数列表比较 如果已经存在 就除去 // 与已有的参数列表比较 如果已经存在 就除去
@ -1214,20 +1210,28 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
public void startDraggingComponent(XCreator xCreator, MouseEvent lastPressEvent, int x, int y) { public void startDraggingComponent(XCreator xCreator, MouseEvent lastPressEvent, int x, int y) {
// 根据所选择的组件的BeanInfo生成相应的AddingModel // 根据所选择的组件的BeanInfo生成相应的AddingModel
// AddingModel和StateModel不一样,适合当前选择的组件相关的 // AddingModel和StateModel不一样,适合当前选择的组件相关的
int creatorWidth = xCreator.getWidth();
int creatorHeight = xCreator.getHeight();
this.addingModel = new AddingModel(xCreator, x, y); this.addingModel = new AddingModel(xCreator, x, y);
TransferHandler handler = new DesignerTransferHandler(this, addingModel); TransferHandler handler = new DesignerTransferHandler(this, addingModel);
setTransferHandler(handler); setTransferHandler(handler);
handler.exportAsDrag(this, lastPressEvent, TransferHandler.COPY); handler.exportAsDrag(this, lastPressEvent, TransferHandler.COPY);
XCreator parent = XCreatorUtils.getParentXLayoutContainer(xCreator); XLayoutContainer parent = XCreatorUtils.getParentXLayoutContainer(xCreator);
selectionModel.removeCreator(xCreator, creatorWidth, creatorHeight); parent.getLayoutAdapter().dragStart(xCreator, selectionModel);
selectionModel.setSelectedCreator(parent);
this.setDropTarget(new FormCreatorDropTarget(this)); this.setDropTarget(new FormCreatorDropTarget(this));
// 触发状态添加模式事件 // 触发状态添加模式事件
repaint(); repaint();
} }
public void draggingComponent(int x, int y){
XCreator xCreator = this.addingModel.getXCreator();
XLayoutContainer parent = XCreatorUtils.getParentXLayoutContainer(xCreator);
if (parent!= null && parent.getLayoutAdapter()!=null){
parent.getLayoutAdapter().dragOver(xCreator, selectionModel, x, y);
}
// 触发状态添加模式事件
repaint();
}
/** /**
* 改变组件值 * 改变组件值
* *
@ -1313,9 +1317,6 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
protected void setToolbarButtons() { protected void setToolbarButtons() {
//自适应布局和底层都不能删除
DesignerContext.getDesignerFrame().checkCombineUp(!isRootSelected(), NAME_ARRAY_LIST);
if (isParameterSelected()) { if (isParameterSelected()) {
DesignerContext.getDesignerFrame().checkCombineUp(false, PARAMETER_TOOLAR_BAN_LIST); DesignerContext.getDesignerFrame().checkCombineUp(false, PARAMETER_TOOLAR_BAN_LIST);
} }
@ -1378,14 +1379,37 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
*/ */
public UpdateAction[] getActions() { public UpdateAction[] getActions() {
if (designerActions == null) { if (designerActions == null) {
designerActions = new ArrayList<UpdateAction>(Arrays.asList(new UpdateAction[]{new CutAction(this), new CopyAction(this), new PasteAction(this), designerActions = new ArrayList<UpdateAction>(getBasicActions());
new FormDeleteAction(this), new MoveToTopAction(this), new MoveToBottomAction(this), designerActions.add(new MoveToTopAction(this));
new MoveUpAction(this), new MoveDownAction(this)})); designerActions.add(new MoveToBottomAction(this));
designerActions.add(new MoveUpAction(this));
designerActions.add(new MoveDownAction(this));
dmlActions(designerActions); dmlActions(designerActions);
} }
return designerActions.toArray(new UpdateAction[designerActions.size()]); return designerActions.toArray(new UpdateAction[designerActions.size()]);
} }
private List<UpdateAction> getBasicActions(){
if (basicActions == null) {
basicActions = new ArrayList<UpdateAction>();
basicActions.add(new CutAction(this));
basicActions.add(new CopyAction(this));
basicActions.add(new PasteAction(this));
basicActions.add(new FormDeleteAction(this));
}
return basicActions;
}
public JComponent[] getBasicActionComponent() {
List<UpdateAction> actions = getBasicActions();
int size = actions.size();
JComponent[] jComponents = new JComponent[size];
for (int i = 0; i < size; i++) {
jComponents[i] = actions.get(i).createToolBarComponentByName("Global_Toolbar");
}
return jComponents;
}
/** /**
* 扩展菜单项 * 扩展菜单项
* *
@ -1404,16 +1428,34 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
} }
} }
private DesignerBaseOperate getLayoutBaseOperate(){
FormSelection selection = this.getSelectionModel().getSelection();
XCreator creator = selection.getSelectedCreator();
XLayoutContainer container = (XLayoutContainer) creator.getParent();
if (container == null) {
return new DefaultDesignerBaseOperate();
}
return container.getLayoutAdapter().getDesignerBaseOperate();
}
public boolean isCurrentComponentCutable() { public boolean isCurrentComponentCutable() {
return !(isRootSelected() || isParameterSelected()); DesignerBaseOperate designerBaseOperate = getLayoutBaseOperate();
return !(isRootSelected() || isParameterSelected()) && designerBaseOperate.supportCutAction();
} }
public boolean isCurrentComponentCopyable() { public boolean isCurrentComponentCopyable() {
return !(isRootSelected() || isParameterSelected()); DesignerBaseOperate designerBaseOperate = getLayoutBaseOperate();
return !(isRootSelected() || isParameterSelected()) && designerBaseOperate.supportCopyAction();
} }
public boolean isCurrentComponentDeletable() { public boolean isCurrentComponentDeletable() {
return !isRootSelected(); DesignerBaseOperate designerBaseOperate = getLayoutBaseOperate();
return !isRootSelected() && designerBaseOperate.supportDeleteAction();
}
public boolean isCurrentComponentPastable() {
DesignerBaseOperate designerBaseOperate = getLayoutBaseOperate();
return designerBaseOperate.supportPasteAction();
} }
// 当前选中控件可以上移一层吗? // 当前选中控件可以上移一层吗?
@ -1469,6 +1511,10 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
return formArea; return formArea;
} }
public void switchBodyLayout(XLayoutContainer xLayoutContainer){
formArea.switchBodyLayout(xLayoutContainer);
}
/** /**
* 设置上层区域 * 设置上层区域
* *

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

@ -210,10 +210,10 @@ public class FormDesignerUI extends ComponentUI {
} }
XCreator bean = addingModel.getXCreator(); XCreator bean = addingModel.getXCreator();
int x = addingModel.getCurrentX(); int x = addingModel.getCurrentX();
int y = addingModel.getCurrentY(); int y = addingModel.getCurrentY() ;
int width = bean.getWidth(); int width = bean.initEditorSize().width;
int height = bean.getHeight(); int height = bean.initEditorSize().height;
Graphics clipg = g.create(x, y, width, height); Graphics clipg = g.create(x, y, width, height);
ArrayList<JComponent> dbcomponents = new ArrayList<JComponent>(); ArrayList<JComponent> dbcomponents = new ArrayList<JComponent>();
// 禁止双缓冲行为 // 禁止双缓冲行为

10
designer-form/src/main/java/com/fr/design/mainframe/FormUndoState.java

@ -14,6 +14,7 @@ public class FormUndoState extends BaseUndoState<BaseJForm> {
private double widthValue; private double widthValue;
private double heightValue; private double heightValue;
private double slideValue; private double slideValue;
private boolean isFixLayout;
public FormUndoState(BaseJForm t, FormArea formArea) { public FormUndoState(BaseJForm t, FormArea formArea) {
super(t); super(t);
@ -31,6 +32,7 @@ public class FormUndoState extends BaseUndoState<BaseJForm> {
this.widthValue = formArea.getWidthPaneValue(); this.widthValue = formArea.getWidthPaneValue();
this.heightValue = formArea.getHeightPaneValue(); this.heightValue = formArea.getHeightPaneValue();
this.slideValue = formArea.getSlideValue(); this.slideValue = formArea.getSlideValue();
this.isFixLayout = formArea.isFixLayout();
} }
/** /**
@ -89,6 +91,14 @@ public class FormUndoState extends BaseUndoState<BaseJForm> {
return this.slideValue; return this.slideValue;
} }
/**
* 返回是否处于固定布局编辑状态下
* @return
*/
public boolean isFixLayout(){
return isFixLayout;
}
@Override @Override
public void applyState() { public void applyState() {
this.getApplyTarget().applyUndoState4Form(this); this.getApplyTarget().applyUndoState4Form(this);

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

@ -6,12 +6,13 @@ import com.fr.base.Parameter;
import com.fr.base.Releasable; import com.fr.base.Releasable;
import com.fr.base.extension.FileExtension; import com.fr.base.extension.FileExtension;
import com.fr.base.iofile.attr.ExtendSharableAttrMark; import com.fr.base.iofile.attr.ExtendSharableAttrMark;
import com.fr.base.theme.TemplateThemeCompatible; import com.fr.base.iofile.attr.TemplateLayoutIdAttrMark;
import com.fr.base.vcs.DesignerMode;
import com.fr.base.theme.FormTheme; import com.fr.base.theme.FormTheme;
import com.fr.base.theme.FormThemeConfig; import com.fr.base.theme.FormThemeConfig;
import com.fr.base.theme.TemplateTheme; import com.fr.base.theme.TemplateTheme;
import com.fr.base.theme.TemplateThemeCompatible;
import com.fr.base.theme.TemplateThemeConfig; import com.fr.base.theme.TemplateThemeConfig;
import com.fr.base.vcs.DesignerMode;
import com.fr.design.DesignModelAdapter; import com.fr.design.DesignModelAdapter;
import com.fr.design.DesignState; import com.fr.design.DesignState;
import com.fr.design.ExtraDesignClassManager; import com.fr.design.ExtraDesignClassManager;
@ -23,10 +24,6 @@ import com.fr.design.base.mode.DesignModeContext;
import com.fr.design.cell.FloatElementsProvider; import com.fr.design.cell.FloatElementsProvider;
import com.fr.design.data.datapane.TableDataTreePane; import com.fr.design.data.datapane.TableDataTreePane;
import com.fr.design.designer.TargetComponent; import com.fr.design.designer.TargetComponent;
import com.fr.design.designer.beans.actions.CopyAction;
import com.fr.design.designer.beans.actions.CutAction;
import com.fr.design.designer.beans.actions.FormDeleteAction;
import com.fr.design.designer.beans.actions.PasteAction;
import com.fr.design.designer.beans.events.DesignerEditListener; 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.XComponent; import com.fr.design.designer.creator.XComponent;
@ -120,6 +117,7 @@ import java.util.List;
public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm<Form>, Releasable { public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm<Form>, Releasable {
private static final String FORM_CARD = "FORM"; private static final String FORM_CARD = "FORM";
private static final String ELEMENTCASE_CARD = "ELEMENTCASE"; private static final String ELEMENTCASE_CARD = "ELEMENTCASE";
private static final String EMPTY_FORM_LAYOUTID = "9ebf6aff-ad53-45a9-a175-9633f4162a3a";
private static final String[] CARDNAME = new String[]{FORM_CARD, ELEMENTCASE_CARD}; private static final String[] CARDNAME = new String[]{FORM_CARD, ELEMENTCASE_CARD};
private static final int TOOLBARPANEDIMHEIGHT_FORM = 60; private static final int TOOLBARPANEDIMHEIGHT_FORM = 60;
@ -141,6 +139,11 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm<F
public JForm() { public JForm() {
super(new Form(new WBorderLayout("form")), "Form"); super(new Form(new WBorderLayout("form")), "Form");
initEmptyFormLayoutId();
}
public JForm(Form form) {
super(form, "Form");
} }
public JForm(Form form, FILE file, Parameter[] parameters) { public JForm(Form form, FILE file, Parameter[] parameters) {
@ -151,6 +154,12 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm<F
super(form, file); super(form, file);
} }
private void initEmptyFormLayoutId() {
Form form = this.getTarget();
form.addAttrMark(new TemplateLayoutIdAttrMark(EMPTY_FORM_LAYOUTID));
form.setLayoutId(EMPTY_FORM_LAYOUTID);
}
@Override @Override
protected void addPane(PropertyItemPaneProvider provider) { protected void addPane(PropertyItemPaneProvider provider) {
@ -672,6 +681,7 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm<F
this.setTarget(undoForm); this.setTarget(undoForm);
JForm.this.refreshRoot(); JForm.this.refreshRoot();
this.formDesign.getArea().setAreaSize(u.getAreaSize(), u.getHorizontalValue(), u.getVerticalValue(), u.getWidthValue(), u.getHeightValue(), u.getSlideValue()); this.formDesign.getArea().setAreaSize(u.getAreaSize(), u.getHorizontalValue(), u.getVerticalValue(), u.getWidthValue(), u.getHeightValue(), u.getSlideValue());
formDesign.getArea().undoFixLayoutState(u.isFixLayout());
//撤销的时候要重新选择的body布局 //撤销的时候要重新选择的body布局
this.formDesign.getSelectionModel().setSelectedCreators(FormSelectionUtils.rebuildSelection(formDesign.getRootComponent(), this.formDesign.getSelectionModel().setSelectedCreators(FormSelectionUtils.rebuildSelection(formDesign.getRootComponent(),
formDesign.getRootComponent() == selectedBodyLayout() ? u.getSelectWidgets() : new Widget[]{selectedBodyLayout().toData()})); formDesign.getRootComponent() == selectedBodyLayout() ? u.getSelectWidgets() : new Widget[]{selectedBodyLayout().toData()}));
@ -749,11 +759,7 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm<F
*/ */
public JComponent[] toolBarButton4Form() { public JComponent[] toolBarButton4Form() {
return this.index == FORM_TAB ? return this.index == FORM_TAB ?
new JComponent[]{ formDesign.getBasicActionComponent():
new CutAction(formDesign).createToolBarComponent(),
new CopyAction(formDesign).createToolBarComponent(),
new PasteAction(formDesign).createToolBarComponent(),
new FormDeleteAction(formDesign).createToolBarComponent()} :
elementCaseDesign.toolBarButton4Form(); elementCaseDesign.toolBarButton4Form();
} }
@ -1205,6 +1211,7 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm<F
formDesign.refreshRoot(); formDesign.refreshRoot();
// 刷新界面后恢复原来的尺寸 // 刷新界面后恢复原来的尺寸
formDesign.getArea().setAreaSize(areaSize, horizontalValue, verticalValue, widthValue, heightValue, slideValue); formDesign.getArea().setAreaSize(areaSize, horizontalValue, verticalValue, widthValue, heightValue, slideValue);
formDesign.getArea().undoFixLayoutState(formArea.isFixLayout());
if (this.index != FORM_TAB) { if (this.index != FORM_TAB) {
refreshToolArea(); refreshToolArea();
} else { } else {

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

@ -99,7 +99,7 @@ public class ToolBarButton extends UIButton implements MouseListener, MouseMotio
creatorSource = no.getNameOption().createWidget(); creatorSource = no.getNameOption().createWidget();
} }
if (creatorSource != null) { if (creatorSource != null) {
XCreator xCreator = XCreatorUtils.createXCreator(creatorSource); XCreator xCreator = XCreatorUtils.createThemedXCreator(creatorSource);
WidgetToolBarPane.getTarget().startDraggingBean(xCreator); WidgetToolBarPane.getTarget().startDraggingBean(xCreator);
FormDesignerUtils.addWidgetProcessInfo(xCreator.toData()); FormDesignerUtils.addWidgetProcessInfo(xCreator.toData());
lastPressEvent = null; lastPressEvent = null;

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

@ -58,6 +58,9 @@ public class TopXCreator extends JComponent {
@Override @Override
public void paint(Graphics g) { public void paint(Graphics g) {
super.paint(g); super.paint(g);
if (creator == null || creator.getParent() == null){
return;
}
ArrayList<JComponent> dbcomponents = new ArrayList<JComponent>(); ArrayList<JComponent> dbcomponents = new ArrayList<JComponent>();
// 禁止双缓冲 // 禁止双缓冲
ComponentUtils.disableBuffer(creator, dbcomponents); ComponentUtils.disableBuffer(creator, dbcomponents);

7
designer-form/src/main/java/com/fr/design/mainframe/share/action/CreateComponentAction.java

@ -251,7 +251,10 @@ public class CreateComponentAction extends UpdateAction {
private Image componentToImage(Component comp, Rectangle rect) { private Image componentToImage(Component comp, Rectangle rect) {
BufferedImage im = new BufferedImage((int) rect.getWidth(), (int) rect.getHeight(), BufferedImage.TYPE_INT_RGB); BufferedImage im = new BufferedImage((int) rect.getWidth(), (int) rect.getHeight(), BufferedImage.TYPE_INT_ARGB);
Graphics2D g2d = (Graphics2D)im.getGraphics();
g2d.setColor(Color.WHITE);
g2d.fillRect(0, 0 , rect.width, rect.height);
comp.paint(im.getGraphics()); comp.paint(im.getGraphics());
return im; return im;
} }
@ -260,7 +263,7 @@ public class CreateComponentAction extends UpdateAction {
private Image moduleToImage(Form form, ElementCaseEditor editor, Map<String, Object> parameterMap, Rectangle rect) { private Image moduleToImage(Form form, ElementCaseEditor editor, Map<String, Object> parameterMap, Rectangle rect) {
if (editor == null) { if (editor == null) {
return new BufferedImage((int) rect.getWidth(), (int) rect.getHeight(), BufferedImage.TYPE_INT_RGB); return new BufferedImage((int) rect.getWidth(), (int) rect.getHeight(), BufferedImage.TYPE_INT_ARGB);
} }
FormElementCaseProvider provider = editor.getElementCase(); FormElementCaseProvider provider = editor.getElementCase();
provider.setName(editor.getWidgetName()); provider.setName(editor.getWidgetName());

2
designer-form/src/main/java/com/fr/design/mainframe/share/util/ShareComponentUtils.java

@ -61,7 +61,7 @@ public class ShareComponentUtils {
boolean isCurrentUsingThemeSuitSharedComponent = StringUtils.isNotEmpty(theme.getName()) && boolean isCurrentUsingThemeSuitSharedComponent = StringUtils.isNotEmpty(theme.getName()) &&
StringUtils.isNotEmpty(suitableTemplateThemeName) && StringUtils.isNotEmpty(suitableTemplateThemeName) &&
StringUtils.equals(theme.getName(), suitableTemplateThemeName); StringUtils.equals(theme.getName(), suitableTemplateThemeName);
XCreatorUtils.setupTemplateTheme(creator, (FormTheme) theme, isCurrentUsingThemeSuitSharedComponent ? TemplateThemeCompatible.NONE : TemplateThemeCompatible.ABSENT); XCreatorUtils.setupTemplateTheme(creator, false, (FormTheme) theme, isCurrentUsingThemeSuitSharedComponent ? TemplateThemeCompatible.NONE : TemplateThemeCompatible.ABSENT);
} }
return creator; return creator;
} }

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

@ -10,6 +10,8 @@ import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XWParameterLayout; import com.fr.design.designer.creator.XWParameterLayout;
import com.fr.design.designer.properties.PropertyTab; import com.fr.design.designer.properties.PropertyTab;
import com.fr.design.file.HistoryTemplateListPane; 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.foldablepane.UIExpandablePane;
import com.fr.design.fun.ParameterExpandablePaneUIProvider; import com.fr.design.fun.ParameterExpandablePaneUIProvider;
import com.fr.design.gui.ibutton.UIButtonGroup; import com.fr.design.gui.ibutton.UIButtonGroup;
@ -20,8 +22,11 @@ import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper; 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.JTemplate;
import com.fr.design.mainframe.widget.accessibles.AccessibleBackgroundEditor; 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.utils.gui.UIComponentUtils;
import com.fr.design.widget.ui.designer.AbstractDataModify; import com.fr.design.widget.ui.designer.AbstractDataModify;
import com.fr.design.widget.ui.designer.component.UIBoundSpinner; import com.fr.design.widget.ui.designer.component.UIBoundSpinner;
@ -35,6 +40,7 @@ import javax.swing.Icon;
import javax.swing.JPanel; import javax.swing.JPanel;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Component; import java.awt.Component;
import java.awt.Rectangle;
import java.util.Set; import java.util.Set;
/** /**
@ -43,18 +49,19 @@ import java.util.Set;
public class RootDesignDefinePane extends AbstractDataModify<WParameterLayout> { public class RootDesignDefinePane extends AbstractDataModify<WParameterLayout> {
private XWParameterLayout root; private XWParameterLayout root;
private UISpinner designerWidth; private UISpinner designerWidth;
private UISpinner paraHeight;
private UICheckBox displayReport; private UICheckBox displayReport;
private UICheckBox useParamsTemplate; private UICheckBox useParamsTemplate;
private AccessibleBackgroundEditor background; private AccessibleBackgroundEditor background;
private UIButtonGroup hAlignmentPane; private UIButtonGroup hAlignmentPane;
private UITextField labelNameTextField; private UITextField labelNameTextField;
/** //是否是新设计模式下决策报表
* 插件带来的额外属性 private boolean newForm;
*/
private PropertyGroupPane extraPropertyGroupPane; private PropertyGroupPane extraPropertyGroupPane;
public RootDesignDefinePane(XCreator xCreator) { public RootDesignDefinePane(XCreator xCreator) {
super(xCreator); super(xCreator);
newForm = TemplateTool.getCurrentEditingNewJForm() != null && DesignerUIModeConfig.getInstance().newUIMode();
this.root = (XWParameterLayout) xCreator; this.root = (XWParameterLayout) xCreator;
initComponent(); initComponent();
} }
@ -62,7 +69,11 @@ public class RootDesignDefinePane extends AbstractDataModify<WParameterLayout> {
public void initComponent() { public void initComponent() {
this.setLayout(FRGUIPaneFactory.createBorderLayout()); this.setLayout(FRGUIPaneFactory.createBorderLayout());
if (newForm) {
paraHeight = new UIBoundSpinner(0, Integer.MAX_VALUE, 1, 0);
} else {
designerWidth = new UIBoundSpinner(1, Integer.MAX_VALUE, 1); designerWidth = new UIBoundSpinner(1, Integer.MAX_VALUE, 1);
}
JPanel advancePane = createAdvancePane(); JPanel advancePane = createAdvancePane();
UIExpandablePane advanceExpandablePane = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Advanced"), 280, 20, advancePane); UIExpandablePane advanceExpandablePane = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Advanced"), 280, 20, advancePane);
this.add(advanceExpandablePane, BorderLayout.NORTH); this.add(advanceExpandablePane, BorderLayout.NORTH);
@ -70,7 +81,6 @@ public class RootDesignDefinePane extends AbstractDataModify<WParameterLayout> {
UIExpandablePane layoutExpandablePane = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Size"), 280, 20, layoutPane); UIExpandablePane layoutExpandablePane = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Size"), 280, 20, layoutPane);
this.add(layoutExpandablePane, BorderLayout.CENTER); this.add(layoutExpandablePane, BorderLayout.CENTER);
this.addExtraUIExpandablePaneFromPlugin(); this.addExtraUIExpandablePaneFromPlugin();
} }
private void addExtraUIExpandablePaneFromPlugin() { private void addExtraUIExpandablePaneFromPlugin() {
@ -92,9 +102,9 @@ public class RootDesignDefinePane extends AbstractDataModify<WParameterLayout> {
double[] rowSize = {p}; double[] rowSize = {p};
double[] columnSize = {p, f}; double[] columnSize = {p, f};
int[][] rowCount = {{1, 1}}; int[][] rowCount = {{1, 1}};
Component[][] components = new Component[][]{ 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}, 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 panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, IntervalConstants.INTERVAL_W1, IntervalConstants.INTERVAL_L1);
JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane();
panel.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0)); panel.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0));
@ -103,6 +113,21 @@ public class RootDesignDefinePane extends AbstractDataModify<WParameterLayout> {
} }
public JPanel createAdvancePane() { 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(); JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane();
labelNameTextField = new UITextField(); labelNameTextField = new UITextField();
displayReport = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Display_Nothing_Before_Query")); displayReport = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Display_Nothing_Before_Query"));
@ -139,6 +164,40 @@ public class RootDesignDefinePane extends AbstractDataModify<WParameterLayout> {
return jPanel; 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 @Override
public String title4PopupWindow() { public String title4PopupWindow() {
return "parameter"; return "parameter";
@ -150,6 +209,10 @@ public class RootDesignDefinePane extends AbstractDataModify<WParameterLayout> {
background.setValue(ob.getBackground()); background.setValue(ob.getBackground());
displayReport.setSelected(ob.isDelayDisplayContent()); displayReport.setSelected(ob.isDelayDisplayContent());
useParamsTemplate.setSelected(ob.isUseParamsTemplate()); useParamsTemplate.setSelected(ob.isUseParamsTemplate());
if (newForm) {
FormDesigner designer = TemplateTool.getCurrentEditingNewJForm().getFormDesign();
paraHeight.setValue(designer.getParaHeight());
} else {
designerWidth.setValue(ob.getDesignWidth()); designerWidth.setValue(ob.getDesignWidth());
hAlignmentPane.setSelectedItem(ob.getPosition()); hAlignmentPane.setSelectedItem(ob.getPosition());
@ -157,10 +220,26 @@ public class RootDesignDefinePane extends AbstractDataModify<WParameterLayout> {
extraPropertyGroupPane.populate(ob); extraPropertyGroupPane.populate(ob);
} }
} }
}
@Override @Override
public WParameterLayout updateBean() { 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 wParameterLayout = (WParameterLayout) creator.toData();
wParameterLayout.setLabelName(labelNameTextField.getText()); wParameterLayout.setLabelName(labelNameTextField.getText());
if (isCompsOutOfDesignerWidth((int) designerWidth.getValue())) { if (isCompsOutOfDesignerWidth((int) designerWidth.getValue())) {
@ -173,22 +252,56 @@ public class RootDesignDefinePane extends AbstractDataModify<WParameterLayout> {
JTemplate jTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); JTemplate jTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate();
jTemplate.needAddTemplateIdAttr(useParamsTemplate.isSelected()); jTemplate.needAddTemplateIdAttr(useParamsTemplate.isSelected());
wParameterLayout.setBackground((Background) background.getValue()); wParameterLayout.setBackground((Background) background.getValue());
wParameterLayout.setPosition((int) hAlignmentPane.getSelectedItem()); wParameterLayout.setPosition((Integer) hAlignmentPane.getSelectedItem());
return wParameterLayout; return wParameterLayout;
} }
private boolean isCompsOutOfDesignerWidth(int designerWidth){ /**
for(int i=0; i<root.getComponentCount(); i++){ * @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); Component comp = root.getComponent(i);
if(comp.getX() + comp.getWidth() > designerWidth){ if (comp.getX() + comp.getWidth() > designerWidth) {
return true; return true;
} }
} }
return false; return false;
} }
@Override @Override
public DataCreatorUI dataUI() { public DataCreatorUI dataUI() {
return null; return null;
} }
} }

36
designer-form/src/main/java/com/fr/design/widget/ui/designer/EmptyLayoutPane.java

@ -0,0 +1,36 @@
package com.fr.design.widget.ui.designer;
import com.fr.base.svg.IconUtils;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
import com.fr.stable.StringUtils;
import javax.swing.BorderFactory;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
public class EmptyLayoutPane extends PredefinedLayoutPane {
public EmptyLayoutPane() {
this.setLayout(new BorderLayout());
this.setPreferredSize(new Dimension(234, 1));
this.setBackground(Color.WHITE);
UILabel newFormIcon = new UILabel(IconUtils.readIcon("/com/fr/design/form/images/new_form.png"));
newFormIcon.setBorder(BorderFactory.createCompoundBorder(
BorderFactory.createEmptyBorder(39, 105, 0, 105),
BorderFactory.createDashedBorder(Color.BLACK, 1.0f, 2.0f, 2.0f, true)
));
UILabel label = new UILabel(Toolkit.i18nText("Fine-Design_New_Empty_Template"));
label.setBorder(BorderFactory.createEmptyBorder(0, 78, 30, 0));
this.add(newFormIcon, BorderLayout.NORTH);
this.add(label, BorderLayout.CENTER);
this.initListener();
}
@Override
public String getTemplatePath() {
return StringUtils.EMPTY;
}
}

291
designer-form/src/main/java/com/fr/design/widget/ui/designer/NewFormPane.java

@ -0,0 +1,291 @@
package com.fr.design.widget.ui.designer;
import com.fr.design.border.UITitledMatteBorder;
import com.fr.design.designer.beans.PredefinedLayout;
import com.fr.design.designer.beans.models.NewFormModel;
import com.fr.design.dialog.BasicPane;
import com.fr.design.dialog.DialogActionListener;
import com.fr.design.dialog.UIDialog;
import com.fr.design.gui.ibutton.UIButtonGroup;
import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.BaseJForm;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.form.main.Form;
import com.fr.general.ComparatorUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils;
import com.fr.stable.bridge.StableFactory;
import javax.swing.BorderFactory;
import javax.swing.DefaultListCellRenderer;
import javax.swing.DefaultListModel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.ListSelectionModel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class NewFormPane extends BasicPane {
private NewFormModel newFormModel;
private UIDialog dialog;
private PredefinedLayoutPane selectedLayoutPane = null;
private Map<String, JPanel> layoutPaneMap = new HashMap<>();
private List<PredefinedLayoutPane> layoutCards = new ArrayList<>();
public NewFormPane() {
newFormModel = NewFormModel.getInstance();
this.setBorder(BorderFactory.createEmptyBorder(10, 10, 0, 0));
this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.add(createModuleListPane(), BorderLayout.WEST);
this.add(createTemplateManagePane(), BorderLayout.CENTER);
}
@Override
protected String title4PopupWindow() {
return Toolkit.i18nText("Fine-Design_New_Template");
}
public void showWindow() {
dialog = new UIDialog(DesignerContext.getDesignerFrame(), this) {
@Override
public void checkValid() throws Exception {
}
};
dialog.setButtonEnabled(false);
dialog.addDialogActionListener(new DialogActionListener() {
@Override
public void doOk() {
if (selectedLayoutPane != null) {
NewFormPane.this.newForm(selectedLayoutPane.getTemplatePath());
}
}
@Override
public void doCancel() {
}
});
dialog.setSize(new Dimension(900, 600));
GUICoreUtils.centerWindow(dialog);
dialog.setTitle(this.title4PopupWindow());
dialog.setResizable(false);
dialog.setVisible(true);
}
private JPanel createModuleListPane() {
JList<String> list = new JList<String>();
list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
list.setModel(initListModel());
list.setSelectedIndex(0);
list.setCellRenderer(new DefaultListCellRenderer() {
@Override
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
this.setBorder(BorderFactory.createEmptyBorder(0, 8, 0, 0));
return this;
}
});
list.addListSelectionListener(new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent e) {
String value = list.getSelectedValue();
int selectedIndex = list.getSelectedIndex();
for (Map.Entry<String, JPanel> entry : layoutPaneMap.entrySet()) {
String moduleName = entry.getKey();
JPanel module = entry.getValue();
module.setVisible(selectedIndex == 0 || ComparatorUtils.equals(moduleName, value));
}
}
});
JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane();
jPanel.setBackground(new Color(255, 255, 255));
jPanel.setPreferredSize(new Dimension(138, 1));
jPanel.add(new UIScrollPane(list), BorderLayout.CENTER);
return jPanel;
}
private DefaultListModel<String> initListModel() {
DefaultListModel<String> model = new DefaultListModel<>();
model.addElement(Toolkit.i18nText("Fine-Design_All_Template_Layout"));
Map<String, List<PredefinedLayout>> map = newFormModel.getConfig();
for (String key : map.keySet()) {
model.addElement(key);
}
return model;
}
private JPanel createTemplateManagePane() {
JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane();
jPanel.add(createTemplateManageNorthPane(), BorderLayout.NORTH);
jPanel.add(createTemplateManageSouthPane(), BorderLayout.CENTER);
return jPanel;
}
private JPanel createTemplateManageNorthPane() {
JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane();
jPanel.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 0));
jPanel.setPreferredSize(new Dimension(1, 129));
jPanel.add(createNewTemplatePane(), BorderLayout.WEST);
jPanel.add(createSwitchButtonPane(), BorderLayout.EAST);
return jPanel;
}
private JPanel createNewTemplatePane() {
EmptyLayoutPane jPanel = new EmptyLayoutPane();
jPanel.addClickListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
setSelectedLayoutPane(jPanel);
dialog.setButtonEnabled(true);
}
});
return jPanel;
}
private JPanel createSwitchButtonPane() {
UIButtonGroup<String> buttonGroup = new UIButtonGroup<String>(new String[] {
Toolkit.i18nText("Fine-Design_Simple_Style_Template"),
Toolkit.i18nText("Fine-Design_Real_Style_Template")
});
buttonGroup.setPreferredSize(new Dimension(140, 20));
buttonGroup.setSelectedIndex(1);
buttonGroup.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
int selectedIndex = buttonGroup.getSelectedIndex();
for (PredefinedLayoutPane layoutCard : layoutCards) {
if (selectedIndex == 1) {
layoutCard.showRealStyle();
} else {
layoutCard.showSimpleStyle();
}
}
}
});
JPanel switchButtonPane = new JPanel(new BorderLayout());
switchButtonPane.add(buttonGroup, BorderLayout.CENTER);
JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane();
jPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 10));
jPanel.add(switchButtonPane, BorderLayout.NORTH);
return jPanel;
}
private JPanel createTemplateManageSouthPane() {
List<JPanel> predefinedLayoutPanes = createPredefinedLayoutPanes();
JPanel selectionsPane = createSelectionsPane(predefinedLayoutPanes);
UIScrollPane selectionsScrollPane = new UIScrollPane(selectionsPane);
selectionsScrollPane.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0));
JPanel titlePane = new JPanel(new BorderLayout());
titlePane.setBorder(UITitledMatteBorder.createTitledBorder(Toolkit.i18nText("Fine-Design_Select_Template"), new Color(1, 159, 222)));
titlePane.add(selectionsScrollPane, BorderLayout.CENTER);
JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane();
jPanel.setBorder(BorderFactory.createEmptyBorder(20, 0, 0, 0));
jPanel.add(titlePane, BorderLayout.CENTER);
return jPanel;
}
private JPanel createSelectionsPane(List<JPanel> components) {
JPanel selectionsPane = new JPanel();
JPanel container = new JPanel(new BorderLayout());
for (int i = 0; i < components.size(); i++) {
JPanel component = components.get(i);
if (component != null) {
container.add(component, BorderLayout.NORTH);
JPanel nextContainer = new JPanel(new BorderLayout());
container.add(nextContainer, BorderLayout.CENTER);
if (i == 0) {
selectionsPane = container;
}
container = nextContainer;
}
}
return selectionsPane;
}
private List<JPanel> createPredefinedLayoutPanes() {
List<JPanel> jPanels = new ArrayList<>();
Map<String, List<PredefinedLayout>> map = newFormModel.getConfig();
for (Map.Entry<String, List<PredefinedLayout>> entry : map.entrySet()) {
String moduleName = entry.getKey();
List<PredefinedLayout> layouts = entry.getValue();
JPanel module = createPredefinedLayoutPane(moduleName);
layoutPaneMap.put(moduleName, module);
for (PredefinedLayout layout : layouts) {
PredefinedLayoutPane predefinedLayoutPane = new PredefinedLayoutPane(layout);
predefinedLayoutPane.addClickListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
setSelectedLayoutPane(predefinedLayoutPane);
dialog.setButtonEnabled(true);
}
});
module.add(predefinedLayoutPane);
layoutCards.add(predefinedLayoutPane);
}
jPanels.add(module);
}
return jPanels;
}
private JPanel createPredefinedLayoutPane(String title) {
JPanel jp = new JPanel();
UITitledMatteBorder explainBorder = UITitledMatteBorder.createTitledTopBorder(title, Color.BLACK);
jp.setBorder(explainBorder);
jp.setLayout(new GridLayout(0, 3, 5, 5));
return jp;
}
private void newForm(String path) {
BaseJForm jForm;
try {
if (StringUtils.isNotEmpty(path)) {
Form form = new Form();
form.readStream(NewFormPane.class.getResourceAsStream(path));
jForm = StableFactory.getMarkedInstanceObjectFromClass(BaseJForm.XML_TAG, new Object[]{form}, BaseJForm.class);
} else {
jForm = StableFactory.getMarkedInstanceObjectFromClass(BaseJForm.XML_TAG, BaseJForm.class);
}
DesignerContext.getDesignerFrame().addAndActivateJTemplate((JTemplate<?, ?>) jForm);
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
private void setSelectedLayoutPane(PredefinedLayoutPane layoutPane) {
if (selectedLayoutPane != layoutPane) {
if (selectedLayoutPane != null) {
selectedLayoutPane.setSelected(false);
}
selectedLayoutPane = layoutPane;
if (selectedLayoutPane != null) {
selectedLayoutPane.setSelected(true);
}
}
}
}

117
designer-form/src/main/java/com/fr/design/widget/ui/designer/PredefinedLayoutPane.java

@ -0,0 +1,117 @@
package com.fr.design.widget.ui.designer;
import com.fr.base.GraphHelper;
import com.fr.base.svg.IconUtils;
import com.fr.design.designer.beans.PredefinedLayout;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.mainframe.share.ui.base.MouseClickListener;
import com.fr.stable.Constants;
import com.fr.stable.StringUtils;
import javax.swing.JPanel;
import java.awt.CardLayout;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Rectangle;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
public class PredefinedLayoutPane extends JPanel {
private static final Color HOVERING_BORDER_COLOR = new Color(65, 155, 249);
private static final Color HOVERING_SHADOW_COLOR = new Color(65, 155, 249, 51);
private CardLayout cardLayout = new CardLayout();
protected boolean hovering = false;
protected boolean selected = false;
protected MouseAdapter clickListener;
protected String templatePath = StringUtils.EMPTY;
public PredefinedLayoutPane() {
}
public PredefinedLayoutPane(PredefinedLayout predefinedLayout) {
this.templatePath = predefinedLayout.getTemplate();
UILabel simpleStyle = new UILabel(IconUtils.readIcon(predefinedLayout.getSimpleStyle()));
UILabel realStyle = new UILabel(IconUtils.readIcon(predefinedLayout.getRealStyle()));
this.setLayout(cardLayout);
this.add(realStyle, 0);
this.add(simpleStyle, 1);
this.initListener();
}
protected void initListener() {
this.addMouseListener(new MouseClickListener() {
@Override
public void mouseClicked(MouseEvent e) {
if (clickListener != null) {
clickListener.mouseClicked(e);
}
}
@Override
public void mouseEntered(MouseEvent e) {
hovering = true;
repaint();
}
@Override
public void mouseExited(MouseEvent e) {
hovering = false;
repaint();
}
});
}
@Override
public void paint(Graphics g) {
super.paint(g);
if (hovering) {
g.setColor(HOVERING_SHADOW_COLOR);
GraphHelper.fillRect(g, 1, 1, this.getWidth() - 2, this.getHeight() - 2);
}
if (selected || hovering) {
g.setColor(HOVERING_BORDER_COLOR);
Rectangle rectangle = new Rectangle(1, 1, this.getWidth() - 2, this.getHeight() - 2);
GraphHelper.draw(g, rectangle, Constants.LINE_MEDIUM);
}
}
public void addClickListener(MouseAdapter clickListener) {
this.clickListener = clickListener;
}
public void showSimpleStyle() {
cardLayout.last(this);
}
public void showRealStyle() {
cardLayout.first(this);
}
public boolean isHovering() {
return hovering;
}
public void setHovering(boolean hovering) {
this.hovering = hovering;
}
public boolean isSelected() {
return selected;
}
public void setSelected(boolean selected) {
this.selected = selected;
repaint();
}
public String getTemplatePath() {
return templatePath;
}
public void setTemplatePath(String templatePath) {
this.templatePath = templatePath;
}
}

28
designer-form/src/main/java/com/fr/design/widget/ui/designer/component/PaddingBoundPane.java

@ -14,6 +14,7 @@ import com.fr.form.ui.RichStyleWidgetProvider;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.SwingConstants; import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Component; import java.awt.Component;
@ -37,10 +38,10 @@ public class PaddingBoundPane extends BasicPane {
public void initBoundPane(int t, int b, int l, int r) { public void initBoundPane(int t, int b, int l, int r) {
this.setLayout(FRGUIPaneFactory.createBorderLayout()); this.setLayout(FRGUIPaneFactory.createBorderLayout());
top = new UISpinner(0, Integer.MAX_VALUE, 1, t); top = new UISpinner(0, Integer.MAX_VALUE, 1, t, false);
bottom = new UISpinner(0, Integer.MAX_VALUE, 1, b); bottom = new UISpinner(0, Integer.MAX_VALUE, 1, b, false);
left = new UISpinner(0, Integer.MAX_VALUE, 1, l); left = new UISpinner(0, Integer.MAX_VALUE, 1, l, false);
right = new UISpinner(0, Integer.MAX_VALUE, 1, r); right = new UISpinner(0, Integer.MAX_VALUE, 1, r, false);
top.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Layout_Padding_Duplicate")); top.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Layout_Padding_Duplicate"));
bottom.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Layout_Padding_Duplicate")); bottom.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Layout_Padding_Duplicate"));
left.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Layout_Padding_Duplicate")); left.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Layout_Padding_Duplicate"));
@ -79,13 +80,32 @@ public class PaddingBoundPane extends BasicPane {
} }
public void update(RichStyleWidgetProvider marginWidget) { public void update(RichStyleWidgetProvider marginWidget) {
try {
marginWidget.setMargin(updateBean()); marginWidget.setMargin(updateBean());
} catch (UnsupportedOperationException e) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
populateBean(marginWidget.getMargin());
}
});
}
} }
public PaddingMargin updateBean() { public PaddingMargin updateBean() {
return new PaddingMargin((int) top.getValue(), (int) left.getValue(), (int) bottom.getValue(), (int) right.getValue()); return new PaddingMargin((int) top.getValue(), (int) left.getValue(), (int) bottom.getValue(), (int) right.getValue());
} }
@Override
public void setEnabled(boolean enabled) {
this.top.setEnabled(enabled);
this.left.setEnabled(enabled);
this.bottom.setEnabled(enabled);
this.right.setEnabled(enabled);
}
@Override @Override
protected String title4PopupWindow() { protected String title4PopupWindow() {
return "PaddingBoundPane"; return "PaddingBoundPane";

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

@ -5,6 +5,8 @@ import com.fr.base.theme.TemplateTheme;
import com.fr.base.theme.settings.ThemedComponentStyle; import com.fr.base.theme.settings.ThemedComponentStyle;
import com.fr.design.designer.IntervalConstants; import com.fr.design.designer.IntervalConstants;
import com.fr.design.designer.creator.*; import com.fr.design.designer.creator.*;
import com.fr.design.fit.DesignerUIModeConfig;
import com.fr.design.fit.attrpane.PcFitExpandablePane;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.style.FollowingThemePane; import com.fr.design.gui.style.FollowingThemePane;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
@ -15,12 +17,15 @@ import com.fr.form.ui.ElementCaseEditor;
import com.fr.form.ui.PaddingMargin; import com.fr.form.ui.PaddingMargin;
import com.fr.form.web.FormToolBarManager; import com.fr.form.web.FormToolBarManager;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.report.fit.ReportFitAttr;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.JPanel; import javax.swing.JPanel;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Component; import java.awt.Component;
import java.util.ArrayList;
import java.util.List;
/** /**
* Created by ibm on 2017/8/7. * Created by ibm on 2017/8/7.
@ -29,6 +34,9 @@ public class ElementEditorDefinePane extends WTitleLayoutDefinePane<ElementCaseE
private final PaddingBoundPane paddingBoundPane; private final PaddingBoundPane paddingBoundPane;
private AccessibleElementCaseToolBarEditor elementCaseToolBarEditor; private AccessibleElementCaseToolBarEditor elementCaseToolBarEditor;
private PropertyGroupPane extraPropertyGroupPane; private PropertyGroupPane extraPropertyGroupPane;
private PcFitExpandablePane pcFitExpandablePane;
private static final String FIT_STATE_PC = "fitStateInPC";
public ElementEditorDefinePane(XCreator xCreator) { public ElementEditorDefinePane(XCreator xCreator) {
super(xCreator); super(xCreator);
@ -61,27 +69,49 @@ public class ElementEditorDefinePane extends WTitleLayoutDefinePane<ElementCaseE
}; };
JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W0, IntervalConstants.INTERVAL_L1); JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W0, IntervalConstants.INTERVAL_L1);
panel.setBorder(BorderFactory.createEmptyBorder(5, 0, 10, 0)); panel.setBorder(BorderFactory.createEmptyBorder(5, 0, 10, 0));
CRPropertyDescriptor[] extraTableEditor = ((XElementCase) creator).getExtraTableEditor(); CRPropertyDescriptor[] extraTableEditor = removeOldFitEditor(((XElementCase) creator).getExtraTableEditor());
extraPropertyGroupPane = new PropertyGroupPane(extraTableEditor, creator); extraPropertyGroupPane = new PropertyGroupPane(extraTableEditor, creator);
centerPane.add(panel, BorderLayout.NORTH); centerPane.add(panel, BorderLayout.NORTH);
if (extraTableEditor.length > 0) {
centerPane.add(extraPropertyGroupPane, BorderLayout.CENTER); centerPane.add(extraPropertyGroupPane, BorderLayout.CENTER);
}
pcFitExpandablePane = new PcFitExpandablePane(this);
if (DesignerUIModeConfig.getInstance().newUIMode()) {
centerPane.add(pcFitExpandablePane, BorderLayout.SOUTH);
}
return centerPane; return centerPane;
} }
private CRPropertyDescriptor[] removeOldFitEditor(CRPropertyDescriptor[] extraTableEditor) {
if (!DesignerUIModeConfig.getInstance().newUIMode()) {
return 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() { protected ElementCaseEditor updateSubBean() {
ElementCaseEditor elementCaseEditor = (ElementCaseEditor) creator.toData(); ElementCaseEditor elementCaseEditor = (ElementCaseEditor) creator.toData();
if (themePane.isFollowingTheme() || ComparatorUtils.equals(getGlobalName(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Layout_Padding_Duplicate"))) { if (themePane.isFollowingTheme() || ComparatorUtils.equals(getGlobalName(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Layout_Padding_Duplicate"))) {
paddingBoundPane.update(elementCaseEditor); paddingBoundPane.update(elementCaseEditor);
} }
elementCaseEditor.setToolBars((FormToolBarManager[]) elementCaseToolBarEditor.getValue()); elementCaseEditor.setToolBars((FormToolBarManager[]) elementCaseToolBarEditor.getValue());
ReportFitAttr fitAttr = pcFitExpandablePane.update();
elementCaseEditor.setReportFitAttr(fitAttr);
return elementCaseEditor; return elementCaseEditor;
} }
protected void populateSubBean(ElementCaseEditor ob) { protected void populateSubBean(ElementCaseEditor ob) {
paddingBoundPane.populate(ob); paddingBoundPane.populate(ob);
elementCaseToolBarEditor.setValue(ob.getToolBars()); elementCaseToolBarEditor.setValue(ob.getToolBars());
extraPropertyGroupPane.populate(ob); extraPropertyGroupPane.populate(ob);
pcFitExpandablePane.populate(ob.getReportFitAttr());
} }
} }

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

@ -4,13 +4,14 @@ import com.fr.base.io.IOFile;
import com.fr.base.iofile.attr.WatermarkAttr; import com.fr.base.iofile.attr.WatermarkAttr;
import com.fr.base.theme.FormTheme; import com.fr.base.theme.FormTheme;
import com.fr.base.theme.TemplateTheme; import com.fr.base.theme.TemplateTheme;
import com.fr.base.theme.settings.ThemedComponentStyle;
import com.fr.design.data.DataCreatorUI; import com.fr.design.data.DataCreatorUI;
import com.fr.design.designer.IntervalConstants; import com.fr.design.designer.IntervalConstants;
import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XWFitLayout; import com.fr.design.designer.creator.XWFitLayout;
import com.fr.design.designer.properties.items.FRLayoutTypeItems; import com.fr.design.designer.properties.items.FRLayoutTypeItems;
import com.fr.design.designer.properties.items.Item; import com.fr.design.designer.properties.items.Item;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.fit.DesignerUIModeConfig;
import com.fr.design.foldablepane.UIExpandablePane; import com.fr.design.foldablepane.UIExpandablePane;
import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
@ -19,6 +20,7 @@ import com.fr.design.gui.xpane.LayoutStylePane;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayoutHelper; import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.WidgetPropertyPane; import com.fr.design.mainframe.WidgetPropertyPane;
import com.fr.design.mainframe.widget.accessibles.AccessibleBodyWatermarkEditor; import com.fr.design.mainframe.widget.accessibles.AccessibleBodyWatermarkEditor;
import com.fr.design.widget.FRWidgetFactory; import com.fr.design.widget.FRWidgetFactory;
@ -36,6 +38,9 @@ import javax.swing.DefaultComboBoxModel;
import javax.swing.JPanel; import javax.swing.JPanel;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Component; import java.awt.Component;
import static javax.swing.JOptionPane.OK_CANCEL_OPTION;
import static javax.swing.JOptionPane.OK_OPTION;
import static javax.swing.JOptionPane.WARNING_MESSAGE;
/** /**
* Created by ibm on 2017/8/2. * Created by ibm on 2017/8/2.
@ -60,8 +65,9 @@ public class FRAbsoluteBodyLayoutDefinePane extends FRAbsoluteLayoutDefinePane {
initUIComboBox(); initUIComboBox();
this.setLayout(FRGUIPaneFactory.createBorderLayout()); this.setLayout(FRGUIPaneFactory.createBorderLayout());
boundPane = new WidgetBoundPane(creator); boundPane = new WidgetBoundPane(creator);
if (!DesignerUIModeConfig.getInstance().newUIMode()){
this.add(boundPane, BorderLayout.NORTH); this.add(boundPane, BorderLayout.NORTH);
}
JPanel panel1 = FRGUIPaneFactory.createBorderLayout_S_Pane(); JPanel panel1 = FRGUIPaneFactory.createBorderLayout_S_Pane();
this.add(panel1, BorderLayout.CENTER); this.add(panel1, BorderLayout.CENTER);
@ -118,12 +124,13 @@ public class FRAbsoluteBodyLayoutDefinePane extends FRAbsoluteLayoutDefinePane {
UILabel layoutTypeLabel = FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Attr_Layout_Type")); UILabel layoutTypeLabel = FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Attr_Layout_Type"));
UILabel scaleModeLabel = FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Scaling_Mode")); UILabel scaleModeLabel = FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Scaling_Mode"));
Component[][] components = DesignerUIModeConfig.getInstance().newUIMode() ? new Component[][]{
JPanel contentPane = TableLayoutHelper.createGapTableLayoutPane( {layoutTypeLabel, layoutCombox}
new Component[][]{ } : new Component[][]{
{layoutTypeLabel, layoutCombox}, {layoutTypeLabel, layoutCombox},
{scaleModeLabel, comboBox} {scaleModeLabel, comboBox}
}, };
JPanel contentPane = TableLayoutHelper.createGapTableLayoutPane(components,
TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W1, IntervalConstants.INTERVAL_L1); TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W1, IntervalConstants.INTERVAL_L1);
contentPane.setBorder(BorderFactory.createEmptyBorder(IntervalConstants.INTERVAL_L1, 0, IntervalConstants.INTERVAL_L1, 0)); contentPane.setBorder(BorderFactory.createEmptyBorder(IntervalConstants.INTERVAL_L1, 0, IntervalConstants.INTERVAL_L1, 0));
@ -173,6 +180,14 @@ public class FRAbsoluteBodyLayoutDefinePane extends FRAbsoluteLayoutDefinePane {
((XWFitLayout) creator.getBackupParent()).toData().resetStyle(); ((XWFitLayout) creator.getBackupParent()).toData().resetStyle();
if (state == WBodyLayoutType.FIT.getTypeValue()) { if (state == WBodyLayoutType.FIT.getTypeValue()) {
XWFitLayout xwFitLayout = ((XWFitLayout)creator.getBackupParent()); XWFitLayout xwFitLayout = ((XWFitLayout)creator.getBackupParent());
int selVal = FineJOptionPane.showConfirmDialog(
DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Design_Form_Layout_Switch_Tip"),
Toolkit.i18nText("Fine-Design_Basic_Alert"),
OK_CANCEL_OPTION,
WARNING_MESSAGE
);
if(OK_OPTION == selVal){
xwFitLayout.switch2FitBodyLayout(creator); xwFitLayout.switch2FitBodyLayout(creator);
WFitLayout wFitLayout = xwFitLayout.toData(); WFitLayout wFitLayout = xwFitLayout.toData();
// 切换布局类型时,保留body背景样式 // 切换布局类型时,保留body背景样式
@ -181,6 +196,11 @@ public class FRAbsoluteBodyLayoutDefinePane extends FRAbsoluteLayoutDefinePane {
wFitLayout.setBorderStyle(layout.getBorderStyle()); wFitLayout.setBorderStyle(layout.getBorderStyle());
} }
copyLayoutAttr(layout, xwFitLayout.toData()); copyLayoutAttr(layout, xwFitLayout.toData());
}else {
this.layoutCombox.setSelectedIndex(1);
}
copyLayoutAttr(layout, xwFitLayout.toData());
xwFitLayout.refreshStylePreviewEffect();
} }
} }
layout.setBorderStyleFollowingTheme(themePane.isFollowingTheme()); layout.setBorderStyleFollowingTheme(themePane.isFollowingTheme());

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

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

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

@ -6,14 +6,17 @@ import com.fr.base.theme.FormTheme;
import com.fr.base.theme.TemplateTheme; import com.fr.base.theme.TemplateTheme;
import com.fr.design.data.DataCreatorUI; import com.fr.design.data.DataCreatorUI;
import com.fr.design.designer.IntervalConstants; import com.fr.design.designer.IntervalConstants;
import com.fr.design.designer.beans.LayoutAdapter;
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.XOccupiedLayout;
import com.fr.design.designer.creator.XWAbsoluteBodyLayout; import com.fr.design.designer.creator.XWAbsoluteBodyLayout;
import com.fr.design.designer.creator.XWFitLayout; import com.fr.design.designer.creator.XWFitLayout;
import com.fr.design.designer.creator.XWScaleLayout; import com.fr.design.designer.creator.XWScaleLayout;
import com.fr.design.designer.properties.items.FRFitConstraintsItems; import com.fr.design.designer.properties.items.FRFitConstraintsItems;
import com.fr.design.designer.properties.items.FRLayoutTypeItems; import com.fr.design.designer.properties.items.FRLayoutTypeItems;
import com.fr.design.designer.properties.items.Item; import com.fr.design.designer.properties.items.Item;
import com.fr.design.fit.DesignerUIModeConfig;
import com.fr.design.foldablepane.UIExpandablePane; import com.fr.design.foldablepane.UIExpandablePane;
import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
@ -27,6 +30,7 @@ import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.FormSelectionUtils; import com.fr.design.mainframe.FormSelectionUtils;
import com.fr.design.mainframe.WidgetPropertyPane; import com.fr.design.mainframe.WidgetPropertyPane;
import com.fr.design.mainframe.widget.accessibles.AccessibleBodyWatermarkEditor; import com.fr.design.mainframe.widget.accessibles.AccessibleBodyWatermarkEditor;
import com.fr.design.ui.util.UIUtil;
import com.fr.design.utils.gui.UIComponentUtils; import com.fr.design.utils.gui.UIComponentUtils;
import com.fr.design.widget.FRWidgetFactory; import com.fr.design.widget.FRWidgetFactory;
import com.fr.design.widget.ui.designer.component.PaddingBoundPane; import com.fr.design.widget.ui.designer.component.PaddingBoundPane;
@ -42,7 +46,10 @@ import com.fr.log.FineLoggerFactory;
import com.fr.report.core.ReportUtils; import com.fr.report.core.ReportUtils;
import javax.swing.*; import javax.swing.*;
import javax.swing.border.Border;
import java.awt.*; import java.awt.*;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
/** /**
* Created by ibm on 2017/8/2. * Created by ibm on 2017/8/2.
@ -124,24 +131,37 @@ public class FRFitLayoutDefinePane extends AbstractFRLayoutDefinePane<WFitLayout
return contentPane0; return contentPane0;
} }
private boolean supportModifyInterval(){
LayoutAdapter layoutAdapter = this.xWFitLayout.getLayoutAdapter();
if (layoutAdapter == null){
return true;
}
return layoutAdapter.supportModifyInsert();
}
public JPanel createLayoutPane() { public JPanel createLayoutPane() {
JPanel containerPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); JPanel containerPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
layoutComboBox = initUIComboBox(FRLayoutTypeItems.ITEMS); layoutComboBox = initUIComboBox(FRLayoutTypeItems.ITEMS);
adaptComboBox = initUIComboBox(FRFitConstraintsItems.ITEMS); adaptComboBox = initUIComboBox(FRFitConstraintsItems.ITEMS);
JPanel adaptComboBoxPane = UIComponentUtils.wrapWithBorderLayoutPane(adaptComboBox); JPanel adaptComboBoxPane = UIComponentUtils.wrapWithBorderLayoutPane(adaptComboBox);
componentIntervel = new UISpinner(0, Integer.MAX_VALUE, 1, 0); componentIntervel = new UISpinner(0, Integer.MAX_VALUE, 1, 0, false);
JPanel componentIntervelPane = UIComponentUtils.wrapWithBorderLayoutPane(componentIntervel); JPanel componentIntervelPane = UIComponentUtils.wrapWithBorderLayoutPane(componentIntervel);
UILabel adaptLabel = FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Component_Scale")); UILabel adaptLabel = FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Component_Scale"));
UILabel intervalLabel = FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Component_Interval")); UILabel intervalLabel = FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Component_Interval"));
JPanel contentPane = TableLayoutHelper.createGapTableLayoutPane( Component[][] components = DesignerUIModeConfig.getInstance().newUIMode() ? new Component[][]{
new Component[][]{ {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Attr_Layout_Type")), layoutComboBox},
{intervalLabel, componentIntervelPane}
} : new Component[][]{
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Attr_Layout_Type")), layoutComboBox}, {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Attr_Layout_Type")), layoutComboBox},
{adaptLabel, adaptComboBoxPane}, {adaptLabel, adaptComboBoxPane},
{intervalLabel, componentIntervelPane} {intervalLabel, componentIntervelPane}
}, };
JPanel contentPane = TableLayoutHelper.createGapTableLayoutPane(
components,
TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W1, IntervalConstants.INTERVAL_L1); TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W1, IntervalConstants.INTERVAL_L1);
contentPane.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0)); contentPane.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0));
containerPane.add(contentPane, BorderLayout.CENTER); containerPane.add(contentPane, BorderLayout.CENTER);
@ -175,9 +195,12 @@ public class FRFitLayoutDefinePane extends AbstractFRLayoutDefinePane<WFitLayout
} }
paddingBound.populate(ob); paddingBound.populate(ob);
paddingBound.setEnabled(supportModifyInterval());
layoutComboBox.setSelectedIndex(ob.getBodyLayoutType().getTypeValue()); layoutComboBox.setSelectedIndex(ob.getBodyLayoutType().getTypeValue());
adaptComboBox.setSelectedIndex(ob.getCompState()); adaptComboBox.setSelectedIndex(ob.getCompState());
componentIntervel.setValue(ob.getCompInterval()); componentIntervel.setValue(ob.getCompInterval());
componentIntervel.setEnabled(supportModifyInterval());
themePane.supportFollowingTheme(ob.supportThemed()); themePane.supportFollowingTheme(ob.supportThemed());
themePane.setFollowingTheme(ob.isBorderStyleFollowingTheme()); themePane.setFollowingTheme(ob.isBorderStyleFollowingTheme());
stylePane.populateBean((LayoutBorderStyle) ob.getBorderStyle()); stylePane.populateBean((LayoutBorderStyle) ob.getBorderStyle());
@ -223,26 +246,43 @@ public class FRFitLayoutDefinePane extends AbstractFRLayoutDefinePane<WFitLayout
wAbsoluteBodyLayout.setBorderStyleFollowingTheme(layout.isBorderStyleFollowingTheme()); wAbsoluteBodyLayout.setBorderStyleFollowingTheme(layout.isBorderStyleFollowingTheme());
wAbsoluteBodyLayout.setBorderStyle((BorderPacker) (layout.getBorderStyle().clone())); wAbsoluteBodyLayout.setBorderStyle((BorderPacker) (layout.getBorderStyle().clone()));
Component[] components = xWFitLayout.getComponents(); Component[] components = xWFitLayout.getComponents();
Rectangle[] backupBounds = getBackupBoundsFromFitLayout();
xWFitLayout.removeAll(); xWFitLayout.removeAll();
layout.resetStyle(); layout.resetStyle();
XWAbsoluteBodyLayout xwAbsoluteBodyLayout = xWFitLayout.getBackupParent() == null ? new XWAbsoluteBodyLayout(wAbsoluteBodyLayout, new Dimension(0, 0)) : (XWAbsoluteBodyLayout) xWFitLayout.getBackupParent(); XWAbsoluteBodyLayout xwAbsoluteBodyLayout = xWFitLayout.getBackupParent() == null ? new XWAbsoluteBodyLayout(wAbsoluteBodyLayout, new Dimension(0, 0)) : (XWAbsoluteBodyLayout) xWFitLayout.getBackupParent();
xWFitLayout.setFixLayout(false);
xWFitLayout.getLayoutAdapter().addBean(xwAbsoluteBodyLayout, 0, 0); xWFitLayout.getLayoutAdapter().addBean(xwAbsoluteBodyLayout, 0, 0);
for (Component component : components) { for (int i = 0; i < components.length; i++) {
XCreator xCreator = (XCreator) component; XCreator xCreator = (XCreator) components[i];
xCreator.setBounds(backupBounds[i]);
//部分控件被ScaleLayout包裹着,绝对布局里面要放出来 //部分控件被ScaleLayout包裹着,绝对布局里面要放出来
if (xCreator.acceptType(XWScaleLayout.class)) { if (xCreator.acceptType(XWScaleLayout.class)) {
if (xCreator.getComponentCount() > 0 && ((XCreator) xCreator.getComponent(0)).shouldScaleCreator()) { if (xCreator.getComponentCount() > 0 && ((XCreator) xCreator.getComponent(0)).shouldScaleCreator()) {
component = xCreator.getComponent(0); Component component = xCreator.getComponent(0);
component.setBounds(xCreator.getBounds()); component.setBounds(xCreator.getBounds());
} }
} }
xwAbsoluteBodyLayout.add(component); if (!xCreator.acceptType(XOccupiedLayout.class)){
xwAbsoluteBodyLayout.add(xCreator);
}
} }
copyLayoutAttr(wFitLayout, xwAbsoluteBodyLayout.toData()); copyLayoutAttr(wFitLayout, xwAbsoluteBodyLayout.toData());
xWFitLayout.setBackupParent(xwAbsoluteBodyLayout); xWFitLayout.setBackupParent(xwAbsoluteBodyLayout);
FormDesigner formDesigner = WidgetPropertyPane.getInstance().getEditingFormDesigner(); FormDesigner formDesigner = WidgetPropertyPane.getInstance().getEditingFormDesigner();
formDesigner.getSelectionModel().setSelectedCreators( formDesigner.getSelectionModel().setSelectedCreators(
FormSelectionUtils.rebuildSelection(xWFitLayout, new Widget[]{wAbsoluteBodyLayout})); FormSelectionUtils.rebuildSelection(xWFitLayout, new Widget[]{wAbsoluteBodyLayout}));
if (xwAbsoluteBodyLayout.toData() != null) {
xwAbsoluteBodyLayout.toData().setBorderStyleFollowingTheme(wAbsoluteBodyLayout.isBorderStyleFollowingTheme());
xwAbsoluteBodyLayout.toData().setBorderStyle(wAbsoluteBodyLayout.getBorderStyle());
}
xwAbsoluteBodyLayout.refreshStylePreviewEffect();
if (xWFitLayout.toData() != null) {
xWFitLayout.toData().resetStyle();
}
xWFitLayout.refreshStylePreviewEffect();
formDesigner.switchBodyLayout(xwAbsoluteBodyLayout);
return layout;
} }
} catch (Exception e) { } catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
@ -253,11 +293,28 @@ public class FRFitLayoutDefinePane extends AbstractFRLayoutDefinePane<WFitLayout
if (xWFitLayout.canAddInterval(intervelValue)) { if (xWFitLayout.canAddInterval(intervelValue)) {
// 设置完间隔后,要同步处理界面组件,容器刷新后显示出对应效果 // 设置完间隔后,要同步处理界面组件,容器刷新后显示出对应效果
setLayoutGap(intervelValue); setLayoutGap(intervelValue);
} else{
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
componentIntervel.setValue(wFitLayout.getCompInterval(), false);
}
});
} }
return layout; return layout;
} }
private Rectangle[] getBackupBoundsFromFitLayout() {
int count = xWFitLayout.getComponentCount();
Rectangle[] rectangles = new Rectangle[count];
for (int i = 0; i < count; i++) {
rectangles[i] = xWFitLayout.getComponent(i).getBounds();
}
return rectangles;
}
private void updateWatermark() { private void updateWatermark() {
WatermarkAttr watermark = (WatermarkAttr) watermarkEditor.getValue(); WatermarkAttr watermark = (WatermarkAttr) watermarkEditor.getValue();
if (watermark != null) { if (watermark != null) {

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 449 B

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 159 B

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 201 B

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 261 B

100
designer-form/src/main/resources/com/fr/design/form/layouts/config.json

@ -0,0 +1,100 @@
{
"config":{
"2-4模块":[
{
"template":"2-4/1.frm",
"realStyle":"real_style_1",
"simpleStyle":"simple_style_1"
},
{
"template":"2-4/2.frm",
"realStyle":"real_style_2",
"simpleStyle":"simple_style_2"
},
{
"template":"2-4/3.frm",
"realStyle":"real_style_3",
"simpleStyle":"simple_style_3"
},
{
"template":"2-4/4.frm",
"realStyle":"real_style_4",
"simpleStyle":"simple_style_4"
},
{
"template":"2-4/5.frm",
"realStyle":"real_style_5",
"simpleStyle":"simple_style_5"
},
{
"template":"2-4/6.frm",
"realStyle":"real_style_6",
"simpleStyle":"simple_style_6"
}
],
"5-7模块":[
{
"template":"5-7/1.frm",
"realStyle":"real_style_7",
"simpleStyle":"simple_style_7"
},
{
"template":"5-7/2.frm",
"realStyle":"real_style_8",
"simpleStyle":"simple_style_8"
},
{
"template":"5-7/3.frm",
"realStyle":"real_style_9",
"simpleStyle":"simple_style_9"
},
{
"template":"5-7/4.frm",
"realStyle":"real_style_10",
"simpleStyle":"simple_style_10"
},
{
"template":"5-7/5.frm",
"realStyle":"real_style_11",
"simpleStyle":"simple_style_11"
},
{
"template":"5-7/6.frm",
"realStyle":"real_style_12",
"simpleStyle":"simple_style_12"
}
],
"多模块":[
{
"template":"multi/1.frm",
"realStyle":"real_style_13",
"simpleStyle":"simple_style_13"
},
{
"template":"multi/2.frm",
"realStyle":"real_style_14",
"simpleStyle":"simple_style_14"
},
{
"template":"multi/3.frm",
"realStyle":"real_style_15",
"simpleStyle":"simple_style_15"
},
{
"template":"multi/4.frm",
"realStyle":"real_style_16",
"simpleStyle":"simple_style_16"
},
{
"template":"multi/5.frm",
"realStyle":"real_style_17",
"simpleStyle":"simple_style_17"
},
{
"template":"multi/6.frm",
"realStyle":"real_style_18",
"simpleStyle":"simple_style_18"
}
]
}
}

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 KiB

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 KiB

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

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

Loading…
Cancel
Save