Browse Source

REPORT-3163 合作开发9.0设计器=>修复弹窗bug:1、失焦后被设计器覆盖;2、弹出后,点击不同单元格,面板没有更新;3、弹出后,点击不同单元格,弹回,面板消失;4、切换面板时,内容不应被遮挡

master
plough 7 years ago
parent
commit
c5e83b3b13
  1. 102
      designer_base/src/com/fr/design/mainframe/EastRegionContainerPane.java

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

@ -9,7 +9,6 @@ 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 ij.gui.Toolbar;
import javax.swing.*; import javax.swing.*;
import javax.swing.border.EmptyBorder; import javax.swing.border.EmptyBorder;
@ -156,6 +155,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();
@ -224,6 +225,7 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
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; // 是否弹出
@ -270,6 +272,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();
} }
@ -322,23 +331,62 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
return propertyPanel; return propertyPanel;
} }
// 弹出对话框 // 固定弹窗
public void popupFixedPane() { public void popupFixedPane() {
if (popupPane == null) { if (popupPane == null) {
popupPane = new FixedPopupPane(this); 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;
// private PopupToolPane popupToolPane;
private int fixedHeight;
FixedPopupPane(PropertyItem propertyItem) { FixedPopupPane(PropertyItem propertyItem) {
contentPane = propertyItem.getContentPane(); contentPane = propertyItem.getContentPane();
this.add(new PopupToolPane(propertyItem)); this.setLayout(new BorderLayout());
this.add(contentPane); // popupToolPane = ;
this.add(new PopupToolPane(propertyItem), BorderLayout.NORTH);
this.add(contentPane, BorderLayout.CENTER);
this.setOpaque(false); this.setOpaque(false);
this.setPreferredSize(new Dimension(CONTAINER_WIDTH - TAB_WIDTH, getPreferredSize().height)); 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() {
@ -349,6 +397,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();
} }
@ -371,7 +420,6 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
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;
@ -488,28 +536,12 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
// 触发弹入、弹出 // 触发弹入、弹出
private void onPop() { private void onPop() {
if (buttonType.equals(UP_BUTTON)) { if (buttonType.equals(UP_BUTTON)) {
popUpDialog(); propertyItem.popupDialog();
} else if (buttonType.equals(DOWN_BUTTON)) { } else if (buttonType.equals(DOWN_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);
@ -552,23 +584,41 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
private Cursor southResizeCursor = Cursor.getPredefinedCursor(Cursor.S_RESIZE_CURSOR); private Cursor southResizeCursor = Cursor.getPredefinedCursor(Cursor.S_RESIZE_CURSOR);
private Point mouseDownCompCoords; private Point mouseDownCompCoords;
private int minHeight; // 对话框最小高度 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);
PopupToolPane popupToolPane = new PopupToolPane(propertyItem, PopupToolPane.DOWN_BUTTON); 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);
minHeight = container.getPreferredSize().height; minHeight = container.getPreferredSize().height;
setSize(CONTENT_WIDTH, minHeight); 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(); 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() { private void initListener() {
addMouseMotionListener(new MouseMotionListener() { addMouseMotionListener(new MouseMotionListener() {
@Override @Override

Loading…
Cancel
Save