diff --git a/designer-base/src/com/fr/design/gui/imenu/UIPopupMenu.java b/designer-base/src/com/fr/design/gui/imenu/UIPopupMenu.java index b97315827c..cdad63bff2 100644 --- a/designer-base/src/com/fr/design/gui/imenu/UIPopupMenu.java +++ b/designer-base/src/com/fr/design/gui/imenu/UIPopupMenu.java @@ -10,6 +10,7 @@ import com.fr.design.constants.UIConstants; public class UIPopupMenu extends JPopupMenu{ private static final float REC = 8f; private boolean onlyText = false; + public static UIPopupMenu EMPTY = new UIPopupMenu(); public UIPopupMenu() { super(); setBackground(UIConstants.NORMAL_BACKGROUND); diff --git a/designer-base/src/com/fr/design/mainframe/EastRegionContainerPane.java b/designer-base/src/com/fr/design/mainframe/EastRegionContainerPane.java index 309baf8a3c..d2bffafc55 100644 --- a/designer-base/src/com/fr/design/mainframe/EastRegionContainerPane.java +++ b/designer-base/src/com/fr/design/mainframe/EastRegionContainerPane.java @@ -499,7 +499,6 @@ public class EastRegionContainerPane extends UIEastResizableContainer { private boolean isEnabled = true; // 是否可用 private Set visibleModes; private Set enableModes; - private static final int MAX_PARA_HEIGHT = 240; // 完整icon路径为 ICON_BASE_DIR + btnIconName + iconSuffix private static final String ICON_BASE_DIR = "/com/fr/design/images/buttonicon/propertiestab/"; @@ -621,8 +620,6 @@ public class EastRegionContainerPane extends UIEastResizableContainer { public void replaceHeaderPane(JComponent pane) { contentArea.remove(headerPane); - int height = Math.min(pane.getPreferredSize().height, MAX_PARA_HEIGHT); - pane.setPreferredSize(new Dimension(pane.getPreferredSize().width, height)); headerPane = pane; contentArea.add(headerPane, BorderLayout.NORTH); diff --git a/designer-form/src/com/fr/design/designer/creator/XCreator.java b/designer-form/src/com/fr/design/designer/creator/XCreator.java index ed234b62ab..31aceeb910 100644 --- a/designer-form/src/com/fr/design/designer/creator/XCreator.java +++ b/designer-form/src/com/fr/design/designer/creator/XCreator.java @@ -12,16 +12,27 @@ import com.fr.design.designer.beans.models.SelectionModel; import com.fr.design.fun.WidgetPropertyUIProvider; import com.fr.design.gui.imenu.UIPopupMenu; import com.fr.design.layout.FRGUIPaneFactory; -import com.fr.design.mainframe.*; +import com.fr.design.mainframe.AuthorityPropertyPane; +import com.fr.design.mainframe.BaseJForm; +import com.fr.design.mainframe.EditingMouseListener; +import com.fr.design.mainframe.FormDesigner; +import com.fr.design.mainframe.NoSupportAuthorityEdit; +import com.fr.design.mainframe.WidgetPropertyPane; import com.fr.design.utils.gui.LayoutUtils; import com.fr.form.ui.Widget; import com.fr.form.ui.container.WTitleLayout; import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; -import javax.swing.*; +import javax.swing.BorderFactory; +import javax.swing.JComponent; +import javax.swing.JPanel; import javax.swing.border.Border; -import java.awt.*; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.Rectangle; import java.awt.event.MouseEvent; import java.beans.IntrospectionException; import java.util.ArrayList; @@ -671,9 +682,9 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo * 创建右击弹出菜单 * */ - public JPopupMenu createPopupMenu(FormDesigner formDesigner) { + public UIPopupMenu createPopupMenu(FormDesigner formDesigner) { UpdateAction[] actions = formDesigner.getActions(); - JPopupMenu popup = new UIPopupMenu(); + UIPopupMenu popup = new UIPopupMenu(); for (int i = 0; i < actions.length; i++) { if (i == SHORTS_SEPARATOR_POS) { popup.addSeparator(); diff --git a/designer-form/src/com/fr/design/designer/creator/XLayoutContainer.java b/designer-form/src/com/fr/design/designer/creator/XLayoutContainer.java index 62ae1e2155..3b4067aac5 100644 --- a/designer-form/src/com/fr/design/designer/creator/XLayoutContainer.java +++ b/designer-form/src/com/fr/design/designer/creator/XLayoutContainer.java @@ -560,4 +560,12 @@ public abstract class XLayoutContainer extends XBorderStyleWidgetCreator impleme return false; } + /** + * 内部组件是否支持叠加顺序的调整 + * return boolean + */ + public boolean supportInnerOrderChangeActions() { + return false; + } + } \ No newline at end of file diff --git a/designer-form/src/com/fr/design/designer/creator/XWAbsoluteLayout.java b/designer-form/src/com/fr/design/designer/creator/XWAbsoluteLayout.java index 6a03f48c5c..7940bfd66e 100644 --- a/designer-form/src/com/fr/design/designer/creator/XWAbsoluteLayout.java +++ b/designer-form/src/com/fr/design/designer/creator/XWAbsoluteLayout.java @@ -520,4 +520,9 @@ public class XWAbsoluteLayout extends XLayoutContainer { widget.setBounds(xCreator.getBounds()); } } + + @Override + public boolean supportInnerOrderChangeActions() { + return true; + } } \ No newline at end of file diff --git a/designer-form/src/com/fr/design/designer/creator/cardlayout/XCardAddButton.java b/designer-form/src/com/fr/design/designer/creator/cardlayout/XCardAddButton.java index a385179a83..e2c720204e 100644 --- a/designer-form/src/com/fr/design/designer/creator/cardlayout/XCardAddButton.java +++ b/designer-form/src/com/fr/design/designer/creator/cardlayout/XCardAddButton.java @@ -1,13 +1,5 @@ package com.fr.design.designer.creator.cardlayout; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.event.MouseEvent; - -import javax.swing.Icon; - import com.fr.base.BaseUtils; import com.fr.base.background.ColorBackground; import com.fr.design.designer.beans.AdapterBus; @@ -15,6 +7,7 @@ import com.fr.design.designer.beans.ComponentAdapter; import com.fr.design.designer.beans.models.SelectionModel; import com.fr.design.designer.creator.XButton; import com.fr.design.designer.creator.XLayoutContainer; +import com.fr.design.gui.imenu.UIPopupMenu; import com.fr.design.mainframe.EditingMouseListener; import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.FormHierarchyTreePane; @@ -25,6 +18,13 @@ import com.fr.form.ui.container.cardlayout.WCardTagLayout; import com.fr.general.ComparatorUtils; import com.fr.general.Inter; +import javax.swing.Icon; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.event.MouseEvent; + public class XCardAddButton extends XButton{ private XWCardTagLayout tagLayout; @@ -112,6 +112,11 @@ public class XCardAddButton extends XButton{ tagLayout.setTabsAndAdjust(); LayoutUtils.layoutRootContainer(designer.getRootComponent()); } + + @Override + public UIPopupMenu createPopupMenu(FormDesigner formDesigner) { + return UIPopupMenu.EMPTY; // 不要菜单 + } private void initRelateLayout(){ XWCardTitleLayout titleLayout = (XWCardTitleLayout)this.getBackupParent(); diff --git a/designer-form/src/com/fr/design/designer/creator/cardlayout/XCardSwitchButton.java b/designer-form/src/com/fr/design/designer/creator/cardlayout/XCardSwitchButton.java index 45a27d33ac..d37123c556 100644 --- a/designer-form/src/com/fr/design/designer/creator/cardlayout/XCardSwitchButton.java +++ b/designer-form/src/com/fr/design/designer/creator/cardlayout/XCardSwitchButton.java @@ -13,6 +13,7 @@ import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XLayoutContainer; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.imenu.UIPopupMenu; import com.fr.design.mainframe.EditingMouseListener; import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.FormHierarchyTreePane; @@ -213,6 +214,11 @@ public class XCardSwitchButton extends XButton { GUICoreUtils.showPopupMenu(jPopupMenu, editingMouseListener.getDesigner(), e.getX(), e.getY()); } + @Override + public UIPopupMenu createPopupMenu(FormDesigner formDesigner) { + return UIPopupMenu.EMPTY; // 自己有一个showPopupMenu,不需要使用通用的弹出菜单 + } + //删除card,同时修改其他switchbutton和tabfit的index private void deleteCard(XCardSwitchButton button,int index){ String titleName = button.getContentLabel().getText(); diff --git a/designer-form/src/com/fr/design/designer/creator/cardlayout/XWCardTagLayout.java b/designer-form/src/com/fr/design/designer/creator/cardlayout/XWCardTagLayout.java index 5b23f8d653..10c1f3a253 100644 --- a/designer-form/src/com/fr/design/designer/creator/cardlayout/XWCardTagLayout.java +++ b/designer-form/src/com/fr/design/designer/creator/cardlayout/XWCardTagLayout.java @@ -3,19 +3,6 @@ */ package com.fr.design.designer.creator.cardlayout; -import java.awt.Component; -import java.awt.Dimension; -import java.awt.Font; -import java.awt.FontMetrics; -import java.awt.Rectangle; -import java.awt.event.ContainerEvent; -import java.awt.event.MouseEvent; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map; - -import javax.swing.border.Border; - import com.fr.base.GraphHelper; import com.fr.base.ScreenResolution; import com.fr.design.designer.beans.AdapterBus; @@ -33,6 +20,7 @@ import com.fr.design.form.layout.FRFlowLayout; import com.fr.design.form.layout.FRHorizontalLayout; import com.fr.design.form.layout.FRVerticalLayout; import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.imenu.UIPopupMenu; import com.fr.design.mainframe.EditingMouseListener; import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.WidgetPropertyPane; @@ -45,6 +33,18 @@ import com.fr.form.ui.container.cardlayout.WTabFitLayout; import com.fr.general.ComparatorUtils; import com.fr.general.FRFont; +import javax.swing.border.Border; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.Font; +import java.awt.FontMetrics; +import java.awt.Rectangle; +import java.awt.event.ContainerEvent; +import java.awt.event.MouseEvent; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; + /** * @date: 2014-11-25-下午3:11:14 */ @@ -239,6 +239,11 @@ public class XWCardTagLayout extends XWHorizontalBoxLayout { } } + @Override + public UIPopupMenu createPopupMenu(FormDesigner formDesigner) { + return UIPopupMenu.EMPTY; // 不要菜单 + } + public int[] getDirections() { return ((XCreator)getParent()).getDirections(); } diff --git a/designer-form/src/com/fr/design/designer/creator/cardlayout/XWTabFitLayout.java b/designer-form/src/com/fr/design/designer/creator/cardlayout/XWTabFitLayout.java index 96298860c7..b93451488c 100644 --- a/designer-form/src/com/fr/design/designer/creator/cardlayout/XWTabFitLayout.java +++ b/designer-form/src/com/fr/design/designer/creator/cardlayout/XWTabFitLayout.java @@ -11,23 +11,29 @@ import com.fr.design.designer.creator.XLayoutContainer; import com.fr.design.designer.creator.XWFitLayout; import com.fr.design.form.util.XCreatorConstants; import com.fr.design.fun.WidgetPropertyUIProvider; +import com.fr.design.gui.imenu.UIPopupMenu; import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.FormHierarchyTreePane; import com.fr.design.mainframe.widget.editors.ButtonTypeEditor; import com.fr.design.mainframe.widget.editors.ImgBackgroundEditor; import com.fr.design.utils.gui.LayoutUtils; import com.fr.form.ui.CardSwitchButton; +import com.fr.form.ui.container.WAbsoluteLayout.BoundsWidget; import com.fr.form.ui.container.cardlayout.WCardTagLayout; import com.fr.form.ui.container.cardlayout.WTabFitLayout; -import com.fr.form.ui.container.WAbsoluteLayout.BoundsWidget; import com.fr.general.Background; -import com.fr.log.FineLoggerFactory; import com.fr.general.Inter; +import com.fr.log.FineLoggerFactory; import com.fr.stable.ArrayUtils; import com.fr.stable.core.PropertyChangeAdapter; import javax.swing.border.Border; -import java.awt.*; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.Font; +import java.awt.FontMetrics; +import java.awt.Rectangle; import java.beans.IntrospectionException; @@ -98,6 +104,11 @@ public class XWTabFitLayout extends XWFitLayout { super(widget, initSize); } + @Override + public UIPopupMenu createPopupMenu(FormDesigner formDesigner) { + return UIPopupMenu.EMPTY; // 不要菜单 + } + /** * 得到属性名 * @return 属性名 diff --git a/designer-form/src/com/fr/design/mainframe/EditingMouseListener.java b/designer-form/src/com/fr/design/mainframe/EditingMouseListener.java index a6dbc913cd..1f94f3fa67 100644 --- a/designer-form/src/com/fr/design/mainframe/EditingMouseListener.java +++ b/designer-form/src/com/fr/design/mainframe/EditingMouseListener.java @@ -9,11 +9,18 @@ import com.fr.design.designer.beans.location.Direction; import com.fr.design.designer.beans.location.Location; import com.fr.design.designer.beans.models.SelectionModel; import com.fr.design.designer.beans.models.StateModel; -import com.fr.design.designer.creator.*; +import com.fr.design.designer.creator.XChartEditor; +import com.fr.design.designer.creator.XCreator; +import com.fr.design.designer.creator.XCreatorUtils; +import com.fr.design.designer.creator.XEditorHolder; +import com.fr.design.designer.creator.XElementCase; +import com.fr.design.designer.creator.XLayoutContainer; +import com.fr.design.designer.creator.XWFitLayout; import com.fr.design.designer.creator.cardlayout.XCardSwitchButton; import com.fr.design.designer.creator.cardlayout.XWCardLayout; import com.fr.design.form.util.XCreatorConstants; import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.gui.imenu.UIPopupMenu; import com.fr.design.gui.xpane.ToolTipEditor; import com.fr.design.icon.IconPathConstants; import com.fr.design.utils.ComponentUtils; @@ -22,9 +29,16 @@ import com.fr.design.utils.gui.LayoutUtils; import com.fr.general.Inter; import com.fr.stable.Constants; -import javax.swing.*; +import javax.swing.BorderFactory; +import javax.swing.JComponent; +import javax.swing.JPopupMenu; +import javax.swing.JWindow; +import javax.swing.SwingUtilities; import javax.swing.event.MouseInputAdapter; -import java.awt.*; +import java.awt.Color; +import java.awt.Container; +import java.awt.Cursor; +import java.awt.Rectangle; import java.awt.event.MouseEvent; /** @@ -540,8 +554,8 @@ public class EditingMouseListener extends MouseInputAdapter { if (creator != null) { creator.respondClick(this, e); if (e.getButton() == MouseEvent.BUTTON3) { - JPopupMenu cellPopupMenu = creator.createPopupMenu(designer); - if (cellPopupMenu != null) { + UIPopupMenu cellPopupMenu = creator.createPopupMenu(designer); + if (cellPopupMenu != UIPopupMenu.EMPTY) { GUICoreUtils.showPopupMenu(cellPopupMenu, designer, e.getX(), e.getY()); } } diff --git a/designer-form/src/com/fr/design/mainframe/FormDesigner.java b/designer-form/src/com/fr/design/mainframe/FormDesigner.java index 1b659cd4d3..831bc73f80 100644 --- a/designer-form/src/com/fr/design/mainframe/FormDesigner.java +++ b/designer-form/src/com/fr/design/mainframe/FormDesigner.java @@ -1013,6 +1013,9 @@ public class FormDesigner extends TargetComponent
implements TreeSelection */ @Override public void valueChanged(TreeSelectionEvent e) { + if (DesignerContext.getDesignerFrame().getSelectedJTemplate() == null) { // 初始化完成前,不响应事件 + return; + } ComponentTree tree = (ComponentTree) e.getSource(); TreePath[] paths = tree.getSelectionPaths(); @@ -1139,8 +1142,8 @@ public class FormDesigner extends TargetComponent implements TreeSelection // 当前选中控件可以上移一层吗? public boolean isCurrentComponentMovableUp() { XCreator creator = getSelectionModel().getSelection().getSelectedCreator(); - Container container = creator.getParent(); - if (container == null) { + XLayoutContainer container = (XLayoutContainer) creator.getParent(); + if (container == null || !container.supportInnerOrderChangeActions()) { return false; } return creator.isMovable() && container.getComponentZOrder(creator) > 0; @@ -1149,8 +1152,8 @@ public class FormDesigner extends TargetComponent implements TreeSelection // 当前选中控件可以下移一层吗? public boolean isCurrentComponentMovableDown() { XCreator creator = getSelectionModel().getSelection().getSelectedCreator(); - Container container = creator.getParent(); - if (container == null) { + XLayoutContainer container = (XLayoutContainer) creator.getParent(); + if (container == null || !container.supportInnerOrderChangeActions()) { return false; } return creator.isMovable() && container.getComponentZOrder(creator) < container.getComponentCount() - 1; diff --git a/designer-form/src/com/fr/design/mainframe/FormHierarchyTreePane.java b/designer-form/src/com/fr/design/mainframe/FormHierarchyTreePane.java index a47219a28a..0a078ed8ae 100644 --- a/designer-form/src/com/fr/design/mainframe/FormHierarchyTreePane.java +++ b/designer-form/src/com/fr/design/mainframe/FormHierarchyTreePane.java @@ -13,15 +13,22 @@ import com.fr.design.gui.controlpane.ShortCut4JControlPane; import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.itoolbar.UIToolBarUI; import com.fr.design.gui.itoolbar.UIToolbar; -import com.fr.design.gui.style.BorderPane; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.menu.ShortCut; import com.fr.design.menu.ToolBarDef; import com.fr.design.parameter.HierarchyTreePane; import com.fr.general.Inter; -import javax.swing.*; -import java.awt.*; +import javax.swing.Action; +import javax.swing.BorderFactory; +import javax.swing.Icon; +import javax.swing.JComponent; +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Graphics2D; import java.util.ArrayList; @@ -96,8 +103,7 @@ public class FormHierarchyTreePane extends FormDockView implements HierarchyTree formDesigner.addDesignerEditListener(new DesignerEditListener() { @Override public void fireCreatorModified(DesignerEvent evt) { - componentTree.setAndScrollSelectionPath(componentTree.getSelectedTreePath()); - componentTree.refreshUI(); + refreshComponentTree(); } }); @@ -110,6 +116,14 @@ public class FormHierarchyTreePane extends FormDockView implements HierarchyTree } add(getWidgetPane(), BorderLayout.CENTER); + + // 这里要刷新一下,否则控件树中没有任何一个控件处于选中状态 + refreshComponentTree(); + } + + private void refreshComponentTree() { + componentTree.setAndScrollSelectionPath(componentTree.getSelectedTreePath()); + componentTree.refreshUI(); } private JPanel getWidgetPane() { diff --git a/designer-form/src/com/fr/design/parameter/ParameterPropertyPane.java b/designer-form/src/com/fr/design/parameter/ParameterPropertyPane.java index 6c0ba3ef12..cf393be8db 100644 --- a/designer-form/src/com/fr/design/parameter/ParameterPropertyPane.java +++ b/designer-form/src/com/fr/design/parameter/ParameterPropertyPane.java @@ -4,10 +4,17 @@ import com.fr.design.constants.UIConstants; import com.fr.design.designer.creator.XWParameterLayout; import com.fr.design.dialog.BasicScrollPane; import com.fr.design.gui.ibutton.UIButton; -import com.fr.design.mainframe.*; - -import javax.swing.*; -import java.awt.*; +import com.fr.design.mainframe.DesignerContext; +import com.fr.design.mainframe.FormDesigner; +import com.fr.design.mainframe.FormHierarchyTreePane; +import com.fr.design.mainframe.JForm; +import com.fr.design.mainframe.JTemplate; + +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import javax.swing.SwingUtilities; +import java.awt.BorderLayout; +import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; @@ -26,6 +33,7 @@ public class ParameterPropertyPane extends JPanel{ private static final int PADDING_SMALL = 5; private static final int PADDING_MIDDLE = 10; private static final int PADDING_LARGE = 15; + private static final int ADD_PARA_PANE_MAX_HEIGHT = 95; public static final ParameterPropertyPane getInstance() { if (THIS == null) { @@ -86,6 +94,7 @@ public class ParameterPropertyPane extends JPanel{ // 显示或隐藏添加参数面板 public void refreshState(JTemplate jt) { setAddParaPaneVisible(toolbarPane.hasSelectedLabelItem(), jt); + updateAddParaPaneSize(); } // 显示或隐藏添加参数面板 @@ -93,6 +102,16 @@ public class ParameterPropertyPane extends JPanel{ refreshState(DesignerContext.getDesignerFrame().getSelectedJTemplate()); } + private void updateAddParaPaneSize() { + if (!addParaPane.isVisible()) { + return; + } + addParaPane.setPreferredSize(null); + int height = Math.min(addParaPane.getPreferredSize().height, ADD_PARA_PANE_MAX_HEIGHT); + addParaPane.setPreferredSize(new Dimension(addParaPane.getPreferredSize().width, height)); + repaintContainer(); + } + public void setAddParaPaneVisible(boolean isVisible, JTemplate jt) { if (isVisible == addParaPane.isVisible() || formHierarchyTreePaneWrapper == null) { return; @@ -112,7 +131,6 @@ public class ParameterPropertyPane extends JPanel{ addParaPane.setVisible(false); this.setPreferredSize(new Dimension(getWidth(), formHierarchyTreePaneWrapper.getPreferredSize().height + UIConstants.GAP_NORMAL)); } - repaintContainer(); } private void setEditor(FormDesigner editor) {