dfBG.add(simpleTimeButton);
isoButton.setSelected(true);
dateFormatChangePopup.add(isoButton);
dateFormatChangePopup.add(simpleTimeButton);
final JCheckBoxMenuItem menuItemToggleToolTips =
new JCheckBoxMenuItem("Show ToolTips");
menuItemToggleToolTips.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent evt) {
preferenceModel.setToolTips(menuItemToggleToolTips.isSelected());
}
});
menuItemToggleToolTips.setIcon(new ImageIcon(ChainsawIcons.TOOL_TIP));
final JCheckBoxMenuItem menuItemLoggerTree =
new JCheckBoxMenuItem("Show Logger Tree panel");
menuItemLoggerTree.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
preferenceModel.setLogTreePanelVisible(
menuItemLoggerTree.isSelected());
}
});
menuItemLoggerTree.setIcon(new ImageIcon(ChainsawIcons.WINDOW_ICON));
final JCheckBoxMenuItem menuItemScrollBottom =
new JCheckBoxMenuItem("Scroll to bottom");
menuItemScrollBottom.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent evt) {
preferenceModel.setScrollToBottom(menuItemScrollBottom.isSelected());
}
});
menuItemScrollBottom.setIcon(
new ImageIcon(ChainsawIcons.SCROLL_TO_BOTTOM));
final JCheckBoxMenuItem menuItemToggleDetails =
new JCheckBoxMenuItem("Show Detail Pane");
menuItemToggleDetails.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
preferenceModel.setDetailPaneVisible(
menuItemToggleDetails.isSelected());
}
});
menuItemToggleDetails.setIcon(new ImageIcon(ChainsawIcons.INFO));
/*
* add preferencemodel listeners
*/
preferenceModel.addPropertyChangeListener(
"levelIcons",
new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) {
renderer.setLevelUseIcons(
((Boolean) evt.getNewValue()).booleanValue());
table.tableChanged(new TableModelEvent(tableModel));
}
});
preferenceModel.addPropertyChangeListener(
"detailPaneVisible",
new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) {
boolean newValue = ((Boolean) evt.getNewValue()).booleanValue();
if (newValue) {
showDetailPane();
} else {
hideDetailPane();
}
}
});
preferenceModel.addPropertyChangeListener(
"logTreePanelVisible",
new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) {
boolean newValue = ((Boolean) evt.getNewValue()).booleanValue();
if (newValue) {
showLogTreePanel();
} else {
hideLogTreePanel();
}
}
});
preferenceModel.addPropertyChangeListener(
"toolTips",
new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) {
renderer.setToolTipsVisible(
((Boolean) evt.getNewValue()).booleanValue());
}
});
preferenceModel.addPropertyChangeListener(
"visibleColumns",
new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) {
TableColumnModel columnModel = table.getColumnModel();
for (int i = 0; i < columnModel.getColumnCount(); i++) {
TableColumn column = columnModel.getColumn(i);
if (
!preferenceModel.isColumnVisible(
column.getHeaderValue().toString())) {
columnModel.removeColumn(column);
}
}
Set columnSet = new HashSet();
Enumeration enumeration = columnModel.getColumns();
while (enumeration.hasMoreElements()) {
TableColumn column = (TableColumn) enumeration.nextElement();
columnSet.add(column.getHeaderValue());
}
for (
Iterator iter = ChainsawColumns.getColumnsNames().iterator();
iter.hasNext();) {
String column = (String) iter.next();
if (
preferenceModel.isColumnVisible(column)
&& !columnSet.contains(column)) {
TableColumn newCol =
new TableColumn(
ChainsawColumns.getColumnsNames().indexOf(column));
newCol.setHeaderValue(column);
columnModel.addColumn(newCol);
}
}
}
});
PropertyChangeListener datePrefsChangeListener =
new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) {
LogPanelPreferenceModel model =
(LogPanelPreferenceModel) evt.getSource();
isoButton.setSelected(model.isUseISO8601Format());
simpleTimeButton.setSelected(
!model.isUseISO8601Format() && !model.isCustomDateFormat());
if (model.isUseISO8601Format()) {
renderer.setDateFormatter(new SimpleDateFormat(Constants.ISO8601_PATTERN));
} else {
renderer.setDateFormatter(
new SimpleDateFormat(model.getDateFormatPattern()));
}
table.tableChanged(new TableModelEvent(tableModel));
}
};
preferenceModel.addPropertyChangeListener(
"dateFormatPattern", datePrefsChangeListener);
preferenceModel.addPropertyChangeListener(
"dateFormatPattern", datePrefsChangeListener);
preferenceModel.addPropertyChangeListener(
"loggerPrecision",
new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) {
LogPanelPreferenceModel model =
(LogPanelPreferenceModel) evt.getSource();
renderer.setLoggerPrecision(model.getLoggerPrecision());
table.tableChanged(new TableModelEvent(tableModel));
}
});
preferenceModel.addPropertyChangeListener(
"toolTips",
new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) {
boolean value = ((Boolean) evt.getNewValue()).booleanValue();
menuItemToggleToolTips.setSelected(value);
}
});
preferenceModel.addPropertyChangeListener(
"logTreePanelVisible",
new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) {
boolean value = ((Boolean) evt.getNewValue()).booleanValue();
menuItemLoggerTree.setSelected(value);
}
});
preferenceModel.addPropertyChangeListener(
"scrollToBottom",
new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) {
boolean value = ((Boolean) evt.getNewValue()).booleanValue();
menuItemScrollBottom.setSelected(value);
scroll = value;
if (scroll) {
table.scrollToBottom(table.columnAtPoint(table.getVisibleRect().getLocation()));
}
}
});
preferenceModel.addPropertyChangeListener(
"detailPaneVisible",
new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) {
boolean value = ((Boolean) evt.getNewValue()).booleanValue();
menuItemToggleDetails.setSelected(value);
}
});
/*
*End of preferenceModel listeners