Browse Source

REPORT-62438 远程模板锁定优化 更新部分业务逻辑

feature/x
hades 3 years ago
parent
commit
b2fce2875d
  1. 16
      designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java
  2. 2
      designer-base/src/main/java/com/fr/design/lock/LockInfoDialog.java
  3. 4
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java
  4. 9
      designer-base/src/main/java/com/fr/design/utils/TemplateUtils.java
  5. 2
      designer-base/src/main/java/com/fr/design/worker/save/SaveFailureHandler.java

16
designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java

@ -15,6 +15,7 @@ import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.DesignerFrameFileDealerPane; import com.fr.design.mainframe.DesignerFrameFileDealerPane;
import com.fr.design.lock.LockInfoDialog; import com.fr.design.lock.LockInfoDialog;
import com.fr.design.mainframe.JTemplate;
import com.fr.file.FILE; import com.fr.file.FILE;
import com.fr.file.FileNodeFILE; import com.fr.file.FileNodeFILE;
import com.fr.file.filetree.FileNode; import com.fr.file.filetree.FileNode;
@ -224,8 +225,8 @@ public class TemplateTreePane extends JPanel implements FileOperations {
} }
String reportPath = reportletsTree.getSelectedTemplatePath(); String reportPath = reportletsTree.getSelectedTemplatePath();
final String selectedFilePath = StableUtils.pathJoin(ProjectConstants.REPORTLETS_NAME, reportPath); final String selectedFilePath = StableUtils.pathJoin(ProjectConstants.REPORTLETS_NAME, reportPath);
if (WorkContext.getCurrent().get(LockInfoOperator.class).isTplUnLocked(selectedFilePath)) { if (hasOpenedTemplate(selectedFilePath)) {
FineLoggerFactory.getLogger().info("{} has been unlocked", selectedFilePath); FineLoggerFactory.getLogger().info("{} has been opened in designer tab", selectedFilePath);
return; return;
} }
String lock = node.getLock(); String lock = node.getLock();
@ -240,6 +241,16 @@ public class TemplateTreePane extends JPanel implements FileOperations {
DesignerContext.getDesignerFrame().openTemplate(new FileNodeFILE(new FileNode(selectedFilePath, false))); DesignerContext.getDesignerFrame().openTemplate(new FileNodeFILE(new FileNode(selectedFilePath, false)));
} }
private boolean hasOpenedTemplate(String path) {
for (JTemplate<?, ?> template : HistoryTemplateListCache.getInstance().getHistoryList()) {
if (ComparatorUtils.equals(template.getEditingFILE().getPath(), path)) {
return true;
}
}
return false;
}
/** /**
* 打开文件夹 * 打开文件夹
*/ */
@ -263,6 +274,7 @@ public class TemplateTreePane extends JPanel implements FileOperations {
// 刷新远程文件夹权限 // 刷新远程文件夹权限
NodeAuthProcessor.getInstance().refresh(); NodeAuthProcessor.getInstance().refresh();
reportletsTree.refresh(); reportletsTree.refresh();
DesignerFrameFileDealerPane.getInstance().refreshRightToolBarBy(null);
FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Basic_Template_File_Tree_Refresh_Successfully") + "!"); FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Basic_Template_File_Tree_Refresh_Successfully") + "!");
} }

2
designer-base/src/main/java/com/fr/design/lock/LockInfoDialog.java

@ -89,7 +89,7 @@ public class LockInfoDialog extends JDialog {
return; return;
} }
final String selectedFilePath = StableUtils.pathJoin(ProjectConstants.REPORTLETS_NAME, TemplateTreePane.getInstance().getFilePath()); final String selectedFilePath = StableUtils.pathJoin(ProjectConstants.REPORTLETS_NAME, TemplateTreePane.getInstance().getFilePath());
TemplateUtils.createAndOpenTemplate(Toolkit.i18nText("Fine_Design_Template_Lock_Copy"), new FileNodeFILE(new FileNode(selectedFilePath, false))); TemplateUtils.createAndOpenTemplate(Toolkit.i18nText("Fine_Design_Template_Lock_Copy"), new FileNodeFILE(new FileNode(selectedFilePath, false)), true);
} }
}); });
cancelButton.addActionListener(new ActionListener() { cancelButton.addActionListener(new ActionListener() {

4
designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java

@ -596,8 +596,10 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
public void refreshRightToolBarBy(FileNode fileNode) { public void refreshRightToolBarBy(FileNode fileNode) {
if (rightToolBar != null) { if (rightToolBar != null) {
boolean visible = fileNode != null boolean locked = fileNode != null
&& StringUtils.isNotEmpty(fileNode.getLock()) && StringUtils.isNotEmpty(fileNode.getLock())
&& !ComparatorUtils.equals(fileNode.getLock(), fileNode.getUserID());
boolean visible = locked
&& WorkContext.getCurrent().isRoot() && WorkContext.getCurrent().isRoot()
&& WorkContext.getCurrent().get(LockInfoOperator.class).isUnLockable() && WorkContext.getCurrent().get(LockInfoOperator.class).isUnLockable()
&& !WorkContext.getCurrent().get(LockInfoOperator.class).isTplUnLocked(fileNode.getEnvPath()); && !WorkContext.getCurrent().get(LockInfoOperator.class).isTplUnLocked(fileNode.getEnvPath());

9
designer-base/src/main/java/com/fr/design/utils/TemplateUtils.java

@ -25,7 +25,7 @@ import javax.swing.SwingWorker;
*/ */
public class TemplateUtils { public class TemplateUtils {
public static void createAndOpenTemplate(String prefix, FILE file) { public static void createAndOpenTemplate(String prefix, FILE file, boolean needOpen) {
String fileName = file.getName(); String fileName = file.getName();
String oldPath = file.getPath(); String oldPath = file.getPath();
int indexOfLastDot = fileName.lastIndexOf(CoreConstants.DOT); int indexOfLastDot = fileName.lastIndexOf(CoreConstants.DOT);
@ -47,13 +47,13 @@ public class TemplateUtils {
if (isOk(result)) { if (isOk(result)) {
file = fileChooserPane.getSelectedFILE(); file = fileChooserPane.getSelectedFILE();
_createAndOpenTemplate(file, oldPath); _createAndOpenTemplate(file, oldPath, needOpen);
} }
} }
private static void _createAndOpenTemplate(FILE file, String oldPath){ private static void _createAndOpenTemplate(FILE file, String oldPath, boolean needOpen){
new SwingWorker<Void, Void>() { new SwingWorker<Void, Void>() {
@Override @Override
@ -86,8 +86,9 @@ public class TemplateUtils {
protected void done() { protected void done() {
try { try {
get(); get();
if (needOpen) {
DesignerContext.getDesignerFrame().openTemplate(file); DesignerContext.getDesignerFrame().openTemplate(file);
TemplateTreePane.getInstance().refresh(); }
} catch (Exception e) { } catch (Exception e) {
SaveFailureHandler.Handler.FullDisk.process(e); SaveFailureHandler.Handler.FullDisk.process(e);
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);

2
designer-base/src/main/java/com/fr/design/worker/save/SaveFailureHandler.java

@ -103,7 +103,7 @@ public class SaveFailureHandler implements ThrowableHandler {
if (option == JOptionPane.YES_OPTION) { if (option == JOptionPane.YES_OPTION) {
JTemplate<?, ?> template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); JTemplate<?, ?> template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (template != null) { if (template != null) {
TemplateUtils.createAndOpenTemplate(Toolkit.i18nText("Fine_Design_Template_Backup"), new FileNodeFILE(new FileNode(template.getPath(), false))); TemplateUtils.createAndOpenTemplate(Toolkit.i18nText("Fine_Design_Template_Backup"), new FileNodeFILE(new FileNode(template.getPath(), false)), false);
} }
} }
} }

Loading…
Cancel
Save