mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-09-25 13:00:47 +00:00
Issue #301 Clear errors log
Expand/Collapse icon in error log moved from right to left
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -15,4 +15,5 @@
|
||||
|
||||
copy = Copy to clipboard
|
||||
details = View details
|
||||
dialog.title = Log
|
||||
dialog.title = Log
|
||||
clear = Clear
|
||||
@@ -15,4 +15,5 @@
|
||||
|
||||
copy = Zkop\u00edrovat do schr\u00e1nky
|
||||
details = Zobrazit detaily
|
||||
dialog.title = Log
|
||||
dialog.title = Log
|
||||
clear = Vypr\u00e1zdnit
|
||||
Reference in New Issue
Block a user