| 2 | 2 | package com.keenwrite.ui.dialogs; |
| 3 | 3 | |
| 4 | import com.keenwrite.events.ExportFailedEvent; |
| 4 | 5 | import com.keenwrite.util.FileWalker; |
| 5 | 6 | import com.keenwrite.util.RangeValidator; |
| ... |
| 51 | 52 | private ComboBox<String> mComboBox; |
| 52 | 53 | private TextField mChapters; |
| 54 | private final boolean mMissingThemes; |
| 53 | 55 | |
| 54 | 56 | /** |
| ... |
| 74 | 76 | final var themes = readThemes( themesDir ); |
| 75 | 77 | |
| 76 | | if( !themes.isEmpty() ) { |
| 77 | | initComboBox( mComboBox, mSettings, readThemes( themesDir ) ); |
| 78 | mMissingThemes = themes.isEmpty(); |
| 78 | 79 | |
| 79 | | mPane.add( createLabel( "Dialog.typesetting.settings.theme" ), 0, 1 ); |
| 80 | | mPane.add( mComboBox, 1, 1 ); |
| 81 | | } |
| 82 | | else { |
| 80 | // Typesetting installation has been corrupted. This is probably due |
| 81 | // to the user's settings file gone missing. Rather than force users |
| 82 | // to find the "themes" directory location, re-install the typesetter, |
| 83 | if( mMissingThemes ) { |
| 83 | 84 | clue( "Dialog.typesetting.settings.themes.missing", |
| 84 | 85 | themesDir.getAbsolutePath() ); |
| 86 | ExportFailedEvent.fire(); |
| 87 | return; |
| 85 | 88 | } |
| 89 | |
| 90 | initComboBox( mComboBox, mSettings, readThemes( themesDir ) ); |
| 91 | |
| 92 | mPane.add( createLabel( "Dialog.typesetting.settings.theme" ), 0, 1 ); |
| 93 | mPane.add( mComboBox, 1, 1 ); |
| 86 | 94 | |
| 87 | 95 | var title = "Dialog.typesetting.settings.header."; |
| ... |
| 139 | 147 | private boolean pick() { |
| 140 | 148 | try { |
| 141 | | final var result = showAndWait(); |
| 149 | if( !mMissingThemes ) { |
| 150 | final var result = showAndWait(); |
| 142 | 151 | |
| 143 | | // The result will only be set if the OK button is pressed. |
| 144 | | if( result.isPresent() ) { |
| 145 | | final var theme = mComboBox.getSelectionModel().getSelectedItem(); |
| 146 | | mSettings.themeProperty().setValue( theme.toLowerCase() ); |
| 152 | // The result will only be set if the OK button is pressed. |
| 153 | if( result.isPresent() ) { |
| 154 | final var theme = mComboBox.getSelectionModel().getSelectedItem(); |
| 155 | mSettings.themeProperty().setValue( theme.toLowerCase() ); |
| 147 | 156 | |
| 148 | | return true; |
| 157 | return true; |
| 158 | } |
| 149 | 159 | } |
| 150 | 160 | } catch( final Exception ex ) { |