From 9698797803b47c951386a9b9bb213639cf0fac3e Mon Sep 17 00:00:00 2001 From: "yaoh.wu" Date: Mon, 4 Jun 2018 01:23:36 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-8449=20=E4=BA=A4=E4=BA=92=E9=97=AE?= =?UTF-8?q?=E9=A2=98bug=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/remote/ui/UserManagerPane.java | 40 +++++++++++-------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/designer-base/src/com/fr/design/remote/ui/UserManagerPane.java b/designer-base/src/com/fr/design/remote/ui/UserManagerPane.java index 6215e7263..e1dcfa62c 100644 --- a/designer-base/src/com/fr/design/remote/ui/UserManagerPane.java +++ b/designer-base/src/com/fr/design/remote/ui/UserManagerPane.java @@ -11,27 +11,16 @@ import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itextfield.UITextField; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; -import com.fr.design.remote.ui.list.AddedMemberList; -import com.fr.design.remote.ui.list.AddedMemberListCellRender; -import com.fr.design.remote.ui.list.AddingMemberList; -import com.fr.design.remote.ui.list.AddingMemberListCellRender; -import com.fr.design.remote.ui.list.MemberListSelectedChangeListener; +import com.fr.design.remote.ui.list.*; import com.fr.env.RemoteDesignMember; import com.fr.env.operator.decision.DecisionOperator; import com.fr.general.Inter; import com.fr.stable.StringUtils; import com.fr.third.guava.collect.ImmutableList; -import javax.swing.BorderFactory; -import javax.swing.DefaultListModel; -import javax.swing.JPanel; -import javax.swing.ListSelectionModel; -import javax.swing.SwingWorker; +import javax.swing.*; import javax.swing.border.EmptyBorder; -import java.awt.BorderLayout; -import java.awt.Component; -import java.awt.Dimension; -import java.awt.FlowLayout; +import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyAdapter; @@ -101,15 +90,22 @@ public class UserManagerPane extends BasicPane { private DefaultListModel addedListModel; + /** + * 左侧列表变动事件 + */ private MemberListSelectedChangeListener addingListChangeListener = new MemberListSelectedChangeListener() { @Override public void selectedChange() { - resetAddedMembers(); + // 右侧列表发生变化后,将右侧列表中选中但是在左侧列表中没有的成员添加进来,同时移除取消选中的 sync2AddedMembersFromAdding(); + // 刷新右侧列表显示 addToAddedMemberList(); } }; + /** + * 右侧列表变动事件 + */ private MemberListSelectedChangeListener addedListChangeListener = new MemberListSelectedChangeListener() { @Override public void selectedChange() { @@ -123,6 +119,8 @@ public class UserManagerPane extends BasicPane { String.valueOf(addedMembers.size()) ) ); + // 刷新左侧列表显示 + addToMemberList(); } }; @@ -228,6 +226,12 @@ public class UserManagerPane extends BasicPane { private void addToMemberList() { addingListModel.clear(); for (RemoteDesignMember member : addingMembers) { + // 如果包含在右侧列表中,那么左侧列表默认选中 + if (addedMembers.contains(member)) { + member.setSelected(true); + } else { + member.setSelected(false); + } addingListModel.addElement(member); } addingList.revalidate(); @@ -282,7 +286,11 @@ public class UserManagerPane extends BasicPane { // shallow copy addingListModel.copyInto(members); for (RemoteDesignMember member : members) { - if (member.isSelected()) { + + if (!member.isSelected()) { + addedMembers.remove(member); + } + if (member.isSelected() && !addedMembers.contains(member)) { addedMembers.add(member); } }