forked from fanruan/design
plough
7 years ago
30 changed files with 525 additions and 272 deletions
@ -0,0 +1,40 @@
|
||||
package com.fr.design.extra.exe; |
||||
|
||||
import com.fr.design.extra.PluginUtils; |
||||
import com.fr.design.extra.Process; |
||||
import com.fr.json.JSONArray; |
||||
import com.fr.plugin.context.PluginContext; |
||||
import com.fr.plugin.manage.PluginManager; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @author kerry |
||||
* @date 2018/6/1 |
||||
*/ |
||||
public class GetInstalledPluginsExecutor implements Executor { |
||||
private String result ="[]"; |
||||
@Override |
||||
public String getTaskFinishMessage() { |
||||
return result; |
||||
} |
||||
|
||||
@Override |
||||
public Command[] getCommands() { |
||||
return new Command[]{ |
||||
new Command() { |
||||
@Override |
||||
public String getExecuteMessage() { |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public void run(Process<String> process) { |
||||
List<PluginContext> plugins = PluginManager.getContexts(); |
||||
JSONArray ja = PluginUtils.transferPluginToJson(plugins.toArray(new PluginContext[plugins.size()])); |
||||
result = ja.toString(); |
||||
} |
||||
} |
||||
}; |
||||
} |
||||
} |
@ -1,72 +0,0 @@
|
||||
package com.fr.design.remote; |
||||
|
||||
import com.fr.general.Inter; |
||||
|
||||
public class RemoteMember { |
||||
|
||||
public static final RemoteMember DEFAULT_MEMBER = |
||||
new RemoteMember(Inter.getLocText("FR-Designer_Remote_Design_Loading")); |
||||
|
||||
|
||||
private String username; |
||||
private String realName; |
||||
private String userId; |
||||
|
||||
private boolean selected; |
||||
|
||||
public RemoteMember() { |
||||
|
||||
} |
||||
|
||||
public RemoteMember(String username) { |
||||
this.username = username; |
||||
} |
||||
|
||||
public RemoteMember username(String username) { |
||||
this.username = username; |
||||
return this; |
||||
} |
||||
|
||||
public RemoteMember realName(String realName) { |
||||
this.realName = realName; |
||||
return this; |
||||
} |
||||
|
||||
public RemoteMember userId(String userId) { |
||||
this.userId = userId; |
||||
return this; |
||||
} |
||||
|
||||
public String getRealName() { |
||||
return realName; |
||||
} |
||||
|
||||
public void setRealName(String realName) { |
||||
this.realName = realName; |
||||
} |
||||
|
||||
public String getUserId() { |
||||
return userId; |
||||
} |
||||
|
||||
public void setUserId(String userId) { |
||||
this.userId = userId; |
||||
} |
||||
|
||||
public String getUsername() { |
||||
return username; |
||||
} |
||||
|
||||
public void setUsername(String username) { |
||||
this.username = username; |
||||
} |
||||
|
||||
|
||||
public boolean isSelected() { |
||||
return selected; |
||||
} |
||||
|
||||
public void setSelected(boolean selected) { |
||||
this.selected = selected; |
||||
} |
||||
} |
@ -1,47 +0,0 @@
|
||||
package com.fr.design.remote; |
||||
|
||||
import com.fr.base.FRContext; |
||||
import com.fr.decision.webservice.bean.user.UserAdditionBean; |
||||
import com.fr.decision.webservice.v10.user.UserService; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.Collection; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
public class Utils { |
||||
|
||||
|
||||
private Utils() { |
||||
} |
||||
|
||||
public static Collection<? extends RemoteMember> getRemoteMember(String keyword) { |
||||
|
||||
List<UserAdditionBean> userBeans = new ArrayList<>(); |
||||
try { |
||||
Map<String, Object> result = |
||||
UserService.getInstance().getAllUsers( |
||||
FRContext.getCurrentEnv().getUser(), |
||||
1, |
||||
10, |
||||
keyword, |
||||
"", |
||||
true); |
||||
userBeans = (List<UserAdditionBean>) result.get("items"); |
||||
} catch (Exception e) { |
||||
FRContext.getLogger().error(e.getMessage()); |
||||
} |
||||
|
||||
List<RemoteMember> res = new ArrayList<>(); |
||||
|
||||
for (UserAdditionBean userBean : userBeans) { |
||||
res.add( |
||||
new RemoteMember() |
||||
.username(userBean.getUsername()) |
||||
.realName(userBean.getRealName()) |
||||
.userId(userBean.getId()) |
||||
); |
||||
} |
||||
return res; |
||||
} |
||||
} |
@ -0,0 +1,59 @@
|
||||
package com.fr.design.remote.button; |
||||
|
||||
import com.fr.base.BaseUtils; |
||||
import com.fr.design.utils.gui.GUICoreUtils; |
||||
import com.fr.stable.StringUtils; |
||||
|
||||
import javax.swing.JButton; |
||||
import javax.swing.JFrame; |
||||
import javax.swing.JPanel; |
||||
import javax.swing.WindowConstants; |
||||
import java.awt.Color; |
||||
import java.awt.GradientPaint; |
||||
import java.awt.Graphics; |
||||
import java.awt.Graphics2D; |
||||
import java.awt.Point; |
||||
|
||||
public final class IconButton extends JButton { |
||||
public IconButton() { |
||||
super(StringUtils.EMPTY); |
||||
setContentAreaFilled(false); |
||||
setFocusPainted(false); |
||||
setIcon(BaseUtils.readIcon("com/fr/design/remote/images/icon_Remove_x.png")); |
||||
setBorder(null); |
||||
} |
||||
|
||||
@Override |
||||
protected void paintBorder(Graphics g) { |
||||
} |
||||
|
||||
@Override |
||||
protected void paintComponent(Graphics g) { |
||||
final Graphics2D g2 = (Graphics2D) g.create(); |
||||
g2.setPaint( |
||||
new GradientPaint( |
||||
new Point(0, 0), |
||||
new Color(0xF5F5F7), |
||||
new Point(0, getPreferredSize().height), |
||||
new Color(0xF5F5F7) |
||||
) |
||||
); |
||||
g2.fillRect(0, 0, getPreferredSize().width, getPreferredSize().height); |
||||
g2.dispose(); |
||||
|
||||
super.paintComponent(g); |
||||
} |
||||
|
||||
public static void main(String[] args) { |
||||
JFrame jf = new JFrame("test"); |
||||
jf.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); |
||||
JPanel content = (JPanel) jf.getContentPane(); |
||||
content.setLayout(null); |
||||
IconButton a = new IconButton(); |
||||
a.setBounds(0, 0, a.getPreferredSize().width, a.getPreferredSize().height); |
||||
content.add(a); |
||||
GUICoreUtils.centerWindow(jf); |
||||
jf.setSize(400, 400); |
||||
jf.setVisible(true); |
||||
} |
||||
} |
@ -1,45 +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 com.fr.design.remote.button.IconButton; |
||||
import com.fr.env.RemoteDesignMember; |
||||
|
||||
import javax.swing.BorderFactory; |
||||
import javax.swing.JList; |
||||
import javax.swing.JPanel; |
||||
import javax.swing.ListCellRenderer; |
||||
import java.awt.Component; |
||||
import java.awt.Dimension; |
||||
import java.awt.FlowLayout; |
||||
|
||||
public class AddedMemberListCellRender extends JPanel implements ListCellRenderer<RemoteMember> { |
||||
public class AddedMemberListCellRender extends JPanel implements ListCellRenderer<RemoteDesignMember> { |
||||
|
||||
|
||||
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 = new UIButton(); |
||||
uiButton.setIcon(BaseUtils.readIcon("com/fr/design/remote/images/icon_Remove_x.png")); |
||||
label.setPreferredSize(new Dimension(270, 20)); |
||||
this.setPreferredSize(new Dimension(this.getPreferredSize().width, 25)); |
||||
|
||||
this.add(label); |
||||
this.add(uiButton); |
||||
this.add(new IconButton()); |
||||
} |
||||
|
||||
@Override |
||||
public Component getListCellRendererComponent(JList<? extends RemoteMember> list, RemoteMember member, int index, boolean isSelected, boolean cellHasFocus) { |
||||
this.setLabelText(member.getUsername()); |
||||
public Component getListCellRendererComponent(JList<? extends RemoteDesignMember> list, RemoteDesignMember member, int index, boolean isSelected, boolean cellHasFocus) { |
||||
this.setLabelText(member.getRealName() + "(" + member.getUsername() + ")"); |
||||
return this; |
||||
} |
||||
|
||||
private void setLabelText(String name) { |
||||
label.setText(name); |
||||
} |
||||
|
||||
} |
||||
|
Loading…
Reference in new issue