Dave Jarvis' Repositories

git clone https://repo.autonoma.ca/repo/keenwrite.git

global 'Show Whitespace Characters' option added (was previously available with Alt+W only for active editor)

AuthorKarl Tauber <email>
Date2015-08-06 18:09:44 GMT+0200
Commit188be48f896690e0c0f23babbebbff94f708db91
Parent56c61ea
Delta42 lines added, 7 lines removed, 35-line increase
src/main/java/org/markdownwriterfx/options/GeneralOptionsPane.java
import java.util.Collection;
import java.util.SortedMap;
+import javafx.scene.control.CheckBox;
import javafx.scene.control.ComboBox;
import javafx.scene.control.Label;
lineSeparatorField.setValue(new Item<String>(Options.getLineSeparator(), Options.getLineSeparator()));
encodingField.setValue(new Item<String>(Options.getEncoding(), Options.getEncoding()));
+
+ showWhitespaceCheckBox.setSelected(Options.isShowWhitespace());
}
void save() {
Options.setLineSeparator(lineSeparatorField.getValue().value);
Options.setEncoding(encodingField.getValue().value);
+
+ Options.setShowWhitespace(showWhitespaceCheckBox.isSelected());
}
private void initComponents() {
// JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
Label lineSeparatorLabel = new Label();
lineSeparatorField = new ComboBox<>();
Label lineSeparatorLabel2 = new Label();
Label encodingLabel = new Label();
encodingField = new ComboBox<>();
+ showWhitespaceCheckBox = new CheckBox();
//======== this ========
setCols("[fill][fill][fill]");
- setRows("[][]");
+ setRows("[][]para[]");
//---- lineSeparatorLabel ----
- lineSeparatorLabel.setText("Line separator:");
+ lineSeparatorLabel.setText("_Line separator:");
+ lineSeparatorLabel.setMnemonicParsing(true);
add(lineSeparatorLabel, "cell 0 0");
add(lineSeparatorField, "cell 1 0");
//---- lineSeparatorLabel2 ----
lineSeparatorLabel2.setText("(applies to new files only)");
add(lineSeparatorLabel2, "cell 2 0");
//---- encodingLabel ----
- encodingLabel.setText("Encoding:");
+ encodingLabel.setText("En_coding:");
+ encodingLabel.setMnemonicParsing(true);
add(encodingLabel, "cell 0 1");
//---- encodingField ----
encodingField.setVisibleRowCount(20);
add(encodingField, "cell 1 1");
+
+ //---- showWhitespaceCheckBox ----
+ showWhitespaceCheckBox.setText("Show _Whitespace Characters");
+ add(showWhitespaceCheckBox, "cell 0 2 3 1,growx 0,alignx left");
// JFormDesigner - End of component initialization //GEN-END:initComponents
+
+ // TODO set this in JFormDesigner as soon as it supports labelFor
+ lineSeparatorLabel.setLabelFor(lineSeparatorField);
+ encodingLabel.setLabelFor(encodingField);
}
// JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
private ComboBox<Item<String>> lineSeparatorField;
private ComboBox<Item<String>> encodingField;
+ private CheckBox showWhitespaceCheckBox;
// JFormDesigner - End of variables declaration //GEN-END:variables
}
src/main/java/org/markdownwriterfx/options/GeneralOptionsPane.jfd
"$layoutConstraints": ""
"$columnConstraints": "[fill][fill][fill]"
- "$rowConstraints": "[][]"
+ "$rowConstraints": "[][]para[]"
} ) {
name: "this"
add( new FormComponent( "javafx.scene.control.Label" ) {
name: "lineSeparatorLabel"
- "text": "Line separator:"
+ "text": "_Line separator:"
+ "mnemonicParsing": true
auxiliary() {
"JavaCodeGenerator.variableLocal": true
add( new FormComponent( "javafx.scene.control.Label" ) {
name: "encodingLabel"
- "text": "Encoding:"
+ "text": "En_coding:"
+ "mnemonicParsing": true
auxiliary() {
"JavaCodeGenerator.variableLocal": true
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 1"
+ } )
+ add( new FormComponent( "javafx.scene.control.CheckBox" ) {
+ name: "showWhitespaceCheckBox"
+ "text": "Show _Whitespace Characters"
+ }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
+ "value": "cell 0 2 3 1,growx 0,alignx left"
} )
}, new FormLayoutConstraints( null ) {
src/main/java/org/markdownwriterfx/options/Options.java
import java.util.prefs.Preferences;
+import javafx.beans.property.BooleanProperty;
import javafx.beans.property.IntegerProperty;
+import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.property.SimpleIntegerProperty;
import javafx.beans.property.SimpleStringProperty;
setEncoding(options.get("encoding", null));
setMarkdownExtensions(options.getInt("markdownExtensions", Extensions.ALL));
+ setShowWhitespace(options.getBoolean("showWhitespace", false));
}
public static void save() {
Utils.putPrefs(options, "lineSeparator", getLineSeparator(), null);
Utils.putPrefs(options, "encoding", getEncoding(), null);
Utils.putPrefsInt(options, "markdownExtensions", getMarkdownExtensions(), Extensions.ALL);
+ Utils.putPrefsBoolean(options, "showWhitespace", isShowWhitespace(), false);
}
private static final IntegerProperty markdownExtensions = new SimpleIntegerProperty();
public static int getMarkdownExtensions() { return markdownExtensions.get(); }
- public static void setMarkdownExtensions(int extensions) { markdownExtensions.set(extensions); }
+ public static void setMarkdownExtensions(int markdownExtensions) { Options.markdownExtensions.set(markdownExtensions); }
public static IntegerProperty markdownExtensionsProperty() { return markdownExtensions; }
+
+ // 'showWhitespace' property
+ private static final BooleanProperty showWhitespace = new SimpleBooleanProperty();
+ public static boolean isShowWhitespace() { return showWhitespace.get(); }
+ public static void setShowWhitespace(boolean showWhitespace) { Options.showWhitespace.set(showWhitespace); }
+ public static BooleanProperty showWhitespaceProperty() { return showWhitespace; }
}