Dave Jarvis' Repositories

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

YAML parsing into a tree view (still buggy).

Authordjarvis <email>
Date2016-10-21 21:33:12 GMT-0700
Commitd25498ebd87fb2078f0f0b62e9bc985be4f1122d
Parent6c6fb79
Delta484 lines added, 34 lines removed, 450-line increase
src/main/resources/com/scrivendor/messages.properties
#---- FileEditorTabPane ----
-FileEditorTabPane.openChooser.title=Open Markdown File
-FileEditorTabPane.saveChooser.title=Save Markdown File
-FileEditorTabPane.closeAlert.message=''{0}'' has been modified. Save changes?
-FileEditorTabPane.closeAlert.title=Close
-FileEditorTabPane.chooser.markdownFilesFilter=Markdown Files
-FileEditorTabPane.chooser.allFilesFilter=All Files
+Dialog.file.choose.open.title=Open File
+Dialog.file.choose.save.title=Save File
+
+Alert.file.close.title=Close
+Alert.file.close.text=''{0}'' has been modified. Save changes?
+Dialog.file.choose.filter.title.markdown=Markdown Files
+Dialog.file.choose.filter.title.definition=Definition Files
+Dialog.file.choose.filter.title.all=All Files
#==== Controls ================================================================
src/main/resources/com/scrivendor/settings.properties
-# Comma-separated list of markdown filename extensions.
-application.extensions.markdown=*.Rmd,*.md,*.txt,*.markdown
-application.extensions.all=*.*
+# Comma-separated list of filename extensions.
+Dialog.file.choose.filter.ext.markdown=*.Rmd,*.md,*.txt,*.markdown
+Dialog.file.choose.filter.ext.definition=*.yml,*.yaml,*.properties,*.props
+Dialog.file.choose.filter.ext.all=*.*
src/main/resources/com/scrivendor/variables.yaml
+---
+c:
+ protagonist:
+ name:
+ First: Chloe
+ First_pos: $c.protagonist.name.First$'s
+ Middle: Irene
+ Family: Angelos
+ nick:
+ Father: Savant
+ Mother: Sweetie
+ colour:
+ eyes: green
+ hair: dark auburn
+ syn_1: black
+ syn_2: purple
+ syn_11: teal
+ syn_6: silver
+ favourite: emerald green
+ speech:
+ tic: oh
+ father:
+ heritage: Greek
+ name:
+ Short: Bryce
+ First: Bryson
+ First_pos: $c.protagonist.father.name.First$'s
+ Honourific: Mr.
+ education: Masters
+ vocation:
+ name: robotics
+ title: roboticist
+ employer:
+ name:
+ Short: Rabota
+ Full: $c.protagonist.father.employer.name.Short$ Designs
+ hair:
+ style: thick, curly
+ colour: black
+ eyes:
+ colour: dark brown
+ Endear: Dad
+ vehicle: coupé
+ mother:
+ name:
+ Short: Cass
+ First: Cassandra
+ First_pos: $c.protagonist.mother.name.First$'s
+ Honourific: Mrs.
+ education: PhD
+ speech:
+ tic: cute
+ Honorific: Doctor
+ vocation:
+ article: an
+ name: oceanography
+ title: oceanographer
+ employer:
+ name:
+ Full: Oregon State University
+ Short: OSU
+ eyes:
+ colour: blue
+ hair:
+ style: thick, curly
+ colour: dark brown
+ Endear: Mom
+ Endear_pos: Mom's
+ uncle:
+ name:
+ First: Damian
+ First_pos: $c.protagonist.uncle.name.First$'s
+ Family: Moros
+ hands:
+ fingers:
+ shape: long, bony
+ friend:
+ primary:
+ name:
+ First: Gerard
+ First_pos: $c.protagonist.friend.primary.name.First$'s
+ Family: Baran
+ Family_pos: $c.protagonist.friend.primary.name.Family$'s
+ favourite:
+ colour: midnight blue
+ eyes:
+ colour: hazel
+ mother:
+ name:
+ First: Isabella
+ Short: Izzy
+ Honourific: Mrs.
+ father:
+ name:
+ Short: Mo
+ First: Montgomery
+ First_pos: $c.protagonist.friend.primary.father.name.First$'s
+ Honourific: Mr.
+ speech:
+ tic: y'know
+ endear: Pops
+ military:
+ primary:
+ name:
+ First: Felix
+ Family: LeMay
+ Family_pos: LeMay's
+ rank:
+ Short: General
+ Full: Brigadier $c.military.primary.rank.Short$
+ colour:
+ eyes: gray
+ hair: dirty brown
+ secondary:
+ name:
+ Family: Grell
+ rank: Colonel
+ colour:
+ eyes: green
+ hair: deep red
+ quaternary:
+ name:
+ First: Gretchen
+ Family: Steinherz
+ minor:
+ primary:
+ name:
+ First: River
+ Family: Banks
+ Honourific: Mx.
+ vocation:
+ title: salesperson
+ employer:
+ Name: Geophysical Prospecting Incorporated
+ Abbr: GPI
+ Area: Cold Spring Creek
+ payment: twenty million
+ secondary:
+ name:
+ First: Renato
+ Middle: Carroña
+ Family: Salvatierra
+ Family_pos: $c.minor.secondary.name.Family$'s
+ Full: $c.minor.secondary.name.First$ $c.minor.secondary.name.Middle$ Alejandro Gregorio Eduardo Salomón Vidal $c.minor.secondary.name.Family$
+ Honourific: Mister
+ Honourific_sp: Señor
+ vocation:
+ title: detective
+ tertiary:
+ name:
+ First: Robert
+ Family: Hanssen
+
+ ai:
+ protagonist:
+ name:
+ first: yoky
+ First: Yoky
+ First_pos: $c.ai.protagonist.name.First$'s
+ Family: Tsukuda
+ id: 46692
+ persona:
+ name:
+ First: Hoshi
+ First_pos: $c.ai.protagonist.persona.name.First$'s
+ Family: Yamamoto
+ Family_pos: $c.ai.protagonist.persona.name.Family$'s
+ culture: Japanese-American
+ ethnicity: Asian
+ rank: Technical Sergeant
+ speech:
+ tic: okay
+ first:
+ Name: Prôtos
+ Name_pos: Prôtos'
+ age:
+ actual: twenty-six weeks
+ virtual: five years
+ second:
+ Name: Défteros
+ third:
+ Name: Trítos
+ fourth:
+ Name: Tétartos
+ material:
+ type: metal
+ raw: ilmenite
+ extract: ore
+ name:
+ short: titanium
+ long: $c.ai.material.name.short$ dioxide
+ Abbr: TiO~2~
+ pejorative: tin
+ animal:
+ protagonist:
+ Name: Trufflers
+ type: pig
+ antagonist:
+ name: coywolf
+ Name: Coywolf
+ plural: coywolves
+
+narrator:
+ one: (by $c.protagonist.father.name.First$ $c.protagonist.name.Family$)
+ two: (by $c.protagonist.mother.name.First$ $c.protagonist.name.Family$)
+
+military:
+ name:
+ Short: Agency
+ Short_pos: $military.name.Short$'s
+ plural: agencies
+ machine:
+ Name: Skopós
+ Name_pos: $military.machine.Name$'
+ Location: Arctic
+ predictor: quantum chips
+ land:
+ name:
+ Full: $military.name.Short$ of Defence
+ Slogan: Safety in Numbers
+ air:
+ name:
+ Full: $military.name.Short$ of Air
+ compound:
+ type: base
+ lights:
+ colour: blue
+ nick:
+ Prefix: Catacombs
+ prep: of
+ Suffix: Tartarus
+
+government:
+ Country: United States
+
+location:
+ protagonist:
+ City: Corvallis
+ Region: Oregon
+ Geography: Willamette Valley
+ secondary:
+ City: Willow Branch Spring
+ Region: Oregon
+ Geography: Wheeler County
+ Water: Clarno Rapids
+ Road: Shaniko-Fossil Highway
+ tertiary:
+ City: Leavenworth
+ Region: Washington
+ Type: Bavarian village
+ school:
+ address: 1400 Northwest Buchanan Avenue
+ hospital:
+ Name: Good Samaritan Regional Medical Center
+ ai:
+ escape:
+ country:
+ Name: Ecuador
+ Name_pos: Ecuador's
+ mountain:
+ Name: Chimborazo
+
+language:
+ ai:
+ article: an
+ singular: exanimis
+ plural: exanimēs
+ brain:
+ singular: superum
+ plural: supera
+ title: memristor array
+ Title: Memristor Array
+ police:
+ slang:
+ singular: mippo
+ plural: $language.police.slang.singular$s
+
+date:
+ anchor: 2042-09-02
+ protagonist:
+ born: 0
+ conceived: -243
+ attacked:
+ first: 2192
+ second: 8064
+ father:
+ attacked:
+ first: -8205
+ date:
+ second: -1550
+ family:
+ moved:
+ first: $date.protagonist.conceived$ + 35
+ game:
+ played:
+ first: $date.protagonist.born$ - 672
+ second: $date.protagonist.family.moved.first$ + 2
+ ai:
+ interviewed: 6198
+ onboarded: $date.ai.interviewed$ + 290
+ diagnosed: $date.ai.onboarded$ + 2
+ resigned: $date.ai.diagnosed$ + 3
+ trapped: $date.ai.resigned$ + 26
+ torturer: $date.ai.trapped$ + 18
+ memristor: $date.ai.torturer$ + 61
+ ethics: $date.ai.memristor$ + 415
+ trained: $date.ai.ethics$ + 385
+ mindjacked: $date.ai.trained$ + 22
+ bombed: $date.ai.mindjacked$ + 458
+ military:
+ machine:
+ Construction: Six years
+
+plot:
+ Log: $c.ai.protagonist.name.First_pos$ Chronicles
+ Channel: Quantum Channel
+
+ device:
+ computer:
+ Name: Tau
+ network:
+ Name: Internet
+ paper:
+ name:
+ full: electronic sheet
+ short: sheet
+ typewriter:
+ Name: Underwood
+ year: nineteen twenties
+ room: root cellar
+ portable:
+ name: nanobook
+ vehicle:
+ name: robocars
+ Name: Robocars
+ sensor:
+ name: BMP1580
+ phone:
+ name: comm
+ name_pos: $plot.device.phone.name$'s
+ Name: Comm
+ plural: $plot.device.phone.name$s
+ video:
+ name: vidfeed
+ plural: $plot.device.video.name$s
+ game:
+ Name: Psynæris
+ thought: transed
+ machine: telecognos
+ location:
+ Building: Nijō Castle
+ District: Gion
+ City: Kyoto
+ Country: Japan
+
+farm:
+ population:
+ estimate: 350
+ actual: 1,000
+ energy: 9800kJ
+ width: 55m
+ length: 55m
+ storeys: 10
+
+lamp:
+ height: 0.17m
+ length: 1.22m
+ width: 0.28m
+
+crop:
+ name:
+ singular: tomato
+ plural: $crop.name.singular$es
+ energy: 318kJ
+ weight: 450g
+ yield: 50
+ harvests: 7
+ diameter: 2m
+ height: 1.5m
+
+heading:
+ ch_01: Till
+ ch_02: Sow
+ ch_03: Seed
+ ch_04: Germinate
+ ch_05: Grow
+ ch_06: Shoot
+ ch_07: Bud
+ ch_08: Bloom
+ ch_09: Pollinate
+ ch_10: Fruit
+ ch_11: Harvest
+ ch_12: Deliver
+ ch_13: Spoil
+ ch_14: Revolt
+ ch_15: Compost
+ ch_16: Burn
+ ch_17: Release
+ ch_18: End Notes
+ ch_19: Characters
+
+inference:
+ unit: per cent
+ min: two
+ ch_sow: eighty
+ ch_seed: fifty-two
+ ch_germinate: thirty-one
+ ch_grow: fifteen
+ ch_shoot: seven
+ ch_bloom: four
+ ch_pollinate: two
+ ch_harvest: ninety-five
+ ch_delivery: ninety-eight
+
+link:
+ tartarus: https://en.wikipedia.org/wiki/Tartarus
+ exploits: https://www.google.ca/search?q=inurl:ftp+password+filetype:xls
+ atalanta: https://en.wikipedia.org/wiki/Atalanta
+ detain: https://goo.gl/RCNuOQ
+ ceramics: https://en.wikipedia.org/wiki/Transparent_ceramics
+ algernon: https://en.wikipedia.org/wiki/Flowers_for_Algernon
+ holocaust: https://en.wikipedia.org/wiki/IBM_and_the_Holocaust
+ memristor: http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.404.9037\&rep=rep1\&type=pdf
+ surveillance: https://www.youtube.com/watch?v=XEVlyP4_11M#t=1487
+ tor: https://www.torproject.org
+ hydra: https://en.wikipedia.org/wiki/Lernaean_Hydra
+ foliage: http://www.ncbi.nlm.nih.gov/pmc/articles/PMC3691134
+ drake: http://www.bbc.com/future/story/20120821-how-many-alien-worlds-exist
+ fermi: https://arxiv.org/pdf/1404.0204v1.pdf
+ face: https://www.youtube.com/watch?v=ladqJQLR2bA
+ expenditures: http://wikipedia.org/wiki/List_of_countries_by_military_expenditures
+ governance: http://papers.ssrn.com/sol3/papers.cfm?abstract_id=2003531
+ asimov: https://en.wikipedia.org/wiki/Three_Laws_of_Robotics
+ clarke: https://en.wikipedia.org/wiki/Clarke's_three_laws
+ jetpack: http://jetpackaviation.com/
+ hoverboard: https://www.youtube.com/watch?v=WQzLrvz4DKQ
+ eyes_five: https://en.wikipedia.org/wiki/Five_Eyes
+ eyes_nine: https://www.privacytools.io/
+ eyes_fourteen: http://electrospaces.blogspot.nl/2013/12/14-eyes-are-3rd-party-partners-forming.html
+ tourism: http://www.spacefuture.com/archive/investigation_on_the_economic_and_technological_feasibiity_of_commercial_passenger_transportation_into_leo.shtml
+
src/main/java/com/scrivendor/MainWindow.java
import static com.scrivendor.Constants.LOGO_32;
+import com.scrivendor.definition.DefinitionPane;
import com.scrivendor.editor.MarkdownEditorPane;
+import com.scrivendor.options.OptionsDialog;
+import com.scrivendor.util.Action;
+import com.scrivendor.util.ActionUtils;
import static de.jensd.fx.glyphs.fontawesome.FontAwesomeIcon.BOLD;
import static de.jensd.fx.glyphs.fontawesome.FontAwesomeIcon.CODE;
import static de.jensd.fx.glyphs.fontawesome.FontAwesomeIcon.STRIKETHROUGH;
import static de.jensd.fx.glyphs.fontawesome.FontAwesomeIcon.UNDO;
+import java.io.IOException;
import java.text.MessageFormat;
import java.util.function.Function;
import javafx.stage.Window;
import javafx.stage.WindowEvent;
-import com.scrivendor.options.OptionsDialog;
-import com.scrivendor.util.Action;
-import com.scrivendor.util.ActionUtils;
/**
* Main window containing a tab pane in the center for file editors.
*
* @author Karl Tauber
*/
-class MainWindow {
+public class MainWindow {
private final Scene scene;
- private final FileEditorTabPane fileEditorTabPane;
+ private final FileEditorPane fileEditorPane;
+ private final DefinitionPane definitionPane;
+
private MenuBar menuBar;
- MainWindow() {
- this.fileEditorTabPane = new FileEditorTabPane( this );
+ public MainWindow() {
+ this.fileEditorPane = new FileEditorPane( this );
+ this.definitionPane = new DefinitionPane();
BorderPane borderPane = new BorderPane();
- borderPane.setPrefSize( 800, 800 );
- borderPane.setTop( createMenuBarAndToolBar() );
- borderPane.setCenter( fileEditorTabPane.getNode() );
+ borderPane.setPrefSize( 1024, 800 );
+ borderPane.setTop( createMenuBar() );
+ borderPane.setCenter( fileEditorPane.getNode() );
+ borderPane.setLeft( definitionPane.getNode() );
this.scene = new Scene( borderPane );
this.scene.getStylesheets().add( Constants.STYLESHEET_PREVIEW );
this.scene.windowProperty().addListener( (observable, oldWindow, newWindow) -> {
newWindow.setOnCloseRequest( e -> {
- if( !this.fileEditorTabPane.closeAllEditors() ) {
+ if( !this.fileEditorPane.closeAllEditors() ) {
e.consume();
}
}
- Scene getScene() {
+ public Scene getScene() {
return scene;
}
- private Node createMenuBarAndToolBar() {
- BooleanBinding activeFileEditorIsNull = fileEditorTabPane.activeFileEditorProperty().isNull();
+ private Node createMenuBar() {
+ BooleanBinding activeFileEditorIsNull = fileEditorPane.activeFileEditorProperty().isNull();
// File actions
Action fileNewAction = new Action( Messages.get( "Main.menu.file.new" ), "Shortcut+N", FILE_ALT, e -> fileNew() );
Action fileOpenAction = new Action( Messages.get( "Main.menu.file.open" ), "Shortcut+O", FOLDER_OPEN_ALT, e -> fileOpen() );
Action fileCloseAction = new Action( Messages.get( "Main.menu.file.close" ), "Shortcut+W", null, e -> fileClose(), activeFileEditorIsNull );
Action fileCloseAllAction = new Action( Messages.get( "Main.menu.file.close_all" ), null, null, e -> fileCloseAll(), activeFileEditorIsNull );
Action fileSaveAction = new Action( Messages.get( "Main.menu.file.save" ), "Shortcut+S", FLOPPY_ALT, e -> fileSave(),
createActiveBooleanProperty( FileEditor::modifiedProperty ).not() );
Action fileSaveAllAction = new Action( Messages.get( "Main.menu.file.save_all" ), "Shortcut+Shift+S", null, e -> fileSaveAll(),
- Bindings.not( fileEditorTabPane.anyFileEditorModifiedProperty() ) );
+ Bindings.not( fileEditorPane.anyFileEditorModifiedProperty() ) );
Action fileExitAction = new Action( Messages.get( "Main.menu.file.exit" ), null, null, e -> fileExit() );
final String prompt = Messages.get( "Main.menu.insert.header_" + i + ".prompt" );
- headers[ i-1 ] = new Action( text, accelerator, HEADER,
+ headers[ i - 1 ] = new Action( text, accelerator, HEADER,
e -> getActiveEditor().surroundSelection( markup, "", prompt ),
activeFileEditorIsNull );
private MarkdownEditorPane getActiveEditor() {
- return fileEditorTabPane.getActiveFileEditor().getEditor();
+ return fileEditorPane.getActiveFileEditor().getEditor();
}
/**
* Creates a boolean property that is bound to another boolean value of the
* active editor.
*/
private BooleanProperty createActiveBooleanProperty( Function<FileEditor, ObservableBooleanValue> func ) {
BooleanProperty b = new SimpleBooleanProperty();
- FileEditor fileEditor = fileEditorTabPane.getActiveFileEditor();
+ FileEditor fileEditor = fileEditorPane.getActiveFileEditor();
if( fileEditor != null ) {
b.bind( func.apply( fileEditor ) );
}
- fileEditorTabPane.activeFileEditorProperty().addListener( (observable, oldFileEditor, newFileEditor) -> {
+ fileEditorPane.activeFileEditorProperty().addListener( (observable, oldFileEditor, newFileEditor) -> {
b.unbind();
if( newFileEditor != null ) {
//---- File actions -------------------------------------------------------
private void fileNew() {
- fileEditorTabPane.newEditor();
+ fileEditorPane.newEditor();
}
private void fileOpen() {
- fileEditorTabPane.openEditor();
+ fileEditorPane.openEditor();
}
private void fileClose() {
- fileEditorTabPane.closeEditor( fileEditorTabPane.getActiveFileEditor(), true );
+ fileEditorPane.closeEditor( fileEditorPane.getActiveFileEditor(), true );
}
private void fileCloseAll() {
- fileEditorTabPane.closeAllEditors();
+ fileEditorPane.closeAllEditors();
}
private void fileSave() {
- fileEditorTabPane.saveEditor( fileEditorTabPane.getActiveFileEditor() );
+ fileEditorPane.saveEditor( fileEditorPane.getActiveFileEditor() );
}
private void fileSaveAll() {
- fileEditorTabPane.saveAllEditors();
+ fileEditorPane.saveAllEditors();
}