From f1cfb52102585feb61c8c8f8bc00cf8b60edf38b Mon Sep 17 00:00:00 2001 From: Starryi Date: Thu, 1 Jul 2021 14:45:31 +0800 Subject: [PATCH 01/14] =?UTF-8?q?REPORT-54116=20=E8=AE=BE=E8=AE=A1?= =?UTF-8?q?=E5=99=A8=E7=BB=9D=E5=AF=B9=E5=B8=83=E5=B1=80=E5=86=85=E5=8F=AF?= =?UTF-8?q?=E9=94=81=E5=AE=9A=E7=BB=84=E4=BB=B6=E5=AE=BD=E9=AB=98=E6=AF=94?= =?UTF-8?q?=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 绝对布局内的组件,按下Shift键拖拽改变组件尺寸或在设计器右侧栏 编辑组件尺寸大小时,可以保持组件宽高比例不变,优化用户体验 按下Shift键鼠标拖拽改变组件尺寸时锁定宽高比例的逻辑, 也对参数面板内控件和表格浮动元素生效 --- .../widget/WidgetBoundsPaneFactory.java | 48 ++++-- .../images/buttonicon/icon_lock_disabled.png | Bin 0 -> 225 bytes .../images/buttonicon/icon_lock_enabled.png | Bin 0 -> 229 bytes .../buttonicon/icon_unlock_disabled.png | Bin 0 -> 226 bytes .../images/buttonicon/icon_unlock_enabled.png | Bin 0 -> 229 bytes .../beans/location/AccessDirection.java | 5 + .../designer/beans/location/Bottom.java | 11 ++ .../design/designer/beans/location/Left.java | 11 ++ .../designer/beans/location/LeftBottom.java | 20 +++ .../designer/beans/location/LeftTop.java | 23 +++ .../design/designer/beans/location/Right.java | 13 ++ .../designer/beans/location/RightBottom.java | 18 +++ .../designer/beans/location/RightTop.java | 20 +++ .../design/designer/beans/location/Top.java | 11 ++ .../designer/beans/models/StateModel.java | 11 ++ .../mainframe/EditingMouseListener.java | 7 +- .../mainframe/FormEditorKeyListener.java | 12 +- .../fr/design/mainframe/FormSelection.java | 13 ++ .../component/WidgetAbsoluteBoundPane.java | 6 +- .../designer/component/WidgetBoundPane.java | 149 ++++++++++++++++-- .../java/com/fr/grid/GridMouseAdapter.java | 81 ++++++++-- 21 files changed, 423 insertions(+), 36 deletions(-) create mode 100644 designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_lock_disabled.png create mode 100644 designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_lock_enabled.png create mode 100644 designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_unlock_disabled.png create mode 100644 designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_unlock_enabled.png diff --git a/designer-base/src/main/java/com/fr/design/widget/WidgetBoundsPaneFactory.java b/designer-base/src/main/java/com/fr/design/widget/WidgetBoundsPaneFactory.java index 9b6e7b5c83..ae3dfc2557 100644 --- a/designer-base/src/main/java/com/fr/design/widget/WidgetBoundsPaneFactory.java +++ b/designer-base/src/main/java/com/fr/design/widget/WidgetBoundsPaneFactory.java @@ -10,6 +10,7 @@ import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import javax.swing.BorderFactory; +import javax.swing.JComponent; import javax.swing.JPanel; import javax.swing.SwingConstants; import java.awt.BorderLayout; @@ -45,23 +46,28 @@ public class WidgetBoundsPaneFactory { private static final int RIGHT_PANE_WIDTH = 145; - public static UIExpandablePane createBoundsPane(UISpinner width, UISpinner height) { + public static UIExpandablePane createBoundsPane(UISpinner width, UISpinner height, JComponent ratioLocked) { JPanel boundsPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); double f = TableLayout.FILL; double p = TableLayout.PREFERRED; Component[][] components = new Component[][]{ - new Component[]{FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Basic_Component_Size")), createRightPane(width, height)}, + new Component[]{FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Basic_Component_Size")), + ratioLocked != null ? createRightPane(width, ratioLocked, height) : createRightPane(width, height)}, new Component[]{null, createRightPane(new UILabel(Toolkit.i18nText("Fine-Design_Basic_Tree_Width"), SwingConstants.CENTER), new UILabel(Toolkit.i18nText("Fine-Design_Basic_Tree_Height"), SwingConstants.CENTER))}, }; double[] rowSize = {p, p}; double[] columnSize = {f, RIGHT_PANE_WIDTH}; - int[][] rowCount = {{1, 1}, {1, 1}}; + int[][] rowCount = ratioLocked != null ? new int[][]{{1, 1}, {1, 1, 1}} : new int[][]{{1, 1}, {1, 1}}; final JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, IntervalConstants.INTERVAL_W5, IntervalConstants.INTERVAL_L6); panel.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0)); boundsPane.add(panel); return new UIExpandablePane(Toolkit.i18nText("Fine-Design_Form_Coords_And_Size"), 280, 24, boundsPane); } + public static UIExpandablePane createBoundsPane(UISpinner width, UISpinner height) { + return createBoundsPane(width, height, null); + } + public static JPanel createRightPane(Component com1, Component com2) { double f = TableLayout.FILL; double p = TableLayout.PREFERRED; @@ -74,21 +80,41 @@ public class WidgetBoundsPaneFactory { return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, IntervalConstants.INTERVAL_L6, IntervalConstants.INTERVAL_L1); } - public static UIExpandablePane createAbsoluteBoundsPane(UISpinner x, UISpinner y, UISpinner width, UISpinner height, NameAttribute nameAttribute) { + public static JPanel createRightPane(Component com1, Component com2, Component com3) { + double f = TableLayout.FILL; + double p = TableLayout.PREFERRED; + double[] rowSize = {p}; + double[] columnSize = {f, 24, f}; + int[][] rowCount = {{1, 1, 1}}; + Component[][] components = new Component[][]{ + new Component[]{com1, com2, com3} + }; + return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, 0, IntervalConstants.INTERVAL_L1); + } + + public static UIExpandablePane createAbsoluteBoundsPane(UISpinner x, UISpinner y, UISpinner width, UISpinner height, JComponent ratioLocked, NameAttribute nameAttribute) { double f = TableLayout.FILL; double p = TableLayout.PREFERRED; + UILabel positionLabel = FRWidgetFactory.createLineWrapLabel(nameAttribute.getPositionName()); + UILabel xLabel = new UILabel(Toolkit.i18nText("Fine-Design_Basic_X_Coordinate"), SwingConstants.CENTER); + UILabel yLabel = new UILabel(Toolkit.i18nText("Fine-Design_Basic_Y_Coordinate"), SwingConstants.CENTER); + + UILabel sizeLabel = FRWidgetFactory.createLineWrapLabel(nameAttribute.getSizeName()); + UILabel widthLabel = new UILabel(Toolkit.i18nText("Fine-Design_Basic_Tree_Width"), SwingConstants.CENTER); + UILabel heightLabel = new UILabel(Toolkit.i18nText("Fine-Design_Basic_Tree_Height"), SwingConstants.CENTER); + Component[][] northComponents = new Component[][]{ - new Component[]{FRWidgetFactory.createLineWrapLabel(nameAttribute.getPositionName()), createRightPane(x, y)}, - new Component[]{null, createRightPane(new UILabel(Toolkit.i18nText("Fine-Design_Basic_X_Coordinate"), SwingConstants.CENTER), new UILabel(Toolkit.i18nText("Fine-Design_Basic_Y_Coordinate"), SwingConstants.CENTER))}, + new Component[]{positionLabel, ratioLocked != null ? createRightPane(x, null, y) : createRightPane(x, y)}, + new Component[]{null, ratioLocked != null ? createRightPane(xLabel, null, yLabel) : createRightPane(xLabel, yLabel)}, }; Component[][] centerComponents = new Component[][]{ - new Component[]{FRWidgetFactory.createLineWrapLabel(nameAttribute.getSizeName()), createRightPane(width, height)}, - new Component[]{null, createRightPane(new UILabel(Toolkit.i18nText("Fine-Design_Basic_Tree_Width"), SwingConstants.CENTER), new UILabel(Toolkit.i18nText("Fine-Design_Basic_Tree_Height"), SwingConstants.CENTER))}, + new Component[]{sizeLabel, ratioLocked != null ? createRightPane(width, ratioLocked, height) : createRightPane(width, height)}, + new Component[]{null, ratioLocked != null ? createRightPane(widthLabel, null, heightLabel) : createRightPane(widthLabel, heightLabel)}, }; double[] rowSize = {p, p}; double[] columnSize = {f, RIGHT_PANE_WIDTH}; - int[][] rowCount = {{1, 1}, {1, 1}}; + int[][] rowCount = ratioLocked != null ? new int[][]{{1, 1, 1}, {1, 1, 1}} : new int[][]{{1, 1}, {1, 1}}; final JPanel northPanel = TableLayoutHelper.createGapTableLayoutPane(northComponents, rowSize, columnSize, rowCount, IntervalConstants.INTERVAL_W5, IntervalConstants.INTERVAL_L6); final JPanel centerPanel = TableLayoutHelper.createGapTableLayoutPane(centerComponents, rowSize, columnSize, rowCount, IntervalConstants.INTERVAL_W5, IntervalConstants.INTERVAL_L6); JPanel boundsPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); @@ -99,6 +125,10 @@ public class WidgetBoundsPaneFactory { return new UIExpandablePane(Toolkit.i18nText("Fine-Design_Form_Coords_And_Size"), 230, 24, boundsPane); } + public static UIExpandablePane createAbsoluteBoundsPane(UISpinner x, UISpinner y, UISpinner width, UISpinner height, NameAttribute nameAttribute) { + return createAbsoluteBoundsPane(x, y, width, height, null, nameAttribute); + } + public static UIExpandablePane createAbsoluteBoundsPane(UISpinner x, UISpinner y, UISpinner width, UISpinner height) { return createAbsoluteBoundsPane(x, y, width, height, NameAttribute.DEFAULT); } diff --git a/designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_lock_disabled.png b/designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_lock_disabled.png new file mode 100644 index 0000000000000000000000000000000000000000..b498e7c141ff6e719ef7ea3c4ba8dc33da3f7d2a GIT binary patch literal 225 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`D?D8sLoEE0Qx*sq1g)6gn8s!x zDH*xK*x=99_8k*`KHOQXo@ZoW@W;8_Fic!RGBU%+$mqkzPem~-nLqygZ2$NFKhOMg zbFB;KdNBLg{`j$jU&f-~0lPXLoEE0Qx*sq1g)6gXvUV2 znYppBsL1^9|Nr{DPn_J`mPOv*U%z&D+1p$CCF04YjT<*+vNIp9zk7fG%*&FJ^?%Y6 z6Xza1aG>Jno12$KT_h7yQvSRVBL;LggQu&X%Q~loCIA+%TQC3s literal 0 HcmV?d00001 diff --git a/designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_unlock_disabled.png b/designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_unlock_disabled.png new file mode 100644 index 0000000000000000000000000000000000000000..6785a5130912472e8ec207c6b6707e5bb61de154 GIT binary patch literal 226 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`D?MEtLoEE0Qx*sq1g)6QIGxeQ z%}wkT4^REm|9^k~pWfN|^yJQB^*kd3gFnvO1y(ZxWoPyD@YL+tBO~r8Wmo@i;s5{k zhnE*W_lr@##1PDHXZMbooloWm!VcI9Q?~ zosg82^!L5|Vga-N#)g0E%b%T@x%fnpL}Efp%Bybu4;Prr1*9AbB?Kl{d|*>r33Rbq Wr=OtT@&zDYFnGH9xvXXLoEE0Qx*sq1g)6QxSBC4 zDk^8roIAe%|Nr++PD%Om@xT4yNAmXjuEy;ydn>-HHGLyJv}}5|Ni~${{7L>ZhuFqFJI22MnwLfXIcHNhb53rLVETe z`|58zfe)Jxb35N+NKT%7n1_eQ%;M7ViJQ~U-%vW8*utp6@KIIo%K_OrYyo0yOVacf d1xedEGfuAe75w 0 && height4Backup > 0) { + mHeightSpinner.setValue(mWidthSpinner.getValue() * width4Backup / height4Backup, false); + } + } + }); + mHeightSpinner.addChangeListener(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + if (isLockEnabled() && isLocked() && width4Backup > 0 && height4Backup > 0) { + mWidthSpinner.setValue(mHeightSpinner.getValue() * height4Backup / width4Backup, false); + } + } + }); + } + + @Override + public Icon getIcon() { + if (this.isLocked()) { + if (this.isLockEnabled()) { + return enabledLocked; + } else { + return disabledLocked; + } + } else { + if (this.isLockEnabled()) { + return enabledUnLocked; + } else { + return disabledUnLocked; + } + } + } + + public void setLocked(boolean locked) { + this.setSelected(locked); + } + + public boolean isLocked() { + return this.isSelected(); + } + + public boolean isLockEnabled() { + return this.isEnabled(); + } + + public void setLockEnabled(boolean enabled) { + this.setEnabled(enabled); + } + + public void populate(XCreator creator) { + Rectangle bounds = new Rectangle(creator.getBounds()); + mCreator = creator; + width4Backup = bounds.width; + height4Backup = bounds.height; + Widget widget = creator.toData(); + setLocked(widget.isAspectRatioLocked()); + } + } } diff --git a/designer-realize/src/main/java/com/fr/grid/GridMouseAdapter.java b/designer-realize/src/main/java/com/fr/grid/GridMouseAdapter.java index b0f91a9029..b6dc8bc4ad 100644 --- a/designer-realize/src/main/java/com/fr/grid/GridMouseAdapter.java +++ b/designer-realize/src/main/java/com/fr/grid/GridMouseAdapter.java @@ -75,6 +75,8 @@ public class GridMouseAdapter implements MouseListener, MouseWheelListener, Mous private int resolution = ScreenResolution.getScreenResolution(); + private int[] resizingBackupBounds = null; + protected GridMouseAdapter(Grid grid) { this.grid = grid; } @@ -338,6 +340,7 @@ public class GridMouseAdapter implements MouseListener, MouseWheelListener, Mous } boolean isControlDown = InputEventBaseOnOS.isControlDown(evt); + boolean isShiftDown = evt.isShiftDown(); long systemCurrentTime = System.currentTimeMillis(); if (systemCurrentTime - lastMouseMoveTime <= DRAG_REFRESH_TIME) {// alex:Drag @@ -351,10 +354,10 @@ public class GridMouseAdapter implements MouseListener, MouseWheelListener, Mous return; } - doWithMouseDragged(evt.getX(), evt.getY(), isControlDown); + doWithMouseDragged(evt.getX(), evt.getY(), isControlDown, isShiftDown); } - private void doWithMouseDragged(int evtX, int evtY, boolean isControlDown) { + private void doWithMouseDragged(int evtX, int evtY, boolean isControlDown, boolean isShiftDown) { ElementCasePane reportPane = grid.getElementCasePane(); if (reportPane.mustInVisibleRange()) { @@ -366,7 +369,7 @@ public class GridMouseAdapter implements MouseListener, MouseWheelListener, Mous Selection selection = reportPane.getSelection(); if (selection instanceof FloatSelection && !DesignerMode.isAuthorityEditing()) { - doWithFloatElementDragged(evtX, evtY, (FloatSelection) selection); + doWithFloatElementDragged(evtX, evtY, (FloatSelection) selection, isShiftDown); grid.setDragType(GridUtils.DRAG_FLOAT); } else if (grid.getDragType() == GridUtils.DRAG_CELLSELECTION_BOTTOMRIGHT_CORNER && !DesignerMode.isAuthorityEditing()) { doWithCellElementDragged(evtX, evtY, (CellSelection) selection); @@ -391,36 +394,83 @@ public class GridMouseAdapter implements MouseListener, MouseWheelListener, Mous * @param fs */ - private void doWithFloatElementDragged(int evtX, int evtY, FloatSelection fs) { + private void doWithFloatElementDragged(int evtX, int evtY, FloatSelection fs, boolean aspectRatio) { ElementCase report = grid.getElementCasePane().getEditingElementCase(); // int resolution = ScreenResolution.getScreenResolution(); String floatName = fs.getSelectedFloatName(); FloatElement floatElement = report.getFloatElement(floatName); int cursorType = grid.getCursor().getType(); + int currentLeft = Math.min(oldEvtX, evtX); + int currentTop = Math.min(oldEvtY, evtY); + int currentRight = Math.max(oldEvtX, evtX); + int currentBottom = Math.max(oldEvtY, evtY); + int currentWidth = currentRight - currentLeft; + int currentHeight = currentBottom - currentTop; + + int backupWidth= resizingBackupBounds[2]; + int backupHeight= resizingBackupBounds[3]; + if (cursorType == Cursor.NW_RESIZE_CURSOR || cursorType == Cursor.NE_RESIZE_CURSOR || cursorType == Cursor.SE_RESIZE_CURSOR || cursorType == Cursor.SW_RESIZE_CURSOR) { + if (aspectRatio) { + double currentDiagonal = Math.pow(currentWidth, 2) + Math.pow(currentHeight, 2); + double backupDiagonal = Math.pow(backupWidth, 2) + Math.pow(backupHeight, 2); + + int newWidth = (int) (Math.sqrt((currentDiagonal / backupDiagonal) * (Math.pow(backupWidth, 2)))); + int newHeight = (int) (Math.sqrt((currentDiagonal / backupDiagonal) * (Math.pow(backupHeight, 2)))); + + if (cursorType == Cursor.NW_RESIZE_CURSOR) { + currentLeft = currentRight - newWidth; + currentTop = currentBottom - newHeight; + } else if (cursorType == Cursor.NE_RESIZE_CURSOR) { + currentRight = currentLeft + newWidth; + currentTop = currentBottom - newHeight; + } else if (cursorType == Cursor.SW_RESIZE_CURSOR) { + currentLeft = currentRight - newWidth; + currentBottom = currentTop + newHeight; + } else if (cursorType == Cursor.SE_RESIZE_CURSOR){ + currentRight = currentLeft + newWidth; + currentBottom = currentTop + newHeight; + } + } + DynamicUnitList columnWidthList = ReportHelper.getColumnWidthList(report); DynamicUnitList rowHeightList = ReportHelper.getRowHeightList(report); - FU floatX1_fu = FU.valueOfPix(Math.min(oldEvtX, evtX), resolution); - FU floatY1_fu = FU.valueOfPix(Math.min(oldEvtY, evtY), resolution); + + FU floatX1_fu = FU.valueOfPix(currentLeft, resolution); + FU floatY1_fu = FU.valueOfPix(currentTop, resolution); FU leftDistance = floatX1_fu.add(columnWidthList.getRangeValue(0, grid.getHorizontalValue())); FU topDistance = floatY1_fu.add(rowHeightList.getRangeValue(0, grid.getVerticalValue())); floatElement.setLeftDistance(leftDistance); floatElement.setTopDistance(topDistance); - floatElement.setWidth(FU.valueOfPix(Math.max(oldEvtX, evtX), resolution).subtract(floatX1_fu)); - floatElement.setHeight(FU.valueOfPix(Math.max(oldEvtY, evtY), resolution).subtract(floatY1_fu)); + floatElement.setWidth(FU.valueOfPix(currentRight, resolution).subtract(floatX1_fu)); + floatElement.setHeight(FU.valueOfPix(currentBottom, resolution).subtract(floatY1_fu)); } else if (cursorType == Cursor.S_RESIZE_CURSOR || cursorType == Cursor.N_RESIZE_CURSOR) { DynamicUnitList rowHeightList = ReportHelper.getRowHeightList(report); - FU floatY1_fu = FU.valueOfPix(Math.min(oldEvtY, evtY), resolution); + FU floatY1_fu = FU.valueOfPix(currentTop, resolution); FU topDistance = floatY1_fu.add(rowHeightList.getRangeValue(0, grid.getVerticalValue())); floatElement.setTopDistance(topDistance); - floatElement.setHeight(FU.valueOfPix(Math.max(oldEvtY, evtY), resolution).subtract(floatY1_fu)); + floatElement.setHeight(FU.valueOfPix(currentBottom, resolution).subtract(floatY1_fu)); + + if (aspectRatio) { + currentWidth = backupWidth * currentHeight / backupHeight; + currentRight = currentLeft + currentWidth; + FU floatX1_fu = FU.valueOfPix(currentLeft, resolution); + floatElement.setWidth(FU.valueOfPix(currentRight, resolution).subtract(floatX1_fu)); + } } else if (cursorType == Cursor.W_RESIZE_CURSOR || cursorType == Cursor.E_RESIZE_CURSOR) { DynamicUnitList columnWidthList = ReportHelper.getColumnWidthList(report); - FU floatX1_fu = FU.valueOfPix(Math.min(oldEvtX, evtX), resolution); + FU floatX1_fu = FU.valueOfPix(currentLeft, resolution); FU leftDistance = floatX1_fu.add(columnWidthList.getRangeValue(0, grid.getHorizontalValue())); floatElement.setLeftDistance(leftDistance); - floatElement.setWidth(FU.valueOfPix(Math.max(oldEvtX, evtX), resolution).subtract(floatX1_fu)); + floatElement.setWidth(FU.valueOfPix(currentRight, resolution).subtract(floatX1_fu)); + + if (aspectRatio) { + currentHeight = backupHeight * currentWidth / backupWidth; + currentBottom = currentTop + currentHeight; + FU floatY1_fu = FU.valueOfPix(currentTop, resolution); + floatElement.setHeight(FU.valueOfPix(currentBottom, resolution).subtract(floatY1_fu)); + } } else if (cursorType == Cursor.MOVE_CURSOR) { DynamicUnitList columnWidthList = ReportHelper.getColumnWidthList(report); DynamicUnitList rowHeightList = ReportHelper.getRowHeightList(report); @@ -799,6 +849,13 @@ public class GridMouseAdapter implements MouseListener, MouseWheelListener, Mous } else if (cursorType == Cursor.E_RESIZE_CURSOR) { setOld_X_AndOld_Y(floatArray[0], floatArray[1]); } + + if (Cursor.SW_RESIZE_CURSOR <= cursorType && cursorType <= Cursor.E_RESIZE_CURSOR) { + resizingBackupBounds = new int[] { + (int) floatArray[0], (int)floatArray[1], + (int) floatArray[2] - (int) floatArray[0], (int) floatArray[3] - (int) floatArray[1] + }; + } } private void setOld_X_AndOld_Y(double x, double y) { From 8da18889b198a755b0c90c645e231b7fbbaa87e5 Mon Sep 17 00:00:00 2001 From: Starryi Date: Mon, 5 Jul 2021 00:01:53 +0800 Subject: [PATCH 02/14] =?UTF-8?q?REPORT-53175=E3=80=9010.0.18=E3=80=91?= =?UTF-8?q?=E7=BB=84=E4=BB=B6=E8=83=8C=E6=99=AF=E5=88=86=E7=A6=BB=E4=B8=BA?= =?UTF-8?q?=E6=A0=87=E9=A2=98/=E8=83=8C=E6=99=AF/=E8=BE=B9=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 组件样式优化后,期望用户通过组件样式面板中的标题来替换 图表内部的标题,因此新创建的图表组件默认显示组件标题 --- .../designer/creator/XBorderStyleWidgetCreator.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XBorderStyleWidgetCreator.java b/designer-form/src/main/java/com/fr/design/designer/creator/XBorderStyleWidgetCreator.java index e4b5377ba7..d4160ef334 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XBorderStyleWidgetCreator.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XBorderStyleWidgetCreator.java @@ -47,8 +47,16 @@ public class XBorderStyleWidgetCreator extends XWidgetCreator{ public AbstractBorderStyleWidget toData() { return (AbstractBorderStyleWidget) data; } - - protected void initStyle() { + + @Override + protected void addToWrapper(XLayoutContainer parentPanel, int width, int minHeight) { + super.addToWrapper(parentPanel, width, minHeight); + // REPORT-53175: 新创建的图表组件默认显示标题 since 10.0.18 + // 将当前对象添加到父容器后,初始化默认样式的效果 + initStyle(); + } + + protected void initStyle() { BorderPacker style = toData().getBorderStyle(); initBorderStyle(); if (ComparatorUtils.equals(style.getType(), LayoutBorderStyle.TITLE)) { From 9050f236398b2227283db53724d6564c9375d1dd Mon Sep 17 00:00:00 2001 From: Starryi Date: Mon, 5 Jul 2021 00:09:47 +0800 Subject: [PATCH 03/14] =?UTF-8?q?REPORT-53175=20=E3=80=9010.0.18=E3=80=91?= =?UTF-8?q?=E7=BB=84=E4=BB=B6=E8=83=8C=E6=99=AF=E5=88=86=E7=A6=BB=E4=B8=BA?= =?UTF-8?q?=E6=A0=87=E9=A2=98/=E8=83=8C=E6=99=AF/=E8=BE=B9=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 优化样式面板中线型选择下拉列表的显示,原有的渲染方法会导致 显示文字"无"时字体过大(使用了默认字体),超出下拉框的高度从而 被截断,且不支持其他文字选项. 优化后的文字渲染逻辑使用默认的JComboBox的文字渲染方法,即通过 JComboBox内部的JLabel控件渲染文字. 且提供toStringFromStyle 接口方法,将对应的Int类型线型值,转变为可渲染的文本. --- .../fr/design/gui/icombobox/LineComboBox.java | 57 +++++++++---------- 1 file changed, 26 insertions(+), 31 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/gui/icombobox/LineComboBox.java b/designer-base/src/main/java/com/fr/design/gui/icombobox/LineComboBox.java index ca4eddfe3e..65e24a7c3a 100644 --- a/designer-base/src/main/java/com/fr/design/gui/icombobox/LineComboBox.java +++ b/designer-base/src/main/java/com/fr/design/gui/icombobox/LineComboBox.java @@ -3,22 +3,14 @@ */ package com.fr.design.gui.icombobox; -import com.fr.base.FRContext; import com.fr.base.GraphHelper; -import com.fr.base.ScreenResolution; -import com.fr.general.FRFont; import com.fr.stable.Constants; -import java.awt.Component; -import java.awt.Dimension; -import java.awt.Font; -import java.awt.FontMetrics; -import java.awt.Graphics; -import java.awt.Graphics2D; +import com.fr.stable.StringUtils; + +import javax.swing.*; +import java.awt.*; import java.awt.geom.GeneralPath; import java.awt.geom.Point2D; -import javax.swing.DefaultComboBoxModel; -import javax.swing.JLabel; -import javax.swing.JList; /** @@ -59,6 +51,13 @@ public class LineComboBox extends UIComboBox { this.setSelectedItem(new Integer(style)); } + protected String toStringFromStyle(int style) { + if (style == Constants.LINE_NONE) { + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_None"); + } + return null; + } + /** * CellRenderer. */ @@ -67,31 +66,27 @@ public class LineComboBox extends UIComboBox { JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { JLabel comp= (JLabel)super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); this.style = ((Integer) value).intValue(); - comp.setText(null); + String displayString = toStringFromStyle(style); + if (StringUtils.isNotEmpty(displayString)) { + comp.setText(" " + displayString); + } else { + comp.setText(null); + } return comp; } public void paint(Graphics g) { super.paint(g); - Graphics2D g2d = (Graphics2D) g; - - Dimension d = getSize(); - g2d.setColor(getForeground()); - - FRFont font = FRContext.getDefaultValues().getFRFont(); - int resolution = ScreenResolution.getScreenResolution(); - Font rfont = font.applyResolutionNP(resolution); - g2d.setFont(rfont); - FontMetrics fm = GraphHelper.getFontMetrics(rfont); - if (style == Constants.LINE_NONE) { - //draw "none" string - GraphHelper.drawString(g2d, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_None"), 4, (d.height - fm.getHeight()) / 2D + fm.getAscent()); - } else { + if (StringUtils.isEmpty(toStringFromStyle(style))) { + Graphics2D g2d = (Graphics2D) g; + + Dimension d = getSize(); + g2d.setColor(getForeground()); GraphHelper.drawLine(g2d, 4, d.height / 2D, d.width - 8D, d.height / 2D, style); - } - - if(isShowAxisWithLineStyle()) { // 带有坐标轴箭头的样式. - drawArrow(g2d, new Point2D.Double(4, d.height / 2D), new Point2D.Double(d.width - 8D, d.height / 2D)); + + if(isShowAxisWithLineStyle()) { // 带有坐标轴箭头的样式. + drawArrow(g2d, new Point2D.Double(4, d.height / 2D), new Point2D.Double(d.width - 8D, d.height / 2D)); + } } } From 859d2667a378654002106f922b742530b3ccd874 Mon Sep 17 00:00:00 2001 From: "Bruce.Deng" Date: Mon, 5 Jul 2021 10:51:34 +0800 Subject: [PATCH 04/14] =?UTF-8?q?REPORT-52847=20=E3=80=9010.0.18=E3=80=91?= =?UTF-8?q?=E9=83=A8=E5=88=86=E6=95=B0=E6=8D=AE=E8=BF=9E=E6=8E=A5=E6=94=AF?= =?UTF-8?q?=E6=8C=81fetchsize?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/datapane/connect/DBCPAttrPane.java | 138 +++++++++++++++++- .../connect/DatabaseConnectionPane.java | 5 +- .../datapane/connect/JDBCConnectionDef.java | 43 ++++++ .../data/datapane/connect/JDBCDefPane.java | 2 + 4 files changed, 177 insertions(+), 11 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/design/data/datapane/connect/JDBCConnectionDef.java diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/connect/DBCPAttrPane.java b/designer-base/src/main/java/com/fr/design/data/datapane/connect/DBCPAttrPane.java index 01af972931..58a021812c 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/connect/DBCPAttrPane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/connect/DBCPAttrPane.java @@ -1,8 +1,9 @@ package com.fr.design.data.datapane.connect; +import com.fr.base.GraphHelper; import com.fr.data.impl.JDBCDatabaseConnection; import com.fr.data.pool.DBCPConnectionPoolAttr; -import com.fr.design.constants.UIConstants; +import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.BasicPane; import com.fr.design.editor.editor.IntegerEditor; import com.fr.design.gui.icombobox.UIComboBox; @@ -12,14 +13,35 @@ 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 java.awt.BorderLayout; -import java.awt.Component; -import javax.swing.BorderFactory; +import com.fr.general.ComparatorUtils; +import com.fr.stable.StringUtils; + import javax.swing.JPanel; +import javax.swing.JTextField; import javax.swing.SwingConstants; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.Window; +import java.awt.event.InputMethodEvent; +import java.awt.event.InputMethodListener; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.util.HashMap; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; public class DBCPAttrPane extends BasicPane { public static final int TIME_MULTIPLE = 1000; + private static final Pattern FETCHSIZE_PATTERN = Pattern.compile("^0$|^[1-9][\\d]*[\\d]*$");; + private static final Pattern CHAR_NEED_ESCAPE = Pattern.compile("[?|$^*\\\\\\[\\](){}.+]"); + private static final int MAX_FETCHSIZE = 1000000; + private static final Map DEFAULT_FETCHSIZE_MAP = new HashMap<>(); + private static final int ORACLE_DEFAULT_FETCHSIZE = 128; + private static final int DB2_DEFAULT_FETCHSIZE = 50; + private static final int POSTGRE_DEFAULT_FETCHSIZE = 10000; // carl:DBCP的一些属性 private IntegerEditor DBCP_INITIAL_SIZE = new IntegerEditor(); private IntegerEditor DBCP_MAX_ACTIVE = new IntegerEditor(); @@ -36,11 +58,24 @@ public class DBCPAttrPane extends BasicPane { private IntegerEditor DBCP_NUMTESTSPEREVICTIONRUN = new IntegerEditor(); private IntegerEditor DBCP_MINEVICTABLEIDLETIMEMILLIS = new IntegerEditor(); + private UITextField FETCHSIZE = new UITextField(); + + private JPanel defaultPane; + private JPanel northFlowPane; + private JPanel southFlowPane; + + static { + DEFAULT_FETCHSIZE_MAP.put("Oracle", ORACLE_DEFAULT_FETCHSIZE); + DEFAULT_FETCHSIZE_MAP.put("DB2", DB2_DEFAULT_FETCHSIZE); + DEFAULT_FETCHSIZE_MAP.put("Postgre", POSTGRE_DEFAULT_FETCHSIZE); + } + public DBCPAttrPane() { - JPanel defaultPane = this; + defaultPane = this; // JPanel northFlowPane - JPanel northFlowPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane(); + northFlowPane = FRGUIPaneFactory.createTitledBorderPane(Toolkit.i18nText("Fine-Design_Basic_ConnectionPool_Attr")); + northFlowPane.setPreferredSize(new Dimension(630, 320)); defaultPane.add(northFlowPane, BorderLayout.NORTH); DBCP_VALIDATION_QUERY.setColumns(15); @@ -67,7 +102,6 @@ public class DBCPAttrPane extends BasicPane { DBCP_MINEVICTABLEIDLETIMEMILLIS}}; JPanel contextPane = TableLayoutHelper.createGapTableLayoutPane(comps, rowSize, columnSize, 10, 4); - contextPane.setBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, UIConstants.LINE_COLOR)); northFlowPane.add(contextPane); } @@ -89,6 +123,10 @@ public class DBCPAttrPane extends BasicPane { this.DBCP_MINEVICTABLEIDLETIMEMILLIS.setValue(dbcpAttr.getMinEvictableIdleTimeMillis() / TIME_MULTIPLE); this.DBCP_NUMTESTSPEREVICTIONRUN.setValue(dbcpAttr.getNumTestsPerEvictionRun()); this.DBCP_TIMEBETWEENEVICTIONRUNSMILLS.setValue(dbcpAttr.getTimeBetweenEvictionRunsMillis()); + Integer fetchSize = DEFAULT_FETCHSIZE_MAP.get(JDBCConnectionDef.getInstance().getDatabaseName()); + if (fetchSize != null) { + this.FETCHSIZE.setText(jdbcDatabase.getFetchSize() == -1 ? String.valueOf(fetchSize) : String.valueOf(jdbcDatabase.getFetchSize())); + } } public void update(JDBCDatabaseConnection jdbcDatabase) { @@ -109,10 +147,94 @@ public class DBCPAttrPane extends BasicPane { dbcpAttr.setMinEvictableIdleTimeMillis(((Number) this.DBCP_MINEVICTABLEIDLETIMEMILLIS.getValue()).intValue() * TIME_MULTIPLE); dbcpAttr.setNumTestsPerEvictionRun(((Number) this.DBCP_NUMTESTSPEREVICTIONRUN.getValue()).intValue()); dbcpAttr.setTimeBetweenEvictionRunsMillis(((Number) this.DBCP_TIMEBETWEENEVICTIONRUNSMILLS.getValue()).intValue()); + Integer fetchSize = DEFAULT_FETCHSIZE_MAP.get(JDBCConnectionDef.getInstance().getDatabaseName()); + if (fetchSize != null) { + jdbcDatabase.setFetchSize(Integer.parseInt(this.FETCHSIZE.getText())); + } + } + + @Override + public BasicDialog showWindow(Window window) { + String databaseName = JDBCConnectionDef.getInstance().getDatabaseName(); + if (showOtherConfig(databaseName)) { + southFlowPane = FRGUIPaneFactory.createTitledBorderPane(Toolkit.i18nText("Fine-Design_Report_Other")); + southFlowPane.setPreferredSize(new Dimension(630, 200)); + double f = TableLayout.FILL; + double[] rowSize = {f}; + double otherColumnSize = GraphHelper.getWidth(Toolkit.i18nText("Fine-Design_Basic_Connection_Pool_Evictionruns_millis")) + 6; + double[] columnSize = {otherColumnSize, otherColumnSize}; + FETCHSIZE.addKeyListener(fetchSizeKeyListener); + FETCHSIZE.addInputMethodListener(fetchSizeInputMethodListener); + FETCHSIZE.setHorizontalAlignment(JTextField.RIGHT); + Component[][] comps = { + {new UILabel("Fetchsize:", SwingConstants.RIGHT), FETCHSIZE} + }; + JPanel otherConfigPane = TableLayoutHelper.createGapTableLayoutPane(comps, rowSize, columnSize, 10, 4); + southFlowPane.add(otherConfigPane); + + defaultPane.removeAll(); + defaultPane.add(northFlowPane, BorderLayout.NORTH); + defaultPane.add(southFlowPane, BorderLayout.SOUTH); + } else { + if (southFlowPane != null) { + defaultPane.remove(southFlowPane); + } + } + return this.showWindow(window, null); + } + + private boolean showOtherConfig(Object dbType) { + return ComparatorUtils.equals(dbType, "Oracle") || ComparatorUtils.equals(dbType, "DB2") || ComparatorUtils.equals(dbType, "Postgre"); + } + + KeyListener fetchSizeKeyListener = new KeyAdapter() { + @Override + public void keyReleased(KeyEvent e) { + String fetchSize = FETCHSIZE.getText(); + if (!isFetchSizeValid(fetchSize)) { + FETCHSIZE.setText(fetchSize.replaceAll(getCharNeedReplace(e.getKeyChar()), "")); + if (!isFetchSizeValid(FETCHSIZE.getText())) { + FETCHSIZE.setText(StringUtils.EMPTY); + } + } else if (FETCHSIZE.getText().length() > String.valueOf(MAX_FETCHSIZE).length() || Long.parseLong(FETCHSIZE.getText()) > MAX_FETCHSIZE) { + FETCHSIZE.setText(String.valueOf(MAX_FETCHSIZE)); + } + } + }; + + InputMethodListener fetchSizeInputMethodListener = new InputMethodListener() { + @Override + public void inputMethodTextChanged(InputMethodEvent event) { + if (null == event.getText()) { + return; + } + char ch = event.getText().current(); + if (!(ch >= '0' && ch <= '9')) { + event.consume(); + } + } + + @Override + public void caretPositionChanged(InputMethodEvent event) { + + } + }; + + private boolean isFetchSizeValid(String fetchSize) { + return FETCHSIZE_PATTERN.matcher(fetchSize).find(); + } + + private String getCharNeedReplace(char c) { + String charNeedReplace = c + ""; + Matcher matcher = CHAR_NEED_ESCAPE.matcher(charNeedReplace); + if (matcher.find()) { + charNeedReplace = "\\" + charNeedReplace; + } + return charNeedReplace; } @Override protected String title4PopupWindow() { - return Toolkit.i18nText("Fine-Design_Basic_ConnectionPool_Attr"); + return Toolkit.i18nText("Fine-Design_Basic_Advanced_Setup"); } } diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/connect/DatabaseConnectionPane.java b/designer-base/src/main/java/com/fr/design/data/datapane/connect/DatabaseConnectionPane.java index f3a97ffb1c..e55aaa2dd4 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/connect/DatabaseConnectionPane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/connect/DatabaseConnectionPane.java @@ -12,7 +12,6 @@ import com.fr.data.solution.entity.DriverPage; import com.fr.data.solution.processor.ClassNotFoundExceptionSolutionProcessor; import com.fr.data.solution.processor.SolutionProcessor; import com.fr.design.beans.BasicBeanPane; -import com.fr.design.dialog.BasicPane; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.ilable.ActionLabel; @@ -338,7 +337,7 @@ public abstract class DatabaseConnectionPane Date: Mon, 5 Jul 2021 13:55:29 +0800 Subject: [PATCH 05/14] =?UTF-8?q?REPORT-54116=20=E8=AE=BE=E8=AE=A1?= =?UTF-8?q?=E5=99=A8=E7=BB=9D=E5=AF=B9=E5=B8=83=E5=B1=80=E5=86=85=E5=8F=AF?= =?UTF-8?q?=E9=94=81=E5=AE=9A=E7=BB=84=E4=BB=B6=E5=AE=BD=E9=AB=98=E6=AF=94?= =?UTF-8?q?=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在已展示Shift锁定尺寸比例提示信息后,下次打开不再提示该信息 --- .../design/designer/beans/location/AccessDirection.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/location/AccessDirection.java b/designer-form/src/main/java/com/fr/design/designer/beans/location/AccessDirection.java index 8cdca27f61..be44eae817 100644 --- a/designer-form/src/main/java/com/fr/design/designer/beans/location/AccessDirection.java +++ b/designer-form/src/main/java/com/fr/design/designer/beans/location/AccessDirection.java @@ -3,6 +3,8 @@ */ package com.fr.design.designer.beans.location; +import com.fr.config.ServerPreferenceConfig; +import com.fr.config.utils.ConfigReadUtils; import com.fr.design.beans.location.Absorptionline; import com.fr.design.beans.location.MoveUtils; import com.fr.design.designer.creator.*; @@ -193,7 +195,11 @@ public abstract class AccessDirection implements Direction { if (type != formEditor.getCursor().getType()) { // 设置当前形状 formEditor.setCursor(Cursor.getPredefinedCursor(type)); - formEditor.setToolTipText(getTooltip()); + ServerPreferenceConfig config = ServerPreferenceConfig.getInstance(); + if (!config.isHasShownLockedAspectRatioResizingToolTip()) { + formEditor.setToolTipText(getTooltip()); + config.setHasShownLockedAspectRatioResizingToolTip(true); + } } } From f2e7401bda33cb554f70899d4acd72ee5b7050d9 Mon Sep 17 00:00:00 2001 From: "Henry.Wang" Date: Mon, 5 Jul 2021 14:17:03 +0800 Subject: [PATCH 06/14] =?UTF-8?q?REPORT-54716=20=E5=86=B3=E7=AD=96?= =?UTF-8?q?=E6=8A=A5=E8=A1=A8=E4=B8=AD=E4=BF=AE=E6=94=B9=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E5=90=8D=E4=B8=BA=E5=A4=A7=E5=86=99=EF=BC=8C=E6=8F=90=E7=A4=BA?= =?UTF-8?q?=E9=87=8D=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mainframe/widget/ui/FormWidgetCardPane.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormWidgetCardPane.java b/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormWidgetCardPane.java index 4ab3fdb74a..debc5ae875 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormWidgetCardPane.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormWidgetCardPane.java @@ -86,7 +86,7 @@ public class FormWidgetCardPane extends AbstractAttrNoScrollPane { return null; } else if (xLayoutContainer.acceptType(XWAbsoluteLayout.class)) { return new WidgetAbsoluteBoundPane(xCreator); - } else if(xCreator.acceptType(XWCardTagLayout.class)){ + } else if (xCreator.acceptType(XWCardTagLayout.class)) { return new WidgetCardTagBoundPane(xCreator); } return new WidgetBoundPane(xCreator); @@ -231,7 +231,14 @@ public class FormWidgetCardPane extends AbstractAttrNoScrollPane { UITextField widgetNameField = widgetPropertyPane.getWidgetNameField(); String toSetWidgetName = widgetNameField.getText(); String currentWidgetName = widget.getWidgetName(); - boolean exist = designer.getTarget().isNameExist(toSetWidgetName) && !ComparatorUtils.equals(toSetWidgetName, currentWidgetName); + boolean isNameExist = false; + Widget tempWidget = designer.getTarget().getWidgetByName(toSetWidgetName); + if (!ComparatorUtils.equals(widget, tempWidget)) { + isNameExist = true; + } else if (ComparatorUtils.equals(toSetWidgetName, tempWidget.getWidgetName())) { + isNameExist = true; + } + boolean exist = isNameExist && !ComparatorUtils.equals(toSetWidgetName, currentWidgetName); if (toSetWidgetName.isEmpty()) { widgetNameField.setText(currentWidgetName); return; From f4e67a6b149c91406aa40ee8ba43a9228cd6a38c Mon Sep 17 00:00:00 2001 From: "Henry.Wang" Date: Mon, 5 Jul 2021 14:36:59 +0800 Subject: [PATCH 07/14] =?UTF-8?q?REPORT-54716=20=E5=86=B3=E7=AD=96?= =?UTF-8?q?=E6=8A=A5=E8=A1=A8=E4=B8=AD=E4=BF=AE=E6=94=B9=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E5=90=8D=E4=B8=BA=E5=A4=A7=E5=86=99=EF=BC=8C=E6=8F=90=E7=A4=BA?= =?UTF-8?q?=E9=87=8D=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/mainframe/widget/ui/FormWidgetCardPane.java | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormWidgetCardPane.java b/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormWidgetCardPane.java index debc5ae875..2fc161fc0a 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormWidgetCardPane.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormWidgetCardPane.java @@ -231,14 +231,7 @@ public class FormWidgetCardPane extends AbstractAttrNoScrollPane { UITextField widgetNameField = widgetPropertyPane.getWidgetNameField(); String toSetWidgetName = widgetNameField.getText(); String currentWidgetName = widget.getWidgetName(); - boolean isNameExist = false; - Widget tempWidget = designer.getTarget().getWidgetByName(toSetWidgetName); - if (!ComparatorUtils.equals(widget, tempWidget)) { - isNameExist = true; - } else if (ComparatorUtils.equals(toSetWidgetName, tempWidget.getWidgetName())) { - isNameExist = true; - } - boolean exist = isNameExist && !ComparatorUtils.equals(toSetWidgetName, currentWidgetName); + boolean exist = designer.getTarget().isNameExist(toSetWidgetName, widget) && !ComparatorUtils.equals(toSetWidgetName, currentWidgetName); if (toSetWidgetName.isEmpty()) { widgetNameField.setText(currentWidgetName); return; From f583095eca6e20206cea2f55e8abdb9dcae738bb Mon Sep 17 00:00:00 2001 From: Starryi Date: Mon, 5 Jul 2021 14:06:58 +0800 Subject: [PATCH 08/14] =?UTF-8?q?REPORT-53175=E3=80=9010.0.18=E3=80=91?= =?UTF-8?q?=E7=BB=84=E4=BB=B6=E8=83=8C=E6=99=AF=E5=88=86=E7=A6=BB=E4=B8=BA?= =?UTF-8?q?=E6=A0=87=E9=A2=98/=E8=83=8C=E6=99=AF/=E8=BE=B9=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 设计器组件样式设置直接在设计器右侧栏展示 2. 设计器组件标题样式支持背景图片,图文混排 3. 设计器组件样式主体样式支持边框图片(点九图) 4. 标题样式背景填充,边框图片,主体背景填充支持透明度 --- .../design/gui/frpane/UIPercentDragPane.java | 30 + .../fr/design/gui/style/BackgroundPane.java | 10 +- .../backgroundpane/ImagePreviewPane.java | 23 +- .../buttonicon/icon_border_image_help.png | Bin 0 -> 468 bytes .../images/buttonicon/icon_choose_inset.png | Bin 0 -> 280 bytes .../images/buttonicon/icon_delete_inset.png | Bin 0 -> 147 bytes .../buttonicon/icon_inset_both_selected.png | Bin 0 -> 145 bytes .../buttonicon/icon_inset_both_unselected.png | Bin 0 -> 141 bytes .../buttonicon/icon_inset_left_selected.png | Bin 0 -> 155 bytes .../buttonicon/icon_inset_left_unselected.png | Bin 0 -> 141 bytes .../buttonicon/icon_inset_right_selected.png | Bin 0 -> 140 bytes .../icon_inset_right_unselected.png | Bin 0 -> 136 bytes .../design/images/transparent_background.jpg | Bin 0 -> 24869 bytes .../creator/XBorderStyleWidgetCreator.java | 6 + .../fr/design/designer/creator/XLabel.java | 14 +- .../gui/xpane/BorderLineAndImagePane.java | 598 ++++++++++++++++++ .../gui/xpane/CardTagLayoutStylePane.java | 27 + .../fr/design/gui/xpane/LayoutStylePane.java | 502 +++++++++++++++ .../design/gui/xpane/TitleInsetImagePane.java | 258 ++++++++ .../widget/ui/FormWidgetCardPane.java | 10 +- .../layout/BorderStyleWidgetDefinePane.java | 14 +- .../FRAbsoluteBodyLayoutDefinePane.java | 91 +-- .../layout/FRFitLayoutDefinePane.java | 93 +-- .../layout/WCardMainLayoutDefinePane.java | 13 +- .../layout/WTitleLayoutDefinePane.java | 36 +- 25 files changed, 1585 insertions(+), 140 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/design/gui/frpane/UIPercentDragPane.java create mode 100644 designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_border_image_help.png create mode 100644 designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_choose_inset.png create mode 100644 designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_delete_inset.png create mode 100644 designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_inset_both_selected.png create mode 100644 designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_inset_both_unselected.png create mode 100644 designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_inset_left_selected.png create mode 100644 designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_inset_left_unselected.png create mode 100644 designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_inset_right_selected.png create mode 100644 designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_inset_right_unselected.png create mode 100644 designer-base/src/main/resources/com/fr/design/images/transparent_background.jpg create mode 100644 designer-form/src/main/java/com/fr/design/gui/xpane/BorderLineAndImagePane.java create mode 100644 designer-form/src/main/java/com/fr/design/gui/xpane/CardTagLayoutStylePane.java create mode 100644 designer-form/src/main/java/com/fr/design/gui/xpane/LayoutStylePane.java create mode 100644 designer-form/src/main/java/com/fr/design/gui/xpane/TitleInsetImagePane.java diff --git a/designer-base/src/main/java/com/fr/design/gui/frpane/UIPercentDragPane.java b/designer-base/src/main/java/com/fr/design/gui/frpane/UIPercentDragPane.java new file mode 100644 index 0000000000..1dd96de00a --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/gui/frpane/UIPercentDragPane.java @@ -0,0 +1,30 @@ +package com.fr.design.gui.frpane; + +import com.fr.design.gui.ilable.UILabel; + +import javax.swing.*; +import java.awt.*; + +/** + * @author Starryi + * @version 10.0.18 + * Created by Starryi on 2021/7/3 + */ +public class UIPercentDragPane extends JPanel { + + private final UINumberDragPane dragPane = new UINumberDragPane(0, 100, 1); + + public UIPercentDragPane() { + setLayout(new BorderLayout()); + add(dragPane, BorderLayout.CENTER); + add(new UILabel(" %"), BorderLayout.EAST); + } + + public void populateBean(double value) { + dragPane.populateBean(value * 100); + } + + public double updateBean() { + return dragPane.updateBean() * 100; + } +} diff --git a/designer-base/src/main/java/com/fr/design/gui/style/BackgroundPane.java b/designer-base/src/main/java/com/fr/design/gui/style/BackgroundPane.java index 13dd9e3c9d..bdf96f32e3 100644 --- a/designer-base/src/main/java/com/fr/design/gui/style/BackgroundPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/style/BackgroundPane.java @@ -70,13 +70,13 @@ public class BackgroundPane extends AbstractBasicStylePane { double f = TableLayout.FILL; double p = TableLayout.PREFERRED; Component[][] components = new Component[][]{ - new Component[]{null, null}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Fill") + " ", SwingConstants.LEFT),typeComboBox}, - new Component[]{null, centerPane} + new Component[]{null}, + new Component[]{typeComboBox}, + new Component[]{centerPane} }; double[] rowSize = {p, p, p}; - double[] columnSize = {p,f}; - int[][] rowCount = {{1, 1},{1, 1},{1, 1}}; + double[] columnSize = {f}; + int[][] rowCount = {{1},{1},{1}}; JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_LARGE, LayoutConstants.VGAP_MEDIUM); this.add(panel, BorderLayout.CENTER); diff --git a/designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/ImagePreviewPane.java b/designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/ImagePreviewPane.java index 24b3ebfc42..10629de029 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/ImagePreviewPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/ImagePreviewPane.java @@ -52,8 +52,15 @@ public class ImagePreviewPane extends JComponent implements Scrollable, ImagePre private boolean isLoading = false; public ImagePreviewPane() { - sizeLabel = new UILabel(); - this.add(sizeLabel); + this(true); + } + + public ImagePreviewPane(boolean showSizeLabel) { + if (showSizeLabel) { + sizeLabel = new UILabel(); + this.add(sizeLabel); + } + this.setBorder(BorderFactory.createEmptyBorder(10, 10, 20, 10)); this.setLayout(new BorderLayout()); this.add(new JPanel() { @@ -117,7 +124,9 @@ public class ImagePreviewPane extends JComponent implements Scrollable, ImagePre ((JViewport) this.getParent()).setMinimumSize(newDimension); ((JViewport) this.getParent()).setMaximumSize(newDimension); } - sizeLabel.setText(null); + if (sizeLabel != null) { + sizeLabel.setText(null); + } } else { isLoading = false; // wait for the size of image. @@ -128,10 +137,14 @@ public class ImagePreviewPane extends JComponent implements Scrollable, ImagePre int totalwidth = ImagePreviewPane.this.getWidth(); int totalheight = ImagePreviewPane.this.getHeight(); String text = imageWidth + "x" + imageHeight; - sizeLabel.setText(text); + if (sizeLabel != null) { + sizeLabel.setText(text); + } FontMetrics cellFM = this.getFontMetrics(getFont()); int width = cellFM.stringWidth(text); - sizeLabel.setBounds(totalwidth - width - LABEL_DELTA_X, totalheight - LABEL_DELTA_Y, width, LABEL_HEIGHT); + if (sizeLabel != null) { + sizeLabel.setBounds(totalwidth - width - LABEL_DELTA_X, totalheight - LABEL_DELTA_Y, width, LABEL_HEIGHT); + } } fireChangeListener(); this.revalidate(); diff --git a/designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_border_image_help.png b/designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_border_image_help.png new file mode 100644 index 0000000000000000000000000000000000000000..89a12190b6b73a804c87d2440b2450d52364ba90 GIT binary patch literal 468 zcmV;_0W1EAP)H(Lx210C#EU2YVozSg-)-#Z*q{jN^q?XLqRy>d5=pyA zokhX*(!Az>fAMh;^!Ln%F!ajjNM zb-Voygv6zc8G}o2Z;2DvJqj!lLbiM#J~@u%27pp&Z5sgGw(a9~2&|?75ZH0fuVuWt zx>n#Ed^8&7RhYk-1;EeRws|lB7`vW_&zjAX=V9-aN@d#fc-i+cRriI$#+0u6Rok}q zeg!Bo#;{?U=7WOA0KQvLiDB2VR_C0J&Y14zItY-=?#G0K9w zA&|x`m;c|){9!;HA3FNU3kbuo7X-mU3K(PNWm!I5#hifJd}OAHm;gE(V`eVM55O|_ z0lEu-nFatoT#z3?6eUxDw?sS!kiG$&65+y(RZ(Oodz8iy<2c@lSZlrXh5aW0rPK%j zYpt(#tG*FzeKmql*yg_xpj5Jv0(qXTeVsJ|e97CLeF4lo1aNC}8y~H#w*u6mEZUeY e&0a$9e2p(fMtTuu{8=af0000$zN{#U|Pe@ihwI$821Rzjy9V0 wfZ63#`2nvh_nV_@pWoiiwtW6e)=ehNFKwm>nzQeF0knm|)78&qol`;+0D4z8LjV8( literal 0 HcmV?d00001 diff --git a/designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_inset_both_selected.png b/designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_inset_both_selected.png new file mode 100644 index 0000000000000000000000000000000000000000..018fa1257d88e057db9675b637cd0ee29aadf138 GIT binary patch literal 145 zcmeAS@N?(olHy`uVBq!ia0vp^fYnuYxoZfBr%tDNI2yj sc=VMovaM%XL{Gxu6Aee$bT(NrtTPN&Ja*}DInWLUPgg&ebxsLQ08%S27XSbN literal 0 HcmV?d00001 diff --git a/designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_inset_both_unselected.png b/designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_inset_both_unselected.png new file mode 100644 index 0000000000000000000000000000000000000000..3a822ba8b245620614da89189048ef11a511c648 GIT binary patch literal 141 zcmeAS@N?(olHy`uVBq!ia0vp^fscq8isq@DZ(4FCQ9UT@0G?98F8%wfDv^_qZ4?Ta=6=?%_D1Xi_h pMz-}Vi|9!>e4^n9o6aUHhMCV(J~CzQcmp(_!PC{xWt~$(696oBF5dtE literal 0 HcmV?d00001 diff --git a/designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_inset_left_selected.png b/designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_inset_left_selected.png new file mode 100644 index 0000000000000000000000000000000000000000..b34a287048004a051da7f1f85b725e534e152b2b GIT binary patch literal 155 zcmeAS@N?(olHy`uVBq!ia0vp^f;M1& literal 0 HcmV?d00001 diff --git a/designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_inset_left_unselected.png b/designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_inset_left_unselected.png new file mode 100644 index 0000000000000000000000000000000000000000..7e8696b97809fe6e670c06178844cc9aabc295f5 GIT binary patch literal 141 zcmeAS@N?(olHy`uVBq!ia0vp^fm5(#_&zU&!qnc0M1Zk%%gT}p|fik`S{~P}>G-@(zopr0QICZ!T7<`n^ZoYyFBm)x@Dzp+6~VoJh}MW+gUr>`-PRB8)Q o^;wa0BBP6yT{%)y%$A9P<+rzB!o+P4fyOgucw_4(NIB(wSWwX(;r#Fa|Mh?W+aDHna}!9rqN?rF)}a`}DZEO; kXjam}gC1dBuKf%QdwIhJQ#0zafJQTTy85}Sb4q9e0015>>i_@% literal 0 HcmV?d00001 diff --git a/designer-base/src/main/resources/com/fr/design/images/transparent_background.jpg b/designer-base/src/main/resources/com/fr/design/images/transparent_background.jpg new file mode 100644 index 0000000000000000000000000000000000000000..b04da96ea64527351d96ba579a8195ffa940a785 GIT binary patch literal 24869 zcmeI)KS&!<9KiASJk6go*W@5tjL3zkZK!pSYNHVwF*UYs6%i^3LJJkUYnOtHQbZ{2 zE?B#iwsw#@>7e4EOL0*AQ(ElSC9OjzmouldHlvUe zXYOZ&lu``lUc&w=(!%fY`n(>$&+F55f2mO(Gy(ymGF%oak5=oI#|n>qfwc1cQ-8tyP;i_hK&#()PBIDjB{rvDlt{ zSn=&g_s6MUhqHAL{xt2&{+Dk)ZMODhMxXV3sBT?~Pi{RoM#lOWm_woBzoO&xY#Qt2 zY+>SH4lN`n(Gz>_6=Ms`a>Y@|i!ab(rY_`6O+@i81_CV=qX5EW_cI2d1zMoxO5zT* zK#Sb28)#GSTA&45paoi>#mz}*sI-REw8-MAoyBvlNuNjyTa>n?-L0GCK?}4%i$)9@F=)h~ z5rakyG*nwdA}t~E+QPZNPg@#INNP3WfNbP`#nid2oO@M2qC)WlBEzkn3 bi>hg@_j_)iJ(`_&f1iG@=8=f5NPF)X8B;4H literal 0 HcmV?d00001 diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XBorderStyleWidgetCreator.java b/designer-form/src/main/java/com/fr/design/designer/creator/XBorderStyleWidgetCreator.java index d4160ef334..e174c122f3 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XBorderStyleWidgetCreator.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XBorderStyleWidgetCreator.java @@ -129,6 +129,12 @@ public class XBorderStyleWidgetCreator extends XWidgetCreator{ title.setFont(wTitle.getFrFont()); title.setTextalign(wTitle.getPosition()); title.setBackground(wTitle.getBackground()); + title.setBackgroundOpacity(wTitle.getBackgroundOpacity()); + + title.setInsetImage(wTitle.getInsetImage()); + title.setInsetImagePadding(wTitle.getInsetImagePadding()); + title.setInsetRelativeTextLeft(wTitle.isInsetRelativeTextLeft()); + title.setInsetRelativeTextRight(wTitle.isInsetRelativeTextRight()); } private WidgetValue getTitleValue(TitlePacker wTitle){ diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XLabel.java b/designer-form/src/main/java/com/fr/design/designer/creator/XLabel.java index df2252c7af..154091a296 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XLabel.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XLabel.java @@ -5,6 +5,7 @@ package com.fr.design.designer.creator; import com.fr.base.BaseUtils; import com.fr.base.Style; +import com.fr.base.background.ImageBackground; import com.fr.design.border.UIRoundedBorder; import com.fr.design.form.util.FontTransformUtil; import com.fr.design.form.util.XCreatorConstants; @@ -17,6 +18,7 @@ import com.fr.design.mainframe.widget.renderer.LabelHorizontalAlignmentRenderer; import com.fr.form.ui.Label; import com.fr.form.ui.container.WParameterLayout; +import com.fr.general.Background; import com.fr.stable.ArrayUtils; import com.fr.stable.Constants; import com.fr.stable.core.PropertyChangeAdapter; @@ -94,10 +96,18 @@ public class XLabel extends XWidgetCreator { } if (label.getWidgetValue() != null) { Graphics2D g2d = (Graphics2D) g.create(); - BaseUtils.drawStringStyleInRotation(g2d, this.getWidth(), this.getHeight(), label.getWidgetValue() - .toString(), Style.getInstance(label.getFont()).deriveHorizontalAlignment(label.getTextalign()) + + Background inset = label.getInsetImage(); + Image insetImage = inset instanceof ImageBackground ? ((ImageBackground) inset).getImage() : null; + + BaseUtils.drawStringStyleInRotation(g2d, + this.getWidth(), this.getHeight(), + label.getWidgetValue().toString(), + Style.getInstance(label.getFont()) + .deriveHorizontalAlignment(label.getTextalign()) .deriveVerticalAlignment(label.isVerticalCenter() ? SwingConstants.CENTER : SwingConstants.TOP) .deriveTextStyle(label.isWrap() ? Style.TEXTSTYLE_WRAPTEXT : Style.TEXTSTYLE_SINGLELINE), + insetImage, label.getInsetImagePadding(), label.isInsetRelativeTextLeft(), label.isInsetRelativeTextRight(), FontTransformUtil.getDesignerFontResolution()); } diff --git a/designer-form/src/main/java/com/fr/design/gui/xpane/BorderLineAndImagePane.java b/designer-form/src/main/java/com/fr/design/gui/xpane/BorderLineAndImagePane.java new file mode 100644 index 0000000000..67eb8c1ae5 --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/gui/xpane/BorderLineAndImagePane.java @@ -0,0 +1,598 @@ +package com.fr.design.gui.xpane; + +import com.fr.base.GraphHelper; +import com.fr.base.Style; +import com.fr.base.Utils; +import com.fr.base.background.ImageBackground; +import com.fr.base.background.ImageFileBackground; +import com.fr.design.border.UIRoundedBorder; +import com.fr.design.constants.UIConstants; +import com.fr.design.designer.IntervalConstants; +import com.fr.design.dialog.BasicDialog; +import com.fr.design.dialog.BasicPane; +import com.fr.design.dialog.DialogActionAdapter; +import com.fr.design.event.UIObserver; +import com.fr.design.event.UIObserverListener; +import com.fr.design.gui.frpane.ImgChooseWrapper; +import com.fr.design.gui.frpane.UIPercentDragPane; +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.gui.ibutton.UIButtonUI; +import com.fr.design.gui.ibutton.UIColorButton; +import com.fr.design.gui.icombobox.LineComboBox; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.itooltip.UIToolTip; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.layout.TableLayout; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.mainframe.DesignerContext; +import com.fr.design.mainframe.backgroundpane.ImagePreviewPane; +import com.fr.design.style.background.image.ImageFileChooser; +import com.fr.form.ui.LayoutBorderStyle; +import com.fr.general.Background; +import com.fr.general.IOUtils; +import com.fr.stable.Constants; +import com.fr.stable.GraphDrawHelper; +import com.fr.stable.StringUtils; + +import javax.swing.*; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import javax.swing.plaf.basic.BasicButtonUI; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.awt.event.MouseMotionListener; +import java.awt.geom.RoundRectangle2D; +import java.awt.image.BufferedImage; +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; + +/** + * @author Starryi + * @version 10.0.18 + * Created by Starryi on 2021/7/2 + * + * 可配置图片类型边框的样式设置面板 + */ +public class BorderLineAndImagePane extends JPanel implements UIObserver { + private final int SETTING_LABEL_WIDTH = 60; + private final Style DEFAULT_IMAGE_LAYOUT_STYLE = Style.DEFAULT_STYLE.deriveImageLayout(Constants.IMAGE_DEFAULT); + private final String TWEAK_NINE_POINT_HELP_URL = ""; + + private UIObserverListener uiObserverListener; + + private BorderLineAndImageComboBox borderLineCombo; + private UIColorButton borderColorPane; + private ImagePreviewPane imagePreviewPane; + private UIButton chooseImageButton; + private UIButton tweakNinePointHelpButton; + private UIButton tweakNinePointButton; + private UIPercentDragPane borderImageOpacityPane; + + private NinePointImageTweakDialogPane tweakPane; + private ImageFileChooser imageFileChooser; + + private int ninePointLeft = -1; + private int ninePointTop = -1; + private int ninePointRight = -1; + private int ninePointBottom = -1; + + public BorderLineAndImagePane() { + this.initComponents(); + this.initLayout(); + } + + private void initComponents() { + borderLineCombo = new BorderLineAndImageComboBox(); + borderColorPane = new UIColorButton(null) {{ + setUI(createButtonUI(this)); + set4ToolbarButton(); + }}; + imagePreviewPane = new ImagePreviewPane() {{ + setImageStyle(Style.DEFAULT_STYLE); + }}; + chooseImageButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Image_Select_Picture")); + + tweakNinePointHelpButton = new UIButton(IOUtils.readIcon("/com/fr/design/images/buttonicon/icon_border_image_help.png")); + tweakNinePointHelpButton.setUI(new BasicButtonUI()); + tweakNinePointHelpButton.setBorderPainted(false); + tweakNinePointHelpButton.setBorder(null); + tweakNinePointHelpButton.setContentAreaFilled(false); + tweakNinePointHelpButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + Desktop desktop = Desktop.getDesktop(); + try { + desktop.browse(new URI(TWEAK_NINE_POINT_HELP_URL)); + } catch (IOException | URISyntaxException ioException) { + ioException.printStackTrace(); + } + } + }); + + tweakNinePointButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Border_Image_Config_Nine_Point_Fill")); + borderImageOpacityPane = new UIPercentDragPane(); + } + + private JPanel createBorderLineComposedPane() { + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + double[] rowSize = {p}; + double[] columnSize = {SETTING_LABEL_WIDTH, f}; + + return TableLayoutHelper.createGapTableLayoutPane( + new JComponent[][]{{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Border_Line")), this.borderLineCombo}}, + rowSize, columnSize, IntervalConstants.INTERVAL_L1, 0); + } + + private JPanel createBorderColorComposedPane() { + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + double[] rowSize = {p}; + double[] columnSize = {SETTING_LABEL_WIDTH, f}; + + return TableLayoutHelper.createGapTableLayoutPane( + new JComponent[][]{{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Border_Color")), this.borderColorPane}}, + rowSize, columnSize, IntervalConstants.INTERVAL_L1, 0); + } + + private JPanel createBorderImageComposePane() { + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + double[] rowSize = {p, p, p}; + double[] columnSize = {SETTING_LABEL_WIDTH, f}; + + JPanel borderedImagePreviewPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + borderedImagePreviewPane.setBorder(new UIRoundedBorder(UIConstants.LINE_COLOR, 1, 5)); + borderedImagePreviewPane.setPreferredSize(new Dimension(145, 145)); + borderedImagePreviewPane.add(imagePreviewPane, BorderLayout.CENTER); + + JPanel tweakNinePointComposedPane = new JPanel(); + tweakNinePointComposedPane.setLayout(new FlowLayout(FlowLayout.RIGHT, 0, 0)); + tweakNinePointButton.setPreferredSize(new Dimension(145, 16)); + tweakNinePointComposedPane.add(tweakNinePointHelpButton); + tweakNinePointComposedPane.add(tweakNinePointButton); + + return TableLayoutHelper.createGapTableLayoutPane( + new JComponent[][]{ + {null, borderedImagePreviewPane}, + {null, chooseImageButton}, + {tweakNinePointComposedPane, null}, + {null, new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget-Style_Alpha"))}, + {null, this.borderImageOpacityPane} + }, + rowSize, columnSize, IntervalConstants.INTERVAL_L1, IntervalConstants.INTERVAL_L1); + } + + private void initImageFileChooserIfNotExist() { + if (imageFileChooser == null) { + imageFileChooser = new ImageFileChooser(); + imageFileChooser.setMultiSelectionEnabled(false); + } + } + + protected void initNinePointTweakPaneIfNotExist() { + if (tweakPane == null) { + tweakPane = new NinePointImageTweakDialogPane(); + } + } + + private void initLayout() { + this.setLayout(new BorderLayout(0, IntervalConstants.INTERVAL_L1)); + + this.add(this.createBorderLineComposedPane(), BorderLayout.NORTH, 0); + this.add(this.createBorderColorComposedPane(), BorderLayout.CENTER, 1); + this.add(this.createBorderImageComposePane(), BorderLayout.SOUTH, 2); + + getComponent(1).setVisible(false); + getComponent(2).setVisible(false); + + this.borderLineCombo.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + getComponent(1).setVisible(borderLineCombo.isSelectedBorderLine()); + getComponent(2).setVisible(borderLineCombo.isSelectedBorderImage()); + + if (!borderLineCombo.isSelectedBorderLine()) { + borderColorPane.setColor(Color.BLACK); + } + if (!borderLineCombo.isSelectedBorderImage()) { + imagePreviewPane.setImageWithSuffix(null); + } + + fireStateChanged(); + } + }); + this.chooseImageButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + initImageFileChooserIfNotExist(); + + int returnVal = imageFileChooser.showOpenDialog(DesignerContext.getDesignerFrame()); + ImgChooseWrapper.getInstance(imagePreviewPane, imageFileChooser, DEFAULT_IMAGE_LAYOUT_STYLE, new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + Image image = imagePreviewPane.getImage(); + ninePointLeft = ninePointRight = (image != null ? image.getWidth(null) / 3 : -1); + ninePointTop = ninePointBottom = (image != null ? image.getHeight(null) / 3 : -1); + borderImageOpacityPane.populateBean(1.0); + + fireStateChanged(); + } + }).dealWithImageFile(returnVal); + } + }); + this.tweakNinePointButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + initNinePointTweakPaneIfNotExist(); + + if (imagePreviewPane.getImage() != null) { + BasicDialog dialog = tweakPane.showWindow(SwingUtilities.getWindowAncestor(BorderLineAndImagePane.this)); + dialog.addDialogActionListener(new DialogActionAdapter() { + @Override + public void doOk() { + fireStateChanged(); + } + }); + dialog.setVisible(true); + } + } + }); + } + + public void populateBean(LayoutBorderStyle style) { + int borderLine = style.getBorder(); + Color borderColor = style.getColor(); + + this.borderLineCombo.setSelectedLineStyle(borderLine); + this.borderColorPane.setColor(borderColor); + + Background borderImage = style.getBorderImage(); + if (borderImage instanceof ImageBackground) { + // 图片类型边框 + Image image = ((ImageBackground) borderImage).getImage(); + int[] ninePoint = ((ImageBackground) borderImage).getNinePoint(); + + if (image != null) { + this.borderLineCombo.selectBorderImage(); + this.imagePreviewPane.setImageWithSuffix(((ImageBackground) borderImage).getImageWithSuffix()); + this.borderImageOpacityPane.populateBean(style.getBorderImageOpacity()); + if (ninePoint != null && ninePoint.length == 4 && ninePoint[0] > 0 && ninePoint[1] > 0 && ninePoint[2] > 0 && ninePoint[3] > 0) { + ninePointLeft = ninePoint[0]; + ninePointTop = ninePoint[1]; + ninePointRight = ninePoint[2]; + ninePointBottom = ninePoint[3]; + } else { + ninePointLeft = ninePointRight = image.getWidth(null) / 3; + ninePointTop = ninePointBottom = image.getHeight(null) / 3; + } + + getComponent(1).setVisible(false); + getComponent(2).setVisible(true); + + return; + } + } + + if (borderLine == Constants.LINE_NONE) { + getComponent(1).setVisible(false); + getComponent(2).setVisible(false); + return; + } else { + getComponent(1).setVisible(true); + getComponent(2).setVisible(false); + } + + this.borderLineCombo.setSelectedLineStyle(style.getBorder()); + this.borderColorPane.setColor(style.getColor()); + } + + public void updateBean(LayoutBorderStyle style) { + + style.setBorder(this.borderLineCombo.getSelectedLineStyle()); + style.setColor(this.borderColorPane.getColor()); + style.setBorderImage(null); + + if (this.borderLineCombo.isSelectedBorderImage()) { + Image image = this.imagePreviewPane.getImage(); + if (image != null) { + ImageBackground newImageBackground = new ImageFileBackground(this.imagePreviewPane.getImageWithSuffix(), Constants.IMAGE_EXTEND); + newImageBackground.setNinePoint(new int[] { ninePointLeft, ninePointTop, ninePointRight, ninePointBottom }); + style.setBorderImage(newImageBackground); + style.setBorderImageOpacity((float)borderImageOpacityPane.updateBean()); + } + } + } + + private void fireStateChanged() { + if (uiObserverListener != null) { + uiObserverListener.doChange(); + } + } + + @Override + public void registerChangeListener(UIObserverListener listener) { + this.uiObserverListener = listener; + } + + @Override + public boolean shouldResponseChangeListener() { + return true; + } + + protected UIButtonUI createButtonUI(final UIColorButton uiColorButton) { + return new UIButtonUI() { + + public void paint(Graphics g, JComponent c) { + UIButton b = (UIButton) c; + g.setColor(Color.black); + GraphHelper.draw(g, new RoundRectangle2D.Double(1, 1, b.getWidth() - 2, b.getHeight() - 2, 0, 0), 1); + + if (b.getModel().isEnabled()) { + g.setColor(uiColorButton.getColor()); + } else { + g.setColor(new Color(Utils.filterRGB(uiColorButton.getColor().getRGB(), 50))); + } + g.fillRect(2, 2, b.getWidth() - 3, b.getHeight() - 3); + } + }; + } + + protected static class BorderLineAndImageComboBox extends LineComboBox { + public static final int LINE_PICTURE = -1; + public final static int[] BORDER_LINE_STYLE_ARRAY = new int[] { + Constants.LINE_NONE, + LINE_PICTURE, + Constants.LINE_THIN, //1px + Constants.LINE_MEDIUM, //2px + Constants.LINE_THICK, //3px + }; + + public BorderLineAndImageComboBox() { + super(BORDER_LINE_STYLE_ARRAY); + } + + @Override + protected String toStringFromStyle(int style) { + if (style == LINE_PICTURE) { + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Border_Image"); + } + return super.toStringFromStyle(style); + } + + public boolean isSelectedBorderLine() { + return getSelectedIndex() > 1; + } + + public boolean isSelectedBorderImage() { + return getSelectedIndex() == 1; + } + + public void selectBorderImage() { + this.setSelectedIndex(1); + } + } + + private class NinePointImageTweakDialogPane extends BasicPane { + private final NinePointLinePreviewPane previewPane = new NinePointLinePreviewPane(); + + public NinePointImageTweakDialogPane() { + this.initComponents(); + } + + private void initComponents() { + setLayout(new BorderLayout()); + setBorder(BorderFactory.createTitledBorder(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Border_Image_Config_Nine_Point_Fill_Preview"))); + + JPanel content = FRGUIPaneFactory.createBorderLayout_S_Pane(); + content.setBorder(BorderFactory.createEmptyBorder( + IntervalConstants.INTERVAL_W1, + IntervalConstants.INTERVAL_W1, + IntervalConstants.INTERVAL_W1, + IntervalConstants.INTERVAL_W1)); + content.add(previewPane); + previewPane.setPreferredSize(new Dimension(611, 457)); + + add(content, BorderLayout.CENTER); + } + + @Override + protected String title4PopupWindow() { + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Border_Image_Config_Nine_Point_Fill"); + } + } + + private class NinePointLinePreviewPane extends JPanel implements MouseMotionListener, MouseListener { + private final BufferedImage transparentImage = IOUtils.readImage("/com/fr/design/images/transparent_background.jpg"); + + public final Color PATCH_COLOR = new Color(0, 0, 0, 38); + public final Color DIVIDER_COLOR = new Color(250, 250, 250); + public final Color TEXT_COLOR = Color.WHITE; + public final int PADDING = 15; + + private int imgWidth; + private int imgHeight; + private int scaleImgWidth; + private int scaleImgHeight; + private int scaleImgX; + private int scaleImgY; + private double scale = 1.0; + + public NinePointLinePreviewPane() { + this.addMouseMotionListener(this); + this.addMouseListener(this); + } + + @Override + protected void paintComponent(Graphics g) { + super.paintComponent(g); + + Graphics2D g2d = (Graphics2D) g; + g2d.drawImage(transparentImage, 0, 0, getWidth(), getHeight(), null); + + Image image = imagePreviewPane.getImage(); + + imgWidth = image.getWidth(null); + imgHeight = image.getHeight(null); + int autoFixAreaWidth = getWidth() - 2 * PADDING; + int autoFixAreaHeight = getHeight() - 2 * PADDING; + int autoFixAreaX = PADDING; + int autoFixAreaY = PADDING; + + if (imgWidth / imgHeight > autoFixAreaWidth / autoFixAreaHeight) { + scaleImgWidth = autoFixAreaWidth; + scaleImgHeight = (int) (1.0F * scaleImgWidth * imgHeight / imgWidth); + scaleImgX = autoFixAreaX; + scaleImgY = (autoFixAreaHeight - scaleImgHeight) / 2 + autoFixAreaY; // 垂直居中 + scale = 1.0 * scaleImgWidth / imgWidth; + } else { + scaleImgHeight = autoFixAreaHeight; + scaleImgWidth = (int) (1.0F * scaleImgHeight * imgWidth / imgHeight); + scaleImgX = (autoFixAreaWidth - scaleImgWidth) / 2 + autoFixAreaX; // 水平居中 + scaleImgY = autoFixAreaY; + scale = 1.0 * scaleImgHeight / imgHeight; + } + + g2d.drawImage(image, scaleImgX, scaleImgY, scaleImgWidth, scaleImgHeight, null); + + int scaleLeft = (int) (ninePointLeft * scale); + int scaleTop = (int) (ninePointTop * scale); + int scaleRight = (int) (ninePointRight * scale); + int scaleBottom = (int) (ninePointBottom * scale); + + g2d.setColor(PATCH_COLOR); + // draw horizontal patch + GraphDrawHelper.fillRect(g2d, 0, scaleImgY + scaleTop, getWidth(), scaleImgHeight - scaleTop - scaleBottom); + // draw vertical patch + GraphDrawHelper.fillRect(g2d, scaleImgX + scaleLeft, 0,scaleImgWidth - scaleLeft - scaleRight, getHeight()); + + g2d.setColor(DIVIDER_COLOR); + // draw top divider + GraphDrawHelper.drawLine(g2d, 0, scaleImgY + scaleTop, getWidth(), scaleImgY + scaleTop); + // draw bottom divider + GraphDrawHelper.drawLine(g2d, 0, scaleImgY + scaleImgHeight - scaleBottom, getWidth(), scaleImgY + scaleImgHeight - scaleBottom); + // draw left divider + GraphDrawHelper.drawLine(g2d, scaleImgX + scaleLeft, 0, scaleImgX + scaleLeft, getHeight()); + // draw right divider + GraphDrawHelper.drawLine(g2d, scaleImgX + scaleImgWidth - scaleRight, 0, scaleImgX + scaleImgWidth - scaleRight, getHeight()); + + g2d.setColor(TEXT_COLOR); + // draw nine point info + GraphDrawHelper.drawString(g2d, Integer.toString(ninePointTop), scaleImgX + (scaleImgWidth + scaleLeft - scaleRight) / 2.0, (scaleImgY + scaleTop) / 2.0); + GraphDrawHelper.drawString(g2d, Integer.toString(ninePointBottom), scaleImgX + scaleLeft + (scaleImgWidth - scaleLeft - scaleRight) / 2.0, scaleImgY + scaleImgHeight - (scaleBottom - PADDING) / 2.0); + GraphDrawHelper.drawString(g2d, Integer.toString(ninePointLeft), (scaleImgX + scaleLeft) / 2.0, scaleImgY + (scaleImgHeight + scaleTop - scaleBottom) / 2.0); + GraphDrawHelper.drawString(g2d, Integer.toString(ninePointRight), scaleImgX + scaleImgWidth - (scaleRight - PADDING) / 2.0, scaleImgY + (scaleImgHeight + scaleTop - scaleBottom) / 2.0); + } + + @Override + public void mouseDragged(MouseEvent e) { + int x = e.getX(); + int y = e.getY(); + + int cursorType = getCursor().getType(); + + switch (cursorType) { + case Cursor.W_RESIZE_CURSOR: { + int nextLeft = (int) ((x - scaleImgX) / scale); + if (1 <= nextLeft && nextLeft < imgWidth - ninePointRight) { + ninePointLeft = nextLeft; + repaint(); + } + return; + } + case Cursor.E_RESIZE_CURSOR: { + int nextRight = (int) ((scaleImgX + scaleImgWidth - x) / scale); + if (1 <= nextRight && nextRight < imgWidth - ninePointLeft) { + ninePointRight = nextRight; + repaint(); + } + return; + } + case Cursor.N_RESIZE_CURSOR: { + int nextTop = (int) ((y - scaleImgY) / scale); + if (1 <= nextTop && nextTop < imgHeight - ninePointBottom) { + ninePointTop = nextTop; + repaint(); + } + return; + } + case Cursor.S_RESIZE_CURSOR: { + int nextBottom = (int) ((scaleImgY + scaleImgHeight - y) / scale); + if (1 <= nextBottom && nextBottom < imgHeight - ninePointTop) { + ninePointBottom = nextBottom; + repaint(); + } + } + } + } + + @Override + public void mouseMoved(MouseEvent e) { + boolean needRepaint; + + int x = e.getX(); + int y = e.getY(); + + double scaleLeft = ninePointLeft * scale; + double scaleTop = ninePointTop * scale; + double scaleRight = ninePointRight * scale; + double scaleBottom = ninePointBottom * scale; + + // determine cursor + int cursorType = Cursor.DEFAULT_CURSOR; + + boolean hoveringLeftDivider = Math.abs(x - (scaleImgX + scaleLeft)) < 2; + boolean hoveringRightDivider = Math.abs(x - (scaleImgX + scaleImgWidth - scaleRight)) < 2; + boolean hoveringTopDivider = Math.abs(y - (scaleImgY + scaleTop)) < 2; + boolean hoveringBottomDivider = Math.abs(y - (scaleImgY + scaleImgHeight - scaleBottom)) < 2; + + if (hoveringLeftDivider) { + cursorType = Cursor.W_RESIZE_CURSOR; + } else if (hoveringRightDivider) { + cursorType = Cursor.E_RESIZE_CURSOR; + } else if (hoveringTopDivider) { + cursorType = Cursor.N_RESIZE_CURSOR; + } else if (hoveringBottomDivider) { + cursorType = Cursor.S_RESIZE_CURSOR; + } + + needRepaint = getCursor().getType() != cursorType; + this.setCursor(Cursor.getPredefinedCursor(cursorType)); + + if (needRepaint) { + repaint(); + } + } + + @Override + public void mouseClicked(MouseEvent e) { + + } + + @Override + public void mousePressed(MouseEvent e) { + + } + + @Override + public void mouseReleased(MouseEvent e) { + this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); + + repaint(); + } + + @Override + public void mouseEntered(MouseEvent e) { + + } + + @Override + public void mouseExited(MouseEvent e) { + + } + } +} diff --git a/designer-form/src/main/java/com/fr/design/gui/xpane/CardTagLayoutStylePane.java b/designer-form/src/main/java/com/fr/design/gui/xpane/CardTagLayoutStylePane.java new file mode 100644 index 0000000000..5e6f7c06c5 --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/gui/xpane/CardTagLayoutStylePane.java @@ -0,0 +1,27 @@ +/* + * Copyright(c) 2001-2010, FineReport Inc, All Rights Reserved. + */ +package com.fr.design.gui.xpane; + +import com.fr.form.ui.LayoutBorderStyle; + +import javax.swing.*; + +/** + * CardTagLayoutBorderPane Pane. + */ +public class CardTagLayoutStylePane extends LayoutStylePane { + + @Override + protected JPanel createTitleStylePane(){ + return null; + } + + @Override + public void updateTitle(LayoutBorderStyle style) { + + } + + @Override + protected void populateTitle() { } +} diff --git a/designer-form/src/main/java/com/fr/design/gui/xpane/LayoutStylePane.java b/designer-form/src/main/java/com/fr/design/gui/xpane/LayoutStylePane.java new file mode 100644 index 0000000000..265de1aba7 --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/gui/xpane/LayoutStylePane.java @@ -0,0 +1,502 @@ +package com.fr.design.gui.xpane; + +import com.fr.base.GraphHelper; +import com.fr.base.Utils; +import com.fr.base.svg.IconUtils; +import com.fr.design.beans.BasicBeanPane; +import com.fr.design.constants.UIConstants; +import com.fr.design.designer.IntervalConstants; +import com.fr.design.file.HistoryTemplateListCache; +import com.fr.design.formula.TinyFormulaPane; +import com.fr.design.gui.frpane.UIPercentDragPane; +import com.fr.design.gui.ibutton.UIButtonGroup; +import com.fr.design.gui.ibutton.UIColorButton; +import com.fr.design.gui.ibutton.UIToggleButton; +import com.fr.design.gui.icheckbox.UICheckBox; +import com.fr.design.gui.icombobox.LineComboBox; +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.BackgroundSpecialPane; +import com.fr.design.gui.style.FRFontPane; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.layout.TableLayout; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.mainframe.JForm; +import com.fr.design.mainframe.JTemplate; +import com.fr.form.ui.LayoutBorderStyle; +import com.fr.form.ui.WidgetTitle; +import com.fr.general.Background; +import com.fr.general.FRFont; +import com.fr.general.IOUtils; +import com.fr.general.act.TitlePacker; +import com.fr.stable.Constants; + +import javax.swing.*; +import javax.swing.border.LineBorder; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import java.awt.*; + +/** + * @author Starryi + * @version 10.0.18 + * Created by Starryi on 2021/6/25 + * + * 可配置图片类型边框的样式设置面板 + */ +public class LayoutStylePane extends BasicBeanPane { + public static final String[] BORDER_STYLE = new String[]{ + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Common"), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Shadow") + }; + private static final Dimension BUTTON_SIZE = new Dimension(20, 20); + private static final int SETTING_LABEL_WIDTH = 60; + + protected LayoutBorderStyle style = new LayoutBorderStyle(); + + //渲染风格:有无阴影 + protected UIComboBox borderStyleCombo; + // 含图片类型边框的边框配置面板(图片类型边框 + 阴影时存在默认的阴影颜色) + protected BorderLineAndImagePane borderLineAndImagePane; + //边框圆角或圆角裁剪 + protected UISpinner cornerSpinner; + //主体背景 + protected BackgroundSpecialPane backgroundPane; + //主体背景透明度 + protected UIPercentDragPane backgroundOpacityPane; + + // 标题可见 + protected UICheckBox titleVisibleCheckbox; + //标题文字内容 + protected TinyFormulaPane titleTextPane; + //标题字体格式 + protected UIComboBox titleFontFamilyComboBox; + //标题字体大小 + protected UIComboBox titleFontSizeComboBox; + //标题字体颜色 + protected UIColorButton titleFontColorSelectPane; + //标题字体特殊效果:粗体、斜体、下划线 + private UIToggleButton titleFontBoldButton; + private UIToggleButton titleFontItalicButton; + private UIToggleButton titleFontUnderlineButton; + private LineComboBox titleFontUnderlineCombo; + // 标题图文混排 + protected TitleInsetImagePane titleInsetImagePane; + //对齐方式 + protected UIButtonGroup titleAlignPane; + //标题整体背景 + protected BackgroundSpecialPane titleBackgroundPane; + //标题背景透明度 + protected UIPercentDragPane titleBackgroundOpacityPane; + + public LayoutStylePane() { + this.initLayout(); + } + + protected void initLayout() { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + this.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); + + JPanel container = FRGUIPaneFactory.createBorderLayout_S_Pane(); + + JTemplate currentEditingTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + boolean currentIsRootLayout = currentEditingTemplate != null && !currentEditingTemplate.isJWorkBook() && ((JForm)currentEditingTemplate).isSelectRootPane(); + + JPanel titlePane = createTitleStylePane(); + if (titlePane != null) { + container.add(titlePane, BorderLayout.NORTH); + if (currentIsRootLayout) { + titlePane.setVisible(false); + } + } + + //界面上表单主体只有背景和透明度可以设置 + JPanel mainStylePane = currentIsRootLayout ? createMainStylePane4RootLayout() : createMainStylePane4WidgetLayout(); + if (mainStylePane != null) { + container.add(mainStylePane, BorderLayout.CENTER); + } + + this.add(container, BorderLayout.CENTER); + } + + protected void initMainComponents() { + borderStyleCombo = new UIComboBox(BORDER_STYLE); + borderLineAndImagePane = new BorderLineAndImagePane(); + cornerSpinner = new UISpinner(0,1000,1,0); + backgroundPane = new BackgroundSpecialPane(); + backgroundOpacityPane = new UIPercentDragPane(); + } + + protected JPanel createMainStylePane4WidgetLayout() { + initMainComponents(); + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + double[] rowSize = {p, p, p, p, p}; + double[] columnSize = {SETTING_LABEL_WIDTH, f}; + + JPanel contentPane = TableLayoutHelper.createGapTableLayoutPane(new JComponent[][]{ + {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Frame_Style")), null}, + {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Render_Style")), borderStyleCombo}, + {this.borderLineAndImagePane, null}, + {this.createMainBackgroundAndOpacityPane(), null}, + {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Radius")), cornerSpinner}, + }, + rowSize, columnSize, IntervalConstants.INTERVAL_L1, IntervalConstants.INTERVAL_L1); + contentPane.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0)); + + JPanel container = FRGUIPaneFactory.createBorderLayout_S_Pane(); + container.setBorder(new BottomLineBorder()); + container.add(contentPane, BorderLayout.NORTH); + + return container; + } + + protected JPanel createMainStylePane4RootLayout() { + initMainComponents(); + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + double[] rowSize = {p, p}; + double[] columnSize = {SETTING_LABEL_WIDTH, f}; + + JPanel contentPane = TableLayoutHelper.createGapTableLayoutPane(new JComponent[][]{ + {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Frame_Style")), null}, + {this.createMainBackgroundAndOpacityPane(), null}, + }, + rowSize, columnSize, IntervalConstants.INTERVAL_L1, IntervalConstants.INTERVAL_L1); + contentPane.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0)); + + JPanel container = FRGUIPaneFactory.createBorderLayout_S_Pane(); + container.setBorder(new BottomLineBorder()); + container.add(contentPane, BorderLayout.NORTH); + + return container; + } + + protected JPanel createMainBackgroundAndOpacityPane() { + return createBackgroundAndOpacityPane( + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget-Style_Body_Background"), + this.backgroundPane, + this.backgroundOpacityPane); + } + + protected void initTitleComponents() { + titleVisibleCheckbox = new UICheckBox(); + + titleTextPane = new TinyFormulaPane(); + + titleFontFamilyComboBox = new UIComboBox(Utils.getAvailableFontFamilyNames4Report()); + titleFontFamilyComboBox.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Family")); + + titleFontSizeComboBox = new UIComboBox(FRFontPane.FONT_SIZES); + titleFontSizeComboBox.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Size")); + + titleFontColorSelectPane = new UIColorButton(); + titleFontColorSelectPane.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Foreground")); + titleFontColorSelectPane.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Foreground")); + + titleFontBoldButton = new UIToggleButton(IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/bold.png")); + titleFontBoldButton.setPreferredSize(BUTTON_SIZE); + titleFontBoldButton.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Bold")); + titleFontBoldButton.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Bold")); + + titleFontItalicButton = new UIToggleButton(IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/italic.png")); + titleFontItalicButton.setPreferredSize(BUTTON_SIZE); + titleFontItalicButton.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Italic")); + titleFontItalicButton.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Italic")); + + titleFontUnderlineButton = new UIToggleButton(IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/underline.png")); + titleFontUnderlineButton.setPreferredSize(BUTTON_SIZE); + titleFontUnderlineButton.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Underline")); + titleFontUnderlineButton.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Underline")); + + titleFontUnderlineCombo = new LineComboBox(UIConstants.BORDER_LINE_STYLE_ARRAY); + titleFontUnderlineCombo.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Line_Style")); + + titleInsetImagePane = new TitleInsetImagePane(); + + titleAlignPane = new UIButtonGroup( + new Icon[] { + IconUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_left_normal.png"), + IconUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_center_normal.png"), + IconUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_right_normal.png") + }, + new Integer[]{Constants.LEFT, Constants.CENTER, Constants.RIGHT}); + titleAlignPane.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") + }); + + titleBackgroundPane = new BackgroundSpecialPane(); + + titleBackgroundOpacityPane = new UIPercentDragPane(); + } + + protected JPanel createTitleStylePane() { + initTitleComponents(); + + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + double[] rowSize = {p,p,p,p,p,p}; + double[] columnSize = {SETTING_LABEL_WIDTH, f}; + + final JPanel bottomPane = TableLayoutHelper.createCommonTableLayoutPane( new JComponent[][]{ + {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Title_Content")), titleTextPane}, + {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Title_Format")), titleFontFamilyComboBox}, + {null, createTitleFontButtonPane()}, + {titleInsetImagePane, null}, + {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Title_Text_Align")), titleAlignPane}, + {this.createTitleBackgroundAndOpacityPane(), null}, + }, + rowSize, columnSize, IntervalConstants.INTERVAL_L1); + bottomPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); + bottomPane.setVisible(false); + + JPanel visibleComposedPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + + titleVisibleCheckbox.setSelected(false); + visibleComposedPane.add(titleVisibleCheckbox, BorderLayout.WEST); + visibleComposedPane.add(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Title_Visible")), BorderLayout.CENTER); + + JPanel topPane = TableLayoutHelper.createCommonTableLayoutPane( new JComponent[][] { + {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Title")), null}, + {visibleComposedPane, null} + }, new double[]{p, p}, new double[]{SETTING_LABEL_WIDTH, p}, IntervalConstants.INTERVAL_L1); + topPane.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0)); + + JPanel container = FRGUIPaneFactory.createBorderLayout_S_Pane(); + container.setBorder(new BottomLineBorder()); + container.add(topPane, BorderLayout.NORTH); + container.add(bottomPane, BorderLayout.CENTER); + + titleVisibleCheckbox.addChangeListener(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + bottomPane.setVisible(titleVisibleCheckbox.isSelected()); + } + }); + + return container; + } + + protected JPanel createTitleFontButtonPane(){ + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + double[] rowSize = {p}; + double[] columnSize = {f, p, p, p, p}; + + JPanel buttonPane = TableLayoutHelper.createCommonTableLayoutPane( new JComponent[][] { + {titleFontSizeComboBox, titleFontColorSelectPane, titleFontItalicButton, titleFontBoldButton, titleFontUnderlineButton}, + }, rowSize, columnSize, IntervalConstants.INTERVAL_W0); + + JPanel containerPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + containerPane.add(buttonPane, BorderLayout.NORTH); + containerPane.add(titleFontUnderlineCombo, BorderLayout.CENTER); + + titleFontUnderlineCombo.setVisible(false); + titleFontUnderlineButton.addChangeListener(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + titleFontUnderlineCombo.setVisible(titleFontUnderlineButton.isSelected()); + } + }); + + return containerPane; + } + + protected JPanel createTitleBackgroundAndOpacityPane() { + return createBackgroundAndOpacityPane( + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Title_Background"), + titleBackgroundPane, + titleBackgroundOpacityPane); + } + + @Override + public LayoutBorderStyle updateBean() { + LayoutBorderStyle style = new LayoutBorderStyle(); + updateMain(style); + updateTitle(style); + return style; + } + + protected void updateMain(LayoutBorderStyle style) { + if (borderStyleCombo != null) { + style.setBorderStyle(borderStyleCombo.getSelectedIndex()); + } + if (cornerSpinner != null) { + style.setBorderRadius((int) cornerSpinner.getValue()); + } + if (borderLineAndImagePane != null) { + borderLineAndImagePane.updateBean(style); + } + if (backgroundPane != null) { + style.setBackground(backgroundPane.update()); + } + if (backgroundOpacityPane != null) { + style.setAlpha((float)backgroundOpacityPane.updateBean()); + } + } + + protected void updateTitle(LayoutBorderStyle style) { + style.setType(titleVisibleCheckbox != null && titleVisibleCheckbox.isSelected() ? LayoutBorderStyle.TITLE : LayoutBorderStyle.STANDARD); + TitlePacker title = style.getTitle() == null ? new WidgetTitle() : style.getTitle(); + title.setTextObject(titleTextPane.updateBean()); + FRFont frFont = title.getFrFont(); + frFont = frFont.applySize((Integer) titleFontSizeComboBox.getSelectedItem()); + frFont = frFont.applyName(titleFontFamilyComboBox.getSelectedItem().toString()); + frFont = frFont.applyForeground(titleFontColorSelectPane.getColor()); + frFont = updateTitleFontItalicBold(frFont); + int line = titleFontUnderlineButton.isSelected() ? this.titleFontUnderlineCombo.getSelectedLineStyle() : Constants.LINE_NONE; + frFont = frFont.applyUnderline(line); + title.setFrFont(frFont); + title.setPosition((Integer) titleAlignPane.getSelectedItem()); + titleInsetImagePane.updateBean(title); + title.setBackground(titleBackgroundPane.update()); + title.setBackgroundOpacity((float)titleBackgroundOpacityPane.updateBean()); + style.setTitle(title); + } + + private FRFont updateTitleFontItalicBold(FRFont frFont) { + int italic_bold = frFont.getStyle(); + boolean isItalic = italic_bold == Font.ITALIC || italic_bold == (Font.BOLD + Font.ITALIC); + boolean isBold = italic_bold == Font.BOLD || italic_bold == (Font.BOLD + Font.ITALIC); + if (titleFontItalicButton.isSelected() && !isItalic) { + italic_bold += Font.ITALIC; + } else if (!titleFontItalicButton.isSelected() && isItalic) { + italic_bold -= Font.ITALIC; + } + frFont = frFont.applyStyle(italic_bold); + if (titleFontBoldButton.isSelected() && !isBold) { + italic_bold += Font.BOLD; + } else if (!titleFontBoldButton.isSelected() && isBold) { + italic_bold -= Font.BOLD; + } + frFont = frFont.applyStyle(italic_bold); + return frFont; + } + + @Override + public void populateBean(LayoutBorderStyle style) { + if(this.style == null) { + this.style = new LayoutBorderStyle(); + } + this.style.setStyle(style); + + populateMain(); + populateTitle(); + } + + protected void populateMain() { + if (this.borderStyleCombo != null) { + this.borderStyleCombo.setSelectedIndex(style.getBorderStyle()); + } + if (this.borderLineAndImagePane != null) { + this.borderLineAndImagePane.populateBean(style); + } + if (this.backgroundPane != null) { + this.backgroundPane.populateBean(style.getBackground()); + if (this.backgroundOpacityPane != null) { + this.backgroundOpacityPane.populateBean(style.getAlpha()); + } + } + if (this.cornerSpinner != null) { + this.cornerSpinner.setValue(style.getBorderRadius()); + } + } + + protected void populateTitle() { + TitlePacker widgetTitle = style == null ? new WidgetTitle() : style.getTitle(); + widgetTitle = widgetTitle == null ? new WidgetTitle() : widgetTitle; + titleVisibleCheckbox.setSelected(style.getType() != LayoutBorderStyle.STANDARD); + + this.titleTextPane.populateBean(widgetTitle.getTextObject().toString()); + + FRFont frFont = widgetTitle.getFrFont(); + this.titleFontSizeComboBox.setSelectedItem(frFont.getSize()); + this.titleFontFamilyComboBox.setSelectedItem(frFont.getFamily()); + this.titleFontColorSelectPane.setColor(frFont.getForeground()); + this.titleFontColorSelectPane.repaint(); + titleFontBoldButton.setSelected(frFont.isBold()); + titleFontItalicButton.setSelected(frFont.isItalic()); + + int line = frFont.getUnderline(); + if (line == Constants.LINE_NONE) { + titleFontUnderlineButton.setSelected(false); + titleFontUnderlineCombo.setVisible(false); + } else { + titleFontUnderlineButton.setSelected(true); + titleFontUnderlineCombo.setVisible(true); + this.titleFontUnderlineCombo.setSelectedLineStyle(line); + } + + titleAlignPane.setSelectedItem(widgetTitle.getPosition()); + titleInsetImagePane.populateBean(widgetTitle); + titleBackgroundPane.populateBean(widgetTitle.getBackground()); + titleBackgroundOpacityPane.populateBean(widgetTitle.getBackgroundOpacity()); + } + + @Override + protected String title4PopupWindow() { + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style"); + } + + private static JPanel createBackgroundAndOpacityPane(String name, BackgroundSpecialPane backgroundPane, UIPercentDragPane opacityPane) { + JPanel container = new JPanel(); + container.setLayout(new BorderLayout(0, 6)); + + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + double[] columnSize = {SETTING_LABEL_WIDTH, f}; + + // 确保BackgroundSpecialPane高度变化时,Label依然保持与其顶部对齐 + JPanel backgroundLabelPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + backgroundLabelPane.setBorder(BorderFactory.createEmptyBorder(IntervalConstants.INTERVAL_L1, 0, 0, 0)); + backgroundLabelPane.add(new UILabel(name), BorderLayout.NORTH); + + JPanel backgroundComposedPane = TableLayoutHelper.createGapTableLayoutPane( + new JComponent[][]{ + {backgroundLabelPane, backgroundPane} + }, + new double[]{p}, columnSize, IntervalConstants.INTERVAL_L1, IntervalConstants.INTERVAL_L1); + + JPanel opacityComposedPane = TableLayoutHelper.createGapTableLayoutPane( + new JComponent[][]{ + {new UILabel(""), new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget-Style_Alpha"))}, + {new UILabel(""), opacityPane} + }, + new double[]{p, p}, columnSize, IntervalConstants.INTERVAL_L1, IntervalConstants.INTERVAL_L1); + + container.add(backgroundComposedPane, BorderLayout.NORTH, 0); + container.add(opacityComposedPane, BorderLayout.CENTER, 1); + + opacityComposedPane.setVisible(false); + + backgroundPane.addChangeListener(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + Background background = backgroundPane.update(); + opacityComposedPane.setVisible(background != null); + } + }); + + return container; + } + + protected static class BottomLineBorder extends LineBorder { + + public BottomLineBorder() { + super(Color.lightGray, 1); + } + + @Override + public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { + Graphics2D g2d = (Graphics2D) g; + Color oldColor = g2d.getColor(); + g2d.setColor(this.lineColor); + GraphHelper.drawLine(g, 0, height, width, height, 1); + g2d.setColor(oldColor); + } + } +} diff --git a/designer-form/src/main/java/com/fr/design/gui/xpane/TitleInsetImagePane.java b/designer-form/src/main/java/com/fr/design/gui/xpane/TitleInsetImagePane.java new file mode 100644 index 0000000000..1a207a0b3e --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/gui/xpane/TitleInsetImagePane.java @@ -0,0 +1,258 @@ +package com.fr.design.gui.xpane; + +import com.fr.base.Style; +import com.fr.base.background.ImageBackground; +import com.fr.base.background.ImageFileBackground; +import com.fr.design.border.UIRoundedBorder; +import com.fr.design.constants.UIConstants; +import com.fr.design.designer.IntervalConstants; +import com.fr.design.event.UIObserver; +import com.fr.design.event.UIObserverListener; +import com.fr.design.gui.frpane.ImgChooseWrapper; +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.gui.ibutton.UIButtonGroup; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.ispinner.UISpinner; +import com.fr.design.layout.TableLayout; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.mainframe.DesignerContext; +import com.fr.design.mainframe.backgroundpane.ImagePreviewPane; +import com.fr.design.style.background.image.ImageFileChooser; +import com.fr.design.widget.ui.designer.component.UIBoundSpinner; +import com.fr.form.ui.WidgetTitle; +import com.fr.general.Background; +import com.fr.general.IOUtils; +import com.fr.general.ImageWithSuffix; +import com.fr.general.act.TitlePacker; +import com.fr.stable.Constants; + +import javax.swing.*; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import javax.swing.plaf.basic.BasicButtonUI; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +/** + * @author Starryi + * @version 10.0.18 + * Created by Starryi on 2021/7/3 + */ +public class TitleInsetImagePane extends JPanel implements UIObserver { + private final int SETTING_LABEL_WIDTH = 60; + private final int DELETE_BUTTON_SIZE = 24; + private final int IMAGE_PREVIEW_SIZE = 145; + private final Style DEFAULT_IMAGE_LAYOUT_STYLE = Style.DEFAULT_STYLE.deriveImageLayout(Constants.IMAGE_DEFAULT); + private final int DEFAULT_INSET_LOCATION_INDEX = 0; + private final int DEFAULT_INSET_PADDING = 10; + + private UIObserverListener uiObserverListener; + + private UIButton imageChooseButton; + private UIButton imageDeleteButton; + private ImagePreviewPane imagePreviewPane; + private UIButtonGroup imageLocationPane; + private UISpinner imagePaddingPane; + + private ImageFileChooser imageFileChooser; + + public TitleInsetImagePane() { + this.initComponents(); + this.initLayout(); + } + + private JPanel createImageChooseComposedPane() { + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + double[] rowSize = {p}; + double[] columnSize = {SETTING_LABEL_WIDTH, f}; + + return TableLayoutHelper.createCommonTableLayoutPane( new JComponent[][]{ + {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Title_Inset")), this.imageChooseButton}, + }, + rowSize, columnSize, IntervalConstants.INTERVAL_L1); + } + + private JPanel createImageContentComposedPane() { + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + double[] rowSize = {p, p, p, p, p}; + double[] columnSize = {SETTING_LABEL_WIDTH, f}; + + JPanel deletableImagePreviewPane = new JPanel(); + deletableImagePreviewPane.setLayout(null); + deletableImagePreviewPane.setBorder(new UIRoundedBorder(UIConstants.LINE_COLOR, 1, 5)); + deletableImagePreviewPane.setPreferredSize(new Dimension(IMAGE_PREVIEW_SIZE, IMAGE_PREVIEW_SIZE)); + imagePreviewPane.setBounds(0, 0, IMAGE_PREVIEW_SIZE, IMAGE_PREVIEW_SIZE); + imageDeleteButton.setBounds(IMAGE_PREVIEW_SIZE - DELETE_BUTTON_SIZE, 0, DELETE_BUTTON_SIZE, DELETE_BUTTON_SIZE); + deletableImagePreviewPane.add(imageDeleteButton, 0); + deletableImagePreviewPane.add(imagePreviewPane, 1); + + return TableLayoutHelper.createCommonTableLayoutPane( + new JComponent[][]{ + {null, deletableImagePreviewPane}, + {null, new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Title_Inset_Relative_Location"))}, + {null, this.imageLocationPane}, + {null, new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Title_Inset_Padding"))}, + {null, this.imagePaddingPane} + }, + rowSize, columnSize, IntervalConstants.INTERVAL_L1); + } + + private void initImageFileChooserIfNotExist() { + if (imageFileChooser == null) { + imageFileChooser = new ImageFileChooser(); + imageFileChooser.setMultiSelectionEnabled(false); + } + } + + private void initComponents() { + imageChooseButton = new UIButton(IOUtils.readIcon("/com/fr/design/images/buttonicon/icon_choose_inset.png")); + + imageDeleteButton = new UIButton(IOUtils.readIcon("/com/fr/design/images/buttonicon/icon_delete_inset.png")); + imageDeleteButton.setUI(new BasicButtonUI()); + imageDeleteButton.setOpaque(true); + imageDeleteButton.setBorderPainted(false); + imageDeleteButton.setBorder(null); + imageDeleteButton.setFocusPainted(false); + imageDeleteButton.setContentAreaFilled(true); + imageDeleteButton.setPreferredSize(new Dimension(DELETE_BUTTON_SIZE, DELETE_BUTTON_SIZE)); + imageDeleteButton.setBackground(new Color(51, 51, 51)); + + imagePreviewPane = new ImagePreviewPane(); + imagePreviewPane.setImageStyle(DEFAULT_IMAGE_LAYOUT_STYLE); + imagePreviewPane.setPreferredSize(new Dimension(IMAGE_PREVIEW_SIZE, IMAGE_PREVIEW_SIZE)); + + imageLocationPane = new UIButtonGroup(new Icon[][]{ + { + IOUtils.readIcon("/com/fr/design/images/buttonicon/icon_inset_left_selected.png"), + IOUtils.readIcon("/com/fr/design/images/buttonicon/icon_inset_left_unselected.png") + }, + { + IOUtils.readIcon("/com/fr/design/images/buttonicon/icon_inset_both_selected.png"), + IOUtils.readIcon("/com/fr/design/images/buttonicon/icon_inset_both_unselected.png") + }, + { + IOUtils.readIcon("/com/fr/design/images/buttonicon/icon_inset_right_selected.png"), + IOUtils.readIcon("/com/fr/design/images/buttonicon/icon_inset_right_unselected.png") + }, + }); + imageLocationPane.setSelectedIndex(DEFAULT_INSET_LOCATION_INDEX); + imageLocationPane.setAllToolTips(new String[]{ + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Title_Inset_Relative_Left_Tooltip"), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Title_Inset_Relative_Both_Tooltip"), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Title_Inset_Relative_Right_Tooltip"), + }); + + imagePaddingPane = new UIBoundSpinner(0, Integer.MAX_VALUE, 1, WidgetTitle.DEFAULT_INSET_PADDING); + imagePaddingPane.setValue(DEFAULT_INSET_PADDING); + } + + private void initLayout() { + + + this.setLayout(new BorderLayout(0, IntervalConstants.INTERVAL_L1)); + + add(createImageChooseComposedPane(), BorderLayout.NORTH, 0); + add(createImageContentComposedPane(), BorderLayout.CENTER, 1); + + getComponent(1).setVisible(false); + + this.imageChooseButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + initImageFileChooserIfNotExist(); + + int returnVal = imageFileChooser.showOpenDialog(DesignerContext.getDesignerFrame()); + ImgChooseWrapper.getInstance(imagePreviewPane, imageFileChooser, DEFAULT_IMAGE_LAYOUT_STYLE, new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + if (!getComponent(1).isVisible()) { + imageLocationPane.setSelectedIndex(DEFAULT_INSET_LOCATION_INDEX); + imagePaddingPane.setValue(DEFAULT_INSET_PADDING); + getComponent(1).setVisible(true); + } + + fireStateChanged(); + } + }).dealWithImageFile(returnVal); + } + }); + this.imageDeleteButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + imagePreviewPane.setImageWithSuffix(null); + imageLocationPane.setSelectedIndex(DEFAULT_INSET_LOCATION_INDEX); + imagePaddingPane.setValue(DEFAULT_INSET_PADDING); + getComponent(1).setVisible(false); + + fireStateChanged(); + } + }); + } + + public void populateBean(TitlePacker packer) { + Background insetImage = packer.getInsetImage(); + if (insetImage instanceof ImageBackground) { + ImageWithSuffix image = ((ImageBackground) insetImage).getImageWithSuffix(); + if (image != null) { + this.imagePreviewPane.setImageWithSuffix(image); + + if (!packer.isInsetRelativeTextLeft()) { + this.imageLocationPane.setSelectedIndex(2); + } else if (!packer.isInsetRelativeTextRight()) { + this.imageLocationPane.setSelectedIndex(0); + } else { + this.imageLocationPane.setSelectedIndex(1); + } + + this.imagePaddingPane.setValue(packer.getInsetImagePadding()); + + getComponent(1).setVisible(true); + + return; + } + } + + this.imagePreviewPane.setImageWithSuffix(null); + this.imageLocationPane.setSelectedIndex(DEFAULT_INSET_LOCATION_INDEX); + this.imagePaddingPane.setValue(DEFAULT_INSET_PADDING); + + getComponent(1).setVisible(false); + } + + public void updateBean(TitlePacker packer) { + Image image = imagePreviewPane.getImageWithSuffix(); + if (image != null) { + packer.setInsetImage(new ImageFileBackground(image, Constants.IMAGE_DEFAULT)); + + int imageLocationIndex = this.imageLocationPane.getSelectedIndex(); + packer.setInsetRelativeTextLeft(imageLocationIndex == 0 || imageLocationIndex == 1); + packer.setInsetRelativeTextRight(imageLocationIndex == 2 || imageLocationIndex == 1); + + packer.setInsetImagePadding((int) this.imagePaddingPane.getValue()); + } else { + packer.setInsetImage(null); + packer.setInsetImagePadding(WidgetTitle.DEFAULT_INSET_PADDING); + packer.setInsetRelativeTextLeft(WidgetTitle.DEFAULT_INSET_LEFT); + packer.setInsetRelativeTextRight(WidgetTitle.DEFAULT_INSET_RIGHT); + } + } + + private void fireStateChanged() { + if (uiObserverListener != null) { + uiObserverListener.doChange(); + } + } + + @Override + public void registerChangeListener(UIObserverListener listener) { + this.uiObserverListener = listener; + } + + @Override + public boolean shouldResponseChangeListener() { + return true; + } +} diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormWidgetCardPane.java b/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormWidgetCardPane.java index 609e45b5da..b1bd8d80de 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormWidgetCardPane.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormWidgetCardPane.java @@ -67,10 +67,6 @@ public class FormWidgetCardPane extends AbstractAttrNoScrollPane implements Rele this.designer = designer; initComponents(); initDefinePane(); - widgetBoundPane = createWidgetBoundPane(xCreator); - if (widgetBoundPane != null) { - attriCardPane.add(widgetBoundPane, BorderLayout.CENTER); - } } public XLayoutContainer getParent(XCreator source) { @@ -162,6 +158,10 @@ public class FormWidgetCardPane extends AbstractAttrNoScrollPane implements Rele jPanel.add(uiExpandablePane, BorderLayout.NORTH); + widgetBoundPane = createWidgetBoundPane(xCreator); + if (widgetBoundPane != null) { + attriCardPane.add(widgetBoundPane, BorderLayout.NORTH); + } } private static void freshPropertyMode(XCreator xCreator) { @@ -187,7 +187,7 @@ public class FormWidgetCardPane extends AbstractAttrNoScrollPane implements Rele JComponent jComponent = definePane.toSwingComponent(); - attriCardPane.add(jComponent, BorderLayout.NORTH); + attriCardPane.add(jComponent, BorderLayout.CENTER); currentEditorDefinePane = definePane; } diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/BorderStyleWidgetDefinePane.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/BorderStyleWidgetDefinePane.java index dbe2735e3f..fe6634b1f7 100644 --- a/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/BorderStyleWidgetDefinePane.java +++ b/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/BorderStyleWidgetDefinePane.java @@ -5,6 +5,7 @@ import com.fr.design.designer.IntervalConstants; import com.fr.design.designer.creator.XCreator; import com.fr.design.foldablepane.UIExpandablePane; import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.xpane.LayoutStylePane; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.widget.accessibles.AccessibleWLayoutBorderStyleEditor; @@ -20,7 +21,7 @@ import java.awt.*; * Created by kerry on 2017/8/29. */ public class BorderStyleWidgetDefinePane extends AbstractDataModify { - private AccessibleWLayoutBorderStyleEditor borderStyleEditor; + private LayoutStylePane stylePane; public BorderStyleWidgetDefinePane(XCreator xCreator) { super(xCreator); @@ -29,13 +30,10 @@ public class BorderStyleWidgetDefinePane extends AbstractDataModify ADAPT_LABEL_MAX_WIDTH ? ADAPT_LABEL_MAX_WIDTH : p; - double[] columnSize = {adaptLabelColumnWidth, f}; - int[][] rowCount = {{1, 1}, {1, 1}}; - JPanel northPane = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{ - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Attr_Layout_Type")), layoutComboBox}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W1, IntervalConstants.INTERVAL_L1); - northPane.setBorder(BorderFactory.createEmptyBorder(IntervalConstants.INTERVAL_L1, 0, 0, 0)); - - - - Component[][] components = new Component[][]{ - new Component[]{adaptLabel, adaptComboBoxPane}, - new Component[]{intervalLabel, componentIntervelPane} - }; - JPanel centerPane = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, IntervalConstants.INTERVAL_W1, IntervalConstants.INTERVAL_L1); - centerPane.setBorder(BorderFactory.createEmptyBorder(IntervalConstants.INTERVAL_L1, IntervalConstants.INTERVAL_L5, 0, 0)); - jPanel.add(northPane, BorderLayout.NORTH); - jPanel.add(centerPane, BorderLayout.CENTER); - return jPanel; + JPanel contentPane = TableLayoutHelper.createGapTableLayoutPane( + new Component[][]{ + {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Attr_Layout_Type")), layoutComboBox}, + {adaptLabel, adaptComboBoxPane}, + {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; } @@ -154,7 +157,7 @@ public class FRFitLayoutDefinePane extends AbstractFRLayoutDefinePane { - private AccessibleCardTagWLayoutBorderStyleEditor accessibleCardTagWLayoutBorderStyleEditor; + private CardTagLayoutStylePane stylePane; private UICheckBox setCarousel; private UISpinner carouselInterval; private JPanel IntervalPane; @@ -39,11 +41,8 @@ public class WCardMainLayoutDefinePane extends AbstractDataModify extends AbstractDataModify { - private AccessibleWLayoutBorderStyleEditor borderStyleEditor; + private LayoutStylePane stylePane; public WTitleLayoutDefinePane(XCreator xCreator) { super(xCreator); @@ -34,18 +27,8 @@ public abstract class WTitleLayoutDefinePane Date: Mon, 5 Jul 2021 17:13:40 +0800 Subject: [PATCH 09/14] =?UTF-8?q?REPORT-54438=20=E5=8D=95=E5=85=83?= =?UTF-8?q?=E6=A0=BC=E5=B1=9E=E6=80=A7=E8=AE=BE=E7=BD=AE=E9=9D=A2=E6=9D=BF?= =?UTF-8?q?=20=E5=9C=A8=E5=88=87=E6=8D=A2=E5=8F=82=E6=95=B0=E9=9D=A2?= =?UTF-8?q?=E6=9D=BF=E7=BC=96=E8=BE=91=E5=90=8E=20=E9=9D=A2=E6=9D=BF?= =?UTF-8?q?=E6=9C=AA=E5=88=B7=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/mainframe/widget/ui/FormWidgetCardPane.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormWidgetCardPane.java b/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormWidgetCardPane.java index 2fc161fc0a..e0c6073238 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormWidgetCardPane.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormWidgetCardPane.java @@ -24,6 +24,7 @@ import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.EastRegionContainerPane; import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.JForm; +import com.fr.design.mainframe.JTemplate; import com.fr.design.widget.DataModify; import com.fr.design.widget.FormWidgetDefinePaneFactoryBase; import com.fr.design.widget.Operator; @@ -164,7 +165,8 @@ public class FormWidgetCardPane extends AbstractAttrNoScrollPane { } private static void freshPropertyMode(XCreator xCreator) { - if (!(HistoryTemplateListCache.getInstance().getCurrentEditingTemplate() instanceof JForm)) { + JTemplate jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + if (!(jTemplate instanceof JForm) && jTemplate.isUpMode()) { if (xCreator instanceof XWParameterLayout) { EastRegionContainerPane.getInstance().switchMode(EastRegionContainerPane.PropertyMode.REPORT_PARA); } else { From 644338f3ecc22be697807d9b04fbb9ade4e502b4 Mon Sep 17 00:00:00 2001 From: "Bruce.Deng" Date: Mon, 5 Jul 2021 17:41:00 +0800 Subject: [PATCH 10/14] =?UTF-8?q?REPORT-52847=20=E3=80=9010.0.18=E3=80=91?= =?UTF-8?q?=E9=83=A8=E5=88=86=E6=95=B0=E6=8D=AE=E8=BF=9E=E6=8E=A5=E6=94=AF?= =?UTF-8?q?=E6=8C=81fetchsize?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/data/datapane/connect/JDBCConnectionDef.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/connect/JDBCConnectionDef.java b/designer-base/src/main/java/com/fr/design/data/datapane/connect/JDBCConnectionDef.java index 1410decee6..6d15b23e9f 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/connect/JDBCConnectionDef.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/connect/JDBCConnectionDef.java @@ -24,6 +24,10 @@ public class JDBCConnectionDef { return instance; } + private JDBCConnectionDef() { + + } + public String getDatabaseName() { return databaseName; } From d99bffbc5826f7e59337bd755485790512dfb8aa Mon Sep 17 00:00:00 2001 From: vito Date: Mon, 5 Jul 2021 17:43:29 +0800 Subject: [PATCH 11/14] =?UTF-8?q?REPORT-53699=20=E6=9B=B4=E6=94=B9?= =?UTF-8?q?=E7=9B=91=E5=90=ACBeforeAllStop=E4=BA=8B=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/design/mainframe/app/DesignerAppUtils.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/app/DesignerAppUtils.java b/designer-realize/src/main/java/com/fr/design/mainframe/app/DesignerAppUtils.java index a00e7dd6fc..437458c9ae 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/app/DesignerAppUtils.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/app/DesignerAppUtils.java @@ -43,7 +43,7 @@ public class DesignerAppUtils { private static final int DEFAULT_MAX_CACHE_SIZE = 50; private static final int DEFAULT_CONCURRENCY_LEVEL = 8; private static final long DEFAULT_EXPIRE_HOURS = 1; - private static boolean enablePluginTipDialog = true; + private volatile static boolean enablePluginTipDialog = true; private static final Cache> ERROR_CACHE = CacheBuilder.newBuilder() .maximumSize(DEFAULT_MAX_CACHE_SIZE) @@ -52,7 +52,7 @@ public class DesignerAppUtils { .build(); public static void initPluginAllActiveListener() { - PluginListenerRegistration.getInstance().listen(PluginEventType.BeforeAllActive, new PluginEventListener() { + PluginListenerRegistration.getInstance().listen(PluginEventType.BeforeAllStop, new PluginEventListener() { @Override public void on(PluginEvent event) { enablePluginTipDialog = false; From 0b968f8351c106dff0d5f9b5f1e70e98cbc45bec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E5=B2=B3?= <445798420@qq.com> Date: Tue, 6 Jul 2021 09:43:46 +0800 Subject: [PATCH 12/14] =?UTF-8?q?CHART-19720=20=20=E6=8E=A7=E4=BB=B6?= =?UTF-8?q?=E9=A1=BA=E5=BA=8F=E5=8F=8D=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../designer/other/VanChartInteractivePane.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/other/VanChartInteractivePane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/other/VanChartInteractivePane.java index d1ac6aa14c..4a0e7adc54 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/other/VanChartInteractivePane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/other/VanChartInteractivePane.java @@ -209,9 +209,9 @@ public class VanChartInteractivePane extends AbstractVanChartScrollPane { } private void createChangeEnablePane(VanChartRectanglePlot plot) { - String scroll = Toolkit.i18nText("Fine-Design_Chart_Scroll"); String scaleAxis = Toolkit.i18nText("Fine-Design_Chart_Scale_Axis"); - controlType = new UIButtonGroup<>(new String[]{scroll, scaleAxis}, ControlType.values()); + String scroll = Toolkit.i18nText("Fine-Design_Chart_Scroll"); + controlType = new UIButtonGroup<>(new String[]{scaleAxis, scroll}, ControlType.values()); JPanel scaleAxisPane = createScaleAxisPane(); JPanel scrollPane = createScrollPane(plot); @@ -225,8 +225,8 @@ public class VanChartInteractivePane extends AbstractVanChartScrollPane { } } }; - centerPane.add(scaleAxisPane, scroll); - centerPane.add(scrollPane, scaleAxis); + centerPane.add(scaleAxisPane, scaleAxis); + centerPane.add(scrollPane, scroll); double p = TableLayout.PREFERRED; double f = TableLayout.FILL; @@ -291,9 +291,9 @@ public class VanChartInteractivePane extends AbstractVanChartScrollPane { if (centerPane != null && controlType != null) { CardLayout cardLayout = (CardLayout) centerPane.getLayout(); if (controlType.getSelectedItem() == ControlType.ZOOM) { - cardLayout.show(centerPane, Toolkit.i18nText("Fine-Design_Chart_Scroll")); - } else { cardLayout.show(centerPane, Toolkit.i18nText("Fine-Design_Chart_Scale_Axis")); + } else { + cardLayout.show(centerPane, Toolkit.i18nText("Fine-Design_Chart_Scroll")); } } } From 4563e2e7817e2649f279a2b8685b14022b0da45d Mon Sep 17 00:00:00 2001 From: Lanlan Date: Tue, 6 Jul 2021 10:32:43 +0800 Subject: [PATCH 13/14] =?UTF-8?q?REPORT-54817=20=E5=86=85=E7=BD=91?= =?UTF-8?q?=E7=8E=AF=E5=A2=83=E4=B8=8B=E8=AF=A5=E8=BF=AD=E4=BB=A3=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E5=BA=94=E5=BD=93=E4=B8=8D=E7=94=9F=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/login/AbstractDesignerSSO.java | 4 ++++ .../login/guide/DesignerGuideHelper.java | 6 +++++- .../login/message/DesignerMessageHelper.java | 3 +++ .../login/utils/DesignerLoginUtils.java | 19 +++++++++++++++++++ 4 files changed, 31 insertions(+), 1 deletion(-) diff --git a/designer-base/src/main/java/com/fr/design/login/AbstractDesignerSSO.java b/designer-base/src/main/java/com/fr/design/login/AbstractDesignerSSO.java index 6fc3c817b4..2662198bbc 100644 --- a/designer-base/src/main/java/com/fr/design/login/AbstractDesignerSSO.java +++ b/designer-base/src/main/java/com/fr/design/login/AbstractDesignerSSO.java @@ -20,6 +20,10 @@ public abstract class AbstractDesignerSSO extends UpdateAction { @Override public void actionPerformed(ActionEvent event) { String url = getJumpUrl(); + if (!DesignerLoginUtils.isOnline()) { + BrowseUtils.browser(url); + return; + } DesignerEnvManager manager = DesignerEnvManager.getEnvManager(); int uid = manager.getDesignerLoginUid(); if (uid > 0) { diff --git a/designer-base/src/main/java/com/fr/design/login/guide/DesignerGuideHelper.java b/designer-base/src/main/java/com/fr/design/login/guide/DesignerGuideHelper.java index 8adebba4f1..92e4171460 100644 --- a/designer-base/src/main/java/com/fr/design/login/guide/DesignerGuideHelper.java +++ b/designer-base/src/main/java/com/fr/design/login/guide/DesignerGuideHelper.java @@ -4,9 +4,13 @@ import com.fr.base.FRContext; import com.fr.design.DesignerEnvManager; import com.fr.design.dialog.UIDialog; import com.fr.design.event.DesignerOpenedListener; +import com.fr.design.login.utils.DesignerLoginUtils; import com.fr.design.mainframe.DesignerContext; import com.fr.design.os.impl.SupportOSImpl; import com.fr.design.update.push.DesignerPushUpdateManager; +import com.fr.general.CloudCenter; +import com.fr.general.CloudCenterConfig; +import com.fr.general.http.HttpToolbox; import com.fr.stable.StringUtils; import javax.swing.WindowConstants; @@ -35,7 +39,7 @@ public class DesignerGuideHelper { public static void prepareShowGuideDialog() { // 如果存在更新升级的弹窗,则不显示引导页面 - if (!SupportOSImpl.DESIGNER_LOGIN.support() || !FRContext.isChineseEnv() || DesignerPushUpdateManager.getInstance().isShouldPopUp()) { + if (!DesignerLoginUtils.isOnline() || !SupportOSImpl.DESIGNER_LOGIN.support() || !FRContext.isChineseEnv() || DesignerPushUpdateManager.getInstance().isShouldPopUp()) { return; } if (isActivatedForOneWeek()) { diff --git a/designer-base/src/main/java/com/fr/design/login/message/DesignerMessageHelper.java b/designer-base/src/main/java/com/fr/design/login/message/DesignerMessageHelper.java index c053fc0e50..f3768629b4 100644 --- a/designer-base/src/main/java/com/fr/design/login/message/DesignerMessageHelper.java +++ b/designer-base/src/main/java/com/fr/design/login/message/DesignerMessageHelper.java @@ -51,6 +51,9 @@ public class DesignerMessageHelper { } public void prepareShowMessage() { + if (!DesignerLoginUtils.isOnline()) { + return; + } DesignerContext.getDesignerFrame().addDesignerOpenedListener(new DesignerOpenedListener() { @Override public void designerOpened() { diff --git a/designer-base/src/main/java/com/fr/design/login/utils/DesignerLoginUtils.java b/designer-base/src/main/java/com/fr/design/login/utils/DesignerLoginUtils.java index 26e095df6a..a39a0be4bf 100644 --- a/designer-base/src/main/java/com/fr/design/login/utils/DesignerLoginUtils.java +++ b/designer-base/src/main/java/com/fr/design/login/utils/DesignerLoginUtils.java @@ -3,10 +3,13 @@ package com.fr.design.login.utils; import com.fr.design.DesignerEnvManager; import com.fr.design.mainframe.toast.DesignerToastMsgUtil; import com.fr.general.CloudCenter; +import com.fr.general.CloudCenterConfig; import com.fr.general.GeneralContext; +import com.fr.general.http.HttpToolbox; import com.fr.general.log.MessageFormatter; import com.fr.json.JSONObject; import com.fr.log.FineLoggerFactory; +import com.fr.stable.StringUtils; import com.fr.third.org.bouncycastle.util.encoders.Hex; import java.awt.Window; import java.security.SecureRandom; @@ -49,6 +52,9 @@ public class DesignerLoginUtils { } public static String generateDesignerSSOUrl(String referrer) { + if (!DesignerLoginUtils.isOnline()) { + return referrer; + } String ssoTemplate = CloudCenter.getInstance().acquireUrlByKind("designer.sso.api", "https://id.fanruan.com/api/app/?code={}&referrer={}"); try { String code = generateLoginCode(); @@ -60,6 +66,19 @@ public class DesignerLoginUtils { return referrer; } + public static boolean isOnline() { + if (CloudCenterConfig.getInstance().isOnline()) { + String ping = CloudCenter.getInstance().acquireConf("ping", StringUtils.EMPTY); + if (StringUtils.isNotEmpty(ping)) { + try { + return StringUtils.isEmpty(HttpToolbox.get(ping)); + } catch (Exception ignore) { + } + } + } + return false; + } + private static String generateLoginCode() throws Exception { DesignerEnvManager manager = DesignerEnvManager.getEnvManager(); JSONObject jo = JSONObject.create(); From d4fc5e23cfb342e1e04d08dddc119bd91034ddbb Mon Sep 17 00:00:00 2001 From: pengda Date: Tue, 6 Jul 2021 11:11:48 +0800 Subject: [PATCH 14/14] =?UTF-8?q?REPORT-54844=20jar=E5=8C=85=E7=9B=B8?= =?UTF-8?q?=E5=90=8C=E6=83=85=E5=86=B5=E4=B8=8B=EF=BC=8C=E5=90=8C=E6=AD=A5?= =?UTF-8?q?=E6=8F=92=E4=BB=B6=E6=97=B6=E5=90=8C=E6=AD=A5=E6=8C=89=E9=92=AE?= =?UTF-8?q?=E4=B8=80=E7=9B=B4=E6=B2=A1=E7=81=B0=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- designer-base/src/main/java/com/fr/env/CheckServiceDialog.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/designer-base/src/main/java/com/fr/env/CheckServiceDialog.java b/designer-base/src/main/java/com/fr/env/CheckServiceDialog.java index 185268e79c..fb1adae6fe 100644 --- a/designer-base/src/main/java/com/fr/env/CheckServiceDialog.java +++ b/designer-base/src/main/java/com/fr/env/CheckServiceDialog.java @@ -309,6 +309,7 @@ public class CheckServiceDialog extends JDialog implements ActionListener { @Override public void mouseClicked(MouseEvent e) { ignoreButton.setEnabled(false); + syncButton.setEnabled(false); String[] option = {Toolkit.i18nText("Fine-Design_Report_Yes"), Toolkit.i18nText("Fine-Design_Report_No")}; if (!jarConsistency) { int a = FineJOptionPane.showOptionDialog(getParent(), Toolkit.i18nText("Fine-Design_Basic_Sync_Info_Information"), @@ -350,6 +351,7 @@ public class CheckServiceDialog extends JDialog implements ActionListener { @Override protected JSONArray doInBackground() { + progressBar.setVisible(true); progressBar.setString(Toolkit.i18nText("Fine-Design_Basic_Sync_Plugins")); progressBar.setValue(0); return VersionCheckUtils.syncPlugins(differentPlugins);