Browse Source

Merge pull request #1256 in BA/design from ~YAOH.WU/a_design_0811:release/9.0 to release/9.0

* commit '39bdb7e62851a594c522a1b2d3231d97324d5e17':
  REPORT-4605 设计器模板删除先尝试放回收站
master
superman 7 years ago
parent
commit
54c4b9e9dd
  1. 29
      designer_base/src/com/fr/design/file/TemplateTreePane.java

29
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());
}
}
}
Loading…
Cancel
Save