Fixes #8, Deletes "Display line number" from preferences

This commit is contained in:
emmanue1 2015-04-06 23:17:55 +02:00
parent 049b3149d2
commit 5257db58e9
3 changed files with 1 additions and 22 deletions

View File

@ -17,14 +17,12 @@ class ClassFileViewerPreferencesProvider extends JPanel implements PreferencesPa
static final String OMIT_THIS_PREFIX = 'ClassFileViewerPreferences.omitThisPrefix'
static final String REALIGN_LINE_NUMBERS = 'ClassFileViewerPreferences.realignLineNumbers'
static final String DISPLAY_DEFAULT_CONSTRUCTOR = 'ClassFileViewerPreferences.displayDefaultConstructor'
static final String DISPLAY_LINE_NUMBERS = 'ClassFileViewerPreferences.displayLineNumbers'
PreferencesPanel.PreferencesPanelChangeListener listener = null
JCheckBox escapeUnicodeCharactersCheckBox
JCheckBox omitThisPrefixCheckBox
JCheckBox realignLineNumbersCheckBox
JCheckBox displayDefaultConstructorCheckBox
JCheckBox displayLineNumbersCheckBox
ClassFileViewerPreferencesProvider() {
super(new GridLayout(0,1))
@ -33,13 +31,11 @@ class ClassFileViewerPreferencesProvider extends JPanel implements PreferencesPa
omitThisPrefixCheckBox = new JCheckBox("Omit the prefix 'this' if possible")
realignLineNumbersCheckBox = new JCheckBox('Realign line numbers')
displayDefaultConstructorCheckBox = new JCheckBox('Display default constructor')
displayLineNumbersCheckBox = new JCheckBox('Display line numbers')
add(escapeUnicodeCharactersCheckBox)
add(omitThisPrefixCheckBox)
add(realignLineNumbersCheckBox)
add(displayDefaultConstructorCheckBox)
add(displayLineNumbersCheckBox)
}
// --- PreferencesPanel --- //
@ -53,7 +49,6 @@ class ClassFileViewerPreferencesProvider extends JPanel implements PreferencesPa
omitThisPrefixCheckBox.selected = 'true'.equals(preferences.get(OMIT_THIS_PREFIX))
realignLineNumbersCheckBox.selected = 'true'.equals(preferences.get(REALIGN_LINE_NUMBERS))
displayDefaultConstructorCheckBox.selected = 'true'.equals(preferences.get(DISPLAY_DEFAULT_CONSTRUCTOR))
displayLineNumbersCheckBox.selected = !'false'.equals(preferences.get(DISPLAY_LINE_NUMBERS))
}
void savePreferences(Map<String, String> preferences) {
@ -61,7 +56,6 @@ class ClassFileViewerPreferencesProvider extends JPanel implements PreferencesPa
preferences.put(OMIT_THIS_PREFIX, Boolean.toString(omitThisPrefixCheckBox.selected))
preferences.put(REALIGN_LINE_NUMBERS, Boolean.toString(realignLineNumbersCheckBox.selected))
preferences.put(DISPLAY_DEFAULT_CONSTRUCTOR, Boolean.toString(displayDefaultConstructorCheckBox.selected))
preferences.put(DISPLAY_LINE_NUMBERS, Boolean.toString(displayLineNumbersCheckBox.selected))
}
boolean arePreferencesValid() { true }

View File

@ -33,7 +33,6 @@ class ClassFilePage
protected static final String OMIT_THIS_PREFIX = 'ClassFileViewerPreferences.omitThisPrefix'
protected static final String REALIGN_LINE_NUMBERS = 'ClassFileViewerPreferences.realignLineNumbers'
protected static final String DISPLAY_DEFAULT_CONSTRUCTOR = 'ClassFileViewerPreferences.displayDefaultConstructor'
protected static final String DISPLAY_LINE_NUMBERS = 'ClassFileViewerPreferences.displayLineNumbers'
protected static final Decompiler DECOMPILER = new DecompilerImpl()
@ -59,7 +58,6 @@ class ClassFilePage
boolean canLoad(String internalTypePath) { false }
}
def printer = new ClassFileSourcePrinter() {
boolean isShowLineNumbers() { false }
boolean getRealignmentLineNumber() { false }
boolean isShowPrefixThis() { false }
boolean isUnicodeEscape() { false }
@ -92,7 +90,6 @@ class ClassFilePage
p.setUnicodeEscape(getPreferenceValue(preferences, ESCAPE_UNICODE_CHARACTERS, false))
p.setShowPrefixThis(! getPreferenceValue(preferences, OMIT_THIS_PREFIX, false));
p.setShowDefaultConstructor(getPreferenceValue(preferences, DISPLAY_DEFAULT_CONSTRUCTOR, false))
p.setShowLineNumbers(getPreferenceValue(preferences, DISPLAY_LINE_NUMBERS, true))
p.setRealignmentLineNumber(getPreferenceValue(preferences, REALIGN_LINE_NUMBERS, false))
setShowMisalignment(p.realignmentLineNumber)
@ -416,7 +413,6 @@ class ClassFilePage
@CompileStatic
class Printer extends ClassFileSourcePrinter {
protected StringBuffer stringBuffer
protected boolean showLineNumbers
protected boolean realignmentLineNumber
protected boolean showPrefixThis
protected boolean unicodeEscape
@ -424,14 +420,12 @@ class ClassFilePage
Printer(GuiPreferences preferences) {
this.stringBuffer = new StringBuffer(10*1024)
this.showLineNumbers = preferences.isShowLineNumbers()
this.realignmentLineNumber = preferences.getRealignmentLineNumber()
this.showPrefixThis = preferences.isShowPrefixThis()
this.unicodeEscape = preferences.isUnicodeEscape()
this.referencesCache = new HashMap<>()
}
boolean isShowLineNumbers() { showLineNumbers }
boolean getRealignmentLineNumber() { realignmentLineNumber }
boolean isShowPrefixThis() { showPrefixThis }
boolean isUnicodeEscape() { unicodeEscape }

View File

@ -13,13 +13,9 @@ public abstract class ClassFileSourcePrinter implements Printer
protected static final String NEWLINE = "\n";
protected int maxLineNumber = 0;
protected int majorVersion = 0;
protected int minorVersion = 0;
protected int indentationCount;
protected boolean display;
protected abstract boolean isShowLineNumbers();
protected abstract boolean getRealignmentLineNumber();
protected abstract boolean isShowPrefixThis();
protected abstract boolean isUnicodeEscape();
@ -27,9 +23,6 @@ public abstract class ClassFileSourcePrinter implements Printer
protected abstract void append(char c);
protected abstract void append(String s);
public int getMajorVersion() { return majorVersion; }
public int getMinorVersion() { return minorVersion; }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //
public void print(byte b) { append(String.valueOf(b)); }
@ -109,11 +102,9 @@ public abstract class ClassFileSourcePrinter implements Printer
}
public void start(int maxLineNumber, int majorVersion, int minorVersion) {
this.majorVersion = majorVersion;
this.minorVersion = minorVersion;
this.indentationCount = 0;
this.display = true;
this.maxLineNumber = isShowLineNumbers() ? maxLineNumber : 0;
this.maxLineNumber = maxLineNumber;
}
public void end() {}