Browse Source

Merge remote-tracking branch 'origin/9.0' into 9.0

master
MoMeak 7 years ago
parent
commit
e9d400ca4e
  1. 19
      designer_base/src/com/fr/design/gui/icontainer/UIEastResizableContainer.java
  2. 360
      designer_base/src/com/fr/design/mainframe/EastRegionContainerPane.java

19
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;
}
@ -224,6 +228,12 @@ public class UIEastResizableContainer extends JPanel {
revalidate();
}
/**
* 伸缩右子面板时触发此方法
*/
public void onResize() {
}
private class TopToolPane extends JPanel {
private int model = UIConstants.MODEL_NORMAL;
@ -264,6 +274,7 @@ public class UIEastResizableContainer extends JPanel {
setPreferredWidth(containerWidth);
containerWidth = leftPaneWidth;
}
onResize();
refreshContainer();
if (BaseUtils.isAuthorityEditing()) {
DesignerContext.getDesignerFrame().doResize();

360
designer_base/src/com/fr/design/mainframe/EastRegionContainerPane.java

@ -2,16 +2,18 @@ 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.utils.gui.GUICoreUtils;
import com.fr.stable.Constants;
import com.fr.general.FRFont;
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;
@ -22,7 +24,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;
/**
* 得到实例
@ -42,10 +47,9 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
super();
// setVerticalDragEnabled(false);
initPropertyItemList();
initRightPane();
initLeftPane();
initContentPane();
// super(leftPane, rightPane);
setContainerWidth(260);
setContainerWidth(CONTAINER_WIDTH);
}
private void initPropertyItemList() {
@ -74,6 +78,11 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
propertyItemList.add(widgetLib);
}
private void initContentPane() {
initRightPane();
initLeftPane();
}
// 右侧属性面板
private void initRightPane() {
rightPane = new JPanel();
@ -90,6 +99,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());
}
@ -99,6 +109,20 @@ 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) {
item.onResize();
}
}
public EastRegionContainerPane(JPanel leftPane, JPanel rightPane) {
super(leftPane, rightPane);
// setVerticalDragEnabled(false);
@ -166,6 +190,7 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
* 刷新右面板
*/
public void refreshRightPane() {
if (this.getRightPane() instanceof DockingView) {
((DockingView) this.getRightPane()).refreshDockingView();
}
@ -178,6 +203,12 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
}
}
private void refreshContainer() {
validate();
repaint();
revalidate();
}
public int getToolPaneY() {
return 0;
}
@ -186,13 +217,16 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
class PropertyItem {
// private UIButton button;
private JButton button;
private UIButton button;
private String name;
private JPanel propertyPanel;
private JComponent propertyPanel;
private JComponent contentPane;
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) {
this.name = name;
@ -208,10 +242,19 @@ 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();
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);
testBtn.addActionListener(new ActionListener() {
@Override
@ -219,14 +262,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();
@ -236,27 +276,40 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
return contentPane;
}
private void refreshContainer() {
propertyPanel.validate();
propertyPanel.repaint();
propertyPanel.revalidate();
public void onResize() {
if (isRightPaneVisible()) {
replaceContentPane(contentPane);
} else if(popupPane != null) {
popupPane.replaceContentPane(contentPane);
}
}
// private void refreshContainer() {
// propertyPanel.validate();
// propertyPanel.repaint();
// propertyPanel.revalidate();
// }
private void initButton(String btnUrl) {
button = new JButton(BaseUtils.readIcon(btnUrl));
// button = new UIButton("btnd\nssdg");
// button.set4LargeToolbarButton();
button.setPreferredSize(new Dimension(BUTTON_WIDTH, BUTTON_WIDTH));
button.setContentAreaFilled(false);
button = new UIButton(BaseUtils.readIcon(btnUrl)) {
public Dimension getPreferredSize() {
return new Dimension(TAB_WIDTH, TAB_WIDTH);
}
};
button.set4LargeToolbarButton();
button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
propertyCard.show(rightPane, name);
if (isRightPaneVisible()) {
propertyCard.show(rightPane, name);
} else {
popupFixedPane();
}
}
});
}
public JButton getButton() {
public UIButton getButton() {
return button;
}
@ -264,8 +317,253 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
return name;
}
public JPanel getPropertyPanel() {
public JComponent getPropertyPanel() {
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);
}
}
}
Loading…
Cancel
Save