diff --git a/build.gradle b/build.gradle index fa342ced2f..3580cbae0d 100644 --- a/build.gradle +++ b/build.gradle @@ -73,7 +73,7 @@ allprojects { implementation 'com.fr.decision:fine-decision:' + frVersion implementation 'com.fr.schedule:fine-schedule:' + frVersion implementation 'com.fr.report:fine-report-engine:' + frDevVersion - implementation 'com.fr.design:design-i18n' + frDevVersion + implementation 'com.fr.design:design-i18n:' + frDevVersion testImplementation 'org.easymock:easymock:3.5.1' testImplementation 'org.powermock:powermock-module-junit4:1.7.1' testImplementation 'org.powermock:powermock-api-easymock:1.7.1' diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/models/SelectionModel.java b/designer-form/src/main/java/com/fr/design/designer/beans/models/SelectionModel.java index 42db0d8503..b3215ede1c 100644 --- a/designer-form/src/main/java/com/fr/design/designer/beans/models/SelectionModel.java +++ b/designer-form/src/main/java/com/fr/design/designer/beans/models/SelectionModel.java @@ -310,7 +310,6 @@ public class SelectionModel { designer.getEditListenerTable().fireCreatorModified(DesignerEvent.CREATOR_DELETED); setSelectedCreator(isInPara ? designer.getParaComponent() : designer.getRootComponent()); - designer.getTopXCreators().refresh(); // 触发事件 diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XChartEditor.java b/designer-form/src/main/java/com/fr/design/designer/creator/XChartEditor.java index f846f29bd2..c002bceb38 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XChartEditor.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XChartEditor.java @@ -17,8 +17,6 @@ import com.fr.design.mainframe.CoverReportPane; import com.fr.design.mainframe.EditingMouseListener; import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.HelpDialogManager; -import com.fr.design.mainframe.widget.topxcreator.BasicTopXCreator; -import com.fr.design.mainframe.widget.topxcreator.TopXCreator; import com.fr.design.mainframe.widget.editors.WLayoutBorderStyleEditor; import com.fr.design.module.DesignModuleFactory; import com.fr.form.ui.BaseChartEditor; @@ -231,6 +229,9 @@ public class XChartEditor extends XBorderStyleWidgetCreator { */ public void paint(Graphics g) { designerEditor.paintEditor(g, this.getSize()); + if (coverPanel != null) { + coverPanel.setSize(this.getSize()); + } super.paint(g); if (isEditing) { g.setColor(INNER_BORDER_COLOR); @@ -361,34 +362,4 @@ public class XChartEditor extends XBorderStyleWidgetCreator { return false; } - @Override - public BasicTopXCreator getTopXCreator() { - return new TopXChart(this); - } - - private class TopXChart extends TopXCreator { - private final DesignerEditor designerEditor; - - public TopXChart(XCreator creator) { - super(creator); - designerEditor = creator.getDesignerEditor(); - Rectangle bounds = getBounds(); - designerEditor.getEditorTarget().setBounds(bounds.x + 1, bounds.y + 1, bounds.width - 2, bounds.height - 2); - } - - /** - * 更新designerEditor的大小 - */ - protected void resetSize(Rectangle bounds) { - super.resetSize(bounds); - designerEditor.getEditorTarget().setBounds(bounds.x + 1, bounds.y + 1, bounds.width - 2, bounds.height - 2); - } - - @Override - public void paint(Graphics g) { - designerEditor.paintEditor(g, this.getSize()); - super.paint(g); - } - } - } 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 20f2788117..5eb284c7ba 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 @@ -19,22 +19,16 @@ import com.fr.design.mainframe.CoverReportPane; import com.fr.design.mainframe.EditingMouseListener; import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.NoSupportAuthorityEdit; -import com.fr.design.mainframe.widget.topxcreator.BasicTopXCreator; import com.fr.design.mainframe.WidgetPropertyPane; import com.fr.design.utils.gui.LayoutUtils; import com.fr.form.ui.Widget; import com.fr.form.ui.container.WTitleLayout; import com.fr.stable.Constants; -import com.fr.stable.CoreGraphHelper; import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; -import com.fr.third.javax.annotation.Nullable; import javax.swing.BorderFactory; -import javax.swing.Icon; -import javax.swing.ImageIcon; import javax.swing.JComponent; -import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.border.Border; import java.awt.BorderLayout; @@ -44,7 +38,6 @@ import java.awt.Dimension; import java.awt.Graphics; import java.awt.Rectangle; import java.awt.event.MouseEvent; -import java.awt.image.BufferedImage; import java.beans.IntrospectionException; import java.util.ArrayList; import java.util.List; @@ -812,32 +805,4 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo return false; } - /** - * 获得该组件的顶层显示组件 - */ - @Nullable - public BasicTopXCreator getTopXCreator() { - return new BasicTopXCreator(this) { - @Override - protected void addComponent() { - Icon icon = new ImageIcon(getImage()); - JLabel jLabel = new JLabel(icon, JLabel.CENTER); - jLabel.setSize(getSize()); - this.add(jLabel); - } - }; - } - - /** - * 获得组件的图像 - */ - public BufferedImage getImage() { - BufferedImage image = CoreGraphHelper.createBufferedImage(getWidth(), getHeight()); - Graphics g = image.createGraphics(); - this.paint(g); - return image; - } - - - } diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XCreatorUtils.java b/designer-form/src/main/java/com/fr/design/designer/creator/XCreatorUtils.java index 072e21fa9f..0c4ea6313f 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XCreatorUtils.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XCreatorUtils.java @@ -343,4 +343,19 @@ public class XCreatorUtils { } return xCreator != null; } + + /** + * 获取组件的最顶层XMainBorderLayout,没有则返回null + * */ + @Nullable + public static XWCardMainBorderLayout getTopXMainBorderLayout(Container creator) { + XWCardMainBorderLayout result = null; + while (creator != null) { + if (creator instanceof XWCardMainBorderLayout) { + result = (XWCardMainBorderLayout) creator; + } + creator = creator.getParent(); + } + return result; + } } \ No newline at end of file diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XElementCase.java b/designer-form/src/main/java/com/fr/design/designer/creator/XElementCase.java index d84fd2e0cd..718c30aeb6 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XElementCase.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XElementCase.java @@ -13,8 +13,6 @@ import com.fr.design.mainframe.widget.editors.ElementCaseToolBarEditor; import com.fr.design.mainframe.widget.editors.PaddingMarginEditor; import com.fr.design.mainframe.widget.editors.WLayoutBorderStyleEditor; import com.fr.design.mainframe.widget.propertypane.BrowserFitPropertyEditor; -import com.fr.design.mainframe.widget.topxcreator.BasicTopXCreator; -import com.fr.design.mainframe.widget.topxcreator.TopXCreator; import com.fr.form.FormElementCaseContainerProvider; import com.fr.form.FormElementCaseProvider; import com.fr.form.FormProvider; @@ -374,19 +372,4 @@ public class XElementCase extends XBorderStyleWidgetCreator implements FormEleme return true; } - @Override - public BasicTopXCreator getTopXCreator() { - return new TopXElementCase(this); - } - - private class TopXElementCase extends TopXCreator { - private UILabel imageLabel; - - public TopXElementCase(XCreator creator) { - super(creator); - imageLabel = initImageBackground(); - add(imageLabel); - } - } - } diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteBodyLayout.java b/designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteBodyLayout.java index 5db000e189..9a7d6dc975 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteBodyLayout.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteBodyLayout.java @@ -7,7 +7,6 @@ import com.fr.design.form.util.XCreatorConstants; import com.fr.design.fun.WidgetPropertyUIProvider; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.widget.editors.WLayoutBorderStyleEditor; -import com.fr.design.mainframe.widget.topxcreator.BasicTopXCreator; import com.fr.form.ui.container.WAbsoluteBodyLayout; import com.fr.stable.core.PropertyChangeAdapter; @@ -132,8 +131,4 @@ public class XWAbsoluteBodyLayout extends XWAbsoluteLayout { return false; } - @Override - public BasicTopXCreator getTopXCreator() { - return null; - } } diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteLayout.java b/designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteLayout.java index 98143a7ea0..da268b0e6c 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteLayout.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteLayout.java @@ -25,8 +25,6 @@ import com.fr.design.mainframe.FormArea; import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.WidgetHelpDialog; import com.fr.design.mainframe.WidgetPropertyPane; -import com.fr.design.mainframe.widget.topxcreator.BasicTopXCreator; -import com.fr.design.mainframe.widget.topxcreator.TopXCreator; import com.fr.form.ui.Connector; import com.fr.form.ui.Widget; import com.fr.form.ui.container.WAbsoluteLayout; @@ -610,8 +608,4 @@ public class XWAbsoluteLayout extends XLayoutContainer { } } - @Override - public BasicTopXCreator getTopXCreator() { - return new TopXCreator(this); - } } diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XWParameterLayout.java b/designer-form/src/main/java/com/fr/design/designer/creator/XWParameterLayout.java index 384ee07b64..3fc35a265c 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XWParameterLayout.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XWParameterLayout.java @@ -15,7 +15,6 @@ import com.fr.design.mainframe.widget.editors.BooleanEditor; import com.fr.design.mainframe.widget.editors.WidgetDisplayPosition; import com.fr.design.mainframe.widget.renderer.BackgroundRenderer; import com.fr.design.mainframe.widget.renderer.WidgetDisplayPositionRender; -import com.fr.design.mainframe.widget.topxcreator.BasicTopXCreator; import com.fr.form.ui.container.WBorderLayout; import com.fr.form.ui.container.WFitLayout; import com.fr.form.ui.container.WParameterLayout; @@ -252,10 +251,6 @@ public class XWParameterLayout extends XWAbsoluteLayout { return false; } - @Override - public BasicTopXCreator getTopXCreator() { - return null; - } } diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XWTitleLayout.java b/designer-form/src/main/java/com/fr/design/designer/creator/XWTitleLayout.java index b8fe8f0049..964f0aa03d 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XWTitleLayout.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XWTitleLayout.java @@ -7,7 +7,6 @@ import com.fr.design.designer.beans.LayoutAdapter; import com.fr.design.designer.beans.adapters.layout.FRTitleLayoutAdapter; import com.fr.design.form.layout.FRTitleLayout; import com.fr.design.fun.WidgetPropertyUIProvider; -import com.fr.design.mainframe.widget.topxcreator.BasicTopXCreator; import com.fr.form.ui.Label; import com.fr.form.ui.Widget; import com.fr.form.ui.WidgetTitle; @@ -191,8 +190,4 @@ public class XWTitleLayout extends DedicateLayoutContainer { return creator.getWidgetPropertyUIProviders(); } - @Override - public BasicTopXCreator getTopXCreator() { - return getEditingChildCreator().getTopXCreator(); - } } \ No newline at end of file diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java b/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java index 3ad1463b97..5b37ad313f 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java @@ -23,8 +23,6 @@ import com.fr.design.mainframe.EditingMouseListener; import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.WidgetHelpDialog; import com.fr.design.mainframe.WidgetPropertyPane; -import com.fr.design.mainframe.widget.topxcreator.BasicTopXCreator; -import com.fr.design.mainframe.widget.topxcreator.TopXCreator; import com.fr.form.event.Listener; import com.fr.form.ui.CardSwitchButton; import com.fr.form.ui.LayoutBorderStyle; @@ -515,8 +513,4 @@ public class XWCardMainBorderLayout extends XWBorderLayout { return true; } - @Override - public BasicTopXCreator getTopXCreator() { - return new TopXCreator(this); - } } 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 4dd84f528b..ee667fd38c 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 @@ -90,7 +90,6 @@ public class ComponentTree extends JTree { public void setSelectionPath(TreePath path) { // 不管点击哪一项,都要先退出编辑状态(图表、报表块、绝对布局、tab块) designer.stopEditing(path); - designer.getTopXCreators().refresh(); super.setSelectionPath(path); } 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 6dcf7f34b7..4cb75e0e4a 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 @@ -316,7 +316,6 @@ public class EditingMouseListener extends MouseInputAdapter { XCreator component = designer.getComponentAt(e); setCoverPaneNotDisplay(component, e, false); - designer.getTopXCreators().displayCoverPane(e); if (processTopLayoutMouseMove(component, e)) { return; @@ -406,16 +405,7 @@ public class EditingMouseListener extends MouseInputAdapter { } private void setCoverPaneNotDisplay(XCreator component, MouseEvent e, boolean isLinkedHelpDialog) { - if (xElementCase != null) { - int x = getParentPositionX(xElementCase, 0) - designer.getArea().getHorizontalValue(); - int y = getParentPositionY(xElementCase, 0) - designer.getArea().getVerticalValue(); - Rectangle rect = new Rectangle(x, y, xElementCase.getWidth(), xElementCase.getHeight()); - if (rect.contains(e.getPoint())) { - return; - } - xElementCase.displayCoverPane(false); - } if (xChartEditor != null) { xChartEditor.displayCoverPane(false); } @@ -426,6 +416,15 @@ public class EditingMouseListener extends MouseInputAdapter { if (xTopLayoutContainer != null) { xTopLayoutContainer.setMouseEnter(false); } + //不知道为什么要对XElementCase进行判断,但是直接return会有bug,所以把他放在最后 + if (xElementCase != null) { + int x = getParentPositionX(xElementCase, 0) - designer.getArea().getHorizontalValue(); + int y = getParentPositionY(xElementCase, 0) - designer.getArea().getVerticalValue(); + Rectangle rect = new Rectangle(x, y, xElementCase.getWidth(), xElementCase.getHeight()); + if (!rect.contains(e.getPoint())) { + xElementCase.displayCoverPane(false); + } + } designer.repaint(); } diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java b/designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java index 40da109cf2..eefeb01a32 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java @@ -35,9 +35,8 @@ import com.fr.design.designer.creator.XLayoutContainer; import com.fr.design.designer.creator.XWAbsoluteBodyLayout; import com.fr.design.designer.creator.XWAbsoluteLayout; import com.fr.design.designer.creator.XWBorderLayout; -import com.fr.design.designer.creator.XWFitLayout; import com.fr.design.designer.creator.XWParameterLayout; -import com.fr.design.designer.creator.XWTitleLayout; +import com.fr.design.designer.creator.cardlayout.XWCardMainBorderLayout; import com.fr.design.designer.creator.cardlayout.XWTabFitLayout; import com.fr.design.designer.properties.FormWidgetAuthorityEditPane; import com.fr.design.dialog.FineJOptionPane; @@ -46,7 +45,6 @@ import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.form.util.XCreatorConstants; import com.fr.design.fun.RightSelectionHandlerProvider; import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus; -import com.fr.design.mainframe.widget.topxcreator.TopXCreators; import com.fr.design.menu.MenuDef; import com.fr.design.menu.ShortCut; import com.fr.design.menu.ToolBarDef; @@ -65,7 +63,6 @@ import com.fr.form.ui.Widget; import com.fr.form.ui.WidgetValue; import com.fr.form.ui.container.WBorderLayout; import com.fr.form.ui.container.WFitLayout; -import com.fr.form.ui.container.cardlayout.WCardMainBorderLayout; import com.fr.general.ComparatorUtils; import com.fr.general.FRLogger; import com.fr.log.FineLoggerFactory; @@ -837,47 +834,35 @@ public class FormDesigner extends TargetComponent
implements TreeSelection /** * 从已选择的组件中找x,y所在的组件 */ - private XCreator xCreatorAt(int x, int y,XCreator root) { + private XCreator xCreatorAt(int x, int y, XCreator root) { XCreator[] xCreators = selectionModel.getSelection().getSelectedCreators(); for (XCreator creator : xCreators) { boolean shouldContinue = creator == null || !creator.isVisible() - || !XCreatorUtils.containComponent(root, creator) - || creator instanceof XWAbsoluteBodyLayout - || creator instanceof XWFitLayout - || creator instanceof XWParameterLayout; + || !XCreatorUtils.containComponent(root, creator); if (shouldContinue) { continue; } + //如果组件为XWCardMainBorderLayout的子组件,直接从XWCardMainBorderLayout中去找 + XWCardMainBorderLayout borderLayout = XCreatorUtils.getTopXMainBorderLayout(creator); + if (borderLayout != null) { + return xCreatorAt(x, y, borderLayout, null); + } + if (creator instanceof XLayoutContainer) { + return xCreatorAt(x, y, creator, null); + } x -= creator.getX(); y -= creator.getY(); Rectangle rect = ComponentUtils.computeVisibleRect(creator); - rect.y += nestTabCount(creator) * WCardMainBorderLayout.TAB_HEIGHT; // 判断是否处于交叉区域 if (!isIntersectArea(x, y, rect)) { continue; } - if (creator instanceof XWTitleLayout) { - return creator.getEditingChildCreator(); - } - return xCreatorAt(x, y, creator, null); + return creator; } return null; } - /** - * 计算嵌套的tab层数 - */ - private int nestTabCount(Container xCreator) { - if (xCreator == null) { - return 0; - } - if (xCreator instanceof XWTabFitLayout) { - return 1 + nestTabCount(xCreator.getParent()); - } - return nestTabCount(xCreator.getParent()); - } - /** * 刷新顶层组件 * */ diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/topxcreator/BasicTopXCreator.java b/designer-form/src/main/java/com/fr/design/mainframe/TopXCreator.java similarity index 59% rename from designer-form/src/main/java/com/fr/design/mainframe/widget/topxcreator/BasicTopXCreator.java rename to designer-form/src/main/java/com/fr/design/mainframe/TopXCreator.java index e49aaf6e85..72541a1fe6 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/widget/topxcreator/BasicTopXCreator.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/TopXCreator.java @@ -1,24 +1,29 @@ -package com.fr.design.mainframe.widget.topxcreator; +package com.fr.design.mainframe; import com.fr.design.designer.creator.XCreator; +import com.fr.design.gui.ilable.UILabel; import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.WidgetPropertyPane; import com.fr.design.utils.ComponentUtils; +import com.fr.stable.CoreGraphHelper; import javax.swing.*; import java.awt.*; import java.awt.event.MouseEvent; +import java.awt.geom.AffineTransform; +import java.awt.image.BufferedImage; +import java.util.ArrayList; /** * @Author: Yuan.Wang * @Date: 2020/8/31 */ -public class BasicTopXCreator extends JComponent { - private FormDesigner designer; - private XCreator creator; +public class TopXCreator extends JComponent { + private final FormDesigner designer; + private final XCreator creator; - public BasicTopXCreator(XCreator creator) { - this.designer = WidgetPropertyPane.getInstance().getEditingFormDesigner(); + public TopXCreator(FormDesigner designer, XCreator creator) { + this.designer = designer; this.creator = creator; init(); } @@ -28,30 +33,16 @@ public class BasicTopXCreator extends JComponent { setBackground(null); setLayout(null); setBounds(calculateBounds()); - addComponent(); } - //子类可能会重写该方法 - protected void resetSize(Rectangle bounds) { - //do nothing - } - - protected void addComponent() { - - } - /** * 重新设置组件大小 * */ public void resizeTopXCreator() { - Rectangle bounds=calculateBounds(); - setBounds(bounds); - resetSize(bounds); + setBounds(calculateBounds()); } - public void displayCoverPane(MouseEvent e, boolean visible) {} - /** * 计算显示大小 * */ @@ -63,8 +54,15 @@ public class BasicTopXCreator extends JComponent { return bounds; } + @Override public void paint(Graphics g) { super.paint(g); + ArrayList dbcomponents = new ArrayList(); + // 禁止双缓冲 + ComponentUtils.disableBuffer(creator, dbcomponents); + creator.paint(g); + // 恢复双缓冲 + ComponentUtils.resetBuffer(dbcomponents); } } diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/topxcreator/TopXCreators.java b/designer-form/src/main/java/com/fr/design/mainframe/TopXCreators.java similarity index 57% rename from designer-form/src/main/java/com/fr/design/mainframe/widget/topxcreator/TopXCreators.java rename to designer-form/src/main/java/com/fr/design/mainframe/TopXCreators.java index f271c3cc10..59220d9a82 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/widget/topxcreator/TopXCreators.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/TopXCreators.java @@ -1,11 +1,10 @@ -package com.fr.design.mainframe.widget.topxcreator; +package com.fr.design.mainframe; import com.fr.design.designer.beans.events.DesignerEvent; import com.fr.design.designer.beans.models.SelectionModel; import com.fr.design.designer.creator.XCreator; -import com.fr.design.mainframe.FormDesigner; - -import java.awt.event.MouseEvent; +import com.fr.design.designer.creator.XCreatorUtils; +import com.fr.design.designer.creator.cardlayout.XWCardMainBorderLayout; import javax.swing.*; import java.awt.*; @@ -31,7 +30,7 @@ public class TopXCreators extends JComponent { setBackground(null); setOpaque(false); designer.addDesignerEditListener(e -> { - if (e.getCreatorEventID() == DesignerEvent.CREATOR_EDITED) { + if (e.getCreatorEventID() == DesignerEvent.CREATOR_SELECTED) { refresh(); } }); @@ -52,28 +51,6 @@ public class TopXCreators extends JComponent { super.paint(g); } - @Override - public void setVisible(boolean aFlag) { - super.setVisible(aFlag); - for (int i = 0, count = getComponentCount(); i < count; i++) { - if (getComponent(i) instanceof TopXCreator) { - TopXCreator xCreator = (TopXCreator) getComponent(i); - xCreator.displayCoverPane(aFlag); - } - } - repaint(); - } - - /** - * 依据MouseEvent坐标来设置是否显示蒙层 - */ - public void displayCoverPane(MouseEvent e) { - for (int i = 0, count = getComponentCount(); i < count; i++) { - BasicTopXCreator xCreator = (BasicTopXCreator) getComponent(i); - xCreator.displayCoverPane(e, isVisible()); - } - } - /** * 加入被选择的组件 */ @@ -81,10 +58,9 @@ public class TopXCreators extends JComponent { SelectionModel selectionModel = designer.getSelectionModel(); XCreator[] xCreators = selectionModel.getSelection().getSelectedCreators(); for (XCreator creator : xCreators) { - BasicTopXCreator topXCreator = creator.getTopXCreator(); - if (topXCreator != null) { - add(topXCreator); - } + XWCardMainBorderLayout topXMainBorderLayout = XCreatorUtils.getTopXMainBorderLayout(creator); + TopXCreator topXCreator = topXMainBorderLayout == null ? new TopXCreator(designer, creator) : new TopXCreator(designer, topXMainBorderLayout); + add(topXCreator); } } @@ -93,7 +69,7 @@ public class TopXCreators extends JComponent { */ private void resizeTopXCreators() { for (int i = 0, count = getComponentCount(); i < count; i++) { - BasicTopXCreator topXCreator = (BasicTopXCreator) getComponent(i); + TopXCreator topXCreator = (TopXCreator) getComponent(i); topXCreator.resizeTopXCreator(); } repaint(); diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/topxcreator/TopXCreator.java b/designer-form/src/main/java/com/fr/design/mainframe/widget/topxcreator/TopXCreator.java deleted file mode 100644 index 42371a44f9..0000000000 --- a/designer-form/src/main/java/com/fr/design/mainframe/widget/topxcreator/TopXCreator.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.fr.design.mainframe.widget.topxcreator; - -import com.fr.design.designer.creator.XCreator; -import com.fr.design.mainframe.CoverReportPane; - -import java.awt.*; -import java.awt.event.MouseEvent; - -/** - * @Author: Yuan.Wang - * @Date: 2020/8/26 - */ -public class TopXCreator extends BasicTopXCreator { - - private final CoverReportPane coverPanel; - - public TopXCreator(XCreator creator) { - super(creator); - coverPanel = new CoverReportPane(); - init(); - } - - private void init() { - coverPanel.setSize(getSize()); - coverPanel.setVisible(false); - add(coverPanel); - } - - - protected void resetSize(Rectangle bounds) { - coverPanel.setSize(getSize()); - } - - /** - * 设置是否显示蒙层 - * */ - public void displayCoverPane(boolean visible) { - coverPanel.setVisible(visible); - } - - /** - * 依据鼠标事件和visible设置是否显示蒙层 - * */ - public void displayCoverPane(MouseEvent event, boolean visible) { - boolean isVisible = visible && getBounds().contains(event.getX(), event.getY()); - coverPanel.setVisible(isVisible); - } - -}