From 214399f13c6513d84077c3b441a01cc469a6f867 Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Sun, 22 Feb 2009 10:45:41 +0000 Subject: [PATCH] * add persistent search history to episodelist to enable completion * make tabbed panes look better in Nimbus LAF --- source/net/sourceforge/filebot/Settings.java | 8 ++--- .../filebot/ui/AbstractSearchPanel.java | 14 +++------ .../ui/panel/analyze/AnalyzePanel.java | 4 +-- .../panel/episodelist/EpisodeListPanel.java | 25 ++++++++++++++- .../ui/panel/subtitle/SubtitlePanel.java | 31 +++++++++++++------ 5 files changed, 54 insertions(+), 28 deletions(-) diff --git a/source/net/sourceforge/filebot/Settings.java b/source/net/sourceforge/filebot/Settings.java index 6fe5fdaa..071f70ed 100644 --- a/source/net/sourceforge/filebot/Settings.java +++ b/source/net/sourceforge/filebot/Settings.java @@ -24,7 +24,7 @@ public final class Settings { return "1.9"; }; - private static final Settings userRoot = new Settings(Preferences.userRoot(), getApplicationName()); + private static final Settings userRoot = new Settings(Preferences.userNodeForPackage(Settings.class)); public static Settings userRoot() { @@ -34,13 +34,13 @@ public final class Settings { private final Preferences prefs; - private Settings(Preferences parentNode, String name) { - this.prefs = parentNode.node(name.toLowerCase()); + private Settings(Preferences prefs) { + this.prefs = prefs; } public Settings node(String nodeName) { - return new Settings(prefs, nodeName); + return new Settings(prefs.node(nodeName.toLowerCase())); } diff --git a/source/net/sourceforge/filebot/ui/AbstractSearchPanel.java b/source/net/sourceforge/filebot/ui/AbstractSearchPanel.java index b88a5ce3..33c0468d 100644 --- a/source/net/sourceforge/filebot/ui/AbstractSearchPanel.java +++ b/source/net/sourceforge/filebot/ui/AbstractSearchPanel.java @@ -2,11 +2,8 @@ package net.sourceforge.filebot.ui; -import static javax.swing.JTabbedPane.SCROLL_TAB_LAYOUT; import static javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER; import static javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED; -import static javax.swing.SwingConstants.TOP; - import java.awt.Window; import java.awt.event.ActionEvent; import java.net.URI; @@ -34,7 +31,6 @@ import net.sourceforge.tuned.ExceptionUtilities; import net.sourceforge.tuned.ui.LabelProvider; import net.sourceforge.tuned.ui.SelectButtonTextField; import net.sourceforge.tuned.ui.TunedUtilities; -import ca.odell.glazedlists.BasicEventList; import ca.odell.glazedlists.EventList; import ca.odell.glazedlists.swing.AutoCompleteSupport; @@ -43,13 +39,13 @@ public abstract class AbstractSearchPanel extends FileBotPanel { protected final JPanel tabbedPaneGroup = new JPanel(new MigLayout("nogrid, fill, insets 0")); - protected final JTabbedPane tabbedPane = new JTabbedPane(TOP, SCROLL_TAB_LAYOUT); + protected final JTabbedPane tabbedPane = new JTabbedPane(); protected final HistoryPanel historyPanel = new HistoryPanel(); protected final SelectButtonTextField searchTextField = new SelectButtonTextField(); - private EventList searchHistory = new BasicEventList(); + protected final EventList searchHistory = createSearchHistory(); public AbstractSearchPanel(String title, Icon icon) { @@ -96,12 +92,10 @@ public abstract class AbstractSearchPanel extends FileBotPanel { protected abstract LabelProvider createSearchEngineLabelProvider(); - protected abstract RequestProcessor createRequestProcessor(); + protected abstract EventList createSearchHistory(); - public EventList getSearchHistory() { - return searchHistory; - } + protected abstract RequestProcessor createRequestProcessor(); private void search(RequestProcessor requestProcessor) { diff --git a/source/net/sourceforge/filebot/ui/panel/analyze/AnalyzePanel.java b/source/net/sourceforge/filebot/ui/panel/analyze/AnalyzePanel.java index f210cebf..f9468afd 100644 --- a/source/net/sourceforge/filebot/ui/panel/analyze/AnalyzePanel.java +++ b/source/net/sourceforge/filebot/ui/panel/analyze/AnalyzePanel.java @@ -7,8 +7,6 @@ import java.beans.PropertyChangeListener; import javax.swing.BorderFactory; import javax.swing.JTabbedPane; -import javax.swing.SwingConstants; - import net.miginfocom.swing.MigLayout; import net.sourceforge.filebot.ResourceManager; import net.sourceforge.filebot.ui.FileBotPanel; @@ -19,7 +17,7 @@ import net.sourceforge.tuned.MessageHandler; public class AnalyzePanel extends FileBotPanel { private final FileTreePanel fileTreePanel = new FileTreePanel(); - private final JTabbedPane toolsPanel = new JTabbedPane(SwingConstants.TOP, JTabbedPane.SCROLL_TAB_LAYOUT); + private final JTabbedPane toolsPanel = new JTabbedPane(); private final MessageHandler messageHandler = new FileTransferableMessageHandler(this, fileTreePanel.getTransferablePolicy()); diff --git a/source/net/sourceforge/filebot/ui/panel/episodelist/EpisodeListPanel.java b/source/net/sourceforge/filebot/ui/panel/episodelist/EpisodeListPanel.java index 2ecde261..be306de4 100644 --- a/source/net/sourceforge/filebot/ui/panel/episodelist/EpisodeListPanel.java +++ b/source/net/sourceforge/filebot/ui/panel/episodelist/EpisodeListPanel.java @@ -21,6 +21,9 @@ import javax.swing.JButton; import javax.swing.JSpinner; import javax.swing.KeyStroke; +import ca.odell.glazedlists.BasicEventList; +import ca.odell.glazedlists.EventList; + import net.sourceforge.filebot.ResourceManager; import net.sourceforge.filebot.Settings; import net.sourceforge.filebot.ui.AbstractSearchPanel; @@ -37,6 +40,7 @@ import net.sourceforge.filebot.web.SearchResult; import net.sourceforge.filebot.web.TVDotComClient; import net.sourceforge.filebot.web.TVRageClient; import net.sourceforge.filebot.web.TheTVDBClient; +import net.sourceforge.tuned.ListChangeSynchronizer; import net.sourceforge.tuned.ui.LabelProvider; import net.sourceforge.tuned.ui.SelectButton; import net.sourceforge.tuned.ui.SimpleLabelProvider; @@ -74,7 +78,7 @@ public class EpisodeListPanel extends AbstractSearchPanel createSearchEngines() { - List engines = new ArrayList(3); + List engines = new ArrayList(4); engines.add(new TVRageClient()); engines.add(new AnidbClient()); @@ -91,6 +95,25 @@ public class EpisodeListPanel extends AbstractSearchPanel createSearchHistory() { + // create in-memory list + BasicEventList searchHistory = new BasicEventList(); + + // get the preferences node that contains the history entries + // and get a StringList that read and writes directly from and to the preferences + List persistentSearchHistory = Settings.userRoot().node("episodelist/history").asList(String.class); + + // add history from the preferences to the current in-memory history (for completion) + searchHistory.addAll(persistentSearchHistory); + + // perform all insert/add/remove operations on the in-memory history on the preferences node as well + ListChangeSynchronizer.syncEventListToList(searchHistory, persistentSearchHistory); + + return searchHistory; + } + + @Override protected EpisodeListRequestProcessor createRequestProcessor() { EpisodeListClient client = searchTextField.getSelectButton().getSelectedValue(); diff --git a/source/net/sourceforge/filebot/ui/panel/subtitle/SubtitlePanel.java b/source/net/sourceforge/filebot/ui/panel/subtitle/SubtitlePanel.java index e4b8bf35..dee4e8db 100644 --- a/source/net/sourceforge/filebot/ui/panel/subtitle/SubtitlePanel.java +++ b/source/net/sourceforge/filebot/ui/panel/subtitle/SubtitlePanel.java @@ -11,6 +11,8 @@ import java.util.Collection; import java.util.List; import java.util.Locale; +import ca.odell.glazedlists.BasicEventList; +import ca.odell.glazedlists.EventList; import net.sourceforge.filebot.ResourceManager; import net.sourceforge.filebot.Settings; import net.sourceforge.filebot.ui.AbstractSearchPanel; @@ -33,16 +35,6 @@ public class SubtitlePanel extends AbstractSearchPanel persistentSearchHistory = Settings.userRoot().node("subtitles/history").asList(String.class); - - // add history from the preferences to the current in-memory history (for completion) - getSearchHistory().addAll(persistentSearchHistory); - - // perform all insert/add/remove operations on the in-memory history on the preferences node as well - ListChangeSynchronizer.syncEventListToList(getSearchHistory(), persistentSearchHistory); } @@ -64,6 +56,25 @@ public class SubtitlePanel extends AbstractSearchPanel createSearchHistory() { + // create in-memory history + BasicEventList history = new BasicEventList(); + + // get the preferences node that contains the history entries + // and get a StringList that read and writes directly from and to the preferences + List persistentHistory = Settings.userRoot().node("subtitles/history").asList(String.class); + + // add history from the preferences to the current in-memory history (for completion) + history.addAll(persistentHistory); + + // perform all insert/add/remove operations on the in-memory history on the preferences node as well + ListChangeSynchronizer.syncEventListToList(history, persistentHistory); + + return history; + } + + @Override protected SubtitleRequestProcessor createRequestProcessor() { SubtitleClient client = searchTextField.getSelectButton().getSelectedValue();