Skip to content

Commit

Permalink
new loading animation and ui updates
Browse files Browse the repository at this point in the history
  • Loading branch information
GraxCode committed May 2, 2020
1 parent 8672875 commit 59caea1
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 63 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ compileTestJava.options.encoding = 'UTF-8'
javadoc.options.encoding = 'UTF-8'

ext {
darklaf_ver = "2.1.0"
darklaf_ver = "2.1.1"
asm_ver = "8.0.1"
}

Expand Down
6 changes: 4 additions & 2 deletions src/me/nov/threadtear/Threadtear.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public class Threadtear extends JFrame {
private static final long serialVersionUID = 1L;
public static final Logger logger = Logger.getLogger(Logger.GLOBAL_LOGGER_NAME);
public TreePanel listPanel;
public ConfigurationPanel configPanel;
private LogFrame logFrame;

public Threadtear() {
Expand Down Expand Up @@ -82,8 +83,8 @@ private void initializeMenu() {

private void initializeFrame() {
this.setLayout(new BorderLayout(16, 16));
this.add(listPanel = new TreePanel(), BorderLayout.CENTER);
this.add(new ConfigurationPanel(this), BorderLayout.SOUTH);
this.add(listPanel = new TreePanel(this), BorderLayout.CENTER);
this.add(configPanel = new ConfigurationPanel(this), BorderLayout.SOUTH);
}

private void initBounds() {
Expand Down Expand Up @@ -161,6 +162,7 @@ public void run(boolean verbose, boolean disableSecurity) {
logger.info("Successful finish!");
System.setSecurityManager(null);
listPanel.classList.loadTree(classes);
configPanel.run.setEnabled(true);
}).start();
});
}
Expand Down
11 changes: 9 additions & 2 deletions src/me/nov/threadtear/swing/panel/ConfigurationPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ public class ConfigurationPanel extends JPanel {
private JCheckBox watermark;
private JCheckBox disableSecurity;
private JCheckBox removeSignature;
public JButton run;
public JButton save;

public ConfigurationPanel(Threadtear main) {
this.main = main;
Expand Down Expand Up @@ -86,8 +88,10 @@ private JPanel createBottomButtons() {
}
});
panel.add(saveCfg);
JButton save = new JButton("Save as jar file", IconLoader.get().loadSVGIcon("res/save.svg", false));
save = new JButton("Save as jar file", IconLoader.get().loadSVGIcon("res/save.svg", false));
save.setEnabled(false);
save.addActionListener(l -> {
save.setEnabled(false);
File inputFile = main.listPanel.classList.inputFile;
if (inputFile == null) {
JOptionPane.showMessageDialog(this, "You have to load a jar file first.");
Expand All @@ -104,10 +108,13 @@ private JPanel createBottomButtons() {
JarIO.saveAsJar(inputFile, output, main.listPanel.classList.classes, removeSignature.isSelected(), watermark.isSelected());
Threadtear.logger.info("Saved to " + output.getAbsolutePath());
}
save.setEnabled(true);
});
panel.add(save);
JButton run = new JButton("Run", IconLoader.get().loadSVGIcon("res/run.svg", false));
run = new JButton("Run", IconLoader.get().loadSVGIcon("res/run.svg", false));
run.setEnabled(false);
run.addActionListener(l -> {
run.setEnabled(false);
main.run(verbose.isSelected(), disableSecurity.isSelected());
});
panel.add(run);
Expand Down
27 changes: 6 additions & 21 deletions src/me/nov/threadtear/swing/panel/DecompilerPanel.java
Original file line number Diff line number Diff line change
@@ -1,31 +1,16 @@
package me.nov.threadtear.swing.panel;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Image;
import java.awt.Toolkit;
import java.awt.*;
import java.util.Objects;

import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
import javax.swing.text.BadLocationException;
import javax.swing.text.DefaultHighlighter;
import javax.swing.text.Document;
import javax.swing.text.Highlighter;
import javax.swing.text.*;

import org.fife.ui.rtextarea.RTextScrollPane;
import org.objectweb.asm.tree.ClassNode;

import com.github.weisj.darklaf.components.loading.LoadingIndicator;
import com.github.weisj.darklaf.icons.IconLoader;
import com.github.weisj.darklaf.ui.text.DarkTextUI;

Expand All @@ -39,7 +24,6 @@ public class DecompilerPanel extends JPanel {

private int searchIndex = -1;
private String lastSearchText = null;
private ImageIcon loading = new ImageIcon(Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("/res/spin.gif")).getScaledInstance(32, 32, Image.SCALE_DEFAULT));

public DecompilerPanel(ClassNode cn) {
this.setLayout(new BorderLayout(4, 4));
Expand Down Expand Up @@ -103,7 +87,8 @@ public DecompilerPanel(ClassNode cn) {
topPanel.add(new JLabel("<html>CFR Decompiler 0.149 (<i>www.benf.org/other/cfr</i>)"), BorderLayout.WEST);
topPanel.add(actionPanel, BorderLayout.EAST);
this.add(topPanel, BorderLayout.NORTH);
JLabel loadingLabel = new JLabel("Decompiling... ", loading, JLabel.CENTER);
LoadingIndicator loadingLabel = new LoadingIndicator("Decompiling class file... ", JLabel.CENTER);
loadingLabel.setRunning(true);
this.add(loadingLabel, BorderLayout.CENTER);
SwingUtilities.invokeLater(() -> {
new Thread(() -> {
Expand Down
5 changes: 3 additions & 2 deletions src/me/nov/threadtear/swing/panel/TreePanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import javax.swing.JSplitPane;
import javax.swing.Timer;

import me.nov.threadtear.Threadtear;
import me.nov.threadtear.swing.tree.ClassTreePanel;
import me.nov.threadtear.swing.tree.ExecutionListPanel;

Expand All @@ -17,12 +18,12 @@ public class TreePanel extends JPanel {
public ClassTreePanel classList;
public ExecutionListPanel executionList;

public TreePanel() {
public TreePanel(Threadtear threadtear) {
this.setLayout(new BorderLayout(16, 16));
this.setBorder(BorderFactory.createEmptyBorder(16, 16, 16, 16));
JPanel inner = new JPanel();
inner.setLayout(new GridLayout(1, 2, 16, 16));
JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, executionList = new ExecutionListPanel(), classList = new ClassTreePanel());
JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, executionList = new ExecutionListPanel(), classList = new ClassTreePanel(threadtear));
split.putClientProperty("JSplitPane.style", "invisible");
inner.add(split);
this.add(inner, BorderLayout.CENTER);
Expand Down
6 changes: 4 additions & 2 deletions src/me/nov/threadtear/swing/textarea/DecompilerTextArea.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;
import org.fife.ui.rsyntaxtextarea.Theme;

import com.github.weisj.darklaf.*;

public class DecompilerTextArea extends RSyntaxTextArea {
private static final long serialVersionUID = 1L;

Expand All @@ -15,9 +17,9 @@ public DecompilerTextArea() {
this.setAntiAliasingEnabled(true);
this.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 12));
this.setEditable(false);

String themeName = com.github.weisj.darklaf.theme.Theme.isDark(LafManager.getTheme()) ? "/res/rsta-theme.xml" : "/org/fife/ui/rsyntaxtextarea/themes/eclipse.xml";
try {
Theme theme = Theme.load(getClass().getResourceAsStream("/res/rsta-theme.xml"));
Theme theme = Theme.load(getClass().getResourceAsStream(themeName));
theme.apply(this);
} catch (IOException e) {
e.printStackTrace();
Expand Down
52 changes: 19 additions & 33 deletions src/me/nov/threadtear/swing/tree/ClassTreePanel.java
Original file line number Diff line number Diff line change
@@ -1,44 +1,28 @@
package me.nov.threadtear.swing.tree;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.Image;
import java.awt.Toolkit;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Enumeration;

import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.SwingUtilities;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreePath;
import javax.swing.tree.TreeSelectionModel;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.util.*;

import javax.swing.*;
import javax.swing.tree.*;

import com.github.weisj.darklaf.components.loading.LoadingIndicator;
import com.github.weisj.darklaf.icons.IconLoader;

import me.nov.threadtear.io.Clazz;
import me.nov.threadtear.io.JarIO;
import me.nov.threadtear.Threadtear;
import me.nov.threadtear.io.*;
import me.nov.threadtear.swing.Utils;
import me.nov.threadtear.swing.dialog.JarAnalysis;
import me.nov.threadtear.swing.frame.BytecodeFrame;
import me.nov.threadtear.swing.frame.DecompilerFrame;
import me.nov.threadtear.swing.handler.ILoader;
import me.nov.threadtear.swing.handler.JarDropHandler;
import me.nov.threadtear.swing.frame.*;
import me.nov.threadtear.swing.handler.*;
import me.nov.threadtear.swing.tree.component.SortedTreeClassNode;
import me.nov.threadtear.swing.tree.renderer.ClassTreeCellRenderer;

public class ClassTreePanel extends JPanel implements ILoader {
private static final long serialVersionUID = 1L;
private Threadtear threadtear;
public File inputFile;
public ArrayList<Clazz> classes;
public DefaultTreeModel model;
Expand All @@ -50,7 +34,8 @@ public class ClassTreePanel extends JPanel implements ILoader {
private JButton bytecode;
private JButton ignore;

public ClassTreePanel() {
public ClassTreePanel(Threadtear threadtear) {
this.threadtear = threadtear;
this.setLayout(new BorderLayout());
this.add(outerPanel = Utils.addTitleAndBorder("Class list", new JScrollPane(tree = new ClassTree())), BorderLayout.CENTER);
this.add(createButtons(), BorderLayout.SOUTH);
Expand Down Expand Up @@ -172,12 +157,11 @@ public void mouseClicked(MouseEvent e) {
}
}

private ImageIcon loading = new ImageIcon(Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("/res/spin.gif")).getScaledInstance(32, 32, Image.SCALE_DEFAULT));

@Override
public void onJarLoad(File input) {
this.remove(outerPanel);
JLabel loadingLabel = new JLabel("Loading class files... ", loading, JLabel.CENTER);
LoadingIndicator loadingLabel = new LoadingIndicator("Loading class files... ", JLabel.CENTER);
loadingLabel.setRunning(true);
this.add(loadingLabel, BorderLayout.CENTER);
this.invalidate();
this.validate();
Expand All @@ -200,6 +184,8 @@ public void onJarLoad(File input) {
refreshIgnored();
model.reload();
analysis.setEnabled(true);
threadtear.configPanel.run.setEnabled(true);
threadtear.configPanel.save.setEnabled(true);
this.remove(loadingLabel);
this.add(outerPanel, BorderLayout.CENTER);
this.invalidate();
Expand Down
Binary file removed src/res/spin.gif
Binary file not shown.

0 comments on commit 59caea1

Please sign in to comment.