in src/main/java/org/apache/log4j/chainsaw/ReceiverConfigurationPanel.java [365:480]
private JPanel buildLogFileReceiverPanel() {
JPanel panel = new JPanel(new GridBagLayout());
browseLogFileButton = new JButton(new AbstractAction(" Open File... ") {
public void actionPerformed(ActionEvent e) {
try {
URL url = browseFile("Select a log file", true);
if (url != null) {
String item = url.toURI().toString();
logFileURLTextField.setText(item);
}
} catch (Exception ex) {
logger.error(
"Error browsing for log file", ex);
}
}
});
browseLogFileButton.setToolTipText("Shows a File Open dialog to allow you to find a log file");
GridBagConstraints c = new GridBagConstraints();
c.gridx = 0;
c.gridy = 0;
c.anchor = GridBagConstraints.LINE_START;
c.insets = new Insets(0, 0, 5, 0);
panel.add(browseLogFileButton, c);
c = new GridBagConstraints();
c.gridx = 0;
c.gridy = 1;
c.anchor = GridBagConstraints.LINE_END;
c.insets = new Insets(0, 0, 5, 5);
panel.add(new JLabel(" Log file URL "), c);
logFileURLTextField = new JTextField();
logFileURLTextField.setEditable(true);
c = new GridBagConstraints();
c.gridx = 1;
c.gridy = 1;
c.weightx = 1.0;
c.gridwidth = 1;
c.anchor = GridBagConstraints.LINE_START;
c.fill = GridBagConstraints.HORIZONTAL;
c.insets = new Insets(0, 0, 5, 0);
panel.add(logFileURLTextField, c);
c = new GridBagConstraints();
c.gridx = 0;
c.gridy = 2;
c.anchor = GridBagConstraints.LINE_END;
c.insets = new Insets(0, 0, 5, 5);
panel.add(new JLabel(" Log file format type "), c);
DefaultComboBoxModel<String> comboBoxModel = new DefaultComboBoxModel<>();
comboBoxModel.addElement("LogFilePatternReceiver LogFormat");
comboBoxModel.addElement("PatternLayout format");
logFileFormatTypeComboBox = new JComboBox<>(comboBoxModel);
logFileFormatTypeComboBox.setOpaque(false);
c = new GridBagConstraints();
c.gridx = 1;
c.gridy = 2;
c.anchor = GridBagConstraints.LINE_START;
c.insets = new Insets(0, 0, 5, 0);
panel.add(logFileFormatTypeComboBox, c);
c = new GridBagConstraints();
c.gridx = 0;
c.gridy = 3;
c.anchor = GridBagConstraints.LINE_END;
c.insets = new Insets(0, 5, 5, 5);
panel.add(new JLabel(" Log file format "), c);
logFileFormatComboBoxModel = new DefaultComboBoxModel<>();
seedLogFileFormatComboBoxModel();
logFileFormatComboBox = new JComboBox<>(logFileFormatComboBoxModel);
logFileFormatComboBox.setEditable(true);
logFileFormatComboBox.setOpaque(false);
logFileFormatComboBox.setSelectedIndex(0);
c = new GridBagConstraints();
c.gridx = 1;
c.gridy = 3;
c.weightx = 0.5;
c.anchor = GridBagConstraints.LINE_START;
c.fill = GridBagConstraints.HORIZONTAL;
c.insets = new Insets(0, 0, 5, 0);
panel.add(logFileFormatComboBox, c);
c = new GridBagConstraints();
c.gridx = 0;
c.gridy = 4;
c.insets = new Insets(0, 5, 5, 5);
panel.add(new JLabel(" Log file timestamp format "), c);
logFileFormatTimestampFormatComboBoxModel = new DefaultComboBoxModel<>();
seedLogFileFormatTimestampComboBoxModel();
logFileFormatTimestampFormatComboBox = new JComboBox<>(logFileFormatTimestampFormatComboBoxModel);
logFileFormatTimestampFormatComboBox.setEditable(true);
logFileFormatTimestampFormatComboBox.setOpaque(false);
c = new GridBagConstraints();
c.gridx = 1;
c.gridy = 4;
c.weightx = 0.5;
c.fill = GridBagConstraints.HORIZONTAL;
c.insets = new Insets(0, 0, 0, 0);
panel.add(logFileFormatTimestampFormatComboBox, c);
c = new GridBagConstraints();
c.gridx = 0;
c.gridy = 5;
c.gridwidth = 5;
c.insets = new Insets(15, 5, 0, 5);
panel.add(new JLabel("<html> See PatternLayout or LogFilePatternReceiver JavaDoc for details </html>"), c);
return panel;
}