From 9ad3ea3549e1d1160b46f3257516017bc2ed2ab5 Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" <3166887LjL> Date: Wed, 2 Aug 2023 15:00:28 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-101409=20=E3=80=90=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E4=B8=89=E6=9C=9F=E3=80=91=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E6=97=A0=E6=9D=83=E9=99=90=E7=9A=84=E7=89=88=E6=9C=AC=E6=B2=A1?= =?UTF-8?q?=E6=9C=89=E5=A4=B1=E8=B4=A5=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mainframe/vcs/ui/VcsCenterPane.java | 6 ---- .../design/mainframe/vcs/ui/VcsNewPane.java | 36 +++++++++++++++---- 2 files changed, 29 insertions(+), 13 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsCenterPane.java b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsCenterPane.java index 080edb4a25..4ca132ea5b 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsCenterPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsCenterPane.java @@ -241,12 +241,6 @@ public class VcsCenterPane extends VcsNewPane { return TITLE; } - - private String getTemplateTruePath(String filename) { - return StableUtils.pathJoin(ProjectConstants.REPORTLETS_NAME, filename); - } - - @Override protected String getDeleteTip(int size) { return Toolkit.i18nText("Fine-Design_Vcs_Delete_Select_All_Version"); diff --git a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsNewPane.java b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsNewPane.java index b924228fd1..0ffa32ef12 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsNewPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsNewPane.java @@ -4,6 +4,7 @@ import com.fr.base.svg.IconUtils; import com.fr.design.dialog.FineJOptionPane; import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.file.MultiTemplateTabPane; +import com.fr.design.file.TemplateTreePane; import com.fr.design.gui.ilable.UILabel; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.DesignerContext; @@ -16,19 +17,20 @@ import com.fr.design.mainframe.vcs.common.VcsCacheFileNodeFile; import com.fr.design.mainframe.vcs.common.VcsHelper; import com.fr.file.FileNodeFILE; import com.fr.file.filetree.FileNode; +import com.fr.file.filetree.FileNodes; import com.fr.io.utils.ResourceIOUtils; +import com.fr.report.InconsistentLockException; import com.fr.report.entity.VcsEntity; +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.resource.WorkResource; import com.fr.workspace.server.vcs.VcsFileUtils; import com.fr.workspace.server.vcs.VcsOperator; import com.fr.workspace.server.vcs.v2.VcsTaskResult; -import javax.swing.Icon; -import javax.swing.JComponent; -import javax.swing.JOptionPane; -import javax.swing.JTable; -import javax.swing.SwingWorker; +import javax.swing.*; import java.awt.*; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; @@ -179,9 +181,12 @@ public class VcsNewPane extends RecyclePane { @Override protected VcsTaskResult doInBackground() throws Exception { String path = VcsHelper.getInstance().getFilePath(entity); - if (!ResourceIOUtils.exist(path)) { + if (!WorkContext.getCurrent().get(WorkResource.class).exist(path)) { return new VcsTaskResult(false, new FileNotFoundException()); } + if (checkLock(entity.getFilename())) { + return new VcsTaskResult(false, new InconsistentLockException()); + } //step1.设置还原的用户名 entity.setUsername(VcsHelper.getInstance().getCurrentUsername()); //step2.rollback到指定版本 @@ -206,7 +211,11 @@ public class VcsNewPane extends RecyclePane { } DesignerContext.getDesignerFrame().openTemplate(new FileNodeFILE(new FileNode(filePath, false))); } else { - FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Warning_Template_Do_Not_Exsit")); + if (result.getException() instanceof FileNotFoundException) { + FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Warning_Template_Do_Not_Exsit")); + } else { + FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Vcs_Open_Lock_Tip"), UIManager.getString("OptionPane.messageDialogTitle"), JOptionPane.ERROR_MESSAGE); + } } } catch (InterruptedException | ExecutionException e) { throw new RuntimeException(e); @@ -215,6 +224,19 @@ public class VcsNewPane extends RecyclePane { }.execute(); } + private boolean checkLock(String filename) { + String selectedFilePath = getTemplateTruePath(filename); + FileNode node = new FileNode(getTemplateTruePath(filename), false); + String lock = node.getLock(); + return TemplateTreePane.needShowLockInfo(lock, selectedFilePath, node); + } + + /** + * 获取模板的路径 + */ + public String getTemplateTruePath(String filename) { + return StableUtils.pathJoin(ProjectConstants.REPORTLETS_NAME, filename); + } private void initDeleteListener() { delete.addMouseListener(new MouseAdapter() {