Browse Source

ui调整

master
yaoh.wu 7 years ago
parent
commit
dee9c6512a
  1. 126
      designer-base/src/com/fr/design/gui/itree/filetree/TemplateFileTree.java
  2. 52
      designer-base/src/com/fr/design/remote/button/IconButton.java
  3. 17
      designer-base/src/com/fr/design/remote/ui/AuthorityListControlPane.java
  4. 4
      designer-base/src/com/fr/design/remote/ui/UserManagerPane.java
  5. 13
      designer-base/src/com/fr/design/remote/ui/list/AddedMemberList.java
  6. 20
      designer-base/src/com/fr/design/remote/ui/list/AddedMemberListCellRender.java
  7. 13
      designer-base/src/com/fr/design/remote/ui/list/AddingMemberList.java
  8. 10
      designer-base/src/com/fr/design/remote/ui/list/AddingMemberListCellRender.java

126
designer-base/src/com/fr/design/gui/itree/filetree/TemplateFileTree.java

@ -1,13 +1,22 @@
package com.fr.design.gui.itree.filetree; package com.fr.design.gui.itree.filetree;
import com.fr.base.Env;
import com.fr.base.FRContext;
import com.fr.base.env.EnvContext;
import com.fr.base.env.proxy.EnvProxy;
import com.fr.base.env.resource.EnvConfigUtils;
import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode; import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode;
import com.fr.env.operator.file.TplFileOperator;
import com.fr.file.filetree.FileNode; import com.fr.file.filetree.FileNode;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
import com.fr.stable.StableUtils;
import com.fr.stable.project.ProjectConstants; import com.fr.stable.project.ProjectConstants;
import javax.swing.text.Position; import javax.swing.text.Position;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreePath; import javax.swing.tree.TreePath;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
/* /*
@ -43,13 +52,13 @@ public class TemplateFileTree extends EnvFileTree {
return null; return null;
} }
public String[] getSelectedTemplatePaths(){ public String[] getSelectedTemplatePaths() {
TreePath[] selectedTreePaths = this.getSelectionPaths(); TreePath[] selectedTreePaths = this.getSelectionPaths();
if (ArrayUtils.isEmpty(selectedTreePaths)) { if (ArrayUtils.isEmpty(selectedTreePaths)) {
return ArrayUtils.EMPTY_STRING_ARRAY; return ArrayUtils.EMPTY_STRING_ARRAY;
} }
List<String> selectedPathList = new ArrayList<String>(); List<String> selectedPathList = new ArrayList<String>();
for(TreePath treepath : selectedTreePaths){ for (TreePath treepath : selectedTreePaths) {
ExpandMutableTreeNode currentTreeNode = (ExpandMutableTreeNode) treepath.getLastPathComponent(); ExpandMutableTreeNode currentTreeNode = (ExpandMutableTreeNode) treepath.getLastPathComponent();
Object userObject = currentTreeNode.getUserObject(); Object userObject = currentTreeNode.getUserObject();
if (userObject instanceof FileNode) { if (userObject instanceof FileNode) {
@ -67,8 +76,7 @@ public class TemplateFileTree extends EnvFileTree {
return selectedPathList.toArray(new String[0]); return selectedPathList.toArray(new String[0]);
} }
public TreePath getNextMatch(String prefix, int startingRow, public TreePath getNextMatch(String prefix, int startingRow, Position.Bias bias) {
Position.Bias bias) {
int max = getRowCount(); int max = getRowCount();
if (prefix == null) { if (prefix == null) {
@ -78,9 +86,7 @@ public class TemplateFileTree extends EnvFileTree {
throw new IllegalArgumentException(); throw new IllegalArgumentException();
} }
prefix = prefix.toUpperCase(); prefix = prefix.toUpperCase();
// start search from the next/previous element from the selected element
// start search from the next/previous element froom the
// selected element
int increment = (bias == Position.Bias.Forward) ? 1 : -1; int increment = (bias == Position.Bias.Forward) ? 1 : -1;
int row = startingRow; int row = startingRow;
do { do {
@ -96,4 +102,110 @@ public class TemplateFileTree extends EnvFileTree {
} while (row != startingRow); } while (row != startingRow);
return null; return null;
} }
public FileNode[] listFile(String path) {
String username = EnvConfigUtils.getUsername(EnvContext.currentEnv());
String extra = EnvProxy.get(TplFileOperator.class).readExtraResourcePath(path);
return EnvProxy.get(TplFileOperator.class).list(username, extra, path);
}
/*
* 改变Env后,根据构造函数时设置的RootPaths,重新加载
*/
public void refreshEnv(Env env) {
DefaultTreeModel defaultTreeModel = (DefaultTreeModel) this.getModel();
ExpandMutableTreeNode rootTreeNode = (ExpandMutableTreeNode) defaultTreeModel.getRoot();
rootTreeNode.removeAllChildren();
FileNode[] fns;
// 如果rootPaths是null的话列出所有文件
if (subPathes == null) {
fns = listFileNodes(this.treeRootPath);
} else {
// 重新加载新的FileDirectoryNode
fns = new FileNode[subPathes.length];
for (int i = 0; i < subPathes.length; i++) {
fns[i] = new FileNode(StableUtils.pathJoin(this.treeRootPath, subPathes[i]), true);
}
}
ExpandMutableTreeNode[] subTreeNodes = fileNodeArray2TreeNodeArray(fns);
for (ExpandMutableTreeNode node : subTreeNodes) {
rootTreeNode.add(node);
}
defaultTreeModel.reload(rootTreeNode);
}
protected ExpandMutableTreeNode[] loadChildTreeNodes(ExpandMutableTreeNode treeNode) {
FileNode[] fn_array = listFileNodes(treeNode);
return fileNodeArray2TreeNodeArray(fn_array);
}
/*
* 把FileNode[]转成ExpandMutableTreeNode[]
*/
private ExpandMutableTreeNode[] fileNodeArray2TreeNodeArray(FileNode[] fileNodes) {
ExpandMutableTreeNode[] res = new ExpandMutableTreeNode[fileNodes.length];
for (int i = 0; i < res.length; i++) {
FileNode fn = fileNodes[i];
res[i] = new ExpandMutableTreeNode(fn);
if (fn.isDirectory()) {
res[i].add(new ExpandMutableTreeNode());
}
}
return res;
}
private FileNode[] listFileNodes(String filePath) {
FileNode[] fileNodes = null;
try {
fileNodes = listFile(filePath);
} catch (Exception e) {
FRContext.getLogger().error(e.getMessage(), e);
}
if (fileNodes == null) {
fileNodes = new FileNode[0];
}
// 用FileNodeFilter过滤一下
if (filter != null) {
List<FileNode> list = new ArrayList<FileNode>();
for (FileNode fileNode : fileNodes) {
if (filter.accept(fileNode)) {
list.add(fileNode);
}
}
fileNodes = list.toArray(new FileNode[list.size()]);
}
Arrays.sort(fileNodes, new FileNodeComparator());
return fileNodes;
}
/*
* 求当前TreeNode下所有的FileNode.
*/
private FileNode[] listFileNodes(ExpandMutableTreeNode currentTreeNode) {
if (currentTreeNode == null) {
return new FileNode[0];
}
Object object = currentTreeNode.getUserObject();
if (object instanceof FileNode) {
return this.listFileNodes(((FileNode) object).getEnvPath());
}
return new FileNode[0];
}
} }

52
designer-base/src/com/fr/design/remote/button/IconButton.java

@ -0,0 +1,52 @@
package com.fr.design.remote.button;
import com.fr.base.BaseUtils;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.stable.StringUtils;
import javax.swing.*;
import java.awt.*;
public final class IconButton extends JButton {
public IconButton() {
super(StringUtils.EMPTY);
setContentAreaFilled(false);
setFocusPainted(false);
setIcon(BaseUtils.readIcon("com/fr/design/remote/images/icon_Remove_x.png"));
setBorder(null);
}
@Override
protected void paintBorder(Graphics g) {
}
@Override
protected void paintComponent(Graphics g) {
final Graphics2D g2 = (Graphics2D) g.create();
g2.setPaint(
new GradientPaint(
new Point(0, 0),
new Color(0xF5F5F7),
new Point(0, getPreferredSize().height),
new Color(0xF5F5F7)
)
);
g2.fillRect(0, 0, getPreferredSize().width, getPreferredSize().height);
g2.dispose();
super.paintComponent(g);
}
public static void main(String[] args) {
JFrame jf = new JFrame("test");
jf.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
JPanel content = (JPanel) jf.getContentPane();
content.setLayout(null);
IconButton a = new IconButton();
a.setBounds(0, 0, a.getPreferredSize().width, a.getPreferredSize().height);
content.add(a);
GUICoreUtils.centerWindow(jf);
jf.setSize(400, 400);
jf.setVisible(true);
}
}

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

@ -24,17 +24,10 @@ import com.fr.general.Inter;
import com.fr.report.DesignAuthority; import com.fr.report.DesignAuthority;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
import javax.swing.BorderFactory; import javax.swing.*;
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.ListSelectionEvent;
import javax.swing.event.ListSelectionListener; import javax.swing.event.ListSelectionListener;
import java.awt.BorderLayout; import java.awt.*;
import java.awt.CardLayout;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -231,6 +224,12 @@ public class AuthorityListControlPane extends BasicPane {
public void addAuthority(DesignAuthority authority, int index) { public void addAuthority(DesignAuthority authority, int index) {
DefaultListModel<DesignAuthority> model = (DefaultListModel<DesignAuthority>) authorityList.getModel(); DefaultListModel<DesignAuthority> model = (DefaultListModel<DesignAuthority>) authorityList.getModel();
for (int i = 0; i < model.size(); i++) {
if (model.get(i).getUserId().equals(authority.getUserId())) {
return;
}
}
model.add(index, authority); model.add(index, authority);
authorityList.setSelectedIndex(index); authorityList.setSelectedIndex(index);
authorityList.ensureIndexIsVisible(index); authorityList.ensureIndexIsVisible(index);

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

@ -163,7 +163,7 @@ public class UserManagerPane extends BasicPane {
// 搜索 // 搜索
JPanel searchPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); JPanel searchPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
searchPanel.setBorder(BorderFactory.createEmptyBorder()); searchPanel.setBorder(BorderFactory.createEmptyBorder());
keyField.setPreferredSize(new Dimension(200, 20)); keyField.setPreferredSize(new Dimension(250, 20));
keyField.requestFocus(); keyField.requestFocus();
keyField.addKeyListener(keyFieldKeyListener); keyField.addKeyListener(keyFieldKeyListener);
keyButton.setText(Inter.getLocText("FR-Designer_Remote_Design_Search")); keyButton.setText(Inter.getLocText("FR-Designer_Remote_Design_Search"));
@ -205,6 +205,8 @@ public class UserManagerPane extends BasicPane {
Inter.getLocText("FR-Designer_Remote_Design_Selected_Member_Count", Inter.getLocText("FR-Designer_Remote_Design_Selected_Member_Count",
String.valueOf(addedMembers.size())) String.valueOf(addedMembers.size()))
); );
countLabel.setBorder(BorderFactory.createEmptyBorder(7, 12, 8, 0));
countLabel.setForeground(new Color(0x8F8F92));
addedListModel = new DefaultListModel<>(); addedListModel = new DefaultListModel<>();
addedList = new AddedMemberList(addedListModel); addedList = new AddedMemberList(addedListModel);

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

@ -2,7 +2,8 @@ package com.fr.design.remote.ui.list;
import com.fr.env.RemoteDesignMember; import com.fr.env.RemoteDesignMember;
import javax.swing.DefaultListModel; import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.util.Vector; import java.util.Vector;
@ -27,7 +28,15 @@ public class AddedMemberList extends MemberList {
@Override @Override
protected boolean shouldDisplaySelected(MouseEvent e) { protected boolean shouldDisplaySelected(MouseEvent e) {
return true; Point point = e.getPoint();
int rX = point.x;
int rY = point.y;
int index = this.getSelectedIndex();
int x = 280;
int y = 25 * index;
int width = 20;
int height = 25;
return x <= rX && rX <= x + width && y <= rY && rY <= y + height;
} }
@Override @Override

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

@ -1,36 +1,29 @@
package com.fr.design.remote.ui.list; package com.fr.design.remote.ui.list;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.remote.button.IconButton;
import com.fr.env.RemoteDesignMember; import com.fr.env.RemoteDesignMember;
import javax.swing.BorderFactory; import javax.swing.*;
import javax.swing.JList; import java.awt.*;
import javax.swing.JPanel;
import javax.swing.ListCellRenderer;
import java.awt.Component;
import java.awt.FlowLayout;
public class AddedMemberListCellRender extends JPanel implements ListCellRenderer<RemoteDesignMember> { public class AddedMemberListCellRender extends JPanel implements ListCellRenderer<RemoteDesignMember> {
private UILabel label; private UILabel label;
private UIButton uiButton;
public AddedMemberListCellRender() { public AddedMemberListCellRender() {
this.setBorder(BorderFactory.createEmptyBorder()); this.setBorder(BorderFactory.createEmptyBorder());
this.setLayout(new FlowLayout(FlowLayout.LEFT)); this.setLayout(new FlowLayout(FlowLayout.LEFT));
label = new UILabel(); label = new UILabel();
label.setIcon(BaseUtils.readIcon("com/fr/design/remote/images/icon_Member_normal@1x.png")); label.setIcon(BaseUtils.readIcon("com/fr/design/remote/images/icon_Member_normal@1x.png"));
label.setPreferredSize(new Dimension(270, 20));
uiButton = new UIButton(); this.setPreferredSize(new Dimension(this.getPreferredSize().width, 25));
uiButton.setIcon(BaseUtils.readIcon("com/fr/design/remote/images/icon_Remove_x.png"));
this.add(label); this.add(label);
this.add(uiButton); this.add(new IconButton());
} }
@Override @Override
@ -42,4 +35,5 @@ public class AddedMemberListCellRender extends JPanel implements ListCellRendere
private void setLabelText(String name) { private void setLabelText(String name) {
label.setText(name); label.setText(name);
} }
} }

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

@ -2,7 +2,8 @@ package com.fr.design.remote.ui.list;
import com.fr.env.RemoteDesignMember; import com.fr.env.RemoteDesignMember;
import javax.swing.DefaultListModel; import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.util.Vector; import java.util.Vector;
@ -38,7 +39,15 @@ public class AddingMemberList extends MemberList {
@Override @Override
protected boolean shouldDisplaySelected(MouseEvent e) { protected boolean shouldDisplaySelected(MouseEvent e) {
return true; Point point = e.getPoint();
int rX = point.x;
int rY = point.y;
int index = this.getSelectedIndex();
int x = 280;
int y = 25 * index;
int width = 25;
int height = 25;
return x <= rX && rX <= x + width && y <= rY && rY <= y + height;
} }
} }

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

@ -5,12 +5,8 @@ import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.env.RemoteDesignMember; import com.fr.env.RemoteDesignMember;
import javax.swing.BorderFactory; import javax.swing.*;
import javax.swing.JList; import java.awt.*;
import javax.swing.JPanel;
import javax.swing.ListCellRenderer;
import java.awt.Component;
import java.awt.FlowLayout;
public class AddingMemberListCellRender extends JPanel implements ListCellRenderer<RemoteDesignMember> { public class AddingMemberListCellRender extends JPanel implements ListCellRenderer<RemoteDesignMember> {
@ -23,6 +19,8 @@ public class AddingMemberListCellRender extends JPanel implements ListCellRender
this.setLayout(new FlowLayout(FlowLayout.LEFT)); this.setLayout(new FlowLayout(FlowLayout.LEFT));
label = new UILabel(); label = new UILabel();
label.setPreferredSize(new Dimension(270, 20));
this.setPreferredSize(new Dimension(this.getPreferredSize().width, 25));
label.setIcon(BaseUtils.readIcon("com/fr/design/remote/images/icon_Member_normal@1x.png")); label.setIcon(BaseUtils.readIcon("com/fr/design/remote/images/icon_Member_normal@1x.png"));
check = new UICheckBox(); check = new UICheckBox();

Loading…
Cancel
Save