From 9f6d40cd901eb95dd058ad75df60636622576217 Mon Sep 17 00:00:00 2001
From: neil <459208047@qq.com>
Date: Mon, 23 Oct 2017 15:34:30 +0800
Subject: [PATCH] =?UTF-8?q?REPORT-5180=20=E6=97=A5=E5=BF=97=E7=BA=A7?=
=?UTF-8?q?=E5=88=AB=E9=85=8D=E7=BD=AE=E6=95=B4=E5=90=88=E5=88=B0=E4=B8=80?=
=?UTF-8?q?=E4=B8=AAxml=E4=B8=AD.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../src/com/fr/design/DesignerEnvManager.java | 42 ++-----------------
.../design/actions/file/PreferencePane.java | 37 ++++++++++++----
.../loghandler/DesignerLogHandler.java | 38 +++++++++++++----
3 files changed, 64 insertions(+), 53 deletions(-)
diff --git a/designer_base/src/com/fr/design/DesignerEnvManager.java b/designer_base/src/com/fr/design/DesignerEnvManager.java
index f43d05bacd..1cd613785a 100644
--- a/designer_base/src/com/fr/design/DesignerEnvManager.java
+++ b/designer_base/src/com/fr/design/DesignerEnvManager.java
@@ -14,7 +14,6 @@ import com.fr.env.RemoteEnv;
import com.fr.env.SignIn;
import com.fr.file.FILEFactory;
import com.fr.general.ComparatorUtils;
-import com.fr.general.FRLevel;
import com.fr.general.FRLogFormatter;
import com.fr.general.FRLogger;
import com.fr.general.GeneralContext;
@@ -34,9 +33,10 @@ import com.fr.stable.xml.XMLTools;
import com.fr.stable.xml.XMLWriter;
import com.fr.stable.xml.XMLableReader;
-import javax.swing.*;
+import javax.swing.SwingWorker;
import javax.swing.SwingWorker.StateValue;
-import java.awt.*;
+import java.awt.Color;
+import java.awt.Rectangle;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileReader;
@@ -53,7 +53,6 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.logging.FileHandler;
import java.util.logging.Handler;
-import java.util.logging.Level;
/**
* The manager of Designer GUI.
@@ -97,7 +96,6 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
private Color paginationLineColor = Color.black; // line color of paper
private boolean supportCellEditorDef = false;
private boolean isDragPermited = false;
- private Level level = Level.INFO;
private int language;
//2014-8-26默认显示全部, 因为以前的版本, 虽然是false, 实际上是显示所有表, 因此这边要兼容
private boolean useOracleSystemSpace = true;
@@ -240,10 +238,6 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
*/
public static void loadLogSetting() {
DesignerEnvManager designerEnvManager = DesignerEnvManager.getEnvManager();
- Level logLevel = designerEnvManager.getLogLevel();
- if (logLevel != null) {
- FRContext.getLogger().setLogLevel(logLevel, true);
- }
if (StringUtils.isNotEmpty(designerEnvManager.getJdkHome())) {
System.setProperty("java.home", designerEnvManager.getJdkHome());
}
@@ -1156,20 +1150,6 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
this.logLocation = logsLocation;
}
- /**
- * 返回日志的等级
- */
- public Level getLogLevel() {
- return this.level;
- }
-
- /**
- * 设置log的等级
- */
- public void setLogLevel(Level level) {
- this.level = level;
- }
-
/**
* 设置撤销的限制次数
*/
@@ -1320,8 +1300,6 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
readActiveKey(reader);
} else if ("LogLocation".equals(name)) {
readLogLocation(reader);
- } else if ("LogLevel".equals(name)) {
- this.readLogLevel(reader);
} else if ("Language".equals(name)) {
readLanguage(reader);
} else if ("JettyServerPort".equals(name)) {
@@ -1516,15 +1494,6 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
checkRecentOpenedFileNum();
}
-
- private void readLogLevel(XMLableReader reader) {
- String level;
- if ((level = reader.getElementValue()) != null) {
- this.setLogLevel(FRLevel.getByName(level).getLevel());
- }
- }
-
-
/**
* Write XML.
* The method will be invoked when save data to XML file.
@@ -1700,11 +1669,6 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
writer.end();
}
- if (this.level != null) {
- writer.startTAG("LogLevel");
- writer.textNode(FRLevel.getByLevel(this.level).getName());
- writer.end();
- }
if (StringUtils.isNotBlank(jdkHome)) {
writer.startTAG("jdkHome");
writer.textNode(jdkHome);
diff --git a/designer_base/src/com/fr/design/actions/file/PreferencePane.java b/designer_base/src/com/fr/design/actions/file/PreferencePane.java
index 51b8c374ae..d32b110d16 100644
--- a/designer_base/src/com/fr/design/actions/file/PreferencePane.java
+++ b/designer_base/src/com/fr/design/actions/file/PreferencePane.java
@@ -1,6 +1,8 @@
package com.fr.design.actions.file;
import com.fr.base.BaseUtils;
+import com.fr.base.ConfigManager;
+import com.fr.base.FRContext;
import com.fr.design.DesignerEnvManager;
import com.fr.design.RestartHelper;
import com.fr.design.dialog.BasicDialog;
@@ -25,9 +27,24 @@ import com.fr.general.FRFont;
import com.fr.general.FRLevel;
import com.fr.general.Inter;
-import javax.swing.*;
-import java.awt.*;
-import java.awt.event.*;
+import javax.swing.JFileChooser;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.KeyStroke;
+import javax.swing.SwingUtilities;
+import java.awt.BorderLayout;
+import java.awt.Component;
+import java.awt.Dimension;
+import java.awt.Font;
+import java.awt.Window;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
+import java.awt.event.KeyAdapter;
+import java.awt.event.KeyEvent;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
import java.io.File;
import java.util.ArrayList;
import java.util.Locale;
@@ -354,7 +371,7 @@ public class PreferencePane extends BasicPane {
logLevelPane.add(logLevelComboBox);
logLevelComboBox.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
- DesignerEnvManager.getEnvManager().setLogLevel(((FRLevel) logLevelComboBox.getSelectedItem()).getLevel());
+ ConfigManager.getProviderInstance().setServerLogLevel(((FRLevel) logLevelComboBox.getSelectedItem()).getLevel());
}
});
}
@@ -534,7 +551,7 @@ public class PreferencePane extends BasicPane {
this.logExportDirectoryField.setText(designerEnvManager.getLogLocation());
- this.logLevelComboBox.setSelectedItem(FRLevel.getByLevel(designerEnvManager.getLogLevel()));
+ this.logLevelComboBox.setSelectedItem(FRLevel.getByLevel(ConfigManager.getProviderInstance().getServerLogLevel()));
this.languageComboBox.setSelectedItem(LANGUAGE.get(designerEnvManager.getLanguage()));
designerEnvLanguageIndex = designerEnvManager.getLanguage();
@@ -578,8 +595,6 @@ public class PreferencePane extends BasicPane {
designerEnvManager.setLogLocation(this.logExportDirectoryField.getText());
- designerEnvManager.setLogLevel(((FRLevel) logLevelComboBox.getSelectedItem()).getLevel());
-
designerEnvManager.setSupportUndo(supportUndoCheckBox.isSelected());
designerEnvManager.setSupportDefaultParentCalculate(supportDefaultParentCalculateCheckBox.isSelected());
@@ -615,6 +630,14 @@ public class PreferencePane extends BasicPane {
if (maxUndoLimit.getSelectedIndex() == SELECTED_INDEX_5) {
designerEnvManager.setUndoLimit(MAX_UNDO_LIMIT_50);
}
+
+ ConfigManager.getProviderInstance().setServerLogLevel(((FRLevel) logLevelComboBox.getSelectedItem()).getLevel());
+ try {
+ FRContext.getCurrentEnv().writeResource(ConfigManager.getProviderInstance());
+ } catch (Exception e) {
+ FRContext.getLogger().error(e.getMessage());
+ }
+
}
/*
diff --git a/designer_base/src/com/fr/design/mainframe/loghandler/DesignerLogHandler.java b/designer_base/src/com/fr/design/mainframe/loghandler/DesignerLogHandler.java
index 740bd4ffe1..9a2aed712f 100644
--- a/designer_base/src/com/fr/design/mainframe/loghandler/DesignerLogHandler.java
+++ b/designer_base/src/com/fr/design/mainframe/loghandler/DesignerLogHandler.java
@@ -1,20 +1,44 @@
package com.fr.design.mainframe.loghandler;
import com.fr.base.BaseUtils;
+import com.fr.base.ConfigManager;
import com.fr.base.FRContext;
-import com.fr.design.DesignerEnvManager;
import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.imenu.UIMenuItem;
import com.fr.design.layout.FRGUIPaneFactory;
-import com.fr.general.*;
+import com.fr.general.ComparatorUtils;
+import com.fr.general.FRLogLevel;
+import com.fr.general.FRLogger;
+import com.fr.general.GeneralContext;
+import com.fr.general.Inter;
import com.fr.log.LogHandler;
import com.fr.stable.EnvChangedListener;
import com.fr.stable.xml.LogRecordTimeProvider;
-import javax.swing.*;
-import javax.swing.text.*;
-import java.awt.*;
-import java.awt.event.*;
+import javax.swing.AbstractAction;
+import javax.swing.ActionMap;
+import javax.swing.InputMap;
+import javax.swing.JCheckBoxMenuItem;
+import javax.swing.JComponent;
+import javax.swing.JPanel;
+import javax.swing.JPopupMenu;
+import javax.swing.JTextPane;
+import javax.swing.KeyStroke;
+import javax.swing.text.BadLocationException;
+import javax.swing.text.DefaultEditorKit;
+import javax.swing.text.Document;
+import javax.swing.text.SimpleAttributeSet;
+import javax.swing.text.StyleConstants;
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
+import java.awt.event.KeyEvent;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.logging.Level;
@@ -105,7 +129,7 @@ public class DesignerLogHandler {
@Override
public void actionPerformed(ActionEvent e) {
JPopupMenu showsetPopup = new JPopupMenu();
- int logLevelvalue = DesignerEnvManager.getEnvManager().getLogLevel().intValue();
+ int logLevelvalue = ConfigManager.getProviderInstance().getServerLogLevel().intValue();
if (logLevelvalue <= INFO_INT) {
showsetPopup.add(showInfo);
showsetPopup.add(showError);