Added: logging/log4j/branches/log4j12-bz53299/modules/lf5/src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryNode.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12-bz53299/modules/lf5/src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryNode.java?rev=1345524&view=auto
==============================================================================
--- logging/log4j/branches/log4j12-bz53299/modules/lf5/src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryNode.java (added)
+++ logging/log4j/branches/log4j12-bz53299/modules/lf5/src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryNode.java Sat Jun 2 15:35:46 2012
@@ -0,0 +1,197 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.log4j.lf5.viewer.categoryexplorer;
+
+import javax.swing.tree.DefaultMutableTreeNode;
+import javax.swing.tree.TreeNode;
+import java.util.Enumeration;
+
+/**
+ * CategoryNode
+ *
+ * @author Michael J. Sikorsky
+ * @author Robert Shaw
+ */
+
+// Contributed by ThoughtWorks Inc.
+
+public class CategoryNode extends DefaultMutableTreeNode {
+ private static final long serialVersionUID = 5958994817693177319L;
+ //--------------------------------------------------------------------------
+ // Constants:
+ //--------------------------------------------------------------------------
+
+ //--------------------------------------------------------------------------
+ // Protected Variables:
+ //--------------------------------------------------------------------------
+ protected boolean _selected = true;
+ protected int _numberOfContainedRecords = 0;
+ protected int _numberOfRecordsFromChildren = 0;
+ protected boolean _hasFatalChildren = false;
+ protected boolean _hasFatalRecords = false;
+
+ //--------------------------------------------------------------------------
+ // Private Variables:
+ //--------------------------------------------------------------------------
+
+ //--------------------------------------------------------------------------
+ // Constructors:
+ //--------------------------------------------------------------------------
+
+ /**
+ *
+ */
+ public CategoryNode(String title) {
+ setUserObject(title);
+ }
+
+ //--------------------------------------------------------------------------
+ // Public Methods:
+ //--------------------------------------------------------------------------
+ public String getTitle() {
+ return (String) getUserObject();
+ }
+
+ public void setSelected(boolean s) {
+ if (s != _selected) {
+ _selected = s;
+ }
+ }
+
+ public boolean isSelected() {
+ return _selected;
+ }
+
+ /**
+ * @deprecated
+ */
+ public void setAllDescendantsSelected() {
+ Enumeration children = children();
+ while (children.hasMoreElements()) {
+ CategoryNode node = (CategoryNode) children.nextElement();
+ node.setSelected(true);
+ node.setAllDescendantsSelected();
+ }
+ }
+
+ /**
+ * @deprecated
+ */
+ public void setAllDescendantsDeSelected() {
+ Enumeration children = children();
+ while (children.hasMoreElements()) {
+ CategoryNode node = (CategoryNode) children.nextElement();
+ node.setSelected(false);
+ node.setAllDescendantsDeSelected();
+ }
+ }
+
+ public String toString() {
+ return (getTitle());
+ }
+
+ public boolean equals(Object obj) {
+ if (obj instanceof CategoryNode) {
+ CategoryNode node = (CategoryNode) obj;
+ String tit1 = getTitle().toLowerCase();
+ String tit2 = node.getTitle().toLowerCase();
+
+ if (tit1.equals(tit2)) {
+ return (true);
+ }
+ }
+ return (false);
+ }
+
+ public int hashCode() {
+ return (getTitle().hashCode());
+ }
+
+ public void addRecord() {
+ _numberOfContainedRecords++;
+ addRecordToParent();
+ }
+
+ public int getNumberOfContainedRecords() {
+ return _numberOfContainedRecords;
+ }
+
+ public void resetNumberOfContainedRecords() {
+ _numberOfContainedRecords = 0;
+ _numberOfRecordsFromChildren = 0;
+ _hasFatalRecords = false;
+ _hasFatalChildren = false;
+ }
+
+ public boolean hasFatalRecords() {
+ return _hasFatalRecords;
+ }
+
+ public boolean hasFatalChildren() {
+ return _hasFatalChildren;
+ }
+
+ public void setHasFatalRecords(boolean flag) {
+ _hasFatalRecords = flag;
+ }
+
+ public void setHasFatalChildren(boolean flag) {
+ _hasFatalChildren = flag;
+ }
+
+ //--------------------------------------------------------------------------
+ // Protected Methods:
+ //--------------------------------------------------------------------------
+
+ protected int getTotalNumberOfRecords() {
+ return getNumberOfRecordsFromChildren() + getNumberOfContainedRecords();
+ }
+
+ /**
+ * Passes up the addition from child to parent
+ */
+ protected void addRecordFromChild() {
+ _numberOfRecordsFromChildren++;
+ addRecordToParent();
+ }
+
+ protected int getNumberOfRecordsFromChildren() {
+ return _numberOfRecordsFromChildren;
+ }
+
+ protected void addRecordToParent() {
+ TreeNode parent = getParent();
+ if (parent == null) {
+ return;
+ }
+ ((CategoryNode) parent).addRecordFromChild();
+ }
+ //--------------------------------------------------------------------------
+ // Private Methods:
+ //--------------------------------------------------------------------------
+
+ //--------------------------------------------------------------------------
+ // Nested Top-Level Classes or Interfaces:
+ //--------------------------------------------------------------------------
+
+}
+
+
+
+
+
+
Propchange: logging/log4j/branches/log4j12-bz53299/modules/lf5/src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryNode.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: logging/log4j/branches/log4j12-bz53299/modules/lf5/src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryNodeEditor.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12-bz53299/modules/lf5/src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryNodeEditor.java?rev=1345524&view=auto
==============================================================================
--- logging/log4j/branches/log4j12-bz53299/modules/lf5/src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryNodeEditor.java (added)
+++ logging/log4j/branches/log4j12-bz53299/modules/lf5/src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryNodeEditor.java Sat Jun 2 15:35:46 2012
@@ -0,0 +1,291 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.log4j.lf5.viewer.categoryexplorer;
+
+import java.awt.Component;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.util.ArrayList;
+import java.util.Enumeration;
+
+import javax.swing.JCheckBox;
+import javax.swing.JMenuItem;
+import javax.swing.JOptionPane;
+import javax.swing.JPopupMenu;
+import javax.swing.JTree;
+import javax.swing.tree.TreePath;
+
+/**
+ * CategoryNodeEditor
+ *
+ * @author Michael J. Sikorsky
+ * @author Robert Shaw
+ */
+
+// Contributed by ThoughtWorks Inc.
+
+public class CategoryNodeEditor extends CategoryAbstractCellEditor {
+ //--------------------------------------------------------------------------
+ // Constants:
+ //--------------------------------------------------------------------------
+
+ //--------------------------------------------------------------------------
+ // Protected Variables:
+ //--------------------------------------------------------------------------
+ protected CategoryNodeEditorRenderer _renderer;
+ protected CategoryNode _lastEditedNode;
+ protected JCheckBox _checkBox;
+ protected CategoryExplorerModel _categoryModel;
+ protected JTree _tree;
+
+ //--------------------------------------------------------------------------
+ // Private Variables:
+ //--------------------------------------------------------------------------
+
+ //--------------------------------------------------------------------------
+ // Constructors:
+ //--------------------------------------------------------------------------
+
+ public CategoryNodeEditor(CategoryExplorerModel model) {
+ _renderer = new CategoryNodeEditorRenderer();
+ _checkBox = _renderer.getCheckBox();
+ _categoryModel = model;
+
+ _checkBox.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ _categoryModel.update(_lastEditedNode, _checkBox.isSelected());
+ stopCellEditing();
+ }
+ });
+
+ _renderer.addMouseListener(new MouseAdapter() {
+ public void mousePressed(MouseEvent e) {
+ if ((e.getModifiers() & MouseEvent.BUTTON3_MASK) != 0) {
+ showPopup(_lastEditedNode, e.getX(), e.getY());
+ }
+ stopCellEditing();
+ }
+ });
+ }
+
+ //--------------------------------------------------------------------------
+ // Public Methods:
+ //--------------------------------------------------------------------------
+
+ public Component getTreeCellEditorComponent(JTree tree, Object value,
+ boolean selected, boolean expanded,
+ boolean leaf, int row) {
+ _lastEditedNode = (CategoryNode) value;
+ _tree = tree;
+
+ return _renderer.getTreeCellRendererComponent(tree,
+ value, selected, expanded,
+ leaf, row, true);
+ // hasFocus ignored
+ }
+
+ public Object getCellEditorValue() {
+ return _lastEditedNode.getUserObject();
+ }
+ //--------------------------------------------------------------------------
+ // Protected Methods:
+ //--------------------------------------------------------------------------
+
+ protected JMenuItem createPropertiesMenuItem(final CategoryNode node) {
+ JMenuItem result = new JMenuItem("Properties");
+ result.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ showPropertiesDialog(node);
+ }
+ });
+ return result;
+ }
+
+ protected void showPropertiesDialog(CategoryNode node) {
+ JOptionPane.showMessageDialog(
+ _tree,
+ getDisplayedProperties(node),
+ "Category Properties: " + node.getTitle(),
+ JOptionPane.PLAIN_MESSAGE
+ );
+ }
+
+ protected Object getDisplayedProperties(CategoryNode node) {
+ ArrayList result = new ArrayList();
+ result.add("Category: " + node.getTitle());
+ if (node.hasFatalRecords()) {
+ result.add("Contains at least one fatal LogRecord.");
+ }
+ if (node.hasFatalChildren()) {
+ result.add("Contains descendants with a fatal LogRecord.");
+ }
+ result.add("LogRecords in this category alone: " +
+ node.getNumberOfContainedRecords());
+ result.add("LogRecords in descendant categories: " +
+ node.getNumberOfRecordsFromChildren());
+ result.add("LogRecords in this category including descendants: " +
+ node.getTotalNumberOfRecords());
+ return result.toArray();
+ }
+
+ protected void showPopup(CategoryNode node, int x, int y) {
+ JPopupMenu popup = new JPopupMenu();
+ popup.setSize(150, 400);
+ //
+ // Configure the Popup
+ //
+ if (node.getParent() == null) {
+ popup.add(createRemoveMenuItem());
+ popup.addSeparator();
+ }
+ popup.add(createSelectDescendantsMenuItem(node));
+ popup.add(createUnselectDescendantsMenuItem(node));
+ popup.addSeparator();
+ popup.add(createExpandMenuItem(node));
+ popup.add(createCollapseMenuItem(node));
+ popup.addSeparator();
+ popup.add(createPropertiesMenuItem(node));
+ popup.show(_renderer, x, y);
+ }
+
+ protected JMenuItem createSelectDescendantsMenuItem(final CategoryNode node) {
+ JMenuItem selectDescendants =
+ new JMenuItem("Select All Descendant Categories");
+ selectDescendants.addActionListener(
+ new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ _categoryModel.setDescendantSelection(node, true);
+ }
+ }
+ );
+ return selectDescendants;
+ }
+
+ protected JMenuItem createUnselectDescendantsMenuItem(final CategoryNode node) {
+ JMenuItem unselectDescendants =
+ new JMenuItem("Deselect All Descendant Categories");
+ unselectDescendants.addActionListener(
+
+ new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ _categoryModel.setDescendantSelection(node, false);
+ }
+ }
+
+ );
+ return unselectDescendants;
+ }
+
+ protected JMenuItem createExpandMenuItem(final CategoryNode node) {
+ JMenuItem result = new JMenuItem("Expand All Descendant Categories");
+ result.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ expandDescendants(node);
+ }
+ });
+ return result;
+ }
+
+ protected JMenuItem createCollapseMenuItem(final CategoryNode node) {
+ JMenuItem result = new JMenuItem("Collapse All Descendant Categories");
+ result.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ collapseDescendants(node);
+ }
+ });
+ return result;
+ }
+
+ /**
+ * This featured was moved from the LogBrokerMonitor class
+ * to the CategoryNodeExplorer so that the Category tree
+ * could be pruned from the Category Explorer popup menu.
+ * This menu option only appears when a user right clicks on
+ * the Category parent node.
+ *
+ * See removeUnusedNodes()
+ */
+ protected JMenuItem createRemoveMenuItem() {
+ JMenuItem result = new JMenuItem("Remove All Empty Categories");
+ result.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ while (removeUnusedNodes() > 0) ;
+ }
+ });
+ return result;
+ }
+
+ protected void expandDescendants(CategoryNode node) {
+ Enumeration descendants = node.depthFirstEnumeration();
+ CategoryNode current;
+ while (descendants.hasMoreElements()) {
+ current = (CategoryNode) descendants.nextElement();
+ expand(current);
+ }
+ }
+
+ protected void collapseDescendants(CategoryNode node) {
+ Enumeration descendants = node.depthFirstEnumeration();
+ CategoryNode current;
+ while (descendants.hasMoreElements()) {
+ current = (CategoryNode) descendants.nextElement();
+ collapse(current);
+ }
+ }
+
+ /**
+ * Removes any inactive nodes from the Category tree.
+ */
+ protected int removeUnusedNodes() {
+ int count = 0;
+ CategoryNode root = _categoryModel.getRootCategoryNode();
+ Enumeration enumeration = root.depthFirstEnumeration();
+ while (enumeration.hasMoreElements()) {
+ CategoryNode node = (CategoryNode) enumeration.nextElement();
+ if (node.isLeaf() && node.getNumberOfContainedRecords() == 0
+ && node.getParent() != null) {
+ _categoryModel.removeNodeFromParent(node);
+ count++;
+ }
+ }
+
+ return count;
+ }
+
+ protected void expand(CategoryNode node) {
+ _tree.expandPath(getTreePath(node));
+ }
+
+ protected TreePath getTreePath(CategoryNode node) {
+ return new TreePath(node.getPath());
+ }
+
+ protected void collapse(CategoryNode node) {
+ _tree.collapsePath(getTreePath(node));
+ }
+
+ //-----------------------------------------------------------------------
+ // Private Methods:
+ //--------------------------------------------------------------------------
+
+ //--------------------------------------------------------------------------
+ // Nested Top-Level Classes or Interfaces:
+ //--------------------------------------------------------------------------
+
+}
Propchange: logging/log4j/branches/log4j12-bz53299/modules/lf5/src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryNodeEditor.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: logging/log4j/branches/log4j12-bz53299/modules/lf5/src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryNodeEditorRenderer.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12-bz53299/modules/lf5/src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryNodeEditorRenderer.java?rev=1345524&view=auto
==============================================================================
--- logging/log4j/branches/log4j12-bz53299/modules/lf5/src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryNodeEditorRenderer.java (added)
+++ logging/log4j/branches/log4j12-bz53299/modules/lf5/src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryNodeEditorRenderer.java Sat Jun 2 15:35:46 2012
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.log4j.lf5.viewer.categoryexplorer;
+
+import java.awt.Component;
+
+import javax.swing.JCheckBox;
+import javax.swing.JTree;
+
+/**
+ * CategoryNodeEditorRenderer
+ *
+ * @author Michael J. Sikorsky
+ * @author Robert Shaw
+ */
+
+// Contributed by ThoughtWorks Inc.
+
+public class CategoryNodeEditorRenderer extends CategoryNodeRenderer {
+ private static final long serialVersionUID = -6094804684259929574L;
+
+ //--------------------------------------------------------------------------
+ // Constants:
+ //--------------------------------------------------------------------------
+
+ //--------------------------------------------------------------------------
+ // Protected Variables:
+ //--------------------------------------------------------------------------
+
+ //--------------------------------------------------------------------------
+ // Private Variables:
+ //--------------------------------------------------------------------------
+
+ //--------------------------------------------------------------------------
+ // Constructors:
+ //--------------------------------------------------------------------------
+
+ //--------------------------------------------------------------------------
+ // Public Methods:
+ //--------------------------------------------------------------------------
+
+ public Component getTreeCellRendererComponent(
+ JTree tree, Object value,
+ boolean selected, boolean expanded,
+ boolean leaf, int row,
+ boolean hasFocus) {
+ Component c = super.getTreeCellRendererComponent(tree,
+ value, selected, expanded,
+ leaf, row, hasFocus);
+
+ return c;
+ }
+
+ public JCheckBox getCheckBox() {
+ return _checkBox;
+ }
+
+ //--------------------------------------------------------------------------
+ // Protected Methods:
+ //--------------------------------------------------------------------------
+
+ //--------------------------------------------------------------------------
+ // Private Methods:
+ //--------------------------------------------------------------------------
+
+ //--------------------------------------------------------------------------
+ // Nested Top-Level Classes or Interfaces:
+ //--------------------------------------------------------------------------
+
+}
Propchange: logging/log4j/branches/log4j12-bz53299/modules/lf5/src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryNodeEditorRenderer.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: logging/log4j/branches/log4j12-bz53299/modules/lf5/src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryNodeRenderer.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12-bz53299/modules/lf5/src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryNodeRenderer.java?rev=1345524&view=auto
==============================================================================
--- logging/log4j/branches/log4j12-bz53299/modules/lf5/src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryNodeRenderer.java (added)
+++ logging/log4j/branches/log4j12-bz53299/modules/lf5/src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryNodeRenderer.java Sat Jun 2 15:35:46 2012
@@ -0,0 +1,151 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.log4j.lf5.viewer.categoryexplorer;
+
+import javax.swing.*;
+import javax.swing.tree.DefaultTreeCellRenderer;
+import java.awt.*;
+import java.net.URL;
+
+/**
+ * CategoryNodeRenderer
+ *
+ * @author Michael J. Sikorsky
+ * @author Robert Shaw
+ */
+
+// Contributed by ThoughtWorks Inc.
+
+public class CategoryNodeRenderer extends DefaultTreeCellRenderer {
+ private static final long serialVersionUID = -6046702673278595048L;
+
+ //--------------------------------------------------------------------------
+ // Constants:
+ //--------------------------------------------------------------------------
+
+ public static final Color FATAL_CHILDREN = new Color(189, 113, 0);
+
+ //--------------------------------------------------------------------------
+ // Protected Variables:
+ //--------------------------------------------------------------------------
+ protected JCheckBox _checkBox = new JCheckBox();
+ protected JPanel _panel = new JPanel();
+ protected static ImageIcon _sat = null;
+// protected JLabel _label = new JLabel();
+
+ //--------------------------------------------------------------------------
+ // Private Variables:
+ //--------------------------------------------------------------------------
+
+ //--------------------------------------------------------------------------
+ // Constructors:
+ //--------------------------------------------------------------------------
+ public CategoryNodeRenderer() {
+ _panel.setBackground(UIManager.getColor("Tree.textBackground"));
+
+ if (_sat == null) {
+ // Load the satellite image.
+ String resource =
+ "/org/apache/log4j/lf5/viewer/images/channelexplorer_satellite.gif";
+ URL satURL = getClass().getResource(resource);
+
+ _sat = new ImageIcon(satURL);
+ }
+
+ setOpaque(false);
+ _checkBox.setOpaque(false);
+ _panel.setOpaque(false);
+
+ // The flowlayout set to LEFT is very important so that the editor
+ // doesn't jump around.
+ _panel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
+ _panel.add(_checkBox);
+ _panel.add(this);
+
+ setOpenIcon(_sat);
+ setClosedIcon(_sat);
+ setLeafIcon(_sat);
+ }
+
+ //--------------------------------------------------------------------------
+ // Public Methods:
+ //--------------------------------------------------------------------------
+ public Component getTreeCellRendererComponent(
+ JTree tree, Object value,
+ boolean selected, boolean expanded,
+ boolean leaf, int row,
+ boolean hasFocus) {
+
+ CategoryNode node = (CategoryNode) value;
+ //FileNode node = (FileNode)value;
+ //String s = tree.convertValueToText(value, selected,
+ // expanded, leaf, row, hasFocus);
+
+ super.getTreeCellRendererComponent(
+ tree, value, selected, expanded,
+ leaf, row, hasFocus);
+
+ if (row == 0) {
+ // Root row -- no check box
+ _checkBox.setVisible(false);
+ } else {
+ _checkBox.setVisible(true);
+ _checkBox.setSelected(node.isSelected());
+ }
+ String toolTip = buildToolTip(node);
+ _panel.setToolTipText(toolTip);
+ if (node.hasFatalChildren()) {
+ this.setForeground(FATAL_CHILDREN);
+ }
+ if (node.hasFatalRecords()) {
+ this.setForeground(Color.red);
+ }
+
+ return _panel;
+ }
+
+ public Dimension getCheckBoxOffset() {
+ return new Dimension(0, 0);
+ }
+
+ //--------------------------------------------------------------------------
+ // Protected Methods:
+ //--------------------------------------------------------------------------
+
+ protected String buildToolTip(CategoryNode node) {
+ StringBuffer result = new StringBuffer();
+ result.append(node.getTitle()).append(" contains a total of ");
+ result.append(node.getTotalNumberOfRecords());
+ result.append(" LogRecords.");
+ result.append(" Right-click for more info.");
+ return result.toString();
+ }
+ //--------------------------------------------------------------------------
+ // Private Methods:
+ //--------------------------------------------------------------------------
+
+ //--------------------------------------------------------------------------
+ // Nested Top-Level Classes or Interfaces:
+ //--------------------------------------------------------------------------
+
+}
+
+
+
+
+
+
Propchange: logging/log4j/branches/log4j12-bz53299/modules/lf5/src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryNodeRenderer.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: logging/log4j/branches/log4j12-bz53299/modules/lf5/src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryPath.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12-bz53299/modules/lf5/src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryPath.java?rev=1345524&view=auto
==============================================================================
--- logging/log4j/branches/log4j12-bz53299/modules/lf5/src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryPath.java (added)
+++ logging/log4j/branches/log4j12-bz53299/modules/lf5/src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryPath.java Sat Jun 2 15:35:46 2012
@@ -0,0 +1,157 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.log4j.lf5.viewer.categoryexplorer;
+
+import java.util.LinkedList;
+import java.util.StringTokenizer;
+
+/**
+ * CategoryPath is a collection of CategoryItems which represent a
+ * path of categories.
+ *
+ * @author Michael J. Sikorsky
+ * @author Robert Shaw
+ */
+
+// Contributed by ThoughtWorks Inc.
+
+public class CategoryPath {
+ //--------------------------------------------------------------------------
+ // Constants:
+ //--------------------------------------------------------------------------
+
+ //--------------------------------------------------------------------------
+ // Protected Variables:
+ //--------------------------------------------------------------------------
+ protected LinkedList _categoryElements = new LinkedList();
+
+ //--------------------------------------------------------------------------
+ // Private Variables:
+ //--------------------------------------------------------------------------
+
+ //--------------------------------------------------------------------------
+ // Constructors:
+ //--------------------------------------------------------------------------
+
+ public CategoryPath() {
+ super();
+ }
+
+ /**
+ * Construct a CategoryPath. If the category is null, it defaults to "Debug".
+ */
+ public CategoryPath(String category) {
+ String processedCategory = category;
+
+ if (processedCategory == null) {
+ processedCategory = "Debug";
+ }
+
+ processedCategory = processedCategory.replace('/', '.');
+ processedCategory = processedCategory.replace('\\', '.');
+
+ StringTokenizer st = new StringTokenizer(processedCategory, ".");
+ while (st.hasMoreTokens()) {
+ String element = st.nextToken();
+ addCategoryElement(new CategoryElement(element));
+ }
+ }
+
+ //--------------------------------------------------------------------------
+ // Public Methods:
+ //--------------------------------------------------------------------------
+
+ /**
+ * returns the number of CategoryElements.
+ */
+ public int size() {
+ int count = _categoryElements.size();
+
+ return (count);
+ }
+
+ public boolean isEmpty() {
+ boolean empty = false;
+
+ if (_categoryElements.size() == 0) {
+ empty = true;
+ }
+
+ return (empty);
+ }
+
+
+ /**
+ * Removes all categoryElements.
+ */
+ public void removeAllCategoryElements() {
+ _categoryElements.clear();
+ }
+
+ /**
+ * Adds the specified categoryElement to the end of the categoryElement set.
+ */
+ public void addCategoryElement(CategoryElement categoryElement) {
+ _categoryElements.addLast(categoryElement);
+ }
+
+ /**
+ * Returns the CategoryElement at the specified index.
+ */
+ public CategoryElement categoryElementAt(int index) {
+ return ((CategoryElement) _categoryElements.get(index));
+ }
+
+
+ public String toString() {
+ StringBuffer out = new StringBuffer(100);
+
+ out.append("\n");
+ out.append("===========================\n");
+ out.append("CategoryPath: \n");
+ out.append("---------------------------\n");
+
+ out.append("\nCategoryPath:\n\t");
+
+ if (this.size() > 0) {
+ for (int i = 0; i < this.size(); i++) {
+ out.append(this.categoryElementAt(i).toString());
+ out.append("\n\t");
+ }
+ } else {
+ out.append("<<NONE>>");
+ }
+
+ out.append("\n");
+ out.append("===========================\n");
+
+ return (out.toString());
+ }
+
+ //--------------------------------------------------------------------------
+ // Protected Methods:
+ //--------------------------------------------------------------------------
+
+ //--------------------------------------------------------------------------
+ // Private Methods:
+ //--------------------------------------------------------------------------
+
+ //--------------------------------------------------------------------------
+ // Nested Top-Level Classes or Interfaces:
+ //--------------------------------------------------------------------------
+
+}
Propchange: logging/log4j/branches/log4j12-bz53299/modules/lf5/src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/CategoryPath.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: logging/log4j/branches/log4j12-bz53299/modules/lf5/src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/TreeModelAdapter.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12-bz53299/modules/lf5/src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/TreeModelAdapter.java?rev=1345524&view=auto
==============================================================================
--- logging/log4j/branches/log4j12-bz53299/modules/lf5/src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/TreeModelAdapter.java (added)
+++ logging/log4j/branches/log4j12-bz53299/modules/lf5/src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/TreeModelAdapter.java Sat Jun 2 15:35:46 2012
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.log4j.lf5.viewer.categoryexplorer;
+
+import javax.swing.event.TreeModelEvent;
+import javax.swing.event.TreeModelListener;
+
+/**
+ * Default implementation of TreeModelListener which does nothing.
+ *
+ * @author Richard Wan
+ */
+
+// Contributed by ThoughtWorks Inc.
+
+public class TreeModelAdapter implements TreeModelListener {
+ //--------------------------------------------------------------------------
+ // Constants:
+ //--------------------------------------------------------------------------
+
+ //--------------------------------------------------------------------------
+ // Protected Variables:
+ //--------------------------------------------------------------------------
+
+ //--------------------------------------------------------------------------
+ // Private Variables:
+ //--------------------------------------------------------------------------
+
+ //--------------------------------------------------------------------------
+ // Constructors:
+ //--------------------------------------------------------------------------
+
+ //--------------------------------------------------------------------------
+ // Public Methods:
+ //--------------------------------------------------------------------------
+ public void treeNodesChanged(TreeModelEvent e) {
+ }
+
+ public void treeNodesInserted(TreeModelEvent e) {
+ }
+
+ public void treeNodesRemoved(TreeModelEvent e) {
+ }
+
+ public void treeStructureChanged(TreeModelEvent e) {
+ }
+
+ //--------------------------------------------------------------------------
+ // Protected Methods:
+ //--------------------------------------------------------------------------
+
+ //--------------------------------------------------------------------------
+ // Private Methods:
+ //--------------------------------------------------------------------------
+
+ //--------------------------------------------------------------------------
+ // Nested Top-Level Classes or Interfaces
+ //--------------------------------------------------------------------------
+}
+
Propchange: logging/log4j/branches/log4j12-bz53299/modules/lf5/src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/TreeModelAdapter.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: logging/log4j/branches/log4j12-bz53299/modules/lf5/src/main/java/org/apache/log4j/lf5/viewer/configure/ConfigurationManager.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12-bz53299/modules/lf5/src/main/java/org/apache/log4j/lf5/viewer/configure/ConfigurationManager.java?rev=1345524&view=auto
==============================================================================
--- logging/log4j/branches/log4j12-bz53299/modules/lf5/src/main/java/org/apache/log4j/lf5/viewer/configure/ConfigurationManager.java (added)
+++ logging/log4j/branches/log4j12-bz53299/modules/lf5/src/main/java/org/apache/log4j/lf5/viewer/configure/ConfigurationManager.java Sat Jun 2 15:35:46 2012
@@ -0,0 +1,466 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.log4j.lf5.viewer.configure;
+
+import java.awt.Color;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.swing.JCheckBoxMenuItem;
+import javax.swing.tree.TreePath;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.apache.log4j.lf5.LogLevel;
+import org.apache.log4j.lf5.LogLevelFormatException;
+import org.apache.log4j.lf5.viewer.LogBrokerMonitor;
+import org.apache.log4j.lf5.viewer.LogTable;
+import org.apache.log4j.lf5.viewer.LogTableColumn;
+import org.apache.log4j.lf5.viewer.LogTableColumnFormatException;
+import org.apache.log4j.lf5.viewer.categoryexplorer.CategoryExplorerModel;
+import org.apache.log4j.lf5.viewer.categoryexplorer.CategoryExplorerTree;
+import org.apache.log4j.lf5.viewer.categoryexplorer.CategoryNode;
+import org.apache.log4j.lf5.viewer.categoryexplorer.CategoryPath;
+import org.w3c.dom.Document;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * <p>ConfigurationManager handles the storage and retrival of the state of
+ * the CategoryExplorer
+ *
+ * @author Richard Hurst
+ * @author Brad Marlborough
+ */
+
+// Contributed by ThoughtWorks Inc.
+
+public class ConfigurationManager extends Object {
+ //--------------------------------------------------------------------------
+ // Constants:
+ //--------------------------------------------------------------------------
+ private static final String CONFIG_FILE_NAME = "lf5_configuration.xml";
+ private static final String NAME = "name";
+ private static final String PATH = "path";
+ private static final String SELECTED = "selected";
+ private static final String EXPANDED = "expanded";
+ private static final String CATEGORY = "category";
+ private static final String FIRST_CATEGORY_NAME = "Categories";
+ private static final String LEVEL = "level";
+ private static final String COLORLEVEL = "colorlevel";
+ private static final String RED = "red";
+ private static final String GREEN = "green";
+ private static final String BLUE = "blue";
+ private static final String COLUMN = "column";
+ private static final String NDCTEXTFILTER = "searchtext";
+ //--------------------------------------------------------------------------
+ // Protected Variables:
+ //--------------------------------------------------------------------------
+
+ //--------------------------------------------------------------------------
+ // Private Variables:
+ //--------------------------------------------------------------------------
+ private LogBrokerMonitor _monitor = null;
+ private LogTable _table = null;
+
+ //--------------------------------------------------------------------------
+ // Constructors:
+ //--------------------------------------------------------------------------
+ public ConfigurationManager(LogBrokerMonitor monitor, LogTable table) {
+ super();
+ _monitor = monitor;
+ _table = table;
+ load();
+ }
+ //--------------------------------------------------------------------------
+ // Public Methods:
+ //--------------------------------------------------------------------------
+
+ public void save() {
+ CategoryExplorerModel model = _monitor.getCategoryExplorerTree().getExplorerModel();
+ CategoryNode root = model.getRootCategoryNode();
+
+ StringBuffer xml = new StringBuffer(2048);
+ openXMLDocument(xml);
+ openConfigurationXML(xml);
+ processLogRecordFilter(_monitor.getNDCTextFilter(), xml);
+ processLogLevels(_monitor.getLogLevelMenuItems(), xml);
+ processLogLevelColors(_monitor.getLogLevelMenuItems(),
+ LogLevel.getLogLevelColorMap(), xml);
+ processLogTableColumns(LogTableColumn.getLogTableColumns(), xml);
+ processConfigurationNode(root, xml);
+ closeConfigurationXML(xml);
+ store(xml.toString());
+ }
+
+ public void reset() {
+ deleteConfigurationFile();
+ collapseTree();
+ selectAllNodes();
+ }
+
+ public static String treePathToString(TreePath path) {
+ // count begins at one so as to not include the 'Categories' - root category
+ StringBuffer sb = new StringBuffer();
+ CategoryNode n = null;
+ Object[] objects = path.getPath();
+ for (int i = 1; i < objects.length; i++) {
+ n = (CategoryNode) objects[i];
+ if (i > 1) {
+ sb.append(".");
+ }
+ sb.append(n.getTitle());
+ }
+ return sb.toString();
+ }
+
+ //--------------------------------------------------------------------------
+ // Protected Methods:
+ //--------------------------------------------------------------------------
+ protected void load() {
+ File file = new File(getFilename());
+ if (file.exists()) {
+ try {
+ DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.
+ newInstance();
+ DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
+ Document doc = docBuilder.parse(file);
+ processRecordFilter(doc);
+ processCategories(doc);
+ processLogLevels(doc);
+ processLogLevelColors(doc);
+ processLogTableColumns(doc);
+ } catch (Exception e) {
+ // ignore all error and just continue as if there was no
+ // configuration xml file but do report a message
+ System.err.println("Unable process configuration file at " +
+ getFilename() + ". Error Message=" + e.getMessage());
+ }
+ }
+
+ }
+
+ // Added in version 1.2 - reads in the NDC text filter from the
+ // xml configuration file. If the value of the filter is not null
+ // or an empty string ("") then the manager will set the LogBrokerMonitor's
+ // LogRecordFilter to use the NDC LogRecordFilter. Otherwise, the
+ // LogBrokerMonitor will use the default LogRecordFilter.
+ protected void processRecordFilter(Document doc) {
+ NodeList nodeList = doc.getElementsByTagName(NDCTEXTFILTER);
+
+ // there is only one value stored
+ Node n = nodeList.item(0);
+ // add check for backwards compatibility as this feature was added in
+ // version 1.2
+ if (n == null) {
+ return;
+ }
+
+ NamedNodeMap map = n.getAttributes();
+ String text = getValue(map, NAME);
+
+ if (text == null || text.equals("")) {
+ return;
+ }
+ _monitor.setNDCLogRecordFilter(text);
+ }
+
+ protected void processCategories(Document doc) {
+ CategoryExplorerTree tree = _monitor.getCategoryExplorerTree();
+ CategoryExplorerModel model = tree.getExplorerModel();
+ NodeList nodeList = doc.getElementsByTagName(CATEGORY);
+
+ // determine where the starting node is
+ NamedNodeMap map = nodeList.item(0).getAttributes();
+ int j = (getValue(map, NAME).equalsIgnoreCase(FIRST_CATEGORY_NAME)) ? 1 : 0;
+ // iterate backwards throught the nodeList so that expansion of the
+ // list can occur
+ for (int i = nodeList.getLength() - 1; i >= j; i--) {
+ Node n = nodeList.item(i);
+ map = n.getAttributes();
+ CategoryNode chnode = model.addCategory(new CategoryPath(getValue(map, PATH)));
+ chnode.setSelected((getValue(map, SELECTED).equalsIgnoreCase("true")) ? true : false);
+ if (getValue(map, EXPANDED).equalsIgnoreCase("true")) ;
+ tree.expandPath(model.getTreePathToRoot(chnode));
+ }
+
+ }
+
+ protected void processLogLevels(Document doc) {
+ NodeList nodeList = doc.getElementsByTagName(LEVEL);
+ Map menuItems = _monitor.getLogLevelMenuItems();
+
+ for (int i = 0; i < nodeList.getLength(); i++) {
+ Node n = nodeList.item(i);
+ NamedNodeMap map = n.getAttributes();
+ String name = getValue(map, NAME);
+ try {
+ JCheckBoxMenuItem item =
+ (JCheckBoxMenuItem) menuItems.get(LogLevel.valueOf(name));
+ item.setSelected(getValue(map, SELECTED).equalsIgnoreCase("true"));
+ } catch (LogLevelFormatException e) {
+ // ignore it will be on by default.
+ }
+ }
+ }
+
+ protected void processLogLevelColors(Document doc) {
+ NodeList nodeList = doc.getElementsByTagName(COLORLEVEL);
+ LogLevel.getLogLevelColorMap();
+
+ for (int i = 0; i < nodeList.getLength(); i++) {
+ Node n = nodeList.item(i);
+ // check for backwards compatibility since this feature was added
+ // in version 1.3
+ if (n == null) {
+ return;
+ }
+
+ NamedNodeMap map = n.getAttributes();
+ String name = getValue(map, NAME);
+ try {
+ LogLevel level = LogLevel.valueOf(name);
+ int red = Integer.parseInt(getValue(map, RED));
+ int green = Integer.parseInt(getValue(map, GREEN));
+ int blue = Integer.parseInt(getValue(map, BLUE));
+ Color c = new Color(red, green, blue);
+ if (level != null) {
+ level.setLogLevelColorMap(level, c);
+ }
+
+ } catch (LogLevelFormatException e) {
+ // ignore it will be on by default.
+ }
+ }
+ }
+
+ protected void processLogTableColumns(Document doc) {
+ NodeList nodeList = doc.getElementsByTagName(COLUMN);
+ Map menuItems = _monitor.getLogTableColumnMenuItems();
+ List selectedColumns = new ArrayList();
+ for (int i = 0; i < nodeList.getLength(); i++) {
+ Node n = nodeList.item(i);
+ // check for backwards compatibility since this feature was added
+ // in version 1.3
+ if (n == null) {
+ return;
+ }
+ NamedNodeMap map = n.getAttributes();
+ String name = getValue(map, NAME);
+ try {
+ LogTableColumn column = LogTableColumn.valueOf(name);
+ JCheckBoxMenuItem item =
+ (JCheckBoxMenuItem) menuItems.get(column);
+ item.setSelected(getValue(map, SELECTED).equalsIgnoreCase("true"));
+
+ if (item.isSelected()) {
+ selectedColumns.add(column);
+ }
+ } catch (LogTableColumnFormatException e) {
+ // ignore it will be on by default.
+ }
+
+ if (selectedColumns.isEmpty()) {
+ _table.setDetailedView();
+ } else {
+ _table.setView(selectedColumns);
+ }
+
+ }
+ }
+
+ protected String getValue(NamedNodeMap map, String attr) {
+ Node n = map.getNamedItem(attr);
+ return n.getNodeValue();
+ }
+
+ protected void collapseTree() {
+ // collapse everything except the first category
+ CategoryExplorerTree tree = _monitor.getCategoryExplorerTree();
+ for (int i = tree.getRowCount() - 1; i > 0; i--) {
+ tree.collapseRow(i);
+ }
+ }
+
+ protected void selectAllNodes() {
+ CategoryExplorerModel model = _monitor.getCategoryExplorerTree().getExplorerModel();
+ CategoryNode root = model.getRootCategoryNode();
+ Enumeration all = root.breadthFirstEnumeration();
+ CategoryNode n = null;
+ while (all.hasMoreElements()) {
+ n = (CategoryNode) all.nextElement();
+ n.setSelected(true);
+ }
+ }
+
+ protected void store(String s) {
+
+ try {
+ PrintWriter writer = new PrintWriter(new FileWriter(getFilename()));
+ writer.print(s);
+ writer.close();
+ } catch (IOException e) {
+ // do something with this error.
+ e.printStackTrace();
+ }
+
+ }
+
+ protected void deleteConfigurationFile() {
+ try {
+ File f = new File(getFilename());
+ if (f.exists()) {
+ f.delete();
+ }
+ } catch (SecurityException e) {
+ System.err.println("Cannot delete " + getFilename() +
+ " because a security violation occured.");
+ }
+ }
+
+ protected String getFilename() {
+ String home = System.getProperty("user.home");
+ String sep = System.getProperty("file.separator");
+
+ return home + sep + "lf5" + sep + CONFIG_FILE_NAME;
+ }
+
+ //--------------------------------------------------------------------------
+ // Private Methods:
+ //--------------------------------------------------------------------------
+ private void processConfigurationNode(CategoryNode node, StringBuffer xml) {
+ CategoryExplorerModel model = _monitor.getCategoryExplorerTree().getExplorerModel();
+
+ Enumeration all = node.breadthFirstEnumeration();
+ CategoryNode n = null;
+ while (all.hasMoreElements()) {
+ n = (CategoryNode) all.nextElement();
+ exportXMLElement(n, model.getTreePathToRoot(n), xml);
+ }
+
+ }
+
+ private void processLogLevels(Map logLevelMenuItems, StringBuffer xml) {
+ xml.append("\t<loglevels>\r\n");
+ Iterator it = logLevelMenuItems.keySet().iterator();
+ while (it.hasNext()) {
+ LogLevel level = (LogLevel) it.next();
+ JCheckBoxMenuItem item = (JCheckBoxMenuItem) logLevelMenuItems.get(level);
+ exportLogLevelXMLElement(level.getLabel(), item.isSelected(), xml);
+ }
+
+ xml.append("\t</loglevels>\r\n");
+ }
+
+ private void processLogLevelColors(Map logLevelMenuItems, Map logLevelColors, StringBuffer xml) {
+ xml.append("\t<loglevelcolors>\r\n");
+ // iterate through the list of log levels being used (log4j, jdk1.4, custom levels)
+ Iterator it = logLevelMenuItems.keySet().iterator();
+ while (it.hasNext()) {
+ LogLevel level = (LogLevel) it.next();
+ // for each level, get the associated color from the log level color map
+ Color color = (Color) logLevelColors.get(level);
+ exportLogLevelColorXMLElement(level.getLabel(), color, xml);
+ }
+
+ xml.append("\t</loglevelcolors>\r\n");
+ }
+
+
+ private void processLogTableColumns(List logTableColumnMenuItems, StringBuffer xml) {
+ xml.append("\t<logtablecolumns>\r\n");
+ Iterator it = logTableColumnMenuItems.iterator();
+ while (it.hasNext()) {
+ LogTableColumn column = (LogTableColumn) it.next();
+ JCheckBoxMenuItem item = _monitor.getTableColumnMenuItem(column);
+ exportLogTableColumnXMLElement(column.getLabel(), item.isSelected(), xml);
+ }
+
+ xml.append("\t</logtablecolumns>\r\n");
+ }
+
+ // Added in version 1.2 - stores the NDC text filter in the xml file
+ // for future use.
+ private void processLogRecordFilter(String text, StringBuffer xml) {
+ xml.append("\t<").append(NDCTEXTFILTER).append(" ");
+ xml.append(NAME).append("=\"").append(text).append("\"");
+ xml.append("/>\r\n");
+ }
+
+ private void openXMLDocument(StringBuffer xml) {
+ xml.append("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\r\n");
+ }
+
+ private void openConfigurationXML(StringBuffer xml) {
+ xml.append("<configuration>\r\n");
+ }
+
+ private void closeConfigurationXML(StringBuffer xml) {
+ xml.append("</configuration>\r\n");
+ }
+
+ private void exportXMLElement(CategoryNode node, TreePath path, StringBuffer xml) {
+ CategoryExplorerTree tree = _monitor.getCategoryExplorerTree();
+
+ xml.append("\t<").append(CATEGORY).append(" ");
+ xml.append(NAME).append("=\"").append(node.getTitle()).append("\" ");
+ xml.append(PATH).append("=\"").append(treePathToString(path)).append("\" ");
+ xml.append(EXPANDED).append("=\"").append(tree.isExpanded(path)).append("\" ");
+ xml.append(SELECTED).append("=\"").append(node.isSelected()).append("\"/>\r\n");
+ }
+
+ private void exportLogLevelXMLElement(String label, boolean selected, StringBuffer xml) {
+ xml.append("\t\t<").append(LEVEL).append(" ").append(NAME);
+ xml.append("=\"").append(label).append("\" ");
+ xml.append(SELECTED).append("=\"").append(selected);
+ xml.append("\"/>\r\n");
+ }
+
+ private void exportLogLevelColorXMLElement(String label, Color color, StringBuffer xml) {
+ xml.append("\t\t<").append(COLORLEVEL).append(" ").append(NAME);
+ xml.append("=\"").append(label).append("\" ");
+ xml.append(RED).append("=\"").append(color.getRed()).append("\" ");
+ xml.append(GREEN).append("=\"").append(color.getGreen()).append("\" ");
+ xml.append(BLUE).append("=\"").append(color.getBlue());
+ xml.append("\"/>\r\n");
+ }
+
+ private void exportLogTableColumnXMLElement(String label, boolean selected, StringBuffer xml) {
+ xml.append("\t\t<").append(COLUMN).append(" ").append(NAME);
+ xml.append("=\"").append(label).append("\" ");
+ xml.append(SELECTED).append("=\"").append(selected);
+ xml.append("\"/>\r\n");
+ }
+ //--------------------------------------------------------------------------
+ // Nested Top-Level Classes or Interfaces:
+ //--------------------------------------------------------------------------
+
+}
+
+
+
+
+
+
Propchange: logging/log4j/branches/log4j12-bz53299/modules/lf5/src/main/java/org/apache/log4j/lf5/viewer/configure/ConfigurationManager.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: logging/log4j/branches/log4j12-bz53299/modules/lf5/src/main/java/org/apache/log4j/lf5/viewer/configure/MRUFileManager.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12-bz53299/modules/lf5/src/main/java/org/apache/log4j/lf5/viewer/configure/MRUFileManager.java?rev=1345524&view=auto
==============================================================================
--- logging/log4j/branches/log4j12-bz53299/modules/lf5/src/main/java/org/apache/log4j/lf5/viewer/configure/MRUFileManager.java (added)
+++ logging/log4j/branches/log4j12-bz53299/modules/lf5/src/main/java/org/apache/log4j/lf5/viewer/configure/MRUFileManager.java Sat Jun 2 15:35:46 2012
@@ -0,0 +1,293 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.log4j.lf5.viewer.configure;
+
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.net.URL;
+import java.util.Iterator;
+import java.util.LinkedList;
+
+
+/**
+ * <p>MRUFileManager handles the storage and retrival the most
+ * recently opened log files.
+ *
+ * @author Brad Marlborough
+ * @author Richard Hurst
+ */
+
+// Contributed by ThoughtWorks Inc.
+
+public class MRUFileManager {
+ //--------------------------------------------------------------------------
+ // Constants:
+ //--------------------------------------------------------------------------
+ private static final String CONFIG_FILE_NAME = "mru_file_manager";
+ private static final int DEFAULT_MAX_SIZE = 3;
+
+ //--------------------------------------------------------------------------
+ // Protected Variables:
+ //--------------------------------------------------------------------------
+
+ //--------------------------------------------------------------------------
+ // Private Variables:
+ //--------------------------------------------------------------------------
+ private int _maxSize = 0;
+ private LinkedList _mruFileList;
+
+ //--------------------------------------------------------------------------
+ // Constructors:
+ //--------------------------------------------------------------------------
+ public MRUFileManager() {
+ load();
+ setMaxSize(DEFAULT_MAX_SIZE);
+ }
+
+ public MRUFileManager(int maxSize) {
+ load();
+ setMaxSize(maxSize);
+ }
+ //--------------------------------------------------------------------------
+ // Public Methods:
+ //--------------------------------------------------------------------------
+
+ /**
+ * Saves a list of MRU files out to a file.
+ */
+ public void save() {
+ File file = new File(getFilename());
+
+ try {
+ ObjectOutputStream oos = new ObjectOutputStream(new
+ FileOutputStream(file));
+ oos.writeObject(_mruFileList);
+ oos.flush();
+ oos.close();
+ } catch (Exception e) {
+ // do nothing
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Gets the size of the MRU file list.
+ */
+ public int size() {
+ return _mruFileList.size();
+ }
+
+ /**
+ * Returns a particular file name stored in a MRU file
+ * list based on an index value.
+ */
+ public Object getFile(int index) {
+ if (index < size()) {
+ return _mruFileList.get(index);
+ }
+
+ return null;
+ }
+
+ /**
+ * Returns a input stream to the resource at the specified index
+ */
+ public InputStream getInputStream(int index) throws IOException,
+ FileNotFoundException {
+ if (index < size()) {
+ Object o = getFile(index);
+ if (o instanceof File) {
+ return getInputStream((File) o);
+ } else {
+ return getInputStream((URL) o);
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Adds a file name to the MRU file list.
+ */
+ public void set(File file) {
+ setMRU(file);
+ }
+
+ /**
+ * Adds a url to the MRU file list.
+ */
+ public void set(URL url) {
+ setMRU(url);
+ }
+
+ /**
+ * Gets the list of files stored in the MRU file list.
+ */
+ public String[] getMRUFileList() {
+ if (size() == 0) {
+ return null;
+ }
+
+ String[] ss = new String[size()];
+
+ for (int i = 0; i < size(); i++) {
+ Object o = getFile(i);
+ if (o instanceof File) {
+ ss[i] = ((File) o).getAbsolutePath();
+ } else // must be a url
+ {
+ ss[i] = o.toString();
+ }
+
+ }
+
+ return ss;
+ }
+
+ /**
+ * Moves the the index to the top of the MRU List
+ *
+ * @param index The index to be first in the mru list
+ */
+ public void moveToTop(int index) {
+ _mruFileList.add(0, _mruFileList.remove(index));
+ }
+
+ /**
+ * Creates the directory where the MRU file list will be written.
+ * The "lf5" directory is created in the Documents and Settings
+ * directory on Windows 2000 machines and where ever the user.home
+ * variable points on all other platforms.
+ */
+ public static void createConfigurationDirectory() {
+ String home = System.getProperty("user.home");
+ String sep = System.getProperty("file.separator");
+ File f = new File(home + sep + "lf5");
+ if (!f.exists()) {
+ try {
+ f.mkdir();
+ } catch (SecurityException e) {
+ e.printStackTrace();
+ }
+ }
+
+ }
+ //--------------------------------------------------------------------------
+ // Protected Methods:
+ //--------------------------------------------------------------------------
+ /**
+ * Gets an input stream for the corresponding file.
+ *
+ * @param file The file to create the input stream from.
+ * @return InputStream
+ */
+ protected InputStream getInputStream(File file) throws IOException,
+ FileNotFoundException {
+ BufferedInputStream reader =
+ new BufferedInputStream(new FileInputStream(file));
+
+ return reader;
+ }
+
+ /**
+ * Gets an input stream for the corresponding URL.
+ *
+ * @param url The url to create the input stream from.
+ * @return InputStream
+ */
+ protected InputStream getInputStream(URL url) throws IOException {
+ return url.openStream();
+ }
+
+ /**
+ * Adds an object to the mru.
+ */
+ protected void setMRU(Object o) {
+ int index = _mruFileList.indexOf(o);
+
+ if (index == -1) {
+ _mruFileList.add(0, o);
+ setMaxSize(_maxSize);
+ } else {
+ moveToTop(index);
+ }
+ }
+
+ /**
+ * Loads the MRU file list in from a file and stores it in a LinkedList.
+ * If no file exists, a new LinkedList is created.
+ */
+ protected void load() {
+ createConfigurationDirectory();
+ File file = new File(getFilename());
+ if (file.exists()) {
+ try {
+ ObjectInputStream ois = new ObjectInputStream(
+ new FileInputStream(file));
+ _mruFileList = (LinkedList) ois.readObject();
+ ois.close();
+
+ // check that only files and url are in linked list
+ Iterator it = _mruFileList.iterator();
+ while (it.hasNext()) {
+ Object o = it.next();
+ if (!(o instanceof File) && !(o instanceof URL)) {
+ it.remove();
+ }
+ }
+ } catch (Exception e) {
+ _mruFileList = new LinkedList();
+ }
+ } else {
+ _mruFileList = new LinkedList();
+ }
+
+ }
+
+ protected String getFilename() {
+ String home = System.getProperty("user.home");
+ String sep = System.getProperty("file.separator");
+
+ return home + sep + "lf5" + sep + CONFIG_FILE_NAME;
+ }
+
+ /**
+ * Ensures that the MRU list will have a MaxSize.
+ */
+ protected void setMaxSize(int maxSize) {
+ if (maxSize < _mruFileList.size()) {
+ for (int i = 0; i < _mruFileList.size() - maxSize; i++) {
+ _mruFileList.removeLast();
+ }
+ }
+
+ _maxSize = maxSize;
+ }
+ //--------------------------------------------------------------------------
+ // Private Methods:
+ //--------------------------------------------------------------------------
+
+ //--------------------------------------------------------------------------
+ // Nested Top-Level Classes or Interfaces
+ //--------------------------------------------------------------------------
+}
\ No newline at end of file
Propchange: logging/log4j/branches/log4j12-bz53299/modules/lf5/src/main/java/org/apache/log4j/lf5/viewer/configure/MRUFileManager.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: logging/log4j/branches/log4j12-bz53299/modules/lf5/src/main/resources/org/apache/log4j/lf5/config/defaultconfig.properties
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12-bz53299/modules/lf5/src/main/resources/org/apache/log4j/lf5/config/defaultconfig.properties?rev=1345524&view=auto
==============================================================================
--- logging/log4j/branches/log4j12-bz53299/modules/lf5/src/main/resources/org/apache/log4j/lf5/config/defaultconfig.properties (added)
+++ logging/log4j/branches/log4j12-bz53299/modules/lf5/src/main/resources/org/apache/log4j/lf5/config/defaultconfig.properties Sat Jun 2 15:35:46 2012
@@ -0,0 +1,31 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# For the general syntax of property based configuration files see the
+# documenation of org.apache.log4j.PropertyConfigurator.
+
+# The root category uses the appender called A1. Since no priority is
+# specified, the root category assumes the default priority for root
+# which is DEBUG in log4j. The root category is the only category that
+# has a default priority. All other categories need not be assigned a
+# priority in which case they inherit their priority from the
+# hierarchy.
+
+log4j.rootCategory=, A1
+
+# A1 is set to be a LogMonitorAppender which outputs to a swing
+# logging console.
+
+log4j.appender.A1=org.apache.log4j.lf5.LF5Appender
Propchange: logging/log4j/branches/log4j12-bz53299/modules/lf5/src/main/resources/org/apache/log4j/lf5/config/defaultconfig.properties
------------------------------------------------------------------------------
svn:eol-style = native
Added: logging/log4j/branches/log4j12-bz53299/modules/lf5/src/main/resources/org/apache/log4j/lf5/viewer/images/channelexplorer_new.gif
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12-bz53299/modules/lf5/src/main/resources/org/apache/log4j/lf5/viewer/images/channelexplorer_new.gif?rev=1345524&view=auto
==============================================================================
Binary file - no diff available.
Propchange: logging/log4j/branches/log4j12-bz53299/modules/lf5/src/main/resources/org/apache/log4j/lf5/viewer/images/channelexplorer_new.gif
------------------------------------------------------------------------------
svn:mime-type = image/gif
Added: logging/log4j/branches/log4j12-bz53299/modules/lf5/src/main/resources/org/apache/log4j/lf5/viewer/images/channelexplorer_satellite.gif
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12-bz53299/modules/lf5/src/main/resources/org/apache/log4j/lf5/viewer/images/channelexplorer_satellite.gif?rev=1345524&view=auto
==============================================================================
Binary file - no diff available.
Propchange: logging/log4j/branches/log4j12-bz53299/modules/lf5/src/main/resources/org/apache/log4j/lf5/viewer/images/channelexplorer_satellite.gif
------------------------------------------------------------------------------
svn:mime-type = image/gif
Added: logging/log4j/branches/log4j12-bz53299/modules/lf5/src/main/resources/org/apache/log4j/lf5/viewer/images/lf5_small_icon.gif
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12-bz53299/modules/lf5/src/main/resources/org/apache/log4j/lf5/viewer/images/lf5_small_icon.gif?rev=1345524&view=auto
==============================================================================
Binary file - no diff available.
Propchange: logging/log4j/branches/log4j12-bz53299/modules/lf5/src/main/resources/org/apache/log4j/lf5/viewer/images/lf5_small_icon.gif
------------------------------------------------------------------------------
svn:mime-type = image/gif
Added: logging/log4j/branches/log4j12-bz53299/modules/net/pom.xml
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12-bz53299/modules/net/pom.xml?rev=1345524&view=auto
==============================================================================
--- logging/log4j/branches/log4j12-bz53299/modules/net/pom.xml (added)
+++ logging/log4j/branches/log4j12-bz53299/modules/net/pom.xml Sat Jun 2 15:35:46 2012
@@ -0,0 +1,65 @@
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.log4j</groupId>
+ <artifactId>log4j-modules</artifactId>
+ <version>1.4.0-SNAPSHOT</version>
+ </parent>
+ <groupId>org.apache.log4j</groupId>
+ <artifactId>log4j-net</artifactId>
+ <name>Apache Log4j-Net</name>
+ <description>Apache Log4j Network Module</description>
+ <packaging>bundle</packaging>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <version>2.0.1</version>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Export-Package>org.apache.log4j.net.*</Export-Package>
+ <Import-Package>javax.mail.*;resolution:=optional,
+ *</Import-Package>
+ <Bundle-DocURL>http://logging.apache.org/log4j</Bundle-DocURL>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.log4j</groupId>
+ <artifactId>log4j-core</artifactId>
+ <version>${project.version}</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.mail</groupId>
+ <artifactId>mail</artifactId>
+ <version>1.4.1</version>
+ <optional>true</optional>
+ </dependency>
+ </dependencies>
+
+</project>
\ No newline at end of file
Propchange: logging/log4j/branches/log4j12-bz53299/modules/net/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Copied: logging/log4j/branches/log4j12-bz53299/modules/net/src/main/java/org/apache/log4j/net/JMSAppender.java (from r1345516, logging/log4j/branches/log4j12-bz53299/src/main/java/org/apache/log4j/net/JMSAppender.java)
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12-bz53299/modules/net/src/main/java/org/apache/log4j/net/JMSAppender.java?p2=logging/log4j/branches/log4j12-bz53299/modules/net/src/main/java/org/apache/log4j/net/JMSAppender.java&p1=logging/log4j/branches/log4j12-bz53299/src/main/java/org/apache/log4j/net/JMSAppender.java&r1=1345516&r2=1345524&rev=1345524&view=diff
==============================================================================
(empty)
Propchange: logging/log4j/branches/log4j12-bz53299/modules/net/src/main/java/org/apache/log4j/net/JMSAppender.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: logging/log4j/branches/log4j12-bz53299/modules/net/src/main/java/org/apache/log4j/net/JMSAppender.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Copied: logging/log4j/branches/log4j12-bz53299/modules/net/src/main/java/org/apache/log4j/net/JMSSink.java (from r1345516, logging/log4j/branches/log4j12-bz53299/src/main/java/org/apache/log4j/net/JMSSink.java)
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12-bz53299/modules/net/src/main/java/org/apache/log4j/net/JMSSink.java?p2=logging/log4j/branches/log4j12-bz53299/modules/net/src/main/java/org/apache/log4j/net/JMSSink.java&p1=logging/log4j/branches/log4j12-bz53299/src/main/java/org/apache/log4j/net/JMSSink.java&r1=1345516&r2=1345524&rev=1345524&view=diff
==============================================================================
(empty)
Propchange: logging/log4j/branches/log4j12-bz53299/modules/net/src/main/java/org/apache/log4j/net/JMSSink.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: logging/log4j/branches/log4j12-bz53299/modules/net/src/main/java/org/apache/log4j/net/JMSSink.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Copied: logging/log4j/branches/log4j12-bz53299/modules/net/src/main/java/org/apache/log4j/net/SMTPAppender.java (from r1345516, logging/log4j/branches/log4j12-bz53299/src/main/java/org/apache/log4j/net/SMTPAppender.java)
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12-bz53299/modules/net/src/main/java/org/apache/log4j/net/SMTPAppender.java?p2=logging/log4j/branches/log4j12-bz53299/modules/net/src/main/java/org/apache/log4j/net/SMTPAppender.java&p1=logging/log4j/branches/log4j12-bz53299/src/main/java/org/apache/log4j/net/SMTPAppender.java&r1=1345516&r2=1345524&rev=1345524&view=diff
==============================================================================
(empty)
Propchange: logging/log4j/branches/log4j12-bz53299/modules/net/src/main/java/org/apache/log4j/net/SMTPAppender.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: logging/log4j/branches/log4j12-bz53299/modules/net/src/main/java/org/apache/log4j/net/SMTPAppender.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Copied: logging/log4j/branches/log4j12-bz53299/modules/net/src/main/java/org/apache/log4j/net/SimpleSocketServer.java (from r1345516, logging/log4j/branches/log4j12-bz53299/src/main/java/org/apache/log4j/net/SimpleSocketServer.java)
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12-bz53299/modules/net/src/main/java/org/apache/log4j/net/SimpleSocketServer.java?p2=logging/log4j/branches/log4j12-bz53299/modules/net/src/main/java/org/apache/log4j/net/SimpleSocketServer.java&p1=logging/log4j/branches/log4j12-bz53299/src/main/java/org/apache/log4j/net/SimpleSocketServer.java&r1=1345516&r2=1345524&rev=1345524&view=diff
==============================================================================
(empty)
Propchange: logging/log4j/branches/log4j12-bz53299/modules/net/src/main/java/org/apache/log4j/net/SimpleSocketServer.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: logging/log4j/branches/log4j12-bz53299/modules/net/src/main/java/org/apache/log4j/net/SimpleSocketServer.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Copied: logging/log4j/branches/log4j12-bz53299/modules/net/src/main/java/org/apache/log4j/net/SocketAppender.java (from r1345516, logging/log4j/branches/log4j12-bz53299/src/main/java/org/apache/log4j/net/SocketAppender.java)
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12-bz53299/modules/net/src/main/java/org/apache/log4j/net/SocketAppender.java?p2=logging/log4j/branches/log4j12-bz53299/modules/net/src/main/java/org/apache/log4j/net/SocketAppender.java&p1=logging/log4j/branches/log4j12-bz53299/src/main/java/org/apache/log4j/net/SocketAppender.java&r1=1345516&r2=1345524&rev=1345524&view=diff
==============================================================================
(empty)
Propchange: logging/log4j/branches/log4j12-bz53299/modules/net/src/main/java/org/apache/log4j/net/SocketAppender.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: logging/log4j/branches/log4j12-bz53299/modules/net/src/main/java/org/apache/log4j/net/SocketAppender.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Copied: logging/log4j/branches/log4j12-bz53299/modules/net/src/main/java/org/apache/log4j/net/SocketHubAppender.java (from r1345516, logging/log4j/branches/log4j12-bz53299/src/main/java/org/apache/log4j/net/SocketHubAppender.java)
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12-bz53299/modules/net/src/main/java/org/apache/log4j/net/SocketHubAppender.java?p2=logging/log4j/branches/log4j12-bz53299/modules/net/src/main/java/org/apache/log4j/net/SocketHubAppender.java&p1=logging/log4j/branches/log4j12-bz53299/src/main/java/org/apache/log4j/net/SocketHubAppender.java&r1=1345516&r2=1345524&rev=1345524&view=diff
==============================================================================
(empty)
Propchange: logging/log4j/branches/log4j12-bz53299/modules/net/src/main/java/org/apache/log4j/net/SocketHubAppender.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: logging/log4j/branches/log4j12-bz53299/modules/net/src/main/java/org/apache/log4j/net/SocketHubAppender.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Copied: logging/log4j/branches/log4j12-bz53299/modules/net/src/main/java/org/apache/log4j/net/SocketNode.java (from r1345516, logging/log4j/branches/log4j12-bz53299/src/main/java/org/apache/log4j/net/SocketNode.java)
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12-bz53299/modules/net/src/main/java/org/apache/log4j/net/SocketNode.java?p2=logging/log4j/branches/log4j12-bz53299/modules/net/src/main/java/org/apache/log4j/net/SocketNode.java&p1=logging/log4j/branches/log4j12-bz53299/src/main/java/org/apache/log4j/net/SocketNode.java&r1=1345516&r2=1345524&rev=1345524&view=diff
==============================================================================
(empty)
Propchange: logging/log4j/branches/log4j12-bz53299/modules/net/src/main/java/org/apache/log4j/net/SocketNode.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: logging/log4j/branches/log4j12-bz53299/modules/net/src/main/java/org/apache/log4j/net/SocketNode.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Copied: logging/log4j/branches/log4j12-bz53299/modules/net/src/main/java/org/apache/log4j/net/SocketServer.java (from r1345516, logging/log4j/branches/log4j12-bz53299/src/main/java/org/apache/log4j/net/SocketServer.java)
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12-bz53299/modules/net/src/main/java/org/apache/log4j/net/SocketServer.java?p2=logging/log4j/branches/log4j12-bz53299/modules/net/src/main/java/org/apache/log4j/net/SocketServer.java&p1=logging/log4j/branches/log4j12-bz53299/src/main/java/org/apache/log4j/net/SocketServer.java&r1=1345516&r2=1345524&rev=1345524&view=diff
==============================================================================
(empty)
Propchange: logging/log4j/branches/log4j12-bz53299/modules/net/src/main/java/org/apache/log4j/net/SocketServer.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: logging/log4j/branches/log4j12-bz53299/modules/net/src/main/java/org/apache/log4j/net/SocketServer.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Copied: logging/log4j/branches/log4j12-bz53299/modules/net/src/main/java/org/apache/log4j/net/SyslogAppender.java (from r1345516, logging/log4j/branches/log4j12-bz53299/src/main/java/org/apache/log4j/net/SyslogAppender.java)
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12-bz53299/modules/net/src/main/java/org/apache/log4j/net/SyslogAppender.java?p2=logging/log4j/branches/log4j12-bz53299/modules/net/src/main/java/org/apache/log4j/net/SyslogAppender.java&p1=logging/log4j/branches/log4j12-bz53299/src/main/java/org/apache/log4j/net/SyslogAppender.java&r1=1345516&r2=1345524&rev=1345524&view=diff
==============================================================================
(empty)
Propchange: logging/log4j/branches/log4j12-bz53299/modules/net/src/main/java/org/apache/log4j/net/SyslogAppender.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: logging/log4j/branches/log4j12-bz53299/modules/net/src/main/java/org/apache/log4j/net/SyslogAppender.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Copied: logging/log4j/branches/log4j12-bz53299/modules/net/src/main/java/org/apache/log4j/net/TelnetAppender.java (from r1345516, logging/log4j/branches/log4j12-bz53299/src/main/java/org/apache/log4j/net/TelnetAppender.java)
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12-bz53299/modules/net/src/main/java/org/apache/log4j/net/TelnetAppender.java?p2=logging/log4j/branches/log4j12-bz53299/modules/net/src/main/java/org/apache/log4j/net/TelnetAppender.java&p1=logging/log4j/branches/log4j12-bz53299/src/main/java/org/apache/log4j/net/TelnetAppender.java&r1=1345516&r2=1345524&rev=1345524&view=diff
==============================================================================
(empty)
Propchange: logging/log4j/branches/log4j12-bz53299/modules/net/src/main/java/org/apache/log4j/net/TelnetAppender.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: logging/log4j/branches/log4j12-bz53299/modules/net/src/main/java/org/apache/log4j/net/TelnetAppender.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Copied: logging/log4j/branches/log4j12-bz53299/modules/net/src/main/java/org/apache/log4j/net/ZeroConfSupport.java (from r1345516, logging/log4j/branches/log4j12-bz53299/src/main/java/org/apache/log4j/net/ZeroConfSupport.java)
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12-bz53299/modules/net/src/main/java/org/apache/log4j/net/ZeroConfSupport.java?p2=logging/log4j/branches/log4j12-bz53299/modules/net/src/main/java/org/apache/log4j/net/ZeroConfSupport.java&p1=logging/log4j/branches/log4j12-bz53299/src/main/java/org/apache/log4j/net/ZeroConfSupport.java&r1=1345516&r2=1345524&rev=1345524&view=diff
==============================================================================
(empty)
Propchange: logging/log4j/branches/log4j12-bz53299/modules/net/src/main/java/org/apache/log4j/net/ZeroConfSupport.java
------------------------------------------------------------------------------
svn:eol-style = native
Copied: logging/log4j/branches/log4j12-bz53299/modules/net/src/main/java/org/apache/log4j/net/package.html (from r1345516, logging/log4j/branches/log4j12-bz53299/src/main/java/org/apache/log4j/net/package.html)
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12-bz53299/modules/net/src/main/java/org/apache/log4j/net/package.html?p2=logging/log4j/branches/log4j12-bz53299/modules/net/src/main/java/org/apache/log4j/net/package.html&p1=logging/log4j/branches/log4j12-bz53299/src/main/java/org/apache/log4j/net/package.html&r1=1345516&r2=1345524&rev=1345524&view=diff
==============================================================================
(empty)
Propchange: logging/log4j/branches/log4j12-bz53299/modules/net/src/main/java/org/apache/log4j/net/package.html
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: logging/log4j/branches/log4j12-bz53299/modules/net/src/main/java/org/apache/log4j/net/package.html
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: logging/log4j/branches/log4j12-bz53299/modules/net/src/test/java/org/apache/log4j/net/SMTPAppenderTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12-bz53299/modules/net/src/test/java/org/apache/log4j/net/SMTPAppenderTest.java?rev=1345524&view=auto
==============================================================================
--- logging/log4j/branches/log4j12-bz53299/modules/net/src/test/java/org/apache/log4j/net/SMTPAppenderTest.java (added)
+++ logging/log4j/branches/log4j12-bz53299/modules/net/src/test/java/org/apache/log4j/net/SMTPAppenderTest.java Sat Jun 2 15:35:46 2012
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.log4j.net;
+
+import junit.framework.TestCase;
+import org.apache.log4j.LogManager;
+import org.apache.log4j.Logger;
+import org.apache.log4j.spi.LoggingEvent;
+import org.apache.log4j.spi.TriggeringEventEvaluator;
+import org.apache.log4j.xml.DOMConfigurator;
+
+/**
+ * Tests for SMTPAppender.
+ */
+public class SMTPAppenderTest extends TestCase {
+ public SMTPAppenderTest(final String testName) {
+ super(testName);
+ }
+
+ /**
+ * Reset configuration after every test.
+ */
+ public void tearDown() {
+ LogManager.resetConfiguration();
+ }
+
+ /**
+ * Trivial implementation of TriggeringEventEvaluator.
+ */
+ public static final class MockTriggeringEventEvaluator implements TriggeringEventEvaluator {
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isTriggeringEvent(final LoggingEvent event) {
+ return true;
+ }
+ }
+
+ /**
+ * Tests that triggeringPolicy element will set evaluator.
+ */
+ public void testTrigger() {
+ DOMConfigurator.configure("target/test-classes/input/xml/smtpAppender1.xml");
+ SMTPAppender appender = (SMTPAppender) Logger.getRootLogger().getAppender("A1");
+ TriggeringEventEvaluator evaluator = appender.getEvaluator();
+ assertTrue(evaluator instanceof MockTriggeringEventEvaluator);
+ }
+}
Propchange: logging/log4j/branches/log4j12-bz53299/modules/net/src/test/java/org/apache/log4j/net/SMTPAppenderTest.java
------------------------------------------------------------------------------
svn:eol-style = native
|