Browse Source

REPORT-6700 适配

master
yaoh.wu 7 years ago
parent
commit
409f5b4f51
  1. 6
      designer-base/src/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java
  2. 72
      designer-base/src/com/fr/design/remote/RemoteMember.java
  3. 47
      designer-base/src/com/fr/design/remote/Utils.java
  4. 13
      designer-base/src/com/fr/design/remote/action/RemoteDesignAuthorityManagerAction.java
  5. 16
      designer-base/src/com/fr/design/remote/ui/AuthorityEditorPane.java
  6. 12
      designer-base/src/com/fr/design/remote/ui/AuthorityListControlPane.java
  7. 36
      designer-base/src/com/fr/design/remote/ui/UserManagerPane.java
  8. 14
      designer-base/src/com/fr/design/remote/ui/list/AddedMemberList.java
  9. 8
      designer-base/src/com/fr/design/remote/ui/list/AddedMemberListCellRender.java
  10. 10
      designer-base/src/com/fr/design/remote/ui/list/AddingMemberList.java
  11. 8
      designer-base/src/com/fr/design/remote/ui/list/AddingMemberListCellRender.java
  12. 2
      designer-base/src/com/fr/design/remote/ui/list/AuthorityListCellRenderer.java
  13. 11
      designer-base/src/com/fr/design/remote/ui/list/MemberList.java

6
designer-base/src/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java

@ -227,7 +227,8 @@ public abstract class ToolBarMenuDock {
menuList.addAll(Arrays.asList(menuDefs));
// 添加服务器菜单
if (FRContext.getCurrentEnv() != null && FRContext.getCurrentEnv().isRoot()) {
// todo 远程设计isRoot 总是返回false,先处理一下
if (FRContext.getCurrentEnv() != null && !FRContext.getCurrentEnv().isRoot()) {
menuList.add(createServerMenuDef(plus));
}
@ -444,7 +445,8 @@ public abstract class ToolBarMenuDock {
}
private boolean shouldShowRemotePermission() {
return FRContext.getCurrentEnv() != null && !FRContext.getCurrentEnv().isLocalEnv() && FRContext.getCurrentEnv().isRoot();
// todo 远程设计 isRoot 总是返回 false 先处理一下
return FRContext.getCurrentEnv() != null && !FRContext.getCurrentEnv().isLocalEnv() && !FRContext.getCurrentEnv().isRoot();
}
protected boolean shouldShowPlugin() {

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

@ -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;
}
}

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

@ -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;
}
}

13
designer-base/src/com/fr/design/remote/action/RemoteDesignAuthorityManagerAction.java

@ -2,12 +2,13 @@ package com.fr.design.remote.action;
import com.fr.base.BaseUtils;
import com.fr.base.FRContext;
import com.fr.base.env.proxy.EnvProxy;
import com.fr.design.actions.UpdateAction;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.remote.ui.AuthorityManagerPane;
import com.fr.env.RemoteEnv;
import com.fr.env.operator.authority.AuthorityOperator;
import com.fr.general.Inter;
import com.fr.report.DesignAuthority;
@ -34,7 +35,8 @@ public class RemoteDesignAuthorityManagerAction extends UpdateAction {
if (!FRContext.getCurrentEnv().isLocalEnv()) {
try {
DesignAuthority[] authorities = ((RemoteEnv) FRContext.getCurrentEnv()).getAuthorities();
// 远程设计获取全部设计成员的权限列表
DesignAuthority[] authorities = EnvProxy.get(AuthorityOperator.class).getAuthorities();
if (authorities != null && authorities.length != 0) {
managerPane.populate(authorities);
}
@ -48,7 +50,12 @@ public class RemoteDesignAuthorityManagerAction extends UpdateAction {
public void doOk() {
DesignAuthority[] authorities = managerPane.update();
if (!FRContext.getCurrentEnv().isLocalEnv()) {
boolean success = ((RemoteEnv) FRContext.getCurrentEnv()).updateAuthorities(authorities);
boolean success = false;
try {
success = EnvProxy.get(AuthorityOperator.class).updateAuthorities(authorities);
} catch (Exception e) {
FRContext.getLogger().error(e.getMessage());
}
FRContext.getLogger().info("update remote design authority: " + success);
}
}

16
designer-base/src/com/fr/design/remote/ui/AuthorityEditorPane.java

@ -2,8 +2,8 @@ package com.fr.design.remote.ui;
import com.fr.base.FRContext;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.border.UITitledBorder;
import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.remote.ui.tree.FileAuthorityTree;
@ -14,23 +14,28 @@ import com.fr.report.DesignAuthority;
import com.fr.stable.CoreConstants;
import javax.swing.BorderFactory;
import javax.swing.border.EmptyBorder;
import javax.swing.tree.TreePath;
import java.awt.BorderLayout;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class AuthorityEditorPane extends BasicBeanPane<DesignAuthority> {
private UILabel label = new UILabel();
private FileAuthorityTree tree = new FileAuthorityTree();
public AuthorityEditorPane() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.setBorder(BorderFactory.createEmptyBorder());
this.add(label, BorderLayout.NORTH);
this.setBorder(
BorderFactory.createCompoundBorder(
new EmptyBorder(6, 0, 6, 6),
UITitledBorder.createBorderWithTitle(
Inter.getLocText("模板设计权限配置")
)
)
);
IOFileNodeFilter filter = new IOFileNodeFilter(new String[]{".cpt", ".class", ".frm", ".form"});
tree.setDigIn(true);
tree.setFileNodeFilter(filter);
@ -49,7 +54,6 @@ public class AuthorityEditorPane extends BasicBeanPane<DesignAuthority> {
if (ob == null) {
return;
}
label.setText(ob.getUsername());
DesignAuthority.Item[] items = ob.getItems();
if (items == null) {

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

@ -15,10 +15,10 @@ import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.menu.ShortCut;
import com.fr.design.menu.ToolBarDef;
import com.fr.design.remote.RemoteDesignAuthorityCreator;
import com.fr.design.remote.RemoteMember;
import com.fr.design.remote.ui.list.AuthorityList;
import com.fr.design.remote.ui.list.AuthorityListCellRenderer;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.env.RemoteDesignMember;
import com.fr.general.ComparatorUtils;
import com.fr.general.Inter;
import com.fr.report.DesignAuthority;
@ -92,8 +92,8 @@ public class AuthorityListControlPane extends BasicPane {
// 右侧卡片布局
cardLayout = new CardLayout();
cardPane = new JPanel(cardLayout);
UILabel selectLabel = new UILabel();
cardPane.add(selectLabel, UNSELECTED_EDITOR_NAME);
UILabel emptyLabel = new UILabel();
cardPane.add(emptyLabel, UNSELECTED_EDITOR_NAME);
cardPane.add(editorCtrl, SELECTED_EDITOR_NAME);
// 左右分割布局
@ -169,7 +169,7 @@ public class AuthorityListControlPane extends BasicPane {
for (int i = 0, len = listModel.getSize(); i < len; i++) {
res.add((DesignAuthority) listModel.getElementAt(i));
}
return res.toArray(new DesignAuthority[0]);
return res.toArray(new DesignAuthority[res.size()]);
}
public void populate(DesignAuthority[] authorities) {
@ -476,8 +476,8 @@ public class AuthorityListControlPane extends BasicPane {
@Override
public void doOk() {
// 获取添加的用户到权限编辑面板
List<RemoteMember> members = userManagerPane.update();
for (RemoteMember member : members) {
List<RemoteDesignMember> members = userManagerPane.update();
for (RemoteDesignMember member : members) {
DesignAuthority authority = new DesignAuthority();
authority.setUsername(member.getUsername());
authority.setUserId(member.getUserId());

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

@ -1,5 +1,8 @@
package com.fr.design.remote.ui;
import com.fr.base.env.EnvContext;
import com.fr.base.env.proxy.EnvProxy;
import com.fr.base.env.resource.EnvConfigUtils;
import com.fr.design.border.UITitledBorder;
import com.fr.design.dialog.BasicPane;
import com.fr.design.gui.ibutton.UIButton;
@ -8,13 +11,13 @@ import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.remote.RemoteMember;
import com.fr.design.remote.Utils;
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.env.RemoteDesignMember;
import com.fr.env.operator.decision.DecisionOperator;
import com.fr.general.Inter;
import com.fr.stable.StringUtils;
import com.fr.third.guava.collect.ImmutableList;
@ -46,16 +49,16 @@ public class UserManagerPane extends BasicPane {
/**
* 获取的决策平台成员
*/
private List<RemoteMember> addingMembers = new ArrayList<>();
private List<RemoteDesignMember> addingMembers = new ArrayList<>();
/**
* 添加到设计的决策平台成员
*/
private List<RemoteMember> addedMembers = new ArrayList<>();
private List<RemoteDesignMember> addedMembers = new ArrayList<>();
/**
* 决策平台成员列表model
*/
private DefaultListModel<RemoteMember> addingListModel = new DefaultListModel<>();
private DefaultListModel<RemoteDesignMember> addingListModel = new DefaultListModel<>();
/**
* 搜索输入框
*/
@ -95,7 +98,7 @@ public class UserManagerPane extends BasicPane {
/**
* 添加到设计的决策成员计数标签
*/
private DefaultListModel<RemoteMember> addedListModel;
private DefaultListModel<RemoteDesignMember> addedListModel;
private MemberListSelectedChangeListener addingListChangeListener = new MemberListSelectedChangeListener() {
@ -224,7 +227,7 @@ public class UserManagerPane extends BasicPane {
private void addToMemberList() {
addingListModel.clear();
for (RemoteMember member : addingMembers) {
for (RemoteDesignMember member : addingMembers) {
addingListModel.addElement(member);
}
addingList.revalidate();
@ -233,7 +236,7 @@ public class UserManagerPane extends BasicPane {
private void addToAddedMemberList() {
addedListModel.clear();
for (RemoteMember member : addedMembers) {
for (RemoteDesignMember member : addedMembers) {
addedListModel.addElement(member);
}
addedList.revalidate();
@ -246,7 +249,7 @@ public class UserManagerPane extends BasicPane {
private void resetMembers() {
addingMembers.clear();
addingMembers.add(RemoteMember.DEFAULT_MEMBER);
addingMembers.add(RemoteDesignMember.DEFAULT_MEMBER);
}
private void resetAddedMembers() {
@ -256,11 +259,12 @@ public class UserManagerPane extends BasicPane {
private void searchAddingMembers(final String keyword) {
final SwingWorker getMemberWorker = new SwingWorker<List<RemoteMember>, Void>() {
final SwingWorker getMemberWorker = new SwingWorker<List<RemoteDesignMember>, Void>() {
@Override
protected List<RemoteMember> doInBackground() {
protected List<RemoteDesignMember> doInBackground() {
addingMembers.clear();
addingMembers.addAll(Utils.getRemoteMember(keyword));
String username = EnvConfigUtils.getUsername(EnvContext.currentEnv());
addingMembers.addAll(EnvProxy.get(DecisionOperator.class).getMembers(username, keyword));
return addingMembers;
}
@ -274,10 +278,10 @@ public class UserManagerPane extends BasicPane {
private void sync2AddedMembersFromAdding() {
RemoteMember[] members = new RemoteMember[addingListModel.getSize()];
RemoteDesignMember[] members = new RemoteDesignMember[addingListModel.getSize()];
// shallow copy
addingListModel.copyInto(members);
for (RemoteMember member : members) {
for (RemoteDesignMember member : members) {
if (member.isSelected()) {
addedMembers.add(member);
}
@ -285,14 +289,14 @@ public class UserManagerPane extends BasicPane {
}
private void sync2AddedMembersFormAdded() {
RemoteMember[] members = new RemoteMember[addedListModel.getSize()];
RemoteDesignMember[] members = new RemoteDesignMember[addedListModel.getSize()];
// shallow copy
addedListModel.copyInto(members);
addedMembers.addAll(Arrays.asList(members));
}
public ImmutableList<RemoteMember> update() {
public ImmutableList<RemoteDesignMember> update() {
return ImmutableList.copyOf(addedMembers);
}
}

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

@ -1,8 +1,8 @@
package com.fr.design.remote.ui.list;
import com.fr.design.remote.RemoteMember;
import com.fr.env.RemoteDesignMember;
import javax.swing.*;
import javax.swing.DefaultListModel;
import java.awt.event.MouseEvent;
import java.util.Vector;
@ -12,15 +12,15 @@ public class AddedMemberList extends MemberList {
super();
}
public AddedMemberList(DefaultListModel<RemoteMember> dataModel) {
public AddedMemberList(DefaultListModel<RemoteDesignMember> dataModel) {
super(dataModel);
}
public AddedMemberList(RemoteMember[] listData) {
public AddedMemberList(RemoteDesignMember[] listData) {
super(listData);
}
public AddedMemberList(Vector<? extends RemoteMember> listData) {
public AddedMemberList(Vector<? extends RemoteDesignMember> listData) {
super(listData);
}
@ -32,10 +32,10 @@ public class AddedMemberList extends MemberList {
@Override
protected void displaySelected() {
RemoteMember member = getSelectedValue();
RemoteDesignMember member = getSelectedValue();
if (member != null) {
member.setSelected(!member.isSelected());
((DefaultListModel<RemoteMember>) getModel()).removeElement(member);
((DefaultListModel<RemoteDesignMember>) getModel()).removeElement(member);
}
revalidate();
repaint();

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

@ -3,7 +3,7 @@ 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.env.RemoteDesignMember;
import javax.swing.BorderFactory;
import javax.swing.JList;
@ -12,7 +12,7 @@ import javax.swing.ListCellRenderer;
import java.awt.Component;
import java.awt.FlowLayout;
public class AddedMemberListCellRender extends JPanel implements ListCellRenderer<RemoteMember> {
public class AddedMemberListCellRender extends JPanel implements ListCellRenderer<RemoteDesignMember> {
private UILabel label;
@ -34,8 +34,8 @@ public class AddedMemberListCellRender extends JPanel implements ListCellRendere
}
@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;
}

10
designer-base/src/com/fr/design/remote/ui/list/AddingMemberList.java

@ -1,6 +1,6 @@
package com.fr.design.remote.ui.list;
import com.fr.design.remote.RemoteMember;
import com.fr.env.RemoteDesignMember;
import javax.swing.DefaultListModel;
import java.awt.event.MouseEvent;
@ -13,23 +13,23 @@ public class AddingMemberList extends MemberList {
super();
}
public AddingMemberList(DefaultListModel<RemoteMember> dataModel) {
public AddingMemberList(DefaultListModel<RemoteDesignMember> dataModel) {
super(dataModel);
}
public AddingMemberList(RemoteMember[] listData) {
public AddingMemberList(RemoteDesignMember[] listData) {
super(listData);
}
public AddingMemberList(Vector<? extends RemoteMember> listData) {
public AddingMemberList(Vector<? extends RemoteDesignMember> listData) {
super(listData);
}
@Override
protected void displaySelected() {
RemoteMember member = getSelectedValue();
RemoteDesignMember member = getSelectedValue();
member.setSelected(!member.isSelected());
revalidate();
repaint();

8
designer-base/src/com/fr/design/remote/ui/list/AddingMemberListCellRender.java

@ -3,7 +3,7 @@ package com.fr.design.remote.ui.list;
import com.fr.base.BaseUtils;
import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.remote.RemoteMember;
import com.fr.env.RemoteDesignMember;
import javax.swing.BorderFactory;
import javax.swing.JList;
@ -12,7 +12,7 @@ import javax.swing.ListCellRenderer;
import java.awt.Component;
import java.awt.FlowLayout;
public class AddingMemberListCellRender extends JPanel implements ListCellRenderer<RemoteMember> {
public class AddingMemberListCellRender extends JPanel implements ListCellRenderer<RemoteDesignMember> {
private UILabel label;
private UICheckBox check;
@ -35,8 +35,8 @@ public class AddingMemberListCellRender extends JPanel implements ListCellRender
@Override
public Component getListCellRendererComponent(JList list, RemoteMember member, int index, boolean isSelected, boolean cellHasFocus) {
this.setLabelText(member.getUsername());
public Component getListCellRendererComponent(JList list, RemoteDesignMember member, int index, boolean isSelected, boolean cellHasFocus) {
this.setLabelText(member.getRealName() + "(" + member.getUsername() + ")");
check.setSelected(member.isSelected());
return this;
}

2
designer-base/src/com/fr/design/remote/ui/list/AuthorityListCellRenderer.java

@ -82,7 +82,7 @@ public class AuthorityListCellRenderer extends
setBorder(border);
this.setIcon(BaseUtils.readIcon("com/fr/design/remote/images/icon_Member_normal@1x.png"));
this.setText(authority.getUsername());
this.setText(authority.getRealName() + "(" + authority.getUsername() + ")");
return this;
}

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

@ -1,6 +1,7 @@
package com.fr.design.remote.ui.list;
import com.fr.design.remote.RemoteMember;
import com.fr.env.RemoteDesignMember;
import javax.swing.DefaultListModel;
import javax.swing.JList;
@ -12,19 +13,19 @@ import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.Vector;
public abstract class MemberList extends JList<RemoteMember> {
public abstract class MemberList extends JList<RemoteDesignMember> {
public MemberList(DefaultListModel<RemoteMember> dataModel) {
public MemberList(DefaultListModel<RemoteDesignMember> dataModel) {
super(dataModel);
init();
}
public MemberList(RemoteMember[] listData) {
public MemberList(RemoteDesignMember[] listData) {
super(listData);
init();
}
public MemberList(Vector<? extends RemoteMember> listData) {
public MemberList(Vector<? extends RemoteDesignMember> listData) {
super(listData);
init();
}

Loading…
Cancel
Save