|
|
|
@ -5,6 +5,8 @@ package com.fr.design.file;
|
|
|
|
|
|
|
|
|
|
import com.fr.base.FRContext; |
|
|
|
|
import com.fr.base.io.FileAssistUtilsOperator; |
|
|
|
|
import com.fr.design.DesignerEnvManager; |
|
|
|
|
import com.fr.design.env.DesignerWorkspaceInfo; |
|
|
|
|
import com.fr.design.gui.icontainer.UIScrollPane; |
|
|
|
|
import com.fr.design.gui.itree.filetree.TemplateFileTree; |
|
|
|
|
import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode; |
|
|
|
@ -20,8 +22,10 @@ import com.fr.general.IOUtils;
|
|
|
|
|
import com.fr.log.FineLoggerFactory; |
|
|
|
|
import com.fr.stable.CoreConstants; |
|
|
|
|
import com.fr.stable.StableUtils; |
|
|
|
|
import com.fr.stable.StringUtils; |
|
|
|
|
import com.fr.stable.project.ProjectConstants; |
|
|
|
|
import com.fr.workspace.WorkContext; |
|
|
|
|
import com.fr.workspace.connect.WorkspaceConnection; |
|
|
|
|
|
|
|
|
|
import javax.swing.JOptionPane; |
|
|
|
|
import javax.swing.JPanel; |
|
|
|
@ -186,6 +190,26 @@ public class TemplateTreePane extends JPanel implements FileOperations {
|
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public void openFile() { |
|
|
|
|
// 判断是否是远程设计的锁定文件
|
|
|
|
|
if (!WorkContext.getCurrent().isLocal()) { |
|
|
|
|
FileNode node = reportletsTree.getSelectedFileNode(); |
|
|
|
|
if (node == null) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
String envName = DesignerEnvManager.getEnvManager().getCurEnvName(); |
|
|
|
|
DesignerWorkspaceInfo info = DesignerEnvManager.getEnvManager().getWorkspaceInfo(envName); |
|
|
|
|
|
|
|
|
|
String username = null; |
|
|
|
|
if (info != null) { |
|
|
|
|
WorkspaceConnection connection = info.getConnection(); |
|
|
|
|
username = connection == null ? StringUtils.EMPTY : connection.getUserName(); |
|
|
|
|
} |
|
|
|
|
String lock = node.getLock(); |
|
|
|
|
if (lock != null && !lock.equals(username)) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
String reportPath = reportletsTree.getSelectedTemplatePath(); |
|
|
|
|
final String selectedFilePath = StableUtils.pathJoin(ProjectConstants.REPORTLETS_NAME, reportPath); |
|
|
|
|
DesignerContext.getDesignerFrame().openTemplate(new FileNodeFILE(new FileNode(selectedFilePath, false))); |
|
|
|
@ -226,11 +250,6 @@ public class TemplateTreePane extends JPanel implements FileOperations {
|
|
|
|
|
public void deleteFile() { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String tipContent = |
|
|
|
|
countSelectedFolder() > 0 |
|
|
|
|
? Toolkit.i18nText("Fine-Design_Basic_Confirm_Delete_Folder") |
|
|
|
|
: Toolkit.i18nText("Fine-Design_Basic_Confirm_Delete_File"); |
|
|
|
|
|
|
|
|
|
ExpandMutableTreeNode[] treeNodes = reportletsTree.getSelectedTreeNodes(); |
|
|
|
|
// 筛选可以删除的文件
|
|
|
|
|
ArrayList<ExpandMutableTreeNode> deletableNodes = new ArrayList<>(); |
|
|
|
@ -238,40 +257,49 @@ public class TemplateTreePane extends JPanel implements FileOperations {
|
|
|
|
|
for (ExpandMutableTreeNode treeNode : treeNodes) { |
|
|
|
|
checkFreeOrLock(treeNode, deletableNodes, lockedNodes); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
boolean success = false; |
|
|
|
|
|
|
|
|
|
if (lockedNodes.isEmpty()) { |
|
|
|
|
|
|
|
|
|
String tipContent = |
|
|
|
|
countSelectedFolder() > 0 |
|
|
|
|
? Toolkit.i18nText("Fine-Design_Basic_Confirm_Delete_Folder") |
|
|
|
|
: Toolkit.i18nText("Fine-Design_Basic_Confirm_Delete_File"); |
|
|
|
|
|
|
|
|
|
if (JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), |
|
|
|
|
tipContent, |
|
|
|
|
UIManager.getString("OptionPane.titleText"), |
|
|
|
|
YES_NO_OPTION) |
|
|
|
|
== JOptionPane.OK_OPTION) { |
|
|
|
|
== JOptionPane.YES_OPTION) { |
|
|
|
|
// 删除所有选中的即可
|
|
|
|
|
success = deleteNodes(Arrays.asList(treeNodes)); |
|
|
|
|
if (!deleteNodes(Arrays.asList(treeNodes))) { |
|
|
|
|
JOptionPane.showConfirmDialog(null, |
|
|
|
|
Toolkit.i18nText("Fine-Design_Basic_Delete_Failure"), |
|
|
|
|
UIManager.getString("OptionPane.titleText"), |
|
|
|
|
JOptionPane.DEFAULT_OPTION, |
|
|
|
|
JOptionPane.ERROR_MESSAGE); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
|
|
String tipContent = |
|
|
|
|
countSelectedFolder() > 0 |
|
|
|
|
? Toolkit.i18nText("Fine-Design_Basic_Confirm_Delete_Unlock_File_And_Folder") |
|
|
|
|
: Toolkit.i18nText("Fine-Design_Basic_Confirm_Delete_Unlock_File"); |
|
|
|
|
|
|
|
|
|
if (JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), |
|
|
|
|
Toolkit.i18nText("Fine-Design_Basic_Confirm_Delete_Unlock_File"), |
|
|
|
|
tipContent, |
|
|
|
|
UIManager.getString("OptionPane.titleText"), |
|
|
|
|
YES_NO_OPTION) |
|
|
|
|
== JOptionPane.YES_OPTION) { |
|
|
|
|
// 删除其他
|
|
|
|
|
success = deleteNodes(deletableNodes); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!success) { |
|
|
|
|
if (!deleteNodes(deletableNodes)) { |
|
|
|
|
JOptionPane.showConfirmDialog(null, |
|
|
|
|
Toolkit.i18nText("Fine-Design_Basic_Delete_Failure"), |
|
|
|
|
UIManager.getString("OptionPane.titleText"), |
|
|
|
|
JOptionPane.DEFAULT_OPTION, |
|
|
|
|
JOptionPane.ERROR_MESSAGE); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
reportletsTree.refresh(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -314,15 +342,7 @@ public class TemplateTreePane extends JPanel implements FileOperations {
|
|
|
|
|
boolean childrenEmptyLock = true; |
|
|
|
|
|
|
|
|
|
for (ExpandMutableTreeNode child : children) { |
|
|
|
|
|
|
|
|
|
boolean childEmptyLock = checkFreeOrLock(child, dNodes, lNodes); |
|
|
|
|
if (childEmptyLock) { |
|
|
|
|
dNodes.add(child); |
|
|
|
|
} else { |
|
|
|
|
lNodes.add(child); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
childrenEmptyLock = childrenEmptyLock && childEmptyLock; |
|
|
|
|
childrenEmptyLock = checkFreeOrLock(child, dNodes, lNodes) && childrenEmptyLock; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
boolean emptyLock = childrenEmptyLock && selfEmptyLock; |
|
|
|
|