From b3657adbbfc19c29013196cb82fcaa5b8eb289d7 Mon Sep 17 00:00:00 2001 From: XiaXiang Date: Wed, 28 Jun 2017 00:58:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E8=B4=A8=E9=87=8F=20?= =?UTF-8?q?=E9=80=89=E4=B8=AD=E7=8A=B6=E6=80=81=E6=A3=80=E6=9F=A5=E6=96=B9?= =?UTF-8?q?=E6=B3=95=E6=94=BE=E5=88=B0listmodel=E9=87=8C=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../alphafine/component/AlphaFineDialog.java | 45 ++++++++++--------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/designer/src/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java b/designer/src/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java index 056aa38905..f09810c81e 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java +++ b/designer/src/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java @@ -78,16 +78,9 @@ public class AlphaFineDialog extends UIDialog { private SwingWorker searchWorker; private SwingWorker showWorker; private String storeText; - - /** - * 是否强制打开,因为面板是否关闭绑定了全局鼠标事件,这里需要处理一下 - */ + //是否强制打开,因为面板是否关闭绑定了全局鼠标事件,这里需要处理一下 private boolean forceOpen; - /** - *List的第一可用项是否被选中 - */ - private boolean isSelected; public AlphaFineDialog(Frame parent, boolean forceOpen) { @@ -343,7 +336,7 @@ public class AlphaFineDialog extends UIDialog { */ private void resetContainer() { searchListModel.removeAllElements(); - setSelected(false); + searchListModel.resetSelectedState(); rightSearchResultPane.removeAll(); rightSearchResultPane.validate(); rightSearchResultPane.repaint(); @@ -799,14 +792,6 @@ public class AlphaFineDialog extends UIDialog { 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 { SearchResult myDelegate; + /** + * 第一有效的项是否被选中 + */ + private boolean isValidSelected; + public SearchListModel(SearchResult searchResult) { this.myDelegate = searchResult; } @@ -922,14 +912,14 @@ public class AlphaFineDialog extends UIDialog { } /** - * 触发选中 + * 触发选中第一有效的项 * @param element * @param index */ private void fireSelectedStateChanged(AlphaCellModel element, int index) { - if (element.hasAction() && !isSelected()) { + if (element.hasAction() && !isValidSelected()) { searchResultList.setSelectedIndex(index); - setSelected(true); + setValidSelected(true); } } @@ -961,6 +951,21 @@ public class AlphaFineDialog extends UIDialog { public void removeAllElements() { this.myDelegate.clear(); } + + /** + * 重置选中状态 + */ + public void resetSelectedState() { + setValidSelected(false); + } + + public boolean isValidSelected() { + return isValidSelected; + } + + private void setValidSelected(boolean selected) { + isValidSelected = selected; + } } } \ No newline at end of file