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.TableLayout;
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.ToolBarDef;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.Inter;
import com.fr.stable.ArrayUtils;
import com.fr.stable.Nameable;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
/**
* Created by plough on 2017/7/21.
@ -29,7 +28,7 @@ public abstract class UIControlPane extends BasicPane implements UnrepeatedNameH
private ToolBarDef toolbarDef;
private UIToolbar toolBar;
protected PopupEditPane popupEditPane;
protected PopupEditDialog popupEditDialog;
// peter:这是整体的一个cardLayout Pane
protected CardLayout cardLayout;
@ -103,7 +102,7 @@ public abstract class UIControlPane extends BasicPane implements UnrepeatedNameH
UILabel selectLabel = new UILabel();
cardPane.add(selectLabel, "SELECT");
cardPane.add(controlUpdatePane, "EDIT");
popupEditPane = new PopupEditPane(cardPane);
popupEditDialog = new PopupEditDialog(cardPane);
// SplitPane
// JSplitPane mainSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, getLeftPane(), cardPane);
// mainSplitPane.setBorder(BorderFactory.createLineBorder(GUICoreUtils.getTitleLineBorderColor()));
@ -185,7 +184,6 @@ public abstract class UIControlPane extends BasicPane implements UnrepeatedNameH
protected ShortCut4JControlPane[] createShortcuts() {
return new ShortCut4JControlPane[]{
// addItemShortCut(),
copyItemShortCut(),
moveUpItemShortCut(),
moveDownItemShortCut(),
@ -250,44 +248,39 @@ public abstract class UIControlPane extends BasicPane implements UnrepeatedNameH
}
// 点击"编辑"按钮,弹出面板
protected class PopupEditPane extends JPopupMenu {
private JComponent contentPane;
protected class PopupEditDialog extends JDialog {
private JComponent editPane;
private static final int WIDTH = 460;
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() {
return contentPane;
PopupEditDialog(JComponent pane) {
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) {
// remove(pane);
this.remove(this.contentPane);
this.add(this.contentPane = pane);
// updateSize();
refreshContainer();
private void hideDialog() {
// 检查是否有子弹窗,如果有,则不隐藏
for (Window window : getOwnedWindows()) {
if (window.isVisible()) {
return;
}
}
setVisible(false);
}
private void refreshContainer() {
validate();
repaint();
revalidate();
private void initListener() {
addWindowFocusListener(new WindowAdapter() {
@Override
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.Nameable;
import com.fr.stable.core.PropertyChangeAdapter;
import sun.swing.DefaultLookup;
import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import java.awt.*;
@ -359,11 +357,13 @@ public abstract class UIListControlPane extends UIControlPane {
}
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;
}
GUICoreUtils.showPopupMenu(popupEditPane, this,
- popupEditPane.getPreferredSize().width, editingIndex * EDIT_RANGE);
Point listPos = nameableList.getLocationOnScreen();
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() {
// @Override
// public void actionPerformed(ActionEvent e) {
// popupEditPane();
// popupEditDialog();
// }
// });
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 JPanel leftPane;
private JPanel rightPane;
private FixedPopupPane currentPopupPane;
private static final int CONTAINER_WIDTH = 260;
private static final int TAB_WIDTH = 40;
private static final int CONTENT_WIDTH = CONTAINER_WIDTH - TAB_WIDTH;
@ -381,6 +382,12 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
return 0;
}
private void hideCurrentPopupPane() {
if (currentPopupPane != null && currentPopupPane.isVisible()) {
currentPopupPane.setVisible(false);
}
}
class PropertyItem {
@ -473,7 +480,7 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
propertyPanel.remove(this.contentPane);
propertyPanel.add(this.contentPane = pane);
if (popupDialog != null && isPoppedOut) {
popupDialog.replaceContentPane(contentPane);
popupDialog.replaceContentPane(this);
}
if (popupPane != null && !isRightPaneVisible()) {
popupPane.replaceContentPane(contentPane);
@ -488,6 +495,7 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
public void onResize() {
if (isRightPaneVisible()) {
hideCurrentPopupPane();
replaceContentPane(contentPane);
} else if(popupPane != null) {
popupPane.replaceContentPane(contentPane);
@ -540,7 +548,13 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
if (popupPane == null) {
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) {
popupDialog = new PopupDialog(this);
} else {
popupDialog.replaceContentPane(contentPane);
popupDialog.replaceContentPane(this);
popupDialog.adjustLocation();
popupDialog.setVisible(true);
}
// initContentPane();
@ -588,6 +603,9 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
updateSize();
}
public void menuSelectionChanged(boolean isIncluded) {
}
private void updateSize() {
int newHeight = fixedHeight + contentPane.getPreferredSize().height;
this.setPreferredSize(new Dimension(CONTAINER_WIDTH - TAB_WIDTH, newHeight));
@ -795,10 +813,12 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
private Point mouseDownCompCoords;
private int minHeight; // 对话框最小高度
private JComponent contentPane;
private PropertyItem propertyItem;
public PopupDialog(PropertyItem propertyItem) {
super(DesignerContext.getDesignerFrame());
container = getContentPane();
setUndecorated(true);
this.propertyItem = propertyItem;
PopupToolPane popupToolPane = new PopupToolPane(propertyItem, PopupToolPane.UP_BUTTON);
popupToolPane.setParentDialog(this);
contentPane = propertyItem.getContentPane();
@ -807,13 +827,20 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
minHeight = container.getPreferredSize().height;
setSize(CONTENT_WIDTH, minHeight);
// validate();
Point btnCoords = propertyItem.getButton().getLocationOnScreen();
this.setLocation(btnCoords.x - CONTENT_WIDTH, btnCoords.y);
adjustLocation();
initListener();
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.add(this.contentPane = contentPane);
// pack();

Loading…
Cancel
Save