* Return a toolbar used by the undocked LogPanel's frame
*
* @return toolbar
*/
private JToolBar createDockwindowToolbar() {
final JToolBar toolbar = new JToolBar();
toolbar.setFloatable(false);
final Action dockPauseAction =
new AbstractAction("Pause") {
public void actionPerformed(ActionEvent evt) {
setPaused(!isPaused());
}
};
dockPauseAction.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_P));
dockPauseAction.putValue(
Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke("F12"));
dockPauseAction.putValue(
Action.SHORT_DESCRIPTION,
"Halts the display, while still allowing events to stream in the background");
dockPauseAction.putValue(
Action.SMALL_ICON, new ImageIcon(ChainsawIcons.PAUSE));
final SmallToggleButton dockPauseButton =
new SmallToggleButton(dockPauseAction);
dockPauseButton.setText("");
dockPauseButton.getModel().setSelected(isPaused());
addPropertyChangeListener(
"paused",
new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) {
dockPauseButton.getModel().setSelected(isPaused());
}
});
toolbar.add(dockPauseButton);
Action dockShowPrefsAction =
new AbstractAction("") {
public void actionPerformed(ActionEvent arg0) {
showPreferences();
}
};
dockShowPrefsAction.putValue(
Action.SHORT_DESCRIPTION, "Define preferences...");
dockShowPrefsAction.putValue(
Action.SMALL_ICON, ChainsawIcons.ICON_PREFERENCES);
toolbar.add(new SmallButton(dockShowPrefsAction));
Action dockToggleLogTreeAction =
new AbstractAction() {
public void actionPerformed(ActionEvent e) {
toggleLogTreeVisible();
}
};
dockToggleLogTreeAction.putValue(Action.SHORT_DESCRIPTION, "Toggles the Logger Tree Pane");
dockToggleLogTreeAction.putValue("enabled", Boolean.TRUE);
dockToggleLogTreeAction.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_T));
dockToggleLogTreeAction.putValue(
Action.ACCELERATOR_KEY,
KeyStroke.getKeyStroke(KeyEvent.VK_T, InputEvent.ALT_MASK));
dockToggleLogTreeAction.putValue(
Action.SMALL_ICON, new ImageIcon(ChainsawIcons.WINDOW_ICON));
final SmallToggleButton toggleLogTreeButton =
new SmallToggleButton(dockToggleLogTreeAction);
preferenceModel.addPropertyChangeListener("logTreePanelVisible", new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) {
toggleLogTreeButton.setSelected(preferenceModel.isLogTreePanelVisible());
}
});
toggleLogTreeButton.setSelected(isLogTreeVisible());
toolbar.add(toggleLogTreeButton);
toolbar.addSeparator();
final Action undockedClearAction =
new AbstractAction("Clear") {
public void actionPerformed(ActionEvent arg0) {
clearModel();
}
};
undockedClearAction.putValue(
Action.SMALL_ICON, new ImageIcon(ChainsawIcons.DELETE));
undockedClearAction.putValue(
Action.SHORT_DESCRIPTION, "Removes all the events from the current view");
final SmallButton dockClearButton = new SmallButton(undockedClearAction);
dockClearButton.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(
KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, InputEvent.CTRL_MASK),
undockedClearAction.getValue(Action.NAME));
dockClearButton.getActionMap().put(
undockedClearAction.getValue(Action.NAME), undockedClearAction);
dockClearButton.setText("");
toolbar.add(dockClearButton);
toolbar.addSeparator();
Action dockToggleScrollToBottomAction =
new AbstractAction("Toggles Scroll to Bottom") {
public void actionPerformed(ActionEvent e) {
toggleScrollToBottom();
}
};
dockToggleScrollToBottomAction.putValue(Action.SHORT_DESCRIPTION, "Toggles Scroll to Bottom");
dockToggleScrollToBottomAction.putValue("enabled", Boolean.TRUE);
dockToggleScrollToBottomAction.putValue(
Action.SMALL_ICON, new ImageIcon(ChainsawIcons.SCROLL_TO_BOTTOM));
final SmallToggleButton toggleScrollToBottomButton =
new SmallToggleButton(dockToggleScrollToBottomAction);
preferenceModel.addPropertyChangeListener("scrollToBottom", new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) {
toggleScrollToBottomButton.setSelected(preferenceModel.isScrollToBottom());
}
});
toggleScrollToBottomButton.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(
KeyStroke.getKeyStroke(KeyEvent.VK_B, InputEvent.CTRL_MASK),
dockToggleScrollToBottomAction.getValue(Action.NAME));
toggleScrollToBottomButton.getActionMap().put(
dockToggleScrollToBottomAction.getValue(Action.NAME), dockToggleScrollToBottomAction);
toggleScrollToBottomButton.setSelected(isScrollToBottom());
toggleScrollToBottomButton.setText("");
toolbar.add(toggleScrollToBottomButton);
toolbar.addSeparator();
findField = new JTextField();
findField.addKeyListener(
new ExpressionRuleContext(filterModel, findField));
final Action undockedFindNextAction =
new AbstractAction() {
public void actionPerformed(ActionEvent e) {
findNext();
}
};
undockedFindNextAction.putValue(Action.NAME, "Find next");
undockedFindNextAction.putValue(
Action.SHORT_DESCRIPTION,
"Find the next occurrence of the rule from the current row");
undockedFindNextAction.putValue(
Action.SMALL_ICON, new ImageIcon(ChainsawIcons.DOWN));
SmallButton undockedFindNextButton =
new SmallButton(undockedFindNextAction);
undockedFindNextButton.setAction(undockedFindNextAction);
undockedFindNextButton.setText("");
undockedFindNextButton.getActionMap().put(
undockedFindNextAction.getValue(Action.NAME), undockedFindNextAction);
undockedFindNextButton.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(
KeyStroke.getKeyStroke("F3"),
undockedFindNextAction.getValue(Action.NAME));
final Action undockedFindPreviousAction =
new AbstractAction() {
public void actionPerformed(ActionEvent e) {
findPrevious();
}
};
undockedFindPreviousAction.putValue(Action.NAME, "Find previous");
undockedFindPreviousAction.putValue(
Action.SHORT_DESCRIPTION,
"Find the previous occurrence of the rule from the current row");
undockedFindPreviousAction.putValue(
Action.SMALL_ICON, new ImageIcon(ChainsawIcons.UP));
SmallButton undockedFindPreviousButton =
new SmallButton(undockedFindPreviousAction);
undockedFindPreviousButton.setAction(undockedFindPreviousAction);
undockedFindPreviousButton.setText("");
undockedFindPreviousButton.getActionMap().put(
undockedFindPreviousAction.getValue(Action.NAME),
undockedFindPreviousAction);
undockedFindPreviousButton.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)
.put(
KeyStroke.getKeyStroke(KeyEvent.VK_F3, KeyEvent.SHIFT_MASK),
undockedFindPreviousAction.getValue(Action.NAME));
Dimension findSize = new Dimension(170, 22);
Dimension findPanelSize = new Dimension(175, 30);
findPanel.setPreferredSize(findPanelSize);
findPanel.setMaximumSize(findPanelSize);
findPanel.setMinimumSize(findPanelSize);
findField.setPreferredSize(findSize);
findField.setMaximumSize(findSize);
findField.setMinimumSize(findSize);
findPanel.setAlignmentY(Component.CENTER_ALIGNMENT);
findField.setAlignmentY(Component.CENTER_ALIGNMENT);
toolbar.add(findPanel);
toolbar.add(undockedFindNextButton);
toolbar.add(undockedFindPreviousButton);
toolbar.addSeparator();
Action redockAction =
new AbstractAction("", ChainsawIcons.ICON_DOCK) {
public void actionPerformed(ActionEvent arg0) {
dock();
}
};
redockAction.putValue(
Action.SHORT_DESCRIPTION,
"Docks this window back with the main Chainsaw window");
SmallButton redockButton = new SmallButton(redockAction);
toolbar.add(redockButton);
return toolbar;
}