yaoh.wu
7 years ago
9 changed files with 324 additions and 24 deletions
@ -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); |
||||
} |
||||
} |
After Width: | Height: | Size: 238 B |
@ -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)); |
||||
} |
||||
} |
@ -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); |
||||
} |
||||
} |
Loading…
Reference in new issue