mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-09-25 16:00:46 +00:00
Issue #301 Reseting icon on clearing error log
Logging errors to GUI on application startup / file load
This commit is contained in:
@@ -200,7 +200,6 @@ public class ErrorLogFrame extends AppFrame {
|
||||
|
||||
|
||||
JLabel levelLabel = new JLabel(level.getName());
|
||||
levelLabel.setPreferredSize(new Dimension(75, 25));
|
||||
levelLabel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
|
||||
header.add(levelLabel);
|
||||
JTextArea msgLabel = new JTextArea(msg);
|
||||
|
||||
@@ -57,7 +57,9 @@ import java.util.Locale;
|
||||
import java.util.Properties;
|
||||
import java.util.logging.ConsoleHandler;
|
||||
import java.util.logging.FileHandler;
|
||||
import java.util.logging.Handler;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.LogRecord;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.logging.SimpleFormatter;
|
||||
import java.util.regex.Matcher;
|
||||
@@ -102,6 +104,7 @@ public class Main {
|
||||
public static LoadFromMemoryFrame loadFromMemoryFrame;
|
||||
public static LoadFromCacheFrame loadFromCacheFrame;
|
||||
public static boolean readOnly = false;
|
||||
private static ErrorLogFrame errorLogFrame;
|
||||
|
||||
public static void loadFromCache() {
|
||||
if (loadFromCacheFrame == null) {
|
||||
@@ -291,6 +294,9 @@ public class Main {
|
||||
@Override
|
||||
public void run() {
|
||||
mainFrame = new MainFrame(swf);
|
||||
if (errorState) {
|
||||
mainFrame.setErrorState();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -470,12 +476,62 @@ public class Main {
|
||||
}
|
||||
}
|
||||
|
||||
public static void displayErrorFrame() {
|
||||
if (errorLogFrame != null) {
|
||||
errorLogFrame.setVisible(true);
|
||||
}
|
||||
}
|
||||
private static boolean errorState = false;
|
||||
|
||||
private static void initGui() {
|
||||
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.setErrorState();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flush() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws SecurityException {
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
autoCheckForUpdates();
|
||||
offerAssociation();
|
||||
}
|
||||
|
||||
public static void showModeFrame() {
|
||||
View.execInEventDispatch(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (mainFrame == null) {
|
||||
mainFrame = new MainFrame(null);
|
||||
if (errorState) {
|
||||
mainFrame.setErrorState();
|
||||
}
|
||||
}
|
||||
mainFrame.setVisible(true);
|
||||
}
|
||||
@@ -783,8 +839,7 @@ public class Main {
|
||||
int retryCount = 0;
|
||||
|
||||
if (args.length < pos + 1) {
|
||||
autoCheckForUpdates();
|
||||
offerAssociation();
|
||||
initGui();
|
||||
showModeFrame();
|
||||
} else {
|
||||
boolean parameterProcessed = true;
|
||||
@@ -1050,8 +1105,8 @@ public class Main {
|
||||
printCmdLineUsage();
|
||||
System.exit(0);
|
||||
} else if (args.length == pos + 1) {
|
||||
autoCheckForUpdates();
|
||||
offerAssociation();
|
||||
|
||||
initGui();
|
||||
openFile(args[pos]);
|
||||
} else {
|
||||
badArguments();
|
||||
@@ -1347,6 +1402,10 @@ public class Main {
|
||||
fileTxt.setFormatter(formatterTxt);
|
||||
logger.addHandler(fileTxt);
|
||||
|
||||
errorState = false;
|
||||
if (mainFrame != null) {
|
||||
mainFrame.clearErrorState();
|
||||
}
|
||||
}
|
||||
|
||||
public static void initLogging(boolean debug) {
|
||||
|
||||
@@ -158,9 +158,7 @@ import java.util.Stack;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import java.util.TreeSet;
|
||||
import java.util.logging.Handler;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.LogRecord;
|
||||
import java.util.logging.Logger;
|
||||
import javax.swing.Box;
|
||||
import javax.swing.BoxLayout;
|
||||
@@ -288,7 +286,6 @@ public class MainFrame extends AppRibbonFrame implements ActionListener, TreeSel
|
||||
private JTextArea fontCharactersTextArea;
|
||||
private JTextField fontAddCharactersField;
|
||||
private JButton errorNotificationButton;
|
||||
private ErrorLogFrame errorLogFrame;
|
||||
private ComponentListener fontChangeList;
|
||||
private JComboBox<String> fontSelection;
|
||||
private JCommandButton saveCommandButton;
|
||||
@@ -1054,7 +1051,7 @@ public class MainFrame extends AppRibbonFrame implements ActionListener, TreeSel
|
||||
statusPanel.add(loadingPanel, BorderLayout.WEST);
|
||||
statusPanel.add(statusLabel, BorderLayout.CENTER);
|
||||
|
||||
errorLogFrame = new ErrorLogFrame();
|
||||
|
||||
errorNotificationButton = new JButton("");
|
||||
errorNotificationButton.setIcon(View.getIcon("okay16"));
|
||||
errorNotificationButton.setBorderPainted(false);
|
||||
@@ -1490,66 +1487,6 @@ public class MainFrame extends AppRibbonFrame implements ActionListener, TreeSel
|
||||
|
||||
//Opening files with drag&drop to main window
|
||||
enableDrop(true);
|
||||
|
||||
Logger logger = Logger.getLogger("");
|
||||
logger.addHandler(errorLogFrame.getHandler());
|
||||
logger.addHandler(new Handler() {
|
||||
private Timer timer = null;
|
||||
private int pos = 0;
|
||||
|
||||
@Override
|
||||
public void publish(final LogRecord record) {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (record.getLevel() == Level.SEVERE) {
|
||||
if (errorNotificationButton == null) {
|
||||
// todo: honfika
|
||||
// why null?
|
||||
return;
|
||||
}
|
||||
|
||||
errorNotificationButton.setIcon(View.getIcon("error16"));
|
||||
errorNotificationButton.setToolTipText(translate("errors.present"));
|
||||
if (timer != null) {
|
||||
timer.cancel();
|
||||
}
|
||||
timer = new Timer();
|
||||
timer.schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
View.execInEventDispatch(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
pos++;
|
||||
if ((pos % 2) == 0 || (pos >= 4)) {
|
||||
errorNotificationButton.setIcon(View.getIcon("error16"));
|
||||
} else {
|
||||
errorNotificationButton.setIcon(null);
|
||||
errorNotificationButton.setSize(16, 16);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (pos >= 4) {
|
||||
cancel();
|
||||
}
|
||||
}
|
||||
}, 500, 500);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flush() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws SecurityException {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void enableDrop(boolean value) {
|
||||
@@ -2370,7 +2307,7 @@ public class MainFrame extends AppRibbonFrame implements ActionListener, TreeSel
|
||||
Main.loadFromCache();
|
||||
break;
|
||||
case "SHOWERRORLOG":
|
||||
errorLogFrame.setVisible(true);
|
||||
Main.displayErrorFrame();
|
||||
break;
|
||||
case "FONTADDCHARS":
|
||||
String newchars = fontAddCharactersField.getText();
|
||||
@@ -3638,4 +3575,46 @@ public class MainFrame extends AppRibbonFrame implements ActionListener, TreeSel
|
||||
public void free() {
|
||||
Helper.emptyObject(this);
|
||||
}
|
||||
|
||||
public void clearErrorState() {
|
||||
errorNotificationButton.setIcon(View.getIcon("okay16"));
|
||||
errorNotificationButton.setToolTipText(translate("errors.none"));
|
||||
}
|
||||
private Timer blinkTimer;
|
||||
private int blinkPos;
|
||||
|
||||
public void setErrorState() {
|
||||
if (errorNotificationButton == null) {
|
||||
// todo: honfika
|
||||
// why null?
|
||||
return;
|
||||
}
|
||||
errorNotificationButton.setIcon(View.getIcon("error16"));
|
||||
errorNotificationButton.setToolTipText(translate("errors.present"));
|
||||
if (blinkTimer != null) {
|
||||
blinkTimer.cancel();
|
||||
}
|
||||
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();
|
||||
}
|
||||
}
|
||||
}, 500, 500);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user