#841 Loop control for sound preview

This commit is contained in:
honfika@gmail.com
2015-04-26 15:50:26 +02:00
parent 28ff32f19c
commit 7803fb78b4
31 changed files with 628 additions and 621 deletions

View File

@@ -85,12 +85,9 @@ public class ErrorLogFrame extends AppFrame {
public static ErrorLogFrame getInstance() {
if (instance == null) {
instance = new ErrorLogFrame();
View.execInEventDispatch(new Runnable() {
@Override
public void run() {
Logger logger = Logger.getLogger("");
logger.addHandler(instance.getHandler());
}
View.execInEventDispatch(() -> {
Logger logger = Logger.getLogger("");
logger.addHandler(instance.getHandler());
});
}
return instance;
@@ -98,12 +95,9 @@ public class ErrorLogFrame extends AppFrame {
public static ErrorLogFrame createNewInstance() {
if (instance != null) {
View.execInEventDispatch(new Runnable() {
@Override
public void run() {
Logger logger = Logger.getLogger("");
logger.removeHandler(instance.getHandler());
}
View.execInEventDispatch(() -> {
Logger logger = Logger.getLogger("");
logger.removeHandler(instance.getHandler());
});
instance.setVisible(false);
instance.dispose();
@@ -210,110 +204,107 @@ public class ErrorLogFrame extends AppFrame {
private void log(final Level level, final String msg, final String detail) {
if (logItemCount.getAndIncrement() < MAX_LOG_ITEM_COUNT) {
View.execInEventDispatchLater(new Runnable() {
@Override
public void run() {
notifyMainFrame(level);
View.execInEventDispatchLater(() -> {
notifyMainFrame(level);
JPanel pan = new JPanel();
pan.setBackground(Color.white);
pan.setLayout(new BoxLayout(pan, BoxLayout.Y_AXIS));
JPanel pan = new JPanel();
pan.setBackground(Color.white);
pan.setLayout(new BoxLayout(pan, BoxLayout.Y_AXIS));
JComponent detailComponent;
if (detail == null) {
detailComponent = null;
} else {
final JTextArea detailTextArea = new JTextArea(detail);
detailTextArea.setEditable(false);
detailTextArea.setOpaque(false);
detailTextArea.setFont(new JLabel().getFont());
detailTextArea.setBackground(Color.white);
detailComponent = detailTextArea;
JComponent detailComponent;
if (detail == null) {
detailComponent = null;
} else {
final JTextArea detailTextArea = new JTextArea(detail);
detailTextArea.setEditable(false);
detailTextArea.setOpaque(false);
detailTextArea.setFont(new JLabel().getFont());
detailTextArea.setBackground(Color.white);
detailComponent = detailTextArea;
}
JPanel header = new JPanel();
header.setLayout(new BoxLayout(header, BoxLayout.X_AXIS));
header.setBackground(Color.white);
SimpleDateFormat format = new SimpleDateFormat("dd/MM/YYYY HH:mm:ss");
final String dateStr = format.format(new Date());
JToggleButton copyButton = new JToggleButton(View.getIcon("copy16"));
copyButton.setFocusPainted(false);
copyButton.setBorderPainted(false);
copyButton.setFocusable(false);
copyButton.setContentAreaFilled(false);
copyButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
copyButton.setMargin(new Insets(2, 2, 2, 2));
copyButton.setToolTipText(translate("copy"));
copyButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
StringSelection stringSelection = new StringSelection(dateStr + " " + level.toString() + " " + msg + "\r\n" + detail);
clipboard.setContents(stringSelection, null);
}
JPanel header = new JPanel();
header.setLayout(new BoxLayout(header, BoxLayout.X_AXIS));
header.setBackground(Color.white);
});
SimpleDateFormat format = new SimpleDateFormat("dd/MM/YYYY HH:mm:ss");
final String dateStr = format.format(new Date());
final JToggleButton expandButton = new JToggleButton(collapseIcon);
expandButton.setFocusPainted(false);
expandButton.setBorderPainted(false);
expandButton.setFocusable(false);
expandButton.setContentAreaFilled(false);
expandButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
expandButton.setMargin(new Insets(2, 2, 2, 2));
expandButton.setToolTipText(translate("details"));
JToggleButton copyButton = new JToggleButton(View.getIcon("copy16"));
copyButton.setFocusPainted(false);
copyButton.setBorderPainted(false);
copyButton.setFocusable(false);
copyButton.setContentAreaFilled(false);
copyButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
copyButton.setMargin(new Insets(2, 2, 2, 2));
copyButton.setToolTipText(translate("copy"));
copyButton.addActionListener(new ActionListener() {
final JScrollPane scrollPane;
if (detailComponent != null) {
scrollPane = new JScrollPane(detailComponent);
scrollPane.setAlignmentX(0f);
} else {
scrollPane = null;
}
if (detailComponent != null) {
expandButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
StringSelection stringSelection = new StringSelection(dateStr + " " + level.toString() + " " + msg + "\r\n" + detail);
clipboard.setContents(stringSelection, null);
expandButton.setIcon(expandButton.isSelected() ? expandIcon : collapseIcon);
scrollPane.setVisible(expandButton.isSelected());
revalidate();
repaint();
}
});
final JToggleButton expandButton = new JToggleButton(collapseIcon);
expandButton.setFocusPainted(false);
expandButton.setBorderPainted(false);
expandButton.setFocusable(false);
expandButton.setContentAreaFilled(false);
expandButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
expandButton.setMargin(new Insets(2, 2, 2, 2));
expandButton.setToolTipText(translate("details"));
final JScrollPane scrollPane;
if (detailComponent != null) {
scrollPane = new JScrollPane(detailComponent);
scrollPane.setAlignmentX(0f);
} else {
scrollPane = null;
}
if (detailComponent != null) {
expandButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
expandButton.setIcon(expandButton.isSelected() ? expandIcon : collapseIcon);
scrollPane.setVisible(expandButton.isSelected());
revalidate();
repaint();
}
});
}
if (detailComponent != null) {
header.add(expandButton);
}
JLabel dateLabel = new JLabel(dateStr);
dateLabel.setPreferredSize(new Dimension(200, (int) dateLabel.getPreferredSize().getHeight()));
dateLabel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
header.add(dateLabel);
JLabel levelLabel = new JLabel(level.getName());
levelLabel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
header.add(levelLabel);
JTextArea msgLabel = new JTextArea(msg);
msgLabel.setEditable(false);
msgLabel.setOpaque(false);
msgLabel.setFont(levelLabel.getFont());
msgLabel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
header.add(msgLabel);
header.setAlignmentX(0f);
header.add(copyButton);
pan.add(header);
if (detailComponent != null) {
pan.add(scrollPane);
scrollPane.setVisible(false);
}
pan.setAlignmentX(0f);
logViewInner.add(pan);
revalidate();
repaint();
}
if (detailComponent != null) {
header.add(expandButton);
}
JLabel dateLabel = new JLabel(dateStr);
dateLabel.setPreferredSize(new Dimension(200, (int) dateLabel.getPreferredSize().getHeight()));
dateLabel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
header.add(dateLabel);
JLabel levelLabel = new JLabel(level.getName());
levelLabel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
header.add(levelLabel);
JTextArea msgLabel = new JTextArea(msg);
msgLabel.setEditable(false);
msgLabel.setOpaque(false);
msgLabel.setFont(levelLabel.getFont());
msgLabel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
header.add(msgLabel);
header.setAlignmentX(0f);
header.add(copyButton);
pan.add(header);
if (detailComponent != null) {
pan.add(scrollPane);
scrollPane.setVisible(false);
}
pan.setAlignmentX(0f);
logViewInner.add(pan);
revalidate();
repaint();
});
}
}