Browse Source
* commit '1802485b2b3b0d819b682806235d6bba20106d8b': (118 commits) REPORT-22207 设计器不显示主界面 CHART-10603 包名和类型修改 CHART-10603 getSubName方法修改 CHART-10603 国际化方法修改 CHART-10603 旧版本图表的name和path处理 REPORT-20549 远程设计改进(设计权限加上角色) 无JIRA任务,sonar问题修复 REPORT-22004 新版本插件管理,删除提示图标错误 KERNEL-418 更新升级重构 REPORT-20549 远程设计改进(设计权限加上角色) CHART-10233 泛型修改 REPORT-19945 设计器启动优化 无jira任务 提交多了 REPORT-20327 sonar问题修复 无jira任务 继承替换 REPORT-19945 设计器启动优化和启动速度监控 冲突 . ct REPORT-21408 sumprecise 函数问题 公式需要变蓝, 改第三方库 ...research/11.0
zheng
5 years ago
319 changed files with 7467 additions and 6208 deletions
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,14 @@
|
||||
package com.fr.design.remote.constants; |
||||
|
||||
/** |
||||
* @author Lucian.Chen |
||||
* @version 10.0 |
||||
* Created by Lucian.Chen on 2019/9/23 |
||||
*/ |
||||
public class MemberIcon { |
||||
|
||||
public static final String CUSTOM_ROLE_ICON = "com/fr/design/remote/images/icon_Custom_Role_normal@1x.png"; |
||||
|
||||
public static final String USER_ICON = "com/fr/design/remote/images/icon_Member_normal@1x.png"; |
||||
|
||||
} |
@ -0,0 +1,440 @@
|
||||
package com.fr.design.remote.ui; |
||||
|
||||
import com.fr.base.BaseUtils; |
||||
import com.fr.design.constants.LayoutConstants; |
||||
import com.fr.design.dialog.BasicPane; |
||||
import com.fr.design.gui.ibutton.UIButton; |
||||
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.i18n.Toolkit; |
||||
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.stable.StringUtils; |
||||
import com.fr.third.guava.collect.ImmutableList; |
||||
import com.fr.workspace.WorkContext; |
||||
import com.fr.workspace.server.authority.RemoteDesignMember; |
||||
|
||||
import javax.swing.BorderFactory; |
||||
import javax.swing.DefaultListModel; |
||||
import javax.swing.JPanel; |
||||
import javax.swing.JViewport; |
||||
import javax.swing.ListSelectionModel; |
||||
import javax.swing.SwingWorker; |
||||
import javax.swing.event.DocumentEvent; |
||||
import javax.swing.event.DocumentListener; |
||||
import java.awt.BorderLayout; |
||||
import java.awt.Color; |
||||
import java.awt.Component; |
||||
import java.awt.Dimension; |
||||
import java.awt.FlowLayout; |
||||
import java.awt.event.ActionEvent; |
||||
import java.awt.event.ActionListener; |
||||
import java.awt.event.AdjustmentEvent; |
||||
import java.awt.event.AdjustmentListener; |
||||
import java.awt.event.KeyAdapter; |
||||
import java.awt.event.KeyEvent; |
||||
import java.awt.event.MouseWheelEvent; |
||||
import java.awt.event.MouseWheelListener; |
||||
import java.util.ArrayList; |
||||
import java.util.Arrays; |
||||
import java.util.Collection; |
||||
import java.util.List; |
||||
|
||||
|
||||
/** |
||||
* 选择设计角色、用户面板的基类 |
||||
* @author yaohwu |
||||
*/ |
||||
public abstract class AbstractManagerPane extends BasicPane { |
||||
|
||||
/** |
||||
* 每页个数 |
||||
*/ |
||||
private static final int DEFAULT_NUM_EACH_PAGE = 50; |
||||
|
||||
/** |
||||
* 获取的决策平台用户 |
||||
*/ |
||||
private final List<RemoteDesignMember> addingMembers = new ArrayList<>(); |
||||
/** |
||||
* 添加到设计的决策平台用户 |
||||
*/ |
||||
private List<RemoteDesignMember> addedMembers = new ArrayList<>(); |
||||
|
||||
/** |
||||
* 决策平台用户列表model |
||||
*/ |
||||
private DefaultListModel<RemoteDesignMember> addingListModel = new DefaultListModel<>(); |
||||
/** |
||||
* 搜索输入框 |
||||
*/ |
||||
private UITextField keyField = new UITextField(); |
||||
/** |
||||
* 搜索按钮 |
||||
*/ |
||||
private UIButton keyButton = new UIButton(); |
||||
|
||||
/** |
||||
* 搜索按钮绑定事件 |
||||
*/ |
||||
private ActionListener keyButtonActionListener = new ActionListener() { |
||||
@Override |
||||
public void actionPerformed(ActionEvent e) { |
||||
searchAddingMembers(keyWord); |
||||
} |
||||
}; |
||||
|
||||
/** |
||||
* 输入框绑定事件 |
||||
*/ |
||||
private KeyAdapter keyFieldKeyListener = new KeyAdapter() { |
||||
|
||||
@Override |
||||
public void keyPressed(KeyEvent e) { |
||||
// 判断按下的键是否是回车键
|
||||
// 对话框回车键绑定的是对话框的确定按钮
|
||||
if (e.getKeyCode() == KeyEvent.VK_ENTER) { |
||||
searchAddingMembers(keyWord); |
||||
// has been processed
|
||||
e.consume(); |
||||
} |
||||
} |
||||
}; |
||||
/** |
||||
* 添加到设计的决策用户计数标签 |
||||
*/ |
||||
private UILabel countLabel = new UILabel(); |
||||
/** |
||||
* 添加到设计的决策用户计数标签 |
||||
*/ |
||||
private DefaultListModel<RemoteDesignMember> addedListModel; |
||||
|
||||
|
||||
/** |
||||
* 左侧列表变动事件 |
||||
*/ |
||||
private MemberListSelectedChangeListener addingListChangeListener = new MemberListSelectedChangeListener() { |
||||
@Override |
||||
public void selectedChange() { |
||||
sync2AddedMembersFromAdding(); |
||||
// 刷新右侧列表显示
|
||||
addToAddedMemberList(); |
||||
} |
||||
}; |
||||
|
||||
/** |
||||
* 右侧列表变动事件 |
||||
*/ |
||||
private MemberListSelectedChangeListener addedListChangeListener = new MemberListSelectedChangeListener() { |
||||
@Override |
||||
public void selectedChange() { |
||||
addingList.revalidate(); |
||||
addingList.repaint(); |
||||
resetAddedMembers(); |
||||
sync2AddedMembersFormAdded(); |
||||
// 不需要重复更新右侧列表显示 但是更新一下计数显示
|
||||
countLabel.setText( |
||||
Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Selected_Member_Count", |
||||
String.valueOf(addedMembers.size()) |
||||
) |
||||
); |
||||
// 刷新左侧列表显示
|
||||
addToMemberList(); |
||||
} |
||||
}; |
||||
|
||||
|
||||
/** |
||||
* 已经添加的用户列表 |
||||
*/ |
||||
private AddedMemberList addedList; |
||||
/** |
||||
* 待添加的用户列表 |
||||
*/ |
||||
private AddingMemberList addingList; |
||||
|
||||
/** |
||||
* 搜索关键字 |
||||
*/ |
||||
private String keyWord; |
||||
|
||||
/** |
||||
* 搜索关键词变更监听 |
||||
*/ |
||||
private transient DocumentListener documentListener = new DocumentListener() { |
||||
@Override |
||||
public void insertUpdate(DocumentEvent e) { |
||||
keyWord = keyField.getText(); |
||||
} |
||||
|
||||
@Override |
||||
public void removeUpdate(DocumentEvent e) { |
||||
keyWord = keyField.getText(); |
||||
} |
||||
|
||||
@Override |
||||
public void changedUpdate(DocumentEvent e) { |
||||
keyWord = keyField.getText(); |
||||
} |
||||
}; |
||||
|
||||
/** |
||||
* 当前分页计数 |
||||
*/ |
||||
private int pageNum = 1; |
||||
|
||||
|
||||
public AbstractManagerPane() { |
||||
this.setBorder(BorderFactory.createEmptyBorder(0, 4, 0, 4)); |
||||
this.setLayout(new BorderLayout()); |
||||
this.add( |
||||
TableLayoutHelper.createCommonTableLayoutPane( |
||||
new Component[][]{ |
||||
new Component[]{createLeftPanel(), createRightPanel()} |
||||
}, |
||||
new double[]{TableLayout.FILL}, |
||||
new double[]{TableLayout.FILL, TableLayout.FILL}, |
||||
LayoutConstants.VGAP_LARGE |
||||
), |
||||
BorderLayout.CENTER); |
||||
} |
||||
|
||||
public void populate(List<RemoteDesignMember> addedMembers) { |
||||
|
||||
// 已选信息
|
||||
resetAddedMembers(); |
||||
this.addedMembers.addAll(addedMembers); |
||||
|
||||
// 刷新右侧面板
|
||||
addToAddedMemberList(); |
||||
|
||||
// 刷新左侧展示信息
|
||||
addToMemberList(); |
||||
} |
||||
|
||||
|
||||
@Override |
||||
protected String title4PopupWindow() { |
||||
// 选择设计用户
|
||||
return Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Choose_User"); |
||||
} |
||||
|
||||
protected abstract JPanel leftPanel(); |
||||
|
||||
private JPanel createLeftPanel() { |
||||
JPanel content = leftPanel(); |
||||
|
||||
// 搜索
|
||||
JPanel searchPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 5)); |
||||
searchPanel.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); |
||||
keyField.setPreferredSize(new Dimension(270, 20)); |
||||
keyField.requestFocus(); |
||||
keyField.addKeyListener(keyFieldKeyListener); |
||||
keyField.getDocument().addDocumentListener(documentListener); |
||||
keyButton.setIcon(BaseUtils.readIcon("com/fr/design/images/buttonicon/user_search_normal.png")); |
||||
keyButton.setToolTipText(Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Search")); |
||||
keyButton.addActionListener(keyButtonActionListener); |
||||
searchPanel.add(keyField); |
||||
searchPanel.add(keyButton); |
||||
|
||||
// 内容列表
|
||||
addingListModel = new DefaultListModel<>(); |
||||
addingList = new AddingMemberList(addingListModel); |
||||
addingList.setCellRenderer(getAddingMemberListCellRender()); |
||||
addingList.addSelectedChangeListener(addingListChangeListener); |
||||
resetMembers(); |
||||
addToMemberList(); |
||||
searchAddingMembers(StringUtils.EMPTY); |
||||
final UIScrollPane listPane = new UIScrollPane(addingList); |
||||
listPane.addMouseWheelListener(new MouseWheelListener() { |
||||
@Override |
||||
public void mouseWheelMoved(MouseWheelEvent e) { |
||||
JViewport vp = listPane.getViewport(); |
||||
if (vp.getView().getHeight() <= vp.getHeight() + vp.getViewPosition().y) { |
||||
loadMoreAddingMembers(keyWord, DEFAULT_NUM_EACH_PAGE); |
||||
} |
||||
} |
||||
}); |
||||
listPane.getVerticalScrollBar().addAdjustmentListener(new AdjustmentListener() { |
||||
@Override |
||||
public void adjustmentValueChanged(AdjustmentEvent e) { |
||||
JViewport vp = listPane.getViewport(); |
||||
if (vp.getView().getHeight() <= vp.getHeight() + vp.getViewPosition().y && e.getValueIsAdjusting()) { |
||||
loadMoreAddingMembers(keyWord, DEFAULT_NUM_EACH_PAGE); |
||||
} |
||||
} |
||||
}); |
||||
listPane.setBorder(BorderFactory.createEmptyBorder()); |
||||
|
||||
content.add(searchPanel, BorderLayout.NORTH); |
||||
content.add(listPane, BorderLayout.CENTER); |
||||
return content; |
||||
} |
||||
|
||||
protected abstract AddingMemberListCellRender getAddingMemberListCellRender(); |
||||
|
||||
protected abstract AddedMemberListCellRender getAddedMemberListCellRender(); |
||||
|
||||
protected abstract JPanel rightPanel(); |
||||
|
||||
private JPanel createRightPanel() { |
||||
JPanel content = rightPanel(); |
||||
|
||||
// 计数
|
||||
countLabel.setText( |
||||
// 已选择{}人
|
||||
Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Selected_Member_Count", |
||||
String.valueOf(addedMembers.size())) |
||||
); |
||||
countLabel.setBorder(BorderFactory.createEmptyBorder(7, 12, 8, 0)); |
||||
countLabel.setForeground(new Color(0x8F8F92)); |
||||
|
||||
addedListModel = new DefaultListModel<>(); |
||||
addedList = new AddedMemberList(addedListModel); |
||||
addedList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); |
||||
addedList.setCellRenderer(getAddedMemberListCellRender()); |
||||
addedList.addSelectedChangeListener(addedListChangeListener); |
||||
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() { |
||||
addingListModel.clear(); |
||||
for (RemoteDesignMember member : addingMembers) { |
||||
// 如果包含在右侧列表中,那么左侧列表默认选中
|
||||
if (addedMembers.contains(member)) { |
||||
member.setAuthority(true); |
||||
member.setSelected(true); |
||||
} else { |
||||
member.setAuthority(false); |
||||
member.setSelected(false); |
||||
} |
||||
addingListModel.addElement(member); |
||||
} |
||||
addingList.revalidate(); |
||||
addingList.repaint(); |
||||
} |
||||
|
||||
private void addToAddedMemberList() { |
||||
addedListModel.clear(); |
||||
for (RemoteDesignMember member : addedMembers) { |
||||
addedListModel.addElement(member); |
||||
} |
||||
addedList.revalidate(); |
||||
addedList.repaint(); |
||||
countLabel.setText( |
||||
Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Selected_Member_Count", |
||||
String.valueOf(addedMembers.size()) |
||||
)); |
||||
} |
||||
|
||||
private void resetMembers() { |
||||
addingMembers.clear(); |
||||
addingMembers.add(RemoteDesignMember.DEFAULT_MEMBER); |
||||
} |
||||
|
||||
private void resetAddedMembers() { |
||||
addedMembers.clear(); |
||||
} |
||||
|
||||
protected abstract Collection<RemoteDesignMember> getMembers(String userName, String keyWord); |
||||
|
||||
protected abstract Collection<RemoteDesignMember> getMembers(String userName, String keyWord, int pageNum, int count); |
||||
|
||||
private void searchAddingMembers(final String keyword) { |
||||
|
||||
final SwingWorker getMemberWorker = new SwingWorker<List<RemoteDesignMember>, Void>() { |
||||
@Override |
||||
protected List<RemoteDesignMember> doInBackground() { |
||||
String username = WorkContext.getCurrent().getConnection().getUserName(); |
||||
synchronized (addingMembers) { |
||||
addingMembers.clear(); |
||||
Collection<RemoteDesignMember> more = getMembers(username, keyword); |
||||
pageNum = 1; |
||||
if (!more.isEmpty()) { |
||||
addingMembers.addAll(more); |
||||
if (more.size() >= DEFAULT_NUM_EACH_PAGE) { |
||||
addingMembers.add(RemoteDesignMember.DEFAULT_MEMBER); |
||||
} |
||||
} |
||||
} |
||||
return addingMembers; |
||||
} |
||||
|
||||
@Override |
||||
protected void done() { |
||||
addToMemberList(); |
||||
} |
||||
}; |
||||
getMemberWorker.execute(); |
||||
} |
||||
|
||||
private void loadMoreAddingMembers(final String keyword, final int count) { |
||||
|
||||
final SwingWorker loadMoreWorker = new SwingWorker<List<RemoteDesignMember>, Void>() { |
||||
@Override |
||||
protected List<RemoteDesignMember> doInBackground() { |
||||
|
||||
String username = WorkContext.getCurrent().getConnection().getUserName(); |
||||
synchronized (addingMembers) { |
||||
addingMembers.remove(RemoteDesignMember.DEFAULT_MEMBER); |
||||
Collection<RemoteDesignMember> more = getMembers(username, keyword, pageNum + 1, count); |
||||
if (!more.isEmpty()) { |
||||
pageNum += 1; |
||||
addingMembers.addAll(more); |
||||
addingMembers.add(RemoteDesignMember.DEFAULT_MEMBER); |
||||
} |
||||
} |
||||
return addingMembers; |
||||
} |
||||
|
||||
@Override |
||||
protected void done() { |
||||
addToMemberList(); |
||||
} |
||||
}; |
||||
loadMoreWorker.execute(); |
||||
} |
||||
|
||||
|
||||
private void sync2AddedMembersFromAdding() { |
||||
RemoteDesignMember[] members = new RemoteDesignMember[addingListModel.getSize()]; |
||||
// shallow copy
|
||||
addingListModel.copyInto(members); |
||||
for (RemoteDesignMember member : members) { |
||||
|
||||
if (!member.isSelected()) { |
||||
addedMembers.remove(member); |
||||
} |
||||
if (member.isSelected() && !addedMembers.contains(member)) { |
||||
addedMembers.add(member); |
||||
} |
||||
} |
||||
} |
||||
|
||||
private void sync2AddedMembersFormAdded() { |
||||
RemoteDesignMember[] members = new RemoteDesignMember[addedListModel.getSize()]; |
||||
// shallow copy
|
||||
addedListModel.copyInto(members); |
||||
addedMembers.addAll(Arrays.asList(members)); |
||||
} |
||||
|
||||
|
||||
public ImmutableList<RemoteDesignMember> update() { |
||||
return ImmutableList.copyOf(addedMembers); |
||||
} |
||||
} |
@ -0,0 +1,38 @@
|
||||
package com.fr.design.remote.ui; |
||||
|
||||
import com.fr.base.BaseUtils; |
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.design.remote.RemoteDesignAuthorityCreator; |
||||
import com.fr.design.remote.ui.list.AuthorityListCellRenderer; |
||||
import com.fr.design.remote.ui.list.cell.AuthorityCustomRoleListCellRender; |
||||
import com.fr.report.DesignAuthority; |
||||
|
||||
public class AuthorityListCustomRolePane extends AbstractListControlPane { |
||||
|
||||
@Override |
||||
protected RemoteDesignAuthorityCreator[] getAuthorityCreators() { |
||||
return new RemoteDesignAuthorityCreator[]{ |
||||
new RemoteDesignAuthorityCreator( |
||||
// 远程设计用户
|
||||
Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Custom"), |
||||
BaseUtils.readIcon("com/fr/design/remote/images/icon_Member_normal@1x.png"), |
||||
DesignAuthority.class, |
||||
AuthorityEditorPane.class) |
||||
}; |
||||
} |
||||
|
||||
@Override |
||||
protected AuthorityListCellRenderer getAuthorityListCellRender() { |
||||
return new AuthorityCustomRoleListCellRender(); |
||||
} |
||||
|
||||
@Override |
||||
protected AbstractManagerPane getManagerPane() { |
||||
return new CustomRoleManagerPane(); |
||||
} |
||||
|
||||
@Override |
||||
protected String getKey() { |
||||
return "Fine-Design_Basic_Utils_Are_You_Sure_To_Delete_The_Role_And_Its_Design_Authorities"; |
||||
} |
||||
} |
@ -0,0 +1,38 @@
|
||||
package com.fr.design.remote.ui; |
||||
|
||||
import com.fr.base.BaseUtils; |
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.design.remote.RemoteDesignAuthorityCreator; |
||||
import com.fr.design.remote.ui.list.AuthorityListCellRenderer; |
||||
import com.fr.design.remote.ui.list.cell.AuthorityUserListCellRender; |
||||
import com.fr.report.DesignAuthority; |
||||
|
||||
public class AuthorityListUserPane extends AbstractListControlPane { |
||||
|
||||
@Override |
||||
protected RemoteDesignAuthorityCreator[] getAuthorityCreators() { |
||||
return new RemoteDesignAuthorityCreator[]{ |
||||
new RemoteDesignAuthorityCreator( |
||||
// 远程设计用户
|
||||
Toolkit.i18nText("Fine-Design_Basic_Remote_Design_User"), |
||||
BaseUtils.readIcon("com/fr/design/remote/images/icon_Member_normal@1x.png"), |
||||
DesignAuthority.class, |
||||
AuthorityEditorPane.class) |
||||
}; |
||||
} |
||||
|
||||
@Override |
||||
protected AuthorityListCellRenderer getAuthorityListCellRender() { |
||||
return new AuthorityUserListCellRender(); |
||||
} |
||||
|
||||
@Override |
||||
protected AbstractManagerPane getManagerPane() { |
||||
return new UserManagerPane(); |
||||
} |
||||
|
||||
@Override |
||||
protected String getKey() { |
||||
return "Fine-Design_Basic_Utils_Are_You_Sure_To_Delete_The_User_And_Its_Design_Authorities"; |
||||
} |
||||
} |
@ -1,36 +1,51 @@
|
||||
package com.fr.design.remote.ui; |
||||
|
||||
import com.fr.design.dialog.BasicPane; |
||||
import com.fr.design.gui.frpane.UITabbedPane; |
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.design.layout.FRGUIPaneFactory; |
||||
import com.fr.report.DesignAuthority; |
||||
|
||||
import javax.swing.BorderFactory; |
||||
import java.awt.BorderLayout; |
||||
|
||||
public class AuthorityManagerPane extends BasicPane { |
||||
|
||||
private AuthorityListControlPane list; |
||||
|
||||
private AuthorityListUserPane userList = new AuthorityListUserPane(); |
||||
private AuthorityListCustomRolePane roleList = new AuthorityListCustomRolePane(); |
||||
|
||||
public AuthorityManagerPane() { |
||||
this.setLayout(new BorderLayout()); |
||||
this.setBorder(BorderFactory.createEmptyBorder()); |
||||
|
||||
list = new AuthorityListControlPane(); |
||||
this.add(list, BorderLayout.CENTER); |
||||
} |
||||
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
||||
|
||||
//Tabbed Pane
|
||||
UITabbedPane tabbedPane = new UITabbedPane(); |
||||
this.add(tabbedPane, BorderLayout.CENTER); |
||||
|
||||
tabbedPane.addTab(Toolkit.i18nText("Fine-Design_Basic_User"), userList); |
||||
tabbedPane.addTab(Toolkit.i18nText("Fine-Design_Basic_Role"), roleList); |
||||
|
||||
} |
||||
|
||||
@Override |
||||
protected String title4PopupWindow() { |
||||
// 远程设计权限管理
|
||||
return Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Authority_Manager"); |
||||
} |
||||
|
||||
public void populate(DesignAuthority[] authorities) { |
||||
list.populate(authorities); |
||||
public void populateByUser(DesignAuthority[] authorities) { |
||||
userList.populate(authorities); |
||||
} |
||||
|
||||
public DesignAuthority[] update() { |
||||
return list.update(); |
||||
public void populateByCustom(DesignAuthority[] authorities) { |
||||
roleList.populate(authorities); |
||||
} |
||||
|
||||
public DesignAuthority[] updateByUser() { |
||||
return userList.update(); |
||||
} |
||||
|
||||
public DesignAuthority[] updateByCustom() { |
||||
return roleList.update(); |
||||
} |
||||
|
||||
} |
||||
|
@ -0,0 +1,83 @@
|
||||
package com.fr.design.remote.ui; |
||||
|
||||
import com.fr.design.border.UITitledBorder; |
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.design.remote.ui.list.AddedMemberListCellRender; |
||||
import com.fr.design.remote.ui.list.AddingMemberListCellRender; |
||||
import com.fr.design.remote.ui.list.cell.AddedCustomRoleListCellRender; |
||||
import com.fr.design.remote.ui.list.cell.AddingCustomRoleListCellRender; |
||||
import com.fr.workspace.WorkContext; |
||||
import com.fr.workspace.server.authority.RemoteDesignMember; |
||||
import com.fr.workspace.server.authority.decision.DecisionOperator; |
||||
|
||||
import javax.swing.BorderFactory; |
||||
import javax.swing.JPanel; |
||||
import javax.swing.border.EmptyBorder; |
||||
import java.awt.BorderLayout; |
||||
import java.util.Collection; |
||||
|
||||
|
||||
/** |
||||
* 选择设计角色 |
||||
*/ |
||||
public class CustomRoleManagerPane extends AbstractManagerPane { |
||||
|
||||
@Override |
||||
protected String title4PopupWindow() { |
||||
// 选择设计角色
|
||||
return Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Choose_Custom"); |
||||
} |
||||
|
||||
@Override |
||||
protected JPanel rightPanel(){ |
||||
JPanel content = new JPanel(new BorderLayout()); |
||||
|
||||
content.setBorder( |
||||
BorderFactory.createCompoundBorder( |
||||
new EmptyBorder(6, 0, 0, 0), |
||||
UITitledBorder.createBorderWithTitle( |
||||
// 已选择的设计角色
|
||||
Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Selected_Custom"), |
||||
4 |
||||
) |
||||
) |
||||
); |
||||
return content; |
||||
} |
||||
|
||||
@Override |
||||
protected JPanel leftPanel(){ |
||||
JPanel content = new JPanel(new BorderLayout()); |
||||
|
||||
content.setBorder( |
||||
BorderFactory.createCompoundBorder( |
||||
new EmptyBorder(6, 0, 0, 0), |
||||
UITitledBorder.createBorderWithTitle( |
||||
// 决策系统角色
|
||||
Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Decision_Custom"), |
||||
4) |
||||
) |
||||
); |
||||
return content; |
||||
} |
||||
|
||||
@Override |
||||
protected AddingMemberListCellRender getAddingMemberListCellRender() { |
||||
return new AddingCustomRoleListCellRender(); |
||||
} |
||||
|
||||
@Override |
||||
protected AddedMemberListCellRender getAddedMemberListCellRender() { |
||||
return new AddedCustomRoleListCellRender(); |
||||
} |
||||
|
||||
@Override |
||||
protected Collection<RemoteDesignMember> getMembers(String userName, String keyWord){ |
||||
return WorkContext.getCurrent().get(DecisionOperator.class).getCustoms(userName, keyWord); |
||||
} |
||||
|
||||
@Override |
||||
protected Collection<RemoteDesignMember> getMembers(String userName, String keyWord, int pageNum, int count){ |
||||
return WorkContext.getCurrent().get(DecisionOperator.class).getCustoms(userName, keyWord, pageNum, count); |
||||
} |
||||
} |
@ -1,450 +1,83 @@
|
||||
package com.fr.design.remote.ui; |
||||
|
||||
import com.fr.base.BaseUtils; |
||||
import com.fr.design.border.UITitledBorder; |
||||
import com.fr.design.constants.LayoutConstants; |
||||
import com.fr.design.dialog.BasicPane; |
||||
import com.fr.design.gui.ibutton.UIButton; |
||||
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.i18n.Toolkit; |
||||
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.stable.StringUtils; |
||||
import com.fr.third.guava.collect.ImmutableList; |
||||
import com.fr.design.remote.ui.list.cell.AddedUserListCellRender; |
||||
import com.fr.design.remote.ui.list.cell.AddingUserListCellRender; |
||||
import com.fr.workspace.WorkContext; |
||||
import com.fr.workspace.server.authority.RemoteDesignMember; |
||||
import com.fr.workspace.server.authority.decision.DecisionOperator; |
||||
|
||||
import javax.swing.BorderFactory; |
||||
import javax.swing.DefaultListModel; |
||||
import javax.swing.JPanel; |
||||
import javax.swing.JViewport; |
||||
import javax.swing.ListSelectionModel; |
||||
import javax.swing.SwingWorker; |
||||
import javax.swing.border.EmptyBorder; |
||||
import javax.swing.event.DocumentEvent; |
||||
import javax.swing.event.DocumentListener; |
||||
import java.awt.BorderLayout; |
||||
import java.awt.Color; |
||||
import java.awt.Component; |
||||
import java.awt.Dimension; |
||||
import java.awt.FlowLayout; |
||||
import java.awt.event.ActionEvent; |
||||
import java.awt.event.ActionListener; |
||||
import java.awt.event.AdjustmentEvent; |
||||
import java.awt.event.AdjustmentListener; |
||||
import java.awt.event.KeyAdapter; |
||||
import java.awt.event.KeyEvent; |
||||
import java.awt.event.MouseWheelEvent; |
||||
import java.awt.event.MouseWheelListener; |
||||
import java.util.ArrayList; |
||||
import java.util.Arrays; |
||||
import java.util.Collection; |
||||
import java.util.List; |
||||
|
||||
|
||||
/** |
||||
* @author yaohwu |
||||
* 选择设计用户 |
||||
*/ |
||||
public class UserManagerPane extends BasicPane { |
||||
|
||||
/** |
||||
* 每页个数 |
||||
*/ |
||||
private static final int DEFAULT_NUM_EACH_PAGE = 50; |
||||
|
||||
/** |
||||
* 获取的决策平台成员 |
||||
*/ |
||||
private final List<RemoteDesignMember> addingMembers = new ArrayList<>(); |
||||
/** |
||||
* 添加到设计的决策平台成员 |
||||
*/ |
||||
private List<RemoteDesignMember> addedMembers = new ArrayList<>(); |
||||
|
||||
/** |
||||
* 决策平台成员列表model |
||||
*/ |
||||
private DefaultListModel<RemoteDesignMember> addingListModel = new DefaultListModel<>(); |
||||
/** |
||||
* 搜索输入框 |
||||
*/ |
||||
private UITextField keyField = new UITextField(); |
||||
/** |
||||
* 搜索按钮 |
||||
*/ |
||||
private UIButton keyButton = new UIButton(); |
||||
|
||||
/** |
||||
* 搜索按钮绑定事件 |
||||
*/ |
||||
private ActionListener keyButtonActionListener = new ActionListener() { |
||||
@Override |
||||
public void actionPerformed(ActionEvent e) { |
||||
searchAddingMembers(keyWord); |
||||
} |
||||
}; |
||||
|
||||
/** |
||||
* 输入框绑定事件 |
||||
*/ |
||||
private KeyAdapter keyFieldKeyListener = new KeyAdapter() { |
||||
|
||||
@Override |
||||
public void keyPressed(KeyEvent e) { |
||||
// 判断按下的键是否是回车键
|
||||
// 对话框回车键绑定的是对话框的确定按钮
|
||||
if (e.getKeyCode() == KeyEvent.VK_ENTER) { |
||||
searchAddingMembers(keyWord); |
||||
// has been processed
|
||||
e.consume(); |
||||
} |
||||
} |
||||
}; |
||||
/** |
||||
* 添加到设计的决策成员计数标签 |
||||
*/ |
||||
private UILabel countLabel = new UILabel(); |
||||
/** |
||||
* 添加到设计的决策成员计数标签 |
||||
*/ |
||||
private DefaultListModel<RemoteDesignMember> addedListModel; |
||||
|
||||
|
||||
/** |
||||
* 左侧列表变动事件 |
||||
*/ |
||||
private MemberListSelectedChangeListener addingListChangeListener = new MemberListSelectedChangeListener() { |
||||
@Override |
||||
public void selectedChange() { |
||||
// 右侧列表发生变化后,将右侧列表中选中但是在左侧列表中没有的成员添加进来,同时移除取消选中的
|
||||
sync2AddedMembersFromAdding(); |
||||
// 刷新右侧列表显示
|
||||
addToAddedMemberList(); |
||||
} |
||||
}; |
||||
|
||||
/** |
||||
* 右侧列表变动事件 |
||||
*/ |
||||
private MemberListSelectedChangeListener addedListChangeListener = new MemberListSelectedChangeListener() { |
||||
@Override |
||||
public void selectedChange() { |
||||
addingList.revalidate(); |
||||
addingList.repaint(); |
||||
resetAddedMembers(); |
||||
sync2AddedMembersFormAdded(); |
||||
// 不需要重复更新右侧列表显示 但是更新一下计数显示
|
||||
countLabel.setText( |
||||
Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Selected_Member_Count", |
||||
String.valueOf(addedMembers.size()) |
||||
) |
||||
); |
||||
// 刷新左侧列表显示
|
||||
addToMemberList(); |
||||
|
||||
} |
||||
}; |
||||
|
||||
|
||||
/** |
||||
* 已经添加的成员列表 |
||||
*/ |
||||
private AddedMemberList addedList; |
||||
/** |
||||
* 待添加的成员列表 |
||||
*/ |
||||
private AddingMemberList addingList; |
||||
|
||||
/** |
||||
* 搜索关键字 |
||||
*/ |
||||
private String keyWord; |
||||
|
||||
/** |
||||
* 搜索关键词变更监听 |
||||
*/ |
||||
private transient DocumentListener documentListener = new DocumentListener() { |
||||
@Override |
||||
public void insertUpdate(DocumentEvent e) { |
||||
keyWord = keyField.getText(); |
||||
} |
||||
|
||||
@Override |
||||
public void removeUpdate(DocumentEvent e) { |
||||
keyWord = keyField.getText(); |
||||
} |
||||
|
||||
@Override |
||||
public void changedUpdate(DocumentEvent e) { |
||||
keyWord = keyField.getText(); |
||||
} |
||||
}; |
||||
|
||||
/** |
||||
* 当前分页计数 |
||||
*/ |
||||
private int pageNum = 1; |
||||
|
||||
|
||||
public UserManagerPane() { |
||||
this.setBorder(BorderFactory.createEmptyBorder(0, 4, 0, 4)); |
||||
this.setLayout(new BorderLayout()); |
||||
this.add( |
||||
TableLayoutHelper.createCommonTableLayoutPane( |
||||
new Component[][]{ |
||||
new Component[]{createLeftPanel(), createRightPanel()} |
||||
}, |
||||
new double[]{TableLayout.FILL}, |
||||
new double[]{TableLayout.FILL, TableLayout.FILL}, |
||||
LayoutConstants.VGAP_LARGE |
||||
), |
||||
BorderLayout.CENTER); |
||||
} |
||||
|
||||
public void populate(List<RemoteDesignMember> addedMembers) { |
||||
|
||||
// 已选信息
|
||||
resetAddedMembers(); |
||||
this.addedMembers.addAll(addedMembers); |
||||
|
||||
// 刷新右侧面板
|
||||
addToAddedMemberList(); |
||||
|
||||
// 刷新左侧展示信息
|
||||
addToMemberList(); |
||||
} |
||||
|
||||
public class UserManagerPane extends AbstractManagerPane { |
||||
|
||||
@Override |
||||
protected String title4PopupWindow() { |
||||
return Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Choose_Member"); |
||||
// 选择设计用户
|
||||
return Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Choose_User"); |
||||
} |
||||
|
||||
private JPanel createLeftPanel() { |
||||
@Override |
||||
protected JPanel rightPanel(){ |
||||
JPanel content = new JPanel(new BorderLayout()); |
||||
|
||||
content.setBorder( |
||||
BorderFactory.createCompoundBorder( |
||||
new EmptyBorder(6, 0, 0, 0), |
||||
UITitledBorder.createBorderWithTitle( |
||||
Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Decision_Member"), |
||||
4) |
||||
// 已选择的设计用户
|
||||
Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Selected_User"), |
||||
4 |
||||
) |
||||
) |
||||
); |
||||
|
||||
// 搜索
|
||||
JPanel searchPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 5)); |
||||
searchPanel.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); |
||||
keyField.setPreferredSize(new Dimension(270, 20)); |
||||
keyField.requestFocus(); |
||||
keyField.addKeyListener(keyFieldKeyListener); |
||||
keyField.getDocument().addDocumentListener(documentListener); |
||||
keyButton.setIcon(BaseUtils.readIcon("com/fr/design/images/buttonicon/user_search_normal.png")); |
||||
keyButton.setToolTipText(Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Search")); |
||||
keyButton.addActionListener(keyButtonActionListener); |
||||
searchPanel.add(keyField); |
||||
searchPanel.add(keyButton); |
||||
|
||||
// 内容列表
|
||||
addingListModel = new DefaultListModel<>(); |
||||
addingList = new AddingMemberList(addingListModel); |
||||
addingList.setCellRenderer(new AddingMemberListCellRender()); |
||||
addingList.addSelectedChangeListener(addingListChangeListener); |
||||
resetMembers(); |
||||
addToMemberList(); |
||||
searchAddingMembers(StringUtils.EMPTY); |
||||
final UIScrollPane listPane = new UIScrollPane(addingList); |
||||
listPane.addMouseWheelListener(new MouseWheelListener() { |
||||
@Override |
||||
public void mouseWheelMoved(MouseWheelEvent e) { |
||||
JViewport vp = listPane.getViewport(); |
||||
if (vp.getView().getHeight() <= vp.getHeight() + vp.getViewPosition().y) { |
||||
loadMoreAddingMembers(keyWord, DEFAULT_NUM_EACH_PAGE); |
||||
} |
||||
} |
||||
}); |
||||
listPane.getVerticalScrollBar().addAdjustmentListener(new AdjustmentListener() { |
||||
@Override |
||||
public void adjustmentValueChanged(AdjustmentEvent e) { |
||||
JViewport vp = listPane.getViewport(); |
||||
if (vp.getView().getHeight() <= vp.getHeight() + vp.getViewPosition().y && e.getValueIsAdjusting()) { |
||||
loadMoreAddingMembers(keyWord, DEFAULT_NUM_EACH_PAGE); |
||||
} |
||||
} |
||||
}); |
||||
listPane.setBorder(BorderFactory.createEmptyBorder()); |
||||
|
||||
content.add(searchPanel, BorderLayout.NORTH); |
||||
content.add(listPane, BorderLayout.CENTER); |
||||
return content; |
||||
} |
||||
|
||||
|
||||
private JPanel createRightPanel() { |
||||
@Override |
||||
protected JPanel leftPanel(){ |
||||
JPanel content = new JPanel(new BorderLayout()); |
||||
|
||||
content.setBorder( |
||||
BorderFactory.createCompoundBorder( |
||||
new EmptyBorder(6, 0, 0, 0), |
||||
UITitledBorder.createBorderWithTitle( |
||||
Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Selected_Member"), |
||||
4 |
||||
) |
||||
// 决策系统用户
|
||||
Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Decision_User"), |
||||
4) |
||||
) |
||||
); |
||||
|
||||
// 计数
|
||||
countLabel.setText( |
||||
Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Selected_Member_Count", |
||||
String.valueOf(addedMembers.size())) |
||||
); |
||||
countLabel.setBorder(BorderFactory.createEmptyBorder(7, 12, 8, 0)); |
||||
countLabel.setForeground(new Color(0x8F8F92)); |
||||
|
||||
addedListModel = new DefaultListModel<>(); |
||||
addedList = new AddedMemberList(addedListModel); |
||||
addedList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); |
||||
addedList.setCellRenderer(new AddedMemberListCellRender()); |
||||
addedList.addSelectedChangeListener(addedListChangeListener); |
||||
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() { |
||||
addingListModel.clear(); |
||||
for (RemoteDesignMember member : addingMembers) { |
||||
// 如果包含在右侧列表中,那么左侧列表默认选中
|
||||
if (addedMembers.contains(member)) { |
||||
member.setSelected(true); |
||||
} else { |
||||
member.setSelected(false); |
||||
} |
||||
addingListModel.addElement(member); |
||||
} |
||||
addingList.revalidate(); |
||||
addingList.repaint(); |
||||
} |
||||
|
||||
private void addToAddedMemberList() { |
||||
addedListModel.clear(); |
||||
for (RemoteDesignMember member : addedMembers) { |
||||
addedListModel.addElement(member); |
||||
} |
||||
addedList.revalidate(); |
||||
addedList.repaint(); |
||||
countLabel.setText( |
||||
Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Selected_Member_Count", |
||||
String.valueOf(addedMembers.size()) |
||||
)); |
||||
} |
||||
|
||||
private void resetMembers() { |
||||
addingMembers.clear(); |
||||
addingMembers.add(RemoteDesignMember.DEFAULT_MEMBER); |
||||
} |
||||
|
||||
private void resetAddedMembers() { |
||||
addedMembers.clear(); |
||||
} |
||||
|
||||
|
||||
private void searchAddingMembers(final String keyword) { |
||||
|
||||
final SwingWorker getMemberWorker = new SwingWorker<List<RemoteDesignMember>, Void>() { |
||||
@Override |
||||
protected List<RemoteDesignMember> doInBackground() { |
||||
String username = WorkContext.getCurrent().getConnection().getUserName(); |
||||
synchronized (addingMembers) { |
||||
addingMembers.clear(); |
||||
Collection<RemoteDesignMember> more = WorkContext.getCurrent().get(DecisionOperator.class).getMembers(username, keyword); |
||||
pageNum = 1; |
||||
if (!more.isEmpty()) { |
||||
addingMembers.addAll(more); |
||||
if (more.size() >= DEFAULT_NUM_EACH_PAGE) { |
||||
addingMembers.add(RemoteDesignMember.DEFAULT_MEMBER); |
||||
} |
||||
} |
||||
} |
||||
return addingMembers; |
||||
} |
||||
|
||||
@Override |
||||
protected void done() { |
||||
addToMemberList(); |
||||
} |
||||
}; |
||||
getMemberWorker.execute(); |
||||
} |
||||
|
||||
private void loadMoreAddingMembers(final String keyword, final int count) { |
||||
|
||||
final SwingWorker loadMoreWorker = new SwingWorker<List<RemoteDesignMember>, Void>() { |
||||
@Override |
||||
protected List<RemoteDesignMember> doInBackground() { |
||||
|
||||
String username = WorkContext.getCurrent().getConnection().getUserName(); |
||||
synchronized (addingMembers) { |
||||
addingMembers.remove(RemoteDesignMember.DEFAULT_MEMBER); |
||||
Collection<RemoteDesignMember> more = |
||||
WorkContext.getCurrent().get(DecisionOperator.class).getMembers(username, keyword, pageNum + 1, count); |
||||
if (!more.isEmpty()) { |
||||
pageNum += 1; |
||||
addingMembers.addAll(more); |
||||
addingMembers.add(RemoteDesignMember.DEFAULT_MEMBER); |
||||
} |
||||
} |
||||
return addingMembers; |
||||
} |
||||
|
||||
@Override |
||||
protected void done() { |
||||
addToMemberList(); |
||||
} |
||||
}; |
||||
loadMoreWorker.execute(); |
||||
@Override |
||||
protected AddingMemberListCellRender getAddingMemberListCellRender() { |
||||
return new AddingUserListCellRender(); |
||||
} |
||||
|
||||
|
||||
private void sync2AddedMembersFromAdding() { |
||||
RemoteDesignMember[] members = new RemoteDesignMember[addingListModel.getSize()]; |
||||
// shallow copy
|
||||
addingListModel.copyInto(members); |
||||
for (RemoteDesignMember member : members) { |
||||
|
||||
if (!member.isSelected()) { |
||||
addedMembers.remove(member); |
||||
} |
||||
if (member.isSelected() && !addedMembers.contains(member)) { |
||||
addedMembers.add(member); |
||||
} |
||||
} |
||||
@Override |
||||
protected AddedMemberListCellRender getAddedMemberListCellRender() { |
||||
return new AddedUserListCellRender(); |
||||
} |
||||
|
||||
private void sync2AddedMembersFormAdded() { |
||||
RemoteDesignMember[] members = new RemoteDesignMember[addedListModel.getSize()]; |
||||
// shallow copy
|
||||
addedListModel.copyInto(members); |
||||
addedMembers.addAll(Arrays.asList(members)); |
||||
@Override |
||||
protected Collection<RemoteDesignMember> getMembers(String userName, String keyWord){ |
||||
return WorkContext.getCurrent().get(DecisionOperator.class).getMembers(userName, keyWord); |
||||
} |
||||
|
||||
|
||||
public ImmutableList<RemoteDesignMember> update() { |
||||
return ImmutableList.copyOf(addedMembers); |
||||
@Override |
||||
protected Collection<RemoteDesignMember> getMembers(String userName, String keyWord, int pageNum, int count){ |
||||
return WorkContext.getCurrent().get(DecisionOperator.class).getMembers(userName, keyWord, pageNum, count); |
||||
} |
||||
} |
@ -0,0 +1,25 @@
|
||||
package com.fr.design.remote.ui.list.cell; |
||||
|
||||
import com.fr.base.BaseUtils; |
||||
import com.fr.design.remote.constants.MemberIcon; |
||||
import com.fr.design.remote.ui.list.AddedMemberListCellRender; |
||||
import com.fr.workspace.server.authority.RemoteDesignMember; |
||||
|
||||
import javax.swing.Icon; |
||||
|
||||
/** |
||||
* @author Lucian.Chen |
||||
* @version 10.0 |
||||
* Created by Lucian.Chen on 2019/9/19 |
||||
*/ |
||||
public class AddedCustomRoleListCellRender extends AddedMemberListCellRender { |
||||
@Override |
||||
protected Icon getMemberIcon() { |
||||
return BaseUtils.readIcon(MemberIcon.CUSTOM_ROLE_ICON); |
||||
} |
||||
|
||||
@Override |
||||
protected String getMemberName(RemoteDesignMember member) { |
||||
return member.getUsername(); |
||||
} |
||||
} |
@ -0,0 +1,25 @@
|
||||
package com.fr.design.remote.ui.list.cell; |
||||
|
||||
import com.fr.base.BaseUtils; |
||||
import com.fr.design.remote.constants.MemberIcon; |
||||
import com.fr.design.remote.ui.list.AddedMemberListCellRender; |
||||
import com.fr.workspace.server.authority.RemoteDesignMember; |
||||
|
||||
import javax.swing.Icon; |
||||
|
||||
/** |
||||
* @author Lucian.Chen |
||||
* @version 10.0 |
||||
* Created by Lucian.Chen on 2019/9/19 |
||||
*/ |
||||
public class AddedUserListCellRender extends AddedMemberListCellRender { |
||||
@Override |
||||
protected Icon getMemberIcon() { |
||||
return BaseUtils.readIcon(MemberIcon.USER_ICON); |
||||
} |
||||
|
||||
@Override |
||||
protected String getMemberName(RemoteDesignMember member) { |
||||
return member.getRealName() + "(" + member.getUsername() + ")"; |
||||
} |
||||
} |
@ -0,0 +1,25 @@
|
||||
package com.fr.design.remote.ui.list.cell; |
||||
|
||||
import com.fr.base.BaseUtils; |
||||
import com.fr.design.remote.constants.MemberIcon; |
||||
import com.fr.design.remote.ui.list.AddingMemberListCellRender; |
||||
import com.fr.workspace.server.authority.RemoteDesignMember; |
||||
|
||||
import javax.swing.Icon; |
||||
|
||||
/** |
||||
* @author Lucian.Chen |
||||
* @version 10.0 |
||||
* Created by Lucian.Chen on 2019/9/19 |
||||
*/ |
||||
public class AddingCustomRoleListCellRender extends AddingMemberListCellRender { |
||||
@Override |
||||
protected Icon getMemberIcon() { |
||||
return BaseUtils.readIcon(MemberIcon.CUSTOM_ROLE_ICON); |
||||
} |
||||
|
||||
@Override |
||||
protected String getMemberName(RemoteDesignMember member) { |
||||
return member.getUsername(); |
||||
} |
||||
} |
@ -0,0 +1,25 @@
|
||||
package com.fr.design.remote.ui.list.cell; |
||||
|
||||
import com.fr.base.BaseUtils; |
||||
import com.fr.design.remote.constants.MemberIcon; |
||||
import com.fr.design.remote.ui.list.AddingMemberListCellRender; |
||||
import com.fr.workspace.server.authority.RemoteDesignMember; |
||||
|
||||
import javax.swing.Icon; |
||||
|
||||
/** |
||||
* @author Lucian.Chen |
||||
* @version 10.0 |
||||
* Created by Lucian.Chen on 2019/9/19 |
||||
*/ |
||||
public class AddingUserListCellRender extends AddingMemberListCellRender { |
||||
@Override |
||||
protected Icon getMemberIcon() { |
||||
return BaseUtils.readIcon(MemberIcon.USER_ICON); |
||||
} |
||||
|
||||
@Override |
||||
protected String getMemberName(RemoteDesignMember member) { |
||||
return member.getRealName() + "(" + member.getUsername() + ")"; |
||||
} |
||||
} |
@ -0,0 +1,25 @@
|
||||
package com.fr.design.remote.ui.list.cell; |
||||
|
||||
import com.fr.base.BaseUtils; |
||||
import com.fr.design.remote.constants.MemberIcon; |
||||
import com.fr.design.remote.ui.list.AuthorityListCellRenderer; |
||||
import com.fr.report.DesignAuthority; |
||||
|
||||
import javax.swing.Icon; |
||||
|
||||
/** |
||||
* @author Lucian.Chen |
||||
* @version 10.0 |
||||
* Created by Lucian.Chen on 2019/9/19 |
||||
*/ |
||||
public class AuthorityCustomRoleListCellRender extends AuthorityListCellRenderer { |
||||
@Override |
||||
protected Icon getMemberIcon() { |
||||
return BaseUtils.readIcon(MemberIcon.CUSTOM_ROLE_ICON); |
||||
} |
||||
|
||||
@Override |
||||
protected String getMemberName(DesignAuthority authority) { |
||||
return authority.getUsername(); |
||||
} |
||||
} |
@ -0,0 +1,25 @@
|
||||
package com.fr.design.remote.ui.list.cell; |
||||
|
||||
import com.fr.base.BaseUtils; |
||||
import com.fr.design.remote.constants.MemberIcon; |
||||
import com.fr.design.remote.ui.list.AuthorityListCellRenderer; |
||||
import com.fr.report.DesignAuthority; |
||||
|
||||
import javax.swing.Icon; |
||||
|
||||
/** |
||||
* @author Lucian.Chen |
||||
* @version 10.0 |
||||
* Created by Lucian.Chen on 2019/9/19 |
||||
*/ |
||||
public class AuthorityUserListCellRender extends AuthorityListCellRenderer { |
||||
@Override |
||||
protected Icon getMemberIcon() { |
||||
return BaseUtils.readIcon(MemberIcon.USER_ICON); |
||||
} |
||||
|
||||
@Override |
||||
protected String getMemberName(DesignAuthority authority) { |
||||
return authority.getRealName() + "(" + authority.getUsername() + ")"; |
||||
} |
||||
} |
@ -0,0 +1,49 @@
|
||||
package com.fr.design.ui.util; |
||||
|
||||
import org.jetbrains.annotations.NotNull; |
||||
|
||||
import javax.swing.SwingUtilities; |
||||
import java.lang.reflect.InvocationTargetException; |
||||
|
||||
/** |
||||
* 事件分发线程管理器。用于管理用户线程 |
||||
* |
||||
* @author vito |
||||
* @version 10.0 |
||||
* Created by vito on 2019/9/16 |
||||
*/ |
||||
public abstract class EdtInvocationManager { |
||||
@NotNull |
||||
private static EdtInvocationManager ourInstance = new SwingEdtInvocationManager(); |
||||
|
||||
public abstract boolean isEventDispatchThread(); |
||||
|
||||
public abstract void invokeLater(@NotNull Runnable task); |
||||
|
||||
public abstract void invokeAndWait(@NotNull Runnable task) throws InvocationTargetException, InterruptedException; |
||||
|
||||
@NotNull |
||||
public static EdtInvocationManager getInstance() { |
||||
return ourInstance; |
||||
} |
||||
|
||||
/** |
||||
* The default {@link EdtInvocationManager} implementation which works with the EDT via SwingUtilities. |
||||
*/ |
||||
private static class SwingEdtInvocationManager extends EdtInvocationManager { |
||||
@Override |
||||
public boolean isEventDispatchThread() { |
||||
return SwingUtilities.isEventDispatchThread(); |
||||
} |
||||
|
||||
@Override |
||||
public void invokeLater(@NotNull Runnable task) { |
||||
SwingUtilities.invokeLater(task); |
||||
} |
||||
|
||||
@Override |
||||
public void invokeAndWait(@NotNull Runnable task) throws InvocationTargetException, InterruptedException { |
||||
SwingUtilities.invokeAndWait(task); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,77 @@
|
||||
package com.fr.design.ui.util; |
||||
|
||||
import org.jetbrains.annotations.NotNull; |
||||
|
||||
import java.awt.*; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* 图形渲染配置 |
||||
* |
||||
* @author vito |
||||
* @version 10.0 |
||||
* Created by vito on 2019/9/18 |
||||
*/ |
||||
public class GraphicsConfig { |
||||
private final Graphics2D myG; |
||||
private final Map myHints; |
||||
private final Composite myComposite; |
||||
private final Stroke myStroke; |
||||
|
||||
public GraphicsConfig(@NotNull Graphics g) { |
||||
myG = (Graphics2D) g; |
||||
myHints = (Map) myG.getRenderingHints().clone(); |
||||
myComposite = myG.getComposite(); |
||||
myStroke = myG.getStroke(); |
||||
} |
||||
|
||||
public GraphicsConfig setAntialiasing(boolean on) { |
||||
myG.setRenderingHint(RenderingHints.KEY_ANTIALIASING, on ? RenderingHints.VALUE_ANTIALIAS_ON : RenderingHints.VALUE_ANTIALIAS_OFF); |
||||
return this; |
||||
} |
||||
|
||||
public GraphicsConfig setAlpha(float alpha) { |
||||
myG.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha)); |
||||
return this; |
||||
} |
||||
|
||||
public GraphicsConfig setRenderingHint(RenderingHints.Key hintKey, Object hintValue) { |
||||
myG.setRenderingHint(hintKey, hintValue); |
||||
return this; |
||||
} |
||||
|
||||
public Graphics2D getG() { |
||||
return myG; |
||||
} |
||||
|
||||
public GraphicsConfig setComposite(Composite composite) { |
||||
myG.setComposite(composite); |
||||
return this; |
||||
} |
||||
|
||||
public GraphicsConfig setStroke(Stroke stroke) { |
||||
myG.setStroke(stroke); |
||||
return this; |
||||
} |
||||
|
||||
public GraphicsConfig setupAAPainting() { |
||||
return setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON) |
||||
.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE); |
||||
} |
||||
|
||||
public GraphicsConfig disableAAPainting() { |
||||
return setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF) |
||||
.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_DEFAULT); |
||||
} |
||||
|
||||
public GraphicsConfig paintWithAlpha(float alpha) { |
||||
assert 0.0f <= alpha && alpha <= 1.0f : "alpha should be in range 0.0f .. 1.0f"; |
||||
return setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha)); |
||||
} |
||||
|
||||
public void restore() { |
||||
myG.setRenderingHints(myHints); |
||||
myG.setComposite(myComposite); |
||||
myG.setStroke(myStroke); |
||||
} |
||||
} |
@ -0,0 +1,55 @@
|
||||
package com.fr.design.ui.util; |
||||
|
||||
import com.fr.log.FineLoggerFactory; |
||||
import org.jetbrains.annotations.NotNull; |
||||
|
||||
import javax.swing.SwingUtilities; |
||||
|
||||
/** |
||||
* 一些常用的 GUI 工具。 |
||||
* <p> |
||||
* 为什么提供 invokeLaterIfNeeded 和 invokeAndWaitIfNeeded这样的方法? |
||||
* 因为 swing 渲染 UI 是单线程的,如果直接使用 |
||||
* {@link SwingUtilities#invokeLater(Runnable)},当 invokeLater 方法 |
||||
* 嵌套的时候,Runnable 会被放到事件循环队列的末尾,从而变成异步而非立即执行, |
||||
* 这是一处坑点。invokeLaterIfNeeded 的行为,当处于事件分发线程(EDT), |
||||
* 则直接运行,当处于其他线程,则使用 EDT 来执行。 |
||||
* <p> |
||||
* 方法{@link SwingUtilities#invokeAndWait(Runnable)},也有一个注意点, |
||||
* 不允许在事件分发线程(EDT)中调用,否则抛错,所以也有必要加上判断 EDT 的逻辑。 |
||||
* |
||||
* @author vito |
||||
* @version 10.0 |
||||
* Created by vito on 2019/9/16 |
||||
*/ |
||||
public class UIUtil { |
||||
/** |
||||
* 在 AWT 线程上立即调用runnable,否则使用 {@link SwingUtilities#invokeLater(Runnable)} 代替。 |
||||
* |
||||
* @param runnable 等待调用的 runnable |
||||
*/ |
||||
public static void invokeLaterIfNeeded(@NotNull Runnable runnable) { |
||||
if (EdtInvocationManager.getInstance().isEventDispatchThread()) { |
||||
runnable.run(); |
||||
} else { |
||||
EdtInvocationManager.getInstance().invokeLater(runnable); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 在 AWT 线程上立即调用runnable,否则使用 {@link SwingUtilities#invokeAndWait(Runnable)} 代替。 |
||||
* |
||||
* @param runnable 等待调用的 runnable |
||||
*/ |
||||
public static void invokeAndWaitIfNeeded(@NotNull Runnable runnable) { |
||||
if (EdtInvocationManager.getInstance().isEventDispatchThread()) { |
||||
runnable.run(); |
||||
} else { |
||||
try { |
||||
EdtInvocationManager.getInstance().invokeAndWait(runnable); |
||||
} catch (Exception e) { |
||||
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -1,118 +0,0 @@
|
||||
package com.fr.design.update.actions; |
||||
|
||||
import com.fr.design.update.domain.UpdateConstants; |
||||
import com.fr.locale.InterProviderFactory; |
||||
import com.fr.log.FineLoggerFactory; |
||||
import com.fr.design.update.domain.DownloadItem; |
||||
import com.fr.stable.ArrayUtils; |
||||
import com.fr.stable.StableUtils; |
||||
|
||||
import javax.swing.JOptionPane; |
||||
import javax.swing.SwingWorker; |
||||
import java.io.File; |
||||
import java.io.FileOutputStream; |
||||
import java.io.InputStream; |
||||
import java.net.URL; |
||||
import java.net.URLConnection; |
||||
import java.util.concurrent.ExecutionException; |
||||
|
||||
/** |
||||
* Created by XINZAI on 2018/8/21. |
||||
*/ |
||||
public abstract class FileDownloader extends SwingWorker<Boolean, DownloadItem> { |
||||
private static final int REPEAT_DOWNLOAD_TIMES = 3; |
||||
private DownloadItem[] files; |
||||
private String saveDir; |
||||
//已经完成的大小
|
||||
private long completeSize; |
||||
|
||||
public FileDownloader(DownloadItem[] files, String saveDir) { |
||||
this.files = files; |
||||
this.saveDir = saveDir; |
||||
} |
||||
|
||||
@Override |
||||
protected Boolean doInBackground() throws Exception { |
||||
if (ArrayUtils.isNotEmpty(files)) { |
||||
setCompleteSize(0L); |
||||
for (DownloadItem item : files) { |
||||
for (int i = 0; i < REPEAT_DOWNLOAD_TIMES; i++) { |
||||
item.setTotalLength(0); |
||||
item.setDownloadLength(0); |
||||
download(item); |
||||
if (item.getTotalLength() == item.getDownloadLength()) { |
||||
break; |
||||
} |
||||
} |
||||
if (item.getTotalLength() != item.getDownloadLength()) { |
||||
JOptionPane.showMessageDialog(null, |
||||
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Updater_Download_Failed"), |
||||
InterProviderFactory.getProvider().getLocText("Fine-Design_Updater_Alert"), JOptionPane.ERROR_MESSAGE); |
||||
return false; |
||||
} else { |
||||
item.setDownloadLength(0); |
||||
completeSize += item.getTotalLength(); |
||||
} |
||||
} |
||||
} |
||||
return true; |
||||
} |
||||
|
||||
@Override |
||||
protected void done() { |
||||
boolean success = false; |
||||
try { |
||||
success = get(); |
||||
} catch (InterruptedException e) { |
||||
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
||||
Thread.currentThread().interrupt(); |
||||
} catch (ExecutionException e) { |
||||
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
||||
} |
||||
if (success) { |
||||
onDownloadSuccess(); |
||||
} else { |
||||
onDownloadFailed(); |
||||
} |
||||
} |
||||
|
||||
private void download(DownloadItem item) throws Exception { |
||||
URL url = new URL(item.getUrl()); |
||||
URLConnection connection = url.openConnection(); |
||||
int total = connection.getContentLength(); |
||||
item.setTotalLength(total); |
||||
File tempFile = new File(StableUtils.pathJoin(saveDir, item.getName())); |
||||
StableUtils.makesureFileExist(tempFile); |
||||
try ( InputStream reader = connection.getInputStream(); |
||||
FileOutputStream writer = new FileOutputStream(tempFile)) { |
||||
byte[] buffer = new byte[UpdateConstants.BYTE]; |
||||
int bytesRead = 0; |
||||
int totalBytesRead = 0; |
||||
while ((bytesRead = reader.read(buffer)) != -1) { |
||||
writer.write(buffer, 0, bytesRead); |
||||
buffer = new byte[UpdateConstants.BYTE]; |
||||
totalBytesRead += bytesRead; |
||||
item.setDownloadLength(totalBytesRead); |
||||
publish(item); |
||||
} |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 下载成功 |
||||
*/ |
||||
public abstract void onDownloadSuccess(); |
||||
|
||||
/** |
||||
* 下载失败 |
||||
*/ |
||||
public abstract void onDownloadFailed(); |
||||
|
||||
public long getCompleteSize() { |
||||
return completeSize; |
||||
} |
||||
|
||||
public void setCompleteSize(long completeSize) { |
||||
this.completeSize = completeSize; |
||||
} |
||||
} |
@ -0,0 +1,55 @@
|
||||
package com.fr.design.update.actions; |
||||
|
||||
import com.fr.decision.update.info.UpdateCallBack; |
||||
import com.fr.decision.update.UpdateExecutor; |
||||
import com.fr.log.FineLoggerFactory; |
||||
|
||||
import javax.swing.*; |
||||
import java.util.concurrent.ExecutionException; |
||||
|
||||
/** |
||||
* @author Bryant |
||||
* @version 10.0 |
||||
* Created by Bryant on 2019-09-12 |
||||
*/ |
||||
public abstract class FileProcess extends SwingWorker<Boolean, Void> { |
||||
|
||||
private UpdateCallBack callBack; |
||||
|
||||
public FileProcess(UpdateCallBack callBack) { |
||||
this.callBack = callBack; |
||||
} |
||||
|
||||
@Override |
||||
protected Boolean doInBackground() throws Exception { |
||||
return UpdateExecutor.getInstance().execute(callBack); |
||||
} |
||||
|
||||
@Override |
||||
protected void done() { |
||||
boolean success = false; |
||||
try { |
||||
success = get(); |
||||
} catch (InterruptedException e) { |
||||
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
||||
Thread.currentThread().interrupt(); |
||||
} catch (ExecutionException e) { |
||||
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
||||
} |
||||
if (success) { |
||||
onDownloadSuccess(); |
||||
} else { |
||||
onDownloadFailed(); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 下载成功 |
||||
*/ |
||||
public abstract void onDownloadSuccess(); |
||||
|
||||
/** |
||||
* 下载失败 |
||||
*/ |
||||
public abstract void onDownloadFailed(); |
||||
} |
@ -1,102 +0,0 @@
|
||||
package com.fr.design.update.domain; |
||||
|
||||
import com.fr.general.ComparatorUtils; |
||||
import com.fr.json.JSONObject; |
||||
|
||||
import java.util.Date; |
||||
|
||||
/** |
||||
* Created by XINZAI on 2018/8/21. |
||||
*/ |
||||
public class DownloadItem { |
||||
|
||||
//显示为百分比
|
||||
private static final int PERCENTAGE_RATIO = 100; |
||||
//显示kB
|
||||
private static final int BYTETOKB_RATIO = 1000; |
||||
|
||||
private String name; |
||||
private String url; |
||||
private long size; |
||||
|
||||
private int totalLength; |
||||
private int downloadLength; |
||||
|
||||
public DownloadItem(JSONObject json) { |
||||
this(json.optString("name"), json.optString("url"), json.optLong("size")); |
||||
} |
||||
|
||||
public DownloadItem(String name, String url, long size) { |
||||
this.name = name; |
||||
this.url = url; |
||||
this.size = size; |
||||
} |
||||
|
||||
public String getName() { |
||||
return name; |
||||
} |
||||
|
||||
public String getUrl() { |
||||
return url + "?v=" + new Date().getTime(); |
||||
} |
||||
|
||||
|
||||
public long getSize() { |
||||
return size; |
||||
} |
||||
|
||||
public void setSize(long size) { |
||||
this.size = size; |
||||
} |
||||
|
||||
public int getTotalLength() { |
||||
return totalLength; |
||||
} |
||||
|
||||
public int getDownloadLength() { |
||||
return downloadLength; |
||||
} |
||||
|
||||
public void setTotalLength(int totalLength) { |
||||
this.totalLength = totalLength; |
||||
} |
||||
|
||||
public void setDownloadLength(int downloadLength) { |
||||
this.downloadLength = downloadLength; |
||||
} |
||||
|
||||
public int getProgressValue() { |
||||
return (int) ((downloadLength / (double) totalLength) * PERCENTAGE_RATIO); |
||||
} |
||||
|
||||
public String getProgressString() { |
||||
return downloadLength / BYTETOKB_RATIO + "KB/" + totalLength / BYTETOKB_RATIO + "KB"; |
||||
} |
||||
|
||||
/** |
||||
* 转化为字符串 |
||||
* |
||||
* @return 字符串 |
||||
*/ |
||||
@Override |
||||
public String toString() { |
||||
return "name:" + name + ";download:" + getProgressString(); |
||||
} |
||||
|
||||
@Override |
||||
public boolean equals(Object obj) { |
||||
return obj instanceof DownloadItem |
||||
&& ComparatorUtils.equals(((DownloadItem) obj).name, name) |
||||
&& ComparatorUtils.equals(((DownloadItem) obj).url, url); |
||||
} |
||||
|
||||
/** |
||||
* 返回一个hash码 |
||||
* |
||||
* @return hash码 |
||||
*/ |
||||
@Override |
||||
public int hashCode() { |
||||
return name.hashCode(); |
||||
} |
||||
} |
After Width: | Height: | Size: 612 B |
After Width: | Height: | Size: 1.4 KiB |
@ -0,0 +1,70 @@
|
||||
package com.fr.design; |
||||
|
||||
import com.fr.config.dao.DaoContext; |
||||
import com.fr.config.dao.impl.LocalClassHelperDao; |
||||
import com.fr.config.dao.impl.LocalEntityDao; |
||||
import com.fr.config.dao.impl.LocalXmlEntityDao; |
||||
import com.fr.design.fun.ToolbarItemProvider; |
||||
import com.fr.design.gui.core.WidgetOption; |
||||
import com.fr.design.mainframe.JTemplate; |
||||
import com.fr.design.mainframe.JVirtualTemplate; |
||||
import com.fr.general.ModuleContext; |
||||
import com.fr.log.FineLoggerFactory; |
||||
import com.fr.report.restriction.CellCountRestriction; |
||||
import com.fr.report.restriction.ReportRestrictionScene; |
||||
import com.fr.restriction.Restrictions; |
||||
import com.fr.stable.Filter; |
||||
import com.fr.stable.module.Module; |
||||
import junit.framework.TestCase; |
||||
import org.easymock.EasyMock; |
||||
import org.junit.Assert; |
||||
|
||||
import java.util.HashSet; |
||||
import java.util.Set; |
||||
|
||||
/** |
||||
* @author zack |
||||
* @version 10.0 |
||||
* Created by zack on 2019/9/17 |
||||
*/ |
||||
public class ExtraDesignClassManagerTest extends TestCase { |
||||
@Override |
||||
protected void setUp() throws Exception { |
||||
DaoContext.setEntityDao(new LocalEntityDao()); |
||||
DaoContext.setClassHelperDao(new LocalClassHelperDao()); |
||||
DaoContext.setXmlEntityDao(new LocalXmlEntityDao()); |
||||
ModuleContext.startModule(Module.PAGE_MODULE); |
||||
Restrictions.register(ReportRestrictionScene.CELL_COUNT, new CellCountRestriction()); |
||||
} |
||||
|
||||
public void testGetWebOption() { |
||||
try { |
||||
final JTemplate jTemplate = new JVirtualTemplate(null); |
||||
ToolbarItemProvider item = EasyMock.mock(ToolbarItemProvider.class); |
||||
ToolbarItemProvider item1 = EasyMock.mock(ToolbarItemProvider.class); |
||||
EasyMock.expect(item.accept(jTemplate)).andReturn(false).anyTimes(); |
||||
EasyMock.expect(item.classForWidget()).andReturn(null).anyTimes(); |
||||
EasyMock.expect(item.iconPathForWidget()).andReturn("").anyTimes(); |
||||
EasyMock.expect(item.nameForWidget()).andReturn("1").anyTimes(); |
||||
EasyMock.expect(item1.accept(jTemplate)).andReturn(true).anyTimes(); |
||||
EasyMock.expect(item1.classForWidget()).andReturn(null).anyTimes(); |
||||
EasyMock.expect(item1.iconPathForWidget()).andReturn("").anyTimes(); |
||||
EasyMock.expect(item1.nameForWidget()).andReturn("2").anyTimes(); |
||||
EasyMock.replay(item); |
||||
EasyMock.replay(item1); |
||||
|
||||
Set<ToolbarItemProvider> set = new HashSet<>(); |
||||
set.add(item); |
||||
set.add(item1); |
||||
WidgetOption[] widgetOptions = ExtraDesignClassManager.getInstance().getWebWidgetOptions(set, new Filter<ToolbarItemProvider>() { |
||||
@Override |
||||
public boolean accept(ToolbarItemProvider toolbarItemProvider) { |
||||
return toolbarItemProvider.accept(jTemplate); |
||||
} |
||||
}); |
||||
Assert.assertEquals(1, widgetOptions.length); |
||||
} catch (Exception e) { |
||||
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,141 @@
|
||||
package com.fr.design.chart.fun; |
||||
|
||||
import com.fr.chart.chartattr.Plot; |
||||
import com.fr.design.beans.BasicBeanPane; |
||||
import com.fr.design.condition.ConditionAttributesPane; |
||||
import com.fr.design.gui.frpane.AttributeChangeListener; |
||||
import com.fr.design.mainframe.chart.AbstractChartAttrPane; |
||||
import com.fr.design.mainframe.chart.ChartEditPane; |
||||
import com.fr.design.mainframe.chart.ChartsConfigPane; |
||||
import com.fr.design.mainframe.chart.gui.ChartDataPane; |
||||
import com.fr.design.mainframe.chart.gui.ChartStylePane; |
||||
import com.fr.design.mainframe.chart.gui.data.report.AbstractReportDataContentPane; |
||||
import com.fr.design.mainframe.chart.gui.data.table.AbstractTableDataContentPane; |
||||
import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane; |
||||
import com.fr.plugin.injectable.SpecialLevel; |
||||
import com.fr.stable.fun.Level; |
||||
|
||||
/** |
||||
* Created by eason on 14/12/29. |
||||
* |
||||
* @since 8.0 |
||||
* 自定义 图表类型 界面接口 |
||||
*/ |
||||
public interface ChartTypeUIProvider extends Level { |
||||
|
||||
String XML_TAG = "ChartTypeUIProvider"; |
||||
|
||||
String OLD_TAG = SpecialLevel.IndependentChartUIProvider.getTagName(); |
||||
|
||||
int CURRENT_API_LEVEL = 3; |
||||
|
||||
/** |
||||
* 图表 类型定义界面类型,就是属性表的第一个界面 |
||||
* 可以返回null 代表没有 图表类型切换界面 |
||||
* |
||||
* @return 图表的类型定义界面类型 |
||||
*/ |
||||
AbstractChartTypePane getPlotTypePane(); |
||||
|
||||
/** |
||||
* 图表 数据配置界面 即属性表的第二个界面 |
||||
* 可以返回null 代表没有数据配置界面 |
||||
*/ |
||||
ChartDataPane getChartDataPane(AttributeChangeListener listener); |
||||
|
||||
/** |
||||
* 图表 属性界面数组 其他样式界面数组 |
||||
* 可以返回空数组 代表没有其他样式界面 |
||||
* |
||||
* @return 属性界面 |
||||
*/ |
||||
AbstractChartAttrPane[] getAttrPaneArray(AttributeChangeListener listener); |
||||
|
||||
/** |
||||
* 图表 名称 |
||||
* eg:柱形图 |
||||
* |
||||
* @return 图表 名称 |
||||
*/ |
||||
String getName(); |
||||
|
||||
/** |
||||
* 图表 名称 |
||||
* 柱形图 堆积柱形图 等 |
||||
* |
||||
* @return 图表 名称 |
||||
*/ |
||||
String[] getSubName(); |
||||
|
||||
/** |
||||
* 图表 demo图片路径 |
||||
* 400*225 |
||||
* 1.图表选择界面的图的路径 原样渲染 |
||||
* 2.图表属性第一个界面 类型界面 缩放渲染 |
||||
* |
||||
* @return demo图片路径 |
||||
*/ |
||||
String[] getDemoImagePath(); |
||||
|
||||
/** |
||||
* 小图标路径 |
||||
* 表单 工具栏 图表小图标 |
||||
* 16*16 |
||||
* |
||||
* @return 图标路径 |
||||
*/ |
||||
String getIconPath(); |
||||
|
||||
|
||||
//todo:把下面这些接口删除
|
||||
@Deprecated |
||||
boolean needChartChangePane(); |
||||
|
||||
/** |
||||
* 数据集数据源的界面 |
||||
* |
||||
* @return 数据集数据源的界面 |
||||
*/ |
||||
@Deprecated |
||||
AbstractTableDataContentPane getTableDataSourcePane(Plot plot, ChartDataPane parent); |
||||
|
||||
|
||||
/** |
||||
* 单元格数据源的界面 |
||||
* |
||||
* @return 单元格数据源的界面 |
||||
*/ |
||||
@Deprecated |
||||
AbstractReportDataContentPane getReportDataSourcePane(Plot plot, ChartDataPane parent); |
||||
|
||||
/** |
||||
* 条件属性界面 |
||||
* |
||||
* @return 条件属性界面 |
||||
*/ |
||||
@Deprecated |
||||
ConditionAttributesPane getPlotConditionPane(Plot plot); |
||||
|
||||
/** |
||||
* 系列界面 |
||||
* |
||||
* @return 系列界面 |
||||
*/ |
||||
@Deprecated |
||||
BasicBeanPane<Plot> getPlotSeriesPane(ChartStylePane parent, Plot plot); |
||||
|
||||
/** |
||||
* 是否使用默认的界面,为了避免界面来回切换 |
||||
* |
||||
* @return 是否使用默认的界面 |
||||
*/ |
||||
@Deprecated |
||||
boolean isUseDefaultPane(); |
||||
|
||||
@Deprecated |
||||
ChartEditPane getChartEditPane(String plotID); |
||||
|
||||
@Deprecated |
||||
ChartsConfigPane getChartConfigPane(String plotID); |
||||
|
||||
} |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue