Browse Source

Pull request #12501: REPORT-91839 模板版本管理二期 修复bug

Merge in DESIGN/design from ~DESTINY.LIN/design:release/11.0 to release/11.0

* commit '2b70d0f48467292a755704416b12390c642546bc':
  REPORT-91839 模板版本管理二期 没设置启动页,启动的时候判断有点问题
  REPORT-100518 【版本管理二期】无磁盘写入权限,版本迁移无异常提示
  REPORT-101340 【版本管理二期】自动清理配置灰化时,hover提示没有
  REPORT-101060 【版本管理三期】删除无权限的版本,能删除成功
  REPORT-101166 【版本管理三期】集群环境,版本管理页面所有配置项都不可点
  REPORT-100954 【版本管理三期】版本中心弹窗交互问题
  REPORT-91839 模板版本管理二期 偶遇报错,不确定场景,加一下处理
  REPORT-101167 【版本管理一期】集群环境,保存版本不生效
  REPORT-100162 【版本管理二期】模板不在编辑状态,还是在触发自动保存
  REPORT-100633 【版本管理二期】取消勾选备注的版本不会被清理,备注的版本还是不会被清理
  REPORT-101289 【版本管理二期】数据迁移的提示弹窗位置没有居中
  REPORT-101293 【版本管理二期】模板未打开,点击版本管理点不开
release/11.0
parent
commit
5d46088632
  1. 64
      designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java
  2. 8
      designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java
  3. 9
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java
  4. 37
      designer-base/src/main/java/com/fr/design/mainframe/vcs/VcsExceptionUtils.java
  5. 7
      designer-base/src/main/java/com/fr/design/mainframe/vcs/VcsTableEntity.java
  6. 14
      designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsHelper.java
  7. 15
      designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsMovePanel.java

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

@ -446,6 +446,7 @@ public class PreferencePane extends BasicPane {
intervalPanel.add(saveIntervalEditor);
intervalPanel.add(delayLabel);
autoCleanPane = createAutoCleanPane();
checkAutoScheduleStartAndUpdateStatus();
vcsEnableCheckBox.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
@ -467,7 +468,9 @@ public class PreferencePane extends BasicPane {
});
vcsPane.add(enableVcsPanel);
vcsPane.add(intervalPanel);
vcsPane.add(saveCommitCheckBox);
if (VcsHelper.getInstance().isLegacyMode()) {
vcsPane.add(saveCommitCheckBox);
}
vcsPane.add(autoCleanPane);
boolean support = VcsHelper.getInstance().checkV2FunctionSupport();
saveIntervalPane.setVisible(support);
@ -491,12 +494,10 @@ public class PreferencePane extends BasicPane {
saveIntervalPane.setVisible(useV2);
autoCleanPane.setVisible(useV2);
gcControlPane.setVisible(!useV2);
saveCommitCheckBox.setVisible(!useV2);
useVcsAutoCleanScheduleCheckBox.setSelected(useV2);
useVcsAutoSaveScheduleCheckBox.setSelected(useV2);
boolean useAutoClean =useV2 && FineScheduler.getInstance().isStarted();
useVcsAutoCleanScheduleCheckBox.setEnabled(useAutoClean);
autoCleanIntervalComboBox.setEnabled(useAutoClean);
autoCleanRetainIntervalComboBox.setEnabled(useAutoClean);
checkAutoScheduleStartAndUpdateStatus();
useVcsAutoSaveScheduleCheckBox.setEnabled(useV2);
}
});
@ -515,14 +516,41 @@ public class PreferencePane extends BasicPane {
autoCleanPane.add(new UILabel(i18nText("Fine-Design_Vcs_Auto_Clean_Content")));
autoCleanPane.add(autoCleanRetainIntervalComboBox);
autoCleanPane.add(new UILabel(i18nText("Fine-Design_Vcs_Auto_Clean_Last")));
boolean useAutoClean = !VcsHelper.getInstance().isLegacyMode() && FineScheduler.getInstance().isStarted();
useVcsAutoCleanScheduleCheckBox.setEnabled(useAutoClean);
autoCleanIntervalComboBox.setEnabled(useAutoClean);
autoCleanRetainIntervalComboBox.setEnabled(useAutoClean);
autoCleanPane.setVisible(false);
return autoCleanPane;
}
private void checkAutoScheduleStartAndUpdateStatus() {
if (!VcsHelper.getInstance().isLegacyMode()) {
new SwingWorker<Boolean, Void>() {
@Override
protected Boolean doInBackground() throws Exception {
return WorkContext.getCurrent().get(VcsAutoCleanOperator.class).isSupport();
}
@Override
protected void done() {
try {
boolean useAutoClean = get();
updateAutoCleanEnabled(useAutoClean);
} catch (InterruptedException | ExecutionException e) {
throw new RuntimeException(e);
}
}
}.execute();
} else {
updateAutoCleanEnabled(false);
}
}
private void updateAutoCleanEnabled(boolean b) {
useVcsAutoCleanScheduleCheckBox.setEnabled(b);
autoCleanIntervalComboBox.setEnabled(b);
autoCleanRetainIntervalComboBox.setEnabled(b);
if (autoCleanPane != null) {
autoCleanPane.setToolTipText(b ? null : Toolkit.i18nText("Fine-Design_Vcs_Server_Start_Hover"));
}
}
private JPanel createSaveIntervalPane() {
JPanel saveIntervalPane = new JPanel(FRGUIPaneFactory.createLeftZeroLayout());
useVcsAutoSaveScheduleCheckBox = new UICheckBox();
@ -1189,14 +1217,16 @@ public class PreferencePane extends BasicPane {
} else {
VcsHelper.getInstance().stopAutoSave();
}
if (useVcsAutoCleanScheduleCheckBox.isSelected()) {
FineLoggerFactory.getLogger().info("[VcsV2] start auto clean!");
WorkContext.getCurrent().get(VcsAutoCleanOperator.class).addOrUpdateVcsAutoCleanJob(
VcsAutoCleanService.VCS_AUTO_CLEAN_JOB_NAME,
getDay(autoCleanIntervalComboBox.getSelectedIndex()),
VcsAutoCleanSchedule.class);
} else {
WorkContext.getCurrent().get(VcsAutoCleanOperator.class).stopVcsAutoCleanJob(VcsAutoCleanService.VCS_AUTO_CLEAN_JOB_NAME);
if (useVcsAutoCleanScheduleCheckBox.isEnabled()) {
if (useVcsAutoCleanScheduleCheckBox.isSelected()) {
FineLoggerFactory.getLogger().info("[VcsV2] start auto clean!");
WorkContext.getCurrent().get(VcsAutoCleanOperator.class).addOrUpdateVcsAutoCleanJob(
VcsAutoCleanService.VCS_AUTO_CLEAN_JOB_NAME,
getDay(autoCleanIntervalComboBox.getSelectedIndex()),
VcsAutoCleanSchedule.class);
} else {
WorkContext.getCurrent().get(VcsAutoCleanOperator.class).stopVcsAutoCleanJob(VcsAutoCleanService.VCS_AUTO_CLEAN_JOB_NAME);
}
}
}
return null;

8
designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java

@ -407,9 +407,11 @@ public class TemplateTreePane extends JPanel implements FileOperations {
if (node instanceof FileNode) {
FileNodeFILE nodeFILE = new FileNodeFILE((FileNode) node);
if (nodeFILE.exists()) {
WorkContext.getCurrent().get(VcsOperator.class).recycleVersion(
VcsHelper.getInstance().getCurrentUsername(),
VcsHelper.getInstance().dealWithFilePath(((FileNode) node).getEnvPath()));
try {
WorkContext.getCurrent().get(VcsOperator.class).recycleVersion(VcsHelper.getInstance().getCurrentUsername(), VcsHelper.getInstance().dealWithFilePath(((FileNode) node).getEnvPath()));
} catch (Exception e) {
return false;
}
if (TemplateResourceManager.getResource().delete(nodeFILE)) {
HistoryTemplateListCache.getInstance().deleteFile(nodeFILE);
} else {

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

@ -394,8 +394,11 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
private boolean isCurrentEditing(String path) {
JTemplate<?, ?> jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
String editing = jt.getEditingFILE().getPath();
return ComparatorUtils.equals(editing, path);
if (JTemplate.isValid(jt)) {
String editing = jt.getEditingFILE().getPath();
return ComparatorUtils.equals(editing, path);
}
return false;
}
/**
@ -594,9 +597,9 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
confirmCloseAndShowVcsNewPane(jTemplate, path);
return;
}
showVcsNewPane(path);
}
}
showVcsNewPane(path);
}
private void confirmCloseAndShowVcsNewPane(JTemplate<?, ?> specifiedTemplate, String path) {

37
designer-base/src/main/java/com/fr/design/mainframe/vcs/VcsExceptionUtils.java

@ -0,0 +1,37 @@
package com.fr.design.mainframe.vcs;
import com.fr.design.i18n.Toolkit;
import java.io.IOException;
import java.util.HashMap;
/**
* 版本管理异常处理工具类
*
* @author Destiny.Lin
* @since 11.0
* Created on 2023/7/24
*/
public class VcsExceptionUtils {
public static final HashMap<Class, String> EXCEPTION_MAP = new HashMap<Class, String>() {
{
put(IOException.class, Toolkit.i18nText("Fine-Design_Vcs_Exception_IO"));
put(UnsupportedOperationException.class, Toolkit.i18nText("Fine-Design_Vcs_Exception_Un_Support"));
}
};
/**
* 根据异常返回结果描述文案
*/
public static String createDetailByException(Exception e) {
for (Class key : EXCEPTION_MAP.keySet()) {
if (key.isAssignableFrom(e.getClass())) {
return EXCEPTION_MAP.get(key);
}
}
return Toolkit.i18nText("Fine-Design_Vcs_Exception_Unknown");
}
}

7
designer-base/src/main/java/com/fr/design/mainframe/vcs/VcsTableEntity.java

@ -1,6 +1,7 @@
package com.fr.design.mainframe.vcs;
import com.fr.report.entity.VcsEntity;
import com.fr.stable.StringUtils;
/**
* 包装VcsEntity的用于表格展示与处理的类
@ -39,7 +40,11 @@ public class VcsTableEntity implements TableEntity{
* @return 版本大小
*/
public String getSize() {
return String.format("%.3f",entity.getSize()/MB_SIZE) + MB;
double size = entity.getSize()/MB_SIZE;
if (size == 0) {
return StringUtils.EMPTY;
}
return String.format("%.3f", size) + MB;
}
/**

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

@ -79,7 +79,14 @@ public class VcsHelper implements JTemplateActionListener {
VcsOperator op = WorkContext.getCurrent().get(VcsOperator.class);
// 开了设计器启动页面时一开始取不到VcsOperator,通过下面的切换环境事件再取,这边判断下
if (op != null) {
legacyMode = op.isLegacyMode();
try {
legacyMode = op.isLegacyMode();
root = WorkContext.getCurrent().isLocal() || WorkContext.getCurrent().isRoot();
} catch (Exception e) {
legacyMode = true;
root = false;
FineLoggerFactory.getLogger().error("[VcsHelper] init first failed ", e.getMessage());
}
}
EventDispatcher.listen(ConfigEvent.READY, new ListenerAdaptor() {
@Override
@ -344,7 +351,7 @@ public class VcsHelper implements JTemplateActionListener {
private void autoSave(JTemplate jt, String currentUsername, String fileName, int nowVersion, boolean replace, VcsOperator operator) {
try {
if (JTemplate.isValid(jt)) {
if (JTemplate.isValid(jt) && !jt.isALLSaved()) {
operator.autoSave(currentUsername, fileName, StringUtils.EMPTY, nowVersion, jt.exportData(), replace);
}
} catch (Exception e) {
@ -364,7 +371,8 @@ public class VcsHelper implements JTemplateActionListener {
public void templateSaved(JTemplate<?, ?> jt) {
if (needInit()
&& DesignerEnvManager.getEnvManager().getVcsConfigManager().isVcsEnable()
&& !WorkContext.getCurrent().isCluster()) {
// 如果是集群,在新版本下才生效
&& (!WorkContext.getCurrent().isCluster() || !VcsHelper.getInstance().isLegacyMode())) {
fireVcs(jt);
}
}

15
designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsMovePanel.java

@ -15,6 +15,7 @@ import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.VerticalFlowLayout;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.vcs.VcsExceptionUtils;
import com.fr.design.mainframe.vcs.common.VcsHelper;
import com.fr.design.utils.DesignUtils;
import com.fr.design.utils.ThemeUtils;
@ -279,7 +280,7 @@ public class VcsMovePanel extends BasicPane {
BasicDialog dlg = choosePane.showMediumWindow(SwingUtilities.getWindowAncestor(VcsMovePanel.this), new DialogActionAdapter() {
@Override
public void doOk() {
createConfirmPane(VcsMovePanel.this);
createConfirmPane();
}
});
dlg.setVisible(true);
@ -287,7 +288,7 @@ public class VcsMovePanel extends BasicPane {
});
}
private void createConfirmPane(Component parent) {
private void createConfirmPane() {
VerticalFlowLayout layout = new VerticalFlowLayout(VerticalFlowLayout.TOP);
layout.setAlignLeft(true);
JPanel panel = new JPanel();
@ -302,7 +303,7 @@ public class VcsMovePanel extends BasicPane {
panel.add(titleLabel);
panel.add(firstLabel);
panel.add(secondLabel);
int value = FineJOptionPane.showConfirmDialog(parent, panel, Toolkit.i18nText("Fine-Design_Vcs_Move_Title"), JOptionPane.YES_NO_OPTION);
int value = FineJOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), panel, Toolkit.i18nText("Fine-Design_Vcs_Move_Title"), JOptionPane.YES_NO_OPTION);
processMove(value);
}
@ -375,7 +376,7 @@ public class VcsMovePanel extends BasicPane {
return parentPane;
}
private void initFailedPane() {
private void initFailedPane(String detail) {
JPanel failedPane = new JPanel();
JPanel body = FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane();
failedButton = new UIButton(Toolkit.i18nText("Fine-Design_Vcs_Move_Failed_Go"));
@ -383,7 +384,7 @@ public class VcsMovePanel extends BasicPane {
failedIconLabel = new UILabel(IconUtils.readIcon("/com/fr/design/vcs/move_failed.svg"));
failedLabel = new UILabel(Toolkit.i18nText("Fine-Design_Vcs_Move_Failed"));
failedLabel.setFont(FONT);
failedTipLabel = new UILabel(Toolkit.i18nText("Fine-Design_Vcs_Move_Failed_Tip"));
failedTipLabel = new UILabel(Toolkit.i18nText("Fine-Design_Vcs_Move_Failed_Tip", detail));
initStatusPane(failedTipLabel, failedIconLabel, failedLabel, failedButton, body, FAILED, failedPane);
}
@ -409,6 +410,7 @@ public class VcsMovePanel extends BasicPane {
private class MoveWorker extends SwingWorker<Boolean, Integer> {
private VcsMoveStrategy strategy;
private String detail = StringUtils.EMPTY;
public MoveWorker(VcsMoveStrategy strategy) {
this.strategy = strategy;
@ -431,6 +433,7 @@ public class VcsMovePanel extends BasicPane {
}, strategy);
} catch (Exception e) {
VcsMoveService.getInstance().stopMoving();
detail = VcsExceptionUtils.createDetailByException(e);
return false;
}
return true;
@ -450,7 +453,7 @@ public class VcsMovePanel extends BasicPane {
VcsMovePanel.this.getParentCard().show(getParentPane(), SUCCESS);
VcsHelper.getInstance().updateLegacyMode();
} else {
initFailedPane();
initFailedPane(detail);
VcsMovePanel.this.getParentCard().show(getParentPane(), FAILED);
FineLoggerFactory.getLogger().error("[VcsV2] Vcs move failed!");
}

Loading…
Cancel
Save