Browse Source

Pull request #7269: REPORT-64656 设计器操作,双击已打开的模板,不会定位到对应模板

Merge in DESIGN/design from ~HADES/design:feature/x to feature/x

* commit '5188dfc04e0b0ff6ed46fbf8f40509701baa00e5':
  REPORT-64656 设计器操作,双击已打开的模板,不会定位到对应模板
feature/x
Hades 3 years ago
parent
commit
d0c5384fd5
  1. 6
      designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java
  2. 25
      designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java

6
designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java

@ -253,7 +253,11 @@ public class HistoryTemplateListCache implements CallbackEvent {
for (int i = 0; i < vCount; i++) { for (int i = 0; i < vCount; i++) {
JTemplate overTemplate = historyList.get(i); JTemplate overTemplate = historyList.get(i);
if (overTemplate.getEditingFILE().exists() && overTemplate.isALLSaved() && overTemplate != editingTemplate) { boolean replaceWithJVirtualTemplate = overTemplate.getEditingFILE().exists()
&& overTemplate.isALLSaved()
&& overTemplate != editingTemplate
&& overTemplate.checkEnable();
if (replaceWithJVirtualTemplate) {
closeVirtualSelectedReport(overTemplate); closeVirtualSelectedReport(overTemplate);
historyList.set(i, new JVirtualTemplate(overTemplate.getEditingFILE())); historyList.set(i, new JVirtualTemplate(overTemplate.getEditingFILE()));
} }

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

@ -57,6 +57,8 @@ import java.util.Enumeration;
import java.util.Objects; import java.util.Objects;
import java.util.Observable; import java.util.Observable;
import java.util.Observer; import java.util.Observer;
import org.jetbrains.annotations.Nullable;
import static javax.swing.JOptionPane.WARNING_MESSAGE; import static javax.swing.JOptionPane.WARNING_MESSAGE;
import static javax.swing.JOptionPane.YES_NO_OPTION; import static javax.swing.JOptionPane.YES_NO_OPTION;
@ -226,17 +228,17 @@ 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 (hasOpenedTemplate(selectedFilePath)) {
FineLoggerFactory.getLogger().info("{} has been opened in designer tab", selectedFilePath);
return;
}
String lock = node.getLock(); String lock = node.getLock();
boolean showLockInfo = LockInfoUtils.isCompatibleOperator() || LockInfoUtils.unableGetLockInfo() boolean showLockInfo = LockInfoUtils.isCompatibleOperator()
|| LockInfoUtils.unableGetLockInfo()
|| WorkContext.getCurrent().get(LockInfoOperator.class).isTplUnLocked(selectedFilePath)
? (lock != null && !lock.equals(node.getUserID())) ? (lock != null && !lock.equals(node.getUserID()))
: WorkContext.getCurrent().get(LockInfoOperator.class).isTplLocked(selectedFilePath); : WorkContext.getCurrent().get(LockInfoOperator.class).isTplLocked(selectedFilePath);
if (showLockInfo) { if (showLockInfo) {
UserInfo userInfo = WorkContext.getCurrent().get(LockInfoOperator.class).getUserInfo(selectedFilePath); UserInfo userInfo = WorkContext.getCurrent().get(LockInfoOperator.class).getUserInfo(selectedFilePath);
node.setLock(UUID.randomUUID().toString()); node.setLock(UUID.randomUUID().toString());
// 对于开发者预览占位锁定 定位到tab中
checkDevelopForBiddenTemplate(selectedFilePath);
LockInfoDialog.show(userInfo); LockInfoDialog.show(userInfo);
return; return;
} else { } else {
@ -245,14 +247,21 @@ 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 void checkDevelopForBiddenTemplate(String selectedFilePath) {
JTemplate<?, ?> template = getOpenedTemplate(selectedFilePath);
if (template != null && template.isForbidden()) {
DesignerContext.getDesignerFrame().openTemplate(new FileNodeFILE(new FileNode(selectedFilePath, false)));
}
}
private boolean hasOpenedTemplate(String path) { @Nullable
private JTemplate<?, ?> getOpenedTemplate(String path) {
for (JTemplate<?, ?> template : HistoryTemplateListCache.getInstance().getHistoryList()) { for (JTemplate<?, ?> template : HistoryTemplateListCache.getInstance().getHistoryList()) {
if (ComparatorUtils.equals(template.getEditingFILE().getPath(), path)) { if (ComparatorUtils.equals(template.getEditingFILE().getPath(), path)) {
return true; return template;
} }
} }
return false; return null;
} }
/** /**

Loading…
Cancel
Save