Browse Source

Pull request #11625: REPORT-80651 模板版本管理重构一期

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

* commit '557e27cf867e886a59ce10c627496f6fbf950b56':
  REPORT-80651 模板版本管理重构一期 - 优化代码结构
  REPORT-80651 模板版本管理重构一期 - 修改代码
  REPORT-80651 模板版本管理重构一期 - 代码格式
  REPORT-80651 模板版本管理重构一期
feature/x
loy-毕翔 2 years ago
parent
commit
52a6876da0
  1. 28
      designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java
  2. 13
      designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsHelper.java

28
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<Boolean, Boolean>() {
@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();
}
/**

13
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<VcsEntity> 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();

Loading…
Cancel
Save