diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/connect/JDBCDefPane.java b/designer-base/src/main/java/com/fr/design/data/datapane/connect/JDBCDefPane.java index 1b2953b4c5..3349581248 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/connect/JDBCDefPane.java +++ b/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); driverLoaderBox.setVisible(selectSelfDefine); driverComboBox.setVisible(!selectSelfDefine); + // 选中自定义的话,将odbc的屏蔽,选中默认的话,重新触发一次driverComboBox的事件 + if (selectSelfDefine) { + odbcTipsLink.setVisible(false); + } else { + driverComboBox.setSelectedItem(driverComboBox.getSelectedItem()); + } } }; ActionListener dbtypeActionListener = new ActionListener() { @@ -515,8 +521,9 @@ public class JDBCDefPane extends JPanel { refreshDriverManage(true); this.driverManageBox.setSelectedItem(Toolkit.i18nText("Fine-Design_Driver_Manage_Self_Define")); String represent = getRepresent(jdbcDatabase.getDriver(), jdbcDatabase.getDriverSource()); - this.driverLoaderBox.removeItem(represent); - this.driverLoaderBox.addItem(represent); + if (!nameAndRepresent.containsValue(represent)) { + this.driverLoaderBox.addItem(represent); + } this.driverLoaderBox.setSelectedItem(represent); } this.urlTextField.setText(jdbcDatabase.getURL()); diff --git a/designer-chart/src/main/java/com/fr/design/module/ChartHyperlinkGroup.java b/designer-chart/src/main/java/com/fr/design/module/ChartHyperlinkGroup.java index 728ebbe057..7611f3300d 100644 --- a/designer-chart/src/main/java/com/fr/design/module/ChartHyperlinkGroup.java +++ b/designer-chart/src/main/java/com/fr/design/module/ChartHyperlinkGroup.java @@ -58,26 +58,21 @@ public class ChartHyperlinkGroup extends BaseHyperlinkGroup { if (template == null) { return false; } - if (template.isJWorkBook() || DesignModeContext.isDuchampMode()) { // 如果是普通报表单元格,那么没有 FormHyperlink 选项 FormHyperlinkProvider formHyperlink = StableFactory.getMarkedInstanceObjectFromClass(FormHyperlinkProvider.XML_TAG, FormHyperlinkProvider.class); //返回true表示可用,返回false表示不可用 return !ComparatorUtils.equals(clazz, formHyperlink.getClass()); - } else { // 如果是决策报表 - Class[] classes = new Class[]{ChartHyperRelateCellLink.class, ChartHyperRelateFloatLink.class}; - for (Class aClass : classes) { - if (template.getEditingReportIndex() == BaseJForm.FORM_TAB) { - // 编辑的是决策报表中的图表,那么没有ChartHyperRelateFloatLink 和 ChartHyperRelateCellLink 选项,有FormHyperlink 选项 - if (ComparatorUtils.equals(aClass, clazz)) { - return false; - } - } else if (template.getEditingReportIndex() == BaseJForm.ELEMENTCASE_TAB) { - // 编辑的是决策报表中的报表块,那么没有 ChartHyperRelateFloatLink,有ChartHyperRelateCellLink 和 FormHyperlink 选项 - return !ComparatorUtils.equals(clazz, ChartHyperRelateFloatLink.class); - } + if (template.getEditingReportIndex() == BaseJForm.FORM_TAB) { + // 编辑的是决策报表中的图表,那么没有ChartHyperRelateFloatLink 和 ChartHyperRelateCellLink 选项,有FormHyperlink 选项 + Class[] classes = new Class[]{ChartHyperRelateCellLink.class, ChartHyperRelateFloatLink.class}; + return !ArrayUtils.contains(classes, clazz); + } else if (template.getEditingReportIndex() == BaseJForm.ELEMENTCASE_TAB) { + // 编辑的是决策报表中的报表块,那么没有 ChartHyperPoplink 和 ChartHyperRelateFloatLink + Class[] classes = new Class[]{ChartHyperPoplink.class, ChartHyperRelateFloatLink.class}; + return !ArrayUtils.contains(classes, clazz); } } return true; @@ -101,17 +96,14 @@ public class ChartHyperlinkGroup extends BaseHyperlinkGroup { return !ComparatorUtils.equals(object.getClass(), formHyperlink.getClass()); } else { // 如果是决策报表 - Class[] classes = new Class[]{ChartHyperRelateCellLink.class, ChartHyperRelateFloatLink.class}; - for (Class aClass : classes) { - if (template.getEditingReportIndex() == BaseJForm.FORM_TAB) { - // 编辑的是决策报表中的图表,那么没有ChartHyperRelateFloatLink 和 ChartHyperRelateCellLink 选项,有FormHyperlink 选项 - if (ComparatorUtils.equals(aClass, object.getClass())) { - return false; - } - } else if (template.getEditingReportIndex() == BaseJForm.ELEMENTCASE_TAB) { - // 编辑的是决策报表中的报表块,那么没有 ChartHyperRelateFloatLink,有ChartHyperRelateCellLink 和 FormHyperlink 选项 - return !ComparatorUtils.equals(object.getClass(), ChartHyperRelateFloatLink.class); - } + if (template.getEditingReportIndex() == BaseJForm.FORM_TAB) { + // 编辑的是决策报表中的图表,那么没有ChartHyperRelateFloatLink 和 ChartHyperRelateCellLink 选项,有FormHyperlink 选项 + Class[] classes = new Class[]{ChartHyperRelateCellLink.class, ChartHyperRelateFloatLink.class}; + return !ArrayUtils.contains(classes, object.getClass()); + } else if (template.getEditingReportIndex() == BaseJForm.ELEMENTCASE_TAB) { + // 编辑的是决策报表中的报表块,那么没有 ChartHyperPoplink 和 ChartHyperRelateFloatLink + Class[] classes = new Class[]{ChartHyperPoplink.class, ChartHyperRelateFloatLink.class}; + return !ArrayUtils.contains(classes, object.getClass()); } } return true; diff --git a/designer-form/src/main/java/com/fr/design/mainframe/ComponentTree.java b/designer-form/src/main/java/com/fr/design/mainframe/ComponentTree.java index 0f39f089f8..2d0bb383fc 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/ComponentTree.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/ComponentTree.java @@ -425,6 +425,7 @@ public class ComponentTree extends JTree { Rectangle rectangle = getRelativeBounds(comp); comp.showSelectedPopup(designer, rectangle, comp.acceptType(XWTitleLayout.class, XWCardMainBorderLayout.class, XWAbsoluteLayout.class)); comp.setSelected(true); + designer.repaint(); } /** diff --git a/designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java b/designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java index 25726a5634..636fdcaaf1 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java +++ b/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 oldY = e.getY(); offsetEventPoint(e); + designer.getSpacingLineDrawer().updateMouseEvent(e, false); if (e.isPopupTrigger()) { if (stateModel.isDragging()) { stateModel.draggingCancel(); diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java b/designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java index 7d7b341663..d193b6774f 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java @@ -1145,7 +1145,7 @@ public class FormDesigner extends TargetComponent
implements TreeSelection return comp == null ? container : comp; } - private XLayoutContainer getRootContainer(int y) { + public XLayoutContainer getRootContainer(int y) { XLayoutContainer container = y < paraHeight - formArea.getVerticalValue() ? paraComponent : rootComponent; if (container == null) { container = rootComponent; diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormSpacingLineDrawer.java b/designer-form/src/main/java/com/fr/design/mainframe/FormSpacingLineDrawer.java index e2982f0414..540c707d49 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/FormSpacingLineDrawer.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/FormSpacingLineDrawer.java @@ -1,6 +1,13 @@ 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.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.stable.Constants; import com.fr.stable.GraphDrawHelper; @@ -17,9 +24,10 @@ import java.awt.geom.RoundRectangle2D; public class FormSpacingLineDrawer { 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 int TEXT_PADDING_HORIZONTAL = 6; - private static final int TEXT_PADDING_VERTICAL = 1; + private static final int TEXT_PADDING_HORIZONTAL = 8; + private static final int TEXT_PADDING_VERTICAL = 2; private static final int MIN_SPACING = 10; + private static final float TIP_FONT_SIZE = 10F; private FormDesigner designer; private XCreator hoverCreator = null; @@ -34,7 +42,7 @@ public class FormSpacingLineDrawer { public void updateMouseEvent(MouseEvent e, boolean isMouseMoveEvent) { XCreator creator = designer.getSelectionModel().getSelection().getSelectedCreator(); if (creator != null) { - this.hoverCreator = designer.getComponentAt(e.getX(), e.getY(), creator.getLevel()); + this.hoverCreator = getHoverComponentAt(e.getX(), e.getY()); } this.isMouseMoveEvent = isMouseMoveEvent; } @@ -80,10 +88,10 @@ public class FormSpacingLineDrawer { return; } - int startX = (int) nearestSides[0].getStartPointOnVerticalCenterLine().getX(); - int startY = (int) nearestSides[0].getStartPointOnVerticalCenterLine().getY(); - int endX = (int) nearestSides[0].getEndPointOnVerticalCenterLine(nearestSides[1].getParallelValue()).getX(); - int endY = (int) nearestSides[0].getEndPointOnVerticalCenterLine(nearestSides[1].getParallelValue()).getY(); + int startX = (int) nearestSides[0].getStartPointOnVerticalCenterLine().getX() - designer.getHorizontalScaleValue(); + int startY = (int) nearestSides[0].getStartPointOnVerticalCenterLine().getY() - designer.getVerticalScaleValue(); + int endX = (int) nearestSides[0].getEndPointOnVerticalCenterLine(nearestSides[1].getParallelValue()).getX() - designer.getHorizontalScaleValue(); + int endY = (int) nearestSides[0].getEndPointOnVerticalCenterLine(nearestSides[1].getParallelValue()).getY() - designer.getVerticalScaleValue(); drawSpacingLine(g, startX, startY, endX, endY); 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) { if (isNeedExtendedLine(nearestSides)) { - int startX = (int) nearestSides[1].getExtendedLineStartPoint(nearestSides[0]).getX(); - int startY = (int) nearestSides[1].getExtendedLineStartPoint(nearestSides[0]).getY(); - int endX = (int) nearestSides[1].getExtendedLineEndPoint(nearestSides[0]).getX(); - int endY = (int) nearestSides[1].getExtendedLineEndPoint(nearestSides[0]).getY(); + int startX = (int) nearestSides[1].getExtendedLineStartPoint(nearestSides[0]).getX() - designer.getHorizontalScaleValue(); + int startY = (int) nearestSides[1].getExtendedLineStartPoint(nearestSides[0]).getY() - designer.getVerticalScaleValue(); + int endX = (int) nearestSides[1].getExtendedLineEndPoint(nearestSides[0]).getX() - designer.getHorizontalScaleValue(); + int endY = (int) nearestSides[1].getExtendedLineEndPoint(nearestSides[0]).getY() - designer.getVerticalScaleValue(); drawExtendedLine(g, startX, startY, endX, endY); } } @@ -109,7 +117,7 @@ public class FormSpacingLineDrawer { private void drawSpacingText(Graphics g, String text, int x, int y) { Graphics2D g2d = (Graphics2D) g.create(); 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); FontMetrics metrics = g2d.getFontMetrics(); int lineHeight = metrics.getAscent(); // 这里由于都是数字,要居中必须忽略掉leading和descent的高度 @@ -128,14 +136,16 @@ public class FormSpacingLineDrawer { GraphDrawHelper.drawString(g2d, text, labelX, labelY); } + private boolean isSelectedParaComponent() { + return designer.getParaComponent() == designer.getSelectionModel().getSelection().getSelectedCreator(); + } + private boolean isSelectedRootComponent() { - return designer.getSelectionModel().getSelection().size() == 1 && - designer.isRoot(designer.getSelectionModel().getSelection().getSelectedCreator()); + return designer.isRoot(designer.getSelectionModel().getSelection().getSelectedCreator()); } private boolean isSelectedForm() { - return designer.getSelectionModel().getSelection().size() == 1 && - designer.getSelectionModel().getSelection().getSelectedCreator().getParent() == null; + return designer.getSelectionModel().getSelection().getSelectedCreator().getParent() == null; } private boolean isNeedExtendedLine(AbstractFormParallelLine[] nearestSides) { @@ -143,16 +153,38 @@ public class FormSpacingLineDrawer { } 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() { - XCreator selectedCreator = designer.getSelectionModel().getSelection().getSelectedCreator(); - return selectedCreator != null && hoverCreator != null && selectedCreator.getParent() == hoverCreator.getParent(); + private boolean isHoveredCompInPara() { + return isCompInPara(hoverCreator); + } + + private boolean isSelectedCompOrHoveredCompInPara() { + return isSelectedCompInPara() || isHoveredCompInPara(); } private boolean isDrawSpacingLine() { - return !isSelectedRootPane() && isSelectedCreatorSameParentWithHoveredCreator() && isMouseMoveEvent; + return isBodyAbsoluteLayout() && !isSelectedRootPane() && hoverCreator != null && !isSelectedCompOrHoveredCompInPara() && isMouseMoveEvent; } private AbstractFormParallelLine[] getNearestHorizontalSide() { @@ -196,4 +228,25 @@ public class FormSpacingLineDrawer { } 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; + } + } } diff --git a/designer-form/src/main/java/com/fr/design/mainframe/MultiSelectionArrangement.java b/designer-form/src/main/java/com/fr/design/mainframe/MultiSelectionArrangement.java index 54298e186d..49dbc8c974 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/MultiSelectionArrangement.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/MultiSelectionArrangement.java @@ -70,21 +70,22 @@ public class MultiSelectionArrangement { // 水平分布,自动,间距由selectedCreators和border共同计算而来 public void horizontalAutoDistribution() { sortHorizontal(); - int gap = calculateHorizontalGap(); - horizontalDistribution(gap); + int[] gaps = calculateHorizontalGaps(); + horizontalDistribution(gaps); } // 水平分布,手动,传入一个间距,排列selectedCreators public void horizontalManualDistribution(int gap) { + sortHorizontal(); 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++) { XCreator creator = selectedCreators.get(i); 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(); } @@ -132,33 +133,35 @@ public class MultiSelectionArrangement { } // 计算selectedCreators的均分间距 - private int calculateHorizontalGap() { + private int[] calculateHorizontalGaps() { int sum = 0; for (XCreator creator : selectedCreators) { sum += creator.getWidth(); } + int gapCount = selectedCreators.size() - 1; 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(); - return (distanceBetweenHeadAndTailCreators - sum) / (selectedCreators.size() - 1); + return calculateIntegerGaps(distanceBetweenHeadAndTailCreators - sum, gapCount); } public void verticalAutoDistribution() { sortVertical(); - int gap = calculateVerticalGap(); - verticalDistribution(gap); + int[] gaps = calculateVerticalGaps(); + verticalDistribution(gaps); } public void verticalManualDistribution(int gap) { + sortVertical(); 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++) { XCreator creator = selectedCreators.get(i); 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(); } @@ -205,15 +208,48 @@ public class MultiSelectionArrangement { }); } - private int calculateVerticalGap() { + private int[] calculateVerticalGaps() { int sum = 0; for (XCreator creator : selectedCreators) { sum += creator.getHeight(); } + int gapCount = selectedCreators.size() - 1; 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(); - 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() { diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormMultiWidgetCardPane.java b/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormMultiWidgetCardPane.java index 30dc8124a1..0263df5bf9 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormMultiWidgetCardPane.java +++ b/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) { - 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.addFocusListener(new FocusAdapter() { @Override diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormSingleWidgetCardPane.java b/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormSingleWidgetCardPane.java index a9e5e5d980..9f0c44ded3 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormSingleWidgetCardPane.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormSingleWidgetCardPane.java @@ -1,5 +1,6 @@ package com.fr.design.mainframe.widget.ui; +import com.fr.design.base.mode.DesignModeContext; import com.fr.design.data.DataCreatorUI; import com.fr.design.designer.beans.events.DesignerEvent; import com.fr.design.designer.creator.XCreator; @@ -154,7 +155,7 @@ public class FormSingleWidgetCardPane extends FormWidgetCardPane { private static void freshPropertyMode(XCreator xCreator) { JTemplate jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); - if (!(jTemplate instanceof JForm) && jTemplate.isUpMode()) { + if (!(jTemplate instanceof JForm) && jTemplate.isUpMode() && !DesignModeContext.isAuthorityEditing()) { if (xCreator instanceof XWParameterLayout) { EastRegionContainerPane.getInstance().switchMode(EastRegionContainerPane.PropertyMode.REPORT_PARA); } else {