Browse Source

代码质量 选中状态检查方法放到listmodel里面

master
XiaXiang 8 years ago
parent
commit
b3657adbbf
  1. 45
      designer/src/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java

45
designer/src/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java

@ -78,16 +78,9 @@ public class AlphaFineDialog extends UIDialog {
private SwingWorker searchWorker; private SwingWorker searchWorker;
private SwingWorker showWorker; private SwingWorker showWorker;
private String storeText; private String storeText;
//是否强制打开,因为面板是否关闭绑定了全局鼠标事件,这里需要处理一下
/**
* 是否强制打开因为面板是否关闭绑定了全局鼠标事件这里需要处理一下
*/
private boolean forceOpen; private boolean forceOpen;
/**
*List的第一可用项是否被选中
*/
private boolean isSelected;
public AlphaFineDialog(Frame parent, boolean forceOpen) { public AlphaFineDialog(Frame parent, boolean forceOpen) {
@ -343,7 +336,7 @@ public class AlphaFineDialog extends UIDialog {
*/ */
private void resetContainer() { private void resetContainer() {
searchListModel.removeAllElements(); searchListModel.removeAllElements();
setSelected(false); searchListModel.resetSelectedState();
rightSearchResultPane.removeAll(); rightSearchResultPane.removeAll();
rightSearchResultPane.validate(); rightSearchResultPane.validate();
rightSearchResultPane.repaint(); rightSearchResultPane.repaint();
@ -799,14 +792,6 @@ public class AlphaFineDialog extends UIDialog {
this.storeText = storeText; this.storeText = storeText;
} }
public boolean isSelected() {
return isSelected;
}
public void setSelected(boolean selected) {
isSelected = selected;
}
/** /**
+-------------------------------------+ +-------------------------------------+
@ -905,6 +890,11 @@ public class AlphaFineDialog extends UIDialog {
private class SearchListModel extends DefaultListModel<AlphaCellModel> { private class SearchListModel extends DefaultListModel<AlphaCellModel> {
SearchResult myDelegate; SearchResult myDelegate;
/**
* 第一有效的项是否被选中
*/
private boolean isValidSelected;
public SearchListModel(SearchResult searchResult) { public SearchListModel(SearchResult searchResult) {
this.myDelegate = searchResult; this.myDelegate = searchResult;
} }
@ -922,14 +912,14 @@ public class AlphaFineDialog extends UIDialog {
} }
/** /**
* 触发选中 * 触发选中第一有效的项
* @param element * @param element
* @param index * @param index
*/ */
private void fireSelectedStateChanged(AlphaCellModel element, int index) { private void fireSelectedStateChanged(AlphaCellModel element, int index) {
if (element.hasAction() && !isSelected()) { if (element.hasAction() && !isValidSelected()) {
searchResultList.setSelectedIndex(index); searchResultList.setSelectedIndex(index);
setSelected(true); setValidSelected(true);
} }
} }
@ -961,6 +951,21 @@ public class AlphaFineDialog extends UIDialog {
public void removeAllElements() { public void removeAllElements() {
this.myDelegate.clear(); this.myDelegate.clear();
} }
/**
* 重置选中状态
*/
public void resetSelectedState() {
setValidSelected(false);
}
public boolean isValidSelected() {
return isValidSelected;
}
private void setValidSelected(boolean selected) {
isValidSelected = selected;
}
} }
} }
Loading…
Cancel
Save