Methods Summary |
---|
public void | addDisplayedProperty(java.lang.Object messageLine)
_displayedLogBrokerProperties.add(messageLine);
|
public void | addMessage(org.apache.log4j.lf5.LogRecord lr)Add a log record message to be displayed in the LogTable.
This method is thread-safe as it posts requests to the SwingThread
rather than processing directly.
if (_isDisposed == true) {
// If the frame has been disposed of, do not log any more
// messages.
return;
}
SwingUtilities.invokeLater(new Runnable() {
public void run() {
_categoryExplorerTree.getExplorerModel().addLogRecord(lr);
_table.getFilteredLogTableModel().addLogRecord(lr); // update table
updateStatusLabel(); // show updated counts
}
});
|
protected void | addTableModelProperties()
final FilteredLogTableModel model = _table.getFilteredLogTableModel();
addDisplayedProperty(new Object() {
public String toString() {
return getRecordsDisplayedMessage();
}
});
addDisplayedProperty(new Object() {
public String toString() {
return "Maximum number of displayed LogRecords: "
+ model._maxNumberOfLogRecords;
}
});
|
protected void | centerFrame(javax.swing.JFrame frame)
Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
Dimension comp = frame.getSize();
frame.setLocation(((screen.width - comp.width) / 2),
((screen.height - comp.height) / 2));
|
protected int | changeFontSizeCombo(javax.swing.JComboBox box, int requestedSize)Changes the font selection in the combo box and returns the
size actually selected.
int len = box.getItemCount();
int currentValue;
Object currentObject;
Object selectedObject = box.getItemAt(0);
int selectedValue = Integer.parseInt(String.valueOf(selectedObject));
for (int i = 0; i < len; i++) {
currentObject = box.getItemAt(i);
currentValue = Integer.parseInt(String.valueOf(currentObject));
if (selectedValue < currentValue && currentValue <= requestedSize) {
selectedValue = currentValue;
selectedObject = currentObject;
}
}
box.setSelectedItem(selectedObject);
return selectedValue;
|
protected void | clearDetailTextArea()
_table._detailTextArea.setText("");
|
protected void | closeAfterConfirm()
StringBuffer message = new StringBuffer();
if (_callSystemExitOnClose == false) {
message.append("Are you sure you want to close the logging ");
message.append("console?\n");
message.append("(Note: This will not shut down the Virtual Machine,\n");
message.append("or the Swing event thread.)");
} else {
message.append("Are you sure you want to exit?\n");
message.append("This will shut down the Virtual Machine.\n");
}
String title =
"Are you sure you want to dispose of the Logging Console?";
if (_callSystemExitOnClose == true) {
title = "Are you sure you want to exit?";
}
int value = JOptionPane.showConfirmDialog(
_logMonitorFrame,
message.toString(),
title,
JOptionPane.OK_CANCEL_OPTION,
JOptionPane.QUESTION_MESSAGE,
null
);
if (value == JOptionPane.OK_OPTION) {
dispose();
}
|
protected javax.swing.JMenuItem | createAllLogLevelsMenuItem()
JMenuItem result = new JMenuItem("Show all LogLevels");
result.setMnemonic('s");
result.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
selectAllLogLevels(true);
_table.getFilteredLogTableModel().refresh();
updateStatusLabel();
}
});
return result;
|
protected javax.swing.JMenuItem | createAllLogTableColumnsMenuItem()
JMenuItem result = new JMenuItem("Show all Columns");
result.setMnemonic('s");
result.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
selectAllLogTableColumns(true);
// update list of columns and reset the view
List selectedColumns = updateView();
_table.setView(selectedColumns);
}
});
return result;
|
protected javax.swing.JMenuItem | createCloseMI()
JMenuItem result = new JMenuItem("Close");
result.setMnemonic('c");
result.setAccelerator(KeyStroke.getKeyStroke("control Q"));
result.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
requestClose();
}
});
return result;
|
protected javax.swing.JMenuItem | createConfigureMaxRecords()
JMenuItem result = new JMenuItem("Set Max Number of Records");
result.setMnemonic('m");
result.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
setMaxRecordConfiguration();
}
});
return result;
|
protected javax.swing.JMenu | createConfigureMenu()
JMenu configureMenu = new JMenu("Configure");
configureMenu.setMnemonic('c");
configureMenu.add(createConfigureSave());
configureMenu.add(createConfigureReset());
configureMenu.add(createConfigureMaxRecords());
return configureMenu;
|
protected javax.swing.JMenuItem | createConfigureReset()
JMenuItem result = new JMenuItem("Reset");
result.setMnemonic('r");
result.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
resetConfiguration();
}
});
return result;
|
protected javax.swing.JMenuItem | createConfigureSave()
JMenuItem result = new JMenuItem("Save");
result.setMnemonic('s");
result.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
saveConfiguration();
}
});
return result;
|
protected javax.swing.JTextArea | createDetailTextArea()
JTextArea detailTA = new JTextArea();
detailTA.setFont(new Font("Monospaced", Font.PLAIN, 14));
detailTA.setTabSize(3);
detailTA.setLineWrap(true);
detailTA.setWrapStyleWord(false);
return (detailTA);
|
protected javax.swing.JMenuItem | createEditFindMI()
JMenuItem editFindMI = new JMenuItem("Find");
editFindMI.setMnemonic('f");
editFindMI.setAccelerator(KeyStroke.getKeyStroke("control F"));
editFindMI.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
String inputValue =
JOptionPane.showInputDialog(
_logMonitorFrame,
"Find text: ",
"Search Record Messages",
JOptionPane.QUESTION_MESSAGE
);
setSearchText(inputValue);
findSearchText();
}
}
);
return editFindMI;
|
protected javax.swing.JMenuItem | createEditFindNextMI()
JMenuItem editFindNextMI = new JMenuItem("Find Next");
editFindNextMI.setMnemonic('n");
editFindNextMI.setAccelerator(KeyStroke.getKeyStroke("F3"));
editFindNextMI.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
findSearchText();
}
});
return editFindNextMI;
|
protected javax.swing.JMenu | createEditMenu()
JMenu editMenu = new JMenu("Edit");
editMenu.setMnemonic('e");
editMenu.add(createEditFindMI());
editMenu.add(createEditFindNextMI());
editMenu.addSeparator();
editMenu.add(createEditSortNDCMI());
editMenu.add(createEditRestoreAllNDCMI());
return editMenu;
|
protected javax.swing.JMenuItem | createEditRestoreAllNDCMI()
JMenuItem editRestoreAllNDCMI = new JMenuItem("Restore all NDCs");
editRestoreAllNDCMI.setMnemonic('r");
editRestoreAllNDCMI.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
_table.getFilteredLogTableModel().setLogRecordFilter(createLogRecordFilter());
// reset the text filter
setNDCTextFilter("");
_table.getFilteredLogTableModel().refresh();
updateStatusLabel();
}
}
);
return editRestoreAllNDCMI;
|
protected javax.swing.JMenuItem | createEditSortNDCMI()
JMenuItem editSortNDCMI = new JMenuItem("Sort by NDC");
editSortNDCMI.setMnemonic('s");
editSortNDCMI.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
String inputValue =
JOptionPane.showInputDialog(
_logMonitorFrame,
"Sort by this NDC: ",
"Sort Log Records by NDC",
JOptionPane.QUESTION_MESSAGE
);
setNDCTextFilter(inputValue);
sortByNDC();
_table.getFilteredLogTableModel().refresh();
updateStatusLabel();
}
}
);
return editSortNDCMI;
|
protected javax.swing.JMenuItem | createExitMI()
JMenuItem result = new JMenuItem("Exit");
result.setMnemonic('x");
result.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
requestExit();
}
});
return result;
|
protected javax.swing.JMenu | createFileMenu()
JMenu fileMenu = new JMenu("File");
fileMenu.setMnemonic('f");
JMenuItem exitMI;
fileMenu.add(createOpenMI());
fileMenu.add(createOpenURLMI());
fileMenu.addSeparator();
fileMenu.add(createCloseMI());
createMRUFileListMI(fileMenu);
fileMenu.addSeparator();
fileMenu.add(createExitMI());
return fileMenu;
|
protected javax.swing.JMenu | createHelpMenu()
JMenu helpMenu = new JMenu("Help");
helpMenu.setMnemonic('h");
helpMenu.add(createHelpProperties());
return helpMenu;
|
protected javax.swing.JMenuItem | createHelpProperties()
final String title = "LogFactor5 Properties";
final JMenuItem result = new JMenuItem(title);
result.setMnemonic('l");
result.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
showPropertiesDialog(title);
}
});
return result;
|
protected javax.swing.JMenu | createLogLevelColorMenu()
JMenu colorMenu = new JMenu("Configure LogLevel Colors");
colorMenu.setMnemonic('c");
Iterator levels = getLogLevels();
while (levels.hasNext()) {
colorMenu.add(createSubMenuItem((LogLevel) levels.next()));
}
return colorMenu;
|
protected javax.swing.JComboBox | createLogLevelCombo()
JComboBox result = new JComboBox();
Iterator levels = getLogLevels();
while (levels.hasNext()) {
result.addItem(levels.next());
}
result.setSelectedItem(_leastSevereDisplayedLogLevel);
result.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JComboBox box = (JComboBox) e.getSource();
LogLevel level = (LogLevel) box.getSelectedItem();
setLeastSevereDisplayedLogLevel(level);
}
});
result.setMaximumSize(result.getPreferredSize());
return result;
|
protected javax.swing.JMenu | createLogLevelMenu()
JMenu result = new JMenu("Log Level");
result.setMnemonic('l");
Iterator levels = getLogLevels();
while (levels.hasNext()) {
result.add(getMenuItem((LogLevel) levels.next()));
}
result.addSeparator();
result.add(createAllLogLevelsMenuItem());
result.add(createNoLogLevelsMenuItem());
result.addSeparator();
result.add(createLogLevelColorMenu());
result.add(createResetLogLevelColorMenuItem());
return result;
|
protected org.apache.log4j.lf5.LogRecordFilter | createLogRecordFilter()
LogRecordFilter result = new LogRecordFilter() {
public boolean passes(LogRecord record) {
CategoryPath path = new CategoryPath(record.getCategory());
return
getMenuItem(record.getLevel()).isSelected() &&
_categoryExplorerTree.getExplorerModel().isCategoryPathActive(path);
}
};
return result;
|
protected javax.swing.JCheckBoxMenuItem | createLogTableColumnMenuItem(org.apache.log4j.lf5.viewer.LogTableColumn column)
JCheckBoxMenuItem result = new JCheckBoxMenuItem(column.toString());
result.setSelected(true);
result.setMnemonic(column.toString().charAt(0));
result.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
// update list of columns and reset the view
List selectedColumns = updateView();
_table.setView(selectedColumns);
}
});
return result;
|
protected void | createMRUFileListMI(javax.swing.JMenu menu)Creates a Most Recently Used file list to be
displayed in the File menu
String[] files = _mruFileManager.getMRUFileList();
if (files != null) {
menu.addSeparator();
for (int i = 0; i < files.length; i++) {
JMenuItem result = new JMenuItem((i + 1) + " " + files[i]);
result.setMnemonic(i + 1);
result.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
requestOpenMRU(e);
}
});
menu.add(result);
}
}
|
protected javax.swing.JMenuBar | createMenuBar()
JMenuBar menuBar = new JMenuBar();
menuBar.add(createFileMenu());
menuBar.add(createEditMenu());
menuBar.add(createLogLevelMenu());
menuBar.add(createViewMenu());
menuBar.add(createConfigureMenu());
menuBar.add(createHelpMenu());
return (menuBar);
|
protected javax.swing.JCheckBoxMenuItem | createMenuItem(org.apache.log4j.lf5.LogLevel level)
JCheckBoxMenuItem result = new JCheckBoxMenuItem(level.toString());
result.setSelected(true);
result.setMnemonic(level.toString().charAt(0));
result.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
_table.getFilteredLogTableModel().refresh();
updateStatusLabel();
}
});
return result;
|
protected org.apache.log4j.lf5.LogRecordFilter | createNDCLogRecordFilter(java.lang.String text)
_NDCTextFilter = text;
LogRecordFilter result = new LogRecordFilter() {
public boolean passes(LogRecord record) {
String NDC = record.getNDC();
CategoryPath path = new CategoryPath(record.getCategory());
if (NDC == null || _NDCTextFilter == null) {
return false;
} else if (NDC.toLowerCase().indexOf(_NDCTextFilter.toLowerCase()) == -1) {
return false;
} else {
return getMenuItem(record.getLevel()).isSelected() &&
_categoryExplorerTree.getExplorerModel().isCategoryPathActive(path);
}
}
};
return result;
|
protected javax.swing.JMenuItem | createNoLogLevelsMenuItem()
JMenuItem result = new JMenuItem("Hide all LogLevels");
result.setMnemonic('h");
result.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
selectAllLogLevels(false);
_table.getFilteredLogTableModel().refresh();
updateStatusLabel();
}
});
return result;
|
protected javax.swing.JMenuItem | createNoLogTableColumnsMenuItem()
JMenuItem result = new JMenuItem("Hide all Columns");
result.setMnemonic('h");
result.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
selectAllLogTableColumns(false);
// update list of columns and reset the view
List selectedColumns = updateView();
_table.setView(selectedColumns);
}
});
return result;
|
protected javax.swing.JMenuItem | createOpenMI()Menu item added to allow log files to be opened with
the LF5 GUI.
JMenuItem result = new JMenuItem("Open...");
result.setMnemonic('o");
result.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
requestOpen();
}
});
return result;
|
protected javax.swing.JMenuItem | createOpenURLMI()Menu item added to allow log files loaded from a URL
to be opened by the LF5 GUI.
JMenuItem result = new JMenuItem("Open URL...");
result.setMnemonic('u");
result.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
requestOpenURL();
}
});
return result;
|
protected javax.swing.JMenuItem | createResetLogLevelColorMenuItem()
JMenuItem result = new JMenuItem("Reset LogLevel Colors");
result.setMnemonic('r");
result.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
// reset the level colors in the map
LogLevel.resetLogLevelColorMap();
// refresh the table
_table.getFilteredLogTableModel().refresh();
}
});
return result;
|
protected javax.swing.JPanel | createStatusArea()
JPanel statusArea = new JPanel();
JLabel status =
new JLabel("No log records to display.");
_statusLabel = status;
status.setHorizontalAlignment(JLabel.LEFT);
statusArea.setBorder(BorderFactory.createEtchedBorder());
statusArea.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
statusArea.add(status);
return (statusArea);
|
protected javax.swing.JMenuItem | createSubMenuItem(org.apache.log4j.lf5.LogLevel level)
final JMenuItem result = new JMenuItem(level.toString());
final LogLevel logLevel = level;
result.setMnemonic(level.toString().charAt(0));
result.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
showLogLevelColorChangeDialog(result, logLevel);
}
});
return result;
|
protected javax.swing.JToolBar | createToolBar()
JToolBar tb = new JToolBar();
tb.putClientProperty("JToolBar.isRollover", Boolean.TRUE);
JComboBox fontCombo = new JComboBox();
JComboBox fontSizeCombo = new JComboBox();
_fontSizeCombo = fontSizeCombo;
ClassLoader cl = this.getClass().getClassLoader();
if(cl == null) {
cl = ClassLoader.getSystemClassLoader();
}
URL newIconURL = cl.getResource("org/apache/log4j/lf5/viewer/" +
"images/channelexplorer_new.gif");
ImageIcon newIcon = null;
if (newIconURL != null) {
newIcon = new ImageIcon(newIconURL);
}
JButton newButton = new JButton("Clear Log Table");
if (newIcon != null) {
newButton.setIcon(newIcon);
}
newButton.setToolTipText("Clear Log Table.");
//newButton.setBorder(BorderFactory.createEtchedBorder());
newButton.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
_table.clearLogRecords();
_categoryExplorerTree.getExplorerModel().resetAllNodeCounts();
updateStatusLabel();
clearDetailTextArea();
LogRecord.resetSequenceNumber();
}
}
);
Toolkit tk = Toolkit.getDefaultToolkit();
// This will actually grab all the fonts
String[] fonts;
if (_loadSystemFonts) {
fonts = GraphicsEnvironment.
getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
} else {
fonts = tk.getFontList();
}
for (int j = 0; j < fonts.length; j++) {
fontCombo.addItem(fonts[j]);
}
fontCombo.setSelectedItem(_fontName);
fontCombo.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
JComboBox box = (JComboBox) e.getSource();
String font = (String) box.getSelectedItem();
_table.setFont(new Font(font, Font.PLAIN, _fontSize));
_fontName = font;
}
}
);
fontSizeCombo.addItem("8");
fontSizeCombo.addItem("9");
fontSizeCombo.addItem("10");
fontSizeCombo.addItem("12");
fontSizeCombo.addItem("14");
fontSizeCombo.addItem("16");
fontSizeCombo.addItem("18");
fontSizeCombo.addItem("24");
fontSizeCombo.setSelectedItem(String.valueOf(_fontSize));
fontSizeCombo.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
JComboBox box = (JComboBox) e.getSource();
String size = (String) box.getSelectedItem();
int s = Integer.valueOf(size).intValue();
setFontSizeSilently(s);
refreshDetailTextArea();
_fontSize = s;
}
}
);
tb.add(new JLabel(" Font: "));
tb.add(fontCombo);
tb.add(fontSizeCombo);
tb.addSeparator();
tb.addSeparator();
tb.add(newButton);
newButton.setAlignmentY(0.5f);
newButton.setAlignmentX(0.5f);
fontCombo.setMaximumSize(fontCombo.getPreferredSize());
fontSizeCombo.setMaximumSize(
fontSizeCombo.getPreferredSize());
return (tb);
|
protected javax.swing.JMenu | createViewMenu()
JMenu result = new JMenu("View");
result.setMnemonic('v");
Iterator columns = getLogTableColumns();
while (columns.hasNext()) {
result.add(getLogTableColumnMenuItem((LogTableColumn) columns.next()));
}
result.addSeparator();
result.add(createAllLogTableColumnsMenuItem());
result.add(createNoLogTableColumnsMenuItem());
return result;
|
public void | dispose()Dispose of the frame for the LogBrokerMonitor.
_logMonitorFrame.dispose();
_isDisposed = true;
if (_callSystemExitOnClose == true) {
System.exit(0);
}
|
protected int | findRecord(int startRow, java.lang.String searchText, java.util.List records)
if (startRow < 0) {
startRow = 0; // start at first element if no rows are selected
} else {
startRow++; // start after the first selected row
}
int len = records.size();
for (int i = startRow; i < len; i++) {
if (matches((LogRecord) records.get(i), searchText)) {
return i; // found a record
}
}
// wrap around to beginning if when we reach the end with no match
len = startRow;
for (int i = 0; i < len; i++) {
if (matches((LogRecord) records.get(i), searchText)) {
return i; // found a record
}
}
// nothing found
return -1;
|
protected void | findSearchText()
String text = _searchText;
if (text == null || text.length() == 0) {
return;
}
int startRow = getFirstSelectedRow();
int foundRow = findRecord(
startRow,
text,
_table.getFilteredLogTableModel().getFilteredRecords()
);
selectRow(foundRow);
|
public javax.swing.JFrame | getBaseFrame()
return _logMonitorFrame;
|
public boolean | getCallSystemExitOnClose()Get the value of whether or not System.exit() will be called
when the LogBrokerMonitor is closed.
return _callSystemExitOnClose;
|
public org.apache.log4j.lf5.viewer.categoryexplorer.CategoryExplorerTree | getCategoryExplorerTree()
return _categoryExplorerTree;
|
public org.apache.log4j.lf5.util.DateFormatManager | getDateFormatManager()Get the DateFormatManager for formatting dates.
return _table.getDateFormatManager();
|
protected int | getFirstSelectedRow()
return _table.getSelectionModel().getMinSelectionIndex();
|
public java.util.Map | getLogLevelMenuItems()
return _logLevelMenuItems;
|
protected java.util.Iterator | getLogLevels()
return _levels.iterator();
|
protected javax.swing.JCheckBoxMenuItem | getLogTableColumnMenuItem(org.apache.log4j.lf5.viewer.LogTableColumn column)
JCheckBoxMenuItem result = (JCheckBoxMenuItem) (_logTableColumnMenuItems.get(column));
if (result == null) {
result = createLogTableColumnMenuItem(column);
_logTableColumnMenuItems.put(column, result);
}
return result;
|
public java.util.Map | getLogTableColumnMenuItems()
return _logTableColumnMenuItems;
|
protected java.util.Iterator | getLogTableColumns()
return _columns.iterator();
|
protected javax.swing.JCheckBoxMenuItem | getMenuItem(org.apache.log4j.lf5.LogLevel level)
JCheckBoxMenuItem result = (JCheckBoxMenuItem) (_logLevelMenuItems.get(level));
if (result == null) {
result = createMenuItem(level);
_logLevelMenuItems.put(level, result);
}
return result;
|
public java.lang.String | getNDCTextFilter()
return _NDCTextFilter;
|
protected java.lang.String | getRecordsDisplayedMessage()
FilteredLogTableModel model = _table.getFilteredLogTableModel();
return getStatusText(model.getRowCount(), model.getTotalRowCount());
|
protected java.lang.String | getStatusText(int displayedRows, int totalRows)
StringBuffer result = new StringBuffer();
result.append("Displaying: ");
result.append(displayedRows);
result.append(" records out of a total of: ");
result.append(totalRows);
result.append(" records.");
return result.toString();
|
public javax.swing.JCheckBoxMenuItem | getTableColumnMenuItem(org.apache.log4j.lf5.viewer.LogTableColumn column)
return getLogTableColumnMenuItem(column);
|
public void | hide()Hide the frame for the LogBrokerMonitor.
_logMonitorFrame.setVisible(false);
|
protected void | initComponents()
//
// Configure the Frame.
//
_logMonitorFrame = new JFrame("LogFactor5");
_logMonitorFrame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
String resource =
"/org/apache/log4j/lf5/viewer/images/lf5_small_icon.gif";
URL lf5IconURL = getClass().getResource(resource);
if (lf5IconURL != null) {
_logMonitorFrame.setIconImage(new ImageIcon(lf5IconURL).getImage());
}
updateFrameSize();
//
// Configure the LogTable.
//
JTextArea detailTA = createDetailTextArea();
JScrollPane detailTAScrollPane = new JScrollPane(detailTA);
_table = new LogTable(detailTA);
setView(_currentView, _table);
_table.setFont(new Font(_fontName, Font.PLAIN, _fontSize));
_logTableScrollPane = new JScrollPane(_table);
if (_trackTableScrollPane) {
_logTableScrollPane.getVerticalScrollBar().addAdjustmentListener(
new TrackingAdjustmentListener()
);
}
// Configure the SplitPane between the LogTable & DetailTextArea
//
JSplitPane tableViewerSplitPane = new JSplitPane();
tableViewerSplitPane.setOneTouchExpandable(true);
tableViewerSplitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
tableViewerSplitPane.setLeftComponent(_logTableScrollPane);
tableViewerSplitPane.setRightComponent(detailTAScrollPane);
// Make sure to do this last..
//tableViewerSplitPane.setDividerLocation(1.0); Doesn't work
//the same under 1.2.x & 1.3
// "350" is a magic number that provides the correct default
// behaviour under 1.2.x & 1.3. For example, bumping this
// number to 400, causes the pane to be completely open in 1.2.x
// and closed in 1.3
tableViewerSplitPane.setDividerLocation(350);
//
// Configure the CategoryExplorer
//
_categoryExplorerTree = new CategoryExplorerTree();
_table.getFilteredLogTableModel().setLogRecordFilter(createLogRecordFilter());
JScrollPane categoryExplorerTreeScrollPane =
new JScrollPane(_categoryExplorerTree);
categoryExplorerTreeScrollPane.setPreferredSize(new Dimension(130, 400));
// Load most recently used file list
_mruFileManager = new MRUFileManager();
//
// Configure the SplitPane between the CategoryExplorer & (LogTable/Detail)
//
JSplitPane splitPane = new JSplitPane();
splitPane.setOneTouchExpandable(true);
splitPane.setRightComponent(tableViewerSplitPane);
splitPane.setLeftComponent(categoryExplorerTreeScrollPane);
// Do this last.
splitPane.setDividerLocation(130);
//
// Add the MenuBar, StatusArea, CategoryExplorer|LogTable to the
// LogMonitorFrame.
//
_logMonitorFrame.getRootPane().setJMenuBar(createMenuBar());
_logMonitorFrame.getContentPane().add(splitPane, BorderLayout.CENTER);
_logMonitorFrame.getContentPane().add(createToolBar(),
BorderLayout.NORTH);
_logMonitorFrame.getContentPane().add(createStatusArea(),
BorderLayout.SOUTH);
makeLogTableListenToCategoryExplorer();
addTableModelProperties();
//
// Configure ConfigurationManager
//
_configurationManager = new ConfigurationManager(this, _table);
|
protected boolean | loadLogFile(java.io.File file)Loads and parses a log file.
boolean ok = false;
try {
LogFileParser lfp = new LogFileParser(file);
lfp.parse(this);
ok = true;
} catch (IOException e) {
LogFactor5ErrorDialog error = new LogFactor5ErrorDialog(
getBaseFrame(), "Error reading " + file.getName());
}
return ok;
|
protected boolean | loadLogFile(java.net.URL url)Loads a parses a log file running on a server.
boolean ok = false;
try {
LogFileParser lfp = new LogFileParser(url.openStream());
lfp.parse(this);
ok = true;
} catch (IOException e) {
LogFactor5ErrorDialog error = new LogFactor5ErrorDialog(
getBaseFrame(), "Error reading URL:" + url.getFile());
}
return ok;
|
protected void | makeLogTableListenToCategoryExplorer()
ActionListener listener = new ActionListener() {
public void actionPerformed(ActionEvent e) {
_table.getFilteredLogTableModel().refresh();
updateStatusLabel();
}
};
_categoryExplorerTree.getExplorerModel().addActionListener(listener);
|
protected boolean | matches(org.apache.log4j.lf5.LogRecord record, java.lang.String text)Check to see if the any records contain the search string.
Searching now supports NDC messages and date.
String message = record.getMessage();
String NDC = record.getNDC();
if (message == null && NDC == null || text == null) {
return false;
}
if (message.toLowerCase().indexOf(text.toLowerCase()) == -1 &&
NDC.toLowerCase().indexOf(text.toLowerCase()) == -1) {
return false;
}
return true;
|
protected void | pause(int millis)
try {
Thread.sleep(millis);
} catch (InterruptedException e) {
}
|
protected void | refresh(javax.swing.JTextArea textArea)When the fontsize of a JTextArea is changed, the word-wrapped lines
may become garbled. This method clears and resets the text of the
text area.
String text = textArea.getText();
textArea.setText("");
textArea.setText(text);
|
protected void | refreshDetailTextArea()
refresh(_table._detailTextArea);
|
protected void | requestClose()
setCallSystemExitOnClose(false);
closeAfterConfirm();
|
protected void | requestExit()
_mruFileManager.save();
setCallSystemExitOnClose(true);
closeAfterConfirm();
|
protected void | requestOpen()Uses a JFileChooser to select a file to opened with the
LF5 GUI.
JFileChooser chooser;
if (_fileLocation == null) {
chooser = new JFileChooser();
} else {
chooser = new JFileChooser(_fileLocation);
}
int returnVal = chooser.showOpenDialog(_logMonitorFrame);
if (returnVal == JFileChooser.APPROVE_OPTION) {
File f = chooser.getSelectedFile();
if (loadLogFile(f)) {
_fileLocation = chooser.getSelectedFile();
_mruFileManager.set(f);
updateMRUList();
}
}
|
protected void | requestOpenMRU(java.awt.event.ActionEvent e)Opens a file in the MRU list.
String file = e.getActionCommand();
StringTokenizer st = new StringTokenizer(file);
String num = st.nextToken().trim();
file = st.nextToken("\n");
try {
int index = Integer.parseInt(num) - 1;
InputStream in = _mruFileManager.getInputStream(index);
LogFileParser lfp = new LogFileParser(in);
lfp.parse(this);
_mruFileManager.moveToTop(index);
updateMRUList();
} catch (Exception me) {
LogFactor5ErrorDialog error = new LogFactor5ErrorDialog(
getBaseFrame(), "Unable to load file " + file);
}
|
protected void | requestOpenURL()Uses a Dialog box to accept a URL to a file to be opened
with the LF5 GUI.
LogFactor5InputDialog inputDialog = new LogFactor5InputDialog(
getBaseFrame(), "Open URL", "URL:");
String temp = inputDialog.getText();
if (temp != null) {
if (temp.indexOf("://") == -1) {
temp = "http://" + temp;
}
try {
URL url = new URL(temp);
if (loadLogFile(url)) {
_mruFileManager.set(url);
updateMRUList();
}
} catch (MalformedURLException e) {
LogFactor5ErrorDialog error = new LogFactor5ErrorDialog(
getBaseFrame(), "Error reading URL.");
}
}
|
protected void | resetConfiguration()
_configurationManager.reset();
|
protected void | saveConfiguration()
_configurationManager.save();
|
protected void | selectAllLogLevels(boolean selected)
Iterator levels = getLogLevels();
while (levels.hasNext()) {
getMenuItem((LogLevel) levels.next()).setSelected(selected);
}
|
protected void | selectAllLogTableColumns(boolean selected)
Iterator columns = getLogTableColumns();
while (columns.hasNext()) {
getLogTableColumnMenuItem((LogTableColumn) columns.next()).setSelected(selected);
}
|
protected void | selectRow(int foundRow)
if (foundRow == -1) {
String message = _searchText + " not found.";
JOptionPane.showMessageDialog(
_logMonitorFrame,
message,
"Text not found",
JOptionPane.INFORMATION_MESSAGE
);
return;
}
LF5SwingUtils.selectRow(foundRow, _table, _logTableScrollPane);
|
public void | setCallSystemExitOnClose(boolean callSystemExitOnClose)Set the value of whether or not System.exit() will be called
when the LogBrokerMonitor is closed.
_callSystemExitOnClose = callSystemExitOnClose;
|
public void | setDateFormatManager(org.apache.log4j.lf5.util.DateFormatManager dfm)Set the date format manager for formatting dates.
_table.setDateFormatManager(dfm);
|
public void | setFontSize(int fontSize)
changeFontSizeCombo(_fontSizeCombo, fontSize);
// setFontSizeSilently(actualFontSize); - changeFontSizeCombo fires event
// refreshDetailTextArea();
|
protected void | setFontSize(java.awt.Component component, int fontSize)
Font oldFont = component.getFont();
Font newFont =
new Font(oldFont.getFontName(), oldFont.getStyle(), fontSize);
component.setFont(newFont);
|
protected void | setFontSizeSilently(int fontSize)Does not update gui or cause any events to be fired.
_fontSize = fontSize;
setFontSize(_table._detailTextArea, fontSize);
selectRow(0);
setFontSize(_table, fontSize);
|
public void | setFrameSize(int width, int height)
Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
if (0 < width && width < screen.width) {
_logMonitorFrameWidth = width;
}
if (0 < height && height < screen.height) {
_logMonitorFrameHeight = height;
}
updateFrameSize();
|
protected void | setLeastSevereDisplayedLogLevel(org.apache.log4j.lf5.LogLevel level)
if (level == null || _leastSevereDisplayedLogLevel == level) {
return; // nothing to do
}
_leastSevereDisplayedLogLevel = level;
_table.getFilteredLogTableModel().refresh();
updateStatusLabel();
|
public void | setMaxNumberOfLogRecords(int maxNumberOfLogRecords)
_table.getFilteredLogTableModel().setMaxNumberOfLogRecords(maxNumberOfLogRecords);
|
protected void | setMaxRecordConfiguration()
LogFactor5InputDialog inputDialog = new LogFactor5InputDialog(
getBaseFrame(), "Set Max Number of Records", "", 10);
String temp = inputDialog.getText();
if (temp != null) {
try {
setMaxNumberOfLogRecords(Integer.parseInt(temp));
} catch (NumberFormatException e) {
LogFactor5ErrorDialog error = new LogFactor5ErrorDialog(
getBaseFrame(),
"'" + temp + "' is an invalid parameter.\nPlease try again.");
setMaxRecordConfiguration();
}
}
|
public void | setNDCLogRecordFilter(java.lang.String textFilter)
_table.getFilteredLogTableModel().
setLogRecordFilter(createNDCLogRecordFilter(textFilter));
|
protected void | setNDCTextFilter(java.lang.String text)
// if no value is set, set it to a blank string
// otherwise use the value provided
if (text == null) {
_NDCTextFilter = "";
} else {
_NDCTextFilter = text;
}
|
protected void | setSearchText(java.lang.String text)
_searchText = text;
|
public void | setTitle(java.lang.String title)
_logMonitorFrame.setTitle(title + " - LogFactor5");
|
protected void | setView(java.lang.String viewString, org.apache.log4j.lf5.viewer.LogTable table)
if (DETAILED_VIEW.equals(viewString)) {
table.setDetailedView();
} else {
String message = viewString + "does not match a supported view.";
throw new IllegalArgumentException(message);
}
_currentView = viewString;
|
public void | show(int delay)Show the frame for the LogBrokerMonitor. Dispatched to the
swing thread.
if (_logMonitorFrame.isVisible()) {
return;
}
// This request is very low priority, let other threads execute first.
SwingUtilities.invokeLater(new Runnable() {
public void run() {
Thread.yield();
pause(delay);
_logMonitorFrame.setVisible(true);
}
});
|
public void | show()
show(0);
|
protected void | showLogLevelColorChangeDialog(javax.swing.JMenuItem result, org.apache.log4j.lf5.LogLevel level)
JMenuItem menuItem = result;
Color newColor = JColorChooser.showDialog(
_logMonitorFrame,
"Choose LogLevel Color",
result.getForeground());
if (newColor != null) {
// set the color for the record
level.setLogLevelColorMap(level, newColor);
_table.getFilteredLogTableModel().refresh();
}
|
protected void | showPropertiesDialog(java.lang.String title)
JOptionPane.showMessageDialog(
_logMonitorFrame,
_displayedLogBrokerProperties.toArray(),
title,
JOptionPane.PLAIN_MESSAGE
);
|
protected void | sortByNDC()
String text = _NDCTextFilter;
if (text == null || text.length() == 0) {
return;
}
// Use new NDC filter
_table.getFilteredLogTableModel().
setLogRecordFilter(createNDCLogRecordFilter(text));
|
protected void | trackTableScrollPane()Ensures that the Table's ScrollPane Viewport will "track" with updates
to the Table. When the vertical scroll bar is at its bottom anchor
and tracking is enabled then viewport will stay at the bottom most
point of the component. The purpose of this feature is to allow
a developer to watch the table as messages arrive and not have to
scroll after each new message arrives. When the vertical scroll bar
is at any other location, then no tracking will happen.
// do nothing
|
protected void | updateFrameSize()
_logMonitorFrame.setSize(_logMonitorFrameWidth, _logMonitorFrameHeight);
centerFrame(_logMonitorFrame);
|
protected void | updateMRUList()Removes old file list and creates a new file list
with the updated MRU list.
JMenu menu = _logMonitorFrame.getJMenuBar().getMenu(0);
menu.removeAll();
menu.add(createOpenMI());
menu.add(createOpenURLMI());
menu.addSeparator();
menu.add(createCloseMI());
createMRUFileListMI(menu);
menu.addSeparator();
menu.add(createExitMI());
|
protected void | updateStatusLabel()
_statusLabel.setText(getRecordsDisplayedMessage());
|
protected java.util.List | updateView()
ArrayList updatedList = new ArrayList();
Iterator columnIterator = _columns.iterator();
while (columnIterator.hasNext()) {
LogTableColumn column = (LogTableColumn) columnIterator.next();
JCheckBoxMenuItem result = getLogTableColumnMenuItem(column);
// check and see if the checkbox is checked
if (result.isSelected()) {
updatedList.add(column);
}
}
return updatedList;
|