Browse Source

Merge pull request #442 in DESIGN/design from ~YAOH.WU/design:feature/10.0 to feature/10.0

* commit '81a7cfef3287730ebfb850535dae4493d8645f7b':
  REPORT-10390 远程设计权限-选择成员交互修订
research/10.0
yaoh.wu 6 years ago
parent
commit
fed7565a4a
  1. 15
      designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java
  2. 21
      designer-base/src/main/java/com/fr/design/remote/action/RemoteDesignAuthManagerAction.java
  3. 77
      designer-base/src/main/java/com/fr/design/remote/ui/AuthorityListControlPane.java
  4. 4
      designer-base/src/main/java/com/fr/design/remote/ui/AuthorityManagerPane.java
  5. 15
      designer-base/src/main/java/com/fr/design/remote/ui/UserManagerPane.java
  6. 0
      designer-base/src/main/resources/com/fr/design/remote/images/icon_Remote_Design_Auth_Manager_normal@1x.png
  7. 0
      designer-base/src/main/resources/com/fr/design/remote/images/icon_Remote_Design_Auth_Manager_normal@2x.png

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

@ -16,7 +16,6 @@ import com.fr.design.actions.community.NeedAction;
import com.fr.design.actions.community.QuestionAction;
import com.fr.design.actions.community.SignAction;
import com.fr.design.actions.community.TechSolutionAction;
import com.fr.design.actions.community.UpAction;
import com.fr.design.actions.community.VideoAction;
import com.fr.design.actions.file.CloseCurrentTemplateAction;
import com.fr.design.actions.file.ExitDesignerAction;
@ -51,7 +50,7 @@ import com.fr.design.menu.SeparatorDef;
import com.fr.design.menu.ShortCut;
import com.fr.design.menu.ToolBarDef;
import com.fr.design.onlineupdate.actions.SoftwareUpdateAction;
import com.fr.design.remote.action.RemoteDesignAuthorityManagerAction;
import com.fr.design.remote.action.RemoteDesignAuthManagerAction;
import com.fr.design.utils.ThemeUtils;
import com.fr.general.ComparatorUtils;
import com.fr.general.GeneralContext;
@ -426,8 +425,8 @@ public abstract class ToolBarMenuDock {
new PlatformManagerAction()
);
if (shouldShowRemotePermission()) {
menuDef.addShortCut(new RemoteDesignAuthorityManagerAction());
if (shouldShowRemoteAuth()) {
menuDef.addShortCut(new RemoteDesignAuthManagerAction());
}
if (!DesignerMode.isAuthorityEditing()) {
@ -451,7 +450,13 @@ public abstract class ToolBarMenuDock {
return processor == null ? new GlobalTableDataAction() : processor.createServerTDAction();
}
private boolean shouldShowRemotePermission() {
/**
* 判断是否应该展示远程设计权限管理
* 如果当前环境是远程环境并且登录用户为管理员那么应该展示否则不予展示
*
* @return boolean
*/
private boolean shouldShowRemoteAuth() {
return WorkContext.getCurrent() != null && !WorkContext.getCurrent().isLocal() && WorkContext.getCurrent().isRoot();
}

21
designer-base/src/main/java/com/fr/design/remote/action/RemoteDesignAuthorityManagerAction.java → designer-base/src/main/java/com/fr/design/remote/action/RemoteDesignAuthManagerAction.java

@ -4,25 +4,25 @@ import com.fr.base.BaseUtils;
import com.fr.design.actions.UpdateAction;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.remote.ui.AuthorityManagerPane;
import com.fr.workspace.server.authority.AuthorityOperator;
import com.fr.log.FineLoggerFactory;
import com.fr.report.DesignAuthority;
import com.fr.workspace.WorkContext;
import com.fr.workspace.server.authority.AuthorityOperator;
import java.awt.event.ActionEvent;
/**
* @author yaohwu
*/
public class RemoteDesignAuthorityManagerAction extends UpdateAction {
public class RemoteDesignAuthManagerAction extends UpdateAction {
public RemoteDesignAuthorityManagerAction() {
this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Authority_Manager"));
this.setSmallIcon(BaseUtils.readIcon("com/fr/design/remote/images/icon_Remote_Design_Permission_Manager_normal@1x.png"));
public RemoteDesignAuthManagerAction() {
this.setName(Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Authority_Manager"));
this.setSmallIcon(BaseUtils.readIcon("com/fr/design/remote/images/icon_Remote_Design_Auth_Manager_normal@1x.png"));
}
@ -49,7 +49,6 @@ public class RemoteDesignAuthorityManagerAction extends UpdateAction {
@Override
public void doOk() {
DesignAuthority[] authorities = managerPane.update();
if (!WorkContext.getCurrent().isLocal()) {
boolean success = false;
@ -58,15 +57,9 @@ public class RemoteDesignAuthorityManagerAction extends UpdateAction {
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
FineLoggerFactory.getLogger().info("update remote design authority: " + success);
FineLoggerFactory.getLogger().debug("update remote design authority: " + success);
}
}
@Override
public void doCancel() {
super.doCancel();
}
});
dialog.setModal(true);
dialog.setVisible(true);

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

@ -10,6 +10,7 @@ import com.fr.design.gui.controlpane.ShortCut4JControlPane;
import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itoolbar.UIToolbar;
import com.fr.design.i18n.Toolkit;
import com.fr.design.icon.IconPathConstants;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.menu.ShortCut;
@ -19,7 +20,6 @@ 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.general.ComparatorUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.report.DesignAuthority;
import com.fr.stable.ArrayUtils;
@ -78,7 +78,7 @@ public class AuthorityListControlPane extends BasicPane {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.authorityCreators = new RemoteDesignAuthorityCreator[]{
new RemoteDesignAuthorityCreator(
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Remote_Design_User"),
Toolkit.i18nText("Fine-Design_Basic_Remote_Design_User"),
BaseUtils.readIcon("com/fr/design/remote/images/icon_Member_normal@1x.png"),
DesignAuthority.class,
AuthorityEditorPane.class)
@ -247,6 +247,34 @@ public class AuthorityListControlPane extends BasicPane {
}
/**
* 添加 RemoteDesignAuthority
*
* @param authorities authority
*/
public void setAuthority(List<DesignAuthority> authorities) {
if (authorities == null || authorities.isEmpty()) {
return;
}
DefaultListModel<DesignAuthority> model = (DefaultListModel<DesignAuthority>) authorityList.getModel();
model.clear();
for (DesignAuthority authority : authorities) {
model.addElement(authority);
}
int size = model.getSize() - 1;
authorityList.setSelectedIndex(size);
authorityList.ensureIndexIsVisible(size);
authorityList.revalidate();
authorityList.repaint();
}
protected DefaultListModel<DesignAuthority> getModel() {
return (DefaultListModel<DesignAuthority>) this.authorityList.getModel();
}
@ -465,12 +493,12 @@ public class AuthorityListControlPane extends BasicPane {
}
/**
* 添加按钮
* 选择按钮
*/
private class AddItemUpdateAction extends UpdateAction {
AddItemUpdateAction() {
this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Action_Add"));
this.setName(Toolkit.i18nText("Fine-Design_Basic_Action_Choose"));
this.setMnemonic('A');
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/buttonicon/add.png"));
}
@ -480,29 +508,54 @@ public class AuthorityListControlPane extends BasicPane {
final UserManagerPane userManagerPane = new UserManagerPane();
BasicDialog dialog = userManagerPane.showWindow(SwingUtilities.getWindowAncestor(AuthorityListControlPane.this));
// 刷新用户管理面板展示信息
final DesignAuthority[] authorities = AuthorityListControlPane.this.update();
dialog.addDialogActionListener(new DialogActionAdapter() {
@Override
public void doOk() {
// 获取添加的用户到权限编辑面板
List<RemoteDesignMember> members = userManagerPane.update();
List<DesignAuthority> oldAuthorities = new ArrayList<>();
// 已有的未修改的
for (RemoteDesignMember member : members) {
for (DesignAuthority authority : authorities) {
if (member.getUserId().equals(authority.getUserId())) {
oldAuthorities.add(authority);
}
}
}
// 保留已有且仍选择的,删除不再选择的
setAuthority(oldAuthorities);
// 新增的
for (RemoteDesignMember member : members) {
DesignAuthority authority = new DesignAuthority();
authority.setUsername(member.getUsername());
authority.setUserId(member.getUserId());
authority.setRealName(member.getRealName());
AuthorityListControlPane.this.addAuthority(authority, getModel().getSize());
}
addAuthority(authority, getModel().getSize());
}
@Override
public void doCancel() {
super.doCancel();
}
});
dialog.setModal(true);
dialog.setVisible(true);
List<RemoteDesignMember> members = new ArrayList<>();
for (DesignAuthority authority : authorities) {
RemoteDesignMember m = new RemoteDesignMember();
m.setUsername(authority.getUsername());
m.setUserId(authority.getUserId());
m.setRealName(authority.getRealName());
m.setSelected(true);
members.add(m);
}
userManagerPane.populate(members);
dialog.setModal(true);
dialog.setVisible(true);
}
}
@ -511,7 +564,7 @@ public class AuthorityListControlPane extends BasicPane {
*/
private class RemoveItemAction extends UpdateAction {
RemoveItemAction() {
this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Action_Remove"));
this.setName(Toolkit.i18nText("Fine-Design_Basic_Action_Remove"));
this.setMnemonic('R');
this.setSmallIcon(BaseUtils
.readIcon(IconPathConstants.TD_REMOVE_ICON_PATH));

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

@ -1,7 +1,7 @@
package com.fr.design.remote.ui;
import com.fr.design.dialog.BasicPane;
import com.fr.design.i18n.Toolkit;
import com.fr.report.DesignAuthority;
import javax.swing.BorderFactory;
@ -23,7 +23,7 @@ public class AuthorityManagerPane extends BasicPane {
@Override
protected String title4PopupWindow() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Authority_Manager");
return Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Authority_Manager");
}
public void populate(DesignAuthority[] authorities) {

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

@ -208,10 +208,23 @@ public class UserManagerPane extends BasicPane {
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_Add_Member");
return Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Choose_Member");
}
private JPanel createLeftPanel() {

0
designer-base/src/main/resources/com/fr/design/remote/images/icon_Remote_Design_Permission_Manager_normal@1x.png → designer-base/src/main/resources/com/fr/design/remote/images/icon_Remote_Design_Auth_Manager_normal@1x.png

Before

Width:  |  Height:  |  Size: 575 B

After

Width:  |  Height:  |  Size: 575 B

0
designer-base/src/main/resources/com/fr/design/remote/images/icon_Remote_Design_Permission_Manager_normal@2x.png → designer-base/src/main/resources/com/fr/design/remote/images/icon_Remote_Design_Auth_Manager_normal@2x.png

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Loading…
Cancel
Save