Dave Jarvis' Repositories

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

Replace R dialogs with non-modal preferences dialog, add image preferences

AuthorDaveJarvis <email>
Date2020-06-11 22:54:57 GMT-0700
Commit438140966a442ec59ece203b30f6ec5fb3f53bcc
Parent507adea
Delta52 lines added, 43 lines removed, 9-line increase
src/main/resources/com/scrivenvar/messages.properties
Main.menu.edit.find=_Find
Main.menu.edit.find.next=Find _Next
+Main.menu.edit.preferences=_Preferences
Main.menu.insert=_Insert
Main.menu.insert.link=Link...
Main.menu.insert.image=Image...
-Main.menu.insert.header_1=Header 1
-Main.menu.insert.header_1.prompt=header 1
-Main.menu.insert.header_2=Header 2
-Main.menu.insert.header_2.prompt=header 2
-Main.menu.insert.header_3=Header 3
-Main.menu.insert.header_3.prompt=header 3
+Main.menu.insert.header.1=Header 1
+Main.menu.insert.header.1.prompt=header 1
+Main.menu.insert.header.2=Header 2
+Main.menu.insert.header.2.prompt=header 2
+Main.menu.insert.header.3=Header 3
+Main.menu.insert.header.3.prompt=header 3
Main.menu.insert.unordered_list=Unordered List
Main.menu.insert.ordered_list=Ordered List
Main.menu.insert.horizontal_rule=Horizontal Rule
-Main.menu.r=_R
-Main.menu.r.script=_Script
-Main.menu.r.directory=_Directory
Main.menu.help=_Help
Main.statusbar.state.default=OK
Main.statusbar.parse.error={0} (near ${Main.statusbar.text.offset} {1})
+
+# ########################################################################
+# Preferences
+# ########################################################################
+Preferences.r=R
+Preferences.r.script=Startup Script
+Preferences.r.script.desc=R statements to run prior to running R statements within the document.
+Preferences.r.directory=Working Directory
+Preferences.r.directory.desc=Value assigned to $application.r.working.directory$ and usable in the script.
+
+Preferences.images=Images
+Preferences.images.directory=Relative Directory
+Preferences.images.directory.desc=Directory name prepended to embedded images.
+Preferences.images.suffixes=Extensions
+Preferences.images.suffixes.desc=Preferred order of image file types to embed.
# ########################################################################
Dialog.about.header=${Main.title}
Dialog.about.content=Copyright 2020 White Magic Software, Ltd.\n\nBased on Markdown Writer FX by Karl Tauber
-
-# R ################################################################
-
-# ########################################################################
-# R Script
-# ########################################################################
-
-Dialog.r.script.title=R Startup Script
-Dialog.r.script.content=Provide R statements to run prior to interpreting R statements embedded in the document.
-
-# ########################################################################
-# R Directory
-# ########################################################################
-
-Dialog.r.directory.title=Bootstrap Working Directory
-Dialog.r.directory.header=Value for $application.r.working.directory$.
# Options ################################################################
src/main/resources/com/scrivenvar/settings.properties
file.logo.512=${application.package}/logo512.png
-# Startup script for R
-file.r.startup=/${application.package}/startup.R
-
# Default filename when a new file is created.
# This ensures that the file type can always be
src/main/java/com/scrivenvar/util/ActionUtils.java
/*
- * Copyright (c) 2015 Karl Tauber <karl at jformdesigner dot com>
+ * Copyright (c) 2015 Karl Tauber
* All rights reserved.
*
*
* @author Karl Tauber
+ * @author White Magic Software, Ltd.
*/
public class ActionUtils {
public static Menu createMenu( final String text, final Action... actions ) {
return new Menu( text, null, createMenuItems( actions ) );
}
- public static MenuItem[] createMenuItems( Action... actions ) {
- MenuItem[] menuItems = new MenuItem[ actions.length ];
+ public static MenuItem[] createMenuItems( final Action... actions ) {
+ final MenuItem[] menuItems = new MenuItem[ actions.length ];
+
for( int i = 0; i < actions.length; i++ ) {
menuItems[ i ] = (actions[ i ] != null)
- ? createMenuItem( actions[ i ] )
- : new SeparatorMenuItem();
+ ? createMenuItem( actions[ i ] )
+ : new SeparatorMenuItem();
}
+
return menuItems;
}
- public static MenuItem createMenuItem( Action action ) {
- MenuItem menuItem = new MenuItem( action.text );
+ public static MenuItem createMenuItem( final Action action ) {
+ final MenuItem menuItem = new MenuItem( action.text );
+
if( action.accelerator != null ) {
menuItem.setAccelerator( action.accelerator );
}
if( action.icon != null ) {
- menuItem.setGraphic( FontAwesomeIconFactory.get().createIcon( action.icon ) );
+ menuItem.setGraphic(
+ FontAwesomeIconFactory.get().createIcon( action.icon ) );
}
}
- public static ToolBar createToolBar( Action... actions ) {
+ public static ToolBar createToolBar( final Action... actions ) {
return new ToolBar( createToolBarButtons( actions ) );
}
- public static Node[] createToolBarButtons( Action... actions ) {
+ public static Node[] createToolBarButtons( final Action... actions ) {
Node[] buttons = new Node[ actions.length ];
for( int i = 0; i < actions.length; i++ ) {
buttons[ i ] = (actions[ i ] != null)
- ? createToolBarButton( actions[ i ] )
- : new Separator();
+ ? createToolBarButton( actions[ i ] )
+ : new Separator();
}
return buttons;
}
- public static Button createToolBarButton( Action action ) {
- Button button = new Button();
- button.setGraphic( FontAwesomeIconFactory.get().createIcon( action.icon, "1.2em" ) );
+ public static Button createToolBarButton( final Action action ) {
+ final Button button = new Button();
+ button.setGraphic(
+ FontAwesomeIconFactory
+ .get()
+ .createIcon( action.icon, "1.2em" ) );
+
String tooltip = action.text;
+
if( tooltip.endsWith( "..." ) ) {
tooltip = tooltip.substring( 0, tooltip.length() - 3 );
}
+
if( action.accelerator != null ) {
tooltip += " (" + action.accelerator.getDisplayText() + ')';
}
+
button.setTooltip( new Tooltip( tooltip ) );
button.setFocusTraversable( false );
button.setOnAction( action.action );
+
if( action.disable != null ) {
button.disableProperty().bind( action.disable );
}
+
return button;
}
src/main/java/com/scrivenvar/processors/RMarkdownCaretInsertionProcessor.java
import static java.lang.Integer.max;
+import com.scrivenvar.processors.markdown.MarkdownCaretInsertionProcessor;
import javafx.beans.value.ObservableValue;