Skip to content

Commit

Permalink
Optimize the preferences panel
Browse files Browse the repository at this point in the history
  • Loading branch information
emmanue1 committed May 14, 2019
1 parent c878ce7 commit 72192e4
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
import java.awt.*;
import java.util.Map;

public class ClassFileViewerPreferencesProvider extends JPanel implements PreferencesPanel {
protected static final String ESCAPE_UNICODE_CHARACTERS = "ClassFileViewerPreferences.escapeUnicodeCharacters";
protected static final String REALIGN_LINE_NUMBERS = "ClassFileViewerPreferences.realignLineNumbers";
public class ClassFileDecompilerPreferencesProvider extends JPanel implements PreferencesPanel {
protected static final String ESCAPE_UNICODE_CHARACTERS = "ClassFileDecompilerPreferences.escapeUnicodeCharacters";
protected static final String REALIGN_LINE_NUMBERS = "ClassFileDecompilerPreferences.realignLineNumbers";

protected PreferencesPanel.PreferencesPanelChangeListener listener = null;
protected JCheckBox escapeUnicodeCharactersCheckBox;
protected JCheckBox realignLineNumbersCheckBox;

public ClassFileViewerPreferencesProvider() {
public ClassFileDecompilerPreferencesProvider() {
super(new GridLayout(0,1));

escapeUnicodeCharactersCheckBox = new JCheckBox("Escape unicode characters");
Expand All @@ -32,7 +32,7 @@ public ClassFileViewerPreferencesProvider() {
}

// --- PreferencesPanel --- //
@Override public String getPreferencesGroupTitle() { return "Viewer"; }
@Override public String getPreferencesGroupTitle() { return "Decompiler"; }
@Override public String getPreferencesPanelTitle() { return "Class file"; }
@Override public JComponent getPanel() { return this; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,18 @@
import java.util.Map;

public class ClassFileSaverPreferencesProvider extends JPanel implements PreferencesPanel {
protected static final String ESCAPE_UNICODE_CHARACTERS = "ClassFileSaverPreferences.escapeUnicodeCharacters";
protected static final String REALIGN_LINE_NUMBERS = "ClassFileSaverPreferences.realignLineNumbers";
protected static final String WRITE_LINE_NUMBERS = "ClassFileSaverPreferences.writeLineNumbers";
protected static final String WRITE_METADATA = "ClassFileSaverPreferences.writeMetadata";

protected JCheckBox escapeUnicodeCharactersCheckBox;
protected JCheckBox realignLineNumbersCheckBox;
protected JCheckBox writeLineNumbersCheckBox;
protected JCheckBox writeMetadataCheckBox;

public ClassFileSaverPreferencesProvider() {
super(new GridLayout(0,1));

escapeUnicodeCharactersCheckBox = new JCheckBox("Escape unicode characters");
realignLineNumbersCheckBox = new JCheckBox("Realign line numbers");
writeLineNumbersCheckBox = new JCheckBox("Write original line numbers");
writeMetadataCheckBox = new JCheckBox("Write metadata");

add(escapeUnicodeCharactersCheckBox);
add(realignLineNumbersCheckBox);
add(writeLineNumbersCheckBox);
add(writeMetadataCheckBox);
}
Expand All @@ -49,16 +41,12 @@ public ClassFileSaverPreferencesProvider() {

@Override
public void loadPreferences(Map<String, String> preferences) {
escapeUnicodeCharactersCheckBox.setSelected("true".equals(preferences.get(ESCAPE_UNICODE_CHARACTERS)));
realignLineNumbersCheckBox.setSelected(!"false".equals(preferences.get(REALIGN_LINE_NUMBERS)));
writeLineNumbersCheckBox.setSelected(!"false".equals(preferences.get(WRITE_LINE_NUMBERS)));
writeMetadataCheckBox.setSelected(!"false".equals(preferences.get(WRITE_METADATA)));
}

@Override
public void savePreferences(Map<String, String> preferences) {
preferences.put(ESCAPE_UNICODE_CHARACTERS, Boolean.toString(escapeUnicodeCharactersCheckBox.isSelected()));
preferences.put(REALIGN_LINE_NUMBERS, Boolean.toString(realignLineNumbersCheckBox.isSelected()));
preferences.put(WRITE_LINE_NUMBERS, Boolean.toString(writeLineNumbersCheckBox.isSelected()));
preferences.put(WRITE_METADATA, Boolean.toString(writeMetadataCheckBox.isSelected()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
import java.util.jar.Manifest;

public class ClassFileSourceSaverProvider extends AbstractSourceSaverProvider {
protected static final String ESCAPE_UNICODE_CHARACTERS = "ClassFileSaverPreferences.escapeUnicodeCharacters";
protected static final String REALIGN_LINE_NUMBERS = "ClassFileSaverPreferences.realignLineNumbers";
protected static final String ESCAPE_UNICODE_CHARACTERS = "ClassFileDecompilerPreferences.escapeUnicodeCharacters";
protected static final String REALIGN_LINE_NUMBERS = "ClassFileDecompilerPreferences.realignLineNumbers";
protected static final String WRITE_LINE_NUMBERS = "ClassFileSaverPreferences.writeLineNumbers";
protected static final String WRITE_METADATA = "ClassFileSaverPreferences.writeMetadata";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
import java.util.Map;

public class ClassFilePage extends TypePage {
protected static final String ESCAPE_UNICODE_CHARACTERS = "ClassFileViewerPreferences.escapeUnicodeCharacters";
protected static final String REALIGN_LINE_NUMBERS = "ClassFileViewerPreferences.realignLineNumbers";
protected static final String ESCAPE_UNICODE_CHARACTERS = "ClassFileDecompilerPreferences.escapeUnicodeCharacters";
protected static final String REALIGN_LINE_NUMBERS = "ClassFileDecompilerPreferences.realignLineNumbers";

protected static final ClassFileToJavaSourceDecompiler DECOMPILER = new ClassFileToJavaSourceDecompiler();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
org.jd.gui.service.preferencespanel.DirectoryIndexerPreferencesProvider
org.jd.gui.service.preferencespanel.ClassFileSaverPreferencesProvider
org.jd.gui.service.preferencespanel.ClassFileViewerPreferencesProvider
org.jd.gui.service.preferencespanel.ClassFileDecompilerPreferencesProvider
org.jd.gui.service.preferencespanel.ViewerPreferencesProvider

0 comments on commit 72192e4

Please sign in to comment.