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. 12
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java
  4. 11
      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.DesignerFrameFileDealerPane;
import com.fr.design.lock.LockInfoDialog;
import com.fr.design.mainframe.JTemplate;
import com.fr.file.FILE;
import com.fr.file.FileNodeFILE;
import com.fr.file.filetree.FileNode;
@ -224,8 +225,8 @@ public class TemplateTreePane extends JPanel implements FileOperations {
}
String reportPath = reportletsTree.getSelectedTemplatePath();
final String selectedFilePath = StableUtils.pathJoin(ProjectConstants.REPORTLETS_NAME, reportPath);
if (WorkContext.getCurrent().get(LockInfoOperator.class).isTplUnLocked(selectedFilePath)) {
FineLoggerFactory.getLogger().info("{} has been unlocked", selectedFilePath);
if (hasOpenedTemplate(selectedFilePath)) {
FineLoggerFactory.getLogger().info("{} has been opened in designer tab", selectedFilePath);
return;
}
String lock = node.getLock();
@ -240,6 +241,16 @@ public class TemplateTreePane extends JPanel implements FileOperations {
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();
reportletsTree.refresh();
DesignerFrameFileDealerPane.getInstance().refreshRightToolBarBy(null);
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;
}
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() {

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

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

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

@ -25,7 +25,7 @@ import javax.swing.SwingWorker;
*/
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 oldPath = file.getPath();
int indexOfLastDot = fileName.lastIndexOf(CoreConstants.DOT);
@ -47,13 +47,13 @@ public class TemplateUtils {
if (isOk(result)) {
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>() {
@Override
@ -86,8 +86,9 @@ public class TemplateUtils {
protected void done() {
try {
get();
DesignerContext.getDesignerFrame().openTemplate(file);
TemplateTreePane.getInstance().refresh();
if (needOpen) {
DesignerContext.getDesignerFrame().openTemplate(file);
}
} catch (Exception e) {
SaveFailureHandler.Handler.FullDisk.process(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) {
JTemplate<?, ?> template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
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