Author: sdeboy
Date: Sat Oct 16 06:05:51 2010
New Revision: 1023196
URL: http://svn.apache.org/viewvc?rev=1023196&view=rev
Log:
Improved reliability of scroll to bottom
Updated calls to deprecated methods
Modified:
logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/JSortTable.java
logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LogPanel.java
Modified: logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/JSortTable.java
URL: http://svn.apache.org/viewvc/logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/JSortTable.java?rev=1023196&r1=1023195&r2=1023196&view=diff
==============================================================================
--- logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/JSortTable.java (original)
+++ logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/JSortTable.java Sat Oct 16 06:05:51 2010
@@ -92,9 +92,9 @@ public class JSortTable extends JTable i
//Allow synchronous updates if already on the EDT
private void scrollTo(final int row, final int col) {
- final int currentRow = getSelectedRow();
SwingHelper.invokeOnEDT(new Runnable() {
public void run() {
+ final int currentRow = getSelectedRow();
if ((row > -1) && (row < getRowCount())) {
try {
//get the requested row off of the bottom and top of the screen by making the 5 rows around the requested row visible
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=1023196&r1=1023195&r2=1023196&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 Sat Oct 16 06:05:51 2010
@@ -54,9 +54,11 @@ import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.StringReader;
+import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.text.DateFormat;
import java.text.NumberFormat;
+import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collection;
@@ -1482,7 +1484,11 @@ public class LogPanel extends DockablePa
String value = "";
if (colName.equalsIgnoreCase(ChainsawConstants.TIMESTAMP_COL_NAME)) {
- value = timestampExpressionFormat.format(new Date(currentTable.getValueAt(row, column).toString()));
+ try {
+ value = timestampExpressionFormat.parse(currentTable.getValueAt(row, column).toString()).toString();
+ } catch (ParseException e) {
+ e.printStackTrace();
+ }
} else {
Object o = table.getValueAt(row, column);
@@ -1695,7 +1701,11 @@ public class LogPanel extends DockablePa
String value = "";
if (colName.equalsIgnoreCase(ChainsawConstants.TIMESTAMP_COL_NAME)) {
- value = timestampExpressionFormat.format(new Date(currentTable.getValueAt(row, column).toString()));
+ try {
+ value = timestampExpressionFormat.parse(currentTable.getValueAt(row, column).toString()).toString();
+ } catch (ParseException e) {
+ e.printStackTrace();
+ }
} else {
Object o = currentTable.getValueAt(row, column);
@@ -1874,18 +1884,17 @@ public class LogPanel extends DockablePa
}
private void scrollToBottom() {
+ //run this in an invokeLater block to ensure this action is enqueued to the end of the EDT
EventQueue.invokeLater(new Runnable()
{
- public void run()
- {
- int scrollRow = tableModel.getRowCount() - 1;
+ public void run() {
+ int scrollRow = tableModel.getRowCount() - 1;
table.scrollToRow(scrollRow);
}
});
}
- public void scrollToTop()
- {
+ public void scrollToTop() {
EventQueue.invokeLater(new Runnable() {
public void run() {
if (tableModel.getRowCount() > 1) {
@@ -2023,8 +2032,12 @@ public class LogPanel extends DockablePa
*/
public void loadSettings(LoadSettingsEvent event) {
- File xmlFile = new File(SettingsManager.getInstance()
- .getSettingsDirectory(), URLEncoder.encode(identifier) + ".xml");
+ File xmlFile = null;
+ try {
+ xmlFile = new File(SettingsManager.getInstance().getSettingsDirectory(), URLEncoder.encode(identifier, "UTF-8") + ".xml");
+ } catch (UnsupportedEncodingException e) {
+ e.printStackTrace();
+ }
if (xmlFile.exists()) {
XStream stream = buildXStreamForLogPanelPreference();
@@ -2147,8 +2160,14 @@ public class LogPanel extends DockablePa
* @see LogPanelPreferenceModel
*/
public void saveSettings(SaveSettingsEvent event) {
- File xmlFile = new File(SettingsManager.getInstance()
- .getSettingsDirectory(), URLEncoder.encode(identifier) + ".xml");
+ File xmlFile = null;
+ try {
+ xmlFile = new File(SettingsManager.getInstance().getSettingsDirectory(), URLEncoder.encode(identifier, "UTF-8") + ".xml");
+ } catch (UnsupportedEncodingException e) {
+ e.printStackTrace();
+ //unable to save..just return
+ return;
+ }
preferenceModel.setHiddenLoggers(new HashSet(logTreePanel.getHiddenSet()));
preferenceModel.setHiddenExpression(logTreePanel.getHiddenExpression());
@@ -3999,9 +4018,13 @@ public class LogPanel extends DockablePa
}
invalidate();
repaint();
- if (isScrollToBottom()) {
- scrollToBottom();
- }
+ //run this in an invokeLater block to ensure this action is enqueued to the end of the EDT
+ EventQueue.invokeLater(new Runnable() {
+ public void run() {
+ if (isScrollToBottom()) {
+ scrollToBottom();
+ }
+ }});
}
});
}
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.