Author: sdeboy
Date: Thu Nov 4 05:57:05 2010
New Revision: 1030840
URL: http://svn.apache.org/viewvc?rev=1030840&view=rev
Log:
Remember and set as default the last log format in the receiver config screen
Modified:
logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LogUI.java
logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/ReceiverConfigurationPanel.java
Modified: logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LogUI.java
URL: http://svn.apache.org/viewvc/logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LogUI.java?rev=1030840&r1=1030839&r2=1030840&view=diff
==============================================================================
--- logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LogUI.java (original)
+++ logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LogUI.java Thu Nov 4 05:57:05 2010
@@ -204,8 +204,9 @@ public class LogUI extends JFrame implem
private PluginRegistry pluginRegistry;
//map of tab names to rulecolorizers
private Map allColorizers = new HashMap();
+ private ReceiverConfigurationPanel receiverConfigurationPanel = new ReceiverConfigurationPanel();
- /**
+ /**
* Constructor which builds up all the visual elements of the frame including
* the Menu bar
*/
@@ -713,6 +714,9 @@ public class LogUI extends JFrame implem
RuleColorizer colorizer = new RuleColorizer();
colorizer.loadColorSettings(ChainsawConstants.DEFAULT_COLOR_RULE_NAME);
allColorizers.put(ChainsawConstants.DEFAULT_COLOR_RULE_NAME, colorizer);
+ if (event.getSetting("SavedConfig.logFormat") != null) {
+ receiverConfigurationPanel.getModel().setLogFormat(event.getSetting("SavedConfig.logFormat"));
+ }
}
/**
@@ -729,6 +733,9 @@ public class LogUI extends JFrame implem
event.saveSetting(LogUI.MAIN_WINDOW_HEIGHT, getHeight());
RuleColorizer colorizer = (RuleColorizer) allColorizers.get(ChainsawConstants.DEFAULT_COLOR_RULE_NAME);
colorizer.saveColorSettings(ChainsawConstants.DEFAULT_COLOR_RULE_NAME);
+ if (receiverConfigurationPanel.getModel().getLogFormat() != null ) {
+ event.saveSetting("SavedConfig.logFormat", receiverConfigurationPanel.getModel().getLogFormat());
+ }
}
/**
@@ -1397,58 +1404,6 @@ public class LogUI extends JFrame implem
* Displays a dialog which will provide options for selecting a configuratino
*/
private void showReceiverConfigurationPanel() {
- final ReceiverConfigurationPanel receiverConfigurationPanel =
- new ReceiverConfigurationPanel();
-
- final SettingsListener sl =
- new SettingsListener() {
- public void loadSettings(LoadSettingsEvent event) {
- if (event.getSetting("SavedConfigs.Size") != null) {
- int configSize = event.asInt("SavedConfigs.Size");
- Object[] configs = new Object[configSize];
-
- for (int i = 0; i < configSize; i++) {
- configs[i] = event.getSetting("SavedConfigs." + i);
- }
-
- receiverConfigurationPanel.getModel().setRememberedConfigs(configs);
- }
-
- if (event.getSetting("SavedLayouts.Size") != null) {
- int layoutSize = event.asInt("SavedLayouts.Size");
- Object[] layouts = new Object[layoutSize];
-
- for (int i = 0; i < layoutSize; i++) {
- layouts[i] = event.getSetting("SavedLayouts." + i);
- }
- receiverConfigurationPanel.getModel().setRememberedLayouts(layouts);
- }
- }
-
- public void saveSettings(SaveSettingsEvent event) {
- Object[] configs = receiverConfigurationPanel.getModel().getRememberedConfigs();
- event.saveSetting("SavedConfigs.Size", configs.length);
-
- for (int i = 0; i < configs.length; i++) {
- event.saveSetting("SavedConfigs." + i, configs[i].toString());
- }
- Object[] layouts = receiverConfigurationPanel.getModel().getRememberedLayouts();
- event.saveSetting("SavedLayouts.Size", layouts.length);
-
- for (int i = 0; i < layouts.length; i++) {
- //the layout is an object, not a string (containing timestamp format, pattern & pattern type)
- event.saveSetting("SavedLayouts." + i, layouts[i]);
- }
- }
- };
-
- /**
- * This listener sets up the NoReciversWarningPanel and loads saves the
- * configs/logfiles
- */
- getSettingsManager().addSettingsListener(sl);
- getSettingsManager().configure(sl);
-
SwingUtilities.invokeLater(
new Runnable() {
public void run() {
Modified: logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/ReceiverConfigurationPanel.java
URL: http://svn.apache.org/viewvc/logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/ReceiverConfigurationPanel.java?rev=1030840&r1=1030839&r2=1030840&view=diff
==============================================================================
--- logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/ReceiverConfigurationPanel.java (original)
+++ logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/ReceiverConfigurationPanel.java Thu Nov 4 05:57:05 2010
@@ -236,7 +236,7 @@ class ReceiverConfigurationPanel extends
{
public void actionPerformed(ActionEvent e)
{
- panelModel.setCancelled();
+ panelModel.setCancelled(true);
completionActionListener.actionPerformed(new ActionEvent(this, -1, "cancelled"));
}
});
@@ -245,6 +245,10 @@ class ReceiverConfigurationPanel extends
{
public void actionPerformed(ActionEvent e)
{
+ panelModel.setCancelled(false);
+ if (logFileFormatComboBox.getSelectedItem() != null && !(logFileFormatComboBox.getSelectedItem().toString().trim().equals(""))) {
+ panelModel.setLogFormat(logFileFormatComboBox.getSelectedItem().toString());
+ }
completionActionListener.actionPerformed(new ActionEvent(this, -1, "cancelled"));
}
});
@@ -392,6 +396,7 @@ class ReceiverConfigurationPanel extends
logFileFormatComboBox = new JComboBox(logFileFormatComboBoxModel);
logFileFormatComboBox.setEditable(true);
logFileFormatComboBox.setOpaque(false);
+ logFileFormatComboBox.setSelectedIndex(0);
c = new GridBagConstraints();
c.gridx = 1;
@@ -632,10 +637,12 @@ class ReceiverConfigurationPanel extends
*/
class PanelModel {
- private File file;
- private boolean cancelled;
+ private File file;
+ //default to cancelled
+ private boolean cancelled = true;
+ private String lastLogFormat;
- public PanelModel(){
+ public PanelModel(){
file = new File(SettingsManager.getInstance().getSettingsDirectory(), "receiver-config.xml");
}
@@ -667,29 +674,6 @@ class ReceiverConfigurationPanel extends
return !cancelled && logFileReceiverRadioButton.isSelected();
}
- public Object[] getRememberedConfigs() {
-
- Object[] urls = new Object[existingConfigurationComboBoxModel.getSize()];
-
- for (int i = 0; i < existingConfigurationComboBoxModel.getSize(); i++) {
- urls[i] = existingConfigurationComboBoxModel.getElementAt(i);
- }
-
- return urls;
- }
-
- public void setRememberedConfigs(final Object[] configs) {
- SwingUtilities.invokeLater(new Runnable() {
- public void run() {
- existingConfigurationComboBoxModel.removeAllElements();
-
- for (int i = 0; i < configs.length; i++) {
- existingConfigurationComboBoxModel.addElement(configs[i]);
- }
- }
- });
- }
-
URL getConfigToLoad() {
try
@@ -727,6 +711,9 @@ class ReceiverConfigurationPanel extends
}
String getLogFormat() {
+ if (cancelled) {
+ return lastLogFormat;
+ }
Object item = logFileFormatComboBox.getSelectedItem();
if (item != null) {
return item.toString();
@@ -748,22 +735,16 @@ class ReceiverConfigurationPanel extends
return null;
}
- public void setRememberedLayouts(Object[] layouts)
+ public void setCancelled(boolean cancelled)
{
- //TODO: implement
- //add an entry to the logformat, formattype and timestamp fields
-
+ this.cancelled = cancelled;
}
- public Object[] getRememberedLayouts()
- {
- //TODO: implement
- return new Object[0];
- }
-
- public void setCancelled()
- {
- cancelled = true;
+ public void setLogFormat(String lastLogFormat) {
+ this.lastLogFormat = lastLogFormat;
+ logFileFormatComboBoxModel.removeElement(lastLogFormat);
+ logFileFormatComboBoxModel.insertElementAt(lastLogFormat, 0);
+ logFileFormatComboBox.setSelectedIndex(0);
}
}
}
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.