From f6f8e0f936a90de83a764aed970ba17d2e6380e6 Mon Sep 17 00:00:00 2001 From: vito Date: Thu, 26 Sep 2019 14:47:13 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-21295=20=E8=BF=9C=E7=A8=8B=E9=9B=86?= =?UTF-8?q?=E7=BE=A4=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/actions/file/PreferencePane.java | 6 +++--- .../DesignerFrameFileDealerPane.java | 20 ++++++++++++++++--- .../mainframe/vcs/common/VcsHelper.java | 20 +++++++++++-------- 3 files changed, 32 insertions(+), 14 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 27b246188b..6a8132a609 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 @@ -1,6 +1,6 @@ package com.fr.design.actions.file; -import com.fr.cluster.engine.base.FineClusterConfig; +import com.fr.cluster.ClusterBridge; import com.fr.config.Configuration; import com.fr.config.ServerPreferenceConfig; import com.fr.design.DesignerEnvManager; @@ -307,7 +307,7 @@ public class PreferencePane extends BasicPane { }); //集群下禁用 - if (FineClusterConfig.getInstance().isCluster()) { + if (ClusterBridge.isClusterMode()) { gcEnableCheckBox.setEnabled(false); gcButton.setEnabled(false); } @@ -1050,7 +1050,7 @@ public class PreferencePane extends BasicPane { if (size > Math.pow(n, 2)) { return df.format(size / Math.pow(n, 2)) + "MB"; } - return new StringBuilder().append(df.format(size / n)).append("KB").toString(); + return df.format(size / n) + "KB"; } /** 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 ff831160b6..c8f8280a49 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 @@ -2,7 +2,7 @@ package com.fr.design.mainframe; import com.fr.base.BaseUtils; import com.fr.base.vcs.DesignerMode; -import com.fr.cluster.engine.base.FineClusterConfig; +import com.fr.cluster.ClusterBridge; import com.fr.design.DesignModelAdapter; import com.fr.design.DesignerEnvManager; import com.fr.design.ExtraDesignClassManager; @@ -242,6 +242,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt /** * 响应数据集改变 */ + @Override public void fireDSChanged() { fireDSChanged(new HashMap()); @@ -252,6 +253,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt * * @param map 改变名字的数据集 */ + @Override public void fireDSChanged(Map map) { DesignTableDataManager.fireDSChanged(map); @@ -307,7 +309,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt return selectedOperation; } - /* + /** * 新建文件夹 */ private class NewFolderAction extends UpdateAction { @@ -363,7 +365,9 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt * 版本管理可用状态的监控 */ private void fireVcsActionChange() { - if (!DesignerEnvManager.getEnvManager().getVcsConfigManager().isVcsEnable() || VcsHelper.getInstance().isUnSelectedTemplate() || FineClusterConfig.getInstance().isCluster()) { + if (!DesignerEnvManager.getEnvManager().getVcsConfigManager().isVcsEnable() + || VcsHelper.getInstance().isUnSelectedTemplate() + || ClusterBridge.isClusterMode()) { setEnabled(false); return; } @@ -549,14 +553,17 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt nameField = new UITextField(oldName); nameField.getDocument().addDocumentListener(new DocumentListener() { + @Override public void changedUpdate(DocumentEvent e) { validInput(); } + @Override public void insertUpdate(DocumentEvent e) { validInput(); } + @Override public void removeUpdate(DocumentEvent e) { validInput(); } @@ -597,6 +604,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt confirmButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Confirm")); confirmButton.setPreferredSize(new Dimension(60, 25)); confirmButton.addActionListener(new ActionListener() { + @Override public void actionPerformed(ActionEvent e) { confirmClose(); } @@ -608,6 +616,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt cancelButton.addActionListener(new ActionListener() { + @Override public void actionPerformed(ActionEvent e) { dispose(); } @@ -764,14 +773,17 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt nameField = new UITextField(); nameField.getDocument().addDocumentListener(new DocumentListener() { + @Override public void changedUpdate(DocumentEvent e) { validInput(); } + @Override public void insertUpdate(DocumentEvent e) { validInput(); } + @Override public void removeUpdate(DocumentEvent e) { validInput(); } @@ -812,6 +824,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt confirmButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Confirm")); confirmButton.setPreferredSize(new Dimension(60, 25)); confirmButton.addActionListener(new ActionListener() { + @Override public void actionPerformed(ActionEvent e) { confirmClose(); } @@ -824,6 +837,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt cancelButton.addActionListener(new ActionListener() { + @Override public void actionPerformed(ActionEvent e) { dispose(); } 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 4f447eaef0..f4089e982f 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 @@ -1,6 +1,7 @@ package com.fr.design.mainframe.vcs.common; -import com.fr.cluster.engine.base.FineClusterConfig; +import com.fr.cluster.ClusterBridge; +import com.fr.concurrent.NamedThreadFactory; import com.fr.design.DesignerEnvManager; import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.file.TemplateTreePane; @@ -49,10 +50,10 @@ public class VcsHelper implements JTemplateActionListener { public final static int OFFSET = 2; private static final int MINUTE = 60 * 1000; private final static String VCS_PLUGIN_ID = "com.fr.plugin.vcs.v10"; - private static final VcsHelper instance = new VcsHelper(); + private static final VcsHelper INSTANCE = new VcsHelper(); public static VcsHelper getInstance() { - return instance; + return INSTANCE; } private int containsFolderCounts() { @@ -111,7 +112,7 @@ public class VcsHelper implements JTemplateActionListener { if (configManager.isSaveCommit() && StringUtils.isNotBlank(entity.getCommitMsg())) { return false; } - return new Date().getTime() - entity.getTime().getTime() < DesignerEnvManager.getEnvManager().getVcsConfigManager().getSaveInterval() * MINUTE; + return System.currentTimeMillis() - entity.getTime().getTime() < DesignerEnvManager.getEnvManager().getVcsConfigManager().getSaveInterval() * MINUTE; } public boolean needInit() { @@ -125,7 +126,8 @@ public class VcsHelper implements JTemplateActionListener { * @param jt */ public void fireVcs(final JTemplate jt) { - new Thread(new Runnable() { + ExecutorService fireVcs = Executors.newSingleThreadExecutor(new NamedThreadFactory("fireVcs")); + fireVcs.execute(new Runnable() { @Override public void run() { @@ -152,8 +154,8 @@ public class VcsHelper implements JTemplateActionListener { } } - }).start(); - + }); + fireVcs.shutdown(); } @@ -169,7 +171,9 @@ public class VcsHelper implements JTemplateActionListener { */ @Override public void templateSaved(JTemplate jt) { - if (needInit() && DesignerEnvManager.getEnvManager().getVcsConfigManager().isVcsEnable() && !FineClusterConfig.getInstance().isCluster()) { + if (needInit() + && DesignerEnvManager.getEnvManager().getVcsConfigManager().isVcsEnable() + && !ClusterBridge.isClusterMode()) { fireVcs(jt); } }