From 471a2852aff5c6141319e3eba053b199ea9136dd Mon Sep 17 00:00:00 2001 From: XiaXiang Date: Fri, 26 Apr 2019 11:06:20 +0800 Subject: [PATCH 1/7] =?UTF-8?q?REPORT-16517=20=E4=BA=A4=E4=BA=92=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/DesignerEnvManager.java | 13 ++++++- .../design/actions/file/PreferencePane.java | 37 +++++++++++++++---- .../DesignerFrameFileDealerPane.java | 5 ++- .../mainframe/vcs/common/VcsHelper.java | 10 ++++- 4 files changed, 54 insertions(+), 11 deletions(-) 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..2c028670e2 100644 --- a/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java +++ b/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java @@ -132,6 +132,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { private String jdkHome; private boolean vcsEnable; private boolean saveCommit; + private boolean useInterval; private int saveInterval; @@ -1608,7 +1609,8 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { 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.setSaveCommit(reader.getAttrAsBoolean("saveCommit", true)); + this.setUseInterval(reader.getAttrAsBoolean("userInterval", true)); this.setSaveInterval(reader.getAttrAsInt("saveInterval", 60)); if ((tmpVal = reader.getAttrAsString("gridLineColor", null)) != null) { this.setGridLineColor(new Color(Integer.parseInt(tmpVal))); @@ -1947,6 +1949,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { .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("gridLineColor", this.getGridLineColor().getRGB()) @@ -1982,4 +1985,12 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { public void setSaveInterval(int saveInterval) { this.saveInterval = saveInterval; } + + public boolean isUseInterval() { + return useInterval; + } + + public void setUseInterval(boolean useInterval) { + this.useInterval = useInterval; + } } 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..da5d381c39 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,7 @@ 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.common.VcsHelper; import com.fr.design.update.push.DesignerPushUpdateManager; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.widget.FRWidgetFactory; @@ -139,7 +140,9 @@ public class PreferencePane extends BasicPane { private UICheckBox vcsEnableCheckBox; private UICheckBox saveCommitCheckBox; + private UICheckBox useIntervalCheckBox; private IntegerEditor saveIntervalEditor; + private UILabel remindVcsLabel; @@ -205,15 +208,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("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()); + 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 +231,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 +593,21 @@ public class PreferencePane extends BasicPane { defaultStringToFormulaBox.setEnabled(false); defaultStringToFormulaBox.setSelected(false); } - vcsEnableCheckBox.setSelected(designerEnvManager.isVcsEnable()); + if (VcsHelper.needInit()) { + vcsEnableCheckBox.setSelected(designerEnvManager.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()); + useIntervalCheckBox.setSelected(designerEnvManager.isUseInterval()); supportCellEditorDefCheckBox.setSelected(designerEnvManager.isSupportCellEditorDef()); @@ -680,6 +700,7 @@ public class PreferencePane extends BasicPane { designerEnvManager.setSaveInterval(this.saveIntervalEditor.getValue()); designerEnvManager.setVcsEnable(this.vcsEnableCheckBox.isSelected()); designerEnvManager.setSaveCommit(this.saveCommitCheckBox.isSelected()); + designerEnvManager.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..87966c6c1e 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(); 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..748d100260 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 @@ -7,6 +7,8 @@ import com.fr.design.gui.itree.filetree.TemplateFileTree; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.JTemplate; 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; @@ -27,6 +29,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,11 +95,16 @@ public class VcsHelper { } public static boolean needDeleteVersion(VcsEntity entity) { - if (entity == null) { + if (entity == null || !DesignerEnvManager.getEnvManager().isUseInterval()) { return false; } return new Date().getTime() - entity.getTime().getTime() < DesignerEnvManager.getEnvManager().getSaveInterval() * MINUTE && StringUtils.isBlank(entity.getCommitMsg()); } + public static boolean needInit() { + PluginContext context = PluginManager.getContext(VCS_PLUGIN_ID); + return context == null || !context.isActive(); + } + } From 1e8eebe86d6bbe693c51857dd739c73b2ecd0602 Mon Sep 17 00:00:00 2001 From: XiaXiang Date: Fri, 26 Apr 2019 12:19:05 +0800 Subject: [PATCH 2/7] =?UTF-8?q?REPORT-16527=20@xiaoxia=20=E9=80=9A?= =?UTF-8?q?=E8=BF=87=E7=9B=B4=E6=8E=A5=E9=A2=84=E8=A7=88=E8=A7=A6=E5=8F=91?= =?UTF-8?q?=E7=9A=84=E6=A8=A1=E7=89=88=E4=BF=9D=E5=AD=98=EF=BC=8C=E8=AF=A5?= =?UTF-8?q?=E6=A8=A1=E7=89=88=E4=B8=8D=E4=BC=9A=E4=BF=9D=E5=AD=98=E6=96=B0?= =?UTF-8?q?=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/mainframe/JTemplate.java | 4 ++ .../mainframe/vcs/common/VcsHelper.java | 35 +++++++++++++ .../src/main/java/com/fr/start/Designer.java | 51 ++----------------- 3 files changed, 44 insertions(+), 46 deletions(-) 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..99273ec5bf 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().isVcsEnable()) { + VcsHelper.dealWithVcs(this); + } return this.saveFile(); } 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 748d100260..ec88800a75 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,7 +5,9 @@ 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.ui.FileVersionTable; import com.fr.general.IOUtils; import com.fr.plugin.context.PluginContext; import com.fr.plugin.manage.PluginManager; @@ -13,6 +15,7 @@ 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; @@ -106,5 +109,37 @@ public class VcsHelper { 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")); From a54b6ce6ef452d46ddca61be503c76bd6b62682e Mon Sep 17 00:00:00 2001 From: plough Date: Fri, 26 Apr 2019 12:27:15 +0800 Subject: [PATCH 3/7] =?UTF-8?q?REPORT-16461=20=E8=AE=BE=E8=AE=A1=E5=99=A8?= =?UTF-8?q?=E4=B8=AD=E5=85=B3=E9=97=AD=E8=87=AA=E5=8A=A8=E6=8E=A8=E9=80=81?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=97=A0=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../push/DesignerPushUpdateManager.java | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/update/push/DesignerPushUpdateManager.java b/designer-base/src/main/java/com/fr/design/update/push/DesignerPushUpdateManager.java index 7ac254c93c..f867d6cfd7 100644 --- a/designer-base/src/main/java/com/fr/design/update/push/DesignerPushUpdateManager.java +++ b/designer-base/src/main/java/com/fr/design/update/push/DesignerPushUpdateManager.java @@ -13,28 +13,29 @@ import com.fr.log.FineLoggerFactory; import com.fr.stable.StringUtils; import com.fr.workspace.WorkContext; -import java.io.IOException; - /** * Created by plough on 2019/4/8. */ public class DesignerPushUpdateManager { private static final String SPLIT_CHAR = "-"; private static DesignerPushUpdateManager singleton; + private static DesignerPushUpdateConfigManager config; + private DesignerUpdateInfo updateInfo; - private DesignerPushUpdateConfigManager config; static { - DesignerContext.getDesignerFrame().addDesignerOpenedListener(new DesignerOpenedListener() { - @Override - public void designerOpened() { - getInstance().checkAndPop(); - } - }); + config = DesignerPushUpdateConfigManager.getInstance(); + if (config.isAutoPushUpdateEnabled()) { + DesignerContext.getDesignerFrame().addDesignerOpenedListener(new DesignerOpenedListener() { + @Override + public void designerOpened() { + getInstance().checkAndPop(); + } + }); + } } private DesignerPushUpdateManager() { - config = DesignerPushUpdateConfigManager.getInstance(); } public static DesignerPushUpdateManager getInstance() { @@ -56,7 +57,7 @@ public class DesignerPushUpdateManager { try { String res = HttpToolbox.get(CloudCenter.getInstance().acquireUrlByKind("jar10.update")); return new JSONObject(res).optString("buildNO"); - } catch (IOException e) { + } catch (Throwable e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); } return StringUtils.EMPTY; From 71025a0b7485681ee778dfb69c41fae4cc964c18 Mon Sep 17 00:00:00 2001 From: plough Date: Fri, 26 Apr 2019 13:39:06 +0800 Subject: [PATCH 4/7] =?UTF-8?q?REPORT-16461=20=E8=AE=BE=E8=AE=A1=E5=99=A8?= =?UTF-8?q?=E4=B8=AD=E5=85=B3=E9=97=AD=E8=87=AA=E5=8A=A8=E6=8E=A8=E9=80=81?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=97=A0=E6=95=88=3D>=E8=B0=83=E6=95=B4?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/update/push/DesignerPushUpdateManager.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/update/push/DesignerPushUpdateManager.java b/designer-base/src/main/java/com/fr/design/update/push/DesignerPushUpdateManager.java index f867d6cfd7..dcb5d45fd2 100644 --- a/designer-base/src/main/java/com/fr/design/update/push/DesignerPushUpdateManager.java +++ b/designer-base/src/main/java/com/fr/design/update/push/DesignerPushUpdateManager.java @@ -19,13 +19,11 @@ import com.fr.workspace.WorkContext; public class DesignerPushUpdateManager { private static final String SPLIT_CHAR = "-"; private static DesignerPushUpdateManager singleton; - private static DesignerPushUpdateConfigManager config; private DesignerUpdateInfo updateInfo; static { - config = DesignerPushUpdateConfigManager.getInstance(); - if (config.isAutoPushUpdateEnabled()) { + if (DesignerPushUpdateConfigManager.getInstance().isAutoPushUpdateEnabled()) { DesignerContext.getDesignerFrame().addDesignerOpenedListener(new DesignerOpenedListener() { @Override public void designerOpened() { @@ -46,7 +44,7 @@ public class DesignerPushUpdateManager { } private void initUpdateInfo(String currentVersion, String latestVersion) { - String lastIgnoredVersion = config.getLastIgnoredVersion(); + String lastIgnoredVersion = DesignerPushUpdateConfigManager.getInstance().getLastIgnoredVersion(); String updatePushInfo = CloudCenter.getInstance().acquireUrlByKind("update.push"); JSONObject pushData = new JSONObject(updatePushInfo); @@ -165,6 +163,6 @@ public class DesignerPushUpdateManager { if (updateInfo == null) { return; } - config.setLastIgnoredVersion(updateInfo.getPushVersion()); + DesignerPushUpdateConfigManager.getInstance().setLastIgnoredVersion(updateInfo.getPushVersion()); } } From ace14386607b3b6043b71c08d8f2f3afed744e76 Mon Sep 17 00:00:00 2001 From: XiaXiang Date: Fri, 26 Apr 2019 13:49:08 +0800 Subject: [PATCH 5/7] =?UTF-8?q?=E5=B0=81=E8=A3=85vcsconfigmanager?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/DesignerEnvManager.java | 55 ++++---------- .../design/actions/file/PreferencePane.java | 21 ++--- .../DesignerFrameFileDealerPane.java | 2 +- .../com/fr/design/mainframe/JTemplate.java | 2 +- .../mainframe/vcs/VcsConfigManager.java | 76 +++++++++++++++++++ .../mainframe/vcs/common/VcsHelper.java | 6 +- 6 files changed, 110 insertions(+), 52 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/design/mainframe/vcs/VcsConfigManager.java 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 2c028670e2..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,12 +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 boolean useInterval; - private int saveInterval; - - //上一次登录弹窗的时间, 为了控制一天只弹一次窗口 private String lastShowBBSTime; @@ -155,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"; @@ -1502,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); } @@ -1608,10 +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", true)); - this.setUseInterval(reader.getAttrAsBoolean("userInterval", true)); - this.setSaveInterval(reader.getAttrAsInt("saveInterval", 60)); if ((tmpVal = reader.getAttrAsString("gridLineColor", null)) != null) { this.setGridLineColor(new Color(Integer.parseInt(tmpVal))); } @@ -1692,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.
@@ -1716,6 +1715,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { writeRecentColor(writer); writeOpenDebug(writer); writeDesignerPushUpdateAttr(writer); + writeVcsAttr(writer); writer.end(); } @@ -1947,10 +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("userInterval", this.isUseInterval()) - .attr("saveCommit", this.isSaveCommit()) .attr("isDragPermited", this.isDragPermited()) .attr("gridLineColor", this.getGridLineColor().getRGB()) .attr("paginationLineColor", this.getPaginationLineColor().getRGB()) @@ -1962,35 +1958,16 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { this.designerPushUpdateConfigManager.writeXML(writer); } - public boolean isVcsEnable() { - return vcsEnable; - } - - public void setVcsEnable(boolean vcsEnable) { - this.vcsEnable = vcsEnable; + private void writeVcsAttr(XMLPrintWriter writer) { + this.vcsConfigManager.writeXML(writer); } - 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() { - return useInterval; + public VcsConfigManager getVcsConfigManager() { + return vcsConfigManager; } - public void setUseInterval(boolean useInterval) { - this.useInterval = useInterval; + 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 da5d381c39..1686613cde 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,7 @@ 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; @@ -209,7 +210,7 @@ public class PreferencePane extends BasicPane { JPanel vcsPane = FRGUIPaneFactory.createVerticalTitledBorderPane(Toolkit.i18nText("Fine-Design_Vcs_Title")); generalPane.add(vcsPane); remindVcsLabel = new UILabel("Fine-Design_Vcs_Remind"); - remindVcsLabel.setVisible(!VcsHelper.needInit()); +// 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); @@ -593,8 +594,9 @@ public class PreferencePane extends BasicPane { defaultStringToFormulaBox.setEnabled(false); defaultStringToFormulaBox.setSelected(false); } + VcsConfigManager vcsConfigManager = designerEnvManager.getVcsConfigManager(); if (VcsHelper.needInit()) { - vcsEnableCheckBox.setSelected(designerEnvManager.isVcsEnable()); + vcsEnableCheckBox.setSelected(vcsConfigManager.isVcsEnable()); } else { vcsEnableCheckBox.setEnabled(false); vcsEnableCheckBox.setSelected(false); @@ -605,9 +607,9 @@ public class PreferencePane extends BasicPane { useIntervalCheckBox.setEnabled(false); } - saveIntervalEditor.setValue(designerEnvManager.getSaveInterval()); - saveCommitCheckBox.setSelected(designerEnvManager.isSaveCommit()); - useIntervalCheckBox.setSelected(designerEnvManager.isUseInterval()); + saveIntervalEditor.setValue(vcsConfigManager.getSaveInterval()); + saveCommitCheckBox.setSelected(vcsConfigManager.isSaveCommit()); + useIntervalCheckBox.setSelected(vcsConfigManager.isUseInterval()); supportCellEditorDefCheckBox.setSelected(designerEnvManager.isSupportCellEditorDef()); @@ -697,10 +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()); - designerEnvManager.setUseInterval(this.useIntervalCheckBox.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 87966c6c1e..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 @@ -464,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 99273ec5bf..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 @@ -543,7 +543,7 @@ public abstract class JTemplate> return false; } collectInfo(); - if (DesignerEnvManager.getEnvManager().isVcsEnable()) { + 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..8c94ac3d42 --- /dev/null +++ b/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(); + } +} 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 ec88800a75..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 @@ -7,6 +7,7 @@ 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; @@ -98,10 +99,10 @@ public class VcsHelper { } public static boolean needDeleteVersion(VcsEntity entity) { - if (entity == null || !DesignerEnvManager.getEnvManager().isUseInterval()) { + 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() { @@ -117,6 +118,7 @@ public class VcsHelper { 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); From 05d747e5c3c78af05f6c495574e6f7778baf21ac Mon Sep 17 00:00:00 2001 From: XiaXiang Date: Fri, 26 Apr 2019 13:52:51 +0800 Subject: [PATCH 6/7] bug fix --- .../java/com/fr/design/actions/file/PreferencePane.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 1686613cde..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 @@ -209,11 +209,11 @@ 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("Fine-Design_Vcs_Remind"); -// remindVcsLabel.setVisible(!VcsHelper.needInit()); + 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); + saveIntervalEditor = new IntegerEditor(60); useIntervalCheckBox = new UICheckBox(); JPanel enableVcsPanel = new JPanel(FRGUIPaneFactory.createLeftZeroLayout()); enableVcsPanel.add(vcsEnableCheckBox); From 10773ba825703c1ded5ab8529d2722a826c198e2 Mon Sep 17 00:00:00 2001 From: XiaXiang Date: Fri, 26 Apr 2019 13:59:55 +0800 Subject: [PATCH 7/7] =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/mainframe/vcs/VcsConfigManager.java | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) 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 index 8c94ac3d42..bbb6e9d9b5 100644 --- 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 @@ -10,14 +10,16 @@ import com.fr.stable.xml.XMLableReader; */ public class VcsConfigManager implements XMLReadable, XMLWriter { public static final String XML_TAG = "VcsConfigManager"; - private static volatile VcsConfigManager instance = new 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; } - private boolean vcsEnable; - public boolean isVcsEnable() { return vcsEnable; } @@ -50,10 +52,6 @@ public class VcsConfigManager implements XMLReadable, XMLWriter { this.saveInterval = saveInterval; } - private boolean saveCommit; - private boolean useInterval; - private int saveInterval; - @Override public void readXML(XMLableReader reader) { if (reader.isAttr()) {