Browse Source

封装vcsconfigmanager

research/10.0
XiaXiang 6 years ago
parent
commit
ace1438660
  1. 55
      designer-base/src/main/java/com/fr/design/DesignerEnvManager.java
  2. 21
      designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java
  3. 2
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java
  4. 2
      designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java
  5. 76
      designer-base/src/main/java/com/fr/design/mainframe/vcs/VcsConfigManager.java
  6. 6
      designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsHelper.java

55
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,12 +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 boolean useInterval;
private int saveInterval;
//上一次登录弹窗的时间, 为了控制一天只弹一次窗口 //上一次登录弹窗的时间, 为了控制一天只弹一次窗口
private String lastShowBBSTime; private String lastShowBBSTime;
@ -155,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";
@ -1502,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);
} }
@ -1608,10 +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", true));
this.setUseInterval(reader.getAttrAsBoolean("userInterval", true));
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)));
} }
@ -1692,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>
@ -1716,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();
} }
@ -1947,10 +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("userInterval", this.isUseInterval())
.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())
@ -1962,35 +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() {
return saveInterval;
}
public void setSaveInterval(int saveInterval) {
this.saveInterval = saveInterval;
}
public boolean isUseInterval() { public VcsConfigManager getVcsConfigManager() {
return useInterval; return vcsConfigManager;
} }
public void setUseInterval(boolean useInterval) { public void setVcsConfigManager(VcsConfigManager vcsConfigManager) {
this.useInterval = useInterval; this.vcsConfigManager = vcsConfigManager;
} }
} }

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

@ -23,6 +23,7 @@ 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.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;
@ -209,7 +210,7 @@ public class PreferencePane extends BasicPane {
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("Fine-Design_Vcs_Remind"); remindVcsLabel = new UILabel("Fine-Design_Vcs_Remind");
remindVcsLabel.setVisible(!VcsHelper.needInit()); // 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(30);
@ -593,8 +594,9 @@ public class PreferencePane extends BasicPane {
defaultStringToFormulaBox.setEnabled(false); defaultStringToFormulaBox.setEnabled(false);
defaultStringToFormulaBox.setSelected(false); defaultStringToFormulaBox.setSelected(false);
} }
VcsConfigManager vcsConfigManager = designerEnvManager.getVcsConfigManager();
if (VcsHelper.needInit()) { if (VcsHelper.needInit()) {
vcsEnableCheckBox.setSelected(designerEnvManager.isVcsEnable()); vcsEnableCheckBox.setSelected(vcsConfigManager.isVcsEnable());
} else { } else {
vcsEnableCheckBox.setEnabled(false); vcsEnableCheckBox.setEnabled(false);
vcsEnableCheckBox.setSelected(false); vcsEnableCheckBox.setSelected(false);
@ -605,9 +607,9 @@ public class PreferencePane extends BasicPane {
useIntervalCheckBox.setEnabled(false); useIntervalCheckBox.setEnabled(false);
} }
saveIntervalEditor.setValue(designerEnvManager.getSaveInterval()); saveIntervalEditor.setValue(vcsConfigManager.getSaveInterval());
saveCommitCheckBox.setSelected(designerEnvManager.isSaveCommit()); saveCommitCheckBox.setSelected(vcsConfigManager.isSaveCommit());
useIntervalCheckBox.setSelected(designerEnvManager.isUseInterval()); useIntervalCheckBox.setSelected(vcsConfigManager.isUseInterval());
supportCellEditorDefCheckBox.setSelected(designerEnvManager.isSupportCellEditorDef()); supportCellEditorDefCheckBox.setSelected(designerEnvManager.isSupportCellEditorDef());
@ -697,10 +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());
designerEnvManager.setUseInterval(this.useIntervalCheckBox.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());
} }

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

@ -464,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;
} }

2
designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java

@ -543,7 +543,7 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
return false; return false;
} }
collectInfo(); collectInfo();
if (DesignerEnvManager.getEnvManager().isVcsEnable()) { if (DesignerEnvManager.getEnvManager().getVcsConfigManager().isVcsEnable()) {
VcsHelper.dealWithVcs(this); VcsHelper.dealWithVcs(this);
} }
return this.saveFile(); return this.saveFile();

76
designer-base/src/main/java/com/fr/design/mainframe/vcs/VcsConfigManager.java

@ -0,0 +1,76 @@
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();
public static VcsConfigManager getInstance() {
return instance;
}
private boolean vcsEnable;
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;
}
private boolean saveCommit;
private boolean useInterval;
private int 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();
}
}

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

@ -7,6 +7,7 @@ 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.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.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.context.PluginContext;
@ -98,10 +99,10 @@ public class VcsHelper {
} }
public static boolean needDeleteVersion(VcsEntity entity) { public static boolean needDeleteVersion(VcsEntity entity) {
if (entity == null || !DesignerEnvManager.getEnvManager().isUseInterval()) { 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() { public static boolean needInit() {
@ -117,6 +118,7 @@ public class VcsHelper {
new Thread(new Runnable() { new Thread(new Runnable() {
@Override @Override
public void run() { public void run() {
String fileName = VcsHelper.getEditingFilename(); String fileName = VcsHelper.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);

Loading…
Cancel
Save