You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by ps...@apache.org on 2003/12/01 02:57:31 UTC
cvs commit: jakarta-log4j/src/java/org/apache/log4j/chainsaw LogUI.java LogPanel.java LogPanelPreferenceModel.java
psmith 2003/11/30 17:57:31
Modified: src/java/org/apache/log4j/chainsaw LogUI.java LogPanel.java
LogPanelPreferenceModel.java
Log:
All Preferences for a LogPanel (those that are encapsulate in
the LogPanelPreferenceModel class at any rate) are now remembered
between application sessions.
Currently this relies on the object being serialized, and
the column widths are stored in a separate file at the moment.
Soon to be combined into a single permanent storage item/file.
Each LogPanel is now registered with the SettingsManager and
is notified when to save it's settings.
Revision Changes Path
1.42 +1 -10 jakarta-log4j/src/java/org/apache/log4j/chainsaw/LogUI.java
Index: LogUI.java
===================================================================
RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/chainsaw/LogUI.java,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -r1.41 -r1.42
--- LogUI.java 20 Nov 2003 22:11:19 -0000 1.41
+++ LogUI.java 1 Dec 2003 01:57:31 -0000 1.42
@@ -879,16 +879,6 @@
// TODO Ask the user if they want to save the settings via a dialog.
getSettingsManager().saveSettings();
- int tabCount = getTabbedPane().getTabCount();
-
- for (int i = 0; i < tabCount; i++) {
- Component c = getTabbedPane().getComponentAt(i);
-
- if (c instanceof LogPanel) {
- ((LogPanel) c).saveSettings();
- }
- }
-
shutdown();
}
@@ -1372,6 +1362,7 @@
getTabbedPane().add(ident, thisPanel);
getPanelMap().put(ident, thisPanel);
+ getSettingsManager().addSettingsListener(thisPanel);
getSettingsManager().configure(thisPanel);
/**
1.26 +64 -12 jakarta-log4j/src/java/org/apache/log4j/chainsaw/LogPanel.java
Index: LogPanel.java
===================================================================
RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/chainsaw/LogPanel.java,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- LogPanel.java 20 Nov 2003 22:09:40 -0000 1.25
+++ LogPanel.java 1 Dec 2003 01:57:31 -0000 1.26
@@ -1658,30 +1658,50 @@
!getPreferenceModel().isLogTreePanelVisible());
}
- public void saveSettings() {
- saveColumnSettings(identifier, table.getColumnModel());
-
- // colorDisplaySelector.save();
- // TODO save display rule settings
- // displayFilter.save();
- }
-
public void saveSettings(SaveSettingsEvent event) {
- //not used..save of columns performed via tablecolumnmodellistener event callback
+ ObjectOutputStream o = null;
+
+ try {
+ File f =
+ new File(
+ SettingsManager.getInstance().getSettingsDirectory()
+ + File.separator + getIdentifier()+ ".prefs");
+ o = new ObjectOutputStream(
+ new BufferedOutputStream(new FileOutputStream(f)));
+
+ o.writeObject(getPreferenceModel());
+ }
+ catch(IOException e)
+ {
+ LogLog.error("Error ocurred saving the Preferences",e);
+ }finally
+ {
+ if(o!=null)
+ {
+ try
+ {
+ o.close();
+ }
+ catch (Exception e)
+ {
+ }
+ }
+ }
+ saveColumnSettings();
}
- void saveColumnSettings(String ident, TableColumnModel model) {
+ void saveColumnSettings() {
ObjectOutputStream o = null;
try {
File f =
new File(
SettingsManager.getInstance().getSettingsDirectory()
- + File.separator + ident + LogUI.COLUMNS_EXTENSION);
+ + File.separator + getIdentifier() + LogUI.COLUMNS_EXTENSION);
o = new ObjectOutputStream(
new BufferedOutputStream(new FileOutputStream(f)));
- Enumeration e = model.getColumns();
+ Enumeration e = this.table.getColumnModel().getColumns();
while (e.hasMoreElements()) {
TableColumn c = (TableColumn) e.nextElement();
@@ -1717,6 +1737,38 @@
* @see org.apache.log4j.chainsaw.prefs.Profileable#loadSettings(org.apache.log4j.chainsaw.prefs.LoadSettingsEvent)
*/
public void loadSettings(LoadSettingsEvent event) {
+ ObjectInputStream o = null;
+
+ try {
+ File f =
+ new File(
+ SettingsManager.getInstance().getSettingsDirectory()
+ + File.separator + getIdentifier()+ ".prefs");
+ o = new ObjectInputStream(
+ new BufferedInputStream(new FileInputStream(f)));
+
+ LogPanelPreferenceModel model = (LogPanelPreferenceModel) o.readObject();
+ getPreferenceModel().apply(model);
+ }
+ catch(Exception e)
+ {
+ LogLog.error("Error ocurred loading the Preferences for ident '" + getIdentifier() + "'",e);
+ }finally
+ {
+ if(o!=null)
+ {
+ try
+ {
+ o.close();
+ }
+ catch (Exception e)
+ {
+ LogLog.error("Error occurred closing a stream", e);
+ }
+ }
+ }
+
+
File f =
new File(
SettingsManager.getInstance().getSettingsDirectory() + File.separator
1.7 +3 -2 jakarta-log4j/src/java/org/apache/log4j/chainsaw/LogPanelPreferenceModel.java
Index: LogPanelPreferenceModel.java
===================================================================
RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/chainsaw/LogPanelPreferenceModel.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- LogPanelPreferenceModel.java 29 Oct 2003 08:50:37 -0000 1.6
+++ LogPanelPreferenceModel.java 1 Dec 2003 01:57:31 -0000 1.7
@@ -56,6 +56,7 @@
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
+import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
@@ -71,7 +72,7 @@
* Used to encapsulate all the preferences for a given LogPanel
* @author Paul Smith
*/
-public class LogPanelPreferenceModel {
+public class LogPanelPreferenceModel implements Serializable{
public static final String ISO8601 = "ISO8601";
public static final Collection DATE_FORMATS;
@@ -91,7 +92,7 @@
DATE_FORMATS = Collections.unmodifiableCollection(list);
}
- private final PropertyChangeSupport propertySupport =
+ private transient final PropertyChangeSupport propertySupport =
new PropertyChangeSupport(this);
private String dateFormatPattern = ISO8601;
private boolean levelIcons = true;
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: log4j-dev-help@jakarta.apache.org