Skip to content

Commit

Permalink
Save last selected Forge version. Closes #13.
Browse files Browse the repository at this point in the history
  • Loading branch information
Parker8283 committed Apr 8, 2015
1 parent f24b7b9 commit 7ee5716
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apply plugin: 'maven'
apply plugin: 'eclipse'
apply plugin: 'idea'

version = "2.1.2"
version = "2.1.3"
group = "com.github.parker8283"
archivesBaseName = "BON"

Expand Down
10 changes: 9 additions & 1 deletion src/main/java/com/github/parker8283/bon2/BON2.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.lang.reflect.Method;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.prefs.Preferences;

import javax.swing.*;
import javax.swing.GroupLayout.Alignment;
Expand All @@ -15,14 +16,17 @@
import com.github.parker8283.bon2.listener.BrowseListener;
import com.github.parker8283.bon2.listener.RefreshListener;
import com.github.parker8283.bon2.listener.StartListener;
import com.google.common.base.Strings;

public class BON2 extends JFrame {
public static final String ERROR_DIALOG_TITLE = "Error - BON2";
public static final File ASM_4_JAR = new File(BONFiles.MODULES_FILES_FOLDER, "org.ow2.asm" + File.separator + "asm-debug-all" + File.separator + "4.1" + File.separator + "dd6ba5c392d4102458494e29f54f70ac534ec2a2" + File.separator + "asm-debug-all-4.1.jar");
public static final File ASM_5_JAR = new File(BONFiles.MODULES_FILES_FOLDER, "org.ow2.asm" + File.separator + "asm-debug-all" + File.separator + "5.0.3" + File.separator + "f9e364ae2a66ce2a543012a4668856e84e5dab74" + File.separator + "asm-debug-all-5.0.3.jar");
public static final File GUAVA_JAR = new File(BONFiles.MODULES_FILES_FOLDER, "com.google.guava" + File.separator + "guava" + File.separator + "17.0" + File.separator + "9c6ef172e8de35fd8d4d8783e4821e57cdef7445" + File.separator + "guava-17.0.jar");
public final Preferences prefs = Preferences.userNodeForPackage(BON2.class);
public static final String PREFS_KEY_FORGEVER = "forgeVer";
public static final long serialVersionUID = -619289399889088924L;

private static final long serialVersionUID = -619289399889088924L;
private JPanel contentPane;
private JTextField inputJarLoc;
private JLabel lblOutput;
Expand Down Expand Up @@ -88,6 +92,10 @@ public BON2() {
RefreshListener refresh = new RefreshListener(this, forgeVersions);
btnRefreshVers.addMouseListener(refresh);
refresh.mouseClicked(null); // update the versions initially
String forgeVer = prefs.get(PREFS_KEY_FORGEVER, "");
if(!Strings.isNullOrEmpty(forgeVer) && refresh.isValidForgeVer(forgeVer)) {
forgeVersions.setSelectedItem(forgeVer);
}

masterProgress = new JProgressBar();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,14 @@ public void mouseClicked(MouseEvent e) {
private boolean hasAdditionalMappings(File file) {
return new File(file, "snapshot").exists() || new File(file, "snapshot_nodoc").exists() || new File(file, "stable").exists() || new File(file, "stable_nodoc").exists();
}

public boolean isValidForgeVer(String candidate) {
for(int i = 0; i < comboBox.getItemCount(); i++) {
String e = comboBox.getItemAt(i).toString();
if(candidate.equals(e)) {
return true;
}
}
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ public StartListener(Component parent, JTextField input, JTextField output, JCom

@Override
public void mouseClicked(MouseEvent e) {
assert parent instanceof BON2 : "Parent component must be an instance of BON2";
((BON2)parent).prefs.put(BON2.PREFS_KEY_FORGEVER, forgeVer.getSelectedItem().toString());
if(!input.getText().endsWith(".jar") || !output.getText().endsWith(".jar")) {
JOptionPane.showMessageDialog(parent, "Nice try, but only JAR mods work.", BON2.ERROR_DIALOG_TITLE, JOptionPane.ERROR_MESSAGE);
}
Expand Down

0 comments on commit 7ee5716

Please sign in to comment.