From 0574c315ad813e0125d495eb544ad07a1cf592f3 Mon Sep 17 00:00:00 2001 From: XiaXiang Date: Tue, 23 Apr 2019 13:25:12 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-14835=20=E8=B0=83=E6=95=B4=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mainframe/vcs/common/VcsHelper.java | 18 +++++++++++++ .../src/main/java/com/fr/start/Designer.java | 25 +++---------------- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsHelper.java b/designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsHelper.java index 006603fde..fc9d4e940 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsHelper.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsHelper.java @@ -1,9 +1,13 @@ package com.fr.design.mainframe.vcs.common; import com.fr.base.BaseUtils; +import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.file.TemplateTreePane; import com.fr.design.gui.itree.filetree.TemplateFileTree; import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.JTemplate; +import com.fr.stable.StringUtils; +import com.fr.stable.project.ProjectConstants; import com.fr.workspace.WorkContext; import javax.swing.Icon; @@ -64,5 +68,19 @@ public class VcsHelper { return VcsHelper.containsFolderCounts() + VcsHelper.selectedTemplateCounts() > 1; } + public static String getEdittingFilename() { + JTemplate jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + String editingFilePath = jt.getEditingFILE().getPath(); + if (editingFilePath.startsWith(ProjectConstants.REPORTLETS_NAME)) { + editingFilePath = editingFilePath.replaceFirst(ProjectConstants.REPORTLETS_NAME, StringUtils.EMPTY); + } else if (editingFilePath.startsWith(VcsHelper.VCS_CACHE_DIR)) { + editingFilePath = editingFilePath.replaceFirst(VcsHelper.VCS_CACHE_DIR, StringUtils.EMPTY); + } + if (editingFilePath.startsWith("/")) { + editingFilePath = editingFilePath.substring(1); + } + return editingFilePath; + } + } diff --git a/designer-realize/src/main/java/com/fr/start/Designer.java b/designer-realize/src/main/java/com/fr/start/Designer.java index 4ad08f2ba..f7cb825ed 100644 --- a/designer-realize/src/main/java/com/fr/start/Designer.java +++ b/designer-realize/src/main/java/com/fr/start/Designer.java @@ -62,7 +62,7 @@ import com.fr.start.preload.ImagePreLoader; import com.fr.start.server.ServerTray; import com.fr.workspace.WorkContext; import com.fr.workspace.server.vcs.VcsOperator; -import com.fr.design.mainframe.vcs.common.Constants; +import com.fr.design.mainframe.vcs.common.VcsHelper; import javax.swing.JComponent; import javax.swing.JOptionPane; @@ -280,7 +280,7 @@ public class Designer extends BaseDesigner { jt.stopEditing(); jt.saveTemplate(); jt.requestFocus(); - String fileName = getEditingFilename(); + String fileName = VcsHelper.getEdittingFilename(); int latestFileVersion = 0; try { latestFileVersion = WorkContext.getCurrent().get(VcsOperator.class).getLatestFileVersion(fileName); @@ -288,15 +288,14 @@ public class Designer extends BaseDesigner { } catch (Exception e1) { FineLoggerFactory.getLogger().error(e1.getMessage()); } - try { if (jt.getEditingFILE() instanceof VcsCacheFileNodeFile) { - WorkContext.getCurrent().get(VcsOperator.class).saveVersionFromCache(Constants.CURRENT_USERNAME, fileName, StringUtils.EMPTY, latestFileVersion + 1); + WorkContext.getCurrent().get(VcsOperator.class).saveVersionFromCache(VcsHelper.CURRENT_USERNAME, fileName, StringUtils.EMPTY, latestFileVersion + 1); String path = DesignerFrameFileDealerPane.getInstance().getSelectedOperation().getFilePath(); FileVersionTable.getInstance().updateModel(1, WorkContext.getCurrent().get(VcsOperator.class).getVersions(path.replaceFirst("/", ""))); } else { - WorkContext.getCurrent().get(VcsOperator.class).saveVersion(Constants.CURRENT_USERNAME, fileName, StringUtils.EMPTY, latestFileVersion + 1); + WorkContext.getCurrent().get(VcsOperator.class).saveVersion(VcsHelper.CURRENT_USERNAME, fileName, StringUtils.EMPTY, latestFileVersion + 1); } } catch (Exception e1) { FineLoggerFactory.getLogger().error(e1.getMessage()); @@ -307,22 +306,6 @@ public class Designer extends BaseDesigner { return saveButton; } - public static String getEditingFilename() { - JTemplate jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); - String editingFilePath = jt.getEditingFILE().getPath(); - //TODO 如果是cache里的文件,也会走到这里,这里是找到reportlets去掉的。万一刚好cache/reportlets会出问题 - if (editingFilePath.startsWith(ProjectConstants.REPORTLETS_NAME)) { - editingFilePath = editingFilePath.replaceFirst(ProjectConstants.REPORTLETS_NAME, StringUtils.EMPTY); - } else if (editingFilePath.startsWith(Constants.VCS_CACHE_DIR)) { - editingFilePath = editingFilePath.replaceFirst(Constants.VCS_CACHE_DIR, StringUtils.EMPTY); - } - //TODO refactor 考虑直接用reportlets/xxx/x/x/x/x/x// or /xx/x/x/x/x/x - if (editingFilePath.startsWith("/")) { - editingFilePath = editingFilePath.substring(1); - } - return editingFilePath; - } - private UIButton createUndoButton() { undo = new UIButton(BaseUtils.readIcon("/com/fr/design/images/buttonicon/undo.png")); undo.setToolTipText(KeySetUtils.UNDO.getMenuKeySetName());