From e22a981f9e601abe8345c124f92ad859925f7260 Mon Sep 17 00:00:00 2001 From: Honfika Date: Fri, 3 Jan 2014 14:04:54 +0100 Subject: [PATCH] #317 Detailed log files --- .../decompiler/flash/SWFInputStream.java | 7 +- .../flash/action/ActionListReader.java | 4 +- .../flash/configuration/Configuration.java | 7 + .../decompiler/flash/gui/ErrorLogFrame.java | 50 ++++++ .../decompiler/flash/gui/ErrorState.java | 25 +++ .../decompiler/flash/gui/LogFormatter.java | 68 ++++++++ .../com/jpexs/decompiler/flash/gui/Main.java | 154 +++++++++--------- .../flash/gui/MainFrameStatusPanel.java | 82 ++++++---- .../jpexs/decompiler/flash/gui/MainPanel.java | 11 +- .../flash/gui/graphics/information16.png | Bin 0 -> 778 bytes .../flash/gui/graphics/warning16.png | Bin 0 -> 666 bytes .../flash/gui/locales/MainFrame.properties | 4 +- .../flash/gui/locales/MainFrame_hu.properties | 3 + trunk/src/com/jpexs/helpers/Helper.java | 13 ++ 14 files changed, 309 insertions(+), 119 deletions(-) create mode 100644 trunk/src/com/jpexs/decompiler/flash/gui/ErrorState.java create mode 100644 trunk/src/com/jpexs/decompiler/flash/gui/LogFormatter.java create mode 100644 trunk/src/com/jpexs/decompiler/flash/gui/graphics/information16.png create mode 100644 trunk/src/com/jpexs/decompiler/flash/gui/graphics/warning16.png diff --git a/trunk/src/com/jpexs/decompiler/flash/SWFInputStream.java b/trunk/src/com/jpexs/decompiler/flash/SWFInputStream.java index 82eb3e42a..14ad23509 100644 --- a/trunk/src/com/jpexs/decompiler/flash/SWFInputStream.java +++ b/trunk/src/com/jpexs/decompiler/flash/SWFInputStream.java @@ -85,7 +85,7 @@ public class SWFInputStream extends InputStream { private Stack margedPos = new Stack<>(); private long pos; private int version; - private static final Logger log = Logger.getLogger(SWFInputStream.class.getName()); + private static final Logger logger = Logger.getLogger(SWFInputStream.class.getName()); private List listeners = new ArrayList<>(); private long percentMax; private List buffered = new ArrayList<>(); @@ -1054,6 +1054,9 @@ public class SWFInputStream extends InputStream { if (tagID == 0) { return null; } + + logger.log(Level.INFO, "Reading tag. ID={0}, position: {1}", new Object[]{tagID, pos}); + long tagLength = (tagIDTagLength & 0x003F); boolean readLong = false; if (tagLength == 0x3f) { @@ -1093,7 +1096,7 @@ public class SWFInputStream extends InputStream { e += (Long.toHexString(data[j] & 0xff) + " "); } } - log.fine(e); + logger.fine(e); } } if (resolve) { diff --git a/trunk/src/com/jpexs/decompiler/flash/action/ActionListReader.java b/trunk/src/com/jpexs/decompiler/flash/action/ActionListReader.java index b7baa9abd..a778c153d 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/ActionListReader.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/ActionListReader.java @@ -69,7 +69,7 @@ import java.util.logging.Logger; */ public class ActionListReader { - private static final Logger log = Logger.getLogger(SWFInputStream.class.getName()); + private static final Logger logger = Logger.getLogger(SWFInputStream.class.getName()); /** @@ -838,7 +838,7 @@ public class ActionListReader { a.translate(localData, stack, output, Graph.SOP_USE_STATIC/*Graph.SOP_SKIP_STATIC*/, path); } } catch (RuntimeException ex) { - log.log(Level.SEVERE, "Disassembly exception", ex); + logger.log(Level.SEVERE, "Disassembly exception", ex); break; } diff --git a/trunk/src/com/jpexs/decompiler/flash/configuration/Configuration.java b/trunk/src/com/jpexs/decompiler/flash/configuration/Configuration.java index 2a3d1f864..b0524289e 100644 --- a/trunk/src/com/jpexs/decompiler/flash/configuration/Configuration.java +++ b/trunk/src/com/jpexs/decompiler/flash/configuration/Configuration.java @@ -49,6 +49,8 @@ public class Configuration { */ private static List replacements = new ArrayList<>(); + public static final Level logLevel; + @ConfigurationDefaultBoolean(true) public static final ConfigurationItem openMultipleFiles = null; @ConfigurationDefaultBoolean(true) @@ -444,6 +446,11 @@ public class Configuration { static { setConfigurationFields(); + if (debugMode.get()) { + logLevel = Level.CONFIG; + } else { + logLevel = Level.WARNING; + } } @SuppressWarnings("unchecked") diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/ErrorLogFrame.java b/trunk/src/com/jpexs/decompiler/flash/gui/ErrorLogFrame.java index edd2ac1e7..69cc13bfe 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/ErrorLogFrame.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/ErrorLogFrame.java @@ -54,16 +54,30 @@ import javax.swing.SwingUtilities; */ public class ErrorLogFrame extends AppFrame { + private static ErrorLogFrame instance; + private JPanel logView = new JPanel(); private JPanel logViewInner = new JPanel(); private Handler handler; private ImageIcon expandIcon; private ImageIcon collapseIcon; + private ErrorState errorState; public Handler getHandler() { return handler; } + public static ErrorLogFrame getInstance() { + if (instance == null) { + instance = new ErrorLogFrame(); + } + return instance; + } + + public ErrorState getErrorState() { + return errorState; + } + public ErrorLogFrame() { setTitle(translate("dialog.title")); setSize(700, 400); @@ -113,10 +127,46 @@ public class ErrorLogFrame extends AppFrame { }; } + public void clearErrorState() { + errorState = ErrorState.NO_ERROR; + MainFrame mainFrame = Main.getMainFrame(); + if (mainFrame != null) { + mainFrame.getPanel().setErrorState(errorState); + } + } + + private void notifyMainFrame(Level level) { + boolean stateChanged = false; + if (level.intValue() >= Level.SEVERE.intValue()) { + if (errorState != ErrorState.ERROR) { + errorState = ErrorState.ERROR; + stateChanged = true; + } + } else if (level.intValue() >= Level.WARNING.intValue()) { + if (errorState != ErrorState.ERROR && errorState != ErrorState.WARNING) { + errorState = ErrorState.WARNING; + stateChanged = true; + } + } else if (level.intValue() >= Level.INFO.intValue()) { + if (errorState == ErrorState.NO_ERROR) { + errorState = ErrorState.INFO; + stateChanged = true; + } + } + if (stateChanged) { + MainFrame mainFrame = Main.getMainFrame(); + if (mainFrame != null) { + mainFrame.getPanel().setErrorState(errorState); + } + } + } + private void log(final Level level, final String msg, final String detail) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { + notifyMainFrame(level); + JPanel pan = new JPanel(); pan.setBackground(Color.white); pan.setLayout(new BoxLayout(pan, BoxLayout.Y_AXIS)); diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/ErrorState.java b/trunk/src/com/jpexs/decompiler/flash/gui/ErrorState.java new file mode 100644 index 000000000..303bb1184 --- /dev/null +++ b/trunk/src/com/jpexs/decompiler/flash/gui/ErrorState.java @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2013 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.gui; + +/** + * + * @author JPEXS + */ +public enum ErrorState { + NO_ERROR, INFO, WARNING, ERROR +} diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/LogFormatter.java b/trunk/src/com/jpexs/decompiler/flash/gui/LogFormatter.java new file mode 100644 index 000000000..4ee8c871c --- /dev/null +++ b/trunk/src/com/jpexs/decompiler/flash/gui/LogFormatter.java @@ -0,0 +1,68 @@ +/* + * Copyright (C) 2010-2013 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.gui; + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.logging.Formatter; +import java.util.logging.Level; +import java.util.logging.LogRecord; + +/** + * + * @author JPEXS + */ +public class LogFormatter extends Formatter { + + static final String lineSep = System.getProperty("line.separator"); + private DateFormat dateFormat; + + @Override + public String format(LogRecord record) { + StringBuilder buf = new StringBuilder(180); + + if (dateFormat == null) + dateFormat = new SimpleDateFormat("HH:mm:ss.SSS"); + + buf.append(dateFormat.format(new Date(record.getMillis()))); + buf.append(" > "); + + if (record.getLevel().intValue() >= Level.WARNING.intValue()) { + buf.append(record.getLevel()); + buf.append(": "); + } + buf.append(formatMessage(record)); + + buf.append(lineSep); + + Throwable throwable = record.getThrown(); + if (throwable != null) { + StringWriter sink = new StringWriter(); + throwable.printStackTrace(new PrintWriter(sink, true)); + buf.append(record.getSourceClassName()); + buf.append(' '); + buf.append(record.getSourceMethodName()); + buf.append(lineSep); + buf.append(sink.toString()); + } + + return buf.toString(); + } +} diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/Main.java b/trunk/src/com/jpexs/decompiler/flash/gui/Main.java index 63bccc0cf..724064bc3 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/Main.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/Main.java @@ -17,6 +17,7 @@ package com.jpexs.decompiler.flash.gui; import com.jpexs.decompiler.flash.ApplicationInfo; +import static com.jpexs.decompiler.flash.ApplicationInfo.applicationVerName; import com.jpexs.decompiler.flash.EventListener; import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.SWFSourceInfo; @@ -32,6 +33,7 @@ import com.jpexs.helpers.Cache; import com.jpexs.helpers.CancellableWorker; import com.jpexs.helpers.Helper; import com.jpexs.helpers.ProgressListener; +import com.jpexs.helpers.Stopwatch; import com.jpexs.helpers.streams.SeekableInputStream; import com.sun.jna.Platform; import java.awt.*; @@ -41,14 +43,16 @@ import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.io.*; import java.net.Socket; +import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Arrays; import java.util.Calendar; +import java.util.Date; import java.util.List; import java.util.Locale; import java.util.logging.ConsoleHandler; import java.util.logging.FileHandler; -import java.util.logging.Handler; +import java.util.logging.Formatter; import java.util.logging.Level; import java.util.logging.LogRecord; import java.util.logging.Logger; @@ -82,7 +86,22 @@ public class Main { private static final int UPDATE_SYSTEM_MINOR = 0; public static LoadFromMemoryFrame loadFromMemoryFrame; public static LoadFromCacheFrame loadFromCacheFrame; - private static ErrorLogFrame errorLogFrame; + private static final Logger logger = Logger.getLogger(Main.class.getName()); + + public static void ensureMainFrame() { + if (mainFrame == null) { + if (Configuration.useRibbonInterface.get()) { + mainFrame = new MainFrameRibbon(); + } else { + mainFrame = new MainFrameClassic(); + } + mainFrame.getPanel().setErrorState(ErrorLogFrame.getInstance().getErrorState()); + } + } + + public static MainFrame getMainFrame() { + return mainFrame; + } public static void loadFromCache() { if (loadFromCacheFrame == null) { @@ -189,7 +208,7 @@ public class Main { } public static SWF parseSWF(String file) throws Exception { - SWFSourceInfo sourceInfo = new SWFSourceInfo(new FileInputStream(file), file, null); + SWFSourceInfo sourceInfo = new SWFSourceInfo(null, file, null); return parseSWF(sourceInfo); } @@ -199,20 +218,24 @@ public class Main { InputStream inputStream = sourceInfo.getInputStream(); if (inputStream == null) { inputStream = new FileInputStream(sourceInfo.getFile()); + logger.log(Level.INFO, "Load file: {0}", sourceInfo.getFile()); } else if (inputStream instanceof SeekableInputStream) { try { ((SeekableInputStream) inputStream).seek(0); } catch (IOException ex) { - Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); + logger.log(Level.SEVERE, null, ex); } + logger.log(Level.INFO, "Load stream: {0}", sourceInfo.getFileTitle()); } else if (inputStream instanceof BufferedInputStream) { try { ((BufferedInputStream) inputStream).reset(); } catch (IOException ex) { - Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); + logger.log(Level.SEVERE, null, ex); } + logger.log(Level.INFO, "Load stream: {0}", sourceInfo.getFileTitle()); } + Stopwatch sw = Stopwatch.startNew(); locswf = new SWF(inputStream, new ProgressListener() { @Override public void progress(int p) { @@ -221,8 +244,20 @@ public class Main { }, Configuration.parallelSpeedUp.get()); if (inputStream instanceof FileInputStream) { + logger.log(Level.INFO, "File loaded in {0} seconds.", (sw.getElapsedMilliseconds() / 1000)); inputStream.close(); + } else { + logger.log(Level.INFO, "Stream loaded in {0} seconds.", (sw.getElapsedMilliseconds() / 1000)); } + + logger.log(Level.INFO, ""); + logger.log(Level.INFO, "== File information =="); + logger.log(Level.INFO, "Size: {0}", Helper.formatFileSize(locswf.fileSize)); + logger.log(Level.INFO, "Flash version: {0}", locswf.version); + int width = (locswf.displayRect.Xmax - locswf.displayRect.Xmin) / 20; + int height = (locswf.displayRect.Ymax - locswf.displayRect.Ymin) / 20; + logger.log(Level.INFO, "Width: {0}", width); + logger.log(Level.INFO, "Height: {0}", height); locswf.sourceInfo = sourceInfo; locswf.file = sourceInfo.getFile(); @@ -313,10 +348,10 @@ public class Main { Main.startWork(AppStrings.translate("work.reading.swf") + "..."); swf = parseSWF(sourceInfo); } catch (OutOfMemoryError ex) { - Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); + logger.log(Level.SEVERE, null, ex); View.showMessageDialog(null, "Cannot load SWF file. Out of memory."); } catch (Exception ex) { - Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); + logger.log(Level.SEVERE, null, ex); View.showMessageDialog(null, "Cannot load SWF file."); } @@ -328,22 +363,13 @@ public class Main { View.execInEventDispatch(new Runnable() { @Override public void run() { - if (mainFrame == null) { - if (Configuration.useRibbonInterface.get()) { - mainFrame = new MainFrameRibbon(); - } else { - mainFrame = new MainFrameClassic(); - } - } + ensureMainFrame(); mainFrame.getPanel().load(swf1, first1); - if (errorState) { - mainFrame.getPanel().setErrorState(); - } } }); } catch (Exception ex) { - Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); + logger.log(Level.SEVERE, null, ex); } } @@ -596,11 +622,8 @@ public class Main { } public static void displayErrorFrame() { - if (errorLogFrame != null) { - errorLogFrame.setVisible(true); - } + ErrorLogFrame.getInstance().setVisible(true); } - private static boolean errorState = false; private static void initGui() { if (Configuration.useRibbonInterface.get()) { @@ -609,42 +632,14 @@ public class Main { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) { - Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); + logger.log(Level.SEVERE, null, ex); } } View.execInEventDispatch(new Runnable() { @Override public void run() { - if (errorLogFrame == null) { - errorLogFrame = new ErrorLogFrame(); - } Logger logger = Logger.getLogger(""); - logger.addHandler(errorLogFrame.getHandler()); - logger.addHandler(new Handler() { - @Override - public void publish(final LogRecord record) { - View.execInEventDispatch(new Runnable() { - @Override - public void run() { - if (record.getLevel() == Level.SEVERE) { - errorState = true; - if (mainFrame != null) { - mainFrame.getPanel().setErrorState(); - } - } - } - }); - - } - - @Override - public void flush() { - } - - @Override - public void close() throws SecurityException { - } - }); + logger.addHandler(ErrorLogFrame.getInstance().getHandler()); } }); autoCheckForUpdates(); @@ -655,16 +650,7 @@ public class Main { View.execInEventDispatch(new Runnable() { @Override public void run() { - if (mainFrame == null) { - if (Configuration.useRibbonInterface.get()) { - mainFrame = new MainFrameRibbon(); - } else { - mainFrame = new MainFrameClassic(); - } - if (errorState) { - mainFrame.getPanel().setErrorState(); - } - } + ensureMainFrame(); mainFrame.setVisible(true); } }); @@ -790,7 +776,7 @@ public class Main { System.gc(); } } catch (InterruptedException ex) { - Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); + logger.log(Level.SEVERE, null, ex); } } }.start(); @@ -1044,32 +1030,46 @@ public class Main { fileTxt.close(); logger.removeHandler(fileTxt); } + + String fileName; + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd-hh-mm-ss"); + try { - File f = new File(Configuration.getFFDecHome() + File.separator + "log.txt"); - FileOutputStream fos = new FileOutputStream(f); - fos.close(); - } catch (IOException ex) { - } - try { - fileTxt = new FileHandler(Configuration.getFFDecHome() + File.separator + "log.txt"); + fileName = Configuration.getFFDecHome() + File.separator + "logs" + File.separator; + if (Configuration.logLevel.intValue() < Level.WARNING.intValue()) { + fileName += "log-" + sdf.format(new Date()) + ".txt"; + } else { + fileName += "log.txt"; + } + File f = new File(fileName).getParentFile(); + if (!f.exists()) { + f.mkdir(); + } + fileTxt = new FileHandler(fileName); } catch (IOException | SecurityException ex) { - Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); + logger.log(Level.SEVERE, null, ex); } - SimpleFormatter formatterTxt = new SimpleFormatter(); + + Formatter formatterTxt = new LogFormatter(); fileTxt.setFormatter(formatterTxt); logger.addHandler(fileTxt); - errorState = false; - if (mainFrame != null) { - mainFrame.getPanel().clearErrorState(); - } + ErrorLogFrame.getInstance().clearErrorState(); + + sdf = new SimpleDateFormat("yyyy-MM-dd"); + logger.log(Level.INFO, "Date: {0}", sdf.format(new Date())); + logger.log(Level.INFO, ApplicationInfo.applicationVerName); + logger.log(Level.INFO, "{0} {1} {2}", new Object[]{ + System.getProperty("os.name"), System.getProperty("os.version"), System.getProperty("os.arch")}); + logger.log(Level.INFO, "{0} {1} {2}", new Object[]{ + System.getProperty("java.version"), System.getProperty("java.vendor"), System.getProperty("os.arch")}); } public static void initLogging(boolean debug) { try { Logger logger = Logger.getLogger(""); - logger.setLevel(debug ? Level.CONFIG : Level.WARNING); + logger.setLevel(Configuration.logLevel); if (debug) { ConsoleHandler conHan = new ConsoleHandler(); SimpleFormatter formatterTxt = new SimpleFormatter(); diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/MainFrameStatusPanel.java b/trunk/src/com/jpexs/decompiler/flash/gui/MainFrameStatusPanel.java index bcf431b9a..e212960a5 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/MainFrameStatusPanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/MainFrameStatusPanel.java @@ -16,6 +16,7 @@ */ package com.jpexs.decompiler.flash.gui; +import static com.jpexs.decompiler.flash.gui.ErrorState.WARNING; import com.jpexs.helpers.CancellableWorker; import java.awt.BorderLayout; import java.awt.Cursor; @@ -26,6 +27,7 @@ import java.awt.event.ActionListener; import java.util.Timer; import java.util.TimerTask; import javax.swing.BoxLayout; +import javax.swing.Icon; import javax.swing.JButton; import javax.swing.JLabel; import javax.swing.JPanel; @@ -46,6 +48,7 @@ public class MainFrameStatusPanel extends JPanel implements ActionListener { private JButton cancelButton = new JButton(); private JButton errorNotificationButton; + private Icon currentIcon; private Timer blinkTimer; private int blinkPos; @@ -126,44 +129,61 @@ public class MainFrameStatusPanel extends JPanel implements ActionListener { cancelButton.setVisible(worker != null); } - public void clearErrorState() { - errorNotificationButton.setIcon(View.getIcon("okay16")); - errorNotificationButton.setToolTipText(translate("errors.none")); - } - - public void setErrorState() { + public void setErrorState(ErrorState errorState) { if (errorNotificationButton == null) { // todo: honfika // why null? return; } - errorNotificationButton.setIcon(View.getIcon("error16")); - errorNotificationButton.setToolTipText(translate("errors.present")); - if (blinkTimer != null) { - blinkTimer.cancel(); + switch (errorState) { + case NO_ERROR: + currentIcon = View.getIcon("okay16"); + errorNotificationButton.setToolTipText(translate("errors.none")); + blinkPos = 0; + break; + case INFO: + currentIcon = View.getIcon("information16"); + errorNotificationButton.setToolTipText(translate("errors.info")); + break; + case WARNING: + currentIcon = View.getIcon("warning16"); + errorNotificationButton.setToolTipText(translate("errors.warning")); + break; + case ERROR: + currentIcon = View.getIcon("error16"); + errorNotificationButton.setToolTipText(translate("errors.present")); + break; } - blinkTimer = new Timer(); - blinkTimer.schedule(new TimerTask() { - @Override - public void run() { - View.execInEventDispatch(new Runnable() { - @Override - public void run() { - blinkPos++; - if ((blinkPos % 2) == 0 || (blinkPos >= 4)) { - errorNotificationButton.setIcon(View.getIcon("error16")); - } else { - errorNotificationButton.setIcon(null); - errorNotificationButton.setSize(16, 16); - } - } - }); - - if (blinkPos >= 4) { - cancel(); - } + + errorNotificationButton.setIcon(currentIcon); + + if (errorState != ErrorState.NO_ERROR) { + if (blinkTimer != null) { + blinkTimer.cancel(); } - }, 500, 500); + blinkTimer = new Timer(); + blinkTimer.schedule(new TimerTask() { + @Override + public void run() { + View.execInEventDispatch(new Runnable() { + @Override + public void run() { + blinkPos++; + if ((blinkPos % 2) == 0 || (blinkPos >= 4)) { + errorNotificationButton.setIcon(currentIcon); + } else { + errorNotificationButton.setIcon(null); + errorNotificationButton.setSize(16, 16); + } + } + }); + + if (blinkPos >= 4) { + cancel(); + } + } + }, 500, 500); + } } } diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/MainPanel.java b/trunk/src/com/jpexs/decompiler/flash/gui/MainPanel.java index f6939d863..23d2bec76 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/MainPanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/MainPanel.java @@ -255,6 +255,8 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec private static final String ACTION_SAVE_TEXT = "SAVETEXT"; private static final String ACTION_CLOSE_SWF = "CLOSESWF"; + private static final Logger logger = Logger.getLogger(MainPanel.class.getName()); + public void setPercent(int percent) { progressBar.setValue(percent); progressBar.setVisible(true); @@ -270,7 +272,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec try { File.createTempFile("temp", ".swf").delete(); //First call to this is slow, so make it first } catch (IOException ex) { - Logger.getLogger(MainPanel.class.getName()).log(Level.SEVERE, null, ex); + logger.log(Level.SEVERE, null, ex); } } @@ -2747,10 +2749,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec Helper.emptyObject(this); } - public void clearErrorState() { - statusPanel.clearErrorState(); - } - public void setErrorState() { - statusPanel.setErrorState(); + public void setErrorState(ErrorState errorState) { + statusPanel.setErrorState(errorState); } } diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/graphics/information16.png b/trunk/src/com/jpexs/decompiler/flash/gui/graphics/information16.png new file mode 100644 index 0000000000000000000000000000000000000000..12cd1aef900803abba99b26920337ec01ad5c267 GIT binary patch literal 778 zcmV+l1NHogP)BVme|mWaqy4$_pJm?y9KM{-*hp?1+Ey3e-CEDooTa!B;e(Q>TSF?bj>5At13y1p zriN3w3x~5SfZj{@J4M{kp{?=M_Lh2bV+5LH)Q)5W!-ePA$RgE1@5f1cyHki0Y}JyVEYZF(LD$xXlt$7A5CgE@ zpV-&l%vf;=5kZ2-2gi@Y6J&=cuwt>!vJ^#(&n|LcZyUzi6Duj$$hJ1s*HD-#;k-w@ zpdrwAuoDG_N2bvb07G$Zk*?Hc)JLtW4yqOnic_$zO7NZ#l>Fm){;fE?b$IbOaX2fe z0la4g0Dfw2xk7Wi7NapVD8YMPCZu?A1QCK*67dgsvRKBLFtrM>?$%&_lD1882mzdO zWPdw5KWw6IT`m1b_8=lS5jt8D3=RDa=&jWzR-)S@56WMslZ~mKu1)-wpXB>rNBQ>N zU#K`#1B&v|_AQK;7I~B}OdGiUT9LX>f0xm6<;LeP!=vFjPsUQF*wCJ*dO)4YBypgdiuF!=i@6Zyi7F|q#K zz?tlSZULa@t1D?$e;f@b36&N!V2mjOHw|*eOSYYtbpBV}~vsBnU!_?2tr-P=|^T zED%wc9ezHgW@NMb!^uT_|SvCpFLJylbx zY%bpaTGI8IYXMN$9w<3j9VkA~NYOKEQXsj?6a9_hcwfU$acAhJhB)zb_w@MVUEy@S zX&I>K-R!bhu3?(6bHWIg$HEl7{9g>>&l_qdd+UYb(1~BCo9LptNq&8>!yoJ3Ui(i5 zRJ|XnYBklL!{@$-7=3mJ>P@1c=7Oc79e-V7yf+%lD2!I;Y&nXBZ>=B!5?CB>LvEx6 znI%n)qqi$#X#wKB(U7XP2P=+4{b@j#r%9-K(8UqtSDk>0UKzf*HM9yqMZ1D!$2MdZ zR=`U>0zhOH1XqN?nY@AQqB7)Fp4{v&dKXvb43hZKvnN8;Po;+jY*}~*Z|W9Q0W%{D z^T}Cc<|r(Su=1K=P5>Z4 zg`et&Va}tdzBS-G-ZcO)zCWpJvGQwrHZ`@wpM420ac@bI5~KkTFfGEM3sPWO8co4^fI6lPnA)Y{ef%@{+SnoUk0+dW+*{8WvF8}}l07*qoM6N<$g7cXs A&j0`b literal 0 HcmV?d00001 diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/locales/MainFrame.properties b/trunk/src/com/jpexs/decompiler/flash/gui/locales/MainFrame.properties index 5517d5631..4a2392480 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/locales/MainFrame.properties +++ b/trunk/src/com/jpexs/decompiler/flash/gui/locales/MainFrame.properties @@ -394,4 +394,6 @@ menu.tools.otherTools = Other menu.tools.otherTools.clearRecentFiles = Clear recent files fontName.name = Font display name: fontName.copyright = Font copyright: -button.preview=Preview +button.preview = Preview +errors.info = There are INFORMATIONS in the log. Click to view. +errors.warning = There are WARNINGS in the log. Click to view. diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/locales/MainFrame_hu.properties b/trunk/src/com/jpexs/decompiler/flash/gui/locales/MainFrame_hu.properties index 5ac475321..7a61d9563 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/locales/MainFrame_hu.properties +++ b/trunk/src/com/jpexs/decompiler/flash/gui/locales/MainFrame_hu.properties @@ -394,3 +394,6 @@ menu.tools.otherTools = Egy\u00e9b menu.tools.otherTools.clearRecentFiles = El\u0151zm\u00e9nyek t\u00f6rl\u00e9se fontName.name = Bet\u0171t\u00edpus megjelen\u00edtett neve: fontName.copyright = Bet\u0171t\u00edpus szerz\u0151i jog: +button.preview = El\u0151n\u00e9zet +errors.info = INFORM\u00c1CI\u00d3K vannak a napl\u00f3ban. Kattintson ide a megjelen\u00edt\u00e9shez. +errors.warning = FIGYELMEZTET\u00c9SEK vannak a napl\u00f3ban. Kattintson ide a megjelen\u00edt\u00e9shez. diff --git a/trunk/src/com/jpexs/helpers/Helper.java b/trunk/src/com/jpexs/helpers/Helper.java index 361409afc..16acab420 100644 --- a/trunk/src/com/jpexs/helpers/Helper.java +++ b/trunk/src/com/jpexs/helpers/Helper.java @@ -536,6 +536,19 @@ public class Helper { return timeStr; } + public static String formatFileSize(long fileSizeLong) { + double fileSize = fileSizeLong; + if (fileSize < 1024) { + return String.format("%d bytes", fileSizeLong) ; + } + fileSize /= 1024; + if (fileSize < 1024) { + return String.format("%.2f KB", fileSize) ; + } + fileSize /= 1024; + return String.format("%.2f MB", fileSize) ; + } + public static void freeMem() { Cache.clearAll(); System.gc();