Browse Source

Merge pull request #844 in DESIGN/design from ~XIAOXIA/design:feature/10.0 to feature/10.0

* commit '10773ba825703c1ded5ab8529d2722a826c198e2':
  格式化
  bug fix
  封装vcsconfigmanager
  REPORT-16527 @xiaoxia 通过直接预览触发的模版保存,该模版不会保存新版本
  REPORT-16517 交互修改
research/10.0
xiaoxia 6 years ago
parent
commit
dd60d8f006
  1. 44
      designer-base/src/main/java/com/fr/design/DesignerEnvManager.java
  2. 52
      designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java
  3. 7
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java
  4. 4
      designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java
  5. 74
      designer-base/src/main/java/com/fr/design/mainframe/vcs/VcsConfigManager.java
  6. 49
      designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsHelper.java
  7. 49
      designer-realize/src/main/java/com/fr/start/Designer.java

44
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.LocalDesignerWorkspaceInfo;
import com.fr.design.env.RemoteDesignerWorkspaceInfo; import com.fr.design.env.RemoteDesignerWorkspaceInfo;
import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.mainframe.vcs.VcsConfigManager;
import com.fr.design.update.push.DesignerPushUpdateConfigManager; import com.fr.design.update.push.DesignerPushUpdateConfigManager;
import com.fr.design.style.color.ColorSelectConfigManager; import com.fr.design.style.color.ColorSelectConfigManager;
import com.fr.design.utils.DesignUtils; import com.fr.design.utils.DesignUtils;
@ -130,11 +131,6 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
private int westRegionContainerWidth = 240; private int westRegionContainerWidth = 240;
private String encryptionKey; private String encryptionKey;
private String jdkHome; private String jdkHome;
private boolean vcsEnable;
private boolean saveCommit;
private int saveInterval;
//上一次登录弹窗的时间, 为了控制一天只弹一次窗口 //上一次登录弹窗的时间, 为了控制一天只弹一次窗口
private String lastShowBBSTime; private String lastShowBBSTime;
@ -154,6 +150,8 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
private DesignerPushUpdateConfigManager designerPushUpdateConfigManager = DesignerPushUpdateConfigManager.getInstance(); private DesignerPushUpdateConfigManager designerPushUpdateConfigManager = DesignerPushUpdateConfigManager.getInstance();
private VcsConfigManager vcsConfigManager = VcsConfigManager.getInstance();
public static final String CAS_CERTIFICATE_PATH = "certificatePath"; public static final String CAS_CERTIFICATE_PATH = "certificatePath";
public static final String CAS_CERTIFICATE_PASSWORD = "certificatePass"; public static final String CAS_CERTIFICATE_PASSWORD = "certificatePass";
@ -1501,6 +1499,8 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
readOpenDebug(reader); readOpenDebug(reader);
} else if (name.equals(DesignerPushUpdateConfigManager.XML_TAG)) { } else if (name.equals(DesignerPushUpdateConfigManager.XML_TAG)) {
readDesignerPushUpdateAttr(reader); readDesignerPushUpdateAttr(reader);
} else if (name.equals(vcsConfigManager.XML_TAG)) {
readVcsAttr(reader);
} else { } else {
readLayout(reader, name); readLayout(reader, name);
} }
@ -1607,9 +1607,6 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
this.setDragPermited(reader.getAttrAsBoolean("isDragPermited", false)); this.setDragPermited(reader.getAttrAsBoolean("isDragPermited", false));
this.setUndoLimit(reader.getAttrAsInt("undoLimit", 5)); this.setUndoLimit(reader.getAttrAsInt("undoLimit", 5));
this.setDefaultStringToFormula(reader.getAttrAsBoolean("defaultStringToFormula", false)); 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) { if ((tmpVal = reader.getAttrAsString("gridLineColor", null)) != null) {
this.setGridLineColor(new Color(Integer.parseInt(tmpVal))); this.setGridLineColor(new Color(Integer.parseInt(tmpVal)));
} }
@ -1690,6 +1687,10 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
reader.readXMLObject(designerPushUpdateConfigManager); reader.readXMLObject(designerPushUpdateConfigManager);
} }
private void readVcsAttr(XMLableReader reader) {
reader.readXMLObject(vcsConfigManager);
}
/** /**
* Write XML.<br> * Write XML.<br>
* The method will be invoked when save data to XML file.<br> * The method will be invoked when save data to XML file.<br>
@ -1714,6 +1715,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
writeRecentColor(writer); writeRecentColor(writer);
writeOpenDebug(writer); writeOpenDebug(writer);
writeDesignerPushUpdateAttr(writer); writeDesignerPushUpdateAttr(writer);
writeVcsAttr(writer);
writer.end(); writer.end();
} }
@ -1945,9 +1947,6 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
.attr("verticalScrollBarVisible", this.isVerticalScrollBarVisible()) .attr("verticalScrollBarVisible", this.isVerticalScrollBarVisible())
.attr("horizontalScrollBarVisible", this.isHorizontalScrollBarVisible()) .attr("horizontalScrollBarVisible", this.isHorizontalScrollBarVisible())
.attr("supportCellEditorDef", this.isSupportCellEditorDef()) .attr("supportCellEditorDef", this.isSupportCellEditorDef())
.attr("supportVcs", this.isVcsEnable())
.attr("saveInterval", this.getSaveInterval())
.attr("saveCommit", this.isSaveCommit())
.attr("isDragPermited", this.isDragPermited()) .attr("isDragPermited", this.isDragPermited())
.attr("gridLineColor", this.getGridLineColor().getRGB()) .attr("gridLineColor", this.getGridLineColor().getRGB())
.attr("paginationLineColor", this.getPaginationLineColor().getRGB()) .attr("paginationLineColor", this.getPaginationLineColor().getRGB())
@ -1959,27 +1958,16 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
this.designerPushUpdateConfigManager.writeXML(writer); this.designerPushUpdateConfigManager.writeXML(writer);
} }
public boolean isVcsEnable() { private void writeVcsAttr(XMLPrintWriter writer) {
return vcsEnable; 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() { public VcsConfigManager getVcsConfigManager() {
return saveInterval; return vcsConfigManager;
} }
public void setSaveInterval(int saveInterval) { public void setVcsConfigManager(VcsConfigManager vcsConfigManager) {
this.saveInterval = saveInterval; this.vcsConfigManager = vcsConfigManager;
} }
} }

52
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.TableLayout;
import com.fr.design.layout.TableLayoutHelper; import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.DesignerContext; 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.update.push.DesignerPushUpdateManager;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.design.widget.FRWidgetFactory; import com.fr.design.widget.FRWidgetFactory;
@ -139,7 +141,9 @@ public class PreferencePane extends BasicPane {
private UICheckBox vcsEnableCheckBox; private UICheckBox vcsEnableCheckBox;
private UICheckBox saveCommitCheckBox; private UICheckBox saveCommitCheckBox;
private UICheckBox useIntervalCheckBox;
private IntegerEditor saveIntervalEditor; private IntegerEditor saveIntervalEditor;
private UILabel remindVcsLabel;
@ -205,15 +209,22 @@ public class PreferencePane extends BasicPane {
private void createVcsSettingPane(JPanel generalPane) { private void createVcsSettingPane(JPanel generalPane) {
JPanel vcsPane = FRGUIPaneFactory.createVerticalTitledBorderPane(Toolkit.i18nText("Fine-Design_Vcs_Title")); JPanel vcsPane = FRGUIPaneFactory.createVerticalTitledBorderPane(Toolkit.i18nText("Fine-Design_Vcs_Title"));
generalPane.add(vcsPane); 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")); vcsEnableCheckBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Vcs_SaveAuto"));
saveCommitCheckBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Vcs_No_Delete")); saveCommitCheckBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Vcs_No_Delete"));
saveIntervalEditor = new IntegerEditor(30); saveIntervalEditor = new IntegerEditor(60);
JPanel memorySpace = new JPanel(FRGUIPaneFactory.createLeftZeroLayout()); 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 everyLabel = new UILabel(Toolkit.i18nText("Fine-Design_Vcs_Every"));
UILabel delayLabel = new UILabel(Toolkit.i18nText("Fine-Design_Vcs_Delay")); UILabel delayLabel = new UILabel(Toolkit.i18nText("Fine-Design_Vcs_Delay"));
memorySpace.add(everyLabel); intervalPanel.add(useIntervalCheckBox);
memorySpace.add(saveIntervalEditor); intervalPanel.add(everyLabel);
memorySpace.add(delayLabel); intervalPanel.add(saveIntervalEditor);
intervalPanel.add(delayLabel);
vcsEnableCheckBox.addChangeListener(new ChangeListener() { vcsEnableCheckBox.addChangeListener(new ChangeListener() {
@Override @Override
public void stateChanged(ChangeEvent e) { public void stateChanged(ChangeEvent e) {
@ -221,14 +232,16 @@ public class PreferencePane extends BasicPane {
if (selected) { if (selected) {
saveCommitCheckBox.setEnabled(true); saveCommitCheckBox.setEnabled(true);
saveIntervalEditor.setEnabled(true); saveIntervalEditor.setEnabled(true);
useIntervalCheckBox.setEnabled(true);
} else { } else {
saveCommitCheckBox.setEnabled(false); saveCommitCheckBox.setEnabled(false);
saveIntervalEditor.setEnabled(false); saveIntervalEditor.setEnabled(false);
useIntervalCheckBox.setEnabled(false);
} }
} }
}); });
vcsPane.add(vcsEnableCheckBox); vcsPane.add(enableVcsPanel);
vcsPane.add(memorySpace); vcsPane.add(intervalPanel);
vcsPane.add(saveCommitCheckBox); vcsPane.add(saveCommitCheckBox);
} }
@ -581,13 +594,22 @@ public class PreferencePane extends BasicPane {
defaultStringToFormulaBox.setEnabled(false); defaultStringToFormulaBox.setEnabled(false);
defaultStringToFormulaBox.setSelected(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()) { if (!vcsEnableCheckBox.isSelected()) {
saveIntervalEditor.setEnabled(false);
saveCommitCheckBox.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()); supportCellEditorDefCheckBox.setSelected(designerEnvManager.isSupportCellEditorDef());
@ -677,9 +699,11 @@ public class PreferencePane extends BasicPane {
designerEnvManager.setOracleSystemSpace(this.oracleSpace.isSelected()); designerEnvManager.setOracleSystemSpace(this.oracleSpace.isSelected());
designerEnvManager.setCachingTemplateLimit((int) this.cachingTemplateSpinner.getValue()); designerEnvManager.setCachingTemplateLimit((int) this.cachingTemplateSpinner.getValue());
designerEnvManager.setJoinProductImprove(this.joinProductImproveCheckBox.isSelected()); designerEnvManager.setJoinProductImprove(this.joinProductImproveCheckBox.isSelected());
designerEnvManager.setSaveInterval(this.saveIntervalEditor.getValue()); VcsConfigManager vcsConfigManager = designerEnvManager.getVcsConfigManager();
designerEnvManager.setVcsEnable(this.vcsEnableCheckBox.isSelected()); vcsConfigManager.setSaveInterval(this.saveIntervalEditor.getValue());
designerEnvManager.setSaveCommit(this.saveCommitCheckBox.isSelected()); vcsConfigManager.setVcsEnable(this.vcsEnableCheckBox.isSelected());
vcsConfigManager.setSaveCommit(this.saveCommitCheckBox.isSelected());
vcsConfigManager.setUseInterval(this.useIntervalCheckBox.isSelected());
if (this.autoPushUpdateCheckBox != null) { if (this.autoPushUpdateCheckBox != null) {
designerEnvManager.setAutoPushUpdateEnabled(this.autoPushUpdateCheckBox.isSelected()); designerEnvManager.setAutoPushUpdateEnabled(this.autoPushUpdateCheckBox.isSelected());
} }

7
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()) { if (WorkContext.getCurrent().isLocal()) {
toolbarDef.addShortCut(showInExplorerAction); toolbarDef.addShortCut(showInExplorerAction);
} }
toolbarDef.addShortCut(renameAction, delFileAction, vcsAction); toolbarDef.addShortCut(renameAction, delFileAction);
Set<ShortCut> extraShortCuts = ExtraDesignClassManager.getInstance().getExtraShortCuts(); Set<ShortCut> extraShortCuts = ExtraDesignClassManager.getInstance().getExtraShortCuts();
for (ShortCut shortCut : extraShortCuts) { for (ShortCut shortCut : extraShortCuts) {
toolbarDef.addShortCut(shortCut); toolbarDef.addShortCut(shortCut);
} }
if (VcsHelper.needInit()) {
toolbarDef.addShortCut(vcsAction);
}
toolbarDef.updateToolBar(toolBar); toolbarDef.updateToolBar(toolBar);
resetActionStatus(); resetActionStatus();
refresh(); refresh();
@ -461,7 +464,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
} }
private void handleVcsAction() { private void handleVcsAction() {
if (!DesignerEnvManager.getEnvManager().isVcsEnable() || VcsHelper.isUnSelectedTemplate()) { if (!DesignerEnvManager.getEnvManager().getVcsConfigManager().isVcsEnable() || VcsHelper.isUnSelectedTemplate()) {
vcsAction.setEnabled(false); vcsAction.setEnabled(false);
return; return;
} }

4
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.template.info.TimeConsumeTimer;
import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus; import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus;
import com.fr.design.mainframe.toolbar.VcsScene; 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.MenuDef;
import com.fr.design.menu.NameSeparator; import com.fr.design.menu.NameSeparator;
import com.fr.design.menu.ShortCut; import com.fr.design.menu.ShortCut;
@ -542,6 +543,9 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
return false; return false;
} }
collectInfo(); collectInfo();
if (DesignerEnvManager.getEnvManager().getVcsConfigManager().isVcsEnable()) {
VcsHelper.dealWithVcs(this);
}
return this.saveFile(); return this.saveFile();
} }

74
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();
}
}

49
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.file.TemplateTreePane;
import com.fr.design.gui.itree.filetree.TemplateFileTree; import com.fr.design.gui.itree.filetree.TemplateFileTree;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerFrameFileDealerPane;
import com.fr.design.mainframe.JTemplate; 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.general.IOUtils;
import com.fr.plugin.context.PluginContext;
import com.fr.plugin.manage.PluginManager;
import com.fr.report.entity.VcsEntity; 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.server.vcs.VcsOperator;
import javax.swing.Icon; import javax.swing.Icon;
import javax.swing.border.EmptyBorder; import javax.swing.border.EmptyBorder;
@ -27,6 +33,7 @@ public class VcsHelper {
private final static String VCS_DIR = "vcs"; private final static String VCS_DIR = "vcs";
public final static String VCS_CACHE_DIR = pathJoin(VCS_DIR, "cache"); public final static String VCS_CACHE_DIR = pathJoin(VCS_DIR, "cache");
private static final int MINUTE = 60 * 1000; 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() public final static String CURRENT_USERNAME = WorkContext.getCurrent().isLocal()
@ -92,10 +99,48 @@ public class VcsHelper {
} }
public static boolean needDeleteVersion(VcsEntity entity) { public static boolean needDeleteVersion(VcsEntity entity) {
if (entity == null) { if (entity == null || !DesignerEnvManager.getEnvManager().getVcsConfigManager().isUseInterval()) {
return false; 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();
} }

49
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.gui.itoolbar.UILargeToolbar;
import com.fr.design.mainframe.ActiveKeyGenerator; import com.fr.design.mainframe.ActiveKeyGenerator;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.DesignerFrameFileDealerPane;
import com.fr.design.mainframe.InformationCollector; import com.fr.design.mainframe.InformationCollector;
import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.JTemplate;
import com.fr.design.mainframe.JWorkBook; 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.bbs.UserInfoPane;
import com.fr.design.mainframe.template.info.TemplateInfoCollector; import com.fr.design.mainframe.template.info.TemplateInfoCollector;
import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus; 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.KeySetUtils;
import com.fr.design.menu.MenuDef; import com.fr.design.menu.MenuDef;
import com.fr.design.menu.SeparatorDef; import com.fr.design.menu.SeparatorDef;
@ -46,7 +43,6 @@ import com.fr.general.ComparatorUtils;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.module.Module; import com.fr.module.Module;
import com.fr.module.ModuleContext; import com.fr.module.ModuleContext;
import com.fr.report.entity.VcsEntity;
import com.fr.runtime.FineRuntime; import com.fr.runtime.FineRuntime;
import com.fr.stable.BuildContext; import com.fr.stable.BuildContext;
import com.fr.stable.OperatingSystem; 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.preload.ImagePreLoader;
import com.fr.start.server.ServerTray; import com.fr.start.server.ServerTray;
import com.fr.workspace.WorkContext; 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.JComponent;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
@ -97,6 +91,10 @@ public class Designer extends BaseDesigner {
private UIButton redo; private UIButton redo;
private UIPreviewButton run; private UIPreviewButton run;
public Designer(String[] args) {
super(args);
}
/** /**
* 设计器启动的Main方法 * 设计器启动的Main方法
* *
@ -169,11 +167,6 @@ public class Designer extends BaseDesigner {
return new SplashFx(); return new SplashFx();
} }
public Designer(String[] args) {
super(args);
}
/** /**
* 创建新建文件的快捷方式数组 * 创建新建文件的快捷方式数组
* *
@ -280,45 +273,11 @@ public class Designer extends BaseDesigner {
jt.stopEditing(); jt.stopEditing();
jt.saveTemplate(); jt.saveTemplate();
jt.requestFocus(); jt.requestFocus();
if (DesignerEnvManager.getEnvManager().isVcsEnable()) {
dealWithVcs(jt);
}
} }
}); });
return saveButton; 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() { private UIButton createUndoButton() {
undo = new UIButton(BaseUtils.readIcon("/com/fr/design/images/buttonicon/undo.png")); undo = new UIButton(BaseUtils.readIcon("/com/fr/design/images/buttonicon/undo.png"));

Loading…
Cancel
Save