diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/ErrorLogFrame.java b/trunk/src/com/jpexs/decompiler/flash/gui/ErrorLogFrame.java index 20da765e0..62765aaea 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/ErrorLogFrame.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/ErrorLogFrame.java @@ -21,6 +21,7 @@ import java.awt.Color; import java.awt.Container; import java.awt.Cursor; import java.awt.Dimension; +import java.awt.FlowLayout; import java.awt.Insets; import java.awt.Toolkit; import java.awt.datatransfer.Clipboard; @@ -37,6 +38,7 @@ import java.util.logging.LogRecord; import javax.swing.BorderFactory; import javax.swing.BoxLayout; import javax.swing.ImageIcon; +import javax.swing.JButton; import javax.swing.JComponent; import javax.swing.JFrame; import javax.swing.JLabel; @@ -77,9 +79,22 @@ public class ErrorLogFrame extends AppFrame { logViewInner.setLayout(new BoxLayout(logViewInner, BoxLayout.Y_AXIS)); logView.add(logViewInner, BorderLayout.NORTH); + JPanel buttonsPanel = new JPanel(new FlowLayout()); + JButton clearButton = new JButton(translate("clear")); + clearButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + logViewInner.removeAll(); + Main.clearLogFile(); + revalidate(); + repaint(); + } + }); + buttonsPanel.add(clearButton); expandIcon = View.getIcon("expand16"); collapseIcon = View.getIcon("collapse16"); + cnt.add(buttonsPanel, BorderLayout.SOUTH); cnt.add(new JScrollPane(logView), BorderLayout.CENTER); handler = new Handler() { @@ -174,8 +189,11 @@ public class ErrorLogFrame extends AppFrame { + if (detailComponent != null) { + header.add(expandButton); + } JLabel dateLabel = new JLabel(dateStr); - dateLabel.setPreferredSize(new Dimension(140, 25)); + dateLabel.setPreferredSize(new Dimension(200, (int) dateLabel.getPreferredSize().getHeight())); dateLabel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); header.add(dateLabel); @@ -193,9 +211,7 @@ public class ErrorLogFrame extends AppFrame { msgLabel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); header.add(msgLabel); header.setAlignmentX(0f); - if (detailComponent != null) { - header.add(expandButton); - } + header.add(copyButton); pan.add(header); if (detailComponent != null) { diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/Main.java b/trunk/src/com/jpexs/decompiler/flash/gui/Main.java index ba8316905..4ecb3081e 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/Main.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/Main.java @@ -265,7 +265,7 @@ public class Main { try { Main.startWork(translate("work.reading.swf") + "..."); swf = parseSWF(Main.inputStream); - if(Main.inputStream instanceof FileInputStream) { + if (Main.inputStream instanceof FileInputStream) { Main.inputStream.close(); } } catch (Exception ex) { @@ -1242,22 +1242,44 @@ public class Main { Configuration.setConfig("lastUpdatesCheckDate", Calendar.getInstance()); return false; } + private static FileHandler fileTxt; + + public static void clearLogFile() { + Logger logger = Logger.getLogger(""); + if (fileTxt != null) { + fileTxt.flush(); + fileTxt.close(); + logger.removeHandler(fileTxt); + } + try { + File f = new File(getFFDecHome() + File.separator + "log.txt"); + FileOutputStream fos = new FileOutputStream(f); + fos.close(); + } catch (IOException ex) { + } + try { + fileTxt = new FileHandler(getFFDecHome() + File.separator + "log.txt"); + } catch (IOException | SecurityException ex) { + Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); + } + + SimpleFormatter formatterTxt = new SimpleFormatter(); + fileTxt.setFormatter(formatterTxt); + logger.addHandler(fileTxt); + + } public static void initLogging(boolean debug) { try { Logger logger = Logger.getLogger(""); logger.setLevel(debug ? Level.CONFIG : Level.WARNING); - FileHandler fileTxt = new FileHandler(getFFDecHome() + File.separator + "log.txt"); - - SimpleFormatter formatterTxt = new SimpleFormatter(); - fileTxt.setFormatter(formatterTxt); - logger.addHandler(fileTxt); - if (debug) { ConsoleHandler conHan = new ConsoleHandler(); + SimpleFormatter formatterTxt = new SimpleFormatter(); conHan.setFormatter(formatterTxt); logger.addHandler(conHan); } + clearLogFile(); } catch (Exception ex) { throw new RuntimeException("Problems with creating the log files"); diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/locales/ErrorLogFrame.properties b/trunk/src/com/jpexs/decompiler/flash/gui/locales/ErrorLogFrame.properties index ed1f7b144..5086f9026 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/locales/ErrorLogFrame.properties +++ b/trunk/src/com/jpexs/decompiler/flash/gui/locales/ErrorLogFrame.properties @@ -15,4 +15,5 @@ copy = Copy to clipboard details = View details -dialog.title = Log \ No newline at end of file +dialog.title = Log +clear = Clear \ No newline at end of file diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/locales/ErrorLogFrame_cs.properties b/trunk/src/com/jpexs/decompiler/flash/gui/locales/ErrorLogFrame_cs.properties index 7510c2065..927ff3168 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/locales/ErrorLogFrame_cs.properties +++ b/trunk/src/com/jpexs/decompiler/flash/gui/locales/ErrorLogFrame_cs.properties @@ -15,4 +15,5 @@ copy = Zkop\u00edrovat do schr\u00e1nky details = Zobrazit detaily -dialog.title = Log \ No newline at end of file +dialog.title = Log +clear = Vypr\u00e1zdnit \ No newline at end of file