|
|
@ -2,16 +2,18 @@ package com.fr.design.mainframe; |
|
|
|
|
|
|
|
|
|
|
|
import com.fr.base.BaseUtils; |
|
|
|
import com.fr.base.BaseUtils; |
|
|
|
import com.fr.design.DesignerEnvManager; |
|
|
|
import com.fr.design.DesignerEnvManager; |
|
|
|
|
|
|
|
import com.fr.design.constants.UIConstants; |
|
|
|
import com.fr.design.gui.ibutton.UIButton; |
|
|
|
import com.fr.design.gui.ibutton.UIButton; |
|
|
|
import com.fr.design.gui.icontainer.UIEastResizableContainer; |
|
|
|
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.utils.gui.GUICoreUtils; |
|
|
|
import com.fr.design.utils.gui.GUICoreUtils; |
|
|
|
import com.fr.stable.Constants; |
|
|
|
import com.fr.general.FRFont; |
|
|
|
|
|
|
|
|
|
|
|
import javax.swing.*; |
|
|
|
import javax.swing.*; |
|
|
|
|
|
|
|
import javax.swing.border.EmptyBorder; |
|
|
|
import java.awt.*; |
|
|
|
import java.awt.*; |
|
|
|
import java.awt.event.ActionEvent; |
|
|
|
import java.awt.event.*; |
|
|
|
import java.awt.event.ActionListener; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
|
|
@ -22,7 +24,10 @@ public class EastRegionContainerPane extends UIEastResizableContainer { |
|
|
|
private JPanel leftPane; |
|
|
|
private JPanel leftPane; |
|
|
|
private JPanel rightPane; |
|
|
|
private JPanel rightPane; |
|
|
|
private static final int CONTAINER_WIDTH = 260; |
|
|
|
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; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 得到实例 |
|
|
|
* 得到实例 |
|
|
@ -42,10 +47,9 @@ public class EastRegionContainerPane extends UIEastResizableContainer { |
|
|
|
super(); |
|
|
|
super(); |
|
|
|
// setVerticalDragEnabled(false);
|
|
|
|
// setVerticalDragEnabled(false);
|
|
|
|
initPropertyItemList(); |
|
|
|
initPropertyItemList(); |
|
|
|
initRightPane(); |
|
|
|
initContentPane(); |
|
|
|
initLeftPane(); |
|
|
|
|
|
|
|
// super(leftPane, rightPane);
|
|
|
|
// super(leftPane, rightPane);
|
|
|
|
setContainerWidth(260); |
|
|
|
setContainerWidth(CONTAINER_WIDTH); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void initPropertyItemList() { |
|
|
|
private void initPropertyItemList() { |
|
|
@ -74,6 +78,11 @@ public class EastRegionContainerPane extends UIEastResizableContainer { |
|
|
|
propertyItemList.add(widgetLib); |
|
|
|
propertyItemList.add(widgetLib); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void initContentPane() { |
|
|
|
|
|
|
|
initRightPane(); |
|
|
|
|
|
|
|
initLeftPane(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 右侧属性面板
|
|
|
|
// 右侧属性面板
|
|
|
|
private void initRightPane() { |
|
|
|
private void initRightPane() { |
|
|
|
rightPane = new JPanel(); |
|
|
|
rightPane = new JPanel(); |
|
|
@ -90,6 +99,7 @@ public class EastRegionContainerPane extends UIEastResizableContainer { |
|
|
|
// 左侧按钮面板
|
|
|
|
// 左侧按钮面板
|
|
|
|
private void initLeftPane() { |
|
|
|
private void initLeftPane() { |
|
|
|
leftPane = new JPanel(); |
|
|
|
leftPane = new JPanel(); |
|
|
|
|
|
|
|
leftPane.setLayout(new VerticalFlowLayout(VerticalFlowLayout.TOP, 0, 0)); |
|
|
|
for (PropertyItem item : propertyItemList) { |
|
|
|
for (PropertyItem item : propertyItemList) { |
|
|
|
leftPane.add(item.getButton()); |
|
|
|
leftPane.add(item.getButton()); |
|
|
|
} |
|
|
|
} |
|
|
@ -99,6 +109,20 @@ public class EastRegionContainerPane extends UIEastResizableContainer { |
|
|
|
replaceLeftPane(leftPane); |
|
|
|
replaceLeftPane(leftPane); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 弹出面板时,更新框架内容
|
|
|
|
|
|
|
|
private void removeItem(PropertyItem propertyItem) { |
|
|
|
|
|
|
|
leftPane.remove(propertyItem.getButton()); |
|
|
|
|
|
|
|
rightPane.remove(propertyItem.getPropertyPanel()); |
|
|
|
|
|
|
|
refreshContainer(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void onResize() { |
|
|
|
|
|
|
|
for (PropertyItem item : propertyItemList) { |
|
|
|
|
|
|
|
item.onResize(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public EastRegionContainerPane(JPanel leftPane, JPanel rightPane) { |
|
|
|
public EastRegionContainerPane(JPanel leftPane, JPanel rightPane) { |
|
|
|
super(leftPane, rightPane); |
|
|
|
super(leftPane, rightPane); |
|
|
|
// setVerticalDragEnabled(false);
|
|
|
|
// setVerticalDragEnabled(false);
|
|
|
@ -166,6 +190,7 @@ public class EastRegionContainerPane extends UIEastResizableContainer { |
|
|
|
* 刷新右面板 |
|
|
|
* 刷新右面板 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void refreshRightPane() { |
|
|
|
public void refreshRightPane() { |
|
|
|
|
|
|
|
|
|
|
|
if (this.getRightPane() instanceof DockingView) { |
|
|
|
if (this.getRightPane() instanceof DockingView) { |
|
|
|
((DockingView) this.getRightPane()).refreshDockingView(); |
|
|
|
((DockingView) this.getRightPane()).refreshDockingView(); |
|
|
|
} |
|
|
|
} |
|
|
@ -178,6 +203,12 @@ public class EastRegionContainerPane extends UIEastResizableContainer { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void refreshContainer() { |
|
|
|
|
|
|
|
validate(); |
|
|
|
|
|
|
|
repaint(); |
|
|
|
|
|
|
|
revalidate(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public int getToolPaneY() { |
|
|
|
public int getToolPaneY() { |
|
|
|
return 0; |
|
|
|
return 0; |
|
|
|
} |
|
|
|
} |
|
|
@ -186,13 +217,16 @@ public class EastRegionContainerPane extends UIEastResizableContainer { |
|
|
|
|
|
|
|
|
|
|
|
class PropertyItem { |
|
|
|
class PropertyItem { |
|
|
|
// private UIButton button;
|
|
|
|
// private UIButton button;
|
|
|
|
private JButton button; |
|
|
|
private UIButton button; |
|
|
|
private String name; |
|
|
|
private String name; |
|
|
|
private JPanel propertyPanel; |
|
|
|
private JComponent propertyPanel; |
|
|
|
private JComponent contentPane; |
|
|
|
private JComponent contentPane; |
|
|
|
|
|
|
|
private FixedPopupPane popupPane; // 左侧固定弹出框
|
|
|
|
|
|
|
|
private PopupToolPane popupToolPane; // 弹出工具条
|
|
|
|
private int x, y; // 弹出框的坐标
|
|
|
|
private int x, y; // 弹出框的坐标
|
|
|
|
private int height; // 弹出框的高度
|
|
|
|
private int height; // 弹出框的高度
|
|
|
|
private boolean isPoppedOut; // 是否弹出
|
|
|
|
private boolean isPoppedOut = false; // 是否弹出
|
|
|
|
|
|
|
|
private Dimension fixedSize; |
|
|
|
|
|
|
|
|
|
|
|
public PropertyItem(String name, String btnUrl) { |
|
|
|
public PropertyItem(String name, String btnUrl) { |
|
|
|
this.name = name; |
|
|
|
this.name = name; |
|
|
@ -208,10 +242,19 @@ public class EastRegionContainerPane extends UIEastResizableContainer { |
|
|
|
private void initPropertyPanel() { |
|
|
|
private void initPropertyPanel() { |
|
|
|
propertyPanel = new JPanel(); |
|
|
|
propertyPanel = new JPanel(); |
|
|
|
propertyPanel.setBackground(Color.pink); |
|
|
|
propertyPanel.setBackground(Color.pink); |
|
|
|
// propertyPanel.setPreferredSize(getPreferredSize());
|
|
|
|
contentPane = generateContentPane(); |
|
|
|
// JPanel titlePanel = new JPanel();
|
|
|
|
popupToolPane = new PopupToolPane(this, PopupToolPane.UP_BUTTON); |
|
|
|
// titlePanel.setPreferredSize(new Dimension(propertyPanel.getPreferredSize().width, 20));
|
|
|
|
propertyPanel.setLayout(new BorderLayout()); |
|
|
|
// titlePanel
|
|
|
|
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); |
|
|
|
JButton testBtn = new JButton(name); |
|
|
|
testBtn.addActionListener(new ActionListener() { |
|
|
|
testBtn.addActionListener(new ActionListener() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
@ -219,14 +262,11 @@ public class EastRegionContainerPane extends UIEastResizableContainer { |
|
|
|
setEnabled(!button.isEnabled()); |
|
|
|
setEnabled(!button.isEnabled()); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
contentPane = new JPanel(); |
|
|
|
|
|
|
|
contentPane.add(testBtn); |
|
|
|
contentPane.add(testBtn); |
|
|
|
propertyPanel.setLayout(new BorderLayout()); |
|
|
|
return contentPane; |
|
|
|
propertyPanel.add(contentPane, BorderLayout.CENTER); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void replaceContentPane(JComponent pane) { |
|
|
|
public void replaceContentPane(JComponent pane) { |
|
|
|
// remove(pane);
|
|
|
|
|
|
|
|
propertyPanel.remove(this.contentPane); |
|
|
|
propertyPanel.remove(this.contentPane); |
|
|
|
propertyPanel.add(this.contentPane = pane); |
|
|
|
propertyPanel.add(this.contentPane = pane); |
|
|
|
refreshContainer(); |
|
|
|
refreshContainer(); |
|
|
@ -236,27 +276,40 @@ public class EastRegionContainerPane extends UIEastResizableContainer { |
|
|
|
return contentPane; |
|
|
|
return contentPane; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void refreshContainer() { |
|
|
|
public void onResize() { |
|
|
|
propertyPanel.validate(); |
|
|
|
if (isRightPaneVisible()) { |
|
|
|
propertyPanel.repaint(); |
|
|
|
replaceContentPane(contentPane); |
|
|
|
propertyPanel.revalidate(); |
|
|
|
} else if(popupPane != null) { |
|
|
|
|
|
|
|
popupPane.replaceContentPane(contentPane); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// private void refreshContainer() {
|
|
|
|
|
|
|
|
// propertyPanel.validate();
|
|
|
|
|
|
|
|
// propertyPanel.repaint();
|
|
|
|
|
|
|
|
// propertyPanel.revalidate();
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
private void initButton(String btnUrl) { |
|
|
|
private void initButton(String btnUrl) { |
|
|
|
button = new JButton(BaseUtils.readIcon(btnUrl)); |
|
|
|
button = new UIButton(BaseUtils.readIcon(btnUrl)) { |
|
|
|
// button = new UIButton("btnd\nssdg");
|
|
|
|
public Dimension getPreferredSize() { |
|
|
|
// button.set4LargeToolbarButton();
|
|
|
|
return new Dimension(TAB_WIDTH, TAB_WIDTH); |
|
|
|
button.setPreferredSize(new Dimension(BUTTON_WIDTH, BUTTON_WIDTH)); |
|
|
|
} |
|
|
|
button.setContentAreaFilled(false); |
|
|
|
}; |
|
|
|
|
|
|
|
button.set4LargeToolbarButton(); |
|
|
|
button.addActionListener(new ActionListener() { |
|
|
|
button.addActionListener(new ActionListener() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
|
|
|
|
if (isRightPaneVisible()) { |
|
|
|
propertyCard.show(rightPane, name); |
|
|
|
propertyCard.show(rightPane, name); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
popupFixedPane(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public JButton getButton() { |
|
|
|
public UIButton getButton() { |
|
|
|
return button; |
|
|
|
return button; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -264,8 +317,253 @@ public class EastRegionContainerPane extends UIEastResizableContainer { |
|
|
|
return name; |
|
|
|
return name; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public JPanel getPropertyPanel() { |
|
|
|
public JComponent getPropertyPanel() { |
|
|
|
return propertyPanel; |
|
|
|
return propertyPanel; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 弹出对话框
|
|
|
|
|
|
|
|
public void popupFixedPane() { |
|
|
|
|
|
|
|
if (popupPane == null) { |
|
|
|
|
|
|
|
popupPane = new FixedPopupPane(contentPane); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
GUICoreUtils.showPopupMenu(popupPane, button, -popupPane.getPreferredSize().width, 0); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private class FixedPopupPane extends JPopupMenu { |
|
|
|
|
|
|
|
private JComponent contentPane; |
|
|
|
|
|
|
|
FixedPopupPane(JComponent contentPane) { |
|
|
|
|
|
|
|
this.contentPane = contentPane; |
|
|
|
|
|
|
|
this.add(contentPane); |
|
|
|
|
|
|
|
this.setPreferredSize(new Dimension(CONTAINER_WIDTH - TAB_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(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 弹出属性面板的工具条
|
|
|
|
|
|
|
|
private class PopupToolPane extends JPanel { |
|
|
|
|
|
|
|
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 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"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public PopupToolPane(PropertyItem propertyItem) { |
|
|
|
|
|
|
|
this(propertyItem, NO_BUTTON); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public PopupToolPane(PropertyItem propertyItem, String buttonType) { |
|
|
|
|
|
|
|
super(); |
|
|
|
|
|
|
|
this.propertyItem = propertyItem; |
|
|
|
|
|
|
|
this.contentPane = propertyItem.getContentPane(); |
|
|
|
|
|
|
|
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); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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) { |
|
|
|
|
|
|
|
if (isMovable && mouseDownCompCoords != null) { |
|
|
|
|
|
|
|
Point currCoords = e.getLocationOnScreen(); |
|
|
|
|
|
|
|
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); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
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) { |
|
|
|
|
|
|
|
onPop(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void mouseReleased(MouseEvent e) { |
|
|
|
|
|
|
|
mouseDownCompCoords = null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void mousePressed(MouseEvent e) { |
|
|
|
|
|
|
|
if (e.getX() < ARROW_RANGE_START) { |
|
|
|
|
|
|
|
mouseDownCompCoords = e.getPoint(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 触发弹入、弹出
|
|
|
|
|
|
|
|
private void onPop() { |
|
|
|
|
|
|
|
if (buttonType.equals(UP_BUTTON)) { |
|
|
|
|
|
|
|
popUpDialog(); |
|
|
|
|
|
|
|
} else if (buttonType.equals(DOWN_BUTTON)) { |
|
|
|
|
|
|
|
popToFrame(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void popUpDialog() { |
|
|
|
|
|
|
|
propertyItem.setIsPoppedOut(true); |
|
|
|
|
|
|
|
new PopupDialog(propertyItem); |
|
|
|
|
|
|
|
// initContentPane();
|
|
|
|
|
|
|
|
// refreshContainer();
|
|
|
|
|
|
|
|
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); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@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 { |
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
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(); |
|
|
|
|
|
|
|
Point btnCoords = propertyItem.getButton().getLocationOnScreen(); |
|
|
|
|
|
|
|
this.setLocation(btnCoords.x - CONTENT_WIDTH, btnCoords.y); |
|
|
|
|
|
|
|
this.setVisible(true); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |