Browse Source

REPORT-6700 远程设计权限

master
yaoh.wu 7 years ago
parent
commit
9d8bffd456
  1. 32
      designer-base/src/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java
  2. 14
      designer-base/src/com/fr/design/remote/RemoteDesignAuthority.java
  3. 45
      designer-base/src/com/fr/design/remote/RemoteDesignAuthorityCreator.java
  4. 20
      designer-base/src/com/fr/design/remote/RemoteMember.java
  5. 48
      designer-base/src/com/fr/design/remote/action/RemoteDesignAuthorityManagerAction.java
  6. BIN
      designer-base/src/com/fr/design/remote/images/icon_List_Folder_normal@1x.png
  7. BIN
      designer-base/src/com/fr/design/remote/images/icon_List_Folder_normal@2x.png
  8. BIN
      designer-base/src/com/fr/design/remote/images/icon_Member_normal@1x.png
  9. BIN
      designer-base/src/com/fr/design/remote/images/icon_Member_normal@2x.png
  10. BIN
      designer-base/src/com/fr/design/remote/images/icon_Member_white@1x.png
  11. BIN
      designer-base/src/com/fr/design/remote/images/icon_Member_white@2x.png
  12. BIN
      designer-base/src/com/fr/design/remote/images/icon_NewFolderIcon_normal.png
  13. BIN
      designer-base/src/com/fr/design/remote/images/icon_NewFolderIcon_normal@2x.png
  14. BIN
      designer-base/src/com/fr/design/remote/images/icon_Remote_Design_Permission_Manager_normal@1x.png
  15. BIN
      designer-base/src/com/fr/design/remote/images/icon_Remote_Design_Permission_Manager_normal@2x.png
  16. 33
      designer-base/src/com/fr/design/remote/ui/AuthorityEditorPane.java
  17. 520
      designer-base/src/com/fr/design/remote/ui/AuthorityListControlPane.java
  18. 37
      designer-base/src/com/fr/design/remote/ui/AuthorityManagerPane.java
  19. 98
      designer-base/src/com/fr/design/remote/ui/UserManagerPane.java
  20. 28
      designer-base/src/com/fr/design/remote/ui/list/AuthorityList.java
  21. 132
      designer-base/src/com/fr/design/remote/ui/list/AuthorityListCellRenderer.java
  22. 39
      designer-base/src/com/fr/design/remote/ui/list/MemberList.java
  23. 45
      designer-base/src/com/fr/design/remote/ui/list/MemberListCellRender.java
  24. 6
      designer-base/src/com/fr/design/remote/ui/tree/FileAuthorityTree.java

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

@ -32,6 +32,7 @@ import com.fr.design.actions.server.GlobalParameterAction;
import com.fr.design.actions.server.GlobalTableDataAction;
import com.fr.design.actions.server.PlatformManagerAction;
import com.fr.design.actions.server.PluginManagerAction;
import com.fr.design.remote.action.RemoteDesignAuthorityManagerAction;
import com.fr.design.file.NewTemplatePane;
import com.fr.design.fun.MenuHandler;
import com.fr.design.fun.TableDataPaneProcessor;
@ -58,11 +59,20 @@ import com.fr.plugin.observer.PluginEvent;
import com.fr.plugin.observer.PluginEventListener;
import com.fr.plugin.observer.PluginEventType;
import com.fr.stable.ArrayUtils;
import com.fr.stable.ProductConstants;
import com.fr.stable.StringUtils;
import javax.swing.*;
import java.awt.*;
import javax.swing.Icon;
import javax.swing.JComponent;
import javax.swing.JMenuBar;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import javax.swing.UIManager;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@ -103,10 +113,12 @@ public abstract class ToolBarMenuDock {
return new JPanel[0];
}
@Override
public JComponent[] toolBarButton4Form() {
return new JComponent[0];
}
@Override
public JComponent toolBar4Authority() {
return new JPanel();
}
@ -116,6 +128,7 @@ public abstract class ToolBarMenuDock {
return DesignState.WORK_SHEET;
}
@Override
public int getToolBarHeight() {
return PANLE_HEIGNT;
}
@ -125,6 +138,7 @@ public abstract class ToolBarMenuDock {
*
* @return 子菜单
*/
@Override
public ShortCut[] shortcut4ExportMenu() {
return new ShortCut[0];
}
@ -404,6 +418,10 @@ public abstract class ToolBarMenuDock {
new PlatformManagerAction()
);
if (shouldShowRemotePermission()) {
menuDef.addShortCut(new RemoteDesignAuthorityManagerAction());
}
if (!BaseUtils.isAuthorityEditing()) {
if (shouldShowPlugin()) {
menuDef.addShortCut(
@ -425,6 +443,11 @@ public abstract class ToolBarMenuDock {
return processor == null ? new GlobalTableDataAction() : processor.createServerTDAction();
}
protected boolean shouldShowRemotePermission() {
// todo 依据是否是远程设计 并且当前登录的用户是否是管理员 进行判断 是否展示远程设计权限管理
return true;
}
protected boolean shouldShowPlugin() {
return !(FRContext.getCurrentEnv() instanceof RemoteEnv) && FRContext.isChineseEnv();
}
@ -527,6 +550,7 @@ public abstract class ToolBarMenuDock {
protected JPanel polyToolBar(String text) {
JPanel panel = new JPanel(new BorderLayout()) {
@Override
public Dimension getPreferredSize() {
Dimension dim = super.getPreferredSize();
dim.height = PANLE_HEIGNT;
@ -711,6 +735,7 @@ public abstract class ToolBarMenuDock {
private abstract class AbstractShortCutMethodAction implements ShortCutMethodAction {
@Override
public ShortCut methodAction(MenuHandler handler) {
return handler.shortcut();
}
@ -731,6 +756,7 @@ public abstract class ToolBarMenuDock {
this.plus = plus;
}
@Override
public ShortCut methodAction(MenuHandler handler) {
return handler.shortcut(plus);
}

14
designer-base/src/com/fr/design/remote/RemoteDesignAuthority.java

@ -0,0 +1,14 @@
package com.fr.design.remote;
public class RemoteDesignAuthority {
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}

45
designer-base/src/com/fr/design/remote/RemoteDesignAuthorityCreator.java

@ -0,0 +1,45 @@
package com.fr.design.remote;
import com.fr.design.beans.BasicBeanPane;
import javax.swing.Icon;
public class RemoteDesignAuthorityCreator {
private String name;
private Icon icon;
private Class clazz;
private Class<? extends BasicBeanPane> editorClazz;
public RemoteDesignAuthorityCreator(String name, Icon icon, Class clazz, Class<? extends BasicBeanPane> editorClazz) {
this.name = name;
this.icon = icon;
this.clazz = clazz;
this.editorClazz = editorClazz;
}
public boolean accept(Object object) {
return this.clazz != null && this.clazz.isInstance(object);
}
public String getName() {
return name;
}
public Icon getIcon() {
return icon;
}
public Class getClazz() {
return clazz;
}
public Class<? extends BasicBeanPane> getEditorClazz() {
return editorClazz;
}
public void saveUpdatedBean(RemoteDesignAuthority authority, Object bean) {
}
}

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

@ -0,0 +1,20 @@
package com.fr.design.remote;
public class RemoteMember {
public static final RemoteMember DEFAULT_MEMBER = new RemoteMember("查询中...");
private String name;
public RemoteMember(String name) {
this.name = name;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}

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

@ -0,0 +1,48 @@
package com.fr.design.remote.action;
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.mainframe.DesignerContext;
import com.fr.design.remote.ui.AuthorityManagerPane;
import java.awt.event.ActionEvent;
/**
* @author yaohwu
*/
public class RemoteDesignAuthorityManagerAction extends UpdateAction {
public RemoteDesignAuthorityManagerAction() {
this.setName("远程设计权限管理");
this.setSmallIcon(BaseUtils.readIcon("com/fr/design/remote/images/icon_Remote_Design_Permission_Manager_normal@1x.png"));
}
@Override
public void actionPerformed(ActionEvent e) {
AuthorityManagerPane managerPane = new AuthorityManagerPane();
BasicDialog dialog = managerPane.showWindow(DesignerContext.getDesignerFrame());
//todo read contents from database by hibernate to show
dialog.addDialogActionListener(new DialogActionAdapter() {
@Override
public void doOk() {
//todo save contents into database by hibernate
}
@Override
public void doCancel() {
super.doCancel();
}
});
dialog.setModal(true);
dialog.setVisible(true);
}
}

BIN
designer-base/src/com/fr/design/remote/images/icon_List_Folder_normal@1x.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 337 B

BIN
designer-base/src/com/fr/design/remote/images/icon_List_Folder_normal@2x.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 548 B

BIN
designer-base/src/com/fr/design/remote/images/icon_Member_normal@1x.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 525 B

BIN
designer-base/src/com/fr/design/remote/images/icon_Member_normal@2x.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
designer-base/src/com/fr/design/remote/images/icon_Member_white@1x.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 350 B

BIN
designer-base/src/com/fr/design/remote/images/icon_Member_white@2x.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 746 B

BIN
designer-base/src/com/fr/design/remote/images/icon_NewFolderIcon_normal.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 288 B

BIN
designer-base/src/com/fr/design/remote/images/icon_NewFolderIcon_normal@2x.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 531 B

BIN
designer-base/src/com/fr/design/remote/images/icon_Remote_Design_Permission_Manager_normal@1x.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 575 B

BIN
designer-base/src/com/fr/design/remote/images/icon_Remote_Design_Permission_Manager_normal@2x.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

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

@ -0,0 +1,33 @@
package com.fr.design.remote.ui;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.remote.RemoteDesignAuthority;
import javax.swing.BorderFactory;
import java.awt.BorderLayout;
import java.awt.Label;
public class AuthorityEditorPane extends BasicBeanPane<RemoteDesignAuthority> {
public AuthorityEditorPane() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.setBorder(BorderFactory.createEmptyBorder());
this.add(new Label("editor"), BorderLayout.CENTER);
}
@Override
protected String title4PopupWindow() {
return "编辑文件权限";
}
@Override
public void populateBean(RemoteDesignAuthority ob) {
}
@Override
public RemoteDesignAuthority updateBean() {
return new RemoteDesignAuthority();
}
}

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

@ -0,0 +1,520 @@
package com.fr.design.remote.ui;
import com.fr.base.BaseUtils;
import com.fr.design.actions.UpdateAction;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.BasicPane;
import com.fr.design.dialog.DialogActionAdapter;
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.icon.IconPathConstants;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.menu.ShortCut;
import com.fr.design.menu.ToolBarDef;
import com.fr.design.remote.RemoteDesignAuthority;
import com.fr.design.remote.RemoteDesignAuthorityCreator;
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.general.Inter;
import com.fr.stable.ArrayUtils;
import javax.swing.BorderFactory;
import javax.swing.DefaultListModel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JSplitPane;
import javax.swing.ListSelectionModel;
import javax.swing.SwingUtilities;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.event.ActionEvent;
import java.util.ArrayList;
import java.util.List;
public class AuthorityListControlPane extends BasicPane {
private static final String LIST_NAME = "AuthorityListControlPaneList";
private static final String UNSELECTED_EDITOR_NAME = "UNSELECTED";
private static final String SELECTED_EDITOR_NAME = "SELECTED";
private AuthorityList authorityList;
private static final int SHORT_WIDTH = 30;
private ListEditorControlPane editorCtrl;
private CardLayout cardLayout;
private JPanel cardPane;
private ShortCut4JControlPane[] shortCuts;
private RemoteDesignAuthorityCreator[] authorityCreators;
private ToolBarDef toolbarDef;
private UIToolbar toolBar;
public AuthorityListControlPane() {
super();
initComponentPane();
}
private void initComponentPane() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.authorityCreators = new RemoteDesignAuthorityCreator[]{
new RemoteDesignAuthorityCreator(
"远程设计用户",
BaseUtils.readIcon("com/fr/design/remote/images/icon_Member_normal@1x.png"),
RemoteDesignAuthority.class,
AuthorityEditorPane.class)
};
editorCtrl = new ListEditorControlPane();
// 左侧列表面板
JPanel leftPane = new JPanel(new BorderLayout());
initLeftList(leftPane);
initLeftToolbar(leftPane);
// 右侧卡片布局
cardLayout = new CardLayout();
cardPane = new JPanel(cardLayout);
UILabel selectLabel = new UILabel();
cardPane.add(selectLabel, UNSELECTED_EDITOR_NAME);
cardPane.add(editorCtrl, SELECTED_EDITOR_NAME);
// 左右分割布局
JSplitPane mainSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, leftPane, cardPane);
mainSplitPane.setBorder(BorderFactory.createLineBorder(GUICoreUtils.getTitleLineBorderColor()));
mainSplitPane.setOneTouchExpandable(true);
add(mainSplitPane, BorderLayout.CENTER);
mainSplitPane.setDividerLocation(shortCuts.length * SHORT_WIDTH);
checkButtonEnabled();
}
private void initLeftToolbar(JPanel leftPane) {
shortCuts = createShortcuts();
if (ArrayUtils.isEmpty(shortCuts)) {
return;
}
toolbarDef = new ToolBarDef();
for (ShortCut4JControlPane sj : shortCuts) {
toolbarDef.addShortCut(sj.getShortCut());
}
toolBar = ToolBarDef.createJToolBar();
toolbarDef.updateToolBar(toolBar);
leftPane.add(toolBar, BorderLayout.NORTH);
}
private void initLeftList(JPanel leftPane) {
authorityList = createList();
authorityList.setName(LIST_NAME);
leftPane.add(new UIScrollPane(authorityList), BorderLayout.CENTER);
authorityList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
authorityList.addListSelectionListener(new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent evt) {
//避免多次update和populate大大降低效率
if (!evt.getValueIsAdjusting()) {
//切换的时候加检验
if (hasInvalid()) {
return;
}
AuthorityListControlPane.this.editorCtrl.update();
AuthorityListControlPane.this.editorCtrl.populate();
AuthorityListControlPane.this.checkButtonEnabled();
}
}
});
}
private AuthorityList createList() {
AuthorityList list = new AuthorityList(new DefaultListModel<RemoteDesignAuthority>());
list.setCellRenderer(new AuthorityListCellRenderer());
return list;
}
private void doWhenPopulate() {
}
private void doBeforePopulate() {
}
public RemoteDesignAuthority[] update() {
List<RemoteDesignAuthority> res = new ArrayList<>();
this.editorCtrl.update();
DefaultListModel listModel = (DefaultListModel) this.authorityList.getModel();
for (int i = 0, len = listModel.getSize(); i < len; i++) {
res.add((RemoteDesignAuthority) listModel.getElementAt(i));
}
return res.toArray(new RemoteDesignAuthority[0]);
}
public void populate(RemoteDesignAuthority[] authorities) {
DefaultListModel<RemoteDesignAuthority> listModel = (DefaultListModel<RemoteDesignAuthority>) this.authorityList.getModel();
listModel.removeAllElements();
if (ArrayUtils.isEmpty(authorities)) {
return;
}
for (RemoteDesignAuthority authority : authorities) {
listModel.addElement(authority);
}
if (listModel.size() > 0) {
this.authorityList.setSelectedIndex(0);
}
this.checkButtonEnabled();
}
public void updateEditorCtrlPane() {
editorCtrl.update();
}
/*
* 刷新当前的选中的UpdatePane
*/
public void populateEditorCtrlPane() {
this.editorCtrl.populate();
}
public void setSelectedName(String name) {
DefaultListModel listModel = (DefaultListModel) this.authorityList.getModel();
for (int i = 0, len = listModel.getSize(); i < len; i++) {
RemoteDesignAuthority authority = (RemoteDesignAuthority) listModel.getElementAt(i);
if (ComparatorUtils.equals(name, authority.getName())) {
this.authorityList.setSelectedIndex(i);
break;
}
}
}
/**
* 获取选中的名字
*/
public String getSelectedName() {
RemoteDesignAuthority authority = (RemoteDesignAuthority) this.authorityList.getSelectedValue();
return authority == null ? null : authority.getName();
}
/**
* 添加 RemoteDesignAuthority
*
* @param authority authority
* @param index 序号
*/
public void addAuthority(RemoteDesignAuthority authority, int index) {
DefaultListModel<RemoteDesignAuthority> model = (DefaultListModel<RemoteDesignAuthority>) authorityList.getModel();
model.add(index, authority);
authorityList.setSelectedIndex(index);
authorityList.ensureIndexIsVisible(index);
authorityList.revalidate();
authorityList.repaint();
}
protected DefaultListModel<RemoteDesignAuthority> getModel() {
return (DefaultListModel<RemoteDesignAuthority>) this.authorityList.getModel();
}
/**
* 检查按钮可用状态 Check button enabled.
*/
public void checkButtonEnabled() {
if (authorityList.getSelectedIndex() == -1) {
this.cardLayout.show(cardPane, UNSELECTED_EDITOR_NAME);
} else {
this.cardLayout.show(cardPane, SELECTED_EDITOR_NAME);
}
for (ShortCut4JControlPane shortCut : shortCuts) {
shortCut.checkEnable();
}
}
public class AbsoluteEnableShortCut extends ShortCut4JControlPane {
AbsoluteEnableShortCut(ShortCut shortCut) {
this.shortCut = shortCut;
}
/**
* 检查是否可用
*/
@Override
public void checkEnable() {
this.shortCut.setEnabled(true);
}
}
public class NormalEnableShortCut extends ShortCut4JControlPane {
NormalEnableShortCut(ShortCut shortCut) {
this.shortCut = shortCut;
}
/**
* 检查是否可用
*/
@Override
public void checkEnable() {
this.shortCut.setEnabled(authorityList.getModel()
.getSize() > 0
&& AuthorityListControlPane.this.authorityList.getSelectedIndex() != -1);
}
}
private BasicBeanPane createPaneByCreators(RemoteDesignAuthorityCreator creator) {
try {
return creator.getEditorClazz().newInstance();
} catch (InstantiationException | IllegalAccessException e) {
throw new RuntimeException(e);
}
}
/**
* 检查是否符合规范
*
* @throws Exception e
*/
@Override
public void checkValid() throws Exception {
this.editorCtrl.checkValid();
}
private int getInValidIndex() {
BasicBeanPane[] p = editorCtrl.editorPanes;
if (p != null) {
for (int i = 0; i < p.length; i++) {
if (p[i] != null) {
try {
p[i].checkValid();
} catch (Exception e) {
return i;
}
}
}
}
return -1;
}
private boolean hasInvalid() {
int idx = AuthorityListControlPane.this.getInValidIndex();
if (authorityList.getSelectedIndex() != idx) {
try {
checkValid();
} catch (Exception exp) {
JOptionPane.showMessageDialog(AuthorityListControlPane.this, exp.getMessage());
authorityList.setSelectedIndex(idx);
return true;
}
}
return false;
}
/**
* 设置选中项
*
* @param index 选中项的序列号
*/
public void setSelectedIndex(int index) {
authorityList.setSelectedIndex(index);
}
private ShortCut4JControlPane[] createShortcuts() {
return new ShortCut4JControlPane[]{
new AbsoluteEnableShortCut(new AddItemUpdateAction(authorityCreators)),
new NormalEnableShortCut(new RemoveItemAction())
};
}
private void doBeforeRemove() {
}
private void doAfterRemove() {
}
/**
* 刷新 creators
*
* @param creators 生成器
*/
public void refreshCreator(RemoteDesignAuthorityCreator[] creators) {
this.authorityCreators = creators;
shortCuts = this.createShortcuts();
toolbarDef.clearShortCuts();
for (ShortCut4JControlPane sj : shortCuts) {
toolbarDef.addShortCut(sj.getShortCut());
}
toolbarDef.updateToolBar(toolBar);
toolBar.validate();
toolBar.repaint();
this.repaint();
}
@Override
protected String title4PopupWindow() {
return null;
}
private class ListEditorControlPane extends JPanel {
private CardLayout card;
private JPanel cardPane;
private BasicBeanPane[] editorPanes;
private RemoteDesignAuthority authority;
ListEditorControlPane() {
initUpdatePane();
}
private void initUpdatePane() {
card = new CardLayout();
cardPane = FRGUIPaneFactory.createCardLayout_S_Pane();
cardPane.setLayout(card);
this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.add(cardPane);
editorPanes = new BasicBeanPane[authorityCreators.length];
}
public void populate() {
authority = (RemoteDesignAuthority) AuthorityListControlPane.this.authorityList.getSelectedValue();
if (authority == null) {
return;
}
for (int i = 0, len = editorPanes.length; i < len; i++) {
if (authorityCreators[i].accept(authority)) {
editorPanes[i] = createPaneByCreators(authorityCreators[i]);
cardPane.add(editorPanes[i], String.valueOf(i));
card.show(cardPane, String.valueOf(i));
doBeforePopulate();
editorPanes[i].populateBean(authority);
doWhenPopulate();
break;
}
}
}
public void update() {
for (int i = 0; i < editorPanes.length; i++) {
BasicBeanPane pane = editorPanes[i];
if (pane != null && pane.isVisible()) {
Object bean = pane.updateBean();
if (i < authorityCreators.length) {
authorityCreators[i].saveUpdatedBean(authority, bean);
}
}
}
}
public void checkValid() throws Exception {
if (editorPanes != null) {
for (BasicBeanPane updatePane : editorPanes) {
if (updatePane != null) {
updatePane.checkValid();
}
}
}
}
}
/**
* 添加按钮
*/
private class AddItemUpdateAction extends UpdateAction {
private RemoteDesignAuthorityCreator creator;
AddItemUpdateAction(RemoteDesignAuthorityCreator[] creators) {
this.creator = creators[0];
this.setName(Inter.getLocText("FR-Action_Add"));
this.setMnemonic('A');
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/buttonicon/add.png"));
}
@Override
public void actionPerformed(ActionEvent e) {
final UserManagerPane userManagerPane = new UserManagerPane();
BasicDialog dialog = userManagerPane.showWindow(SwingUtilities.getWindowAncestor(AuthorityListControlPane.this));
dialog.addDialogActionListener(new DialogActionAdapter() {
@Override
public void doOk() {
// todo 获取 UserManagerPane 添加的用户
userManagerPane.title4PopupWindow();
RemoteDesignAuthority authority = new RemoteDesignAuthority();
authority.setName("new User");
AuthorityListControlPane.this.addAuthority(authority, getModel().getSize());
}
@Override
public void doCancel() {
super.doCancel();
}
});
dialog.setModal(true);
dialog.setVisible(true);
}
}
/*
* 删除按钮
*/
private class RemoveItemAction extends UpdateAction {
RemoveItemAction() {
this.setName(Inter.getLocText("FR-Action_Remove"));
this.setMnemonic('R');
this.setSmallIcon(BaseUtils
.readIcon(IconPathConstants.TD_REMOVE_ICON_PATH));
}
@Override
public void actionPerformed(ActionEvent evt) {
doBeforeRemove();
if (GUICoreUtils.removeJListSelectedNodes(SwingUtilities
.getWindowAncestor(AuthorityListControlPane.this), authorityList)) {
checkButtonEnabled();
doAfterRemove();
}
}
}
}

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

@ -0,0 +1,37 @@
package com.fr.design.remote.ui;
import com.fr.design.dialog.BasicPane;
import com.fr.design.remote.RemoteDesignAuthority;
import com.fr.general.Inter;
import javax.swing.BorderFactory;
import java.awt.BorderLayout;
public class AuthorityManagerPane extends BasicPane {
private AuthorityListControlPane list;
public AuthorityManagerPane() {
this.setLayout(new BorderLayout());
this.setBorder(BorderFactory.createEmptyBorder());
list = new AuthorityListControlPane();
this.add(list, BorderLayout.CENTER);
}
@Override
protected String title4PopupWindow() {
return Inter.getLocText("远程设计权限管理");
}
public void populate(RemoteDesignAuthority[] authorities) {
list.populate(authorities);
}
private RemoteDesignAuthority[] update() {
return list.update();
}
}

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

@ -0,0 +1,98 @@
package com.fr.design.remote.ui;
import com.fr.design.border.UITitledBorder;
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.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.ui.list.MemberList;
import com.fr.design.remote.ui.list.MemberListCellRender;
import com.fr.general.Inter;
import javax.swing.BorderFactory;
import javax.swing.DefaultListModel;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.FlowLayout;
import java.util.ArrayList;
import java.util.List;
/**
* @author yaohwu
*/
public class UserManagerPane extends BasicPane {
private List<RemoteMember> members = new ArrayList<>();
DefaultListModel<RemoteMember> listModel = new DefaultListModel<>();
public UserManagerPane() {
this.setBorder(BorderFactory.createEmptyBorder());
this.setLayout(new BorderLayout());
this.add(
TableLayoutHelper.createTableLayoutPane(
new Component[][]{
new Component[]{createLeftPanel(), new JPanel()}
},
new double[]{TableLayout.FILL},
new double[]{TableLayout.FILL, TableLayout.FILL}
),
BorderLayout.CENTER);
}
@Override
protected String title4PopupWindow() {
return "添加设计成员";
}
private JPanel createLeftPanel() {
JPanel content = new JPanel(new BorderLayout());
content.setBorder(
BorderFactory.createCompoundBorder(
new EmptyBorder(6, 0, 0, 0),
UITitledBorder.createBorderWithTitle(Inter.getLocText("决策系统成员")))
);
// 搜索
UITextField searchKeyInput = new UITextField();
UIButton searchButton = new UIButton("搜索");
JPanel searchPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
searchPanel.setBorder(BorderFactory.createEmptyBorder());
searchPanel.add(searchKeyInput);
searchPanel.add(searchButton);
// 内容列表
listModel = new DefaultListModel<>();
MemberList list = new MemberList(listModel);
list.setCellRenderer(new MemberListCellRender());
resetMembers();
addContentToList();
UIScrollPane listPane = new UIScrollPane(list);
listPane.setBorder(BorderFactory.createEmptyBorder());
content.add(searchPanel, BorderLayout.NORTH);
content.add(listPane, BorderLayout.CENTER);
return content;
}
private void addContentToList() {
listModel.removeAllElements();
for (RemoteMember member : members) {
listModel.addElement(member);
}
}
private void resetMembers() {
members.clear();
members.add(RemoteMember.DEFAULT_MEMBER);
}
}

28
designer-base/src/com/fr/design/remote/ui/list/AuthorityList.java

@ -0,0 +1,28 @@
package com.fr.design.remote.ui.list;
import com.fr.design.remote.RemoteDesignAuthority;
import javax.swing.JList;
import javax.swing.ListModel;
import java.util.Vector;
public class AuthorityList extends JList<RemoteDesignAuthority> {
public AuthorityList() {
super();
}
public AuthorityList(ListModel<RemoteDesignAuthority> dataModel) {
super(dataModel);
}
public AuthorityList(final RemoteDesignAuthority[] listData) {
super(listData);
}
public AuthorityList(final Vector<? extends RemoteDesignAuthority> listData) {
super(listData);
}
}

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

@ -0,0 +1,132 @@
package com.fr.design.remote.ui.list;
import com.fr.base.BaseUtils;
import com.fr.design.remote.RemoteDesignAuthority;
import sun.swing.DefaultLookup;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.ListCellRenderer;
import javax.swing.border.Border;
import javax.swing.border.EmptyBorder;
import java.awt.Color;
import java.awt.Component;
/*
* NameableListCellRenderer
*/
public class AuthorityListCellRenderer extends
JLabel implements ListCellRenderer<RemoteDesignAuthority> {
/**
* An empty <code>Border</code>. This field might not be used. To change the
* <code>Border</code> used by this renderer override the
* <code>getListCellRendererComponent</code> method and set the border
* of the returned component directly.
*/
private static final Border SAFE_NO_FOCUS_BORDER = new EmptyBorder(1, 1, 1, 1);
private static final Border DEFAULT_NO_FOCUS_BORDER = new EmptyBorder(1, 1, 1, 1);
private static Border noFocusBorder = DEFAULT_NO_FOCUS_BORDER;
/**
* Constructs a default renderer object for an item
* in a list.
*/
public AuthorityListCellRenderer() {
super();
setOpaque(true);
setBorder(getNoFocusBorder());
setName("List.cellRenderer");
}
@Override
public Component getListCellRendererComponent(JList list, RemoteDesignAuthority authority,
int index, boolean isSelected, boolean cellHasFocus) {
setComponentOrientation(list.getComponentOrientation());
Color bg = null;
Color fg = null;
JList.DropLocation dropLocation = list.getDropLocation();
if (dropLocation != null
&& !dropLocation.isInsert()
&& dropLocation.getIndex() == index) {
bg = DefaultLookup.getColor(this, ui, "List.dropCellBackground");
fg = DefaultLookup.getColor(this, ui, "List.dropCellForeground");
isSelected = true;
}
if (isSelected) {
setBackground(bg == null ? list.getSelectionBackground() : bg);
setForeground(fg == null ? list.getSelectionForeground() : fg);
} else {
setBackground(list.getBackground());
setForeground(list.getForeground());
}
setEnabled(list.isEnabled());
setFont(list.getFont());
Border border = null;
if (cellHasFocus) {
if (isSelected) {
border = DefaultLookup.getBorder(this, ui, "List.focusSelectedCellHighlightBorder");
}
if (border == null) {
border = DefaultLookup.getBorder(this, ui, "List.focusCellHighlightBorder");
}
} else {
border = getNoFocusBorder();
}
setBorder(border);
this.setIcon(BaseUtils.readIcon("com/fr/design/remote/images/icon_Member_normal@1x.png"));
this.setText(authority.getName());
return this;
}
private Border getNoFocusBorder() {
Border border = DefaultLookup.getBorder(this, ui, "List.cellNoFocusBorder");
if (System.getSecurityManager() != null) {
if (border != null) return border;
return SAFE_NO_FOCUS_BORDER;
} else {
if (border != null &&
(noFocusBorder == null ||
noFocusBorder == DEFAULT_NO_FOCUS_BORDER)) {
return border;
}
return noFocusBorder;
}
}
/**
* Overridden for performance reasons.
* See the <a href="#override">Implementation Note</a>
* for more information.
*
* @return <code>true</code> if the background is completely opaque
* and differs from the JList's background;
* <code>false</code> otherwise
* @since 1.5
*/
@Override
public boolean isOpaque() {
Color back = getBackground();
Component p = getParent();
if (p != null) {
p = p.getParent();
}
// p should now be the JList.
boolean colorMatch = (back != null) && (p != null) &&
back.equals(p.getBackground()) &&
p.isOpaque();
return !colorMatch && super.isOpaque();
}
}

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

@ -0,0 +1,39 @@
package com.fr.design.remote.ui.list;
import com.fr.design.remote.RemoteMember;
import javax.swing.JList;
import javax.swing.ListModel;
import java.awt.Color;
import java.util.Vector;
public class MemberList extends JList<RemoteMember> {
public MemberList() {
super();
init();
}
public MemberList(ListModel<RemoteMember> dataModel) {
super(dataModel);
init();
}
public MemberList(RemoteMember[] listData) {
super(listData);
init();
}
public MemberList(Vector<? extends RemoteMember> listData) {
super(listData);
init();
}
private void init() {
setBackground(new Color(0xF5F5F7));
}
}

45
designer-base/src/com/fr/design/remote/ui/list/MemberListCellRender.java

@ -0,0 +1,45 @@
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 javax.swing.BorderFactory;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.ListCellRenderer;
import java.awt.Component;
import java.awt.FlowLayout;
public class MemberListCellRender extends JPanel implements ListCellRenderer<RemoteMember> {
private UILabel label;
private UICheckBox check;
public MemberListCellRender() {
this.setBorder(BorderFactory.createEmptyBorder());
this.setLayout(new FlowLayout(FlowLayout.LEFT));
label = new UILabel();
label.setIcon(BaseUtils.readIcon("com/fr/design/remote/images/icon_Member_normal@1x.png"));
check = new UICheckBox();
check.setSelected(false);
this.add(label);
this.add(check);
}
@Override
public Component getListCellRendererComponent(JList list, RemoteMember member, int index, boolean isSelected, boolean cellHasFocus) {
this.setLabelName(member.getName());
check.setSelected(false);
return this;
}
private void setLabelName(String name) {
label.setName(name);
}
}

6
designer-base/src/com/fr/design/remote/ui/tree/FileAuthorityTree.java

@ -0,0 +1,6 @@
package com.fr.design.remote.ui.tree;
import javax.swing.JTree;
public class FileAuthorityTree extends JTree {
}
Loading…
Cancel
Save