Browse Source

REPORT-3163 合作开发9.0设计器=>列表面板=》完善UI细节

master
plough 7 years ago
parent
commit
18c5fc3941
  1. 11
      designer_base/src/com/fr/design/gui/controlpane/UIControlPane.java
  2. 24
      designer_base/src/com/fr/design/gui/controlpane/UIListControlPane.java
  3. 37
      designer_base/src/com/fr/design/gui/controlpane/UINameableListCellRenderer.java
  4. 2
      designer_base/src/com/fr/design/gui/ilist/UINameEdList.java

11
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); // mainSplitPane.setOneTouchExpandable(true);
this.add(getLeftPane(), BorderLayout.CENTER); this.add(getLeftPane(), BorderLayout.CENTER);
this.setBorder(BorderFactory.createEmptyBorder(0, 10, 12, 10));
// mainSplitPane.setDividerLocation(getLeftPreferredSize()); // mainSplitPane.setDividerLocation(getLeftPreferredSize());
this.checkButtonEnabled(); this.checkButtonEnabled();
} }
@ -134,14 +135,21 @@ public abstract class UIControlPane extends BasicPane implements UnrepeatedNameH
toolbarDef.addShortCut(sj.getShortCut()); toolbarDef.addShortCut(sj.getShortCut());
} }
toolBar = ToolBarDef.createJToolBar(); toolBar = ToolBarDef.createJToolBar();
// toolBar.setLayout(new FlowLayout(FlowLayout.LEFT));
toolbarDef.updateToolBar(toolBar); 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按钮 // 顶部标签及add按钮
UIToolbar topToolBar = new UIToolbar(); UIToolbar topToolBar = new UIToolbar();
topToolBar.setLayout(new BorderLayout()); topToolBar.setLayout(new BorderLayout());
ShortCut addItem = addItemShortCut().getShortCut(); ShortCut addItem = addItemShortCut().getShortCut();
addItem.intoJToolBar(topToolBar); addItem.intoJToolBar(topToolBar);
topToolBar.setBorder(BorderFactory.createEmptyBorder(2, 0, 2, 0));
double p = TableLayout.PREFERRED; double p = TableLayout.PREFERRED;
double f = TableLayout.FILL; double f = TableLayout.FILL;
double[] columnSize = { p, f }; double[] columnSize = { p, f };
@ -150,6 +158,7 @@ public abstract class UIControlPane extends BasicPane implements UnrepeatedNameH
new Component[]{new UILabel("add hyperlink "), topToolBar}, new Component[]{new UILabel("add hyperlink "), topToolBar},
}; };
JPanel leftTopPane = TableLayoutHelper.createTableLayoutPane(components,rowSize,columnSize); JPanel leftTopPane = TableLayoutHelper.createTableLayoutPane(components,rowSize,columnSize);
leftTopPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 6, 0));
leftPane.add(leftTopPane, BorderLayout.NORTH); leftPane.add(leftTopPane, BorderLayout.NORTH);
return leftPane; return leftPane;

24
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.MultiTDTableDataPane;
import com.fr.design.data.tabledata.tabledatapane.TreeTableDataPane; import com.fr.design.data.tabledata.tabledatapane.TreeTableDataPane;
import com.fr.design.file.HistoryTemplateListPane; 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.icontainer.UIScrollPane;
import com.fr.design.gui.ilist.UINameEdList; import com.fr.design.gui.ilist.UINameEdList;
import com.fr.design.gui.ilist.ListModelElement; import com.fr.design.gui.ilist.ListModelElement;
@ -47,7 +48,7 @@ import java.util.Comparator;
public abstract class UIListControlPane extends UIControlPane { public abstract class UIListControlPane extends UIControlPane {
public static final String LIST_NAME = "UIControl_List"; 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 UINameEdList nameableList;
protected int editingIndex; protected int editingIndex;
@ -358,8 +359,11 @@ public abstract class UIListControlPane extends UIControlPane {
} }
private void popupEditPane() { private void popupEditPane() {
if (editingIndex < 0) {
return;
}
GUICoreUtils.showPopupMenu(popupEditPane, this, 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); 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) { private void wrapActionListener(NameableCreator[] creators) {
for (final NameableCreator creator : creators) { for (final NameableCreator creator : creators) {
if (!whetherAdd(creator.menuName())) { if (!whetherAdd(creator.menuName())) {
@ -649,6 +668,7 @@ public abstract class UIListControlPane extends UIControlPane {
selectedName = nameableList.getNameAt(editingIndex); selectedName = nameableList.getNameAt(editingIndex);
nameableList.editItemAt(nameableList.getSelectedIndex()); nameableList.editItemAt(nameableList.getSelectedIndex());
} else if (SwingUtilities.isLeftMouseButton(evt) && evt.getX() <= EDIT_RANGE) { } else if (SwingUtilities.isLeftMouseButton(evt) && evt.getX() <= EDIT_RANGE) {
editingIndex = nameableList.getSelectedIndex();
popupEditPane(); popupEditPane();
} }

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

@ -25,8 +25,9 @@ public class UINameableListCellRenderer extends
JPanel implements ListCellRenderer { JPanel implements ListCellRenderer {
private static final Border SAFE_NO_FOCUS_BORDER = new EmptyBorder(1, 1, 1, 1); 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 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; 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 editButton; // "编辑按钮",实际上是一个 UILabel,由列表项(UIListControlPane)统一处理点击事件
private UILabel label; private UILabel label;
private UIListControlPane listControlPane; private UIListControlPane listControlPane;
@ -48,6 +49,8 @@ public class UINameableListCellRenderer extends
}; };
// editButton.set4LargeToolbarButton(); // editButton.set4LargeToolbarButton();
editButton.setIcon(BaseUtils.readIcon("/com/fr/base/images/cell/control/add.png")); 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() { // editButton.addActionListener(new ActionListener() {
// @Override // @Override
// public void actionPerformed(ActionEvent e) { // public void actionPerformed(ActionEvent e) {
@ -55,30 +58,28 @@ public class UINameableListCellRenderer extends
// } // }
// }); // });
label = new UILabel(); label = new UILabel();
label.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 0));
// label.setEditable(false); // label.setEditable(false);
this.setLayout(new BorderLayout()); this.setLayout(new BorderLayout());
this.add(editButton, BorderLayout.WEST); this.add(editButton, BorderLayout.WEST);
this.add(label, BorderLayout.CENTER); this.add(label, BorderLayout.CENTER);
} }
private void popupEditPane() {
GUICoreUtils.showPopupMenu(listControlPane.popupEditPane, editButton,
- listControlPane.popupEditPane.getPreferredSize().width, 0);
}
private Border getNoFocusBorder() { private Border getNoFocusBorder() {
Border border = DefaultLookup.getBorder(this, ui, "List.cellNoFocusBorder"); // return BorderFactory.createLineBorder(new Color(201, 198, 184));
if (System.getSecurityManager() != null) { return BorderFactory.createMatteBorder(0, 0, 1, 0, BORDER_COLOR);
if (border != null) return border; // Border border = DefaultLookup.getBorder(this, ui, "List.cellNoFocusBorder");
return SAFE_NO_FOCUS_BORDER; // if (System.getSecurityManager() != null) {
} else { // if (border != null) return border;
if (border != null && // return SAFE_NO_FOCUS_BORDER;
(noFocusBorder == null || // } else {
noFocusBorder == DEFAULT_NO_FOCUS_BORDER)) { // if (border != null &&
return border; // (noFocusBorder == null ||
} // noFocusBorder == DEFAULT_NO_FOCUS_BORDER)) {
return noFocusBorder; // return border;
} // }
// return noFocusBorder;
// }
} }
private void setText(String t) { private void setText(String t) {

2
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 { public class UINameEdList extends UIList implements CellEditorListener {
private static final int TEST_LIST_LENTH = 20; 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; private boolean editable = true;
// kunsnat: 是否强制ListName是数字 (int型) // kunsnat: 是否强制ListName是数字 (int型)

Loading…
Cancel
Save