diff --git a/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java b/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java index 46485409bb..e09d6f7a05 100644 --- a/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java +++ b/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java @@ -356,8 +356,6 @@ public class PreferencePane extends BasicPane { useIntervalCheckBox = new UICheckBox(); //gc面板 - JPanel gcControlPane = createGcControlPane(); - JPanel enableVcsPanel = new JPanel(FRGUIPaneFactory.createLeftZeroLayout()); enableVcsPanel.add(vcsEnableCheckBox); enableVcsPanel.add(remindVcsLabel); @@ -390,7 +388,31 @@ public class PreferencePane extends BasicPane { vcsPane.add(enableVcsPanel); vcsPane.add(intervalPanel); vcsPane.add(saveCommitCheckBox); - vcsPane.add(gcControlPane); + + initGcControlPane(vcsPane); + } + + private void initGcControlPane(JPanel vcsPane) { + JPanel gcControlPane = createGcControlPane(); + new SwingWorker() { + @Override + protected Boolean doInBackground() throws Exception { + return WorkContext.getCurrent().get(VcsOperator.class).isLegacyMode(); + } + + @Override + protected void done() { + try { + if (Boolean.TRUE.equals(get())) { + // 老版本时才显示gc选项 + vcsPane.add(gcControlPane); + vcsPane.updateUI(); + } + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e, "[Vcs] retrieve legacy mode error: {}", e.getMessage()); + } + } + }.execute(); } /** 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 980ccb5a3a..c72fa68dc4 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 @@ -25,6 +25,7 @@ import com.fr.workspace.server.vcs.filesystem.VcsFileSystem; import com.fr.workspace.server.vcs.git.config.GcConfig; import javax.swing.Icon; +import javax.swing.SwingUtilities; import javax.swing.border.EmptyBorder; import java.awt.Color; import java.util.List; @@ -137,20 +138,18 @@ public class VcsHelper implements JTemplateActionListener { String fileName = getEditingFilename(); VcsOperator operator = WorkContext.getCurrent().get(VcsOperator.class); VcsEntity entity = operator.getFileVersionByIndex(fileName, 0); + boolean replace = needDeleteVersion(entity); int latestFileVersion = 0; if (entity != null) { latestFileVersion = entity.getVersion(); } if (jt.getEditingFILE() instanceof VcsCacheFileNodeFile) { - operator.saveVersionFromCache(getCurrentUsername(), fileName, StringUtils.EMPTY, latestFileVersion + 1); + operator.saveVersionFromCache(getCurrentUsername(), fileName, StringUtils.EMPTY, latestFileVersion + 1, replace); String path = DesignerFrameFileDealerPane.getInstance().getSelectedOperation().getFilePath(); - FileVersionTable.getInstance().updateModel(1, WorkContext.getCurrent().get(VcsOperator.class).getVersions(path.replaceFirst(VCS_FILE_SLASH, StringUtils.EMPTY))); + List updatedList = WorkContext.getCurrent().get(VcsOperator.class).getVersions(path.replaceFirst(VCS_FILE_SLASH, StringUtils.EMPTY)); + SwingUtilities.invokeLater(() -> FileVersionTable.getInstance().updateModel(1, updatedList)); } else { - operator.saveVersion(getCurrentUsername(), fileName, StringUtils.EMPTY, latestFileVersion + 1); - } - VcsEntity oldEntity = WorkContext.getCurrent().get(VcsOperator.class).getFileVersionByIndexAndUsername(fileName, getCurrentUsername(), 1); - if (needDeleteVersion(oldEntity)) { - operator.deleteVersion(oldEntity.getFilename(), oldEntity.getVersion()); + operator.saveVersion(getCurrentUsername(), fileName, StringUtils.EMPTY, latestFileVersion + 1, replace); } if (GcConfig.getInstance().isGcEnable()) { operator.gc();