Browse Source

REPORT-6700 远程设计权限

master
yaoh.wu 7 years ago
parent
commit
8a81a5d533
  1. 12
      designer-base/src/com/fr/design/remote/RemoteMember.java
  2. 49
      designer-base/src/com/fr/design/remote/Utils.java
  3. BIN
      designer-base/src/com/fr/design/remote/images/icon_Remove_x.png
  4. 4
      designer-base/src/com/fr/design/remote/ui/AuthorityListControlPane.java
  5. 144
      designer-base/src/com/fr/design/remote/ui/UserManagerPane.java
  6. 35
      designer-base/src/com/fr/design/remote/ui/list/AddedMemberList.java
  7. 44
      designer-base/src/com/fr/design/remote/ui/list/AddedMemberListCellRender.java
  8. 47
      designer-base/src/com/fr/design/remote/ui/list/MemberList.java
  9. 13
      designer-base/src/com/fr/design/remote/ui/list/MemberListCellRender.java

12
designer-base/src/com/fr/design/remote/RemoteMember.java

@ -4,8 +4,11 @@ public class RemoteMember {
public static final RemoteMember DEFAULT_MEMBER = new RemoteMember("查询中..."); public static final RemoteMember DEFAULT_MEMBER = new RemoteMember("查询中...");
private String name; private String name;
private boolean selected;
public RemoteMember(String name) { public RemoteMember(String name) {
this.name = name; this.name = name;
} }
@ -17,4 +20,13 @@ public class RemoteMember {
public void setName(String name) { public void setName(String name) {
this.name = name; this.name = name;
} }
public boolean isSelected() {
return selected;
}
public void setSelected(boolean selected) {
this.selected = selected;
}
} }

49
designer-base/src/com/fr/design/remote/Utils.java

@ -0,0 +1,49 @@
package com.fr.design.remote;
import com.fr.stable.StringUtils;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Random;
public class Utils {
private static final String SOURCES =
"._-~`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890";
private Utils() {
}
public static Collection<? extends RemoteMember> getRemoteMember(String keyword) {
// todo 使用决策平台api获取决策平台用户
List<RemoteMember> res = new ArrayList<>();
for (int i = 0; i < 30; i++) {
RemoteMember remoteMember = new RemoteMember(generate());
if (StringUtils.isEmpty(keyword)) {
res.add(remoteMember);
continue;
}
if (remoteMember.getName().contains(keyword)) {
res.add(remoteMember);
}
}
return res;
}
/**
* Generate a random string.
*
* @return String string
*/
private static String generate() {
Random random = new Random();
char[] text = new char[6];
for (int i = 0; i < 6; i++) {
text[i] = Utils.SOURCES.charAt(random.nextInt(Utils.SOURCES.length()));
}
return new String(text);
}
}

BIN
designer-base/src/com/fr/design/remote/images/icon_Remove_x.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 238 B

4
designer-base/src/com/fr/design/remote/ui/AuthorityListControlPane.java

@ -217,7 +217,7 @@ public class AuthorityListControlPane extends BasicPane {
* 获取选中的名字 * 获取选中的名字
*/ */
public String getSelectedName() { public String getSelectedName() {
RemoteDesignAuthority authority = (RemoteDesignAuthority) this.authorityList.getSelectedValue(); RemoteDesignAuthority authority = this.authorityList.getSelectedValue();
return authority == null ? null : authority.getName(); return authority == null ? null : authority.getName();
} }
@ -412,7 +412,7 @@ public class AuthorityListControlPane extends BasicPane {
} }
public void populate() { public void populate() {
authority = (RemoteDesignAuthority) AuthorityListControlPane.this.authorityList.getSelectedValue(); authority = AuthorityListControlPane.this.authorityList.getSelectedValue();
if (authority == null) { if (authority == null) {
return; return;

144
designer-base/src/com/fr/design/remote/ui/UserManagerPane.java

@ -4,10 +4,13 @@ import com.fr.design.border.UITitledBorder;
import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.BasicPane;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itextfield.UITextField; import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper; import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.remote.RemoteMember; import com.fr.design.remote.RemoteMember;
import com.fr.design.remote.Utils;
import com.fr.design.remote.ui.list.AddedMemberList;
import com.fr.design.remote.ui.list.MemberList; import com.fr.design.remote.ui.list.MemberList;
import com.fr.design.remote.ui.list.MemberListCellRender; import com.fr.design.remote.ui.list.MemberListCellRender;
import com.fr.general.Inter; import com.fr.general.Inter;
@ -15,10 +18,17 @@ import com.fr.general.Inter;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.DefaultListModel; import javax.swing.DefaultListModel;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.ListSelectionModel;
import javax.swing.SwingWorker;
import javax.swing.border.EmptyBorder; import javax.swing.border.EmptyBorder;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Component; import java.awt.Component;
import java.awt.Dimension;
import java.awt.FlowLayout; import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -28,9 +38,58 @@ import java.util.List;
*/ */
public class UserManagerPane extends BasicPane { public class UserManagerPane extends BasicPane {
/**
* 获取的决策平台成员
*/
private List<RemoteMember> members = new ArrayList<>(); private List<RemoteMember> members = new ArrayList<>();
/**
DefaultListModel<RemoteMember> listModel = new DefaultListModel<>(); * 添加到设计的决策平台成员
*/
private List<RemoteMember> addedMembers = new ArrayList<>();
/**
* 决策平台成员列表model
*/
private DefaultListModel<RemoteMember> listModel = new DefaultListModel<>();
/**
* 搜索输入框
*/
private UITextField keyField = new UITextField();
/**
* 搜索按钮
*/
private UIButton keyButton = new UIButton();
/**
* 搜索按钮绑定事件
*/
private ActionListener keyButtonActionListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
searchMembers(keyField.getText());
}
};
/**
* 输入框绑定事件
*/
private KeyAdapter keyFieldKeyListener = new KeyAdapter() {
@Override
public void keyReleased(KeyEvent e) {
//判断按下的键是否是回车键
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
searchMembers(keyField.getText());
}
}
};
/**
* 添加到设计的决策成员计数标签
*/
private UILabel countLabel = new UILabel();
/**
* 添加到设计的决策成员计数标签
*/
private DefaultListModel<Object> addedListModel;
public UserManagerPane() { public UserManagerPane() {
@ -39,7 +98,7 @@ public class UserManagerPane extends BasicPane {
this.add( this.add(
TableLayoutHelper.createTableLayoutPane( TableLayoutHelper.createTableLayoutPane(
new Component[][]{ new Component[][]{
new Component[]{createLeftPanel(), new JPanel()} new Component[]{createLeftPanel(), createRightPanel()}
}, },
new double[]{TableLayout.FILL}, new double[]{TableLayout.FILL},
new double[]{TableLayout.FILL, TableLayout.FILL} new double[]{TableLayout.FILL, TableLayout.FILL}
@ -63,18 +122,23 @@ public class UserManagerPane extends BasicPane {
); );
// 搜索 // 搜索
UITextField searchKeyInput = new UITextField();
UIButton searchButton = new UIButton("搜索");
JPanel searchPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); JPanel searchPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
searchPanel.setBorder(BorderFactory.createEmptyBorder()); searchPanel.setBorder(BorderFactory.createEmptyBorder());
searchPanel.add(searchKeyInput); keyField.setPreferredSize(new Dimension(200, 20));
searchPanel.add(searchButton); keyField.requestFocus();
keyField.addKeyListener(keyFieldKeyListener);
keyButton.setText("搜索");
keyButton.addActionListener(keyButtonActionListener);
searchPanel.add(keyField);
searchPanel.add(keyButton);
// 内容列表 // 内容列表
listModel = new DefaultListModel<>(); listModel = new DefaultListModel<>();
MemberList list = new MemberList(listModel); final MemberList list = new MemberList(listModel);
list.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
list.setCellRenderer(new MemberListCellRender()); list.setCellRenderer(new MemberListCellRender());
resetMembers(); resetMembers();
addContentToList(); addToMemberList();
UIScrollPane listPane = new UIScrollPane(list); UIScrollPane listPane = new UIScrollPane(list);
listPane.setBorder(BorderFactory.createEmptyBorder()); listPane.setBorder(BorderFactory.createEmptyBorder());
@ -84,15 +148,73 @@ public class UserManagerPane extends BasicPane {
} }
private void addContentToList() { private JPanel createRightPanel() {
listModel.removeAllElements(); JPanel content = new JPanel(new BorderLayout());
content.setBorder(
BorderFactory.createCompoundBorder(
new EmptyBorder(6, 0, 0, 0),
UITitledBorder.createBorderWithTitle(Inter.getLocText("已选择的设计成员")))
);
// 计数
countLabel.setText(Inter.getLocText("已选择{R1}人", "0"));
addedListModel = new DefaultListModel<>();
final AddedMemberList addedList = new AddedMemberList(listModel);
addedList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
addedList.setCellRenderer(new MemberListCellRender());
resetAddedMembers();
addToAddedMemberList();
UIScrollPane listPane = new UIScrollPane(addedList);
listPane.setBorder(BorderFactory.createEmptyBorder());
content.add(countLabel, BorderLayout.NORTH);
content.add(listPane, BorderLayout.CENTER);
return content;
}
private void addToMemberList() {
listModel.clear();
for (RemoteMember member : members) { for (RemoteMember member : members) {
listModel.addElement(member); listModel.addElement(member);
} }
} }
private void addToAddedMemberList() {
addedListModel.clear();
for (RemoteMember member : addedMembers) {
addedListModel.addElement(member);
}
}
private void resetMembers() { private void resetMembers() {
members.clear(); members.clear();
members.add(RemoteMember.DEFAULT_MEMBER); members.add(RemoteMember.DEFAULT_MEMBER);
} }
private void resetAddedMembers() {
addedMembers.clear();
}
private void searchMembers(final String keyword) {
final SwingWorker getMemberWorker = new SwingWorker<List<RemoteMember>, Void>() {
@Override
protected List<RemoteMember> doInBackground() {
members.clear();
members.addAll(Utils.getRemoteMember(keyword));
return members;
}
@Override
protected void done() {
addToMemberList();
}
};
getMemberWorker.execute();
}
} }

35
designer-base/src/com/fr/design/remote/ui/list/AddedMemberList.java

@ -0,0 +1,35 @@
package com.fr.design.remote.ui.list;
import com.fr.design.remote.RemoteMember;
import javax.swing.JList;
import javax.swing.ListModel;
import java.awt.Color;
import java.util.Vector;
public class AddedMemberList extends JList<RemoteMember> {
public AddedMemberList() {
super();
init(this.getModel().getSize());
}
public AddedMemberList(ListModel<RemoteMember> dataModel) {
super(dataModel);
init(dataModel.getSize());
}
public AddedMemberList(RemoteMember[] listData) {
super(listData);
init(listData.length);
}
public AddedMemberList(Vector<? extends RemoteMember> listData) {
super(listData);
init(listData.size());
}
private void init(int size) {
setBackground(new Color(0xF5F5F7));
}
}

44
designer-base/src/com/fr/design/remote/ui/list/AddedMemberListCellRender.java

@ -0,0 +1,44 @@
package com.fr.design.remote.ui.list;
import com.fr.base.BaseUtils;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.remote.RemoteMember;
import javax.swing.BorderFactory;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.ListCellRenderer;
import java.awt.Component;
import java.awt.FlowLayout;
public class AddedMemberListCellRender extends JPanel implements ListCellRenderer<RemoteMember> {
private UILabel label;
private UIButton uiButton;
public AddedMemberListCellRender() {
this.setBorder(BorderFactory.createEmptyBorder());
this.setLayout(new FlowLayout(FlowLayout.LEFT));
label = new UILabel();
label.setIcon(BaseUtils.readIcon("com/fr/design/remote/images/icon_Member_normal@1x.png"));
uiButton.setIcon(BaseUtils.readIcon("com/fr/design/remote/images/icon_Remove_x.png"));
this.add(label);
this.add(uiButton);
}
@Override
public Component getListCellRendererComponent(JList<? extends RemoteMember> list, RemoteMember member, int index, boolean isSelected, boolean cellHasFocus) {
this.setLabelText(member.getName());
return this;
}
private void setLabelText(String name) {
label.setText(name);
}
}

47
designer-base/src/com/fr/design/remote/ui/list/MemberList.java

@ -5,33 +5,70 @@ import com.fr.design.remote.RemoteMember;
import javax.swing.JList; import javax.swing.JList;
import javax.swing.ListModel; import javax.swing.ListModel;
import java.awt.Color; import java.awt.Color;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.Vector; import java.util.Vector;
public class MemberList extends JList<RemoteMember> { public class MemberList extends JList<RemoteMember> {
private boolean[] selects;
public MemberList() { public MemberList() {
super(); super();
init(); init(this.getModel().getSize());
} }
public MemberList(ListModel<RemoteMember> dataModel) { public MemberList(ListModel<RemoteMember> dataModel) {
super(dataModel); super(dataModel);
init(); init(dataModel.getSize());
} }
public MemberList(RemoteMember[] listData) { public MemberList(RemoteMember[] listData) {
super(listData); super(listData);
init(); init(listData.length);
} }
public MemberList(Vector<? extends RemoteMember> listData) { public MemberList(Vector<? extends RemoteMember> listData) {
super(listData); super(listData);
init(); init(listData.size());
}
@Override
public void setModel(ListModel<RemoteMember> model) {
super.setModel(model);
selects = new boolean[this.getModel().getSize()];
} }
private void init() { private void init(int size) {
selects = new boolean[size];
setBackground(new Color(0xF5F5F7)); setBackground(new Color(0xF5F5F7));
this.addMouseListener(new MouseAdapter() {
@Override
public void mouseReleased(MouseEvent e) {
super.mouseReleased(e);
displaySelected();
}
});
this.addKeyListener(new KeyAdapter() {
@Override
public void keyReleased(KeyEvent e) {
super.keyReleased(e);
if (e.getKeyCode() == KeyEvent.VK_SPACE) {
displaySelected();
}
}
});
}
private void displaySelected() {
RemoteMember member = getSelectedValue();
member.setSelected(!member.isSelected());
revalidate();
repaint();
} }
} }

13
designer-base/src/com/fr/design/remote/ui/list/MemberListCellRender.java

@ -21,10 +21,13 @@ public class MemberListCellRender extends JPanel implements ListCellRenderer<Rem
public MemberListCellRender() { public MemberListCellRender() {
this.setBorder(BorderFactory.createEmptyBorder()); this.setBorder(BorderFactory.createEmptyBorder());
this.setLayout(new FlowLayout(FlowLayout.LEFT)); this.setLayout(new FlowLayout(FlowLayout.LEFT));
label = new UILabel(); label = new UILabel();
label.setIcon(BaseUtils.readIcon("com/fr/design/remote/images/icon_Member_normal@1x.png")); label.setIcon(BaseUtils.readIcon("com/fr/design/remote/images/icon_Member_normal@1x.png"));
check = new UICheckBox(); check = new UICheckBox();
check.setSelected(false); check.setSelected(false);
this.add(label); this.add(label);
this.add(check); this.add(check);
} }
@ -32,14 +35,12 @@ public class MemberListCellRender extends JPanel implements ListCellRenderer<Rem
@Override @Override
public Component getListCellRendererComponent(JList list, RemoteMember member, int index, boolean isSelected, boolean cellHasFocus) { public Component getListCellRendererComponent(JList list, RemoteMember member, int index, boolean isSelected, boolean cellHasFocus) {
this.setLabelName(member.getName()); this.setLabelText(member.getName());
check.setSelected(false); check.setSelected(member.isSelected());
return this; return this;
} }
private void setLabelName(String name) { private void setLabelText(String name) {
label.setName(name); label.setText(name);
} }
} }

Loading…
Cancel
Save