From 39c29ab26d386ca727efbb14eaab7466e275ee9e Mon Sep 17 00:00:00 2001 From: hades Date: Tue, 6 Jul 2021 10:15:30 +0800 Subject: [PATCH 1/3] =?UTF-8?q?REPORT-54122=20=E8=AE=BE=E8=AE=A1=E5=99=A8?= =?UTF-8?q?=E7=BB=84=E4=BB=B6=E6=82=AC=E5=81=9C/=E9=80=89=E4=B8=AD/?= =?UTF-8?q?=E7=BC=96=E8=BE=91=E7=8A=B6=E6=80=81=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/images/control/show_edit.png | Bin 0 -> 304 bytes .../fr/design/images/control/show_setting.png | Bin 0 -> 281 bytes .../designer/creator/SelectedBorderIcon.java | 47 ++++++++++ .../fr/design/designer/creator/XCreator.java | 22 +++++ .../fr/design/mainframe/ComponentTree.java | 82 +++++++++++++++++- .../mainframe/EditingMouseListener.java | 40 ++++++++- .../mainframe/FormCreatorDropTarget.java | 11 +++ .../fr/design/mainframe/FormDesignerUI.java | 39 ++++++--- .../fr/design/mainframe/FormSelection.java | 3 + 9 files changed, 230 insertions(+), 14 deletions(-) create mode 100644 designer-base/src/main/resources/com/fr/design/images/control/show_edit.png create mode 100644 designer-base/src/main/resources/com/fr/design/images/control/show_setting.png create mode 100644 designer-form/src/main/java/com/fr/design/designer/creator/SelectedBorderIcon.java diff --git a/designer-base/src/main/resources/com/fr/design/images/control/show_edit.png b/designer-base/src/main/resources/com/fr/design/images/control/show_edit.png new file mode 100644 index 0000000000000000000000000000000000000000..9378e76c5f5f969c782028ca87d3e8b5676c7273 GIT binary patch literal 304 zcmV-00nh%4P)%4P1gBOq>D1ND$YciMk3A+{75^A_OrqP!mxMT!4b1FsUHol@3OF zpnJL-E3K+i@7`A>{|v|dNp69D6;CbKtpFqSt*9+0QZB3lCD{V5ffseT6ClYV@C5XL zWA(H(Ajuq1NL&Z5fF1Rx3t$Kw0C$O>CN4m;VJ45t$L|(NuW=0000*q)O`A@-*y{VM!hF#{~NYIV7mh}B`s{f0F!7MOPbn#1imG$GqN*5G_QaL zFbD2|hX8&88(;wZ0NsovPmtI@E{vp~R3>cM!h1~lk7q7vSg;U*JprSf?4;&7fHR<< zv-1kPrC?7AY;S?v(%6=yuc+Suhf;kf>F#O-Y3J1~WYTO`3o(4wTVw4*3Ki8)xqLa5 fKGTI~T!0+`QonK$Q5cW*00000NkvXXu0mjfNWyQ% literal 0 HcmV?d00001 diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/SelectedBorderIcon.java b/designer-form/src/main/java/com/fr/design/designer/creator/SelectedBorderIcon.java new file mode 100644 index 0000000000..fe2d839b96 --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/designer/creator/SelectedBorderIcon.java @@ -0,0 +1,47 @@ +package com.fr.design.designer.creator; + +import com.fr.design.form.util.XCreatorConstants; +import com.fr.general.IOUtils; +import java.awt.AlphaComposite; +import java.awt.Color; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Image; +import java.awt.Rectangle; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2021/06/30 + */ +public class SelectedBorderIcon { + + private static final Image EDIT_ICON = IOUtils.readImage("/com/fr/design/images/control/show_edit.png"); + private static final Image SETTING_ICON = IOUtils.readImage("/com/fr/design/images/control/show_setting.png"); + private static final float ALPHA = 0.7F; + private static final int TIP_WIDTH = 20; + private static final int TIP_HEIGHT = 40; + private static final int ARC_VALUE = 4; + // 组件到整个提示之间的空隙 + private static final int CREATOR_TO_TIP_GAP = 5; + // icon在整个提示背景下缩进 + private static final int TIP_ICON_GAP = 2; + + /** + * 在bounds范围的右上角绘制特定图标 + * + * @param g + * @param bounds + */ + public void paint(Graphics g, Rectangle bounds) { + Graphics2D g2d = (Graphics2D) g; + AlphaComposite alphaComposite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, ALPHA); + g2d.setColor(XCreatorConstants.EDIT_COLOR); + g2d.setComposite(alphaComposite); + g2d.fillRoundRect(bounds.x + bounds.width + CREATOR_TO_TIP_GAP, bounds.y, TIP_WIDTH, TIP_HEIGHT, ARC_VALUE, ARC_VALUE); + g2d.drawImage(EDIT_ICON, bounds.x + bounds.width + CREATOR_TO_TIP_GAP + TIP_ICON_GAP, bounds.y + TIP_ICON_GAP, EDIT_ICON.getWidth(null), EDIT_ICON.getHeight(null), null); + g2d.drawImage(SETTING_ICON, bounds.x + bounds.width + CREATOR_TO_TIP_GAP + TIP_ICON_GAP, bounds.y + CREATOR_TO_TIP_GAP + EDIT_ICON.getHeight(null), SETTING_ICON.getWidth(null), SETTING_ICON.getHeight(null), null); + g2d.setColor(Color.WHITE); + g2d.drawLine(bounds.x + bounds.width + CREATOR_TO_TIP_GAP + TIP_ICON_GAP, bounds.y + TIP_WIDTH, bounds.x + bounds.width + CREATOR_TO_TIP_GAP + TIP_ICON_GAP + EDIT_ICON.getWidth(null), bounds.y + TIP_WIDTH); + } +} diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java b/designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java index 265fa3618c..7220eafe8b 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java @@ -68,6 +68,9 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo private Rectangle backupBound; private String shareId = StringUtils.EMPTY;//如果组件是共享的会有这个属性 private boolean isHelpBtnOnFocus = false;//焦点是否在帮助按钮上 + // 当前组件是否处在选中状态 + private boolean selected; + private SelectedBorderIcon selectedBorderIcon = new SelectedBorderIcon(); private static final int SHORTS_SEPARATOR_POS = 4; // 弹出菜单分割的位置 public XCreator(Widget ob, Dimension initSize) { @@ -760,6 +763,18 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo GraphHelper.draw(g, bounds, Constants.LINE_MEDIUM); } + /** + * 绘制选中时右上边框图标 + * + * @param g + * @param bounds + */ + public void paintSelectedBorderIcon(Graphics g, Rectangle bounds) { + if (selected) { + selectedBorderIcon.paint(g, bounds); + } + } + /** * 创建右击弹出菜单 * @@ -797,5 +812,12 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo } + public boolean isSelected() { + return selected; + } + + public void setSelected(boolean selected) { + this.selected = selected; + } } diff --git a/designer-form/src/main/java/com/fr/design/mainframe/ComponentTree.java b/designer-form/src/main/java/com/fr/design/mainframe/ComponentTree.java index c9ae03272f..134252487c 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/ComponentTree.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/ComponentTree.java @@ -2,15 +2,20 @@ package com.fr.design.mainframe; import com.fr.design.constants.UIConstants; import com.fr.design.designer.creator.XCreator; +import com.fr.design.designer.creator.XCreatorUtils; import com.fr.design.designer.creator.XLayoutContainer; import com.fr.design.designer.treeview.ComponentTreeCellRenderer; import com.fr.design.designer.treeview.ComponentTreeModel; import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.gui.itree.UITreeUI; +import com.fr.design.utils.ComponentUtils; import com.fr.design.utils.gui.GUICoreUtils; -import com.fr.log.FineLoggerFactory; +import com.fr.stable.ArrayUtils; import com.fr.stable.StringUtils; +import java.awt.Rectangle; +import java.awt.event.MouseListener; +import java.util.Stack; import javax.swing.BorderFactory; import javax.swing.DropMode; import javax.swing.JPanel; @@ -370,6 +375,81 @@ public class ComponentTree extends JTree { public void mouseExited(MouseEvent e) { hidePreviewPane(); } + + @Override + public void mouseClicked(MouseEvent e) { + // 鼠标左键 双击 + if (e.getClickCount() == 2 && e.getButton() == MouseEvent.BUTTON1 && !designer.isFormParaDesigner()) { + Point p = e.getPoint(); + // 解析组件树路径 获取选中的组件 + int selRow = tree.getRowForLocation(p.x, p.y); + TreePath path = tree.getPathForRow(selRow); + Rectangle bounds = tree.getPathBounds(path); + if (bounds != null) { + Point point = bounds.getLocation(); + SwingUtilities.convertPointToScreen(point, tree); + XCreator comp = (XCreator) path.getLastPathComponent(); + startEditing(comp, e); + } + } + } + + /** + * 组件进入编辑状态 + * + * @param comp + * @param e + */ + private void startEditing(XCreator comp, MouseEvent e) { + designer.getSelectionModel().selectACreator(comp); + Rectangle rectangle = getRelativeBounds(comp); + int x = rectangle.x + rectangle.width / 2; + int y = rectangle.y + rectangle.height / 2; + XCreator creator = comp.getEditingChildCreator(); + MouseListener[] listeners = designer.getMouseListeners(); + if (ArrayUtils.isNotEmpty(listeners) && listeners[0] instanceof EditingMouseListener) { + responseClickAll(creator, (EditingMouseListener) listeners[0], new MouseEvent(creator, MouseEvent.MOUSE_CLICKED, e.getWhen(), e.getModifiers(), x, y, e.getClickCount(), false)); + } + } + + /** + * 自父容器到子组件 每一层的都响应click事件 + * + * + * @param creator + * @param editingMouseListener + * @param mouseEvent + */ + public void responseClickAll(XCreator creator, EditingMouseListener editingMouseListener, MouseEvent mouseEvent) { + Stack stack = new Stack<>(); + stack.push(creator); + while (creator.getParent() instanceof XCreator) { + creator = (XCreator) creator.getParent(); + stack.push(creator); + } + while (!stack.isEmpty()) { + stack.pop().respondClick(editingMouseListener, mouseEvent); + } + } + + + /** + * 获取组件范围坐标 + * + * @param creator + * @return + */ + private Rectangle getRelativeBounds(XCreator creator) { + Rectangle bounds = creator.getBounds(); + XLayoutContainer parent = XCreatorUtils.getParentXLayoutContainer(creator); + if (parent == null) { + return bounds; + } + Rectangle rec = ComponentUtils.getRelativeBounds(parent); + bounds.x += rec.x; + bounds.y += rec.y; + return bounds; + } } private class PopupPreviewPane extends JPopupMenu { diff --git a/designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java b/designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java index a8ad6dd585..00ba360bba 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java @@ -21,6 +21,7 @@ import com.fr.design.designer.creator.XLayoutContainer; import com.fr.design.designer.creator.XWFitLayout; import com.fr.design.designer.creator.cardlayout.XCardSwitchButton; import com.fr.design.designer.creator.cardlayout.XWCardLayout; +import com.fr.design.designer.creator.cardlayout.XWCardMainBorderLayout; import com.fr.design.form.util.XCreatorConstants; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.imenu.UIPopupMenu; @@ -29,6 +30,7 @@ import com.fr.design.icon.IconPathConstants; import com.fr.design.utils.ComponentUtils; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.LayoutUtils; +import com.fr.general.ComparatorUtils; import com.fr.stable.Constants; import javax.swing.BorderFactory; @@ -353,6 +355,15 @@ public class EditingMouseListener extends MouseInputAdapter { } + private void processCoverPane(XCreator component) { + // selected状态 不展示封面 + XCreator xCreator = selectionModel.getSelection().getSelectedCreator(); + boolean accept = xCreator == null || !ComparatorUtils.equals(xCreator.toData().getWidgetName(), component.toData().getWidgetName()) ||!xCreator.isSelected(); + if (accept) { + component.displayCoverPane(true); + } + } + private boolean isShareConfigButton(MouseEvent e, XCreator component, Insets insets) { if (component.isShared()) { int minX = getParentPositionX(component, component.getX()) + component.getWidth() - insets.right - CoverReportPane.SHARE_CONF_BTN_W - designer.getHorizontalScaleValue(); @@ -387,7 +398,7 @@ public class EditingMouseListener extends MouseInputAdapter { private void elementCaseMouseMoved(MouseEvent e, XCreator component) { xElementCase = (XElementCase) component; - component.displayCoverPane(true); + processCoverPane(component); processCoverMouseMove(component, e); } @@ -428,7 +439,7 @@ public class EditingMouseListener extends MouseInputAdapter { private void processChartEditorMouseMove(XCreator component, MouseEvent e) { if (component instanceof XChartEditor) { xChartEditor = (XChartEditor) component; - component.displayCoverPane(true); + processCoverPane(component); processCoverMouseMove(component, e); } @@ -608,10 +619,23 @@ public class EditingMouseListener extends MouseInputAdapter { return; } + XCreator oldCreator = creator; creator = processTopLayoutMouseClick(creator); if (creator != null) { - creator.respondClick(this, e); + if (e.getClickCount() == 1 && designer.getCursor().getType() != Cursor.HAND_CURSOR) { + setCoverPaneNotDisplay(creator, e, false); + selectionModel.selectACreatorAtMouseEvent(e); + refreshTopXCreator(); + XCreator[] xCreators = selectionModel.getSelection().getSelectedCreators(); + for (XCreator xCreator : xCreators) { + xCreator.setSelected(true); + } + } else if (responseTabLayout(oldCreator, e)) { + // do nothing + } else { + creator.respondClick(this, e); + } if (e.getButton() == MouseEvent.BUTTON3) { UIPopupMenu cellPopupMenu = creator.createPopupMenu(designer); if (cellPopupMenu != UIPopupMenu.EMPTY) { @@ -624,6 +648,16 @@ public class EditingMouseListener extends MouseInputAdapter { LayoutUtils.layoutRootContainer(designer.getRootComponent()); } + private boolean responseTabLayout(XCreator creator, MouseEvent e) { + if (creator.acceptType(XWCardMainBorderLayout.class) ) { + creator.respondClick(this, e); + return true; + } else if (creator.getParent() instanceof XCreator) { + return responseTabLayout((XCreator) creator.getParent(), e); + } + return false; + } + /** * 离开 diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormCreatorDropTarget.java b/designer-form/src/main/java/com/fr/design/mainframe/FormCreatorDropTarget.java index 222165a53c..30b941818d 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/FormCreatorDropTarget.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/FormCreatorDropTarget.java @@ -49,6 +49,7 @@ import java.awt.dnd.DropTarget; import java.awt.dnd.DropTargetDragEvent; import java.awt.dnd.DropTargetDropEvent; import java.awt.dnd.DropTargetEvent; +import javax.swing.SwingUtilities; /** * 添加模式下鼠标事件处理器。 @@ -302,6 +303,16 @@ public class FormCreatorDropTarget extends DropTarget { public synchronized void drop(DropTargetDropEvent dtde) { Point loc = dtde.getLocation(); this.adding(designer.getRelativeX(loc.x), designer.getRelativeY(loc.y)); + // 放到事件末尾执行 + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + // 拖拽释放后标记未选中 + for (XCreator xCreator : designer.getSelectionModel().getSelection().getSelectedCreators()) { + xCreator.setSelected(true); + } + } + }); //针对在表单中拖入一个控件直接ctrl+s无反应 designer.requestFocus(); } diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormDesignerUI.java b/designer-form/src/main/java/com/fr/design/mainframe/FormDesignerUI.java index 7cd9e21083..8df27c19fe 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/FormDesignerUI.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/FormDesignerUI.java @@ -307,7 +307,10 @@ public class FormDesignerUI extends ComponentUI { bounds.x -= designer.getHorizontalScaleValue(); bounds.y -= designer.getVerticalScaleValue(); - drawResizingThumbs(g, selectionModel.getSelection().getDirections(), bounds.x, bounds.y, bounds.width, bounds.height); + // 绘制调整框线 + if (designer.getStateModel().getDirection() != null) { + drawResizingThumbs(g, selectionModel.getSelection().getDirections(), bounds.x, bounds.y, bounds.width, bounds.height, designer.getStateModel().getDirection().getActual()); + } //选中时边框颜色 g.setColor(XCreatorConstants.FORM_BORDER_COLOR); @@ -321,6 +324,10 @@ public class FormDesignerUI extends ComponentUI { resetCreatorBounds(creatorBounds); } creator.paintBorder(g, creatorBounds); + // 拖拽时不绘制 + if (!designer.getStateModel().isDragging()) { + creator.paintSelectedBorderIcon(g, creatorBounds); + } } } @@ -357,48 +364,60 @@ public class FormDesignerUI extends ComponentUI { /** * 画出八个拖拽框 */ - private void drawResizingThumbs(Graphics g, int[] directions, int x, int y, int w, int h) { + private void drawResizingThumbs(Graphics g, int[] directions, int x, int y, int w, int h, int direction) { int bx = x - XCreatorConstants.RESIZE_BOX_SIZ; int by = y - XCreatorConstants.RESIZE_BOX_SIZ; - if (ArrayUtils.contains(directions, Direction.LEFT_TOP)) { + if (showBox(Direction.LEFT_TOP, direction, directions)) { drawBox(g, bx, by); } - if (ArrayUtils.contains(directions, Direction.TOP)) { + if (showBox(Direction.TOP, direction, directions)) { bx = x + ((w - XCreatorConstants.RESIZE_BOX_SIZ) / 2); drawBox(g, bx, by); } - if (ArrayUtils.contains(directions, Direction.RIGHT_TOP)) { + if (showBox(Direction.RIGHT_TOP, direction, directions)) { bx = x + w; drawBox(g, bx, by); } - if (ArrayUtils.contains(directions, Direction.LEFT)) { + if (showBox(Direction.LEFT, direction, directions)) { bx = x - XCreatorConstants.RESIZE_BOX_SIZ; by = y + ((h - XCreatorConstants.RESIZE_BOX_SIZ) / 2); drawBox(g, bx, by); } - if (ArrayUtils.contains(directions, Direction.LEFT_BOTTOM)) { + if (showBox(Direction.LEFT_BOTTOM, direction, directions)) { bx = x - XCreatorConstants.RESIZE_BOX_SIZ; by = y + h; drawBox(g, bx, by); } - if (ArrayUtils.contains(directions, Direction.BOTTOM)) { + if (showBox(Direction.BOTTOM, direction, directions)) { bx = x + ((w - XCreatorConstants.RESIZE_BOX_SIZ) / 2); by = y + h; drawBox(g, bx, by); } - if (ArrayUtils.contains(directions, Direction.RIGHT_BOTTOM)) { + if (showBox(Direction.RIGHT_BOTTOM, direction, directions)) { bx = x + w; by = y + h; drawBox(g, bx, by); } - if (ArrayUtils.contains(directions, Direction.RIGHT)) { + if (showBox(Direction.RIGHT, direction, directions)) { bx = x + w; by = y + ((h - XCreatorConstants.RESIZE_BOX_SIZ) / 2); drawBox(g, bx, by); } } + /** + * 是否展示某个方位的调整框 + * + * @param currentDirection + * @param actualDirection + * @param directions + * @return + */ + private boolean showBox(int currentDirection, int actualDirection, int[] directions) { + return ArrayUtils.contains(directions, currentDirection) && (currentDirection == actualDirection || !designer.getStateModel().isDragging()); + } + /** * 画每一个小拖拽框 */ diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormSelection.java b/designer-form/src/main/java/com/fr/design/mainframe/FormSelection.java index 956e1cb66a..3bf4b49ac3 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/FormSelection.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/FormSelection.java @@ -40,6 +40,9 @@ public class FormSelection { * 重置选中的组件 */ public void reset() { + for (XCreator xCreator : selection) { + xCreator.setSelected(false); + } selection.clear(); } From 5cfb22420c95c3d1ef3e631330b7f72e15d21a6d 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 15:13:11 +0800 Subject: [PATCH 2/3] =?UTF-8?q?CHART-19708=20=E5=9B=BE=E8=A1=A8=E5=9D=97?= =?UTF-8?q?=E5=9B=BE=E8=A1=A8=E6=A0=87=E9=A2=98=E8=83=8C=E6=99=AF=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/chart/gui/ChartWidgetOption.java | 9 +++- .../design/mainframe/chart/ChartEditPane.java | 12 +++++ .../chart/gui/ChartTypeButtonPane.java | 13 +++++ .../mainframe/chart/gui/ChartTypePane.java | 9 +++- .../chart/bubble/VanChartBubbleStylePane.java | 14 ++--- .../custom/style/VanChartCustomStylePane.java | 5 +- .../designer/style/VanChartStylePane.java | 26 +++++++--- .../designer/style/VanChartTitlePane.java | 25 +++++++-- .../VanChartAreaBackgroundPane.java | 52 +++++++++++++------ .../style/background/VanChartAreaPane.java | 15 ++++-- 10 files changed, 136 insertions(+), 44 deletions(-) diff --git a/designer-chart/src/main/java/com/fr/design/chart/gui/ChartWidgetOption.java b/designer-chart/src/main/java/com/fr/design/chart/gui/ChartWidgetOption.java index 42eabf93e1..7e64f3d209 100644 --- a/designer-chart/src/main/java/com/fr/design/chart/gui/ChartWidgetOption.java +++ b/designer-chart/src/main/java/com/fr/design/chart/gui/ChartWidgetOption.java @@ -1,10 +1,12 @@ package com.fr.design.chart.gui; import com.fr.base.chart.BaseChartGetter; +import com.fr.chart.chartattr.ChartCollection; import com.fr.design.gui.core.WidgetOption; import com.fr.form.ui.ChartEditor; import com.fr.form.ui.Widget; import com.fr.log.FineLoggerFactory; +import com.fr.plugin.chart.vanchart.VanChart; import javax.swing.Icon; @@ -37,7 +39,12 @@ public class ChartWidgetOption extends WidgetOption { Class clz = widgetClass(); try { ChartEditor widget = clz.newInstance(); - widget.resetChangeChartCollection(BaseChartGetter.createChartCollection(this.chartID)); + ChartCollection chartCollection = (ChartCollection) BaseChartGetter.createChartCollection(this.chartID); + VanChart vanChart = chartCollection.getSelectedChartProvider(VanChart.class); + if (vanChart !=null) { + vanChart.resetAttrInForm(); + } + widget.resetChangeChartCollection(chartCollection); return widget; } catch (InstantiationException e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/ChartEditPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/ChartEditPane.java index 3dc90d3a34..6cd8ae54a2 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/ChartEditPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/ChartEditPane.java @@ -20,6 +20,7 @@ import com.fr.design.mainframe.chart.gui.ChartOtherPane; import com.fr.design.mainframe.chart.gui.ChartStylePane; import com.fr.design.mainframe.chart.gui.ChartTypePane; import com.fr.design.mainframe.chart.info.ChartInfoCollector; +import com.fr.form.main.Form; import com.fr.general.ComparatorUtils; import com.fr.log.FineLoggerFactory; import com.fr.plugin.chart.vanchart.VanChart; @@ -168,6 +169,7 @@ public class ChartEditPane extends BasicPane implements AttributeChange, Prepare AbstractChartAttrPane[] otherPaneList = ChartTypeInterfaceManager.getInstance().getAttrPaneArray(chartID, listener); for (int i = 0; i < otherPaneList.length; i++) { otherPaneList[i].addAttributeChangeListener(listener); + otherPaneList[i].registerChartEditPane(this); paneList.add(otherPaneList[i]); } this.isDefaultPane = false; @@ -366,4 +368,14 @@ public class ChartEditPane extends BasicPane implements AttributeChange, Prepare } }); } + + public boolean isInForm() { + if (container != null && container.getEPane() != null) { + Object target = container.getEPane().getTarget(); + if (target instanceof Form) { + return true; + } + } + return false; + } } \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java index 2ddfe46d42..778f779a07 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java @@ -67,6 +67,8 @@ public class ChartTypeButtonPane extends BasicBeanPane implemen registerSupportChangeConfigChartClass(VanChart.class); } + private boolean inForm; + private UIButton addButton; private UIButton configButton; private UIButton copyButton; @@ -160,10 +162,17 @@ public class ChartTypeButtonPane extends BasicBeanPane implemen addButton.addActionListener((e) -> { String name = getNewChartName(); ChartProvider chart = getChangeStateNewChart(); + checkInForm(chart); addNewChart(chart, name, editingCollection.getChartCount()); }); } + private void checkInForm(ChartProvider chart) { + if (inForm) { + chart.resetAttrInForm(); + } + } + private void initConfigButton() { configButton.setPreferredSize(new Dimension(20, 20)); configButton.addActionListener((e) -> showConfigDialog()); @@ -680,4 +689,8 @@ public class ChartTypeButtonPane extends BasicBeanPane implemen currentEditingEditor.requestFocus(); } } + + public void refreshChartInForm(boolean inForm) { + this.inForm = inForm; + } } \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypePane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypePane.java index 1fa61298a5..2318fc05f5 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypePane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypePane.java @@ -47,6 +47,7 @@ public class ChartTypePane extends AbstractChartAttrPane { private ChartEditPane editPane; private ChartCollection editingCollection; private ActionListener autoButtonListener; + private boolean inForm; @Override protected JPanel createContentPane() { @@ -54,6 +55,7 @@ public class ChartTypePane extends AbstractChartAttrPane { JPanel content = new JPanel(new BorderLayout()); buttonPane = new ChartTypeButtonPane(this); + buttonPane.refreshChartInForm(inForm); content.add(buttonPane, BorderLayout.NORTH); if (editingCollection != null) { @@ -180,8 +182,10 @@ public class ChartTypePane extends AbstractChartAttrPane { } //这一步会替换plot ((AbstractChartTypePane) getSelectedPane()).updateBean(chart); - - reLayoutEditPane(chart,lastPlotID); + if (inForm) { + chart.resetAttrInForm(); + } + reLayoutEditPane(chart, lastPlotID); } protected UIComboBox createComboBox() { @@ -405,5 +409,6 @@ public class ChartTypePane extends AbstractChartAttrPane { */ public void registerChartEditPane(ChartEditPane currentEditPane) { this.editPane = currentEditPane; + this.inForm = editPane.isInForm(); } } \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/van/chart/bubble/VanChartBubbleStylePane.java b/designer-chart/src/main/java/com/fr/van/chart/bubble/VanChartBubbleStylePane.java index de4e88070f..cd62fff560 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/bubble/VanChartBubbleStylePane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/bubble/VanChartBubbleStylePane.java @@ -21,9 +21,9 @@ public class VanChartBubbleStylePane extends VanChartScatterStylePane { super(listener); } - protected void addVanChartTooltipPane(List paneList){ + protected void addVanChartTooltipPane(List paneList) { Plot plot = getChart().getPlot(); - if(((VanChartBubblePlot) plot).isForceBubble()){ + if (((VanChartBubblePlot) plot).isForceBubble()) { paneList.add(new VanChartForceBubbleTooltipPane(VanChartBubbleStylePane.this)); } else { super.addVanChartTooltipPane(paneList); @@ -31,11 +31,11 @@ public class VanChartBubbleStylePane extends VanChartScatterStylePane { } @Override - protected void addVanChartAreaPane(List paneList) { - if (((VanChartBubblePlot)getChart().getPlot()).isForceBubble()){ - paneList.add(new VanChartForceBubbleAreaPane(getChart().getPlot(), VanChartBubbleStylePane.this)); - }else { - paneList.add(new VanChartAreaPane(getChart().getPlot(), VanChartBubbleStylePane.this)); + protected VanChartAreaPane createVanChartAreaPane() { + if (((VanChartBubblePlot) getChart().getPlot()).isForceBubble()) { + return new VanChartForceBubbleAreaPane(getChart().getPlot(), VanChartBubbleStylePane.this); + } else { + return new VanChartAreaPane(getChart().getPlot(), VanChartBubbleStylePane.this); } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/custom/style/VanChartCustomStylePane.java b/designer-chart/src/main/java/com/fr/van/chart/custom/style/VanChartCustomStylePane.java index a01cbf1cb5..da4fa2534c 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/custom/style/VanChartCustomStylePane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/custom/style/VanChartCustomStylePane.java @@ -11,6 +11,7 @@ import com.fr.plugin.chart.custom.VanChartCustomPlot; import com.fr.plugin.chart.custom.type.CustomPlotType; import com.fr.van.chart.designer.component.richText.VanChartRichEditorPane; import com.fr.van.chart.designer.style.VanChartStylePane; +import com.fr.van.chart.designer.style.background.VanChartAreaPane; import java.util.List; @@ -61,8 +62,8 @@ public class VanChartCustomStylePane extends VanChartStylePane { @Override - protected void addVanChartAreaPane(List paneList) { - paneList.add(new VanChartCustomAreaPane(getChart().getPlot(), VanChartCustomStylePane.this)); + protected VanChartAreaPane createVanChartAreaPane() { + return new VanChartCustomAreaPane(getChart().getPlot(), VanChartCustomStylePane.this); } @Override diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartStylePane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartStylePane.java index 53619765c7..7ca77a9fc2 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartStylePane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartStylePane.java @@ -3,6 +3,7 @@ package com.fr.van.chart.designer.style; import com.fr.chart.chartattr.Plot; import com.fr.design.dialog.BasicPane; import com.fr.design.gui.frpane.AttributeChangeListener; +import com.fr.design.mainframe.chart.ChartEditPane; import com.fr.design.mainframe.chart.gui.ChartStylePane; import com.fr.plugin.chart.attr.plot.VanChartAxisPlot; import com.fr.van.chart.designer.component.richText.VanChartRichEditorPane; @@ -19,14 +20,20 @@ public class VanChartStylePane extends ChartStylePane { private static final long serialVersionUID = 186776958263021761L; + private ChartEditPane chartEditPane; + public VanChartStylePane(AttributeChangeListener listener) { super(listener); } - protected java.util.List getPaneList() { - java.util.List paneList = new ArrayList(); + protected List getPaneList() { + List paneList = new ArrayList(); Plot plot = getChart().getPlot(); - paneList.add(createVanChartTitlePane()); + + boolean inForm = chartEditPane != null ? chartEditPane.isInForm() : false; + VanChartTitlePane vanChartTitlePane = createVanChartTitlePane(); + vanChartTitlePane.refreshTooltipLabel(inForm); + paneList.add(vanChartTitlePane); if (plot.isSupportLegend()) { paneList.add(new VanChartLegendPane(VanChartStylePane.this)); } @@ -47,7 +54,9 @@ public class VanChartStylePane extends ChartStylePane { } } - addVanChartAreaPane(paneList); + VanChartAreaPane vanChartAreaPane = createVanChartAreaPane(); + vanChartAreaPane.refreshTooltipLabel(inForm); + paneList.add(vanChartAreaPane); addVanChartTooltipPane(paneList); @@ -61,8 +70,8 @@ public class VanChartStylePane extends ChartStylePane { protected void addOtherAxisPane(java.util.List paneList, Plot plot) { } - protected void addVanChartAreaPane(List paneList) { - paneList.add(new VanChartAreaPane(getChart().getPlot(), VanChartStylePane.this)); + protected VanChartAreaPane createVanChartAreaPane() { + return new VanChartAreaPane(getChart().getPlot(), VanChartStylePane.this); } protected void createVanChartAxisPane(List paneList, VanChartAxisPlot plot) { @@ -80,4 +89,9 @@ public class VanChartStylePane extends ChartStylePane { public void refreshTableFieldNames() { VanChartRichEditorPane.refreshCommonChartFieldNames(getChart()); } + + public void registerChartEditPane(ChartEditPane currentEditPane) { + this.chartEditPane = currentEditPane; + } + } \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartTitlePane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartTitlePane.java index 59652a4afa..10a313af7e 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartTitlePane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartTitlePane.java @@ -13,6 +13,7 @@ import com.fr.design.gui.ibutton.UIButtonGroup; import com.fr.design.gui.ibutton.UIToggleButton; import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.Toolkit; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.chart.PaneTitleConstants; @@ -36,6 +37,7 @@ import javax.swing.SwingConstants; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import java.awt.BorderLayout; +import java.awt.Color; import java.awt.Component; import java.awt.Point; import java.awt.event.ActionEvent; @@ -69,6 +71,7 @@ public class VanChartTitlePane extends AbstractVanChartScrollPane { private JPanel maxProportionPane; //区域显示策略 恢复用注释。取消注释。 //private LimitPane limitPane; + private UILabel tooltipLabel; protected VanChartStylePane parent; @@ -88,21 +91,30 @@ public class VanChartTitlePane extends AbstractVanChartScrollPane { } private void initComponents() { - isTitleVisible = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Title_Visible")); - titlePane = createTitlePane(); + isTitleVisible = new UICheckBox(Toolkit.i18nText("Fine-Design_Chart_Title_Visible")); + tooltipLabel = new UILabel("" + Toolkit.i18nText("Fine-Design_Chart_Title_Tooltip") + ""); + tooltipLabel.setForeground(Color.gray); + tooltipLabel.setBorder(BorderFactory.createEmptyBorder(5, 10, 5, 10)); + tooltipLabel.setVisible(false); + + JPanel panel = new JPanel(); + panel.setLayout(new BorderLayout()); + panel.add(isTitleVisible, BorderLayout.NORTH); + panel.add(tooltipLabel, BorderLayout.CENTER); + titlePane = createTitlePane(); double p = TableLayout.PREFERRED; double f = TableLayout.FILL; double[] columnSize = {f}; double[] rowSize = {p, p, p}; Component[][] components = new Component[][]{ - new Component[]{isTitleVisible}, + new Component[]{panel}, new Component[]{titlePane} }; - JPanel panel = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); + JPanel panel1 = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); this.setLayout(new BorderLayout()); - this.add(panel, BorderLayout.CENTER); + this.add(panel1, BorderLayout.CENTER); isTitleVisible.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { @@ -370,4 +382,7 @@ public class VanChartTitlePane extends AbstractVanChartScrollPane { ChartInfoCollector.getInstance().updateChartConfig(chart, ConfigType.TITLE, chart.getBuryingPointTitleConfig()); } + public void refreshTooltipLabel(boolean inForm) { + tooltipLabel.setVisible(inForm); + } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/background/VanChartAreaBackgroundPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/background/VanChartAreaBackgroundPane.java index 6cef622ebe..19f5d40510 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/background/VanChartAreaBackgroundPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/background/VanChartAreaBackgroundPane.java @@ -3,6 +3,8 @@ package com.fr.van.chart.designer.style.background; import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.Plot; import com.fr.design.gui.frpane.AbstractAttrNoScrollPane; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.Toolkit; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.chart.PaneTitleConstants; @@ -12,8 +14,10 @@ import com.fr.van.chart.designer.component.background.VanChartBackgroundPane; import com.fr.van.chart.designer.component.border.VanChartBorderWithRadiusPane; import com.fr.van.chart.designer.style.background.radar.VanChartRadarAxisAreaPane; +import javax.swing.BorderFactory; import javax.swing.JPanel; import java.awt.BorderLayout; +import java.awt.Color; import java.awt.Component; //图表区|绘图区 边框和背景 @@ -25,12 +29,13 @@ public class VanChartAreaBackgroundPane extends AbstractVanChartScrollPane" + Toolkit.i18nText("Fine-Design_Chart_Background_Tooltip") + ""); + tooltipLabel.setForeground(Color.gray); + tooltipLabel.setBorder(BorderFactory.createEmptyBorder(0, 10, 5, 10)); + contentPane.add(tooltipLabel, BorderLayout.NORTH); + tooltipLabel.setVisible(false); + } return contentPane; } @@ -68,11 +81,11 @@ public class VanChartAreaBackgroundPane extends AbstractVanChartScrollPane implements AutoSele JPanel pane = new JPanel(new FlowLayout(FlowLayout.LEADING, 0, 0)); if (nameArray.length > 1) { pane.add(tabPane); - tabPane.setBorder(BorderFactory.createEmptyBorder(0,5,0,0)); + tabPane.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0)); this.add(pane, BorderLayout.NORTH); } } - centerPane.setBorder(BorderFactory.createEmptyBorder(10,0,0,0)); + centerPane.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); this.add(centerPane, BorderLayout.CENTER); } /** * 界面 使用标题 - * @return 标题 + * + * @return 标题 */ public String title4PopupWindow() { return PaneTitleConstants.CHART_STYLE_AREA_TITLE; @@ -66,7 +67,7 @@ public class VanChartAreaPane extends ThirdTabPane implements AutoSele paneList.add(new NamePane(areaPane.title4PopupWindow(), areaPane)); - if(plot.isSupportPlotBackground()) { + if (plot.isSupportPlotBackground()) { paneList.add(new NamePane(plotPane.title4PopupWindow(), plotPane)); } return paneList; @@ -111,4 +112,10 @@ public class VanChartAreaPane extends ThirdTabPane implements AutoSele } } } + + public void refreshTooltipLabel(boolean inForm) { + if (areaPane != null) { + areaPane.refreshTooltipLabel(inForm); + } + } } \ No newline at end of file From 6f740ef27716336db1cd0077814b9b0c721f3f81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=B9=E7=A3=8A?= <294531121@qq.com> Date: Tue, 6 Jul 2021 16:17:56 +0800 Subject: [PATCH 3/3] =?UTF-8?q?REPORT-54604=20=E5=8F=82=E6=95=B0=E9=9D=A2?= =?UTF-8?q?=E6=9D=BF=E6=94=BE=E7=BD=AE=E9=BB=98=E8=AE=A4=E4=B8=8D=E5=8F=AF?= =?UTF-8?q?=E8=A7=81=E7=9A=84=E9=A2=84=E5=AE=9A=E4=B9=89=E6=8E=A7=E4=BB=B6?= =?UTF-8?q?=E5=90=8E=EF=BC=8C=E4=BF=AE=E6=94=B9=E6=8E=A7=E4=BB=B6=E5=B1=9E?= =?UTF-8?q?=E6=80=A7=EF=BC=8C=E6=8E=A7=E4=BB=B6=E5=9C=A8=E5=8F=82=E6=95=B0?= =?UTF-8?q?=E9=9D=A2=E6=9D=BF=E4=B8=A2=E5=A4=B1=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/fr/design/designer/creator/XNameWidget.java | 1 - 1 file changed, 1 deletion(-) diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XNameWidget.java b/designer-form/src/main/java/com/fr/design/designer/creator/XNameWidget.java index 0f78c5739d..2cc20e111a 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XNameWidget.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XNameWidget.java @@ -91,7 +91,6 @@ public class XNameWidget extends XWidgetCreator { if (editor != null) { this.setLayout(FRGUIPaneFactory.createBorderLayout()); add(editor, BorderLayout.CENTER); - this.setVisible(toData().isVisible()); } }