From 18c5fc394181f4604cd3f202e237988f7f898f55 Mon Sep 17 00:00:00 2001 From: plough Date: Mon, 24 Jul 2017 15:08:05 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-3163=20=E5=90=88=E4=BD=9C=E5=BC=80?= =?UTF-8?q?=E5=8F=919.0=E8=AE=BE=E8=AE=A1=E5=99=A8=3D>=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E9=9D=A2=E6=9D=BF=3D=E3=80=8B=E5=AE=8C=E5=96=84UI=E7=BB=86?= =?UTF-8?q?=E8=8A=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/gui/controlpane/UIControlPane.java | 11 +++++- .../gui/controlpane/UIListControlPane.java | 24 +++++++++++- .../UINameableListCellRenderer.java | 37 ++++++++++--------- .../com/fr/design/gui/ilist/UINameEdList.java | 2 +- 4 files changed, 52 insertions(+), 22 deletions(-) diff --git a/designer_base/src/com/fr/design/gui/controlpane/UIControlPane.java b/designer_base/src/com/fr/design/gui/controlpane/UIControlPane.java index 4de5f5d86b..8878cd43a8 100644 --- a/designer_base/src/com/fr/design/gui/controlpane/UIControlPane.java +++ b/designer_base/src/com/fr/design/gui/controlpane/UIControlPane.java @@ -110,6 +110,7 @@ public abstract class UIControlPane extends BasicPane implements UnrepeatedNameH // mainSplitPane.setOneTouchExpandable(true); this.add(getLeftPane(), BorderLayout.CENTER); + this.setBorder(BorderFactory.createEmptyBorder(0, 10, 12, 10)); // mainSplitPane.setDividerLocation(getLeftPreferredSize()); this.checkButtonEnabled(); } @@ -134,14 +135,21 @@ public abstract class UIControlPane extends BasicPane implements UnrepeatedNameH toolbarDef.addShortCut(sj.getShortCut()); } toolBar = ToolBarDef.createJToolBar(); +// toolBar.setLayout(new FlowLayout(FlowLayout.LEFT)); toolbarDef.updateToolBar(toolBar); - leftContentPane.add(toolBar, BorderLayout.NORTH); + // 封装一层,加边框 + JPanel toolBarPane = new JPanel(new BorderLayout()); + toolBarPane.add(toolBar, BorderLayout.CENTER); + toolBarPane.setBorder(BorderFactory.createMatteBorder(1, 1, 0, 1, new Color(201, 198, 184))); + leftContentPane.add(toolBarPane, BorderLayout.NORTH); +// leftContentPane.setBorder(BorderFactory.createLineBorder(new Color(201, 198, 184))); // 顶部标签及add按钮 UIToolbar topToolBar = new UIToolbar(); topToolBar.setLayout(new BorderLayout()); ShortCut addItem = addItemShortCut().getShortCut(); addItem.intoJToolBar(topToolBar); + topToolBar.setBorder(BorderFactory.createEmptyBorder(2, 0, 2, 0)); double p = TableLayout.PREFERRED; double f = TableLayout.FILL; double[] columnSize = { p, f }; @@ -150,6 +158,7 @@ public abstract class UIControlPane extends BasicPane implements UnrepeatedNameH new Component[]{new UILabel("add hyperlink "), topToolBar}, }; JPanel leftTopPane = TableLayoutHelper.createTableLayoutPane(components,rowSize,columnSize); + leftTopPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 6, 0)); leftPane.add(leftTopPane, BorderLayout.NORTH); return leftPane; diff --git a/designer_base/src/com/fr/design/gui/controlpane/UIListControlPane.java b/designer_base/src/com/fr/design/gui/controlpane/UIListControlPane.java index a6131b3ed5..c082f66983 100644 --- a/designer_base/src/com/fr/design/gui/controlpane/UIListControlPane.java +++ b/designer_base/src/com/fr/design/gui/controlpane/UIListControlPane.java @@ -9,6 +9,7 @@ import com.fr.design.data.tabledata.tabledatapane.GlobalTreeTableDataPane; import com.fr.design.data.tabledata.tabledatapane.MultiTDTableDataPane; import com.fr.design.data.tabledata.tabledatapane.TreeTableDataPane; import com.fr.design.file.HistoryTemplateListPane; +import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.ilist.UINameEdList; import com.fr.design.gui.ilist.ListModelElement; @@ -47,7 +48,7 @@ import java.util.Comparator; public abstract class UIListControlPane extends UIControlPane { public static final String LIST_NAME = "UIControl_List"; - private static final int EDIT_RANGE = 20; // 编辑按钮的x坐标范围 + private static final int EDIT_RANGE = 25; // 编辑按钮的x坐标范围 protected UINameEdList nameableList; protected int editingIndex; @@ -358,8 +359,11 @@ public abstract class UIListControlPane extends UIControlPane { } private void popupEditPane() { + if (editingIndex < 0) { + return; + } GUICoreUtils.showPopupMenu(popupEditPane, this, - - popupEditPane.getPreferredSize().width, nameableList.getSelectedIndex() * EDIT_RANGE); + - popupEditPane.getPreferredSize().width, editingIndex * EDIT_RANGE); } /** @@ -394,6 +398,21 @@ public abstract class UIListControlPane extends UIControlPane { wrapActionListener(creators); } + /** + * 生成UIButton + * @return 菜单按钮 + */ + public UIButton createUIButton() { + createdButton = super.createUIButton(); + // 此按钮单独抽出,不应使用工具栏外观 + if (!createdButton.isOpaque()) { + createdButton.setOpaque(true); + createdButton.setNormalPainted(true); + createdButton.setBorderPaintedOnlyWhenPressed(false); + } + return createdButton; + } + private void wrapActionListener(NameableCreator[] creators) { for (final NameableCreator creator : creators) { if (!whetherAdd(creator.menuName())) { @@ -649,6 +668,7 @@ public abstract class UIListControlPane extends UIControlPane { selectedName = nameableList.getNameAt(editingIndex); nameableList.editItemAt(nameableList.getSelectedIndex()); } else if (SwingUtilities.isLeftMouseButton(evt) && evt.getX() <= EDIT_RANGE) { + editingIndex = nameableList.getSelectedIndex(); popupEditPane(); } diff --git a/designer_base/src/com/fr/design/gui/controlpane/UINameableListCellRenderer.java b/designer_base/src/com/fr/design/gui/controlpane/UINameableListCellRenderer.java index e8844d3856..e56b038074 100644 --- a/designer_base/src/com/fr/design/gui/controlpane/UINameableListCellRenderer.java +++ b/designer_base/src/com/fr/design/gui/controlpane/UINameableListCellRenderer.java @@ -25,8 +25,9 @@ public class UINameableListCellRenderer extends JPanel implements ListCellRenderer { private static final Border SAFE_NO_FOCUS_BORDER = new EmptyBorder(1, 1, 1, 1); private static final Border DEFAULT_NO_FOCUS_BORDER = new EmptyBorder(1, 1, 1, 1); + private static final Color BORDER_COLOR = new Color(201, 198, 184); protected static Border noFocusBorder = DEFAULT_NO_FOCUS_BORDER; - private static final int BUTTON_WIDTH = 20; + private static final int BUTTON_WIDTH = 25; private UILabel editButton; // "编辑按钮",实际上是一个 UILabel,由列表项(UIListControlPane)统一处理点击事件 private UILabel label; private UIListControlPane listControlPane; @@ -48,6 +49,8 @@ public class UINameableListCellRenderer extends }; // editButton.set4LargeToolbarButton(); editButton.setIcon(BaseUtils.readIcon("/com/fr/base/images/cell/control/add.png")); + editButton.setBorder(BorderFactory.createMatteBorder(0, 0, 0, 1, BORDER_COLOR)); + editButton.setHorizontalAlignment(SwingConstants.CENTER); // editButton.addActionListener(new ActionListener() { // @Override // public void actionPerformed(ActionEvent e) { @@ -55,30 +58,28 @@ public class UINameableListCellRenderer extends // } // }); label = new UILabel(); + label.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 0)); // label.setEditable(false); this.setLayout(new BorderLayout()); this.add(editButton, BorderLayout.WEST); this.add(label, BorderLayout.CENTER); } - private void popupEditPane() { - GUICoreUtils.showPopupMenu(listControlPane.popupEditPane, editButton, - - listControlPane.popupEditPane.getPreferredSize().width, 0); - } - private Border getNoFocusBorder() { - Border border = DefaultLookup.getBorder(this, ui, "List.cellNoFocusBorder"); - if (System.getSecurityManager() != null) { - if (border != null) return border; - return SAFE_NO_FOCUS_BORDER; - } else { - if (border != null && - (noFocusBorder == null || - noFocusBorder == DEFAULT_NO_FOCUS_BORDER)) { - return border; - } - return noFocusBorder; - } +// return BorderFactory.createLineBorder(new Color(201, 198, 184)); + return BorderFactory.createMatteBorder(0, 0, 1, 0, BORDER_COLOR); + // Border border = DefaultLookup.getBorder(this, ui, "List.cellNoFocusBorder"); +// if (System.getSecurityManager() != null) { +// if (border != null) return border; +// return SAFE_NO_FOCUS_BORDER; +// } else { +// if (border != null && +// (noFocusBorder == null || +// noFocusBorder == DEFAULT_NO_FOCUS_BORDER)) { +// return border; +// } +// return noFocusBorder; +// } } private void setText(String t) { diff --git a/designer_base/src/com/fr/design/gui/ilist/UINameEdList.java b/designer_base/src/com/fr/design/gui/ilist/UINameEdList.java index 73ba2bf82c..823c95d6e4 100644 --- a/designer_base/src/com/fr/design/gui/ilist/UINameEdList.java +++ b/designer_base/src/com/fr/design/gui/ilist/UINameEdList.java @@ -24,7 +24,7 @@ import java.util.Vector; */ public class UINameEdList extends UIList implements CellEditorListener { private static final int TEST_LIST_LENTH = 20; - private static final int BUTTON_WIDTH = 20; + private static final int BUTTON_WIDTH = 25; private boolean editable = true; // kunsnat: 是否强制ListName是数字 (int型)