From d6d632aedc8bfe8eb321a7f3d5dcf58968b6dcab Mon Sep 17 00:00:00 2001 From: plough Date: Thu, 13 Jul 2017 14:48:23 +0800 Subject: [PATCH 1/5] =?UTF-8?q?REPORT-3163=20=E5=90=88=E4=BD=9C=E5=BC=80?= =?UTF-8?q?=E5=8F=919.0=E8=AE=BE=E8=AE=A1=E5=99=A8=3D>=E4=BD=BF=E7=94=A8UI?= =?UTF-8?q?Button=E4=BD=9C=E4=B8=BA=E7=AB=96=E5=90=91tab=E7=9A=84=E6=8C=89?= =?UTF-8?q?=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../icontainer/UIEastResizableContainer.java | 12 ++++--- .../mainframe/EastRegionContainerPane.java | 33 +++++++++++++++---- 2 files changed, 35 insertions(+), 10 deletions(-) diff --git a/designer_base/src/com/fr/design/gui/icontainer/UIEastResizableContainer.java b/designer_base/src/com/fr/design/gui/icontainer/UIEastResizableContainer.java index e1a1c2a16..ae7c92fd9 100644 --- a/designer_base/src/com/fr/design/gui/icontainer/UIEastResizableContainer.java +++ b/designer_base/src/com/fr/design/gui/icontainer/UIEastResizableContainer.java @@ -33,7 +33,7 @@ public class UIEastResizableContainer extends JPanel { private static final int ARROW_MARGIN = 15; private static final int ARROW_RANGE = 35; - private boolean isRightPaneVisible = true; +// private boolean isRightPaneVisible = true; public UIEastResizableContainer() { this(new JPanel(), new JPanel()); @@ -49,11 +49,15 @@ public class UIEastResizableContainer extends JPanel { this.preferredWidth = width; } - - public void setRightPaneVisible(boolean isVisible){ - this.isRightPaneVisible = isVisible; + public boolean isRightPaneVisible() { + return containerWidth > leftPaneWidth; } + +// public void setRightPaneVisible(boolean isVisible){ +// this.isRightPaneVisible = isVisible; +// } + private void setPreferredWidth(int width) { this.preferredWidth = width; } diff --git a/designer_base/src/com/fr/design/mainframe/EastRegionContainerPane.java b/designer_base/src/com/fr/design/mainframe/EastRegionContainerPane.java index 99cf14517..117a257b0 100644 --- a/designer_base/src/com/fr/design/mainframe/EastRegionContainerPane.java +++ b/designer_base/src/com/fr/design/mainframe/EastRegionContainerPane.java @@ -5,6 +5,7 @@ import com.fr.design.DesignerEnvManager; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.icontainer.UIEastResizableContainer; import com.fr.design.gui.icontainer.UIResizableContainer; +import com.fr.design.layout.VerticalFlowLayout; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.stable.Constants; @@ -90,6 +91,7 @@ public class EastRegionContainerPane extends UIEastResizableContainer { // 左侧按钮面板 private void initLeftPane() { leftPane = new JPanel(); + leftPane.setLayout(new VerticalFlowLayout(VerticalFlowLayout.TOP, 0, 0)); for (PropertyItem item : propertyItemList) { leftPane.add(item.getButton()); } @@ -186,7 +188,7 @@ public class EastRegionContainerPane extends UIEastResizableContainer { class PropertyItem { // private UIButton button; - private JButton button; + private UIButton button; private String name; private JPanel propertyPanel; private JComponent contentPane; @@ -243,20 +245,33 @@ public class EastRegionContainerPane extends UIEastResizableContainer { } private void initButton(String btnUrl) { - button = new JButton(BaseUtils.readIcon(btnUrl)); + button = new UIButton(BaseUtils.readIcon(btnUrl)) { + public Dimension getPreferredSize() { + return new Dimension(BUTTON_WIDTH, BUTTON_WIDTH); + } + }; // button = new UIButton("btnd\nssdg"); // button.set4LargeToolbarButton(); - button.setPreferredSize(new Dimension(BUTTON_WIDTH, BUTTON_WIDTH)); - button.setContentAreaFilled(false); +// button.setBorder(BorderFactory.createEmptyBorder(0, 40, 0, 0)); +// button.setMargin(null); +// button.setOpaque(false); + button.set4LargeToolbarButton(); +// button.setSize(new Dimension(BUTTON_WIDTH, BUTTON_WIDTH)); +// button.setPreferredSize(new Dimension(BUTTON_WIDTH, BUTTON_WIDTH)); +// button.setContentAreaFilled(false); button.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - propertyCard.show(rightPane, name); + if (isRightPaneVisible()) { + propertyCard.show(rightPane, name); + } else { + popOut(); + } } }); } - public JButton getButton() { + public UIButton getButton() { return button; } @@ -267,5 +282,11 @@ public class EastRegionContainerPane extends UIEastResizableContainer { public JPanel getPropertyPanel() { return propertyPanel; } + + // 弹出对话框 + public void popOut() { + JDialog dialog = new JDialog(); + dialog.setVisible(true); + } } } \ No newline at end of file From 0569a1ff26f51ccd824c62de50456e8bd579a73e Mon Sep 17 00:00:00 2001 From: plough Date: Fri, 14 Jul 2017 11:05:18 +0800 Subject: [PATCH 2/5] =?UTF-8?q?REPORT-3163=20=E5=90=88=E4=BD=9C=E5=BC=80?= =?UTF-8?q?=E5=8F=919.0=E8=AE=BE=E8=AE=A1=E5=99=A8=3D>=E5=B1=9E=E6=80=A7?= =?UTF-8?q?=E9=9D=A2=E6=9D=BF=E6=94=B6=E8=B5=B7=E7=8A=B6=E6=80=81=E6=97=B6?= =?UTF-8?q?=EF=BC=8C=E7=82=B9=E5=87=BB=E7=AB=96=E5=90=91tab=EF=BC=8C?= =?UTF-8?q?=E5=BC=B9=E5=87=BA=E5=B1=9E=E6=80=A7=E9=9D=A2=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../icontainer/UIEastResizableContainer.java | 7 ++ .../mainframe/EastRegionContainerPane.java | 80 ++++++++++++++----- 2 files changed, 66 insertions(+), 21 deletions(-) diff --git a/designer_base/src/com/fr/design/gui/icontainer/UIEastResizableContainer.java b/designer_base/src/com/fr/design/gui/icontainer/UIEastResizableContainer.java index ae7c92fd9..3a24e3902 100644 --- a/designer_base/src/com/fr/design/gui/icontainer/UIEastResizableContainer.java +++ b/designer_base/src/com/fr/design/gui/icontainer/UIEastResizableContainer.java @@ -228,6 +228,12 @@ public class UIEastResizableContainer extends JPanel { revalidate(); } + /** + * 伸缩右子面板时,触发此方法 + */ + public void onResize() { + } + private class TopToolPane extends JPanel { private int model = UIConstants.MODEL_NORMAL; @@ -268,6 +274,7 @@ public class UIEastResizableContainer extends JPanel { setPreferredWidth(containerWidth); containerWidth = leftPaneWidth; } + onResize(); refreshContainer(); if (BaseUtils.isAuthorityEditing()) { DesignerContext.getDesignerFrame().doResize(); diff --git a/designer_base/src/com/fr/design/mainframe/EastRegionContainerPane.java b/designer_base/src/com/fr/design/mainframe/EastRegionContainerPane.java index 117a257b0..5f7960665 100644 --- a/designer_base/src/com/fr/design/mainframe/EastRegionContainerPane.java +++ b/designer_base/src/com/fr/design/mainframe/EastRegionContainerPane.java @@ -6,6 +6,7 @@ import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.icontainer.UIEastResizableContainer; import com.fr.design.gui.icontainer.UIResizableContainer; import com.fr.design.layout.VerticalFlowLayout; +import com.fr.design.style.AbstractPopBox; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.stable.Constants; @@ -46,7 +47,7 @@ public class EastRegionContainerPane extends UIEastResizableContainer { initRightPane(); initLeftPane(); // super(leftPane, rightPane); - setContainerWidth(260); + setContainerWidth(CONTAINER_WIDTH); } private void initPropertyItemList() { @@ -101,6 +102,13 @@ public class EastRegionContainerPane extends UIEastResizableContainer { replaceLeftPane(leftPane); } + @Override + public void onResize() { + for (PropertyItem item : propertyItemList) { + item.onResize(); + } + } + public EastRegionContainerPane(JPanel leftPane, JPanel rightPane) { super(leftPane, rightPane); // setVerticalDragEnabled(false); @@ -192,9 +200,11 @@ public class EastRegionContainerPane extends UIEastResizableContainer { private String name; private JPanel propertyPanel; private JComponent contentPane; + private PropertyFixedPopupPane popupPane; // 左侧固定弹出框 private int x, y; // 弹出框的坐标 private int height; // 弹出框的高度 private boolean isPoppedOut; // 是否弹出 + private Dimension fixedSize; public PropertyItem(String name, String btnUrl) { this.name = name; @@ -210,10 +220,13 @@ public class EastRegionContainerPane extends UIEastResizableContainer { private void initPropertyPanel() { propertyPanel = new JPanel(); propertyPanel.setBackground(Color.pink); -// propertyPanel.setPreferredSize(getPreferredSize()); -// JPanel titlePanel = new JPanel(); -// titlePanel.setPreferredSize(new Dimension(propertyPanel.getPreferredSize().width, 20)); -// titlePanel + contentPane = generateContentPane(); + propertyPanel.setLayout(new BorderLayout()); + propertyPanel.add(contentPane, BorderLayout.CENTER); + } + + public JComponent generateContentPane() { + JComponent contentPane = new JPanel(); JButton testBtn = new JButton(name); testBtn.addActionListener(new ActionListener() { @Override @@ -221,14 +234,11 @@ public class EastRegionContainerPane extends UIEastResizableContainer { setEnabled(!button.isEnabled()); } }); - contentPane = new JPanel(); contentPane.add(testBtn); - propertyPanel.setLayout(new BorderLayout()); - propertyPanel.add(contentPane, BorderLayout.CENTER); + return contentPane; } public void replaceContentPane(JComponent pane) { -// remove(pane); propertyPanel.remove(this.contentPane); propertyPanel.add(this.contentPane = pane); refreshContainer(); @@ -238,6 +248,14 @@ public class EastRegionContainerPane extends UIEastResizableContainer { return contentPane; } + public void onResize() { + if (isRightPaneVisible()) { + replaceContentPane(contentPane); + } else if(popupPane != null) { + popupPane.replaceContentPane(contentPane); + } + } + private void refreshContainer() { propertyPanel.validate(); propertyPanel.repaint(); @@ -250,22 +268,14 @@ public class EastRegionContainerPane extends UIEastResizableContainer { return new Dimension(BUTTON_WIDTH, BUTTON_WIDTH); } }; -// button = new UIButton("btnd\nssdg"); -// button.set4LargeToolbarButton(); -// button.setBorder(BorderFactory.createEmptyBorder(0, 40, 0, 0)); -// button.setMargin(null); -// button.setOpaque(false); button.set4LargeToolbarButton(); -// button.setSize(new Dimension(BUTTON_WIDTH, BUTTON_WIDTH)); -// button.setPreferredSize(new Dimension(BUTTON_WIDTH, BUTTON_WIDTH)); -// button.setContentAreaFilled(false); button.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (isRightPaneVisible()) { propertyCard.show(rightPane, name); } else { - popOut(); + popupFixedPane(); } } }); @@ -284,9 +294,37 @@ public class EastRegionContainerPane extends UIEastResizableContainer { } // 弹出对话框 - public void popOut() { - JDialog dialog = new JDialog(); - dialog.setVisible(true); + public void popupFixedPane() { + if (popupPane == null) { + popupPane = new PropertyFixedPopupPane(contentPane); + } + GUICoreUtils.showPopupMenu(popupPane, button, -popupPane.getPreferredSize().width, 0); + } + } + + private class PropertyFixedPopupPane extends JPopupMenu { + private JComponent contentPane; + PropertyFixedPopupPane(JComponent contentPane) { + this.contentPane = contentPane; + this.add(contentPane); + this.setPreferredSize(new Dimension(CONTAINER_WIDTH - BUTTON_WIDTH, getPreferredSize().height)); + } + + public JComponent getContentPane() { + return contentPane; + } + + public void replaceContentPane(JComponent pane) { +// remove(pane); + this.remove(this.contentPane); + this.add(this.contentPane = pane); + refreshContainer(); + } + + private void refreshContainer() { + validate(); + repaint(); + revalidate(); } } } \ No newline at end of file From 6ee7cee67153785f80ecb7001a44019c3e0413be Mon Sep 17 00:00:00 2001 From: plough Date: Sat, 15 Jul 2017 07:01:05 +0800 Subject: [PATCH 3/5] =?UTF-8?q?REPORT-3163=20=E5=90=88=E4=BD=9C=E5=BC=80?= =?UTF-8?q?=E5=8F=919.0=E8=AE=BE=E8=AE=A1=E5=99=A8=3D>=E5=BC=B9=E5=87=BA?= =?UTF-8?q?=E5=AF=B9=E8=AF=9D=E6=A1=86=E7=9A=84=E5=88=9D=E6=AD=A5=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=EF=BC=9B=E8=B0=83=E6=95=B4=E5=BC=B9=E5=85=A5=E3=80=81?= =?UTF-8?q?=E5=BC=B9=E5=87=BA=E5=B7=A5=E5=85=B7=E6=9D=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mainframe/EastRegionContainerPane.java | 177 ++++++++++++++++-- 1 file changed, 165 insertions(+), 12 deletions(-) diff --git a/designer_base/src/com/fr/design/mainframe/EastRegionContainerPane.java b/designer_base/src/com/fr/design/mainframe/EastRegionContainerPane.java index 5f7960665..b73ff02ef 100644 --- a/designer_base/src/com/fr/design/mainframe/EastRegionContainerPane.java +++ b/designer_base/src/com/fr/design/mainframe/EastRegionContainerPane.java @@ -2,18 +2,22 @@ package com.fr.design.mainframe; import com.fr.base.BaseUtils; import com.fr.design.DesignerEnvManager; +import com.fr.design.constants.UIConstants; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.icontainer.UIEastResizableContainer; import com.fr.design.gui.icontainer.UIResizableContainer; +import com.fr.design.gui.ilable.UILabel; import com.fr.design.layout.VerticalFlowLayout; import com.fr.design.style.AbstractPopBox; import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.general.FRFont; import com.fr.stable.Constants; +import com.fr.stable.StringUtils; import javax.swing.*; +import javax.swing.border.EmptyBorder; import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; +import java.awt.event.*; import java.util.ArrayList; import java.util.List; @@ -24,7 +28,10 @@ public class EastRegionContainerPane extends UIEastResizableContainer { private JPanel leftPane; private JPanel rightPane; private static final int CONTAINER_WIDTH = 260; - private static final int BUTTON_WIDTH = 40; + private static final int TAB_WIDTH = 40; + private static final int CONTENT_WIDTH = CONTAINER_WIDTH - TAB_WIDTH; + private static final int POPUP_TOOLPANE_HEIGHT = 25; + private static final int ARROW_RANGE_START = CONTENT_WIDTH - 30; /** * 得到实例 @@ -176,6 +183,7 @@ public class EastRegionContainerPane extends UIEastResizableContainer { * 刷新右面板 */ public void refreshRightPane() { + if (this.getRightPane() instanceof DockingView) { ((DockingView) this.getRightPane()).refreshDockingView(); } @@ -188,6 +196,12 @@ public class EastRegionContainerPane extends UIEastResizableContainer { } } + private void refreshContainer() { + validate(); + repaint(); + revalidate(); + } + public int getToolPaneY() { return 0; } @@ -198,9 +212,10 @@ public class EastRegionContainerPane extends UIEastResizableContainer { // private UIButton button; private UIButton button; private String name; - private JPanel propertyPanel; + private JComponent propertyPanel; private JComponent contentPane; private PropertyFixedPopupPane popupPane; // 左侧固定弹出框 + private PopupToolPane popupToolPane; // 弹出工具条 private int x, y; // 弹出框的坐标 private int height; // 弹出框的高度 private boolean isPoppedOut; // 是否弹出 @@ -221,7 +236,9 @@ public class EastRegionContainerPane extends UIEastResizableContainer { propertyPanel = new JPanel(); propertyPanel.setBackground(Color.pink); contentPane = generateContentPane(); + popupToolPane = new PopupToolPane(contentPane, PopupToolPane.UP_BUTTON); propertyPanel.setLayout(new BorderLayout()); + propertyPanel.add(popupToolPane, BorderLayout.NORTH); propertyPanel.add(contentPane, BorderLayout.CENTER); } @@ -256,16 +273,16 @@ public class EastRegionContainerPane extends UIEastResizableContainer { } } - private void refreshContainer() { - propertyPanel.validate(); - propertyPanel.repaint(); - propertyPanel.revalidate(); - } +// private void refreshContainer() { +// propertyPanel.validate(); +// propertyPanel.repaint(); +// propertyPanel.revalidate(); +// } private void initButton(String btnUrl) { button = new UIButton(BaseUtils.readIcon(btnUrl)) { public Dimension getPreferredSize() { - return new Dimension(BUTTON_WIDTH, BUTTON_WIDTH); + return new Dimension(TAB_WIDTH, TAB_WIDTH); } }; button.set4LargeToolbarButton(); @@ -289,7 +306,7 @@ public class EastRegionContainerPane extends UIEastResizableContainer { return name; } - public JPanel getPropertyPanel() { + public JComponent getPropertyPanel() { return propertyPanel; } @@ -307,7 +324,7 @@ public class EastRegionContainerPane extends UIEastResizableContainer { PropertyFixedPopupPane(JComponent contentPane) { this.contentPane = contentPane; this.add(contentPane); - this.setPreferredSize(new Dimension(CONTAINER_WIDTH - BUTTON_WIDTH, getPreferredSize().height)); + this.setPreferredSize(new Dimension(CONTAINER_WIDTH - TAB_WIDTH, getPreferredSize().height)); } public JComponent getContentPane() { @@ -327,4 +344,140 @@ public class EastRegionContainerPane extends UIEastResizableContainer { revalidate(); } } + + // 弹出属性面板的工具条 + private class PopupToolPane extends JPanel { + private int model = UIConstants.MODEL_NORMAL; + private String title = "单元格元素"; + private JComponent contentPane; + private String buttonType; + private static final String NO_BUTTON = "NoButton"; + private static final String UP_BUTTON = "UpButton"; + private static final String DOWN_BUTTON = "DownButton"; + + public PopupToolPane(JComponent contentPane) { + this(contentPane, NO_BUTTON); + } + + public PopupToolPane(JComponent contentPane, String buttonType) { + super(); + this.contentPane = contentPane; + setLayout(new BorderLayout()); + UILabel label = new UILabel(title); + label.setForeground(new Color(69, 135, 255)); + add(label, BorderLayout.WEST); + setBorder(new EmptyBorder(5, 10, 0, 0)); + + initToolButton(buttonType); + } + + private void initToolButton(String buttonType) { + this.buttonType = buttonType; + if (buttonType.equals(NO_BUTTON)) { + return; + } + + if (buttonType.equals(UP_BUTTON)) { + + } else if (buttonType.equals(DOWN_BUTTON)) { + + } else { + throw new IllegalArgumentException("unknown button type: " + buttonType); + } + + addMouseMotionListener(new MouseMotionListener() { + @Override + public void mouseMoved(MouseEvent e) { + if (e.getX() >= ARROW_RANGE_START) { + setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); + model = UIConstants.MODEL_PRESS; + } else { + setCursor(Cursor.getDefaultCursor()); + model = UIConstants.MODEL_NORMAL; + } + repaint(); + } + + @Override + public void mouseDragged(MouseEvent e) { + } + }); + addMouseListener(new MouseAdapter() { + @Override + public void mouseExited(MouseEvent e) { + setCursor(Cursor.getDefaultCursor()); + model = UIConstants.MODEL_NORMAL; + repaint(); + } + + @Override + public void mouseClicked(MouseEvent e) { + if (e.getX() >= ARROW_RANGE_START) { + popupDialog(); + } + } + }); + } + + public void popupDialog() { + new PopupDialog(contentPane); + } + + @Override + public Dimension getPreferredSize() { + return new Dimension(super.getPreferredSize().width, POPUP_TOOLPANE_HEIGHT); + } + + @Override + public void paint(Graphics g) { + super.paint(g); + Image button; + g.setColor(new Color(69, 135, 255)); + g.setFont(FRFont.getInstance().applySize(14)); +// g.drawString(title, 5, 20); +// g.drawImage(UIConstants.DRAG_BAR, 0, 0, CONTENT_WIDTH, POPUP_TOOLPANE_HEIGHT, null); + + if (buttonType.equals(NO_BUTTON)) { + return; + } + if (buttonType.equals(UP_BUTTON)) { + if (model == UIConstants.MODEL_NORMAL) { + button = UIConstants.DRAG_LEFT_NORMAL; + } else { + button = UIConstants.DRAG_LEFT_PRESS; + } + } else { + if (model == UIConstants.MODEL_NORMAL) { + button = UIConstants.DRAG_RIGHT_NORMAL; + } else { + button = UIConstants.DRAG_RIGHT_PRESS; + } + } +// g.drawImage(button, 2, ARROW_MARGIN_VERTICAL, 5, toolPaneHeight, null); + g.drawImage(button, ARROW_RANGE_START + 12, 7, 5, 5, null); + } + } + + private class PopupDialog extends JDialog { + public PopupDialog(JComponent contentPane) { +// setUndecorated(true); +// JPanel pane = new JPanel(); +// pane.setBackground(Color.yellow); +// pane.setPreferredSize(new Dimension(100, 100)); +// +// getContentPane().add(pane); +// setSize(CONTENT_WIDTH, pane.getPreferredSize().height); + getContentPane().add(contentPane); + setSize(CONTENT_WIDTH, contentPane.getPreferredSize().height); + validate(); + + this.setVisible(true); + } + + private void refreshContainer() { + validate(); + repaint(); + revalidate(); + } + } } \ No newline at end of file From 0a9708d434538dfd28bf0c27ac7bbb4592c5b813 Mon Sep 17 00:00:00 2001 From: plough Date: Sat, 15 Jul 2017 11:35:53 +0800 Subject: [PATCH 4/5] =?UTF-8?q?REPORT-3163=20=E5=90=88=E4=BD=9C=E5=BC=80?= =?UTF-8?q?=E5=8F=919.0=E8=AE=BE=E8=AE=A1=E5=99=A8=3D>=E5=BC=B9=E5=87=BA?= =?UTF-8?q?=E5=AF=B9=E8=AF=9D=E6=A1=86=E5=8F=AF=E6=8B=96=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mainframe/EastRegionContainerPane.java | 93 ++++++++++++++----- 1 file changed, 72 insertions(+), 21 deletions(-) diff --git a/designer_base/src/com/fr/design/mainframe/EastRegionContainerPane.java b/designer_base/src/com/fr/design/mainframe/EastRegionContainerPane.java index b73ff02ef..76f552dc0 100644 --- a/designer_base/src/com/fr/design/mainframe/EastRegionContainerPane.java +++ b/designer_base/src/com/fr/design/mainframe/EastRegionContainerPane.java @@ -51,8 +51,7 @@ public class EastRegionContainerPane extends UIEastResizableContainer { super(); // setVerticalDragEnabled(false); initPropertyItemList(); - initRightPane(); - initLeftPane(); + initContentPane(); // super(leftPane, rightPane); setContainerWidth(CONTAINER_WIDTH); } @@ -83,6 +82,11 @@ public class EastRegionContainerPane extends UIEastResizableContainer { propertyItemList.add(widgetLib); } + private void initContentPane() { + initRightPane(); + initLeftPane(); + } + // 右侧属性面板 private void initRightPane() { rightPane = new JPanel(); @@ -109,6 +113,13 @@ public class EastRegionContainerPane extends UIEastResizableContainer { replaceLeftPane(leftPane); } + // 弹出面板时,更新框架内容 + private void removeItem(PropertyItem propertyItem) { + leftPane.remove(propertyItem.getButton()); + rightPane.remove(propertyItem.getPropertyPanel()); + refreshContainer(); + } + @Override public void onResize() { for (PropertyItem item : propertyItemList) { @@ -236,12 +247,16 @@ public class EastRegionContainerPane extends UIEastResizableContainer { propertyPanel = new JPanel(); propertyPanel.setBackground(Color.pink); contentPane = generateContentPane(); - popupToolPane = new PopupToolPane(contentPane, PopupToolPane.UP_BUTTON); + popupToolPane = new PopupToolPane(this, PopupToolPane.UP_BUTTON); propertyPanel.setLayout(new BorderLayout()); propertyPanel.add(popupToolPane, BorderLayout.NORTH); propertyPanel.add(contentPane, BorderLayout.CENTER); } + public void setIsPoppedOut(boolean isPoppedOut) { + this.isPoppedOut = isPoppedOut; + } + public JComponent generateContentPane() { JComponent contentPane = new JPanel(); JButton testBtn = new JButton(name); @@ -350,18 +365,24 @@ public class EastRegionContainerPane extends UIEastResizableContainer { private int model = UIConstants.MODEL_NORMAL; private String title = "单元格元素"; private JComponent contentPane; + private PropertyItem propertyItem; private String buttonType; + private JDialog parentDialog; // 如果不在对话框中,值为null + private boolean isMovable = false; + private Point mouseDownCompCoords; // 存储按下左键的位置,移动对话框时会用到 + private static final String NO_BUTTON = "NoButton"; private static final String UP_BUTTON = "UpButton"; private static final String DOWN_BUTTON = "DownButton"; - public PopupToolPane(JComponent contentPane) { - this(contentPane, NO_BUTTON); + public PopupToolPane(PropertyItem propertyItem) { + this(propertyItem, NO_BUTTON); } - public PopupToolPane(JComponent contentPane, String buttonType) { + public PopupToolPane(PropertyItem propertyItem, String buttonType) { super(); - this.contentPane = contentPane; + this.propertyItem = propertyItem; + this.contentPane = propertyItem.getContentPane(); setLayout(new BorderLayout()); UILabel label = new UILabel(title); label.setForeground(new Color(69, 135, 255)); @@ -371,7 +392,12 @@ public class EastRegionContainerPane extends UIEastResizableContainer { initToolButton(buttonType); } - private void initToolButton(String buttonType) { + public void setParentDialog(JDialog parentDialog) { + this.parentDialog = parentDialog; + isMovable = true; + } + + private void initToolButton(final String buttonType) { this.buttonType = buttonType; if (buttonType.equals(NO_BUTTON)) { return; @@ -400,6 +426,10 @@ public class EastRegionContainerPane extends UIEastResizableContainer { @Override public void mouseDragged(MouseEvent e) { + if (isMovable && e.getX() < ARROW_RANGE_START) { + Point currCoords = e.getLocationOnScreen(); + parentDialog.setLocation(currCoords.x - mouseDownCompCoords.x, currCoords.y - mouseDownCompCoords.y); + } } }); addMouseListener(new MouseAdapter() { @@ -413,14 +443,35 @@ public class EastRegionContainerPane extends UIEastResizableContainer { @Override public void mouseClicked(MouseEvent e) { if (e.getX() >= ARROW_RANGE_START) { - popupDialog(); + onPop(); } } + + @Override + public void mouseReleased(MouseEvent e) { + mouseDownCompCoords = null; + } + @Override + public void mousePressed(MouseEvent e) { + mouseDownCompCoords = e.getPoint(); + } + }); } - public void popupDialog() { - new PopupDialog(contentPane); + // 触发弹入、弹出 + private void onPop() { + if (buttonType.equals(UP_BUTTON)) { + popUpDialog(); + } + } + + public void popUpDialog() { + propertyItem.setIsPoppedOut(true); + new PopupDialog(propertyItem); +// initContentPane(); +// refreshContainer(); + removeItem(propertyItem); } @Override @@ -459,25 +510,25 @@ public class EastRegionContainerPane extends UIEastResizableContainer { } private class PopupDialog extends JDialog { - public PopupDialog(JComponent contentPane) { -// setUndecorated(true); + private Container container; + public PopupDialog(PropertyItem propertyItem) { + container = getContentPane(); + setUndecorated(true); // JPanel pane = new JPanel(); // pane.setBackground(Color.yellow); // pane.setPreferredSize(new Dimension(100, 100)); // // getContentPane().add(pane); // setSize(CONTENT_WIDTH, pane.getPreferredSize().height); - getContentPane().add(contentPane); - setSize(CONTENT_WIDTH, contentPane.getPreferredSize().height); + PopupToolPane popupToolPane = new PopupToolPane(propertyItem, PopupToolPane.DOWN_BUTTON); + popupToolPane.setParentDialog(this); + JComponent contentPane = propertyItem.getContentPane(); + container.add(popupToolPane, BorderLayout.NORTH); + container.add(contentPane, BorderLayout.CENTER); + setSize(CONTENT_WIDTH, container.getPreferredSize().height); validate(); this.setVisible(true); } - - private void refreshContainer() { - validate(); - repaint(); - revalidate(); - } } } \ No newline at end of file From dadb31b82e43544deb44f8986a14c6e2535482a2 Mon Sep 17 00:00:00 2001 From: plough Date: Sat, 15 Jul 2017 23:22:39 +0800 Subject: [PATCH 5/5] =?UTF-8?q?REPORT-3163=20=E5=90=88=E4=BD=9C=E5=BC=80?= =?UTF-8?q?=E5=8F=919.0=E8=AE=BE=E8=AE=A1=E5=99=A8=3D>=E5=8F=AF=E5=BC=B9?= =?UTF-8?q?=E5=87=BA=E3=80=81=E5=BC=B9=E5=85=A5=E5=AF=B9=E8=AF=9D=E6=A1=86?= =?UTF-8?q?=EF=BC=9B=E9=99=90=E5=88=B6=E5=AF=B9=E8=AF=9D=E6=A1=86=E5=8F=AF?= =?UTF-8?q?=E7=A7=BB=E5=8A=A8=E5=8C=BA=E5=9F=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mainframe/EastRegionContainerPane.java | 61 +++++++++++++++---- 1 file changed, 48 insertions(+), 13 deletions(-) diff --git a/designer_base/src/com/fr/design/mainframe/EastRegionContainerPane.java b/designer_base/src/com/fr/design/mainframe/EastRegionContainerPane.java index 76f552dc0..baef0d069 100644 --- a/designer_base/src/com/fr/design/mainframe/EastRegionContainerPane.java +++ b/designer_base/src/com/fr/design/mainframe/EastRegionContainerPane.java @@ -5,14 +5,10 @@ import com.fr.design.DesignerEnvManager; import com.fr.design.constants.UIConstants; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.icontainer.UIEastResizableContainer; -import com.fr.design.gui.icontainer.UIResizableContainer; import com.fr.design.gui.ilable.UILabel; import com.fr.design.layout.VerticalFlowLayout; -import com.fr.design.style.AbstractPopBox; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.general.FRFont; -import com.fr.stable.Constants; -import com.fr.stable.StringUtils; import javax.swing.*; import javax.swing.border.EmptyBorder; @@ -225,11 +221,11 @@ public class EastRegionContainerPane extends UIEastResizableContainer { private String name; private JComponent propertyPanel; private JComponent contentPane; - private PropertyFixedPopupPane popupPane; // 左侧固定弹出框 + private FixedPopupPane popupPane; // 左侧固定弹出框 private PopupToolPane popupToolPane; // 弹出工具条 private int x, y; // 弹出框的坐标 private int height; // 弹出框的高度 - private boolean isPoppedOut; // 是否弹出 + private boolean isPoppedOut = false; // 是否弹出 private Dimension fixedSize; public PropertyItem(String name, String btnUrl) { @@ -328,15 +324,15 @@ public class EastRegionContainerPane extends UIEastResizableContainer { // 弹出对话框 public void popupFixedPane() { if (popupPane == null) { - popupPane = new PropertyFixedPopupPane(contentPane); + popupPane = new FixedPopupPane(contentPane); } GUICoreUtils.showPopupMenu(popupPane, button, -popupPane.getPreferredSize().width, 0); } } - private class PropertyFixedPopupPane extends JPopupMenu { + private class FixedPopupPane extends JPopupMenu { private JComponent contentPane; - PropertyFixedPopupPane(JComponent contentPane) { + FixedPopupPane(JComponent contentPane) { this.contentPane = contentPane; this.add(contentPane); this.setPreferredSize(new Dimension(CONTAINER_WIDTH - TAB_WIDTH, getPreferredSize().height)); @@ -371,6 +367,12 @@ public class EastRegionContainerPane extends UIEastResizableContainer { private boolean isMovable = false; private Point mouseDownCompCoords; // 存储按下左键的位置,移动对话框时会用到 + private static final int MIN_X = -150; + private static final int MIN_Y_SHIFT = 50; + private static final int MAX_X_SHIFT = 50; + private static final int MAX_Y_SHIFT = 50; + + private static final String NO_BUTTON = "NoButton"; private static final String UP_BUTTON = "UpButton"; private static final String DOWN_BUTTON = "DownButton"; @@ -426,9 +428,28 @@ public class EastRegionContainerPane extends UIEastResizableContainer { @Override public void mouseDragged(MouseEvent e) { - if (isMovable && e.getX() < ARROW_RANGE_START) { + if (isMovable && mouseDownCompCoords != null) { Point currCoords = e.getLocationOnScreen(); - parentDialog.setLocation(currCoords.x - mouseDownCompCoords.x, currCoords.y - mouseDownCompCoords.y); + int x = currCoords.x - mouseDownCompCoords.x; + int y = currCoords.y - mouseDownCompCoords.y; + //屏幕可用区域 + Rectangle screen = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds(); + + int minY = screen.y; + int maxX = Toolkit.getDefaultToolkit().getScreenSize().width - MAX_X_SHIFT; + int maxY = Toolkit.getDefaultToolkit().getScreenSize().height - MAX_Y_SHIFT; + if (x < MIN_X) { + x = MIN_X; + } else if (x > maxX) { + x = maxX; + } + if (y < minY) { + y = minY; + } else if (y > maxY) { + y = maxY; + } + // 移动到屏幕边缘时,需要校正位置 + parentDialog.setLocation(x, y); } } }); @@ -453,7 +474,9 @@ public class EastRegionContainerPane extends UIEastResizableContainer { } @Override public void mousePressed(MouseEvent e) { - mouseDownCompCoords = e.getPoint(); + if (e.getX() < ARROW_RANGE_START) { + mouseDownCompCoords = e.getPoint(); + } } }); @@ -463,6 +486,8 @@ public class EastRegionContainerPane extends UIEastResizableContainer { private void onPop() { if (buttonType.equals(UP_BUTTON)) { popUpDialog(); + } else if (buttonType.equals(DOWN_BUTTON)) { + popToFrame(); } } @@ -474,6 +499,14 @@ public class EastRegionContainerPane extends UIEastResizableContainer { removeItem(propertyItem); } + public void popToFrame() { + propertyItem.setIsPoppedOut(false); + parentDialog.dispose(); + initContentPane(); + onResize(); + refreshContainer(); + } + @Override public Dimension getPreferredSize() { return new Dimension(super.getPreferredSize().width, POPUP_TOOLPANE_HEIGHT); @@ -526,8 +559,10 @@ public class EastRegionContainerPane extends UIEastResizableContainer { container.add(popupToolPane, BorderLayout.NORTH); container.add(contentPane, BorderLayout.CENTER); setSize(CONTENT_WIDTH, container.getPreferredSize().height); - validate(); + validate(); + Point btnCoords = propertyItem.getButton().getLocationOnScreen(); + this.setLocation(btnCoords.x - CONTENT_WIDTH, btnCoords.y); this.setVisible(true); } }