mirror of
https://github.com/KOHGYLW/kiftd-source.git
synced 2025-01-08 12:07:47 +08:00
update to v1.2.0 进一步优化“文件”功能
This commit is contained in:
parent
8812970d92
commit
5efffe09e8
1
TODO.txt
1
TODO.txt
@ -210,5 +210,6 @@ test.auth.xxx=ucd
|
||||
【待实现】完善移动“m”权限的安全性:当仅有“m”权限时,用户可执行“复制”操作;若同时具备删除“d”权限,才可以进行“剪切”操作。
|
||||
注:这是为了防止使用者先将某个文件从一个原本不具备删除权限的文件夹内移动的一个具备删除权限的文件夹内再将其删除的恶意操作。
|
||||
【已完成】新增文件夹体积计算功能:当访问者打开文件夹的“详细信息...”模态框时,系统将实时统计该文件夹的内容总体积,之后将结果显示在该界面上供用户查看。
|
||||
【已完成】进一步优化了“文件”功能:在图形界面下,可以通过点击表头对文件列表进行排序;此外还修复了几处执行文件导入导出操作时可能导致死锁的问题。
|
||||
【待实现】新增导入账户设置:当执行“导入”操作时,可以使用指定账户来为它们设置“创建者”。
|
||||
【待实现】优化剪切复制操作:如果执行粘贴时已剪切或复制的文件不再存在,那么在提示后自动清除剪切或复制的文件记录,将剪切或复制显示恢复到初始状态。
|
@ -2,11 +2,15 @@ package kohgylw.kiftd.ui.util;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseListener;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.List;
|
||||
import javax.swing.JTable;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.event.TableModelListener;
|
||||
import javax.swing.table.DefaultTableCellRenderer;
|
||||
import javax.swing.table.JTableHeader;
|
||||
import javax.swing.table.TableModel;
|
||||
|
||||
import kohgylw.kiftd.printer.Printer;
|
||||
@ -28,13 +32,118 @@ public class FilesTable extends JTable {
|
||||
|
||||
private static final String[] columns = new String[] { "名称", "创建日期", "大小", "创建者" };
|
||||
private static List<Folder> folders;// 当前显示的文件夹列表
|
||||
private static List<Node> files;// 当前显示的文件列表
|
||||
public static final int MAX_LIST_LIMIT = Integer.MAX_VALUE;
|
||||
|
||||
private int sortByName = 1;// 名称排序顺序,默认从小到大
|
||||
private int sortByDate = 1;// 创建日期排序顺序,默认从小到大
|
||||
private static SimpleDateFormat cdf = new SimpleDateFormat("yyyy年MM月dd日");// 创建日期辅助转换对象
|
||||
private int sortBySize = 1;// 按大小排序,默认从小到大
|
||||
private int sortByCreator = 1;// 按创建者排序,默认从小到大
|
||||
|
||||
/** */
|
||||
private static final long serialVersionUID = -3436472714356711024L;
|
||||
|
||||
public FilesTable() {
|
||||
super(new Object[][] {}, columns);
|
||||
// 设置点击某一列标题时自动根据此列进行排序
|
||||
JTableHeader filesTableHeader = getTableHeader();
|
||||
filesTableHeader.addMouseListener(new MouseListener() {
|
||||
|
||||
@Override
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mousePressed(MouseEvent e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseExited(MouseEvent e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseEntered(MouseEvent e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
int col = filesTableHeader.columnAtPoint(e.getPoint());
|
||||
switch (col) {
|
||||
case 0:
|
||||
// 按名称排序
|
||||
files.sort((e1, e2) -> {
|
||||
return sortByName * e1.getFileName().compareTo(e2.getFileName());
|
||||
});
|
||||
folders.sort((e1, e2) -> {
|
||||
return sortByName * e1.getFolderName().compareTo(e2.getFolderName());
|
||||
});
|
||||
sortByName = sortByName * -1;
|
||||
sortByDate = 1;
|
||||
sortBySize = 1;
|
||||
sortByCreator = 1;
|
||||
break;
|
||||
case 1:
|
||||
// 按创建日期排序
|
||||
files.sort((e1, e2) -> {
|
||||
try {
|
||||
return sortByDate * cdf.parse(e1.getFileCreationDate())
|
||||
.compareTo(cdf.parse(e2.getFileCreationDate()));
|
||||
} catch (ParseException e3) {
|
||||
Printer.instance.print(e3.toString());
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
folders.sort((e1, e2) -> {
|
||||
try {
|
||||
return sortByDate * cdf.parse(e1.getFolderCreationDate())
|
||||
.compareTo(cdf.parse(e2.getFolderCreationDate()));
|
||||
} catch (ParseException e3) {
|
||||
Printer.instance.print(e3.toString());
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
sortByDate = sortByDate * -1;
|
||||
sortByName = 1;
|
||||
sortBySize = 1;
|
||||
sortByCreator = 1;
|
||||
break;
|
||||
case 2:
|
||||
// 按大小排序
|
||||
files.sort((e1, e2) -> {
|
||||
return sortBySize
|
||||
* Long.compare(Long.parseLong(e1.getFileSize()), Long.parseLong(e2.getFileSize()));
|
||||
});
|
||||
sortBySize = sortBySize * -1;
|
||||
sortByName = 1;
|
||||
sortByDate = 1;
|
||||
sortByCreator = 1;
|
||||
break;
|
||||
case 3:
|
||||
// 按创建者排序
|
||||
files.sort((e1, e2) -> {
|
||||
return sortByCreator * e1.getFileCreator().compareTo(e2.getFileCreator());
|
||||
});
|
||||
folders.sort((e1, e2) -> {
|
||||
return sortByCreator * e1.getFolderCreator().compareTo(e2.getFolderCreator());
|
||||
});
|
||||
sortByCreator = sortByCreator * -1;
|
||||
sortByName = 1;
|
||||
sortByDate = 1;
|
||||
sortBySize = 1;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
// 排序完毕后更新列表显示
|
||||
updateValues(folders, files);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -109,6 +218,7 @@ public class FilesTable extends JTable {
|
||||
setRowFontColor();
|
||||
validate();
|
||||
FilesTable.folders = folders;
|
||||
FilesTable.files = files;
|
||||
} catch (Exception e) {
|
||||
Printer.instance.print(e.toString());
|
||||
}
|
||||
|
@ -4,7 +4,6 @@ public class Folder extends kohgylw.kiftd.server.model.Folder{
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
// TODO 自动生成的方法存根
|
||||
return getFolderName();
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
#Generated by Maven Integration for Eclipse
|
||||
#Tue Dec 26 13:31:45 CST 2023
|
||||
#Tue Dec 26 15:14:32 CST 2023
|
||||
m2e.projectLocation=/Users/kohgylw/Programs/java_workspace/kiftd
|
||||
m2e.projectName=kiftd
|
||||
groupId=kohgylw
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
target/classes/kohgylw/kiftd/ui/util/FilesTable$4.class
Normal file
BIN
target/classes/kohgylw/kiftd/ui/util/FilesTable$4.class
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user