bcv-vf/src/main/java/the/bytecode/club/bytecodeviewer/resources/exporting/impl/RunnableJarExporter.java

55 lines
1.4 KiB
Java
Raw Normal View History

2021-06-27 20:41:38 +00:00
package the.bytecode.club.bytecodeviewer.resources.exporting.impl;
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
import the.bytecode.club.bytecodeviewer.Configuration;
import the.bytecode.club.bytecodeviewer.gui.components.ExportJar;
import the.bytecode.club.bytecodeviewer.gui.components.FileChooser;
import the.bytecode.club.bytecodeviewer.resources.exporting.Exporter;
import the.bytecode.club.bytecodeviewer.util.DialogueUtils;
2021-06-27 20:41:38 +00:00
import javax.swing.*;
import java.io.File;
/**
* @author Konloch
* @since 6/27/2021
*/
public class RunnableJarExporter implements Exporter
{
@Override
public void promptForExport()
{
2021-07-07 02:46:12 +00:00
if (BytecodeViewer.promptIfNoLoadedClasses())
2021-06-27 20:41:38 +00:00
return;
Thread exportThread = new Thread(() ->
{
2021-07-03 19:29:31 +00:00
if (BytecodeViewer.autoCompileSuccessful())
2021-06-27 20:41:38 +00:00
return;
JFileChooser fc = new FileChooser(Configuration.getLastDirectory(),
2021-06-27 20:41:38 +00:00
"Select Jar Export",
"Jar Archives",
"jar");
int returnVal = fc.showSaveDialog(BytecodeViewer.viewer);
if (returnVal == JFileChooser.APPROVE_OPTION)
{
Configuration.lastDirectory = fc.getSelectedFile().getAbsolutePath();
File file = fc.getSelectedFile();
String path = file.getAbsolutePath();
//auto append .jar
if (!path.endsWith(".jar"))
path = path + ".jar";
if (!DialogueUtils.canOverwriteFile(path))
return;
2021-06-27 20:41:38 +00:00
new ExportJar(path).setVisible(true);
}
2021-07-01 09:48:10 +00:00
}, "Runnable Jar Export");
2021-06-27 20:41:38 +00:00
exportThread.start();
}
}