Browse Source

REPORT-3163 合作开发9.0设计器=>新列表面板=》修复二次弹窗的bug

master
plough 8 years ago
parent
commit
1a47a1fc77
  1. 67
      designer_base/src/com/fr/design/gui/controlpane/UIControlPane.java
  2. 10
      designer_base/src/com/fr/design/gui/controlpane/UIListControlPane.java
  3. 2
      designer_base/src/com/fr/design/gui/controlpane/UINameableListCellRenderer.java
  4. 39
      designer_base/src/com/fr/design/mainframe/EastRegionContainerPane.java

67
designer_base/src/com/fr/design/gui/controlpane/UIControlPane.java

@ -6,16 +6,15 @@ import com.fr.design.gui.itoolbar.UIToolbar;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper; import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.EastRegionContainerPane; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.menu.ShortCut; import com.fr.design.menu.ShortCut;
import com.fr.design.menu.ToolBarDef; import com.fr.design.menu.ToolBarDef;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.Inter;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
import com.fr.stable.Nameable; import com.fr.stable.Nameable;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
import java.awt.event.*;
/** /**
* Created by plough on 2017/7/21. * Created by plough on 2017/7/21.
@ -29,7 +28,7 @@ public abstract class UIControlPane extends BasicPane implements UnrepeatedNameH
private ToolBarDef toolbarDef; private ToolBarDef toolbarDef;
private UIToolbar toolBar; private UIToolbar toolBar;
protected PopupEditPane popupEditPane; protected PopupEditDialog popupEditDialog;
// peter:这是整体的一个cardLayout Pane // peter:这是整体的一个cardLayout Pane
protected CardLayout cardLayout; protected CardLayout cardLayout;
@ -103,7 +102,7 @@ public abstract class UIControlPane extends BasicPane implements UnrepeatedNameH
UILabel selectLabel = new UILabel(); UILabel selectLabel = new UILabel();
cardPane.add(selectLabel, "SELECT"); cardPane.add(selectLabel, "SELECT");
cardPane.add(controlUpdatePane, "EDIT"); cardPane.add(controlUpdatePane, "EDIT");
popupEditPane = new PopupEditPane(cardPane); popupEditDialog = new PopupEditDialog(cardPane);
// SplitPane // SplitPane
// JSplitPane mainSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, getLeftPane(), cardPane); // JSplitPane mainSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, getLeftPane(), cardPane);
// mainSplitPane.setBorder(BorderFactory.createLineBorder(GUICoreUtils.getTitleLineBorderColor())); // mainSplitPane.setBorder(BorderFactory.createLineBorder(GUICoreUtils.getTitleLineBorderColor()));
@ -185,7 +184,6 @@ public abstract class UIControlPane extends BasicPane implements UnrepeatedNameH
protected ShortCut4JControlPane[] createShortcuts() { protected ShortCut4JControlPane[] createShortcuts() {
return new ShortCut4JControlPane[]{ return new ShortCut4JControlPane[]{
// addItemShortCut(),
copyItemShortCut(), copyItemShortCut(),
moveUpItemShortCut(), moveUpItemShortCut(),
moveDownItemShortCut(), moveDownItemShortCut(),
@ -250,44 +248,39 @@ public abstract class UIControlPane extends BasicPane implements UnrepeatedNameH
} }
// 点击"编辑"按钮,弹出面板 // 点击"编辑"按钮,弹出面板
protected class PopupEditPane extends JPopupMenu { protected class PopupEditDialog extends JDialog {
private JComponent contentPane; private JComponent editPane;
private static final int WIDTH = 460; private static final int WIDTH = 460;
private static final int HEIGHT = 500; private static final int HEIGHT = 500;
// private PopupToolPane popupToolPane;
// private int fixedHeight;
PopupEditPane(JComponent pane) {
contentPane = pane;
this.setLayout(new BorderLayout());
this.add(contentPane, BorderLayout.CENTER);
this.setOpaque(false);
contentPane.setPreferredSize(new Dimension(WIDTH, 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() { PopupEditDialog(JComponent pane) {
return contentPane; super(DesignerContext.getDesignerFrame());
setUndecorated(true);
this.editPane = pane;
this.getContentPane().add(editPane, BorderLayout.CENTER);
setSize(WIDTH, HEIGHT);
this.setVisible(false);
initListener();
} }
public void replaceContentPane(JComponent pane) { private void hideDialog() {
// remove(pane); // 检查是否有子弹窗,如果有,则不隐藏
this.remove(this.contentPane); for (Window window : getOwnedWindows()) {
this.add(this.contentPane = pane); if (window.isVisible()) {
// updateSize(); return;
refreshContainer(); }
}
setVisible(false);
} }
private void refreshContainer() { private void initListener() {
validate(); addWindowFocusListener(new WindowAdapter() {
repaint(); @Override
revalidate(); public void windowLostFocus(WindowEvent e) {
super.windowLostFocus(e);
hideDialog();
}
});
} }
} }
} }

10
designer_base/src/com/fr/design/gui/controlpane/UIListControlPane.java

@ -26,10 +26,8 @@ import com.fr.general.Inter;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
import com.fr.stable.Nameable; import com.fr.stable.Nameable;
import com.fr.stable.core.PropertyChangeAdapter; import com.fr.stable.core.PropertyChangeAdapter;
import sun.swing.DefaultLookup;
import javax.swing.*; import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener; import javax.swing.event.ListSelectionListener;
import java.awt.*; import java.awt.*;
@ -359,11 +357,13 @@ public abstract class UIListControlPane extends UIControlPane {
} }
private void popupEditPane(Point mousePos) { private void popupEditPane(Point mousePos) {
if (editingIndex < 0 || !nameableList.getCellBounds(editingIndex, editingIndex).contains(mousePos)) { Rectangle currentCellBounds = nameableList.getCellBounds(editingIndex, editingIndex);
if (editingIndex < 0 || !currentCellBounds.contains(mousePos)) {
return; return;
} }
GUICoreUtils.showPopupMenu(popupEditPane, this, Point listPos = nameableList.getLocationOnScreen();
- popupEditPane.getPreferredSize().width, editingIndex * EDIT_RANGE); popupEditDialog.setLocation(listPos.x - popupEditDialog.getSize().width, listPos.y + editingIndex * EDIT_RANGE);
popupEditDialog.setVisible(true);
} }
/** /**

2
designer_base/src/com/fr/design/gui/controlpane/UINameableListCellRenderer.java

@ -54,7 +54,7 @@ public class UINameableListCellRenderer extends
// editButton.addActionListener(new ActionListener() { // editButton.addActionListener(new ActionListener() {
// @Override // @Override
// public void actionPerformed(ActionEvent e) { // public void actionPerformed(ActionEvent e) {
// popupEditPane(); // popupEditDialog();
// } // }
// }); // });
label = new UILabel(); label = new UILabel();

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

@ -27,6 +27,7 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
private CardLayout propertyCard; private CardLayout propertyCard;
private JPanel leftPane; private JPanel leftPane;
private JPanel rightPane; private JPanel rightPane;
private FixedPopupPane currentPopupPane;
private static final int CONTAINER_WIDTH = 260; private static final int CONTAINER_WIDTH = 260;
private static final int TAB_WIDTH = 40; private static final int TAB_WIDTH = 40;
private static final int CONTENT_WIDTH = CONTAINER_WIDTH - TAB_WIDTH; private static final int CONTENT_WIDTH = CONTAINER_WIDTH - TAB_WIDTH;
@ -381,6 +382,12 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
return 0; return 0;
} }
private void hideCurrentPopupPane() {
if (currentPopupPane != null && currentPopupPane.isVisible()) {
currentPopupPane.setVisible(false);
}
}
class PropertyItem { class PropertyItem {
@ -473,7 +480,7 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
propertyPanel.remove(this.contentPane); propertyPanel.remove(this.contentPane);
propertyPanel.add(this.contentPane = pane); propertyPanel.add(this.contentPane = pane);
if (popupDialog != null && isPoppedOut) { if (popupDialog != null && isPoppedOut) {
popupDialog.replaceContentPane(contentPane); popupDialog.replaceContentPane(this);
} }
if (popupPane != null && !isRightPaneVisible()) { if (popupPane != null && !isRightPaneVisible()) {
popupPane.replaceContentPane(contentPane); popupPane.replaceContentPane(contentPane);
@ -488,6 +495,7 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
public void onResize() { public void onResize() {
if (isRightPaneVisible()) { if (isRightPaneVisible()) {
hideCurrentPopupPane();
replaceContentPane(contentPane); replaceContentPane(contentPane);
} else if(popupPane != null) { } else if(popupPane != null) {
popupPane.replaceContentPane(contentPane); popupPane.replaceContentPane(contentPane);
@ -540,7 +548,13 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
if (popupPane == null) { if (popupPane == null) {
popupPane = new FixedPopupPane(this); popupPane = new FixedPopupPane(this);
} }
GUICoreUtils.showPopupMenu(popupPane, button, -popupPane.getPreferredSize().width, 0); if (popupPane.isVisible()) {
popupPane.setVisible(false);
} else {
hideCurrentPopupPane();
currentPopupPane = popupPane;
GUICoreUtils.showPopupMenu(popupPane, button, -popupPane.getPreferredSize().width, 0);
}
} }
// 弹出对话框 // 弹出对话框
@ -553,7 +567,8 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
if (popupDialog == null) { if (popupDialog == null) {
popupDialog = new PopupDialog(this); popupDialog = new PopupDialog(this);
} else { } else {
popupDialog.replaceContentPane(contentPane); popupDialog.replaceContentPane(this);
popupDialog.adjustLocation();
popupDialog.setVisible(true); popupDialog.setVisible(true);
} }
// initContentPane(); // initContentPane();
@ -588,6 +603,9 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
updateSize(); updateSize();
} }
public void menuSelectionChanged(boolean isIncluded) {
}
private void updateSize() { private void updateSize() {
int newHeight = fixedHeight + contentPane.getPreferredSize().height; int newHeight = fixedHeight + contentPane.getPreferredSize().height;
this.setPreferredSize(new Dimension(CONTAINER_WIDTH - TAB_WIDTH, newHeight)); this.setPreferredSize(new Dimension(CONTAINER_WIDTH - TAB_WIDTH, newHeight));
@ -795,10 +813,12 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
private Point mouseDownCompCoords; private Point mouseDownCompCoords;
private int minHeight; // 对话框最小高度 private int minHeight; // 对话框最小高度
private JComponent contentPane; private JComponent contentPane;
private PropertyItem propertyItem;
public PopupDialog(PropertyItem propertyItem) { public PopupDialog(PropertyItem propertyItem) {
super(DesignerContext.getDesignerFrame()); super(DesignerContext.getDesignerFrame());
container = getContentPane(); container = getContentPane();
setUndecorated(true); setUndecorated(true);
this.propertyItem = propertyItem;
PopupToolPane popupToolPane = new PopupToolPane(propertyItem, PopupToolPane.UP_BUTTON); PopupToolPane popupToolPane = new PopupToolPane(propertyItem, PopupToolPane.UP_BUTTON);
popupToolPane.setParentDialog(this); popupToolPane.setParentDialog(this);
contentPane = propertyItem.getContentPane(); contentPane = propertyItem.getContentPane();
@ -807,13 +827,20 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
minHeight = container.getPreferredSize().height; minHeight = container.getPreferredSize().height;
setSize(CONTENT_WIDTH, minHeight); setSize(CONTENT_WIDTH, minHeight);
// validate(); // validate();
Point btnCoords = propertyItem.getButton().getLocationOnScreen(); adjustLocation();
this.setLocation(btnCoords.x - CONTENT_WIDTH, btnCoords.y);
initListener(); initListener();
this.setVisible(true); this.setVisible(true);
} }
public void replaceContentPane(JComponent contentPane) {
public void adjustLocation() {
Point btnCoords = propertyItem.getButton().getLocationOnScreen();
this.setLocation(btnCoords.x - CONTENT_WIDTH, btnCoords.y);
}
public void replaceContentPane(PropertyItem propertyItem) {
this.propertyItem = propertyItem;
JComponent contentPane = propertyItem.getContentPane();
container.remove(this.contentPane); container.remove(this.contentPane);
container.add(this.contentPane = contentPane); container.add(this.contentPane = contentPane);
// pack(); // pack();

Loading…
Cancel
Save