diff --git a/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java b/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java
index 6d8d5b9c0c..bd464d77e0 100644
--- a/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java
+++ b/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java
@@ -14,6 +14,7 @@ import com.fr.design.env.DesignerWorkspaceType;
import com.fr.design.env.LocalDesignerWorkspaceInfo;
import com.fr.design.env.RemoteDesignerWorkspaceInfo;
import com.fr.design.file.HistoryTemplateListPane;
+import com.fr.design.mainframe.vcs.VcsConfigManager;
import com.fr.design.update.push.DesignerPushUpdateConfigManager;
import com.fr.design.style.color.ColorSelectConfigManager;
import com.fr.design.utils.DesignUtils;
@@ -130,11 +131,6 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
private int westRegionContainerWidth = 240;
private String encryptionKey;
private String jdkHome;
- private boolean vcsEnable;
- private boolean saveCommit;
- private int saveInterval;
-
-
//上一次登录弹窗的时间, 为了控制一天只弹一次窗口
private String lastShowBBSTime;
@@ -154,6 +150,8 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
private DesignerPushUpdateConfigManager designerPushUpdateConfigManager = DesignerPushUpdateConfigManager.getInstance();
+ private VcsConfigManager vcsConfigManager = VcsConfigManager.getInstance();
+
public static final String CAS_CERTIFICATE_PATH = "certificatePath";
public static final String CAS_CERTIFICATE_PASSWORD = "certificatePass";
@@ -1501,6 +1499,8 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
readOpenDebug(reader);
} else if (name.equals(DesignerPushUpdateConfigManager.XML_TAG)) {
readDesignerPushUpdateAttr(reader);
+ } else if (name.equals(vcsConfigManager.XML_TAG)) {
+ readVcsAttr(reader);
} else {
readLayout(reader, name);
}
@@ -1607,9 +1607,6 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
this.setDragPermited(reader.getAttrAsBoolean("isDragPermited", false));
this.setUndoLimit(reader.getAttrAsInt("undoLimit", 5));
this.setDefaultStringToFormula(reader.getAttrAsBoolean("defaultStringToFormula", false));
- this.setVcsEnable(reader.getAttrAsBoolean("supportVcs", true));
- this.setSaveCommit(reader.getAttrAsBoolean("saveCommit", false));
- this.setSaveInterval(reader.getAttrAsInt("saveInterval", 60));
if ((tmpVal = reader.getAttrAsString("gridLineColor", null)) != null) {
this.setGridLineColor(new Color(Integer.parseInt(tmpVal)));
}
@@ -1690,6 +1687,10 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
reader.readXMLObject(designerPushUpdateConfigManager);
}
+ private void readVcsAttr(XMLableReader reader) {
+ reader.readXMLObject(vcsConfigManager);
+ }
+
/**
* Write XML.
* The method will be invoked when save data to XML file.
@@ -1714,6 +1715,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
writeRecentColor(writer);
writeOpenDebug(writer);
writeDesignerPushUpdateAttr(writer);
+ writeVcsAttr(writer);
writer.end();
}
@@ -1945,9 +1947,6 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
.attr("verticalScrollBarVisible", this.isVerticalScrollBarVisible())
.attr("horizontalScrollBarVisible", this.isHorizontalScrollBarVisible())
.attr("supportCellEditorDef", this.isSupportCellEditorDef())
- .attr("supportVcs", this.isVcsEnable())
- .attr("saveInterval", this.getSaveInterval())
- .attr("saveCommit", this.isSaveCommit())
.attr("isDragPermited", this.isDragPermited())
.attr("gridLineColor", this.getGridLineColor().getRGB())
.attr("paginationLineColor", this.getPaginationLineColor().getRGB())
@@ -1959,27 +1958,16 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
this.designerPushUpdateConfigManager.writeXML(writer);
}
- public boolean isVcsEnable() {
- return vcsEnable;
+ private void writeVcsAttr(XMLPrintWriter writer) {
+ this.vcsConfigManager.writeXML(writer);
}
- public void setVcsEnable(boolean vcsEnable) {
- this.vcsEnable = vcsEnable;
- }
-
- public boolean isSaveCommit() {
- return saveCommit;
- }
-
- public void setSaveCommit(boolean saveCommit) {
- this.saveCommit = saveCommit;
- }
- public int getSaveInterval() {
- return saveInterval;
+ public VcsConfigManager getVcsConfigManager() {
+ return vcsConfigManager;
}
- public void setSaveInterval(int saveInterval) {
- this.saveInterval = saveInterval;
+ public void setVcsConfigManager(VcsConfigManager vcsConfigManager) {
+ this.vcsConfigManager = vcsConfigManager;
}
}
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 e7db515af5..9293500812 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
@@ -23,6 +23,8 @@ import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.DesignerContext;
+import com.fr.design.mainframe.vcs.VcsConfigManager;
+import com.fr.design.mainframe.vcs.common.VcsHelper;
import com.fr.design.update.push.DesignerPushUpdateManager;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.design.widget.FRWidgetFactory;
@@ -139,7 +141,9 @@ public class PreferencePane extends BasicPane {
private UICheckBox vcsEnableCheckBox;
private UICheckBox saveCommitCheckBox;
+ private UICheckBox useIntervalCheckBox;
private IntegerEditor saveIntervalEditor;
+ private UILabel remindVcsLabel;
@@ -205,15 +209,22 @@ public class PreferencePane extends BasicPane {
private void createVcsSettingPane(JPanel generalPane) {
JPanel vcsPane = FRGUIPaneFactory.createVerticalTitledBorderPane(Toolkit.i18nText("Fine-Design_Vcs_Title"));
generalPane.add(vcsPane);
+ remindVcsLabel = new UILabel(Toolkit.i18nText("Fine-Design_Vcs_Remind"));
+ remindVcsLabel.setVisible(!VcsHelper.needInit());
vcsEnableCheckBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Vcs_SaveAuto"));
saveCommitCheckBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Vcs_No_Delete"));
- saveIntervalEditor = new IntegerEditor(30);
- JPanel memorySpace = new JPanel(FRGUIPaneFactory.createLeftZeroLayout());
+ saveIntervalEditor = new IntegerEditor(60);
+ useIntervalCheckBox = new UICheckBox();
+ JPanel enableVcsPanel = new JPanel(FRGUIPaneFactory.createLeftZeroLayout());
+ enableVcsPanel.add(vcsEnableCheckBox);
+ enableVcsPanel.add(remindVcsLabel);
+ JPanel intervalPanel = new JPanel(FRGUIPaneFactory.createLeftZeroLayout());
UILabel everyLabel = new UILabel(Toolkit.i18nText("Fine-Design_Vcs_Every"));
UILabel delayLabel = new UILabel(Toolkit.i18nText("Fine-Design_Vcs_Delay"));
- memorySpace.add(everyLabel);
- memorySpace.add(saveIntervalEditor);
- memorySpace.add(delayLabel);
+ intervalPanel.add(useIntervalCheckBox);
+ intervalPanel.add(everyLabel);
+ intervalPanel.add(saveIntervalEditor);
+ intervalPanel.add(delayLabel);
vcsEnableCheckBox.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
@@ -221,14 +232,16 @@ public class PreferencePane extends BasicPane {
if (selected) {
saveCommitCheckBox.setEnabled(true);
saveIntervalEditor.setEnabled(true);
+ useIntervalCheckBox.setEnabled(true);
} else {
saveCommitCheckBox.setEnabled(false);
saveIntervalEditor.setEnabled(false);
+ useIntervalCheckBox.setEnabled(false);
}
}
});
- vcsPane.add(vcsEnableCheckBox);
- vcsPane.add(memorySpace);
+ vcsPane.add(enableVcsPanel);
+ vcsPane.add(intervalPanel);
vcsPane.add(saveCommitCheckBox);
}
@@ -581,13 +594,22 @@ public class PreferencePane extends BasicPane {
defaultStringToFormulaBox.setEnabled(false);
defaultStringToFormulaBox.setSelected(false);
}
- vcsEnableCheckBox.setSelected(designerEnvManager.isVcsEnable());
+ VcsConfigManager vcsConfigManager = designerEnvManager.getVcsConfigManager();
+ if (VcsHelper.needInit()) {
+ vcsEnableCheckBox.setSelected(vcsConfigManager.isVcsEnable());
+ } else {
+ vcsEnableCheckBox.setEnabled(false);
+ vcsEnableCheckBox.setSelected(false);
+ }
if (!vcsEnableCheckBox.isSelected()) {
- saveIntervalEditor.setEnabled(false);
saveCommitCheckBox.setEnabled(false);
+ saveIntervalEditor.setEnabled(false);
+ useIntervalCheckBox.setEnabled(false);
}
- saveIntervalEditor.setValue(designerEnvManager.getSaveInterval());
- saveCommitCheckBox.setSelected(designerEnvManager.isSaveCommit());
+
+ saveIntervalEditor.setValue(vcsConfigManager.getSaveInterval());
+ saveCommitCheckBox.setSelected(vcsConfigManager.isSaveCommit());
+ useIntervalCheckBox.setSelected(vcsConfigManager.isUseInterval());
supportCellEditorDefCheckBox.setSelected(designerEnvManager.isSupportCellEditorDef());
@@ -677,9 +699,11 @@ public class PreferencePane extends BasicPane {
designerEnvManager.setOracleSystemSpace(this.oracleSpace.isSelected());
designerEnvManager.setCachingTemplateLimit((int) this.cachingTemplateSpinner.getValue());
designerEnvManager.setJoinProductImprove(this.joinProductImproveCheckBox.isSelected());
- designerEnvManager.setSaveInterval(this.saveIntervalEditor.getValue());
- designerEnvManager.setVcsEnable(this.vcsEnableCheckBox.isSelected());
- designerEnvManager.setSaveCommit(this.saveCommitCheckBox.isSelected());
+ VcsConfigManager vcsConfigManager = designerEnvManager.getVcsConfigManager();
+ vcsConfigManager.setSaveInterval(this.saveIntervalEditor.getValue());
+ vcsConfigManager.setVcsEnable(this.vcsEnableCheckBox.isSelected());
+ vcsConfigManager.setSaveCommit(this.saveCommitCheckBox.isSelected());
+ vcsConfigManager.setUseInterval(this.useIntervalCheckBox.isSelected());
if (this.autoPushUpdateCheckBox != null) {
designerEnvManager.setAutoPushUpdateEnabled(this.autoPushUpdateCheckBox.isSelected());
}
diff --git a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java
index 32b9d11401..265e7dfe60 100644
--- a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java
+++ b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java
@@ -197,11 +197,14 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
if (WorkContext.getCurrent().isLocal()) {
toolbarDef.addShortCut(showInExplorerAction);
}
- toolbarDef.addShortCut(renameAction, delFileAction, vcsAction);
+ toolbarDef.addShortCut(renameAction, delFileAction);
Set extraShortCuts = ExtraDesignClassManager.getInstance().getExtraShortCuts();
for (ShortCut shortCut : extraShortCuts) {
toolbarDef.addShortCut(shortCut);
}
+ if (VcsHelper.needInit()) {
+ toolbarDef.addShortCut(vcsAction);
+ }
toolbarDef.updateToolBar(toolBar);
resetActionStatus();
refresh();
@@ -461,7 +464,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
}
private void handleVcsAction() {
- if (!DesignerEnvManager.getEnvManager().isVcsEnable() || VcsHelper.isUnSelectedTemplate()) {
+ if (!DesignerEnvManager.getEnvManager().getVcsConfigManager().isVcsEnable() || VcsHelper.isUnSelectedTemplate()) {
vcsAction.setEnabled(false);
return;
}
diff --git a/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java b/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java
index 9b6a761726..87d0f9d356 100644
--- a/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java
+++ b/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java
@@ -39,6 +39,7 @@ import com.fr.design.mainframe.template.info.TemplateProcessInfo;
import com.fr.design.mainframe.template.info.TimeConsumeTimer;
import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus;
import com.fr.design.mainframe.toolbar.VcsScene;
+import com.fr.design.mainframe.vcs.common.VcsHelper;
import com.fr.design.menu.MenuDef;
import com.fr.design.menu.NameSeparator;
import com.fr.design.menu.ShortCut;
@@ -542,6 +543,9 @@ public abstract class JTemplate>
return false;
}
collectInfo();
+ if (DesignerEnvManager.getEnvManager().getVcsConfigManager().isVcsEnable()) {
+ VcsHelper.dealWithVcs(this);
+ }
return this.saveFile();
}
diff --git a/designer-base/src/main/java/com/fr/design/mainframe/vcs/VcsConfigManager.java b/designer-base/src/main/java/com/fr/design/mainframe/vcs/VcsConfigManager.java
new file mode 100644
index 0000000000..bbb6e9d9b5
--- /dev/null
+++ b/designer-base/src/main/java/com/fr/design/mainframe/vcs/VcsConfigManager.java
@@ -0,0 +1,74 @@
+package com.fr.design.mainframe.vcs;
+
+import com.fr.stable.xml.XMLPrintWriter;
+import com.fr.stable.xml.XMLReadable;
+import com.fr.stable.xml.XMLWriter;
+import com.fr.stable.xml.XMLableReader;
+
+/**
+ * Created by XiaXiang on 2019/4/26.
+ */
+public class VcsConfigManager implements XMLReadable, XMLWriter {
+ public static final String XML_TAG = "VcsConfigManager";
+ private static volatile VcsConfigManager instance = new VcsConfigManager();
+ private boolean vcsEnable;
+ private boolean saveCommit;
+ private boolean useInterval;
+ private int saveInterval;
+
+ public static VcsConfigManager getInstance() {
+ return instance;
+ }
+
+ public boolean isVcsEnable() {
+ return vcsEnable;
+ }
+
+ public void setVcsEnable(boolean vcsEnable) {
+ this.vcsEnable = vcsEnable;
+ }
+
+ public boolean isSaveCommit() {
+ return saveCommit;
+ }
+
+ public void setSaveCommit(boolean saveCommit) {
+ this.saveCommit = saveCommit;
+ }
+
+ public boolean isUseInterval() {
+ return useInterval;
+ }
+
+ public void setUseInterval(boolean useInterval) {
+ this.useInterval = useInterval;
+ }
+
+ public int getSaveInterval() {
+ return saveInterval;
+ }
+
+ public void setSaveInterval(int saveInterval) {
+ this.saveInterval = saveInterval;
+ }
+
+ @Override
+ public void readXML(XMLableReader reader) {
+ if (reader.isAttr()) {
+ this.setSaveCommit(reader.getAttrAsBoolean("saveCommit", true));
+ this.setSaveInterval(reader.getAttrAsInt("saveInterval", 60));
+ this.setUseInterval(reader.getAttrAsBoolean("useInterval", true));
+ this.setVcsEnable(reader.getAttrAsBoolean("vcsEnable", true));
+ }
+ }
+
+ @Override
+ public void writeXML(XMLPrintWriter writer) {
+ writer.startTAG(XML_TAG);
+ writer.attr("saveCommit", this.isSaveCommit());
+ writer.attr("saveInterval", this.getSaveInterval());
+ writer.attr("useInterval", this.isUseInterval());
+ writer.attr("vcsEnable", this.isVcsEnable());
+ writer.end();
+ }
+}
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 ecde0e1331..4fc99731a5 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
@@ -5,12 +5,18 @@ 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.DesignerFrameFileDealerPane;
import com.fr.design.mainframe.JTemplate;
+import com.fr.design.mainframe.vcs.VcsConfigManager;
+import com.fr.design.mainframe.vcs.ui.FileVersionTable;
import com.fr.general.IOUtils;
+import com.fr.plugin.context.PluginContext;
+import com.fr.plugin.manage.PluginManager;
import com.fr.report.entity.VcsEntity;
import com.fr.stable.StringUtils;
import com.fr.stable.project.ProjectConstants;
import com.fr.workspace.WorkContext;
+import com.fr.workspace.server.vcs.VcsOperator;
import javax.swing.Icon;
import javax.swing.border.EmptyBorder;
@@ -27,6 +33,7 @@ public class VcsHelper {
private final static String VCS_DIR = "vcs";
public final static String VCS_CACHE_DIR = pathJoin(VCS_DIR, "cache");
private static final int MINUTE = 60 * 1000;
+ private final static String VCS_PLUGIN_ID = "com.fr.plugin.vcs.v10";
public final static String CURRENT_USERNAME = WorkContext.getCurrent().isLocal()
@@ -92,10 +99,48 @@ public class VcsHelper {
}
public static boolean needDeleteVersion(VcsEntity entity) {
- if (entity == null) {
+ if (entity == null || !DesignerEnvManager.getEnvManager().getVcsConfigManager().isUseInterval()) {
return false;
}
- return new Date().getTime() - entity.getTime().getTime() < DesignerEnvManager.getEnvManager().getSaveInterval() * MINUTE && StringUtils.isBlank(entity.getCommitMsg());
+ return new Date().getTime() - entity.getTime().getTime() < DesignerEnvManager.getEnvManager().getVcsConfigManager().getSaveInterval() * MINUTE && StringUtils.isBlank(entity.getCommitMsg());
+ }
+
+ public static boolean needInit() {
+ PluginContext context = PluginManager.getContext(VCS_PLUGIN_ID);
+ return context == null || !context.isActive();
+ }
+
+ /**
+ * 版本控制
+ * @param jt
+ */
+ public static void dealWithVcs(final JTemplate jt) {
+ new Thread(new Runnable() {
+ @Override
+ public void run() {
+
+ String fileName = VcsHelper.getEditingFilename();
+ VcsOperator operator = WorkContext.getCurrent().get(VcsOperator.class);
+ VcsEntity entity = operator.getFileVersionByIndex(fileName, 0);
+ int latestFileVersion = 0;
+ if (entity != null) {
+ latestFileVersion = entity.getVersion();
+ }
+ if (jt.getEditingFILE() instanceof VcsCacheFileNodeFile) {
+ operator.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 {
+ operator.saveVersion(VcsHelper.CURRENT_USERNAME, fileName, StringUtils.EMPTY, latestFileVersion + 1);
+ }
+ VcsEntity oldEntity = WorkContext.getCurrent().get(VcsOperator.class).getFileVersionByIndex(fileName, 1);
+ if (VcsHelper.needDeleteVersion(oldEntity)) {
+ operator.deleteVersion(oldEntity.getFilename(), oldEntity.getVersion());
+ }
+
+ }
+ }).start();
+
}
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 a2f6c92c76..daf0046d7f 100644
--- a/designer-realize/src/main/java/com/fr/start/Designer.java
+++ b/designer-realize/src/main/java/com/fr/start/Designer.java
@@ -23,7 +23,6 @@ import com.fr.design.gui.imenu.UIPopupMenu;
import com.fr.design.gui.itoolbar.UILargeToolbar;
import com.fr.design.mainframe.ActiveKeyGenerator;
import com.fr.design.mainframe.DesignerContext;
-import com.fr.design.mainframe.DesignerFrameFileDealerPane;
import com.fr.design.mainframe.InformationCollector;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.mainframe.JWorkBook;
@@ -32,8 +31,6 @@ import com.fr.design.mainframe.bbs.UserInfoLabel;
import com.fr.design.mainframe.bbs.UserInfoPane;
import com.fr.design.mainframe.template.info.TemplateInfoCollector;
import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus;
-import com.fr.design.mainframe.vcs.common.VcsCacheFileNodeFile;
-import com.fr.design.mainframe.vcs.ui.FileVersionTable;
import com.fr.design.menu.KeySetUtils;
import com.fr.design.menu.MenuDef;
import com.fr.design.menu.SeparatorDef;
@@ -46,7 +43,6 @@ import com.fr.general.ComparatorUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.module.Module;
import com.fr.module.ModuleContext;
-import com.fr.report.entity.VcsEntity;
import com.fr.runtime.FineRuntime;
import com.fr.stable.BuildContext;
import com.fr.stable.OperatingSystem;
@@ -61,8 +57,6 @@ import com.fr.start.module.StartupArgs;
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.VcsHelper;
import javax.swing.JComponent;
import javax.swing.JOptionPane;
@@ -97,13 +91,17 @@ public class Designer extends BaseDesigner {
private UIButton redo;
private UIPreviewButton run;
+ public Designer(String[] args) {
+ super(args);
+ }
+
/**
* 设计器启动的Main方法
*
* @param args 参数
*/
public static void main(String[] args) {
-
+
//启动运行时
FineRuntime.start();
BuildContext.setBuildFilePath("/com/fr/stable/build.properties");
@@ -169,11 +167,6 @@ public class Designer extends BaseDesigner {
return new SplashFx();
}
- public Designer(String[] args) {
- super(args);
- }
-
-
/**
* 创建新建文件的快捷方式数组。
*
@@ -280,45 +273,11 @@ public class Designer extends BaseDesigner {
jt.stopEditing();
jt.saveTemplate();
jt.requestFocus();
- if (DesignerEnvManager.getEnvManager().isVcsEnable()) {
- dealWithVcs(jt);
- }
}
});
return saveButton;
}
- /**
- * 版本控制
- * @param jt
- */
- private void dealWithVcs(final JTemplate jt) {
- new Thread(new Runnable() {
- @Override
- public void run() {
- String fileName = VcsHelper.getEditingFilename();
- VcsOperator operator = WorkContext.getCurrent().get(VcsOperator.class);
- VcsEntity entity = operator.getFileVersionByIndex(fileName, 0);
- int latestFileVersion = 0;
- if (entity != null) {
- latestFileVersion = entity.getVersion();
- }
- if (jt.getEditingFILE() instanceof VcsCacheFileNodeFile) {
- operator.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 {
- operator.saveVersion(VcsHelper.CURRENT_USERNAME, fileName, StringUtils.EMPTY, latestFileVersion + 1);
- }
- VcsEntity oldEntity = WorkContext.getCurrent().get(VcsOperator.class).getFileVersionByIndex(fileName, 1);
- if (VcsHelper.needDeleteVersion(oldEntity)) {
- operator.deleteVersion(oldEntity.getFilename(), oldEntity.getVersion());
- }
-
- }
- }).start();
-
- }
private UIButton createUndoButton() {
undo = new UIButton(BaseUtils.readIcon("/com/fr/design/images/buttonicon/undo.png"));