From 6ee7cee67153785f80ecb7001a44019c3e0413be Mon Sep 17 00:00:00 2001 From: plough Date: Sat, 15 Jul 2017 07:01:05 +0800 Subject: [PATCH] =?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 5f79606653..b73ff02ef6 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