### Eclipse Workspace Patch 1.0 #P common-swing Index: src/main/java/org/crosswire/common/swing/FontStore.java =================================================================== --- src/main/java/org/crosswire/common/swing/FontStore.java (revision 1949) +++ src/main/java/org/crosswire/common/swing/FontStore.java (working copy) @@ -139,6 +139,17 @@ fontMap.setProperty(new StringBuffer(LANG_KEY_PREFIX).append(lang.getCode()).toString(), GuiConvert.font2String(font)); store(); } + + /** + * Remove the font settings for a given key + * + * @param key the book initials or language code + */ + public void resetFont(String key) { + load(); + fontMap.remove(key); + store(); + } /** * Get a font for the specified resource. If it does not work try the #P bibledesktop Index: src/main/java/org/crosswire/bibledesktop/book/install/SitePane_control.properties =================================================================== --- src/main/java/org/crosswire/bibledesktop/book/install/SitePane_control.properties (revision 1949) +++ src/main/java/org/crosswire/bibledesktop/book/install/SitePane_control.properties (working copy) @@ -2,5 +2,6 @@ Unindex.Enabled=false Unlock.Enabled=false ChooseFont.Enabled=false +ResetFont.Enabled=false Install.Enabled=false InstallSearch.Enabled=false Index: src/main/java/org/crosswire/bibledesktop/book/install/SitePane.properties =================================================================== --- src/main/java/org/crosswire/bibledesktop/book/install/SitePane.properties (revision 1949) +++ src/main/java/org/crosswire/bibledesktop/book/install/SitePane.properties (working copy) @@ -5,6 +5,9 @@ ChooseFont.MnemonicKey=F ChooseFont.Name=Font... ChooseFont.ToolTip=Choose a Font for the Language or Book +ResetFont.MnemonicKey=E +ResetFont.Name=Reset Font +ResetFont.ToolTip=Reset the custom font set for this Language or Book Delete.MnemonicKey=D Delete.Name=Delete Book Delete.ToolTip=Delete the selected book Index: src/main/java/org/crosswire/bibledesktop/book/install/BookFont.java =================================================================== --- src/main/java/org/crosswire/bibledesktop/book/install/BookFont.java (revision 1949) +++ src/main/java/org/crosswire/bibledesktop/book/install/BookFont.java (working copy) @@ -93,6 +93,39 @@ { return fonts.getFont(null, language, null); } + + /** + * Is a font for this book / language set in the properties file? + * + * @param book the book to test + * @param lang the language to test + * @return true a font property was set, false otherwise + */ + public boolean isSet(Book book, Language lang) { + if (book != null) + { + return getFontMap().getProperty(book.getInitials()) != null; + } + if (lang != null) + { + return getFontMap().getProperty(new StringBuffer(LANG_KEY_PREFIX).append(lang.getCode()).toString()) != null; + } + return false; + } + + /** + * Remove the entry for this book / language in the properties file and use the default font + */ + public void resetFont(Book book, Language lang) { + if (book != null) + { + resetFont(book.getInitials()); + } + if (lang != null) + { + resetFont(new StringBuffer(LANG_KEY_PREFIX).append(lang.getCode()).toString()); + } + } private static BookFont fonts = new BookFont(); } Index: src/main/java/org/crosswire/bibledesktop/book/install/SitePane.java =================================================================== --- src/main/java/org/crosswire/bibledesktop/book/install/SitePane.java (revision 1949) +++ src/main/java/org/crosswire/bibledesktop/book/install/SitePane.java (working copy) @@ -296,11 +296,12 @@ } else { - panel.setLayout(new GridLayout(2, 2, 3, 3)); + panel.setLayout(new GridLayout(3, 2, 3, 3)); panel.add(new JButton(actions.getAction(DELETE))); panel.add(new JButton(actions.getAction(UNINDEX))); panel.add(new JButton(actions.getAction(CHOOSE_FONT))); panel.add(new JButton(actions.getAction(UNLOCK))); + panel.add(new JButton(actions.getAction(RESET_FONT))); } return panel; } @@ -533,6 +534,24 @@ Font picked = FontChooser.showDialog(this, Msg.FONT_CHOOSER.toString(), BookFont.instance().getFont(language)); BookFont.instance().setFont(language, picked); } + actions.getAction(RESET_FONT).setEnabled(BookFont.instance().isSet(book, language)); + } + + /** + * Resets any font specifically set for this Book / Language + */ + public void doResetFont() { + TreePath path = treAvailable.getSelectionPath(); + if (path == null) + { + return; + } + + Object last = path.getLastPathComponent(); + Book book = getBook(last); + Language language = getLanguage(last); + BookFont.instance().resetFont(book, language); + actions.getAction(RESET_FONT).setEnabled(false); } /** @@ -559,6 +578,7 @@ actions.getAction(INSTALL).setEnabled(book != null && book.isSupported()); actions.getAction(INSTALL_SEARCH).setEnabled(book != null && book.isSupported() && book.getBookCategory() == BookCategory.BIBLE); actions.getAction(CHOOSE_FONT).setEnabled(book != null || lang != null); + actions.getAction(RESET_FONT).setEnabled(BookFont.instance().isSet(book, lang)); } public void setTreeModel(BookList books) @@ -614,6 +634,7 @@ private static final String UNLOCK = "Unlock"; //$NON-NLS-1$ private static final String CHOOSE_FONT = "ChooseFont"; //$NON-NLS-1$ private static final String UNINDEX = "Unindex"; //$NON-NLS-1$ + private static final String RESET_FONT = "ResetFont"; //$NON-NLS-1$ /** * From which we get our list of installable books