| Author | DaveJarvis <email> |
|---|---|
| Date | 2021-05-08 17:55:53 GMT-0700 |
| Commit | 7bfa9f93b834cccb1c1e74eec949979dcc8cebb6 |
| Parent | ef0709f |
| Group.of( | ||
| get( KEY_TYPESET_CONTEXT ), | ||
| - Setting.of( label( KEY_TYPESET_CONTEXT_PATH ) ), | ||
| - Setting.of( title( KEY_TYPESET_CONTEXT_PATH ), | ||
| - fileProperty( KEY_TYPESET_CONTEXT_PATH ), true ) | ||
| + Setting.of( label( KEY_TYPESET_CONTEXT_THEMES_PATH ) ), | ||
| + Setting.of( title( KEY_TYPESET_CONTEXT_THEMES_PATH ), | ||
| + fileProperty( KEY_TYPESET_CONTEXT_THEMES_PATH ), true ) | ||
| ) | ||
| ), |
| entry( KEY_R_DELIM_BEGAN, asStringProperty( R_DELIM_BEGAN_DEFAULT ) ), | ||
| entry( KEY_R_DELIM_ENDED, asStringProperty( R_DELIM_ENDED_DEFAULT ) ), | ||
| - | ||
| + | ||
| entry( KEY_IMAGES_DIR, asFileProperty( USER_DIRECTORY ) ), | ||
| entry( KEY_IMAGES_ORDER, asStringProperty( PERSIST_IMAGES_DEFAULT ) ), | ||
| - | ||
| + | ||
| entry( KEY_DEF_PATH, asFileProperty( DEFINITION_DEFAULT ) ), | ||
| entry( KEY_DEF_DELIM_BEGAN, asStringProperty( DEF_DELIM_BEGAN_DEFAULT ) ), | ||
| entry( KEY_UI_FONT_PREVIEW_MONO_NAME, asStringProperty( FONT_NAME_PREVIEW_MONO_NAME_DEFAULT ) ), | ||
| entry( KEY_UI_FONT_PREVIEW_MONO_SIZE, asDoubleProperty( FONT_SIZE_PREVIEW_MONO_SIZE_DEFAULT ) ), | ||
| - //@formatter:on | ||
| entry( KEY_UI_WINDOW_X, asDoubleProperty( WINDOW_X_DEFAULT ) ), | ||
| entry( KEY_LANGUAGE_LOCALE, asLocaleProperty( LOCALE_DEFAULT ) ), | ||
| - entry( KEY_TYPESET_CONTEXT_PATH, asFileProperty( USER_DIRECTORY ) ), | ||
| - entry( KEY_TYPESET_CONTEXT_THEME, asStringProperty( "boschet" ) ) | ||
| + entry( KEY_TYPESET_CONTEXT_THEMES_PATH, asFileProperty( USER_DIRECTORY ) ), | ||
| + entry( KEY_TYPESET_CONTEXT_THEME_SELECTION, asStringProperty( "boschet" ) ) | ||
| + //@formatter:on | ||
| ); | ||
| assert key != null; | ||
| return valuesProperty( key ); | ||
| - } | ||
| - | ||
| - /** | ||
| - * Delegates setting the property for a workspace {@link Key} to the | ||
| - * inner property instance. | ||
| - * | ||
| - * @param key The name of the property value to change. | ||
| - * @param value The new property value. | ||
| - */ | ||
| - public void setStringProperty( final Key key, final String value ) { | ||
| - assert value != null; | ||
| - stringProperty( key ).set( value ); | ||
| } | ||
| public static final Key KEY_TYPESET = key( KEY_ROOT, "typeset" ); | ||
| public static final Key KEY_TYPESET_CONTEXT = key( KEY_TYPESET, "context" ); | ||
| - public static final Key KEY_TYPESET_CONTEXT_PATH = key( KEY_TYPESET_CONTEXT, "path" ); | ||
| - public static final Key KEY_TYPESET_CONTEXT_THEME = key( KEY_TYPESET_CONTEXT, "theme" ); | ||
| + public static final Key KEY_TYPESET_CONTEXT_THEMES = key( KEY_TYPESET, "themes" ); | ||
| + public static final Key KEY_TYPESET_CONTEXT_THEMES_PATH = key( KEY_TYPESET_CONTEXT_THEMES, "path" ); | ||
| + public static final Key KEY_TYPESET_CONTEXT_THEME_SELECTION = key( KEY_TYPESET_CONTEXT_THEMES, "selection" ); | ||
| //@formatter:on | ||
| import static com.keenwrite.constants.Constants.DEFAULT_DIRECTORY; | ||
| import static com.keenwrite.events.StatusEvent.clue; | ||
| -import static com.keenwrite.preferences.WorkspaceKeys.KEY_TYPESET_CONTEXT_PATH; | ||
| -import static com.keenwrite.preferences.WorkspaceKeys.KEY_TYPESET_CONTEXT_THEME; | ||
| +import static com.keenwrite.preferences.WorkspaceKeys.KEY_TYPESET_CONTEXT_THEMES_PATH; | ||
| +import static com.keenwrite.preferences.WorkspaceKeys.KEY_TYPESET_CONTEXT_THEME_SELECTION; | ||
| import static java.lang.ProcessBuilder.Redirect.DISCARD; | ||
| import static java.lang.String.format; | ||
| private boolean reinitialize() { | ||
| final var filename = mOutput.getFileName(); | ||
| - final var themes = mWorkspace.toFile( KEY_TYPESET_CONTEXT_PATH ); | ||
| - final var theme = mWorkspace.toString( KEY_TYPESET_CONTEXT_THEME ); | ||
| + final var themes = getThemesPath(); | ||
| + final var theme = getThemesSelection(); | ||
| final var cacheExists = !isEmpty( getCacheDir().toPath() ); | ||
| return new BufferedReader( new InputStreamReader( mInputStream ) ); | ||
| } | ||
| + } | ||
| + | ||
| + private File getThemesPath() { | ||
| + return mWorkspace.toFile( KEY_TYPESET_CONTEXT_THEMES_PATH ); | ||
| + } | ||
| + | ||
| + private String getThemesSelection() { | ||
| + return mWorkspace.toString( KEY_TYPESET_CONTEXT_THEME_SELECTION ); | ||
| } | ||
| } | ||
| import static com.keenwrite.constants.GraphicsConstants.ICON_DIALOG_NODE; | ||
| import static com.keenwrite.events.StatusEvent.clue; | ||
| -import static com.keenwrite.preferences.WorkspaceKeys.KEY_TYPESET_CONTEXT_PATH; | ||
| -import static com.keenwrite.preferences.WorkspaceKeys.KEY_TYPESET_CONTEXT_THEME; | ||
| +import static com.keenwrite.preferences.WorkspaceKeys.KEY_TYPESET_CONTEXT_THEMES_PATH; | ||
| +import static com.keenwrite.preferences.WorkspaceKeys.KEY_TYPESET_CONTEXT_THEME_SELECTION; | ||
| import static com.keenwrite.processors.ProcessorFactory.createProcessors; | ||
| import static com.keenwrite.ui.explorer.FilePickerFactory.Options; | ||
| public void file‿export‿pdf() { | ||
| final var workspace = getWorkspace(); | ||
| - final var themes = workspace.toFile( KEY_TYPESET_CONTEXT_PATH ); | ||
| - final var theme = workspace.stringProperty( KEY_TYPESET_CONTEXT_THEME ); | ||
| + final var themes = workspace.toFile( KEY_TYPESET_CONTEXT_THEMES_PATH ); | ||
| + final var theme = workspace.stringProperty( | ||
| + KEY_TYPESET_CONTEXT_THEME_SELECTION ); | ||
| - if( Typesetter.canRun() && ThemePicker.choose( themes, theme ) ) { | ||
| - file‿export( APPLICATION_PDF ); | ||
| + if( Typesetter.canRun() ) { | ||
| + if( ThemePicker.choose( themes, theme ) ) { | ||
| + file‿export( APPLICATION_PDF ); | ||
| + } | ||
| } | ||
| else { | ||
| import static com.keenwrite.events.StatusEvent.clue; | ||
| import static com.keenwrite.util.FileWalker.walk; | ||
| +import static java.lang.Math.max; | ||
| /** | ||
| */ | ||
| private boolean pick() { | ||
| - | ||
| try { | ||
| - // Use a sorted map. | ||
| - final var choices = new TreeMap<String, File>(); | ||
| + // List themes in alphabetical order (human readable by directory name). | ||
| + final var choices = new TreeMap<String, String>(); | ||
| + final String[] selection = new String[]{""}; | ||
| // Populate the choices with themes detected on the system. | ||
| walk( mThemes.toPath(), "**/theme.properties", ( path ) -> { | ||
| try { | ||
| - choices.put( readThemeName( path ), path.getParent().toFile() ); | ||
| + final var themeName = path.getParent().toFile().getName(); | ||
| + final var themeDisplay = readThemeName( path ); | ||
| + choices.put( themeDisplay, themeName ); | ||
| + if( themeName.equals( mTheme.get() ) ) { | ||
| + selection[ 0 ] = themeDisplay; | ||
| + } | ||
| } catch( final Exception ex ) { | ||
| clue( get( "Main.status.error.theme.name", path ) ); | ||
| } | ||
| } ); | ||
| final var items = getItems(); | ||
| items.addAll( choices.keySet() ); | ||
| - setSelectedItem( items.get( 0 ) ); | ||
| + setSelectedItem( items.get( max( items.indexOf( selection[ 0 ] ), 0 ) ) ); | ||
| final var result = showAndWait(); | ||
| - final var themeName = result.orElseThrow(); | ||
| - final var themeDir = choices.get( themeName ); | ||
| - | ||
| - mTheme.set( themeDir.getName() ); | ||
| - return true; | ||
| - } catch( final IOException ex ) { | ||
| - clue( ex ); | ||
| + if( result.isPresent() ) { | ||
| + mTheme.set( choices.get( result.get() ) ); | ||
| + return true; | ||
| + } | ||
| + } catch( final Exception ex ) { | ||
| + clue( get( "Main.status.error.theme.missing", mThemes ), ex ); | ||
| } | ||
| workspace.typeset=Typesetting | ||
| workspace.typeset.context=ConTeXt | ||
| -workspace.typeset.context.path=Paths | ||
| -workspace.typeset.context.path.desc=Directory containing theme subdirectories. | ||
| -workspace.typeset.context.path.title=Themes | ||
| +workspace.typeset.context.themes.path=Paths | ||
| +workspace.typeset.context.themes.path.desc=Directory containing theme subdirectories. | ||
| +workspace.typeset.context.themes.path.title=Themes | ||
| # ######################################################################## | ||
| Main.status.error.redo=Cannot redo; end of redo history reached | ||
| -Main.status.error.theme.name=Missing theme name for ''{0}'' | ||
| +Main.status.error.theme.missing=Install themes before exporting (no themes found at ''{0}'') | ||
| +Main.status.error.theme.name=Cannot find theme name for ''{0}'' | ||
| Main.status.image.request.init=Initializing HTTP request | ||
| Delta | 54 lines added, 48 lines removed, 6-line increase |
|---|