Skip to content

Commit

Permalink
Resolved again
Browse files Browse the repository at this point in the history
  • Loading branch information
Col-E committed Oct 14, 2017
2 parents 31478cd + 864ea1f commit 4382529
Show file tree
Hide file tree
Showing 62 changed files with 4,520 additions and 4,436 deletions.
5 changes: 5 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@
</reportSet>
</reportSets>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.0.0-M1</version>
</plugin>
</plugins>
</reporting>

Expand Down
15 changes: 0 additions & 15 deletions src/me/coley/recaf/Main.java

This file was deleted.

200 changes: 100 additions & 100 deletions src/me/coley/recaf/Options.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,108 +14,108 @@
import me.coley.recaf.util.Misc;

public class Options {
/**
* File to store config in.
*/
private final static File optionsFile = new File("rcoptions.json");
/**
* Show confirmation prompt on doing potentially dangerous things.
*/
public boolean confirmDeletions = true;
/**
* Show extra jump information.
*/
public boolean opcodeShowJumpHelp = true;
/**
* Simplify descriptor displays on the opcode list.
*/
public boolean opcodeSimplifyDescriptors = true;
/**
* Display variable's signature in the opcode edit window for variable
* opcodes. Allows editing of signatures <i>(Generic types)</i> and
* significantly increases the edit window size.
*/
public boolean showVariableSignatureInTable;
/**
* Flags for reading in classes.
*/
public int classFlagsInput = ClassReader.EXPAND_FRAMES;
/**
* Flags for writing classes.
*/
public int classFlagsOutput = ClassWriter.COMPUTE_FRAMES;
/**
* Max length for text in ldc opcodes to be displayed.
*/
public int ldcMaxLength = 125;
/**
* File to store config in.
*/
private final static File optionsFile = new File("rcoptions.json");
/**
* Show confirmation prompt on doing potentially dangerous things.
*/
public boolean confirmDeletions = true;
/**
* Show extra jump information.
*/
public boolean opcodeShowJumpHelp = true;
/**
* Simplify descriptor displays on the opcode list.
*/
public boolean opcodeSimplifyDescriptors = true;
/**
* Display variable's signature in the opcode edit window for variable
* opcodes. Allows editing of signatures <i>(Generic types)</i> and
* significantly increases the edit window size.
*/
public boolean showVariableSignatureInTable;
/**
* Flags for reading in classes.
*/
public int classFlagsInput = ClassReader.EXPAND_FRAMES;
/**
* Flags for writing classes.
*/
public int classFlagsOutput = ClassWriter.COMPUTE_FRAMES;
/**
* Max length for text in ldc opcodes to be displayed.
*/
public int ldcMaxLength = 125;

public Options() {
Runtime.getRuntime().addShutdownHook(new Thread() {
@Override
public void run() {
save();
}
});
}
public Options() {
Runtime.getRuntime().addShutdownHook(new Thread() {
@Override
public void run() {
save();
}
});
}

/**
* Load from configuration.
*/
public void load() {
if (!optionsFile.exists()) {
return;
}
try {
JsonObject json = Json.parse(Misc.readFile(optionsFile.getAbsolutePath())).asObject();
for (Field field : Options.class.getDeclaredFields()) {
String name = field.getName();
JsonValue value = json.get(name);
if (value == null) {
continue;
}
field.setAccessible(true);
if (value.isBoolean()) {
field.set(this, value.asBoolean());
} else if (value.isNumber()) {
field.set(this, value.asInt());
} else if (value.isString()) {
field.set(this, value.asString());
}
}
} catch (Exception e) {
// TODO: Propper logging
e.printStackTrace();
}
}
/**
* Load from configuration.
*/
public void load() {
if (!optionsFile.exists()) {
return;
}
try {
JsonObject json = Json.parse(Misc.readFile(optionsFile.getAbsolutePath())).asObject();
for (Field field : Options.class.getDeclaredFields()) {
String name = field.getName();
JsonValue value = json.get(name);
if (value == null) {
continue;
}
field.setAccessible(true);
if (value.isBoolean()) {
field.set(this, value.asBoolean());
} else if (value.isNumber()) {
field.set(this, value.asInt());
} else if (value.isString()) {
field.set(this, value.asString());
}
}
} catch (Exception e) {
// TODO: Propper logging
e.printStackTrace();
}
}

/**
* Save current settings to configuration.
*/
public void save() {
try {
if (!optionsFile.exists()) {
optionsFile.createNewFile();
}
JsonObject json = Json.object();
for (Field field : Options.class.getDeclaredFields()) {
field.setAccessible(true);
String name = field.getName();
Object value = field.get(this);
if (value instanceof Boolean) {
json.set(name, (boolean) value);
} else if (value instanceof Integer) {
json.set(name, (int) value);
} else if (value instanceof String) {
json.set(name, (String) value);
}
}
StringWriter w = new StringWriter();
json.writeTo(w, WriterConfig.PRETTY_PRINT);
Misc.writeFile(optionsFile.getAbsolutePath(), w.toString());
} catch (Exception e) {
// TODO: Propper logging
e.getMessage();
}
}
/**
* Save current settings to configuration.
*/
public void save() {
try {
if (!optionsFile.exists()) {
optionsFile.createNewFile();
}
JsonObject json = Json.object();
for (Field field : Options.class.getDeclaredFields()) {
field.setAccessible(true);
String name = field.getName();
Object value = field.get(this);
if (value instanceof Boolean) {
json.set(name, (boolean) value);
} else if (value instanceof Integer) {
json.set(name, (int) value);
} else if (value instanceof String) {
json.set(name, (String) value);
}
}
StringWriter w = new StringWriter();
json.writeTo(w, WriterConfig.PRETTY_PRINT);
Misc.writeFile(optionsFile.getAbsolutePath(), w.toString());
} catch (Exception e) {
// TODO: Propper logging
e.getMessage();
}
}

}
100 changes: 50 additions & 50 deletions src/me/coley/recaf/Recaf.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,62 +14,62 @@
import me.coley.recaf.ui.Gui;

public class Recaf {
private static Recaf instance;
public Gui window;
public File currentJar;
public JarData jarData;
public FileChoosers fileChoosers;
public Options options;
public AsmUtil asm;
private static Recaf instance;
public Gui window;
public File currentJar;
public JarData jarData;
public FileChoosers fileChoosers;
public Options options;
public AsmUtil asm;

public Recaf() {
instance = this;
fileChoosers = new FileChoosers();
options = new Options();
options.load();
asm = new AsmUtil();
}
public Recaf() {
instance = this;
fileChoosers = new FileChoosers();
options = new Options();
options.load();
asm = new AsmUtil();
}

public void openFile(File file) throws IOException {
this.currentJar = file;
this.jarData = new JarData(file);
this.window.updateTree();
this.window.getFrame().setTitle("Recaf: " + file.getName());
}
public void openFile(File file) throws IOException {
this.currentJar = file;
this.jarData = new JarData(file);
this.window.updateTree();
this.window.getFrame().setTitle("Recaf: " + file.getName());
}

public void saveFile(File file) throws IOException {
this.jarData.save(file);
}
public void saveFile(File file) throws IOException {
this.jarData.save(file);
}

public void selectClass(ClassNode node) {
this.window.addClassView(node);
}
public void selectClass(ClassNode node) {
this.window.addClassView(node);
}

public void showGui() {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
window = new Gui();
window.getFrame().setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
public void showGui() {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
window = new Gui();
window.getFrame().setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}

public static Recaf getInstance() {
return instance;
}
public static Recaf getInstance() {
return instance;
}

public static void main(String[] args) {
try {
UIManager.setLookAndFeel("javax.swing.plaf.nimbus.NimbusLookAndFeel");
} catch (Exception e) {
e.printStackTrace();
}
Recaf program = new Recaf();
program.showGui();
public static void main(String[] args) {
try {
UIManager.setLookAndFeel("javax.swing.plaf.nimbus.NimbusLookAndFeel");
} catch (Exception e) {
e.printStackTrace();
}
Recaf program = new Recaf();
program.showGui();

}
}
}
Loading

0 comments on commit 4382529

Please sign in to comment.