logging-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sde...@apache.org
Subject svn commit: r825384 - in /logging/chainsaw/trunk/src/main: java/org/apache/log4j/chainsaw/ resources/org/apache/log4j/chainsaw/prefs/
Date Thu, 15 Oct 2009 03:55:45 GMT
Author: sdeboy
Date: Thu Oct 15 03:55:45 2009
New Revision: 825384

URL: http://svn.apache.org/viewvc?rev=825384&view=rev
Log:
Make sure all default columns are added to the 'columns' of the preferencemodel (so defaults
can be re-enabled if previously disabled)

Modified:
    logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LogPanel.java
    logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LogPanelPreferenceModel.java
    logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LogPanelPreferencePanel.java
    logging/chainsaw/trunk/src/main/resources/org/apache/log4j/chainsaw/prefs/default.properties

Modified: logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LogPanel.java
URL: http://svn.apache.org/viewvc/logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LogPanel.java?rev=825384&r1=825383&r2=825384&view=diff
==============================================================================
--- logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LogPanel.java (original)
+++ logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LogPanel.java Thu Oct 15
03:55:45 2009
@@ -1547,7 +1547,19 @@
             	in = stream.createObjectInputStream(r);
             	
                 LogPanelPreferenceModel storedPrefs = (LogPanelPreferenceModel)in.readObject();
+                String columnOrder = event.getSetting(TABLE_COLUMN_ORDER);
                 preferenceModel.apply(storedPrefs);
+
+                //update prefModel columns to include defaults
+                int index = 0;
+                StringTokenizer tok = new StringTokenizer(columnOrder, ",");
+                while (tok.hasMoreElements()) {
+                  String element = tok.nextElement().toString().trim();
+                  TableColumn column = new TableColumn(index++);
+                  column.setHeaderValue(element);
+                  preferenceModel.addColumn(column);
+                }
+
                 TableColumnModel columnModel = table.getColumnModel();
                 //remove previous columns
                 while (columnModel.getColumnCount() > 0) {

Modified: logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LogPanelPreferenceModel.java
URL: http://svn.apache.org/viewvc/logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LogPanelPreferenceModel.java?rev=825384&r1=825383&r2=825384&view=diff
==============================================================================
--- logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LogPanelPreferenceModel.java
(original)
+++ logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LogPanelPreferenceModel.java
Thu Oct 15 03:55:45 2009
@@ -134,7 +134,7 @@
 	  if (findColumnByHeader(allColumns, column.getHeaderValue().toString()) != null) {
 		  return false;
 	  }
-	  
+
       Object oldValue = allColumns;
       allColumns = new ArrayList(allColumns);
       allColumns.add(column);
@@ -276,11 +276,11 @@
   /**
    * Returns true if the named column should be made visible otherwise
    * false.
-   * @param columnName
+   * @param column
    * @return column visible flag
    */
   public boolean isColumnVisible(TableColumn column) {
-	  return (visibleColumns.contains(column));
+	  return (findColumnByHeader(visibleColumns, column.getHeaderValue().toString()) != null);
   }
 
   private void setVisibleColumns(List visibleColumns) {
@@ -292,20 +292,19 @@
 
   public void setColumnVisible(String columnName, boolean isVisible) {
     boolean wasVisible = findColumnByHeader(visibleColumns, columnName) != null;
-    boolean newVisible = isVisible;
 
-    //because we're a list and not a set, ensure we keep at most
+      //because we're a list and not a set, ensure we keep at most
     //one entry for a tablecolumn
     Object col = findColumnByHeader(allColumns, columnName);
-    if (newVisible && !wasVisible) {
+    if (isVisible && !wasVisible) {
 		visibleColumns.add(col);
 		visibleColumnOrder.add(col);
-	    propertySupport.firePropertyChange("visibleColumns", new Boolean(newVisible), new Boolean(wasVisible));
     
+	    propertySupport.firePropertyChange("visibleColumns", new Boolean(isVisible), new Boolean(wasVisible));
 	}
-    if (!newVisible && wasVisible) {
+    if (!isVisible && wasVisible) {
 		visibleColumns.remove(col);
 		visibleColumnOrder.remove(col);
-	    propertySupport.firePropertyChange("visibleColumns", new Boolean(newVisible), new Boolean(wasVisible));
     
+	    propertySupport.firePropertyChange("visibleColumns", new Boolean(isVisible), new Boolean(wasVisible));
 	}
   }
   

Modified: logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LogPanelPreferencePanel.java
URL: http://svn.apache.org/viewvc/logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LogPanelPreferencePanel.java?rev=825384&r1=825383&r2=825384&view=diff
==============================================================================
--- logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LogPanelPreferencePanel.java
(original)
+++ logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LogPanelPreferencePanel.java
Thu Oct 15 03:55:45 2009
@@ -25,6 +25,7 @@
 import java.awt.event.MouseEvent;
 import java.beans.PropertyChangeEvent;
 import java.beans.PropertyChangeListener;
+import java.util.Enumeration;
 import java.util.Iterator;
 import java.util.List;
 
@@ -174,7 +175,18 @@
         Iterator iter = preferenceModel.getColumns().iterator();
           iter.hasNext();)
       {
-        columnListModel.addElement(iter.next());
+          TableColumn col = (TableColumn)iter.next();
+          Enumeration enumeration = columnListModel.elements();
+          boolean found = false;
+          while (enumeration.hasMoreElements()) {
+              TableColumn thisCol = (TableColumn) enumeration.nextElement();
+              if (thisCol.getHeaderValue().equals(col.getHeaderValue())) {
+                  found = true;
+              }
+          }
+            if (!found) {
+              columnListModel.addElement(col);
+            }
       }
 
       columnList.setModel(columnListModel);
@@ -643,7 +655,15 @@
           	          iter.hasNext();)
           	      {
           	        TableColumn col = (TableColumn) iter.next();
-          	        if (!columnListModel.contains(col)) {
+                    Enumeration enumeration = columnListModel.elements();
+                    boolean found = false;
+                    while (enumeration.hasMoreElements()) {
+                        TableColumn thisCol = (TableColumn) enumeration.nextElement();
+                        if (thisCol.getHeaderValue().equals(col.getHeaderValue())) {
+                            found = true;
+                        }
+                    }
+          	        if (!found) {
           	        	columnListModel.addElement(col);
           	            columnListModel.fireContentsChanged();
           	        }
@@ -658,7 +678,6 @@
                     columnListModel.fireContentsChanged();
                   }
                 });
-
     }
   }
 }

Modified: logging/chainsaw/trunk/src/main/resources/org/apache/log4j/chainsaw/prefs/default.properties
URL: http://svn.apache.org/viewvc/logging/chainsaw/trunk/src/main/resources/org/apache/log4j/chainsaw/prefs/default.properties?rev=825384&r1=825383&r2=825384&view=diff
==============================================================================
--- logging/chainsaw/trunk/src/main/resources/org/apache/log4j/chainsaw/prefs/default.properties
(original)
+++ logging/chainsaw/trunk/src/main/resources/org/apache/log4j/chainsaw/prefs/default.properties
Thu Oct 15 03:55:45 2009
@@ -9,7 +9,8 @@
 main.window.width=640
 main.window.height=480
 
-table.columns.order=ID,Timestamp,Level,Logger,Message,Throwable,Thread,NDC,Class,Method,File,Line
+#entries need to have 1st char uppercase, remaining lowercase
+table.columns.order=Id,Timestamp,Level,Logger,Message,Throwable,Thread,Ndc,Class,Method,File,Line
 table.columns.widths=50,150,50,100,300,100,150,150,300,150,100,100
 
 SavedConfigs.Size=0



Mime
View raw message