|
|
@ -63,29 +63,7 @@ public abstract class JListControlPane extends JControlPane { |
|
|
|
public abstract NameableCreator[] createNameableCreators(); |
|
|
|
public abstract NameableCreator[] createNameableCreators(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected JPanel getLeftPane() { |
|
|
|
protected void initLeftPane(JPanel leftPane) { |
|
|
|
// LeftPane
|
|
|
|
|
|
|
|
JPanel leftPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
initNameList(leftPane); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
shorts = this.createShortcuts(); |
|
|
|
|
|
|
|
if (ArrayUtils.isEmpty(shorts)) { |
|
|
|
|
|
|
|
return leftPane; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
toolbarDef = new ToolBarDef(); |
|
|
|
|
|
|
|
for (ShortCut4JControlPane sj : shorts) { |
|
|
|
|
|
|
|
toolbarDef.addShortCut(sj.getShortCut()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
toolBar = ToolBarDef.createJToolBar(); |
|
|
|
|
|
|
|
toolbarDef.updateToolBar(toolBar); |
|
|
|
|
|
|
|
leftPane.add(toolBar, BorderLayout.NORTH); |
|
|
|
|
|
|
|
return leftPane; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void initNameList(JPanel leftPane) { |
|
|
|
|
|
|
|
nameableList = createJNameList(); |
|
|
|
nameableList = createJNameList(); |
|
|
|
nameableList.setName(LIST_NAME); |
|
|
|
nameableList.setName(LIST_NAME); |
|
|
|
leftPane.add(new UIScrollPane(nameableList), BorderLayout.CENTER); |
|
|
|
leftPane.add(new UIScrollPane(nameableList), BorderLayout.CENTER); |
|
|
@ -127,23 +105,9 @@ public abstract class JListControlPane extends JControlPane { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected int getLeftPreferredSize() { |
|
|
|
|
|
|
|
return shorts.length * JControlPane.SHORT_WIDTH; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected ShortCut4JControlPane[] createShortcuts() { |
|
|
|
|
|
|
|
return new ShortCut4JControlPane[]{ |
|
|
|
|
|
|
|
addItemShortCut(), |
|
|
|
|
|
|
|
removeItemShortCut(), |
|
|
|
|
|
|
|
copyItemShortCut(), |
|
|
|
|
|
|
|
moveUpItemShortCut(), |
|
|
|
|
|
|
|
moveDownItemShortCut(), |
|
|
|
|
|
|
|
sortItemShortCut() |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected ShortCut4JControlPane addItemShortCut() { |
|
|
|
protected ShortCut4JControlPane addItemShortCut() { |
|
|
|
ShortCut addItemShortCut; |
|
|
|
ShortCut addItemShortCut; |
|
|
|
|
|
|
|
NameableCreator[] creators = creators(); |
|
|
|
if (creators.length == 1) { |
|
|
|
if (creators.length == 1) { |
|
|
|
addItemShortCut = new AddItemUpdateAction(creators); |
|
|
|
addItemShortCut = new AddItemUpdateAction(creators); |
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -264,25 +228,6 @@ public abstract class JListControlPane extends JControlPane { |
|
|
|
return el == null ? null : el.wrapper.getName(); |
|
|
|
return el == null ? null : el.wrapper.getName(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 刷新 NameableCreator |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param creators 生成器 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public void refreshNameableCreator(NameableCreator[] creators) { |
|
|
|
|
|
|
|
this.creators = creators; |
|
|
|
|
|
|
|
shorts = this.createShortcuts(); |
|
|
|
|
|
|
|
toolbarDef.clearShortCuts(); |
|
|
|
|
|
|
|
for (ShortCut4JControlPane sj : shorts) { |
|
|
|
|
|
|
|
toolbarDef.addShortCut(sj.getShortCut()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
toolbarDef.updateToolBar(toolBar); |
|
|
|
|
|
|
|
toolBar.validate(); |
|
|
|
|
|
|
|
toolBar.repaint(); |
|
|
|
|
|
|
|
this.repaint(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected boolean isNameRepeted(java.util.List[] list, String name) { |
|
|
|
protected boolean isNameRepeted(java.util.List[] list, String name) { |
|
|
|
for (int i = 0; i < list.length; i++) { |
|
|
|
for (int i = 0; i < list.length; i++) { |
|
|
|
if (list[i].contains(name)) { |
|
|
|
if (list[i].contains(name)) { |
|
|
@ -676,7 +621,7 @@ public abstract class JListControlPane extends JControlPane { |
|
|
|
// p:右键菜单.
|
|
|
|
// p:右键菜单.
|
|
|
|
JPopupMenu popupMenu = new JPopupMenu(); |
|
|
|
JPopupMenu popupMenu = new JPopupMenu(); |
|
|
|
|
|
|
|
|
|
|
|
for (ShortCut4JControlPane sj : shorts) { |
|
|
|
for (ShortCut4JControlPane sj : getShorts()) { |
|
|
|
sj.getShortCut().intoJPopupMenu(popupMenu); |
|
|
|
sj.getShortCut().intoJPopupMenu(popupMenu); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -694,13 +639,14 @@ public abstract class JListControlPane extends JControlPane { |
|
|
|
* 检查按钮可用状态 Check button enabled. |
|
|
|
* 检查按钮可用状态 Check button enabled. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void checkButtonEnabled() { |
|
|
|
public void checkButtonEnabled() { |
|
|
|
|
|
|
|
|
|
|
|
int selectedIndex = nameableList.getSelectedIndex(); |
|
|
|
int selectedIndex = nameableList.getSelectedIndex(); |
|
|
|
if (selectedIndex == -1) { |
|
|
|
if (selectedIndex == -1) { |
|
|
|
this.cardLayout.show(cardPane, "SELECT"); |
|
|
|
this.cardLayout.show(cardPane, "SELECT"); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
this.cardLayout.show(cardPane, "EDIT"); |
|
|
|
this.cardLayout.show(cardPane, "EDIT"); |
|
|
|
} |
|
|
|
} |
|
|
|
for (ShortCut4JControlPane sj : this.shorts) { |
|
|
|
for (ShortCut4JControlPane sj : getShorts()) { |
|
|
|
sj.checkEnable(); |
|
|
|
sj.checkEnable(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -713,10 +659,6 @@ public abstract class JListControlPane extends JControlPane { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public NameableCreator[] creators() { |
|
|
|
|
|
|
|
return creators == null ? new NameableCreator[0] : creators; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
/* |
|
|
|
* Nameable的ListCellRenerer |
|
|
|
* Nameable的ListCellRenerer |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -732,7 +674,7 @@ public abstract class JListControlPane extends JControlPane { |
|
|
|
this.setText(((ListModelElement) value).wrapper.getName()); |
|
|
|
this.setText(((ListModelElement) value).wrapper.getName()); |
|
|
|
|
|
|
|
|
|
|
|
boolean iconSet = false; |
|
|
|
boolean iconSet = false; |
|
|
|
for (NameableCreator creator : JListControlPane.this.creators) { |
|
|
|
for (NameableCreator creator : JListControlPane.this.creators()) { |
|
|
|
if (creator.menuIcon() != null && creator.acceptObject2Populate(wrappee) != null) { |
|
|
|
if (creator.menuIcon() != null && creator.acceptObject2Populate(wrappee) != null) { |
|
|
|
this.setIcon(creator.menuIcon()); |
|
|
|
this.setIcon(creator.menuIcon()); |
|
|
|
this.setToolTipText(creator.createTooltip()); |
|
|
|
this.setToolTipText(creator.createTooltip()); |
|
|
@ -836,6 +778,7 @@ public abstract class JListControlPane extends JControlPane { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void initUpdatePane() { |
|
|
|
private void initUpdatePane() { |
|
|
|
|
|
|
|
NameableCreator[] creators = creators(); |
|
|
|
if (creators == null) { |
|
|
|
if (creators == null) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
@ -855,6 +798,7 @@ public abstract class JListControlPane extends JControlPane { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
elEditing = el; |
|
|
|
elEditing = el; |
|
|
|
|
|
|
|
NameableCreator[] creators = creators(); |
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0, len = updatePanes.length; i < len; i++) { |
|
|
|
for (int i = 0, len = updatePanes.length; i < len; i++) { |
|
|
|
Object ob2Populate = creators[i].acceptObject2Populate(el.wrapper); |
|
|
|
Object ob2Populate = creators[i].acceptObject2Populate(el.wrapper); |
|
|
@ -884,13 +828,14 @@ public abstract class JListControlPane extends JControlPane { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void update() { |
|
|
|
public void update() { |
|
|
|
|
|
|
|
NameableCreator[] creators = creators(); |
|
|
|
for (int i = 0; i < updatePanes.length; i++) { |
|
|
|
for (int i = 0; i < updatePanes.length; i++) { |
|
|
|
BasicBeanPane pane = updatePanes[i]; |
|
|
|
BasicBeanPane pane = updatePanes[i]; |
|
|
|
|
|
|
|
|
|
|
|
if (pane != null && pane.isVisible()) { |
|
|
|
if (pane != null && pane.isVisible()) { |
|
|
|
Object bean = pane.updateBean(); |
|
|
|
Object bean = pane.updateBean(); |
|
|
|
if (i < JListControlPane.this.creators.length) { |
|
|
|
if (i < creators.length) { |
|
|
|
JListControlPane.this.creators[i].saveUpdatedBean(elEditing, bean); |
|
|
|
creators[i].saveUpdatedBean(elEditing, bean); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -937,8 +882,9 @@ public abstract class JListControlPane extends JControlPane { |
|
|
|
|
|
|
|
|
|
|
|
// 选项添加个数有限制等情况下 要求能控制快捷按钮的状态
|
|
|
|
// 选项添加个数有限制等情况下 要求能控制快捷按钮的状态
|
|
|
|
protected void setToolbarDefEnable(int shortCutIndex, int itemIndex, boolean enabled) { |
|
|
|
protected void setToolbarDefEnable(int shortCutIndex, int itemIndex, boolean enabled) { |
|
|
|
if (this.toolbarDef.getShortCutCount() > shortCutIndex) { |
|
|
|
ToolBarDef toolbarDef = getToolbarDef(); |
|
|
|
ShortCut sc = this.toolbarDef.getShortCut(shortCutIndex); |
|
|
|
if (toolbarDef.getShortCutCount() > shortCutIndex) { |
|
|
|
|
|
|
|
ShortCut sc = toolbarDef.getShortCut(shortCutIndex); |
|
|
|
if (sc instanceof AddItemMenuDef) { |
|
|
|
if (sc instanceof AddItemMenuDef) { |
|
|
|
AddItemMenuDef am = (AddItemMenuDef) sc; |
|
|
|
AddItemMenuDef am = (AddItemMenuDef) sc; |
|
|
|
if (am.getShortCutCount() > itemIndex) { |
|
|
|
if (am.getShortCutCount() > itemIndex) { |
|
|
|