|
|
@ -9,6 +9,7 @@ import com.fr.design.gui.ilable.UILabel; |
|
|
|
import com.fr.design.layout.VerticalFlowLayout; |
|
|
|
import com.fr.design.layout.VerticalFlowLayout; |
|
|
|
import com.fr.design.utils.gui.GUICoreUtils; |
|
|
|
import com.fr.design.utils.gui.GUICoreUtils; |
|
|
|
import com.fr.general.FRFont; |
|
|
|
import com.fr.general.FRFont; |
|
|
|
|
|
|
|
import com.fr.general.Inter; |
|
|
|
|
|
|
|
|
|
|
|
import javax.swing.*; |
|
|
|
import javax.swing.*; |
|
|
|
import javax.swing.border.EmptyBorder; |
|
|
|
import javax.swing.border.EmptyBorder; |
|
|
@ -56,19 +57,19 @@ public class EastRegionContainerPane extends UIEastResizableContainer { |
|
|
|
propertyItemList = new ArrayList<>(); |
|
|
|
propertyItemList = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
|
|
// 单元格元素
|
|
|
|
// 单元格元素
|
|
|
|
PropertyItem cellElement = new PropertyItem("cellElement", "/com/fr/design/images/buttonicon/add.png"); |
|
|
|
PropertyItem cellElement = new PropertyItem("cellElement", Inter.getLocText("FR-Designer_Cell_Element"), "/com/fr/design/images/buttonicon/add.png"); |
|
|
|
// 单元格属性
|
|
|
|
// 单元格属性
|
|
|
|
PropertyItem cellAttr = new PropertyItem("cellAttr", "com/fr/design/images/toolbarbtn/close.png"); |
|
|
|
PropertyItem cellAttr = new PropertyItem("cellAttr", Inter.getLocText("FR-Designer_Cell_Attributes"), "com/fr/design/images/toolbarbtn/close.png"); |
|
|
|
// 悬浮元素
|
|
|
|
// 悬浮元素
|
|
|
|
PropertyItem floatElement = new PropertyItem("floatElement", "com/fr/design/images/toolbarbtn/close.png"); |
|
|
|
PropertyItem floatElement = new PropertyItem("floatElement", Inter.getLocText("FR-Designer_Float_Element"), "com/fr/design/images/toolbarbtn/close.png"); |
|
|
|
// 控件设置
|
|
|
|
// 控件设置
|
|
|
|
PropertyItem widgetSettings = new PropertyItem("widgetSettings", "com/fr/design/images/toolbarbtn/close.png"); |
|
|
|
PropertyItem widgetSettings = new PropertyItem("widgetSettings", Inter.getLocText("FR-Designer-Widget_Settings"), "com/fr/design/images/toolbarbtn/close.png"); |
|
|
|
// 条件属性
|
|
|
|
// 条件属性
|
|
|
|
PropertyItem conditionAttr = new PropertyItem("conditionAttr", "com/fr/design/images/toolbarbtn/close.png"); |
|
|
|
PropertyItem conditionAttr = new PropertyItem("conditionAttr", Inter.getLocText("FR-Designer_Condition_Attributes"), "com/fr/design/images/toolbarbtn/close.png"); |
|
|
|
// 超级链接
|
|
|
|
// 超级链接
|
|
|
|
PropertyItem hyperlink = new PropertyItem("hyperlink", "com/fr/design/images/toolbarbtn/close.png"); |
|
|
|
PropertyItem hyperlink = new PropertyItem("hyperlink", Inter.getLocText("FR-Designer_Hyperlink"), "com/fr/design/images/toolbarbtn/close.png"); |
|
|
|
// 组件库
|
|
|
|
// 组件库
|
|
|
|
PropertyItem widgetLib = new PropertyItem("widgetLib", "com/fr/design/images/toolbarbtn/close.png"); |
|
|
|
PropertyItem widgetLib = new PropertyItem("widgetLib", Inter.getLocText("FR-Designer_Widget_Library"), "com/fr/design/images/toolbarbtn/close.png"); |
|
|
|
propertyItemList.add(cellElement); |
|
|
|
propertyItemList.add(cellElement); |
|
|
|
propertyItemList.add(cellAttr); |
|
|
|
propertyItemList.add(cellAttr); |
|
|
|
propertyItemList.add(floatElement); |
|
|
|
propertyItemList.add(floatElement); |
|
|
@ -78,6 +79,15 @@ public class EastRegionContainerPane extends UIEastResizableContainer { |
|
|
|
propertyItemList.add(widgetLib); |
|
|
|
propertyItemList.add(widgetLib); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// "无可用配置项"面板
|
|
|
|
|
|
|
|
private JPanel getDefaultPane() { |
|
|
|
|
|
|
|
JPanel defaultPane = new JPanel(); |
|
|
|
|
|
|
|
UILabel label = new UILabel(Inter.getLocText("FR-Designer_No_Settings_Available")); |
|
|
|
|
|
|
|
defaultPane.setLayout(new BorderLayout()); |
|
|
|
|
|
|
|
defaultPane.add(label, BorderLayout.CENTER); |
|
|
|
|
|
|
|
return defaultPane; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void initContentPane() { |
|
|
|
private void initContentPane() { |
|
|
|
initRightPane(); |
|
|
|
initRightPane(); |
|
|
|
initLeftPane(); |
|
|
|
initLeftPane(); |
|
|
@ -90,8 +100,12 @@ public class EastRegionContainerPane extends UIEastResizableContainer { |
|
|
|
rightPane.setBackground(Color.green); |
|
|
|
rightPane.setBackground(Color.green); |
|
|
|
rightPane.setLayout(propertyCard); |
|
|
|
rightPane.setLayout(propertyCard); |
|
|
|
for (PropertyItem item : propertyItemList) { |
|
|
|
for (PropertyItem item : propertyItemList) { |
|
|
|
|
|
|
|
if (item.isPoppedOut()) { |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
} |
|
|
|
rightPane.add(item.getName(), item.getPropertyPanel()); |
|
|
|
rightPane.add(item.getName(), item.getPropertyPanel()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
rightPane.add(getDefaultPane()); |
|
|
|
|
|
|
|
|
|
|
|
replaceRightPane(rightPane); |
|
|
|
replaceRightPane(rightPane); |
|
|
|
} |
|
|
|
} |
|
|
@ -101,6 +115,9 @@ public class EastRegionContainerPane extends UIEastResizableContainer { |
|
|
|
leftPane = new JPanel(); |
|
|
|
leftPane = new JPanel(); |
|
|
|
leftPane.setLayout(new VerticalFlowLayout(VerticalFlowLayout.TOP, 0, 0)); |
|
|
|
leftPane.setLayout(new VerticalFlowLayout(VerticalFlowLayout.TOP, 0, 0)); |
|
|
|
for (PropertyItem item : propertyItemList) { |
|
|
|
for (PropertyItem item : propertyItemList) { |
|
|
|
|
|
|
|
if (item.isPoppedOut()) { |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
} |
|
|
|
leftPane.add(item.getButton()); |
|
|
|
leftPane.add(item.getButton()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -155,6 +172,8 @@ public class EastRegionContainerPane extends UIEastResizableContainer { |
|
|
|
|
|
|
|
|
|
|
|
public static void main(String[] args){ |
|
|
|
public static void main(String[] args){ |
|
|
|
JFrame jf = new JFrame("test"); |
|
|
|
JFrame jf = new JFrame("test"); |
|
|
|
|
|
|
|
// jf = new JFrame("test");
|
|
|
|
|
|
|
|
|
|
|
|
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
|
|
|
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
|
|
|
|
|
|
|
|
|
|
|
JPanel cc = new JPanel(); |
|
|
|
JPanel cc = new JPanel(); |
|
|
@ -218,18 +237,21 @@ public class EastRegionContainerPane extends UIEastResizableContainer { |
|
|
|
class PropertyItem { |
|
|
|
class PropertyItem { |
|
|
|
// private UIButton button;
|
|
|
|
// private UIButton button;
|
|
|
|
private UIButton button; |
|
|
|
private UIButton button; |
|
|
|
private String name; |
|
|
|
private String name; // 用于 card 切换
|
|
|
|
|
|
|
|
private String title; // 用于显示
|
|
|
|
private JComponent propertyPanel; |
|
|
|
private JComponent propertyPanel; |
|
|
|
private JComponent contentPane; |
|
|
|
private JComponent contentPane; |
|
|
|
private FixedPopupPane popupPane; // 左侧固定弹出框
|
|
|
|
private FixedPopupPane popupPane; // 左侧固定弹出框
|
|
|
|
private PopupToolPane popupToolPane; // 弹出工具条
|
|
|
|
private PopupToolPane popupToolPane; // 弹出工具条
|
|
|
|
|
|
|
|
private PopupDialog popupDialog; // 弹出框
|
|
|
|
private int x, y; // 弹出框的坐标
|
|
|
|
private int x, y; // 弹出框的坐标
|
|
|
|
private int height; // 弹出框的高度
|
|
|
|
private int height; // 弹出框的高度
|
|
|
|
private boolean isPoppedOut = false; // 是否弹出
|
|
|
|
private boolean isPoppedOut = false; // 是否弹出
|
|
|
|
private Dimension fixedSize; |
|
|
|
private Dimension fixedSize; |
|
|
|
|
|
|
|
|
|
|
|
public PropertyItem(String name, String btnUrl) { |
|
|
|
public PropertyItem(String name, String title, String btnUrl) { |
|
|
|
this.name = name; |
|
|
|
this.name = name; |
|
|
|
|
|
|
|
this.title = title; |
|
|
|
initButton(btnUrl); |
|
|
|
initButton(btnUrl); |
|
|
|
initPropertyPanel(); |
|
|
|
initPropertyPanel(); |
|
|
|
} |
|
|
|
} |
|
|
@ -243,7 +265,7 @@ public class EastRegionContainerPane extends UIEastResizableContainer { |
|
|
|
propertyPanel = new JPanel(); |
|
|
|
propertyPanel = new JPanel(); |
|
|
|
propertyPanel.setBackground(Color.pink); |
|
|
|
propertyPanel.setBackground(Color.pink); |
|
|
|
contentPane = generateContentPane(); |
|
|
|
contentPane = generateContentPane(); |
|
|
|
popupToolPane = new PopupToolPane(this, PopupToolPane.UP_BUTTON); |
|
|
|
popupToolPane = new PopupToolPane(this, PopupToolPane.DOWN_BUTTON); |
|
|
|
propertyPanel.setLayout(new BorderLayout()); |
|
|
|
propertyPanel.setLayout(new BorderLayout()); |
|
|
|
propertyPanel.add(popupToolPane, BorderLayout.NORTH); |
|
|
|
propertyPanel.add(popupToolPane, BorderLayout.NORTH); |
|
|
|
propertyPanel.add(contentPane, BorderLayout.CENTER); |
|
|
|
propertyPanel.add(contentPane, BorderLayout.CENTER); |
|
|
@ -253,6 +275,10 @@ public class EastRegionContainerPane extends UIEastResizableContainer { |
|
|
|
this.isPoppedOut = isPoppedOut; |
|
|
|
this.isPoppedOut = isPoppedOut; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public boolean isPoppedOut() { |
|
|
|
|
|
|
|
return isPoppedOut; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public JComponent generateContentPane() { |
|
|
|
public JComponent generateContentPane() { |
|
|
|
JComponent contentPane = new JPanel(); |
|
|
|
JComponent contentPane = new JPanel(); |
|
|
|
JButton testBtn = new JButton(name); |
|
|
|
JButton testBtn = new JButton(name); |
|
|
@ -269,6 +295,13 @@ public class EastRegionContainerPane extends UIEastResizableContainer { |
|
|
|
public void replaceContentPane(JComponent pane) { |
|
|
|
public void replaceContentPane(JComponent pane) { |
|
|
|
propertyPanel.remove(this.contentPane); |
|
|
|
propertyPanel.remove(this.contentPane); |
|
|
|
propertyPanel.add(this.contentPane = pane); |
|
|
|
propertyPanel.add(this.contentPane = pane); |
|
|
|
|
|
|
|
if (popupDialog != null && isPoppedOut) { |
|
|
|
|
|
|
|
popupDialog.replaceContentPane(contentPane); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (popupPane != null && !isRightPaneVisible()) { |
|
|
|
|
|
|
|
popupPane.replaceContentPane(contentPane); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
refreshContainer(); |
|
|
|
refreshContainer(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -317,25 +350,70 @@ public class EastRegionContainerPane extends UIEastResizableContainer { |
|
|
|
return name; |
|
|
|
return name; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public String getTitle() { |
|
|
|
|
|
|
|
return title; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public JComponent getPropertyPanel() { |
|
|
|
public JComponent getPropertyPanel() { |
|
|
|
return propertyPanel; |
|
|
|
return propertyPanel; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 弹出对话框
|
|
|
|
// 固定弹窗
|
|
|
|
public void popupFixedPane() { |
|
|
|
public void popupFixedPane() { |
|
|
|
if (popupPane == null) { |
|
|
|
if (popupPane == null) { |
|
|
|
popupPane = new FixedPopupPane(contentPane); |
|
|
|
popupPane = new FixedPopupPane(this); |
|
|
|
} |
|
|
|
} |
|
|
|
GUICoreUtils.showPopupMenu(popupPane, button, -popupPane.getPreferredSize().width, 0); |
|
|
|
GUICoreUtils.showPopupMenu(popupPane, button, -popupPane.getPreferredSize().width, 0); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 弹出对话框
|
|
|
|
|
|
|
|
public void popupDialog() { |
|
|
|
|
|
|
|
// setIsPoppedOut(true);
|
|
|
|
|
|
|
|
if (isPoppedOut) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
isPoppedOut = true; |
|
|
|
|
|
|
|
if (popupDialog == null) { |
|
|
|
|
|
|
|
popupDialog = new PopupDialog(this); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
popupDialog.replaceContentPane(contentPane); |
|
|
|
|
|
|
|
popupDialog.setVisible(true); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// initContentPane();
|
|
|
|
|
|
|
|
// refreshContainer();
|
|
|
|
|
|
|
|
removeItem(this); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void popToFrame() { |
|
|
|
|
|
|
|
if (isPoppedOut) { |
|
|
|
|
|
|
|
isPoppedOut = false; |
|
|
|
|
|
|
|
// popupDialog.dispose();
|
|
|
|
|
|
|
|
popupDialog.setVisible(false); |
|
|
|
|
|
|
|
initContentPane(); |
|
|
|
|
|
|
|
onResize(); |
|
|
|
|
|
|
|
refreshContainer(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private class FixedPopupPane extends JPopupMenu { |
|
|
|
private class FixedPopupPane extends JPopupMenu { |
|
|
|
private JComponent contentPane; |
|
|
|
private JComponent contentPane; |
|
|
|
FixedPopupPane(JComponent contentPane) { |
|
|
|
// private PopupToolPane popupToolPane;
|
|
|
|
this.contentPane = contentPane; |
|
|
|
private int fixedHeight; |
|
|
|
this.add(contentPane); |
|
|
|
FixedPopupPane(PropertyItem propertyItem) { |
|
|
|
this.setPreferredSize(new Dimension(CONTAINER_WIDTH - TAB_WIDTH, getPreferredSize().height)); |
|
|
|
contentPane = propertyItem.getContentPane(); |
|
|
|
|
|
|
|
this.setLayout(new BorderLayout()); |
|
|
|
|
|
|
|
// popupToolPane = ;
|
|
|
|
|
|
|
|
this.add(new PopupToolPane(propertyItem), BorderLayout.NORTH); |
|
|
|
|
|
|
|
this.add(contentPane, BorderLayout.CENTER); |
|
|
|
|
|
|
|
this.setOpaque(false); |
|
|
|
|
|
|
|
fixedHeight = getPreferredSize().height - contentPane.getPreferredSize().height; |
|
|
|
|
|
|
|
updateSize(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void updateSize() { |
|
|
|
|
|
|
|
int newHeight = fixedHeight + contentPane.getPreferredSize().height; |
|
|
|
|
|
|
|
this.setPreferredSize(new Dimension(CONTAINER_WIDTH - TAB_WIDTH, newHeight)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public JComponent getContentPane() { |
|
|
|
public JComponent getContentPane() { |
|
|
@ -346,6 +424,7 @@ public class EastRegionContainerPane extends UIEastResizableContainer { |
|
|
|
// remove(pane);
|
|
|
|
// remove(pane);
|
|
|
|
this.remove(this.contentPane); |
|
|
|
this.remove(this.contentPane); |
|
|
|
this.add(this.contentPane = pane); |
|
|
|
this.add(this.contentPane = pane); |
|
|
|
|
|
|
|
updateSize(); |
|
|
|
refreshContainer(); |
|
|
|
refreshContainer(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -359,16 +438,16 @@ public class EastRegionContainerPane extends UIEastResizableContainer { |
|
|
|
// 弹出属性面板的工具条
|
|
|
|
// 弹出属性面板的工具条
|
|
|
|
private class PopupToolPane extends JPanel { |
|
|
|
private class PopupToolPane extends JPanel { |
|
|
|
private int model = UIConstants.MODEL_NORMAL; |
|
|
|
private int model = UIConstants.MODEL_NORMAL; |
|
|
|
private String title = "单元格元素"; |
|
|
|
private String title; |
|
|
|
private JComponent contentPane; |
|
|
|
private JComponent contentPane; |
|
|
|
private PropertyItem propertyItem; |
|
|
|
private PropertyItem propertyItem; |
|
|
|
private String buttonType; |
|
|
|
private String buttonType; |
|
|
|
private JDialog parentDialog; // 如果不在对话框中,值为null
|
|
|
|
private JDialog parentDialog; // 如果不在对话框中,值为null
|
|
|
|
|
|
|
|
private Color originColor; // 初始背景
|
|
|
|
private boolean isMovable = false; |
|
|
|
private boolean isMovable = false; |
|
|
|
private Point mouseDownCompCoords; // 存储按下左键的位置,移动对话框时会用到
|
|
|
|
private Point mouseDownCompCoords; // 存储按下左键的位置,移动对话框时会用到
|
|
|
|
|
|
|
|
|
|
|
|
private static final int MIN_X = -150; |
|
|
|
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_X_SHIFT = 50; |
|
|
|
private static final int MAX_Y_SHIFT = 50; |
|
|
|
private static final int MAX_Y_SHIFT = 50; |
|
|
|
|
|
|
|
|
|
|
@ -384,7 +463,9 @@ public class EastRegionContainerPane extends UIEastResizableContainer { |
|
|
|
public PopupToolPane(PropertyItem propertyItem, String buttonType) { |
|
|
|
public PopupToolPane(PropertyItem propertyItem, String buttonType) { |
|
|
|
super(); |
|
|
|
super(); |
|
|
|
this.propertyItem = propertyItem; |
|
|
|
this.propertyItem = propertyItem; |
|
|
|
|
|
|
|
this.title = propertyItem.getTitle(); |
|
|
|
this.contentPane = propertyItem.getContentPane(); |
|
|
|
this.contentPane = propertyItem.getContentPane(); |
|
|
|
|
|
|
|
originColor = getBackground(); |
|
|
|
setLayout(new BorderLayout()); |
|
|
|
setLayout(new BorderLayout()); |
|
|
|
UILabel label = new UILabel(title); |
|
|
|
UILabel label = new UILabel(title); |
|
|
|
label.setForeground(new Color(69, 135, 255)); |
|
|
|
label.setForeground(new Color(69, 135, 255)); |
|
|
@ -405,9 +486,9 @@ public class EastRegionContainerPane extends UIEastResizableContainer { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (buttonType.equals(UP_BUTTON)) { |
|
|
|
if (buttonType.equals(DOWN_BUTTON)) { |
|
|
|
|
|
|
|
|
|
|
|
} else if (buttonType.equals(DOWN_BUTTON)) { |
|
|
|
} else if (buttonType.equals(UP_BUTTON)) { |
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
throw new IllegalArgumentException("unknown button type: " + buttonType); |
|
|
|
throw new IllegalArgumentException("unknown button type: " + buttonType); |
|
|
@ -419,6 +500,9 @@ public class EastRegionContainerPane extends UIEastResizableContainer { |
|
|
|
if (e.getX() >= ARROW_RANGE_START) { |
|
|
|
if (e.getX() >= ARROW_RANGE_START) { |
|
|
|
setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
|
|
|
setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
|
|
|
model = UIConstants.MODEL_PRESS; |
|
|
|
model = UIConstants.MODEL_PRESS; |
|
|
|
|
|
|
|
} else if (isMovable) { |
|
|
|
|
|
|
|
setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR)); |
|
|
|
|
|
|
|
setBackground(Color.pink); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
setCursor(Cursor.getDefaultCursor()); |
|
|
|
setCursor(Cursor.getDefaultCursor()); |
|
|
|
model = UIConstants.MODEL_NORMAL; |
|
|
|
model = UIConstants.MODEL_NORMAL; |
|
|
@ -457,6 +541,9 @@ public class EastRegionContainerPane extends UIEastResizableContainer { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void mouseExited(MouseEvent e) { |
|
|
|
public void mouseExited(MouseEvent e) { |
|
|
|
setCursor(Cursor.getDefaultCursor()); |
|
|
|
setCursor(Cursor.getDefaultCursor()); |
|
|
|
|
|
|
|
if (mouseDownCompCoords == null) { |
|
|
|
|
|
|
|
setBackground(originColor); |
|
|
|
|
|
|
|
} |
|
|
|
model = UIConstants.MODEL_NORMAL; |
|
|
|
model = UIConstants.MODEL_NORMAL; |
|
|
|
repaint(); |
|
|
|
repaint(); |
|
|
|
} |
|
|
|
} |
|
|
@ -471,6 +558,9 @@ public class EastRegionContainerPane extends UIEastResizableContainer { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void mouseReleased(MouseEvent e) { |
|
|
|
public void mouseReleased(MouseEvent e) { |
|
|
|
mouseDownCompCoords = null; |
|
|
|
mouseDownCompCoords = null; |
|
|
|
|
|
|
|
if (!getBounds().contains(e.getPoint())) { |
|
|
|
|
|
|
|
setBackground(originColor); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void mousePressed(MouseEvent e) { |
|
|
|
public void mousePressed(MouseEvent e) { |
|
|
@ -484,29 +574,13 @@ public class EastRegionContainerPane extends UIEastResizableContainer { |
|
|
|
|
|
|
|
|
|
|
|
// 触发弹入、弹出
|
|
|
|
// 触发弹入、弹出
|
|
|
|
private void onPop() { |
|
|
|
private void onPop() { |
|
|
|
if (buttonType.equals(UP_BUTTON)) { |
|
|
|
if (buttonType.equals(DOWN_BUTTON)) { |
|
|
|
popUpDialog(); |
|
|
|
propertyItem.popupDialog(); |
|
|
|
} else if (buttonType.equals(DOWN_BUTTON)) { |
|
|
|
} else if (buttonType.equals(UP_BUTTON)) { |
|
|
|
popToFrame(); |
|
|
|
propertyItem.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 |
|
|
|
@Override |
|
|
|
public Dimension getPreferredSize() { |
|
|
|
public Dimension getPreferredSize() { |
|
|
|
return new Dimension(super.getPreferredSize().width, POPUP_TOOLPANE_HEIGHT); |
|
|
|
return new Dimension(super.getPreferredSize().width, POPUP_TOOLPANE_HEIGHT); |
|
|
@ -524,7 +598,7 @@ public class EastRegionContainerPane extends UIEastResizableContainer { |
|
|
|
if (buttonType.equals(NO_BUTTON)) { |
|
|
|
if (buttonType.equals(NO_BUTTON)) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
if (buttonType.equals(UP_BUTTON)) { |
|
|
|
if (buttonType.equals(DOWN_BUTTON)) { |
|
|
|
if (model == UIConstants.MODEL_NORMAL) { |
|
|
|
if (model == UIConstants.MODEL_NORMAL) { |
|
|
|
button = UIConstants.DRAG_LEFT_NORMAL; |
|
|
|
button = UIConstants.DRAG_LEFT_NORMAL; |
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -544,26 +618,92 @@ public class EastRegionContainerPane extends UIEastResizableContainer { |
|
|
|
|
|
|
|
|
|
|
|
private class PopupDialog extends JDialog { |
|
|
|
private class PopupDialog extends JDialog { |
|
|
|
private Container container; |
|
|
|
private Container container; |
|
|
|
|
|
|
|
private static final int RESIZE_RANGE = 4; |
|
|
|
|
|
|
|
private Cursor originCursor; |
|
|
|
|
|
|
|
private Cursor southResizeCursor = Cursor.getPredefinedCursor(Cursor.S_RESIZE_CURSOR); |
|
|
|
|
|
|
|
private Point mouseDownCompCoords; |
|
|
|
|
|
|
|
private int minHeight; // 对话框最小高度
|
|
|
|
|
|
|
|
private JComponent contentPane; |
|
|
|
public PopupDialog(PropertyItem propertyItem) { |
|
|
|
public PopupDialog(PropertyItem propertyItem) { |
|
|
|
|
|
|
|
super(DesignerContext.getDesignerFrame()); |
|
|
|
container = getContentPane(); |
|
|
|
container = getContentPane(); |
|
|
|
setUndecorated(true); |
|
|
|
setUndecorated(true); |
|
|
|
// JPanel pane = new JPanel();
|
|
|
|
PopupToolPane popupToolPane = new PopupToolPane(propertyItem, PopupToolPane.UP_BUTTON); |
|
|
|
// 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); |
|
|
|
popupToolPane.setParentDialog(this); |
|
|
|
JComponent contentPane = propertyItem.getContentPane(); |
|
|
|
contentPane = propertyItem.getContentPane(); |
|
|
|
container.add(popupToolPane, BorderLayout.NORTH); |
|
|
|
container.add(popupToolPane, BorderLayout.NORTH); |
|
|
|
container.add(contentPane, BorderLayout.CENTER); |
|
|
|
container.add(contentPane, BorderLayout.CENTER); |
|
|
|
setSize(CONTENT_WIDTH, container.getPreferredSize().height); |
|
|
|
minHeight = container.getPreferredSize().height; |
|
|
|
|
|
|
|
setSize(CONTENT_WIDTH, minHeight); |
|
|
|
validate(); |
|
|
|
// validate();
|
|
|
|
Point btnCoords = propertyItem.getButton().getLocationOnScreen(); |
|
|
|
Point btnCoords = propertyItem.getButton().getLocationOnScreen(); |
|
|
|
this.setLocation(btnCoords.x - CONTENT_WIDTH, btnCoords.y); |
|
|
|
this.setLocation(btnCoords.x - CONTENT_WIDTH, btnCoords.y); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
initListener(); |
|
|
|
this.setVisible(true); |
|
|
|
this.setVisible(true); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public void replaceContentPane(JComponent contentPane) { |
|
|
|
|
|
|
|
container.remove(this.contentPane); |
|
|
|
|
|
|
|
container.add(this.contentPane = contentPane); |
|
|
|
|
|
|
|
// pack();
|
|
|
|
|
|
|
|
if (getSize().height < container.getPreferredSize().height) { |
|
|
|
|
|
|
|
setSize(CONTENT_WIDTH, container.getPreferredSize().height); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
refreshContainer(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void refreshContainer() { |
|
|
|
|
|
|
|
validate(); |
|
|
|
|
|
|
|
repaint(); |
|
|
|
|
|
|
|
revalidate(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void initListener() { |
|
|
|
|
|
|
|
addMouseMotionListener(new MouseMotionListener() { |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void mouseDragged(MouseEvent e) { |
|
|
|
|
|
|
|
if (mouseDownCompCoords != null) { |
|
|
|
|
|
|
|
Rectangle bounds = getBounds(); |
|
|
|
|
|
|
|
Point currCoords = e.getLocationOnScreen(); |
|
|
|
|
|
|
|
bounds.height = currCoords.y - mouseDownCompCoords.y + bounds.height; |
|
|
|
|
|
|
|
// 校正位置
|
|
|
|
|
|
|
|
if (bounds.height < minHeight) { |
|
|
|
|
|
|
|
bounds.height = minHeight; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
mouseDownCompCoords.y = currCoords.y; |
|
|
|
|
|
|
|
setBounds(bounds); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void mouseMoved(MouseEvent e) { |
|
|
|
|
|
|
|
if (originCursor == null) { // 记录最初的光标
|
|
|
|
|
|
|
|
originCursor = getCursor(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (e.getY() > getHeight() - RESIZE_RANGE) { |
|
|
|
|
|
|
|
setCursor(southResizeCursor); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
// 还原
|
|
|
|
|
|
|
|
if (mouseDownCompCoords == null && getCursor().equals(southResizeCursor)) { |
|
|
|
|
|
|
|
setCursor(originCursor); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
repaint(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
addMouseListener(new MouseAdapter() { |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void mousePressed(MouseEvent e) { |
|
|
|
|
|
|
|
if (getCursor().equals(southResizeCursor)) { |
|
|
|
|
|
|
|
mouseDownCompCoords = e.getLocationOnScreen(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void mouseReleased(MouseEvent e) { |
|
|
|
|
|
|
|
mouseDownCompCoords = null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |