Browse Source

REPORT-80651 模板版本管理重构一期(在11.0.15上回滚)

Revert "REPORT-92325 修复环境初始化之前调用远程设计接口导致NPE问题"
Revert "REPORT-92308 版本管理可用性判断逻辑适配新模式"
Revert "REPORT-80651 模板版本管理重构一期"
release/11.0
loy 2 years ago
parent
commit
006ae013d3
  1. 5
      designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java
  2. 9
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java
  3. 41
      designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsHelper.java

5
designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java

@ -390,10 +390,7 @@ public class PreferencePane extends BasicPane {
vcsPane.add(enableVcsPanel); vcsPane.add(enableVcsPanel);
vcsPane.add(intervalPanel); vcsPane.add(intervalPanel);
vcsPane.add(saveCommitCheckBox); vcsPane.add(saveCommitCheckBox);
if (VcsHelper.getInstance().isLegacyMode()) { vcsPane.add(gcControlPane);
// 老版本时才显示gc选项
vcsPane.add(gcControlPane);
}
} }
/** /**

9
designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java

@ -325,7 +325,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
if (VcsHelper.getInstance().needInit()) { if (VcsHelper.getInstance().needInit()) {
vcsAction = new VcsAction(); vcsAction = new VcsAction();
if (!isLegacyOnCluster()) { if (!WorkContext.getCurrent().isCluster()) {
vcsAction.setName(Toolkit.i18nText("Fine-Design_Vcs_Title")); vcsAction.setName(Toolkit.i18nText("Fine-Design_Vcs_Title"));
} else { } else {
vcsAction.setName(Toolkit.i18nText("Fine-Design_Vcs_NotSupportRemote")); vcsAction.setName(Toolkit.i18nText("Fine-Design_Vcs_NotSupportRemote"));
@ -509,7 +509,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
private void fireVcsActionChange(boolean enable) { private void fireVcsActionChange(boolean enable) {
if (!DesignerEnvManager.getEnvManager().getVcsConfigManager().isVcsEnable() if (!DesignerEnvManager.getEnvManager().getVcsConfigManager().isVcsEnable()
|| VcsHelper.getInstance().isUnSelectedTemplate() || VcsHelper.getInstance().isUnSelectedTemplate()
|| isLegacyOnCluster()) { || WorkContext.getCurrent().isCluster()) {
setEnabled(false); setEnabled(false);
return; return;
} }
@ -810,11 +810,6 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
} }
} }
private boolean isLegacyOnCluster() {
// 老模式且为集群,用于代替之前的只判断集群逻辑
return WorkContext.getCurrent().isCluster() && VcsHelper.getInstance().isLegacyMode();
}
private String doCheck (String userInput, String suffix) { private String doCheck (String userInput, String suffix) {
String errorMsg = StringUtils.EMPTY; String errorMsg = StringUtils.EMPTY;
if (selectedOperation.duplicated(userInput, suffix, true)) { if (selectedOperation.duplicated(userInput, suffix, true)) {

41
designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsHelper.java

@ -12,9 +12,6 @@ import com.fr.design.mainframe.JTemplate;
import com.fr.design.mainframe.JTemplateActionListener; import com.fr.design.mainframe.JTemplateActionListener;
import com.fr.design.mainframe.vcs.VcsConfigManager; import com.fr.design.mainframe.vcs.VcsConfigManager;
import com.fr.design.mainframe.vcs.ui.FileVersionTable; import com.fr.design.mainframe.vcs.ui.FileVersionTable;
import com.fr.event.Event;
import com.fr.event.EventDispatcher;
import com.fr.event.Listener;
import com.fr.general.IOUtils; import com.fr.general.IOUtils;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.plugin.context.PluginContext; import com.fr.plugin.context.PluginContext;
@ -23,14 +20,11 @@ import com.fr.report.entity.VcsEntity;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.stable.project.ProjectConstants; import com.fr.stable.project.ProjectConstants;
import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContext;
import com.fr.workspace.Workspace;
import com.fr.workspace.WorkspaceEvent;
import com.fr.workspace.server.vcs.VcsOperator; import com.fr.workspace.server.vcs.VcsOperator;
import com.fr.workspace.server.vcs.filesystem.VcsFileSystem; import com.fr.workspace.server.vcs.filesystem.VcsFileSystem;
import com.fr.workspace.server.vcs.git.config.GcConfig; import com.fr.workspace.server.vcs.git.config.GcConfig;
import javax.swing.Icon; import javax.swing.Icon;
import javax.swing.SwingUtilities;
import javax.swing.border.EmptyBorder; import javax.swing.border.EmptyBorder;
import java.awt.Color; import java.awt.Color;
import java.util.List; import java.util.List;
@ -61,26 +55,10 @@ public class VcsHelper implements JTemplateActionListener {
private final static String SERVICE_NAME_MOVE = "moveVcs"; private final static String SERVICE_NAME_MOVE = "moveVcs";
private static final VcsHelper INSTANCE = new VcsHelper(); private static final VcsHelper INSTANCE = new VcsHelper();
private volatile boolean legacyMode;
public static VcsHelper getInstance() { public static VcsHelper getInstance() {
return INSTANCE; return INSTANCE;
} }
private VcsHelper() {
VcsOperator op = WorkContext.getCurrent().get(VcsOperator.class);
// 开了设计器启动页面时一开始取不到VcsOperator,通过下面的切换环境事件再取,这边判断下
if (op != null) {
legacyMode = op.isLegacyMode();
}
EventDispatcher.listen(WorkspaceEvent.AfterSwitch, new Listener<Workspace>() {
@Override
public void on(Event event, Workspace param) {
legacyMode = WorkContext.getCurrent().get(VcsOperator.class).isLegacyMode();
}
});
}
private int containsFolderCounts() { private int containsFolderCounts() {
TemplateFileTree fileTree = TemplateTreePane.getInstance().getTemplateFileTree(); TemplateFileTree fileTree = TemplateTreePane.getInstance().getTemplateFileTree();
if (fileTree.getSelectionPaths() == null) { if (fileTree.getSelectionPaths() == null) {
@ -159,18 +137,20 @@ public class VcsHelper implements JTemplateActionListener {
String fileName = getEditingFilename(); String fileName = getEditingFilename();
VcsOperator operator = WorkContext.getCurrent().get(VcsOperator.class); VcsOperator operator = WorkContext.getCurrent().get(VcsOperator.class);
VcsEntity entity = operator.getFileVersionByIndex(fileName, 0); VcsEntity entity = operator.getFileVersionByIndex(fileName, 0);
boolean replace = needDeleteVersion(entity);
int latestFileVersion = 0; int latestFileVersion = 0;
if (entity != null) { if (entity != null) {
latestFileVersion = entity.getVersion(); latestFileVersion = entity.getVersion();
} }
if (jt.getEditingFILE() instanceof VcsCacheFileNodeFile) { if (jt.getEditingFILE() instanceof VcsCacheFileNodeFile) {
operator.saveVersionFromCache(getCurrentUsername(), fileName, StringUtils.EMPTY, latestFileVersion + 1, replace); operator.saveVersionFromCache(getCurrentUsername(), fileName, StringUtils.EMPTY, latestFileVersion + 1);
String path = DesignerFrameFileDealerPane.getInstance().getSelectedOperation().getFilePath(); String path = DesignerFrameFileDealerPane.getInstance().getSelectedOperation().getFilePath();
List<VcsEntity> updatedList = WorkContext.getCurrent().get(VcsOperator.class).getVersions(path.replaceFirst(VCS_FILE_SLASH, StringUtils.EMPTY)); FileVersionTable.getInstance().updateModel(1, WorkContext.getCurrent().get(VcsOperator.class).getVersions(path.replaceFirst(VCS_FILE_SLASH, StringUtils.EMPTY)));
SwingUtilities.invokeLater(() -> FileVersionTable.getInstance().updateModel(1, updatedList));
} else { } else {
operator.saveVersion(getCurrentUsername(), fileName, StringUtils.EMPTY, latestFileVersion + 1, replace); 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());
} }
if (GcConfig.getInstance().isGcEnable()) { if (GcConfig.getInstance().isGcEnable()) {
operator.gc(); operator.gc();
@ -208,13 +188,6 @@ public class VcsHelper implements JTemplateActionListener {
moveVcs.shutdown(); moveVcs.shutdown();
} }
/**
* 判断是否为老模式
* @return 是否为老模式
*/
public boolean isLegacyMode() {
return legacyMode;
}
@Override @Override
public void templateOpened(JTemplate<?, ?> jt) { public void templateOpened(JTemplate<?, ?> jt) {

Loading…
Cancel
Save