From 39bdb7e62851a594c522a1b2d3231d97324d5e17 Mon Sep 17 00:00:00 2001 From: "yaoh.wu" Date: Tue, 19 Sep 2017 10:33:24 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-4605=20=E8=AE=BE=E8=AE=A1=E5=99=A8?= =?UTF-8?q?=E6=A8=A1=E6=9D=BF=E5=88=A0=E9=99=A4=E5=85=88=E5=B0=9D=E8=AF=95?= =?UTF-8?q?=E6=94=BE=E5=9B=9E=E6=94=B6=E7=AB=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/file/TemplateTreePane.java | 29 ++++++++++++++++--- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/designer_base/src/com/fr/design/file/TemplateTreePane.java b/designer_base/src/com/fr/design/file/TemplateTreePane.java index e9009ff9fa..3c690a5c6b 100644 --- a/designer_base/src/com/fr/design/file/TemplateTreePane.java +++ b/designer_base/src/com/fr/design/file/TemplateTreePane.java @@ -5,8 +5,8 @@ package com.fr.design.file; import com.fr.base.FRContext; import com.fr.dav.LocalEnv; -import com.fr.design.gui.itree.filetree.TemplateFileTree; import com.fr.design.gui.icontainer.UIScrollPane; +import com.fr.design.gui.itree.filetree.TemplateFileTree; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.JTemplate; @@ -17,16 +17,18 @@ import com.fr.file.filetree.IOFileNodeFilter; import com.fr.general.ComparatorUtils; import com.fr.general.FRLogger; import com.fr.general.Inter; -import com.fr.stable.ProductConstants; import com.fr.stable.CoreConstants; +import com.fr.stable.ProductConstants; import com.fr.stable.StableUtils; import com.fr.stable.project.ProjectConstants; +import com.sun.jna.platform.FileUtils; import javax.swing.*; import javax.swing.tree.DefaultMutableTreeNode; import java.awt.*; import java.awt.event.*; import java.io.File; +import java.io.IOException; import java.util.ArrayList; import java.util.logging.Level; @@ -177,7 +179,7 @@ public class TemplateTreePane extends JPanel implements FileOperations { } if (nodeFile.exists()) { String path = StableUtils.pathJoin(new String[]{nodeFile.getEnvPath(), nodeFile.getPath()}); - FRContext.getCurrentEnv().deleteFile(nodeFile.getPath()); + moveToTrash(nodeFile); deleteHistory(path.replaceAll("/", "\\\\")); } else { JOptionPane.showMessageDialog(this, Inter.getLocText("Warning-Template_Do_Not_Exsit"), ProductConstants.PRODUCT_NAME, @@ -187,7 +189,6 @@ public class TemplateTreePane extends JPanel implements FileOperations { reportletsTree.refresh(); } - private void deleteHistory(String fileName) { int index = HistoryTemplateListPane.getInstance().contains(fileName); int size = HistoryTemplateListPane.getInstance().getHistoryCount(); @@ -304,4 +305,24 @@ public class TemplateTreePane extends JPanel implements FileOperations { } } + /** + * 文件回收 + * + * @param nodeFile 节点文件 + */ + private void moveToTrash(FileNodeFILE nodeFile) { + FileUtils fileUtils = FileUtils.getInstance(); + if (fileUtils.hasTrash()) { + try { + fileUtils.moveToTrash(new File[]{new File(StableUtils.pathJoin(nodeFile.getEnvPath(), nodeFile.getPath()))}); + } catch (IOException e) { + FRLogger.getLogger().info(e.getMessage()); + FRContext.getCurrentEnv().deleteFile(nodeFile.getPath()); + } + } else { + FRLogger.getLogger().info("No Trash Available"); + FRContext.getCurrentEnv().deleteFile(nodeFile.getPath()); + } + } + } \ No newline at end of file