* 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";
|
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() {
|
public static Settings userRoot() {
|
||||||
|
@ -34,13 +34,13 @@ public final class Settings {
|
||||||
private final Preferences prefs;
|
private final Preferences prefs;
|
||||||
|
|
||||||
|
|
||||||
private Settings(Preferences parentNode, String name) {
|
private Settings(Preferences prefs) {
|
||||||
this.prefs = parentNode.node(name.toLowerCase());
|
this.prefs = prefs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Settings node(String nodeName) {
|
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;
|
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.HORIZONTAL_SCROLLBAR_NEVER;
|
||||||
import static javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;
|
import static javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;
|
||||||
import static javax.swing.SwingConstants.TOP;
|
|
||||||
|
|
||||||
import java.awt.Window;
|
import java.awt.Window;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
@ -34,7 +31,6 @@ import net.sourceforge.tuned.ExceptionUtilities;
|
||||||
import net.sourceforge.tuned.ui.LabelProvider;
|
import net.sourceforge.tuned.ui.LabelProvider;
|
||||||
import net.sourceforge.tuned.ui.SelectButtonTextField;
|
import net.sourceforge.tuned.ui.SelectButtonTextField;
|
||||||
import net.sourceforge.tuned.ui.TunedUtilities;
|
import net.sourceforge.tuned.ui.TunedUtilities;
|
||||||
import ca.odell.glazedlists.BasicEventList;
|
|
||||||
import ca.odell.glazedlists.EventList;
|
import ca.odell.glazedlists.EventList;
|
||||||
import ca.odell.glazedlists.swing.AutoCompleteSupport;
|
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 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 HistoryPanel historyPanel = new HistoryPanel();
|
||||||
|
|
||||||
protected final SelectButtonTextField<S> searchTextField = new SelectButtonTextField<S>();
|
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) {
|
public AbstractSearchPanel(String title, Icon icon) {
|
||||||
|
@ -96,14 +92,12 @@ public abstract class AbstractSearchPanel<S, E> extends FileBotPanel {
|
||||||
protected abstract LabelProvider<S> createSearchEngineLabelProvider();
|
protected abstract LabelProvider<S> createSearchEngineLabelProvider();
|
||||||
|
|
||||||
|
|
||||||
|
protected abstract EventList<String> createSearchHistory();
|
||||||
|
|
||||||
|
|
||||||
protected abstract RequestProcessor<?, E> createRequestProcessor();
|
protected abstract RequestProcessor<?, E> createRequestProcessor();
|
||||||
|
|
||||||
|
|
||||||
public EventList<String> getSearchHistory() {
|
|
||||||
return searchHistory;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void search(RequestProcessor<?, E> requestProcessor) {
|
private void search(RequestProcessor<?, E> requestProcessor) {
|
||||||
FileBotTab<?> tab = requestProcessor.tab;
|
FileBotTab<?> tab = requestProcessor.tab;
|
||||||
|
|
||||||
|
|
|
@ -7,8 +7,6 @@ import java.beans.PropertyChangeListener;
|
||||||
|
|
||||||
import javax.swing.BorderFactory;
|
import javax.swing.BorderFactory;
|
||||||
import javax.swing.JTabbedPane;
|
import javax.swing.JTabbedPane;
|
||||||
import javax.swing.SwingConstants;
|
|
||||||
|
|
||||||
import net.miginfocom.swing.MigLayout;
|
import net.miginfocom.swing.MigLayout;
|
||||||
import net.sourceforge.filebot.ResourceManager;
|
import net.sourceforge.filebot.ResourceManager;
|
||||||
import net.sourceforge.filebot.ui.FileBotPanel;
|
import net.sourceforge.filebot.ui.FileBotPanel;
|
||||||
|
@ -19,7 +17,7 @@ import net.sourceforge.tuned.MessageHandler;
|
||||||
public class AnalyzePanel extends FileBotPanel {
|
public class AnalyzePanel extends FileBotPanel {
|
||||||
|
|
||||||
private final FileTreePanel fileTreePanel = new FileTreePanel();
|
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());
|
private final MessageHandler messageHandler = new FileTransferableMessageHandler(this, fileTreePanel.getTransferablePolicy());
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,9 @@ import javax.swing.JButton;
|
||||||
import javax.swing.JSpinner;
|
import javax.swing.JSpinner;
|
||||||
import javax.swing.KeyStroke;
|
import javax.swing.KeyStroke;
|
||||||
|
|
||||||
|
import ca.odell.glazedlists.BasicEventList;
|
||||||
|
import ca.odell.glazedlists.EventList;
|
||||||
|
|
||||||
import net.sourceforge.filebot.ResourceManager;
|
import net.sourceforge.filebot.ResourceManager;
|
||||||
import net.sourceforge.filebot.Settings;
|
import net.sourceforge.filebot.Settings;
|
||||||
import net.sourceforge.filebot.ui.AbstractSearchPanel;
|
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.TVDotComClient;
|
||||||
import net.sourceforge.filebot.web.TVRageClient;
|
import net.sourceforge.filebot.web.TVRageClient;
|
||||||
import net.sourceforge.filebot.web.TheTVDBClient;
|
import net.sourceforge.filebot.web.TheTVDBClient;
|
||||||
|
import net.sourceforge.tuned.ListChangeSynchronizer;
|
||||||
import net.sourceforge.tuned.ui.LabelProvider;
|
import net.sourceforge.tuned.ui.LabelProvider;
|
||||||
import net.sourceforge.tuned.ui.SelectButton;
|
import net.sourceforge.tuned.ui.SelectButton;
|
||||||
import net.sourceforge.tuned.ui.SimpleLabelProvider;
|
import net.sourceforge.tuned.ui.SimpleLabelProvider;
|
||||||
|
@ -74,7 +78,7 @@ public class EpisodeListPanel extends AbstractSearchPanel<EpisodeListClient, Epi
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<EpisodeListClient> createSearchEngines() {
|
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 TVRageClient());
|
||||||
engines.add(new AnidbClient());
|
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
|
@Override
|
||||||
protected EpisodeListRequestProcessor createRequestProcessor() {
|
protected EpisodeListRequestProcessor createRequestProcessor() {
|
||||||
EpisodeListClient client = searchTextField.getSelectButton().getSelectedValue();
|
EpisodeListClient client = searchTextField.getSelectButton().getSelectedValue();
|
||||||
|
|
|
@ -11,6 +11,8 @@ import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
|
import ca.odell.glazedlists.BasicEventList;
|
||||||
|
import ca.odell.glazedlists.EventList;
|
||||||
import net.sourceforge.filebot.ResourceManager;
|
import net.sourceforge.filebot.ResourceManager;
|
||||||
import net.sourceforge.filebot.Settings;
|
import net.sourceforge.filebot.Settings;
|
||||||
import net.sourceforge.filebot.ui.AbstractSearchPanel;
|
import net.sourceforge.filebot.ui.AbstractSearchPanel;
|
||||||
|
@ -33,16 +35,6 @@ public class SubtitlePanel extends AbstractSearchPanel<SubtitleClient, SubtitleP
|
||||||
|
|
||||||
historyPanel.setColumnHeader(0, "Show / Movie");
|
historyPanel.setColumnHeader(0, "Show / Movie");
|
||||||
historyPanel.setColumnHeader(1, "Number of Subtitles");
|
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
|
@Override
|
||||||
protected SubtitleRequestProcessor createRequestProcessor() {
|
protected SubtitleRequestProcessor createRequestProcessor() {
|
||||||
SubtitleClient client = searchTextField.getSelectButton().getSelectedValue();
|
SubtitleClient client = searchTextField.getSelectButton().getSelectedValue();
|
||||||
|
|
Loading…
Reference in New Issue