Browse Source

Merge pull request #5428 in DESIGN/design from feature/10.0 to feature/big-screen

* commit 'fc64a08f0bedc7902969e579bbd30a2f68471242':
  REPORT-57128&REPORT-57657 优化代码冗余逻辑
  REPORT-57128&REPORT-57657 修复参数面板中会显示间距线的问题&修复报表块图表块不显示间距线的问题
  REPORT-57128 【FRM布局推荐】组件复用-关于悬浮hover组件的交互设计更新
  REPORT-57520 报表块内图表超链不应该显示悬浮窗图表
  REPORT-57658   处理odbc链接的共存关系
  REPORT-57438 【回归测试】权限细粒度控制-参数面板控件,控件权限编辑栏无法正常显示
  REPORT-53615  调整下combox的展示顺序
  REPORT-57317 修改间距提示文字的大小
  REPORT-57333 还原代码
  REPORT-57181 【FRM布局推荐】组件复用-自动间距目前么有把小数处理成整数
  REPORT-57333 【FRM布局推荐】组件复用-现在还不能实现绝对画布块上重叠放置组件
  REPORT-56895 还是计算间距线相对位置的问题
  REPORT-56926&REPORT-57238 解决因为修复这两个问题引起的新问题
  REPORT-56049 组件复用-组件目录树选中控件,如果选中后不移动鼠标的话,控件没有出现工具栏
feature/big-screen
superman 3 years ago
parent
commit
227e554a84
  1. 11
      designer-base/src/main/java/com/fr/design/data/datapane/connect/JDBCDefPane.java
  2. 40
      designer-chart/src/main/java/com/fr/design/module/ChartHyperlinkGroup.java
  3. 1
      designer-form/src/main/java/com/fr/design/mainframe/ComponentTree.java
  4. 1
      designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java
  5. 2
      designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java
  6. 95
      designer-form/src/main/java/com/fr/design/mainframe/FormSpacingLineDrawer.java
  7. 68
      designer-form/src/main/java/com/fr/design/mainframe/MultiSelectionArrangement.java
  8. 8
      designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormMultiWidgetCardPane.java
  9. 3
      designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormSingleWidgetCardPane.java

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

@ -185,6 +185,12 @@ public class JDBCDefPane extends JPanel {
driverManageLabel.setVisible(selectSelfDefine); driverManageLabel.setVisible(selectSelfDefine);
driverLoaderBox.setVisible(selectSelfDefine); driverLoaderBox.setVisible(selectSelfDefine);
driverComboBox.setVisible(!selectSelfDefine); driverComboBox.setVisible(!selectSelfDefine);
// 选中自定义的话,将odbc的屏蔽,选中默认的话,重新触发一次driverComboBox的事件
if (selectSelfDefine) {
odbcTipsLink.setVisible(false);
} else {
driverComboBox.setSelectedItem(driverComboBox.getSelectedItem());
}
} }
}; };
ActionListener dbtypeActionListener = new ActionListener() { ActionListener dbtypeActionListener = new ActionListener() {
@ -515,8 +521,9 @@ public class JDBCDefPane extends JPanel {
refreshDriverManage(true); refreshDriverManage(true);
this.driverManageBox.setSelectedItem(Toolkit.i18nText("Fine-Design_Driver_Manage_Self_Define")); this.driverManageBox.setSelectedItem(Toolkit.i18nText("Fine-Design_Driver_Manage_Self_Define"));
String represent = getRepresent(jdbcDatabase.getDriver(), jdbcDatabase.getDriverSource()); String represent = getRepresent(jdbcDatabase.getDriver(), jdbcDatabase.getDriverSource());
this.driverLoaderBox.removeItem(represent); if (!nameAndRepresent.containsValue(represent)) {
this.driverLoaderBox.addItem(represent); this.driverLoaderBox.addItem(represent);
}
this.driverLoaderBox.setSelectedItem(represent); this.driverLoaderBox.setSelectedItem(represent);
} }
this.urlTextField.setText(jdbcDatabase.getURL()); this.urlTextField.setText(jdbcDatabase.getURL());

40
designer-chart/src/main/java/com/fr/design/module/ChartHyperlinkGroup.java

@ -58,26 +58,21 @@ public class ChartHyperlinkGroup extends BaseHyperlinkGroup {
if (template == null) { if (template == null) {
return false; return false;
} }
if (template.isJWorkBook() || DesignModeContext.isDuchampMode()) { if (template.isJWorkBook() || DesignModeContext.isDuchampMode()) {
// 如果是普通报表单元格,那么没有 FormHyperlink 选项 // 如果是普通报表单元格,那么没有 FormHyperlink 选项
FormHyperlinkProvider formHyperlink = StableFactory.getMarkedInstanceObjectFromClass(FormHyperlinkProvider.XML_TAG, FormHyperlinkProvider.class); FormHyperlinkProvider formHyperlink = StableFactory.getMarkedInstanceObjectFromClass(FormHyperlinkProvider.XML_TAG, FormHyperlinkProvider.class);
//返回true表示可用,返回false表示不可用 //返回true表示可用,返回false表示不可用
return !ComparatorUtils.equals(clazz, formHyperlink.getClass()); return !ComparatorUtils.equals(clazz, formHyperlink.getClass());
} else { } else {
// 如果是决策报表 // 如果是决策报表
Class[] classes = new Class[]{ChartHyperRelateCellLink.class, ChartHyperRelateFloatLink.class}; if (template.getEditingReportIndex() == BaseJForm.FORM_TAB) {
for (Class aClass : classes) { // 编辑的是决策报表中的图表,那么没有ChartHyperRelateFloatLink 和 ChartHyperRelateCellLink 选项,有FormHyperlink 选项
if (template.getEditingReportIndex() == BaseJForm.FORM_TAB) { Class[] classes = new Class[]{ChartHyperRelateCellLink.class, ChartHyperRelateFloatLink.class};
// 编辑的是决策报表中的图表,那么没有ChartHyperRelateFloatLink 和 ChartHyperRelateCellLink 选项,有FormHyperlink 选项 return !ArrayUtils.contains(classes, clazz);
if (ComparatorUtils.equals(aClass, clazz)) { } else if (template.getEditingReportIndex() == BaseJForm.ELEMENTCASE_TAB) {
return false; // 编辑的是决策报表中的报表块,那么没有 ChartHyperPoplink 和 ChartHyperRelateFloatLink
} Class[] classes = new Class[]{ChartHyperPoplink.class, ChartHyperRelateFloatLink.class};
} else if (template.getEditingReportIndex() == BaseJForm.ELEMENTCASE_TAB) { return !ArrayUtils.contains(classes, clazz);
// 编辑的是决策报表中的报表块,那么没有 ChartHyperRelateFloatLink,有ChartHyperRelateCellLink 和 FormHyperlink 选项
return !ComparatorUtils.equals(clazz, ChartHyperRelateFloatLink.class);
}
} }
} }
return true; return true;
@ -101,17 +96,14 @@ public class ChartHyperlinkGroup extends BaseHyperlinkGroup {
return !ComparatorUtils.equals(object.getClass(), formHyperlink.getClass()); return !ComparatorUtils.equals(object.getClass(), formHyperlink.getClass());
} else { } else {
// 如果是决策报表 // 如果是决策报表
Class[] classes = new Class[]{ChartHyperRelateCellLink.class, ChartHyperRelateFloatLink.class}; if (template.getEditingReportIndex() == BaseJForm.FORM_TAB) {
for (Class aClass : classes) { // 编辑的是决策报表中的图表,那么没有ChartHyperRelateFloatLink 和 ChartHyperRelateCellLink 选项,有FormHyperlink 选项
if (template.getEditingReportIndex() == BaseJForm.FORM_TAB) { Class[] classes = new Class[]{ChartHyperRelateCellLink.class, ChartHyperRelateFloatLink.class};
// 编辑的是决策报表中的图表,那么没有ChartHyperRelateFloatLink 和 ChartHyperRelateCellLink 选项,有FormHyperlink 选项 return !ArrayUtils.contains(classes, object.getClass());
if (ComparatorUtils.equals(aClass, object.getClass())) { } else if (template.getEditingReportIndex() == BaseJForm.ELEMENTCASE_TAB) {
return false; // 编辑的是决策报表中的报表块,那么没有 ChartHyperPoplink 和 ChartHyperRelateFloatLink
} Class[] classes = new Class[]{ChartHyperPoplink.class, ChartHyperRelateFloatLink.class};
} else if (template.getEditingReportIndex() == BaseJForm.ELEMENTCASE_TAB) { return !ArrayUtils.contains(classes, object.getClass());
// 编辑的是决策报表中的报表块,那么没有 ChartHyperRelateFloatLink,有ChartHyperRelateCellLink 和 FormHyperlink 选项
return !ComparatorUtils.equals(object.getClass(), ChartHyperRelateFloatLink.class);
}
} }
} }
return true; return true;

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

@ -425,6 +425,7 @@ public class ComponentTree extends JTree {
Rectangle rectangle = getRelativeBounds(comp); Rectangle rectangle = getRelativeBounds(comp);
comp.showSelectedPopup(designer, rectangle, comp.acceptType(XWTitleLayout.class, XWCardMainBorderLayout.class, XWAbsoluteLayout.class)); comp.showSelectedPopup(designer, rectangle, comp.acceptType(XWTitleLayout.class, XWCardMainBorderLayout.class, XWAbsoluteLayout.class));
comp.setSelected(true); comp.setSelected(true);
designer.repaint();
} }
/** /**

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

@ -217,6 +217,7 @@ public class EditingMouseListener extends MouseInputAdapter {
int oldX = e.getX(); int oldX = e.getX();
int oldY = e.getY(); int oldY = e.getY();
offsetEventPoint(e); offsetEventPoint(e);
designer.getSpacingLineDrawer().updateMouseEvent(e, false);
if (e.isPopupTrigger()) { if (e.isPopupTrigger()) {
if (stateModel.isDragging()) { if (stateModel.isDragging()) {
stateModel.draggingCancel(); stateModel.draggingCancel();

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

@ -1145,7 +1145,7 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
return comp == null ? container : comp; return comp == null ? container : comp;
} }
private XLayoutContainer getRootContainer(int y) { public XLayoutContainer getRootContainer(int y) {
XLayoutContainer container = y < paraHeight - formArea.getVerticalValue() ? paraComponent : rootComponent; XLayoutContainer container = y < paraHeight - formArea.getVerticalValue() ? paraComponent : rootComponent;
if (container == null) { if (container == null) {
container = rootComponent; container = rootComponent;

95
designer-form/src/main/java/com/fr/design/mainframe/FormSpacingLineDrawer.java

@ -1,6 +1,13 @@
package com.fr.design.mainframe; package com.fr.design.mainframe;
import com.fr.design.designer.creator.XChartEditor;
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.XElementCase;
import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.creator.XWParameterLayout;
import com.fr.design.form.parameter.FormParaDesigner;
import com.fr.design.form.util.FormDesignerUtils;
import com.fr.design.utils.ComponentUtils; import com.fr.design.utils.ComponentUtils;
import com.fr.stable.Constants; import com.fr.stable.Constants;
import com.fr.stable.GraphDrawHelper; import com.fr.stable.GraphDrawHelper;
@ -17,9 +24,10 @@ import java.awt.geom.RoundRectangle2D;
public class FormSpacingLineDrawer { public class FormSpacingLineDrawer {
private static final Color LINE_COLOR = new Color(230, 82, 81); private static final Color LINE_COLOR = new Color(230, 82, 81);
private static final Color TEXT_COLOR = new Color(255, 255, 255); private static final Color TEXT_COLOR = new Color(255, 255, 255);
private static final int TEXT_PADDING_HORIZONTAL = 6; private static final int TEXT_PADDING_HORIZONTAL = 8;
private static final int TEXT_PADDING_VERTICAL = 1; private static final int TEXT_PADDING_VERTICAL = 2;
private static final int MIN_SPACING = 10; private static final int MIN_SPACING = 10;
private static final float TIP_FONT_SIZE = 10F;
private FormDesigner designer; private FormDesigner designer;
private XCreator hoverCreator = null; private XCreator hoverCreator = null;
@ -34,7 +42,7 @@ public class FormSpacingLineDrawer {
public void updateMouseEvent(MouseEvent e, boolean isMouseMoveEvent) { public void updateMouseEvent(MouseEvent e, boolean isMouseMoveEvent) {
XCreator creator = designer.getSelectionModel().getSelection().getSelectedCreator(); XCreator creator = designer.getSelectionModel().getSelection().getSelectedCreator();
if (creator != null) { if (creator != null) {
this.hoverCreator = designer.getComponentAt(e.getX(), e.getY(), creator.getLevel()); this.hoverCreator = getHoverComponentAt(e.getX(), e.getY());
} }
this.isMouseMoveEvent = isMouseMoveEvent; this.isMouseMoveEvent = isMouseMoveEvent;
} }
@ -80,10 +88,10 @@ public class FormSpacingLineDrawer {
return; return;
} }
int startX = (int) nearestSides[0].getStartPointOnVerticalCenterLine().getX(); int startX = (int) nearestSides[0].getStartPointOnVerticalCenterLine().getX() - designer.getHorizontalScaleValue();
int startY = (int) nearestSides[0].getStartPointOnVerticalCenterLine().getY(); int startY = (int) nearestSides[0].getStartPointOnVerticalCenterLine().getY() - designer.getVerticalScaleValue();
int endX = (int) nearestSides[0].getEndPointOnVerticalCenterLine(nearestSides[1].getParallelValue()).getX(); int endX = (int) nearestSides[0].getEndPointOnVerticalCenterLine(nearestSides[1].getParallelValue()).getX() - designer.getHorizontalScaleValue();
int endY = (int) nearestSides[0].getEndPointOnVerticalCenterLine(nearestSides[1].getParallelValue()).getY(); int endY = (int) nearestSides[0].getEndPointOnVerticalCenterLine(nearestSides[1].getParallelValue()).getY() - designer.getVerticalScaleValue();
drawSpacingLine(g, startX, startY, endX, endY); drawSpacingLine(g, startX, startY, endX, endY);
drawSpacingText(g, String.valueOf(gap), (startX + endX) / 2, (startY + endY) / 2); drawSpacingText(g, String.valueOf(gap), (startX + endX) / 2, (startY + endY) / 2);
@ -98,10 +106,10 @@ public class FormSpacingLineDrawer {
private void drawExtendedLine(Graphics g, AbstractFormParallelLine[] nearestSides) { private void drawExtendedLine(Graphics g, AbstractFormParallelLine[] nearestSides) {
if (isNeedExtendedLine(nearestSides)) { if (isNeedExtendedLine(nearestSides)) {
int startX = (int) nearestSides[1].getExtendedLineStartPoint(nearestSides[0]).getX(); int startX = (int) nearestSides[1].getExtendedLineStartPoint(nearestSides[0]).getX() - designer.getHorizontalScaleValue();
int startY = (int) nearestSides[1].getExtendedLineStartPoint(nearestSides[0]).getY(); int startY = (int) nearestSides[1].getExtendedLineStartPoint(nearestSides[0]).getY() - designer.getVerticalScaleValue();
int endX = (int) nearestSides[1].getExtendedLineEndPoint(nearestSides[0]).getX(); int endX = (int) nearestSides[1].getExtendedLineEndPoint(nearestSides[0]).getX() - designer.getHorizontalScaleValue();
int endY = (int) nearestSides[1].getExtendedLineEndPoint(nearestSides[0]).getY(); int endY = (int) nearestSides[1].getExtendedLineEndPoint(nearestSides[0]).getY() - designer.getVerticalScaleValue();
drawExtendedLine(g, startX, startY, endX, endY); drawExtendedLine(g, startX, startY, endX, endY);
} }
} }
@ -109,7 +117,7 @@ public class FormSpacingLineDrawer {
private void drawSpacingText(Graphics g, String text, int x, int y) { private void drawSpacingText(Graphics g, String text, int x, int y) {
Graphics2D g2d = (Graphics2D) g.create(); Graphics2D g2d = (Graphics2D) g.create();
g2d.setColor(LINE_COLOR); g2d.setColor(LINE_COLOR);
Font newFont = g2d.getFont().deriveFont(8F).deriveFont(Font.BOLD); Font newFont = g2d.getFont().deriveFont(TIP_FONT_SIZE).deriveFont(Font.BOLD);
g2d.setFont(newFont); g2d.setFont(newFont);
FontMetrics metrics = g2d.getFontMetrics(); FontMetrics metrics = g2d.getFontMetrics();
int lineHeight = metrics.getAscent(); // 这里由于都是数字,要居中必须忽略掉leading和descent的高度 int lineHeight = metrics.getAscent(); // 这里由于都是数字,要居中必须忽略掉leading和descent的高度
@ -128,14 +136,16 @@ public class FormSpacingLineDrawer {
GraphDrawHelper.drawString(g2d, text, labelX, labelY); GraphDrawHelper.drawString(g2d, text, labelX, labelY);
} }
private boolean isSelectedParaComponent() {
return designer.getParaComponent() == designer.getSelectionModel().getSelection().getSelectedCreator();
}
private boolean isSelectedRootComponent() { private boolean isSelectedRootComponent() {
return designer.getSelectionModel().getSelection().size() == 1 && return designer.isRoot(designer.getSelectionModel().getSelection().getSelectedCreator());
designer.isRoot(designer.getSelectionModel().getSelection().getSelectedCreator());
} }
private boolean isSelectedForm() { private boolean isSelectedForm() {
return designer.getSelectionModel().getSelection().size() == 1 && return designer.getSelectionModel().getSelection().getSelectedCreator().getParent() == null;
designer.getSelectionModel().getSelection().getSelectedCreator().getParent() == null;
} }
private boolean isNeedExtendedLine(AbstractFormParallelLine[] nearestSides) { private boolean isNeedExtendedLine(AbstractFormParallelLine[] nearestSides) {
@ -143,16 +153,38 @@ public class FormSpacingLineDrawer {
} }
private boolean isSelectedRootPane() { private boolean isSelectedRootPane() {
return isSelectedForm() || isSelectedRootComponent(); // form、body、para这三个选中了,都不要画任何间距线
return isSelectedForm() || isSelectedRootComponent() || isSelectedParaComponent();
}
// 当前组件是否在参数面板里面
private boolean isCompInPara(XCreator creator) {
XLayoutContainer container = XCreatorUtils.getHotspotContainer(creator);
boolean xCreatorAccept = creator.acceptType(XWParameterLayout.class);
boolean containerAccept = container != null && container.acceptType(XWParameterLayout.class);
return xCreatorAccept || containerAccept;
}
private boolean isBodyAbsoluteLayout() {
return !(designer instanceof FormParaDesigner) && FormDesignerUtils.isBodyAbsolute(designer);
}
private boolean isSelectedCompInPara() {
return isCompInPara(designer.getSelectionModel().getSelection().getSelectedCreator());
} }
private boolean isSelectedCreatorSameParentWithHoveredCreator() { private boolean isHoveredCompInPara() {
XCreator selectedCreator = designer.getSelectionModel().getSelection().getSelectedCreator(); return isCompInPara(hoverCreator);
return selectedCreator != null && hoverCreator != null && selectedCreator.getParent() == hoverCreator.getParent(); }
private boolean isSelectedCompOrHoveredCompInPara() {
return isSelectedCompInPara() || isHoveredCompInPara();
} }
private boolean isDrawSpacingLine() { private boolean isDrawSpacingLine() {
return !isSelectedRootPane() && isSelectedCreatorSameParentWithHoveredCreator() && isMouseMoveEvent; return isBodyAbsoluteLayout() && !isSelectedRootPane() && hoverCreator != null && !isSelectedCompOrHoveredCompInPara() && isMouseMoveEvent;
} }
private AbstractFormParallelLine[] getNearestHorizontalSide() { private AbstractFormParallelLine[] getNearestHorizontalSide() {
@ -196,4 +228,25 @@ public class FormSpacingLineDrawer {
} }
return nearestSides; return nearestSides;
} }
private XCreator getHoverComponentAt(int x, int y) {
XCreator component = designer.getComponentAt(x, y);
XLayoutContainer parent = XCreatorUtils.getHotspotContainer(component).getTopLayout();
if (parent != null) {
if (!parent.isEditable()) {
return parent;
} else {
if (parent == component) {
return null;
}
if (component instanceof XChartEditor || component instanceof XElementCase) {
return (XCreator) component.getParent();
}
return component;
}
} else {
return component;
}
}
} }

68
designer-form/src/main/java/com/fr/design/mainframe/MultiSelectionArrangement.java

@ -70,21 +70,22 @@ public class MultiSelectionArrangement {
// 水平分布,自动,间距由selectedCreators和border共同计算而来 // 水平分布,自动,间距由selectedCreators和border共同计算而来
public void horizontalAutoDistribution() { public void horizontalAutoDistribution() {
sortHorizontal(); sortHorizontal();
int gap = calculateHorizontalGap(); int[] gaps = calculateHorizontalGaps();
horizontalDistribution(gap); horizontalDistribution(gaps);
} }
// 水平分布,手动,传入一个间距,排列selectedCreators // 水平分布,手动,传入一个间距,排列selectedCreators
public void horizontalManualDistribution(int gap) { public void horizontalManualDistribution(int gap) {
sortHorizontal();
reSizeRecByHorizontal(gap); reSizeRecByHorizontal(gap);
horizontalDistribution(gap); horizontalDistribution(fillGaps(gap, selectedCreators.size() - 1));
} }
private void horizontalDistribution(int gap) { private void horizontalDistribution(int[] gaps) {
for (int i = 1; i < selectedCreators.size() - 1; i++) { for (int i = 1; i < selectedCreators.size() - 1; i++) {
XCreator creator = selectedCreators.get(i); XCreator creator = selectedCreators.get(i);
XCreator preCreator = selectedCreators.get(i - 1); XCreator preCreator = selectedCreators.get(i - 1);
creator.setLocation(preCreator.getX() + preCreator.getWidth() + gap, creator.getY()); creator.setLocation(preCreator.getX() + preCreator.getWidth() + gaps[i - 1], creator.getY());
} }
update(); update();
} }
@ -132,33 +133,35 @@ public class MultiSelectionArrangement {
} }
// 计算selectedCreators的均分间距 // 计算selectedCreators的均分间距
private int calculateHorizontalGap() { private int[] calculateHorizontalGaps() {
int sum = 0; int sum = 0;
for (XCreator creator : selectedCreators) { for (XCreator creator : selectedCreators) {
sum += creator.getWidth(); sum += creator.getWidth();
} }
int gapCount = selectedCreators.size() - 1;
XCreator head = selectedCreators.get(0); XCreator head = selectedCreators.get(0);
XCreator tail = selectedCreators.get(selectedCreators.size() - 1); XCreator tail = selectedCreators.get(gapCount);
int distanceBetweenHeadAndTailCreators = Math.abs(head.getX() - tail.getX()) + tail.getWidth(); int distanceBetweenHeadAndTailCreators = Math.abs(head.getX() - tail.getX()) + tail.getWidth();
return (distanceBetweenHeadAndTailCreators - sum) / (selectedCreators.size() - 1); return calculateIntegerGaps(distanceBetweenHeadAndTailCreators - sum, gapCount);
} }
public void verticalAutoDistribution() { public void verticalAutoDistribution() {
sortVertical(); sortVertical();
int gap = calculateVerticalGap(); int[] gaps = calculateVerticalGaps();
verticalDistribution(gap); verticalDistribution(gaps);
} }
public void verticalManualDistribution(int gap) { public void verticalManualDistribution(int gap) {
sortVertical();
reSizeRecByVertical(gap); reSizeRecByVertical(gap);
verticalDistribution(gap); verticalDistribution(fillGaps(gap, selectedCreators.size() - 1));
} }
private void verticalDistribution(int gap) { private void verticalDistribution(int[] gaps) {
for (int i = 1; i < selectedCreators.size() - 1; i++) { for (int i = 1; i < selectedCreators.size() - 1; i++) {
XCreator creator = selectedCreators.get(i); XCreator creator = selectedCreators.get(i);
XCreator preCreator = selectedCreators.get(i - 1); XCreator preCreator = selectedCreators.get(i - 1);
creator.setLocation(creator.getX(), preCreator.getY() + preCreator.getHeight() + gap); creator.setLocation(creator.getX(), preCreator.getY() + preCreator.getHeight() + gaps[i - 1]);
} }
update(); update();
} }
@ -205,15 +208,48 @@ public class MultiSelectionArrangement {
}); });
} }
private int calculateVerticalGap() { private int[] calculateVerticalGaps() {
int sum = 0; int sum = 0;
for (XCreator creator : selectedCreators) { for (XCreator creator : selectedCreators) {
sum += creator.getHeight(); sum += creator.getHeight();
} }
int gapCount = selectedCreators.size() - 1;
XCreator head = selectedCreators.get(0); XCreator head = selectedCreators.get(0);
XCreator tail = selectedCreators.get(selectedCreators.size() - 1); XCreator tail = selectedCreators.get(gapCount);
int distanceBetweenHeadAndTailCreators = Math.abs(head.getY() - tail.getY()) + tail.getHeight(); int distanceBetweenHeadAndTailCreators = Math.abs(head.getY() - tail.getY()) + tail.getHeight();
return (distanceBetweenHeadAndTailCreators - sum) / (selectedCreators.size() - 1); return calculateIntegerGaps(distanceBetweenHeadAndTailCreators - sum, gapCount);
}
private int[] calculateIntegerGaps(int gapTotalSize, int gapCount) {
int finalGap[] = new int[gapCount];
// gapTotalSize: 原先的所有未取整的gap的总和,是一个整数
int intGap = Math.round((float) gapTotalSize / gapCount);
// 把所有取整的gap求和,得到的整数gap
int intTotalSize = intGap * (gapCount);
// 求差,可以知道总误差
int difference = intTotalSize - gapTotalSize;
// 遍历,由于取整是四舍五入得到的,取整后每个gap和取整前的gap最多相差0.5,故difference绝对值小于gapCount的
for (int i = 0; i < gapCount; i++) {
if (i < Math.abs(difference)) {
if (difference < 0) {
// 说明取整后gap总误差小于取整前总gap,一个个加1补上
finalGap[i] = intGap + 1;
} else {
// 说明取整后gap总误差大于取整前总gap,一个个减1去掉
finalGap[i] = intGap - 1;
}
} else {
finalGap[i] = intGap;
}
}
return finalGap;
}
// 创建用gap填满一个size大小的数组
private int[] fillGaps(int gap, int size) {
int[] gaps = new int[size];
Arrays.fill(gaps, gap);
return gaps;
} }
private void update() { private void update() {

8
designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormMultiWidgetCardPane.java

@ -158,7 +158,13 @@ public class FormMultiWidgetCardPane extends FormWidgetCardPane {
} }
private UINumberField createIntNumberField(boolean isVertical, String tipText) { private UINumberField createIntNumberField(boolean isVertical, String tipText) {
final UINumberField numberField = new UINumberField(); final UINumberField numberField = new UINumberField() {
private static final long serialVersionUID = -448512934137620557L;
public boolean shouldResponseChangeListener() {
return false;
}
};
numberField.setPlaceholder(tipText); numberField.setPlaceholder(tipText);
numberField.addFocusListener(new FocusAdapter() { numberField.addFocusListener(new FocusAdapter() {
@Override @Override

3
designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormSingleWidgetCardPane.java

@ -1,5 +1,6 @@
package com.fr.design.mainframe.widget.ui; package com.fr.design.mainframe.widget.ui;
import com.fr.design.base.mode.DesignModeContext;
import com.fr.design.data.DataCreatorUI; import com.fr.design.data.DataCreatorUI;
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;
@ -154,7 +155,7 @@ public class FormSingleWidgetCardPane extends FormWidgetCardPane {
private static void freshPropertyMode(XCreator xCreator) { private static void freshPropertyMode(XCreator xCreator) {
JTemplate jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); JTemplate jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (!(jTemplate instanceof JForm) && jTemplate.isUpMode()) { if (!(jTemplate instanceof JForm) && jTemplate.isUpMode() && !DesignModeContext.isAuthorityEditing()) {
if (xCreator instanceof XWParameterLayout) { if (xCreator instanceof XWParameterLayout) {
EastRegionContainerPane.getInstance().switchMode(EastRegionContainerPane.PropertyMode.REPORT_PARA); EastRegionContainerPane.getInstance().switchMode(EastRegionContainerPane.PropertyMode.REPORT_PARA);
} else { } else {

Loading…
Cancel
Save