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