diff --git a/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java b/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java index 78e440ab7..8f20583ab 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java +++ b/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(); } @@ -474,7 +479,7 @@ public abstract class ToolBarMenuDock { shortCuts.add(new TutorialAction()); } //远程不使用更新升级 - if(WorkContext.getCurrent().isLocal()) { + if (WorkContext.getCurrent().isLocal()) { shortCuts.add(new SoftwareUpdateAction()); } diff --git a/designer-base/src/main/java/com/fr/design/remote/action/RemoteDesignAuthorityManagerAction.java b/designer-base/src/main/java/com/fr/design/remote/action/RemoteDesignAuthManagerAction.java similarity index 80% rename from designer-base/src/main/java/com/fr/design/remote/action/RemoteDesignAuthorityManagerAction.java rename to designer-base/src/main/java/com/fr/design/remote/action/RemoteDesignAuthManagerAction.java index ceebd0c01..ff96907a7 100644 --- a/designer-base/src/main/java/com/fr/design/remote/action/RemoteDesignAuthorityManagerAction.java +++ b/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); diff --git a/designer-base/src/main/java/com/fr/design/remote/ui/AuthorityListControlPane.java b/designer-base/src/main/java/com/fr/design/remote/ui/AuthorityListControlPane.java index f917e9219..7404ed699 100644 --- a/designer-base/src/main/java/com/fr/design/remote/ui/AuthorityListControlPane.java +++ b/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 authorities) { + + if (authorities == null || authorities.isEmpty()) { + return; + } + + DefaultListModel model = (DefaultListModel) 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 getModel() { return (DefaultListModel) 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 members = userManagerPane.update(); + + List 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 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)); diff --git a/designer-base/src/main/java/com/fr/design/remote/ui/AuthorityManagerPane.java b/designer-base/src/main/java/com/fr/design/remote/ui/AuthorityManagerPane.java index f84bff5c9..7dbf8ed4e 100644 --- a/designer-base/src/main/java/com/fr/design/remote/ui/AuthorityManagerPane.java +++ b/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) { diff --git a/designer-base/src/main/java/com/fr/design/remote/ui/UserManagerPane.java b/designer-base/src/main/java/com/fr/design/remote/ui/UserManagerPane.java index bb3f222b9..6c4037145 100644 --- a/designer-base/src/main/java/com/fr/design/remote/ui/UserManagerPane.java +++ b/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 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() { diff --git a/designer-base/src/main/resources/com/fr/design/remote/images/icon_Remote_Design_Permission_Manager_normal@1x.png b/designer-base/src/main/resources/com/fr/design/remote/images/icon_Remote_Design_Auth_Manager_normal@1x.png similarity index 100% rename from designer-base/src/main/resources/com/fr/design/remote/images/icon_Remote_Design_Permission_Manager_normal@1x.png rename to designer-base/src/main/resources/com/fr/design/remote/images/icon_Remote_Design_Auth_Manager_normal@1x.png diff --git a/designer-base/src/main/resources/com/fr/design/remote/images/icon_Remote_Design_Permission_Manager_normal@2x.png b/designer-base/src/main/resources/com/fr/design/remote/images/icon_Remote_Design_Auth_Manager_normal@2x.png similarity index 100% rename from designer-base/src/main/resources/com/fr/design/remote/images/icon_Remote_Design_Permission_Manager_normal@2x.png rename to designer-base/src/main/resources/com/fr/design/remote/images/icon_Remote_Design_Auth_Manager_normal@2x.png