Browse Source

file tree

master
yaoh.wu 7 years ago
parent
commit
f2131d1f21
  1. 8
      designer-base/src/com/fr/design/remote/ui/AuthorityEditorPane.java
  2. 14
      designer-base/src/com/fr/design/remote/ui/AuthorityListControlPane.java
  3. 6
      designer-base/src/com/fr/design/remote/ui/UserManagerPane.java
  4. 4
      designer-base/src/com/fr/design/remote/ui/tree/FileAuthorityTree.java
  5. 141
      designer-base/src/com/fr/design/remote/ui/tree/FileAuthorityTreeNode.java

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

@ -1,19 +1,21 @@
package com.fr.design.remote.ui;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.gui.ilable.UILabel;
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> {
private UILabel label = new UILabel();
public AuthorityEditorPane() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.setBorder(BorderFactory.createEmptyBorder());
this.add(new Label("editor"), BorderLayout.CENTER);
this.add(label, BorderLayout.CENTER);
}
@Override
@ -23,7 +25,7 @@ public class AuthorityEditorPane extends BasicBeanPane<RemoteDesignAuthority> {
@Override
public void populateBean(RemoteDesignAuthority ob) {
label.setText(ob.getName());
}
@Override

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

@ -16,6 +16,7 @@ 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.RemoteMember;
import com.fr.design.remote.ui.list.AuthorityList;
import com.fr.design.remote.ui.list.AuthorityListCellRenderer;
import com.fr.design.utils.gui.GUICoreUtils;
@ -476,12 +477,13 @@ public class AuthorityListControlPane extends BasicPane {
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());
// 获取添加的用户到权限编辑面板
List<RemoteMember> members = userManagerPane.update();
for (RemoteMember member : members) {
RemoteDesignAuthority authority = new RemoteDesignAuthority();
authority.setName(member.getName());
AuthorityListControlPane.this.addAuthority(authority, getModel().getSize());
}
}
@Override

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

@ -17,6 +17,7 @@ import com.fr.design.remote.ui.list.AddingMemberListCellRender;
import com.fr.design.remote.ui.list.MemberListSelectedChangeListener;
import com.fr.general.Inter;
import com.fr.stable.StringUtils;
import com.fr.third.guava.collect.ImmutableList;
import javax.swing.BorderFactory;
import javax.swing.DefaultListModel;
@ -277,4 +278,9 @@ public class UserManagerPane extends BasicPane {
addedListModel.copyInto(members);
addedMembers.addAll(Arrays.asList(members));
}
public ImmutableList<RemoteMember> update() {
return ImmutableList.copyOf(addedMembers);
}
}

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

@ -1,6 +1,6 @@
package com.fr.design.remote.ui.tree;
import javax.swing.JTree;
import com.fr.design.gui.itree.filetree.TemplateFileTree;
public class FileAuthorityTree extends JTree {
public class FileAuthorityTree extends TemplateFileTree {
}

141
designer-base/src/com/fr/design/remote/ui/tree/FileAuthorityTreeNode.java

@ -0,0 +1,141 @@
package com.fr.design.remote.ui.tree;
import javax.swing.tree.DefaultMutableTreeNode;
public class FileAuthorityTreeNode extends DefaultMutableTreeNode {
public enum Status {
SELECTED,
UNSELECTED,
INDETERMINATE
}
private Status status;
public FileAuthorityTreeNode() {
this(null);
}
public FileAuthorityTreeNode(Object userObject) {
this(userObject, true, Status.UNSELECTED);
}
public FileAuthorityTreeNode(Object userObject, boolean allowsChildren, Status status) {
super(userObject, allowsChildren);
this.status = status;
}
public Status getStatus() {
return status;
}
public boolean isSelected() {
return status == Status.SELECTED;
}
public boolean isUnselected() {
return status == Status.UNSELECTED;
}
public boolean isIndeterminate() {
return status == Status.INDETERMINATE;
}
public void setSelected(boolean selected) {
setStatus(selected ? Status.SELECTED : Status.UNSELECTED);
}
public void setStatus(Status status) {
this.status = status;
switch (status) {
case SELECTED:
// 向下
// 如果选中,则所有的子结点都要选中
if (children != null) {
for (Object obj : children) {
FileAuthorityTreeNode node = (FileAuthorityTreeNode) obj;
if (!node.isSelected()) {
node.setSelected(true);
}
}
}
// 向上
// 检查其父节点
if (parent != null) {
FileAuthorityTreeNode pNode = (FileAuthorityTreeNode) parent;
int index = 0;
for (; index < pNode.children.size(); ++index) {
FileAuthorityTreeNode pChildNode = (FileAuthorityTreeNode) pNode.children.get(index);
if (!pChildNode.isSelected()) {
break;
}
}
// 如果父结点下的子结点都被选中了,那么选中父节点
if (index == pNode.children.size()) {
if (!pNode.isSelected()) {
pNode.setSelected(true);
}
}
// 如果父结点下的子结点有部分没被选中,那么标记父结点选中状况为未知
else {
if (!pNode.isIndeterminate()) {
pNode.setStatus(Status.INDETERMINATE);
}
}
}
break;
case UNSELECTED:
// 向下
// 子结点都要取消选中
if (children != null) {
for (Object aChildren : children) {
FileAuthorityTreeNode node = (FileAuthorityTreeNode) aChildren;
if (!node.isUnselected()) {
node.setSelected(false);
}
}
}
// 向上
// 查看父节点的选中情况
if (parent != null) {
FileAuthorityTreeNode pNode = (FileAuthorityTreeNode) parent;
int index = 0;
for (; index < pNode.children.size(); ++index) {
FileAuthorityTreeNode pChildNode = (FileAuthorityTreeNode) pNode.children.get(index);
if (!pChildNode.isUnselected()) {
break;
}
}
// 如果父结点下的子结点都是未被选中的,那么取消选中父节点
if (index == pNode.children.size()) {
if (!pNode.isUnselected()) {
pNode.setSelected(false);
}
}
// 如果父结点下的子结点有部分不是未被选中的,那么标记父结点选中状况为未知
else {
if (!pNode.isIndeterminate()) {
pNode.setStatus(Status.INDETERMINATE);
}
}
}
break;
case INDETERMINATE:
// todo 标记为未知
break;
default:
break;
}
}
}
Loading…
Cancel
Save