From 624748dd870d072aa7ac6ddc149684566a5af461 Mon Sep 17 00:00:00 2001 From: hades Date: Thu, 22 Jul 2021 12:42:04 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-55557=20=E5=BC=B9=E7=AA=97=E5=B7=A5?= =?UTF-8?q?=E5=85=B7=E6=A0=8F=E5=85=B3=E9=97=AD=E5=A4=84=E7=90=86=EF=BC=88?= =?UTF-8?q?cpt&frm=E5=90=88=E5=B9=B6=E4=B8=8B=E5=A4=84=E7=90=86=E6=96=B9?= =?UTF-8?q?=E5=BC=8F=EF=BC=89&&=20REPORT-55552=20=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E8=80=81=E7=BC=96=E8=BE=91=E5=92=8C=E5=B8=AE=E5=8A=A9=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/mainframe/DesktopCardPane.java | 4 +++ .../com/fr/design/mainframe/JTemplate.java | 7 ++++- .../design/mainframe/TabChangeListener.java | 13 ++++++++ .../fr/design/designer/creator/XCreator.java | 8 ++++- .../designer/creator/XWAbsoluteLayout.java | 5 +--- .../cardlayout/XWCardMainBorderLayout.java | 5 +--- .../design/designer/ui/PopupControlPanel.java | 4 ++- .../designer/ui/SelectedPopupDialog.java | 9 ++++++ .../fr/design/mainframe/ComponentTree.java | 3 +- .../com/fr/design/mainframe/CoverPane.java | 21 ++++++++++--- .../fr/design/mainframe/CoverReportPane.java | 3 -- .../mainframe/EditingMouseListener.java | 15 +++++++--- .../com/fr/design/mainframe/FormDesigner.java | 14 +++++++++ .../java/com/fr/design/mainframe/JForm.java | 30 +++++-------------- .../com/fr/design/mainframe/JWorkBook.java | 16 ++++++++++ 15 files changed, 111 insertions(+), 46 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/design/mainframe/TabChangeListener.java diff --git a/designer-base/src/main/java/com/fr/design/mainframe/DesktopCardPane.java b/designer-base/src/main/java/com/fr/design/mainframe/DesktopCardPane.java index f540832d0d..f3afcacc98 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/DesktopCardPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/DesktopCardPane.java @@ -56,6 +56,10 @@ public class DesktopCardPane extends BasicPane implements TargetModifiedListener } else if (!DesignModeContext.isVcsMode() && !DesignModeContext.isAuthorityEditing()) { DesignModeContext.switchTo(DesignerMode.NORMAL); } + // 切换时 + if (component != null) { + component.fireTabChange(); + } DesignerFrameFileDealerPane.getInstance().setCurrentEditingTemplate(jt); if (component != null) { layeredPane.remove(component); diff --git a/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java b/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java index abd219ee7f..f1bc2cbafe 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java @@ -95,7 +95,7 @@ import java.util.concurrent.Callable; /** * 报表设计和表单设计的编辑区域(设计器编辑的IO文件) */ -public abstract class JTemplate> extends TargetComponent implements ToolBarMenuDockPlus, DesignerProxy, JTemplateSave { +public abstract class JTemplate> extends TargetComponent implements ToolBarMenuDockPlus, DesignerProxy, JTemplateSave, TabChangeListener { // TODO ALEX_SEP editingFILE这个属性一定要吗?如果非要不可,有没有可能保证不为null private static final int PREFIX_NUM = 3000; protected FILE editingFILE = null; @@ -218,6 +218,11 @@ public abstract class JTemplate> } } + @Override + public void fireTabChange() { + // do nothing + } + protected void addPane(PropertyItemPaneProvider provider) { // do nothing } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/TabChangeListener.java b/designer-base/src/main/java/com/fr/design/mainframe/TabChangeListener.java new file mode 100644 index 0000000000..a69706c551 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/TabChangeListener.java @@ -0,0 +1,13 @@ +package com.fr.design.mainframe; + +/** + * tab切换时对当前打开的模版处理些事件 + * + * @author hades + * @version 10.0 + * Created by hades on 2021/7/22 + */ +public interface TabChangeListener { + + void fireTabChange(); +} 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 2f5f0e6282..fa9267b1a7 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 @@ -778,7 +778,7 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo int extraY = (int) (bounds.y * designer.getScale()); popup.setLocation(designer.getLocationOnScreen().x + designer.getPaintX() + extraX, designer.getLocationOnScreen().y + designer.getPaintY() + extraY); popup.updatePane(designer); - popup.setVisible(selected && accept && popup.hasVisibleButtons()); + popup.setVisible(selected && accept && popup.hasVisibleButtons() && popup.isCanVisible()); popup.setRelativeBounds(bounds); } @@ -836,4 +836,10 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo } } + public void processPopup(boolean canVisible) { + if (popup != null) { + popup.setCanVisible(canVisible); + } + } + } 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 c6d0067c3a..fdd62d1b0f 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 @@ -447,10 +447,7 @@ public class XWAbsoluteLayout extends XLayoutContainer { super.paint(g); //如果鼠标移动到布局内且布局不可编辑,画出编辑蒙层 if (isMouseEnter && !this.editable) { - CoverReportPane.paintEditButton(g, this); - if (isShared()) { - CoverReportPane.paintShareButton(g, this); - } + CoverReportPane.paintCover(g, this); } } 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 523533e5e7..6009711f71 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 @@ -344,10 +344,7 @@ public class XWCardMainBorderLayout extends XWBorderLayout { super.paint(g); //如果鼠标移动到布局内且布局不可编辑,画出编辑蒙层 if (isMouseEnter && !editable) { - CoverReportPane.paintEditButton(g, this); - if (isShared()) { - CoverReportPane.paintShareButton(g, this); - } + CoverReportPane.paintCover(g, this); } } diff --git a/designer-form/src/main/java/com/fr/design/designer/ui/PopupControlPanel.java b/designer-form/src/main/java/com/fr/design/designer/ui/PopupControlPanel.java index ebcfa472f0..ad003ff692 100644 --- a/designer-form/src/main/java/com/fr/design/designer/ui/PopupControlPanel.java +++ b/designer-form/src/main/java/com/fr/design/designer/ui/PopupControlPanel.java @@ -4,7 +4,9 @@ import com.fr.design.designer.beans.AdapterBus; import com.fr.design.designer.beans.adapters.layout.FRAbsoluteLayoutAdapter; import com.fr.design.designer.beans.events.DesignerEvent; import com.fr.design.designer.creator.XCreator; +import com.fr.design.designer.creator.XWAbsoluteLayout; import com.fr.design.designer.creator.XWTitleLayout; +import com.fr.design.designer.creator.cardlayout.XWCardMainBorderLayout; import com.fr.design.gui.ilable.UILabel; import com.fr.design.i18n.Toolkit; import com.fr.design.layout.VerticalFlowLayout; @@ -193,7 +195,7 @@ public class PopupControlPanel extends JPanel { } public void updatePane(FormDesigner designer) { - setButtonVisible(editButton, creator.acceptType(XWTitleLayout.class)); + setButtonVisible(editButton, creator.acceptType(XWTitleLayout.class, XWCardMainBorderLayout.class) || creator.getClass().equals(XWAbsoluteLayout.class)); setButtonVisible(settingButton, creator.isShared()); setButtonVisible(toggleButton, AdapterBus.searchLayoutAdapter(designer, creator) instanceof FRAbsoluteLayoutAdapter); toggleButton.setSelected(creator.toData().isAspectRatioLocked()); diff --git a/designer-form/src/main/java/com/fr/design/designer/ui/SelectedPopupDialog.java b/designer-form/src/main/java/com/fr/design/designer/ui/SelectedPopupDialog.java index c5f94d70eb..285bbc3b8b 100644 --- a/designer-form/src/main/java/com/fr/design/designer/ui/SelectedPopupDialog.java +++ b/designer-form/src/main/java/com/fr/design/designer/ui/SelectedPopupDialog.java @@ -20,6 +20,8 @@ public class SelectedPopupDialog extends JDialog { private final PopupControlPanel controlPanel; + private boolean canVisible = true; + public SelectedPopupDialog(XCreator creator, FormDesigner designer) { super(DesignerContext.getDesignerFrame()); this.setUndecorated(true); @@ -43,4 +45,11 @@ public class SelectedPopupDialog extends JDialog { this.controlPanel.setRelativeBounds(rectangle); } + public boolean isCanVisible() { + return canVisible; + } + + public void setCanVisible(boolean canVisible) { + this.canVisible = canVisible; + } } 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 25bf1f5de7..0c838b61ec 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 @@ -4,6 +4,7 @@ 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.creator.XWAbsoluteLayout; import com.fr.design.designer.creator.XWTitleLayout; import com.fr.design.designer.creator.cardlayout.XWCardMainBorderLayout; import com.fr.design.designer.treeview.ComponentTreeCellRenderer; @@ -414,7 +415,7 @@ public class ComponentTree extends JTree { private void showSelectedPopup(XCreator comp) { Rectangle rectangle = getRelativeBounds(comp); - comp.showSelectedPopup(designer, rectangle, comp.acceptType(XWTitleLayout.class)); + comp.showSelectedPopup(designer, rectangle, comp.acceptType(XWTitleLayout.class, XWCardMainBorderLayout.class, XWAbsoluteLayout.class)); comp.setSelected(true); } diff --git a/designer-form/src/main/java/com/fr/design/mainframe/CoverPane.java b/designer-form/src/main/java/com/fr/design/mainframe/CoverPane.java index f63c430554..6bafb317f3 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/CoverPane.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/CoverPane.java @@ -42,9 +42,7 @@ public class CoverPane extends JComponent { Graphics2D g2d = (Graphics2D) g; Composite oldComposite = g2d.getComposite(); //画白色的编辑层 - g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 50 / 100.0F)); - g2d.setColor(XCreatorConstants.COVER_COLOR); - g2d.fillRect(x, y, w, h); + paintCover(g, component); //画编辑按钮所在框 FormDesigner formDesigner = WidgetPropertyPane.getInstance().getEditingFormDesigner(); AlphaComposite alphaComposite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, formDesigner.getCursor().getType() != Cursor.DEFAULT_CURSOR ? 0.9f : 0.7f); @@ -71,6 +69,21 @@ public class CoverPane extends JComponent { GraphHelper.draw(g, new Rectangle(BORDER_WIDTH, BORDER_WIDTH, w - BORDER_WIDTH * 2, h - BORDER_WIDTH * 2), Constants.LINE_MEDIUM); } + /** + * 绘制悬浮层 + * @param g + * @param component + */ + public static void paintCover(Graphics g, Component component) { + Graphics2D g2d = (Graphics2D) g; + Composite oldComposite = g2d.getComposite(); + //画白色的编辑层 + g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 50 / 100.0F)); + g2d.setColor(XCreatorConstants.COVER_COLOR); + g2d.fillRect(0, 0, component.getWidth(), component.getHeight()); + g2d.setComposite(oldComposite); + } + public CoverPane() { setBackground(null); setOpaque(false); @@ -87,6 +100,6 @@ public class CoverPane extends JComponent { public void paint(Graphics g) { super.paint(g); - paintEditButton(g, this); + paintCover(g, this); } } diff --git a/designer-form/src/main/java/com/fr/design/mainframe/CoverReportPane.java b/designer-form/src/main/java/com/fr/design/mainframe/CoverReportPane.java index 14b8aed7a3..ba687f5255 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/CoverReportPane.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/CoverReportPane.java @@ -75,8 +75,5 @@ public class CoverReportPane extends CoverPane{ @Override public void paint(Graphics g) { super.paint(g); - if (isShared()) { - paintShareButton(g, this); - } } } 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 783e984b9d..5cd0458350 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 @@ -18,7 +18,9 @@ import com.fr.design.designer.creator.XCreatorUtils; import com.fr.design.designer.creator.XEditorHolder; import com.fr.design.designer.creator.XElementCase; import com.fr.design.designer.creator.XLayoutContainer; +import com.fr.design.designer.creator.XWAbsoluteLayout; import com.fr.design.designer.creator.XWFitLayout; +import com.fr.design.designer.creator.XWTitleLayout; import com.fr.design.designer.creator.cardlayout.XCardAddButton; import com.fr.design.designer.creator.cardlayout.XCardSwitchButton; import com.fr.design.designer.creator.cardlayout.XWCardLayout; @@ -383,6 +385,14 @@ public class EditingMouseListener extends MouseInputAdapter { } private boolean isEditButton(MouseEvent e, XCreator component, Insets insets) { + // 不显示编辑按钮 鼠标格式 + if (component.getParent() instanceof XCreator) { + XCreator parent = (XCreator) component.getParent(); + if (parent.acceptType(XWTitleLayout.class) || component.acceptType(XWCardMainBorderLayout.class, XWAbsoluteLayout.class)) { + return false; + } + } + int innerWidth = component.getWidth() - insets.left - insets.right; int innerHeight = component.getHeight() - insets.top - insets.bottom; @@ -458,10 +468,7 @@ public class EditingMouseListener extends MouseInputAdapter { if (designer.getCursor().getType() == Cursor.HAND_CURSOR) { designer.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } - if (isShareConfigButton(e, component, insets)) { - designer.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); - component.setHelpBtnOnFocus(true); - } else if (isEditButton(e, component, insets)) { + if (isEditButton(e, component, insets)) { designer.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); } } 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 1d4fad8e34..1a6d24ec55 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 @@ -1743,4 +1743,18 @@ public class FormDesigner extends TargetComponent
implements TreeSelection return false; } + public void processPopup(boolean canVisible) { + XCreator creator = this.getSelectionModel().getSelection().getSelectedCreator(); + if (creator != null) { + creator.processPopup(canVisible); + } + } + + public void hidePopup() { + XCreator creator = this.getSelectionModel().getSelection().getSelectedCreator(); + if (creator != null) { + creator.hidePopup(); + } + } + } diff --git a/designer-form/src/main/java/com/fr/design/mainframe/JForm.java b/designer-form/src/main/java/com/fr/design/mainframe/JForm.java index bc32c5fd9e..8c9b1f2bc8 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/JForm.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/JForm.java @@ -89,8 +89,6 @@ import com.fr.stable.StringUtils; import com.fr.stable.bridge.StableFactory; import com.fr.web.controller.ViewRequestConstants; -import java.awt.event.ContainerAdapter; -import java.awt.event.ContainerEvent; import javax.swing.BorderFactory; import javax.swing.Icon; import javax.swing.JComponent; @@ -133,36 +131,16 @@ public class JForm extends JTemplate implements BaseJForm implements BaseJForm implements BaseJForm { centerPane = new UIModeControlContainer(parameterPane, reportComposite = new ReportComponentComposite(this)) { @Override protected void onModeChanged() { + processPopup(isUpMode()); refreshToolArea(); } @@ -1221,4 +1222,19 @@ public class JWorkBook extends JTemplate { super.whenClose(); reportComposite.doRemoveAction(); } + + protected void processPopup(boolean visible) { + FormDesigner designer = (FormDesigner) parameterPane.getParaDesigner(); + if (designer != null) { + designer.processPopup(visible); + } + } + + @Override + public void fireTabChange() { + FormDesigner designer = (FormDesigner) parameterPane.getParaDesigner(); + if (designer != null) { + designer.hidePopup(); + } + } }