* add persistent search history to episodelist to enable completion
* make tabbed panes look better in Nimbus LAF
This commit is contained in:
parent
d2f5c8e572
commit
214399f13c
|
@ -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()));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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<S, E> 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<S> searchTextField = new SelectButtonTextField<S>();
|
||||
|
||||
private EventList<String> searchHistory = new BasicEventList<String>();
|
||||
protected final EventList<String> searchHistory = createSearchHistory();
|
||||
|
||||
|
||||
public AbstractSearchPanel(String title, Icon icon) {
|
||||
|
@ -96,12 +92,10 @@ public abstract class AbstractSearchPanel<S, E> extends FileBotPanel {
|
|||
protected abstract LabelProvider<S> createSearchEngineLabelProvider();
|
||||
|
||||
|
||||
protected abstract RequestProcessor<?, E> createRequestProcessor();
|
||||
protected abstract EventList<String> createSearchHistory();
|
||||
|
||||
|
||||
public EventList<String> getSearchHistory() {
|
||||
return searchHistory;
|
||||
}
|
||||
protected abstract RequestProcessor<?, E> createRequestProcessor();
|
||||
|
||||
|
||||
private void search(RequestProcessor<?, E> requestProcessor) {
|
||||
|
|
|
@ -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());
|
||||
|
||||
|
|
|
@ -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<EpisodeListClient, Epi
|
|||
|
||||
@Override
|
||||
protected List<EpisodeListClient> createSearchEngines() {
|
||||
List<EpisodeListClient> engines = new ArrayList<EpisodeListClient>(3);
|
||||
List<EpisodeListClient> engines = new ArrayList<EpisodeListClient>(4);
|
||||
|
||||
engines.add(new TVRageClient());
|
||||
engines.add(new AnidbClient());
|
||||
|
@ -91,6 +95,25 @@ public class EpisodeListPanel extends AbstractSearchPanel<EpisodeListClient, Epi
|
|||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected EventList<String> createSearchHistory() {
|
||||
// create in-memory list
|
||||
BasicEventList<String> searchHistory = new BasicEventList<String>();
|
||||
|
||||
// get the preferences node that contains the history entries
|
||||
// and get a StringList that read and writes directly from and to the preferences
|
||||
List<String> 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();
|
||||
|
|
|
@ -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<SubtitleClient, SubtitleP
|
|||
|
||||
historyPanel.setColumnHeader(0, "Show / Movie");
|
||||
historyPanel.setColumnHeader(1, "Number of Subtitles");
|
||||
|
||||
// get preferences node that contains the history entries
|
||||
// and get a StringList that read and writes directly from and to the preferences
|
||||
List<String> 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<SubtitleClient, SubtitleP
|
|||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected EventList<String> createSearchHistory() {
|
||||
// create in-memory history
|
||||
BasicEventList<String> history = new BasicEventList<String>();
|
||||
|
||||
// get the preferences node that contains the history entries
|
||||
// and get a StringList that read and writes directly from and to the preferences
|
||||
List<String> 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();
|
||||
|
|
Loading…
Reference in New Issue