Browse Source

Merge pull request #90 in BA/design from ~ZACK/design:dev to dev

* commit 'b6433715ba84e504e5224e2f4c42ed2060570406':
  加override
  加上override
  加一个数据集面板处理器的接口,和jcontrolpane分开
master
neil 9 years ago
parent
commit
507e59be0f
  1. 9
      designer_base/src/com/fr/design/data/datapane/ReportTableDataPane.java
  2. 62
      designer_base/src/com/fr/design/data/datapane/TableDataPaneController.java
  3. 38
      designer_base/src/com/fr/design/data/datapane/TableDataPaneListPane.java
  4. 14
      designer_base/src/com/fr/design/data/tabledata/tabledatapane/TableDataManagerPane.java
  5. 4
      designer_base/src/com/fr/design/fun/TableDataPaneProcessor.java
  6. 174
      designer_base/src/com/fr/design/gui/controlpane/JControlPane.java
  7. 129
      designer_base/src/com/fr/design/gui/controlpane/JListControlPane.java

9
designer_base/src/com/fr/design/data/datapane/ReportTableDataPane.java

@ -6,7 +6,6 @@ package com.fr.design.data.datapane;
import com.fr.data.TableDataSource;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.fun.TableDataPaneProcessor;
import com.fr.design.gui.controlpane.JControlPane;
import com.fr.design.gui.controlpane.NameableCreator;
import com.fr.design.gui.frpane.LoadingBasicPane;
import com.fr.design.layout.FRGUIPaneFactory;
@ -22,24 +21,24 @@ import java.util.Map;
* 创建于2011-6-14
*/
public class ReportTableDataPane extends LoadingBasicPane {
private JControlPane tdPane;
private TableDataPaneController tdPane;
@Override
protected void initComponents(JPanel container) {
container.setLayout(FRGUIPaneFactory.createBorderLayout());
TableDataPaneProcessor paneProcessor = ExtraDesignClassManager.getInstance().getTableDataPaneProcessor();
JControlPane pane = null;
TableDataPaneController pane = null;
if (paneProcessor != null) {
pane = paneProcessor.createServerTableDataPane();
}
tdPane = pane == null ? new TableDataListPane() {
tdPane = pane == null ? new TableDataPaneListPane() {
@Override
public NameableCreator[] createNameableCreators() {
return TableDataCreatorProducer.getInstance().createReportTableDataCreator();
}
} : pane;
container.add(tdPane, BorderLayout.CENTER);
container.add(tdPane.getPanel(), BorderLayout.CENTER);
}
@Override

62
designer_base/src/com/fr/design/data/datapane/TableDataPaneController.java

@ -0,0 +1,62 @@
package com.fr.design.data.datapane;
import com.fr.data.TableDataSource;
import com.fr.file.DatasourceManagerProvider;
import javax.swing.*;
import java.util.Map;
/**
* Coder: zack
* Date: 2016/5/18
* Time: 10:13
*/
public interface TableDataPaneController {
/**
* 获取数据集名字变更集合
*
* @return
*/
Map<String, String> getDsNameChangedMap();
/**
* 数据集重命名
*
* @param oldName
* @param newName
*/
void rename(String oldName, String newName);
/**
* 是否合法
* @throws Exception
*/
void checkValid() throws Exception;
/**
* 名字是否允许
* @return
*/
boolean isNamePermitted();
void populate(DatasourceManagerProvider datasourceManagerProvider);
void update(DatasourceManagerProvider datasourceManagerProvider);
void populate(TableDataSource datasourceManagerProvider);
void update(TableDataSource datasourceManagerProvider);
/**
* 设置选中项
* @param index
*/
void setSelectedIndex(int index);
/**
* 返回当前数据集面板
* @return
*/
JPanel getPanel();
}

38
designer_base/src/com/fr/design/data/datapane/TableDataListPane.java → designer_base/src/com/fr/design/data/datapane/TableDataPaneListPane.java

@ -21,10 +21,11 @@ import java.util.*;
/**
* TableDataList Pane.
*/
public class TableDataListPane extends JListControlPane {
public class TableDataPaneListPane extends JListControlPane implements TableDataPaneController {
private boolean isNamePermitted = true;
private Map<String, String> dsNameChangedMap = new HashMap<String, String>();
public TableDataListPane() {
public TableDataPaneListPane() {
super();
dsNameChangedMap.clear();
this.addEditingListner(new PropertyChangeAdapter() {
@ -42,7 +43,7 @@ public class TableDataListPane extends JListControlPane {
String[] sign = new String[]{",", "!"};
isNamePermitted = false;
nameableList.stopEditing();
JOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(TableDataListPane.this), Inter.getLocText(warning, sign));
JOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(TableDataPaneListPane.this), Inter.getLocText(warning, sign));
setWarnigText(editingIndex);
return;
}
@ -53,14 +54,14 @@ public class TableDataListPane extends JListControlPane {
String[] sign = new String[]{"", tempName + ",", "!"};
isNamePermitted = false;
nameableList.stopEditing();
JOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(TableDataListPane.this), Inter.getLocText(waning, sign));
JOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(TableDataPaneListPane.this), Inter.getLocText(waning, sign));
setWarnigText(editingIndex);
} else if (editingType instanceof StoreProcedure && isIncludeUnderline(tempName)) {
String[] datasource_underline = new String[]{"Datasource-Stored_Procedure", "Name", "can_not_include_underline"};
String[] sign = new String[]{"", "", "!"};
isNamePermitted = false;
nameableList.stopEditing();
JOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(TableDataListPane.this), Inter.getLocText(datasource_underline, sign));
JOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(TableDataPaneListPane.this), Inter.getLocText(datasource_underline, sign));
setWarnigText(editingIndex);
}
if (nameableList.getSelectedValue() instanceof ListModelElement) {
@ -74,7 +75,8 @@ public class TableDataListPane extends JListControlPane {
});
}
protected void rename(String oldName, String newName) {
@Override
public void rename(String oldName, String newName) {
dsNameChangedMap.put(oldName, newName);
}
@ -83,6 +85,7 @@ public class TableDataListPane extends JListControlPane {
*
* @return /
*/
@Override
public boolean isNamePermitted() {
return isNamePermitted;
}
@ -91,6 +94,7 @@ public class TableDataListPane extends JListControlPane {
/**
* 检查按钮可用状态 Check button enabled.
*/
@Override
public void checkButtonEnabled() {
super.checkButtonEnabled();
isNamePermitted = !isContainsRename();
@ -105,6 +109,7 @@ public class TableDataListPane extends JListControlPane {
*
* @return 数组
*/
@Override
public NameableCreator[] createNameableCreators() {
return TableDataCreatorProducer.getInstance().createServerTableDataCreator();
}
@ -165,6 +170,7 @@ public class TableDataListPane extends JListControlPane {
/**
* Populate.
*/
@Override
public void populate(TableDataSource tds) {
List<NameObject> nameObjectList = new ArrayList<NameObject>();
@ -184,6 +190,7 @@ public class TableDataListPane extends JListControlPane {
/**
* Populate.
*/
@Override
public void populate(DatasourceManagerProvider datasourceManager) {
Iterator<String> nameIt = datasourceManager.getTableDataNameIterator();
Iterator<String> procedurenameIt = datasourceManager.getProcedureNameIterator();
@ -200,6 +207,7 @@ public class TableDataListPane extends JListControlPane {
populate(nameObjectList.toArray(new NameObject[nameObjectList.size()]));
}
@Override
public void update(DatasourceManagerProvider datasourceManager) {
datasourceManager.clearAllTableData();
datasourceManager.clearAllProcedure();
@ -210,6 +218,7 @@ public class TableDataListPane extends JListControlPane {
}
}
@Override
public void update(TableDataSource tds) {
tds.clearAllTableData();
@ -223,6 +232,7 @@ public class TableDataListPane extends JListControlPane {
/**
* 判断数据集是否重名
*/
@Override
public void checkValid() throws Exception {
List<String> exsitTableDataNameList = new ArrayList<String>();
// _denny: 判断是否有重复的数据集名
@ -254,7 +264,23 @@ public class TableDataListPane extends JListControlPane {
this.setSelectedName(name);
}
@Override
public Map<String, String> getDsNameChangedMap() {
return this.dsNameChangedMap;
}
@Override
public JPanel getPanel() {
return this;
}
/**
* 设置选中项
*
* @param index 选中项的序列号
*/
@Override
public void setSelectedIndex(int index) {
nameableList.setSelectedIndex(index);
}
}

14
designer_base/src/com/fr/design/data/tabledata/tabledatapane/TableDataManagerPane.java

@ -2,9 +2,9 @@ package com.fr.design.data.tabledata.tabledatapane;
import com.fr.base.FRContext;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.data.datapane.TableDataListPane;
import com.fr.design.data.datapane.TableDataPaneController;
import com.fr.design.data.datapane.TableDataPaneListPane;
import com.fr.design.fun.TableDataPaneProcessor;
import com.fr.design.gui.controlpane.JControlPane;
import com.fr.design.gui.frpane.LoadingBasicPane;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itextfield.UITextField;
@ -21,7 +21,7 @@ import java.util.Map;
public class TableDataManagerPane extends LoadingBasicPane {
private UITextField tableDataTextField;
private JControlPane tableDataPane;
private TableDataPaneController tableDataPane;
@Override
protected void initComponents(JPanel container) {
@ -40,17 +40,17 @@ public class TableDataManagerPane extends LoadingBasicPane {
tableDataPathPane.add(tableDataTextField, BorderLayout.CENTER);
this.tableDataTextField.setEditable(false);
TableDataPaneProcessor paneProcessor = ExtraDesignClassManager.getInstance().getTableDataPaneProcessor();
JControlPane pane = null;
TableDataPaneController pane = null;
if (paneProcessor != null) {
pane = paneProcessor.createServerTableDataPane();
}
tableDataPane = pane == null ? new TableDataListPane() {
protected void rename(String oldName, String newName) {
tableDataPane = pane == null ? new TableDataPaneListPane() {
public void rename(String oldName, String newName) {
super.rename(oldName, newName);
renameConnection(oldName, newName);
}
} : pane;
container.add(tableDataPane, BorderLayout.CENTER);
container.add(tableDataPane.getPanel(), BorderLayout.CENTER);
}

4
designer_base/src/com/fr/design/fun/TableDataPaneProcessor.java

@ -2,7 +2,7 @@ package com.fr.design.fun;
import com.fr.design.DesignModelAdapter;
import com.fr.design.data.BasicTableDataTreePane;
import com.fr.design.gui.controlpane.JControlPane;
import com.fr.design.data.datapane.TableDataPaneController;
import com.fr.stable.fun.Level;
/**
@ -25,6 +25,6 @@ public interface TableDataPaneProcessor extends Level {
* 服务器数据集面板(模板数据集面板)
* @return 服务器数据集面板
*/
JControlPane createServerTableDataPane();
TableDataPaneController createServerTableDataPane();
}

174
designer_base/src/com/fr/design/gui/controlpane/JControlPane.java

@ -1,20 +1,16 @@
package com.fr.design.gui.controlpane;
import com.fr.data.TableDataSource;
import com.fr.design.dialog.BasicPane;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itoolbar.UIToolbar;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.menu.ToolBarDef;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.file.DatasourceManagerProvider;
import com.fr.stable.ArrayUtils;
import com.fr.stable.Nameable;
import javax.swing.*;
import java.awt.*;
import java.util.HashMap;
import java.util.Map;
/**
* Coder: zack
@ -24,12 +20,12 @@ import java.util.Map;
public abstract class JControlPane extends BasicPane implements UnrepeatedNameHelper {
protected static final int SHORT_WIDTH = 30; //每加一个short Divider位置加30
protected JPanel controlUpdatePane;
protected Map<String, String> dsNameChangedMap = new HashMap<String, String>();
protected ShortCut4JControlPane[] shorts;
protected NameableCreator[] creators;
protected ToolBarDef toolbarDef;
protected UIToolbar toolBar;
private ShortCut4JControlPane[] shorts;
private NameableCreator[] creators;
private ToolBarDef toolbarDef;
private UIToolbar toolBar;
// peter:这是整体的一个cardLayout Pane
protected CardLayout cardLayout;
@ -46,6 +42,50 @@ public abstract class JControlPane extends BasicPane implements UnrepeatedNameHe
*/
public abstract NameableCreator[] createNameableCreators();
public ShortCut4JControlPane[] getShorts() {
return shorts;
}
public void setShorts(ShortCut4JControlPane[] shorts) {
this.shorts = shorts;
}
public void setCreators(NameableCreator[] creators) {
this.creators = creators;
}
public ToolBarDef getToolbarDef() {
return toolbarDef;
}
public void setToolbarDef(ToolBarDef toolbarDef) {
this.toolbarDef = toolbarDef;
}
public UIToolbar getToolBar() {
return toolBar;
}
public void setToolBar(UIToolbar toolBar) {
this.toolBar = toolBar;
}
public CardLayout getCardLayout() {
return cardLayout;
}
public void setCardLayout(CardLayout cardLayout) {
this.cardLayout = cardLayout;
}
public JPanel getCardPane() {
return cardPane;
}
public void setCardPane(JPanel cardPane) {
this.cardPane = cardPane;
}
protected void initComponentPane() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.creators = this.createNameableCreators();
@ -75,7 +115,7 @@ public abstract class JControlPane extends BasicPane implements UnrepeatedNameHe
// LeftPane
JPanel leftPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
init(leftPane);
initLeftPane(leftPane);
shorts = this.createShortcuts();
if (ArrayUtils.isEmpty(shorts)) {
@ -92,59 +132,10 @@ public abstract class JControlPane extends BasicPane implements UnrepeatedNameHe
return leftPane;
}
public ShortCut4JControlPane[] getShorts() {
return shorts;
}
public void setShorts(ShortCut4JControlPane[] shorts) {
this.shorts = shorts;
}
public NameableCreator[] getCreators() {
return creators;
}
public void setCreators(NameableCreator[] creators) {
this.creators = creators;
}
public ToolBarDef getToolbarDef() {
return toolbarDef;
}
public void setToolbarDef(ToolBarDef toolbarDef) {
this.toolbarDef = toolbarDef;
}
public UIToolbar getToolBar() {
return toolBar;
}
public void setToolBar(UIToolbar toolBar) {
this.toolBar = toolBar;
}
public CardLayout getCardLayout() {
return cardLayout;
}
public void setCardLayout(CardLayout cardLayout) {
this.cardLayout = cardLayout;
}
public JPanel getCardPane() {
return cardPane;
}
public void setCardPane(JPanel cardPane) {
this.cardPane = cardPane;
}
/**
* 初始化
* 初始化左边面板
*/
protected void init(JPanel leftPane) {
protected void initLeftPane(JPanel leftPane) {
}
@ -152,13 +143,6 @@ public abstract class JControlPane extends BasicPane implements UnrepeatedNameHe
return shorts.length * SHORT_WIDTH;
}
public Map<String, String> getDsNameChangedMap() {
return dsNameChangedMap;
}
public void setDsNameChangedMap(Map<String, String> dsNameChangedMap) {
this.dsNameChangedMap = dsNameChangedMap;
}
protected ShortCut4JControlPane[] createShortcuts() {
return new ShortCut4JControlPane[]{
@ -183,36 +167,12 @@ public abstract class JControlPane extends BasicPane implements UnrepeatedNameHe
protected abstract ShortCut4JControlPane sortItemShortCut();
public void setNameListEditable(boolean editable) {
}
public abstract Nameable[] update();
public void populate(Nameable[] nameableArray) {
}
public void update(DatasourceManagerProvider datasourceManager) {
}
public void populate(DatasourceManagerProvider datasourceManager) {
}
public void populate(TableDataSource tds) {
}
public void update(TableDataSource tds) {
}
/**
* 名字是否允许
*
* @return 默认返回true
*/
public boolean isNamePermitted() {
return true;
}
/**
* 检查按钮可用状态 Check button enabled.
*/
@ -220,37 +180,33 @@ public abstract class JControlPane extends BasicPane implements UnrepeatedNameHe
}
protected void doBeforeRemove() {
}
protected void doAfterRemove() {
}
public NameableCreator[] creators() {
return creators == null ? new NameableCreator[0] : creators;
}
/**
* 检查是否符合规范
*
* @throws Exception
*/
public void checkValid() throws Exception {
}
protected abstract boolean hasInvalid(boolean isAdd);
/**
* 设置选中项
* 刷新 NameableCreator
*
* @param index 选中项的序列号
* @param creators 生成器
*/
public void setSelectedIndex(int index) {
}
public void refreshNameableCreator(NameableCreator[] creators) {
this.creators = creators;
shorts = this.createShortcuts();
toolbarDef.clearShortCuts();
for (ShortCut4JControlPane sj : shorts) {
toolbarDef.addShortCut(sj.getShortCut());
}
protected void rename(String oldName, String newName) {
dsNameChangedMap.put(oldName, newName);
toolbarDef.updateToolBar(toolBar);
toolBar.validate();
toolBar.repaint();
this.repaint();
}
}

129
designer_base/src/com/fr/design/gui/controlpane/JListControlPane.java

@ -51,6 +51,7 @@ public abstract class JListControlPane extends JControlPane {
this.initComponentPane();
}
@Override
protected JPanel createControlUpdatePane() {
return new JControlUpdatePane();
}
@ -60,32 +61,12 @@ public abstract class JListControlPane extends JControlPane {
*
* @return 按钮的NameableCreator
*/
@Override
public abstract NameableCreator[] createNameableCreators();
protected JPanel getLeftPane() {
// 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) {
@Override
protected void initLeftPane(JPanel leftPane) {
nameableList = createJNameList();
nameableList.setName(LIST_NAME);
leftPane.add(new UIScrollPane(nameableList), BorderLayout.CENTER);
@ -111,6 +92,7 @@ public abstract class JListControlPane extends JControlPane {
public JNameEdList createJNameList() {
JNameEdList nameEdList = new JNameEdList(new DefaultListModel()) {
@Override
protected void doAfterLostFocus() {
JListControlPane.this.updateControlUpdatePane();
}
@ -127,23 +109,10 @@ 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()
};
}
@Override
protected ShortCut4JControlPane addItemShortCut() {
ShortCut addItemShortCut;
NameableCreator[] creators = creators();
if (creators.length == 1) {
addItemShortCut = new AddItemUpdateAction(creators);
} else {
@ -152,22 +121,27 @@ public abstract class JListControlPane extends JControlPane {
return new AbsoluteEnableShortCut(addItemShortCut);
}
@Override
protected ShortCut4JControlPane removeItemShortCut() {
return new NormalEnableShortCut(new RemoveItemAction());
}
@Override
protected ShortCut4JControlPane copyItemShortCut() {
return new NormalEnableShortCut(new CopyItemAction());
}
@Override
protected ShortCut4JControlPane moveUpItemShortCut() {
return new NormalEnableShortCut(new MoveUpItemAction());
}
@Override
protected ShortCut4JControlPane moveDownItemShortCut() {
return new NormalEnableShortCut(new MoveDownItemAction());
}
@Override
protected ShortCut4JControlPane sortItemShortCut() {
return new NormalEnableShortCut(new SortItemAction());
}
@ -176,6 +150,7 @@ public abstract class JListControlPane extends JControlPane {
this.nameableList.setEditable(editable);
}
@Override
public Nameable[] update() {
java.util.List<Nameable> res = new java.util.ArrayList<Nameable>();
((JControlUpdatePane) this.controlUpdatePane).update();
@ -187,6 +162,7 @@ public abstract class JListControlPane extends JControlPane {
return res.toArray(new Nameable[res.size()]);
}
@Override
public void populate(Nameable[] nameableArray) {
DefaultListModel listModel = (DefaultListModel) this.nameableList.getModel();
listModel.removeAllElements();
@ -264,25 +240,6 @@ public abstract class JListControlPane extends JControlPane {
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) {
for (int i = 0; i < list.length; i++) {
if (list[i].contains(name)) {
@ -361,6 +318,7 @@ public abstract class JListControlPane extends JControlPane {
* @param prefix 名字前缀
* @return 名字
*/
@Override
public String createUnrepeatedName(String prefix) {
DefaultListModel model = this.getModel();
Nameable[] all = new Nameable[model.getSize()];
@ -401,6 +359,7 @@ public abstract class JListControlPane extends JControlPane {
this.setSmallIcon(BaseUtils.readIcon("/com/fr/base/images/cell/control/add.png"));
}
@Override
public void actionPerformed(ActionEvent e) {
Nameable nameable = creator.createNameable(JListControlPane.this);
@ -438,6 +397,7 @@ public abstract class JListControlPane extends JControlPane {
}
}
@Override
public void actionPerformed(ActionEvent e) {
if (hasInvalid(true)) {
return;
@ -479,6 +439,7 @@ public abstract class JListControlPane extends JControlPane {
.readIcon("/com/fr/base/images/cell/control/remove.png"));
}
@Override
public void actionPerformed(ActionEvent evt) {
try {
JListControlPane.this.nameableList.getCellEditor()
@ -506,6 +467,7 @@ public abstract class JListControlPane extends JControlPane {
.readIcon("/com/fr/base/images/cell/control/copy.png"));
}
@Override
public void actionPerformed(ActionEvent evt) {
// p:选中的值.
ListModelElement selectedValue = (ListModelElement) nameableList.getSelectedValue();
@ -540,6 +502,7 @@ public abstract class JListControlPane extends JControlPane {
.readIcon("/com/fr/design/images/control/up.png"));
}
@Override
public void actionPerformed(ActionEvent evt) {
int selectedIndex = nameableList.getSelectedIndex();
if (selectedIndex == -1) {
@ -572,6 +535,7 @@ public abstract class JListControlPane extends JControlPane {
.readIcon("/com/fr/design/images/control/down.png"));
}
@Override
public void actionPerformed(ActionEvent evt) {
int selectedIndex = nameableList.getSelectedIndex();
if (selectedIndex == -1) {
@ -602,6 +566,7 @@ public abstract class JListControlPane extends JControlPane {
.readIcon("/com/fr/design/images/control/sortAsc.png"));
}
@Override
public void actionPerformed(ActionEvent evt) {
// p:选中的值.
Object selectedValue = nameableList.getSelectedValue();
@ -620,6 +585,7 @@ public abstract class JListControlPane extends JControlPane {
// p:排序.
if (isAtoZ) {
Comparator<Nameable> nameableComparator = new Comparator<Nameable>() {
@Override
public int compare(Nameable o1, Nameable o2) {
return -ComparatorUtils.compare(o1.getName(), o2
.getName());
@ -629,6 +595,7 @@ public abstract class JListControlPane extends JControlPane {
Arrays.sort(nameableArray, nameableComparator);
} else {
Comparator<Nameable> nameableComparator = new Comparator<Nameable>() {
@Override
public int compare(Nameable o1, Nameable o2) {
return ComparatorUtils.compare(o1.getName(), o2
.getName());
@ -657,6 +624,7 @@ public abstract class JListControlPane extends JControlPane {
* JNameEdList的鼠标事件
*/
private MouseListener listMouseListener = new MouseAdapter() {
@Override
public void mouseReleased(MouseEvent evt) {
nameableList.stopEditing();
if (evt.getClickCount() >= 2
@ -676,7 +644,7 @@ public abstract class JListControlPane extends JControlPane {
// p:右键菜单.
JPopupMenu popupMenu = new JPopupMenu();
for (ShortCut4JControlPane sj : shorts) {
for (ShortCut4JControlPane sj : getShorts()) {
sj.getShortCut().intoJPopupMenu(popupMenu);
}
@ -685,6 +653,7 @@ public abstract class JListControlPane extends JControlPane {
evt.getY() - 1);
}
@Override
public void mouseMoved(MouseEvent e) {
}
@ -693,35 +662,26 @@ public abstract class JListControlPane extends JControlPane {
/**
* 检查按钮可用状态 Check button enabled.
*/
@Override
public void checkButtonEnabled() {
int selectedIndex = nameableList.getSelectedIndex();
if (selectedIndex == -1) {
this.cardLayout.show(cardPane, "SELECT");
} else {
this.cardLayout.show(cardPane, "EDIT");
}
for (ShortCut4JControlPane sj : this.shorts) {
for (ShortCut4JControlPane sj : getShorts()) {
sj.checkEnable();
}
}
protected void doBeforeRemove() {
}
protected void doAfterRemove() {
}
public NameableCreator[] creators() {
return creators == null ? new NameableCreator[0] : creators;
}
/*
* Nameable的ListCellRenerer
*/
private class NameableListCellRenderer extends
DefaultListCellRenderer {
@Override
public Component getListCellRendererComponent(JList list, Object value,
int index, boolean isSelected, boolean cellHasFocus) {
super.getListCellRendererComponent(list, value, index, isSelected,
@ -732,7 +692,7 @@ public abstract class JListControlPane extends JControlPane {
this.setText(((ListModelElement) value).wrapper.getName());
boolean iconSet = false;
for (NameableCreator creator : JListControlPane.this.creators) {
for (NameableCreator creator : JListControlPane.this.creators()) {
if (creator.menuIcon() != null && creator.acceptObject2Populate(wrappee) != null) {
this.setIcon(creator.menuIcon());
this.setToolTipText(creator.createTooltip());
@ -757,6 +717,7 @@ public abstract class JListControlPane extends JControlPane {
/**
* 检查是否可用
*/
@Override
public void checkEnable() {
this.shortCut.setEnabled(true);
}
@ -770,6 +731,7 @@ public abstract class JListControlPane extends JControlPane {
/**
* 检查是否可用
*/
@Override
public void checkEnable() {
this.shortCut.setEnabled(getModel()
.getSize() > 0
@ -836,6 +798,7 @@ public abstract class JListControlPane extends JControlPane {
}
private void initUpdatePane() {
NameableCreator[] creators = creators();
if (creators == null) {
return;
}
@ -855,6 +818,7 @@ public abstract class JListControlPane extends JControlPane {
}
elEditing = el;
NameableCreator[] creators = creators();
for (int i = 0, len = updatePanes.length; i < len; i++) {
Object ob2Populate = creators[i].acceptObject2Populate(el.wrapper);
@ -884,13 +848,14 @@ public abstract class JListControlPane extends JControlPane {
}
public void update() {
NameableCreator[] creators = creators();
for (int i = 0; i < updatePanes.length; i++) {
BasicBeanPane pane = updatePanes[i];
if (pane != null && pane.isVisible()) {
Object bean = pane.updateBean();
if (i < JListControlPane.this.creators.length) {
JListControlPane.this.creators[i].saveUpdatedBean(elEditing, bean);
if (i < creators.length) {
creators[i].saveUpdatedBean(elEditing, bean);
}
}
}
@ -937,8 +902,9 @@ public abstract class JListControlPane extends JControlPane {
// 选项添加个数有限制等情况下 要求能控制快捷按钮的状态
protected void setToolbarDefEnable(int shortCutIndex, int itemIndex, boolean enabled) {
if (this.toolbarDef.getShortCutCount() > shortCutIndex) {
ShortCut sc = this.toolbarDef.getShortCut(shortCutIndex);
ToolBarDef toolbarDef = getToolbarDef();
if (toolbarDef.getShortCutCount() > shortCutIndex) {
ShortCut sc = toolbarDef.getShortCut(shortCutIndex);
if (sc instanceof AddItemMenuDef) {
AddItemMenuDef am = (AddItemMenuDef) sc;
if (am.getShortCutCount() > itemIndex) {
@ -953,6 +919,7 @@ public abstract class JListControlPane extends JControlPane {
*
* @throws Exception
*/
@Override
public void checkValid() throws Exception {
((JControlUpdatePane) this.controlUpdatePane).checkValid();
}
@ -973,6 +940,7 @@ public abstract class JListControlPane extends JControlPane {
return -1;
}
@Override
protected boolean hasInvalid(boolean isAdd) {
int idx = JListControlPane.this.getInValidIndex();
if (isAdd || nameableList.getSelectedIndex() != idx) {
@ -987,13 +955,4 @@ public abstract class JListControlPane extends JControlPane {
return false;
}
/**
* 设置选中项
*
* @param index 选中项的序列号
*/
public void setSelectedIndex(int index) {
nameableList.setSelectedIndex(index);
}
}
Loading…
Cancel
Save