* settings / preferences
* small ui enhancements * little bit of refactoring
This commit is contained in:
parent
0d90d19d05
commit
36c0406ec6
|
@ -1,5 +1,5 @@
|
|||
|
||||
package net.sourceforge.filebot.ui;
|
||||
package net.sourceforge.filebot;
|
||||
|
||||
|
||||
import javax.swing.Action;
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
package net.sourceforge.filebot.ui;
|
||||
package net.sourceforge.filebot;
|
||||
|
||||
|
||||
import java.io.File;
|
|
@ -0,0 +1,96 @@
|
|||
|
||||
package net.sourceforge.filebot;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.prefs.Preferences;
|
||||
|
||||
|
||||
public class Settings {
|
||||
|
||||
private static Settings settings = new Settings();
|
||||
|
||||
|
||||
public static Settings getSettings() {
|
||||
return settings;
|
||||
}
|
||||
|
||||
private Preferences prefs;
|
||||
|
||||
|
||||
private Settings() {
|
||||
this.prefs = Preferences.userNodeForPackage(this.getClass());
|
||||
}
|
||||
|
||||
private String defaultDelimiter = ";";
|
||||
|
||||
|
||||
private void putStringList(String key, Collection<String> values) {
|
||||
try {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
|
||||
for (String value : values) {
|
||||
sb.append(value.replaceAll(defaultDelimiter, " "));
|
||||
sb.append(defaultDelimiter);
|
||||
}
|
||||
|
||||
prefs.put(key, sb.toString());
|
||||
} catch (IllegalArgumentException e) {
|
||||
// value might exceed max length
|
||||
Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.SEVERE, e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private Collection<String> getStringList(String key) {
|
||||
String[] values = prefs.get(key, "").split(defaultDelimiter);
|
||||
|
||||
List<String> list = new ArrayList<String>();
|
||||
|
||||
for (String value : values) {
|
||||
if (!value.isEmpty())
|
||||
list.add(value);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
private static enum Key {
|
||||
panel, tvshowcompletionterms, subtitlecompletionterms;
|
||||
}
|
||||
|
||||
|
||||
public int getSelectedPanel() {
|
||||
return prefs.getInt(Key.panel.name(), 3);
|
||||
}
|
||||
|
||||
|
||||
public void setSelectedPanel(int index) {
|
||||
prefs.putInt(Key.panel.name(), index);
|
||||
}
|
||||
|
||||
|
||||
public void setTvShowCompletionTerms(Collection<String> terms) {
|
||||
putStringList(Key.tvshowcompletionterms.name(), terms);
|
||||
}
|
||||
|
||||
|
||||
public Collection<String> getTvShowCompletionTerms() {
|
||||
return getStringList(Key.tvshowcompletionterms.name());
|
||||
}
|
||||
|
||||
|
||||
public void setSubtitleCompletionTerms(Collection<String> terms) {
|
||||
putStringList(Key.subtitlecompletionterms.name(), terms);
|
||||
}
|
||||
|
||||
|
||||
public Collection<String> getSubtitleCompletionTerms() {
|
||||
return getStringList(Key.subtitlecompletionterms.name());
|
||||
}
|
||||
}
|
|
@ -21,6 +21,7 @@ import javax.swing.KeyStroke;
|
|||
import javax.swing.ListSelectionModel;
|
||||
import javax.swing.border.TitledBorder;
|
||||
|
||||
import net.sourceforge.filebot.FileBotUtil;
|
||||
import net.sourceforge.filebot.ui.transfer.DefaultTransferHandler;
|
||||
import net.sourceforge.filebot.ui.transfer.ExportHandler;
|
||||
import net.sourceforge.filebot.ui.transfer.FileTransferable;
|
||||
|
|
|
@ -21,6 +21,8 @@ import javax.swing.border.EmptyBorder;
|
|||
import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
|
||||
import net.sourceforge.filebot.FileBotUtil;
|
||||
import net.sourceforge.filebot.Settings;
|
||||
import net.sourceforge.filebot.resources.ResourceManager;
|
||||
import net.sourceforge.tuned.ui.ShadowBorder;
|
||||
|
||||
|
@ -55,7 +57,7 @@ public class FileBotWindow extends JFrame implements ListSelectionListener {
|
|||
|
||||
setSize(760, 615);
|
||||
|
||||
selectionListPanel.setSelectedIndex(3);
|
||||
selectionListPanel.setSelectedIndex(Settings.getSettings().getSelectedPanel());
|
||||
}
|
||||
|
||||
|
||||
|
@ -68,6 +70,8 @@ public class FileBotWindow extends JFrame implements ListSelectionListener {
|
|||
|
||||
JComponent c = (JComponent) getContentPane();
|
||||
c.updateUI();
|
||||
|
||||
Settings.getSettings().setSelectedPanel(selectionListPanel.getSelectedIndex());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -16,8 +16,8 @@ import javax.swing.JScrollPane;
|
|||
import javax.swing.KeyStroke;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
|
||||
import net.sourceforge.filebot.FileBotUtil;
|
||||
import net.sourceforge.filebot.resources.ResourceManager;
|
||||
import net.sourceforge.filebot.ui.FileBotUtil;
|
||||
import net.sourceforge.filebot.ui.transfer.LoadAction;
|
||||
import net.sourceforge.tuned.ui.LoadingOverlayPanel;
|
||||
|
||||
|
|
|
@ -24,9 +24,9 @@ import javax.swing.event.ChangeListener;
|
|||
import javax.swing.tree.DefaultMutableTreeNode;
|
||||
import javax.swing.tree.DefaultTreeModel;
|
||||
|
||||
import net.sourceforge.filebot.FileFormat;
|
||||
import net.sourceforge.filebot.resources.ResourceManager;
|
||||
import net.sourceforge.filebot.ui.FileBotTree;
|
||||
import net.sourceforge.filebot.ui.FileFormat;
|
||||
import net.sourceforge.filebot.ui.transfer.DefaultTransferHandler;
|
||||
import net.sourceforge.tuned.ui.GradientStyle;
|
||||
import net.sourceforge.tuned.ui.LoadingOverlayPanel;
|
||||
|
|
|
@ -17,9 +17,9 @@ import javax.swing.SwingWorker;
|
|||
import javax.swing.tree.DefaultMutableTreeNode;
|
||||
import javax.swing.tree.DefaultTreeModel;
|
||||
|
||||
import net.sourceforge.filebot.FileFormat;
|
||||
import net.sourceforge.filebot.resources.ResourceManager;
|
||||
import net.sourceforge.filebot.ui.FileBotTree;
|
||||
import net.sourceforge.filebot.ui.FileFormat;
|
||||
import net.sourceforge.filebot.ui.transfer.DefaultTransferHandler;
|
||||
import net.sourceforge.tuned.ui.LoadingOverlayPanel;
|
||||
|
||||
|
|
|
@ -19,9 +19,9 @@ import javax.swing.KeyStroke;
|
|||
import javax.swing.SpinnerNumberModel;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
|
||||
import net.sourceforge.filebot.FileBotUtil;
|
||||
import net.sourceforge.filebot.resources.ResourceManager;
|
||||
import net.sourceforge.filebot.ui.FileBotPanel;
|
||||
import net.sourceforge.filebot.ui.FileBotUtil;
|
||||
|
||||
|
||||
public class CreatePanel extends FileBotPanel {
|
||||
|
|
|
@ -7,8 +7,8 @@ import java.io.IOException;
|
|||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.sourceforge.filebot.FileFormat;
|
||||
import net.sourceforge.filebot.torrent.Torrent;
|
||||
import net.sourceforge.filebot.ui.FileFormat;
|
||||
import net.sourceforge.filebot.ui.transferablepolicies.FileTransferablePolicy;
|
||||
|
||||
|
||||
|
|
|
@ -11,8 +11,8 @@ import java.util.logging.Logger;
|
|||
|
||||
import javax.swing.DefaultListModel;
|
||||
|
||||
import net.sourceforge.filebot.FileFormat;
|
||||
import net.sourceforge.filebot.torrent.Torrent;
|
||||
import net.sourceforge.filebot.ui.FileFormat;
|
||||
import net.sourceforge.filebot.ui.panel.rename.entry.StringEntry;
|
||||
import net.sourceforge.filebot.ui.panel.rename.entry.TorrentEntry;
|
||||
import net.sourceforge.filebot.ui.transferablepolicies.FileTransferablePolicy;
|
||||
|
|
|
@ -9,8 +9,8 @@ import java.util.List;
|
|||
import javax.swing.AbstractAction;
|
||||
import javax.swing.Action;
|
||||
|
||||
import net.sourceforge.filebot.FileFormat;
|
||||
import net.sourceforge.filebot.resources.ResourceManager;
|
||||
import net.sourceforge.filebot.ui.FileFormat;
|
||||
import net.sourceforge.filebot.ui.MessageManager;
|
||||
import net.sourceforge.filebot.ui.panel.rename.entry.FileEntry;
|
||||
import net.sourceforge.filebot.ui.panel.rename.entry.ListEntry;
|
||||
|
|
|
@ -4,7 +4,7 @@ package net.sourceforge.filebot.ui.panel.rename.entry;
|
|||
|
||||
import java.io.File;
|
||||
|
||||
import net.sourceforge.filebot.ui.FileFormat;
|
||||
import net.sourceforge.filebot.FileFormat;
|
||||
|
||||
|
||||
public class FileEntry extends AbstractFileEntry<File> {
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
package net.sourceforge.filebot.ui.panel.rename.entry;
|
||||
|
||||
|
||||
import net.sourceforge.filebot.FileFormat;
|
||||
import net.sourceforge.filebot.torrent.Torrent;
|
||||
import net.sourceforge.filebot.torrent.Torrent.Entry;
|
||||
import net.sourceforge.filebot.ui.FileFormat;
|
||||
|
||||
|
||||
public class TorrentEntry extends AbstractFileEntry<Torrent.Entry> {
|
||||
|
|
|
@ -34,10 +34,11 @@ import javax.swing.SwingUtilities;
|
|||
import javax.swing.SwingWorker;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
|
||||
import net.sourceforge.filebot.FileBotUtil;
|
||||
import net.sourceforge.filebot.Settings;
|
||||
import net.sourceforge.filebot.resources.ResourceManager;
|
||||
import net.sourceforge.filebot.ui.FileBotList;
|
||||
import net.sourceforge.filebot.ui.FileBotPanel;
|
||||
import net.sourceforge.filebot.ui.FileBotUtil;
|
||||
import net.sourceforge.filebot.ui.MessageManager;
|
||||
import net.sourceforge.filebot.ui.transfer.SaveAction;
|
||||
import net.sourceforge.filebot.web.AnidbClient;
|
||||
|
@ -87,6 +88,7 @@ public class SearchPanel extends FileBotPanel {
|
|||
searchField.getTextField().setColumns(25);
|
||||
|
||||
searchFieldCompletion = new TextCompletion(searchField.getTextField());
|
||||
searchFieldCompletion.addCompletionTerms(Settings.getSettings().getTvShowCompletionTerms());
|
||||
searchFieldCompletion.hook();
|
||||
|
||||
JPanel mainPanel = new JPanel(new BorderLayout(5, 5));
|
||||
|
@ -354,6 +356,7 @@ public class SearchPanel extends FileBotPanel {
|
|||
}
|
||||
|
||||
searchFieldCompletion.addCompletionTerm(showname);
|
||||
Settings.getSettings().setTvShowCompletionTerms(searchFieldCompletion.getCompletionTerms());
|
||||
|
||||
String title = showname;
|
||||
if (task.getNumberOfSeason() != SeasonSpinnerEditor.ALL_SEASONS)
|
||||
|
|
|
@ -18,7 +18,7 @@ import javax.swing.ListSelectionModel;
|
|||
import javax.swing.table.TableColumn;
|
||||
import javax.swing.table.TableModel;
|
||||
|
||||
import net.sourceforge.filebot.ui.FileFormat;
|
||||
import net.sourceforge.filebot.FileFormat;
|
||||
import net.sourceforge.filebot.ui.panel.sfv.renderer.ChecksumTableCellRenderer;
|
||||
import net.sourceforge.filebot.ui.panel.sfv.renderer.StateIconTableCellRenderer;
|
||||
import net.sourceforge.filebot.ui.panel.sfv.renderer.TextTableCellRenderer;
|
||||
|
|
|
@ -13,7 +13,7 @@ import java.util.List;
|
|||
|
||||
import javax.swing.table.AbstractTableModel;
|
||||
|
||||
import net.sourceforge.filebot.ui.FileFormat;
|
||||
import net.sourceforge.filebot.FileFormat;
|
||||
|
||||
|
||||
public class SfvTableModel extends AbstractTableModel {
|
||||
|
|
|
@ -17,9 +17,9 @@ import javax.swing.KeyStroke;
|
|||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
|
||||
import net.sourceforge.filebot.FileBotUtil;
|
||||
import net.sourceforge.filebot.FileFormat;
|
||||
import net.sourceforge.filebot.resources.ResourceManager;
|
||||
import net.sourceforge.filebot.ui.FileBotUtil;
|
||||
import net.sourceforge.filebot.ui.FileFormat;
|
||||
import net.sourceforge.filebot.ui.transfer.LoadAction;
|
||||
import net.sourceforge.filebot.ui.transfer.SaveAction;
|
||||
import net.sourceforge.tuned.ui.SelectDialog;
|
||||
|
|
|
@ -13,7 +13,7 @@ import java.util.logging.Logger;
|
|||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import net.sourceforge.filebot.ui.FileFormat;
|
||||
import net.sourceforge.filebot.FileFormat;
|
||||
import net.sourceforge.filebot.ui.transferablepolicies.BackgroundFileTransferablePolicy;
|
||||
import net.sourceforge.filebot.ui.transferablepolicies.MultiTransferablePolicy;
|
||||
|
||||
|
|
|
@ -8,8 +8,8 @@ import java.io.File;
|
|||
import javax.swing.AbstractAction;
|
||||
import javax.swing.JFileChooser;
|
||||
|
||||
import net.sourceforge.filebot.FileBotUtil;
|
||||
import net.sourceforge.filebot.resources.ResourceManager;
|
||||
import net.sourceforge.filebot.ui.FileBotUtil;
|
||||
|
||||
|
||||
public class SaveAction extends AbstractAction {
|
||||
|
|
|
@ -13,7 +13,7 @@ import java.util.logging.Logger;
|
|||
import javax.swing.JComponent;
|
||||
import javax.swing.TransferHandler;
|
||||
|
||||
import net.sourceforge.filebot.ui.FileBotUtil;
|
||||
import net.sourceforge.filebot.FileBotUtil;
|
||||
|
||||
|
||||
public class SaveableExportHandler implements ExportHandler {
|
||||
|
|
|
@ -7,6 +7,7 @@ import java.awt.Component;
|
|||
import java.awt.GradientPaint;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Insets;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
|
||||
import javax.swing.DefaultListCellRenderer;
|
||||
|
@ -23,49 +24,65 @@ public class FancyListCellRenderer extends DefaultListCellRenderer {
|
|||
|
||||
private Color gradientEndColor;
|
||||
|
||||
private boolean highlightingEnabled;
|
||||
|
||||
private Border defaultBorder;
|
||||
|
||||
private Border selectedBorder;
|
||||
|
||||
private GradientStyle gradientStyle;
|
||||
|
||||
private boolean paintGradient;
|
||||
private boolean paintGradientEnabled;
|
||||
|
||||
private Insets padding;
|
||||
|
||||
|
||||
public FancyListCellRenderer() {
|
||||
this(7, GradientStyle.TOP_TO_BOTTOM);
|
||||
this(GradientStyle.TOP_TO_BOTTOM, false, new Insets(7, 7, 7, 7), new Insets(1, 1, 0, 1), null);
|
||||
}
|
||||
|
||||
|
||||
public FancyListCellRenderer(int margin, GradientStyle gradientStyle) {
|
||||
this(margin, null, gradientStyle);
|
||||
public FancyListCellRenderer(int padding, Color selectedBorderColor, GradientStyle gradientStyle) {
|
||||
this(gradientStyle, false, new Insets(padding, padding, padding, padding), new Insets(0, 0, 0, 0), selectedBorderColor);
|
||||
}
|
||||
|
||||
|
||||
public FancyListCellRenderer(int margin, Color selectedBorderColor, GradientStyle gradientStyle) {
|
||||
public FancyListCellRenderer(GradientStyle gradientStyle, boolean highlighting, Insets margin, Insets padding, Color selectedBorderColor) {
|
||||
this.gradientStyle = gradientStyle;
|
||||
this.padding = padding;
|
||||
this.highlightingEnabled = highlighting;
|
||||
|
||||
Border marginBorder = new EmptyBorder(margin, margin, margin, margin);
|
||||
Border marginBorder = new EmptyBorder(margin);
|
||||
Border paddingBorder = new EmptyBorder(padding);
|
||||
|
||||
defaultBorder = marginBorder;
|
||||
selectedBorder = marginBorder;
|
||||
|
||||
if (selectedBorderColor != null) {
|
||||
defaultBorder = new CompoundBorder(new EmptyBorder(1, 1, 1, 1), marginBorder);
|
||||
selectedBorder = new CompoundBorder(new LineBorder(selectedBorderColor, 1), marginBorder);
|
||||
} else {
|
||||
defaultBorder = marginBorder;
|
||||
selectedBorder = marginBorder;
|
||||
defaultBorder = new CompoundBorder(new EmptyBorder(1, 1, 1, 1), defaultBorder);
|
||||
selectedBorder = new CompoundBorder(new LineBorder(selectedBorderColor, 1), selectedBorder);
|
||||
}
|
||||
|
||||
defaultBorder = new CompoundBorder(paddingBorder, defaultBorder);
|
||||
selectedBorder = new CompoundBorder(paddingBorder, selectedBorder);
|
||||
|
||||
setOpaque(false);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void paintComponent(Graphics g) {
|
||||
if (isPaintGradient()) {
|
||||
Graphics2D g2d = (Graphics2D) g;
|
||||
|
||||
Rectangle2D shape = new Rectangle2D.Double(0, 0, getWidth(), getHeight());
|
||||
|
||||
Graphics2D g2d = (Graphics2D) g;
|
||||
Rectangle2D shape = new Rectangle2D.Double(padding.left, padding.top, getWidth() - (padding.left + padding.right), getHeight() - (padding.top + padding.bottom));
|
||||
|
||||
if (highlightingEnabled) {
|
||||
g2d.setPaint(getBackground());
|
||||
g2d.fill(shape);
|
||||
}
|
||||
|
||||
if (paintGradientEnabled) {
|
||||
GradientPaint gradient = gradientStyle.getGradientPaint(shape, gradientBeginColor, gradientEndColor);
|
||||
|
||||
g2d.setPaint(gradient);
|
||||
g2d.fill(shape);
|
||||
}
|
||||
|
@ -78,18 +95,27 @@ public class FancyListCellRenderer extends DefaultListCellRenderer {
|
|||
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||
|
||||
setOpaque(false);
|
||||
Color sc = list.getSelectionBackground();
|
||||
|
||||
if (highlightingEnabled) {
|
||||
Color normalBg = list.getBackground();
|
||||
Color highlightBg = new Color(sc.getRed(), sc.getGreen(), sc.getBlue(), 28);
|
||||
|
||||
if ((index % 2) == 0)
|
||||
setBackground(highlightBg);
|
||||
else
|
||||
setBackground(normalBg);
|
||||
}
|
||||
|
||||
if (isSelected) {
|
||||
setPaintGradient(true);
|
||||
setPaintGradientEnabled(true);
|
||||
|
||||
Color c = list.getSelectionBackground();
|
||||
setGradientBeginColor(c.brighter());
|
||||
setGradientEndColor(c);
|
||||
setGradientBeginColor(sc.brighter());
|
||||
setGradientEndColor(sc);
|
||||
|
||||
setBorder(selectedBorder);
|
||||
} else {
|
||||
setPaintGradient(false);
|
||||
setPaintGradientEnabled(false);
|
||||
setBorder(defaultBorder);
|
||||
}
|
||||
|
||||
|
@ -127,13 +153,23 @@ public class FancyListCellRenderer extends DefaultListCellRenderer {
|
|||
}
|
||||
|
||||
|
||||
public boolean isPaintGradient() {
|
||||
return paintGradient;
|
||||
public boolean isPaintGradientEnabled() {
|
||||
return paintGradientEnabled;
|
||||
}
|
||||
|
||||
|
||||
public void setPaintGradient(boolean gradientEnabled) {
|
||||
this.paintGradient = gradientEnabled;
|
||||
public void setPaintGradientEnabled(boolean gradientEnabled) {
|
||||
this.paintGradientEnabled = gradientEnabled;
|
||||
}
|
||||
|
||||
|
||||
public boolean isHighlightingEnabled() {
|
||||
return highlightingEnabled;
|
||||
}
|
||||
|
||||
|
||||
public void setHighlightingEnabled(boolean highlightingEnabled) {
|
||||
this.highlightingEnabled = highlightingEnabled;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -81,7 +81,7 @@ public class FancyTreeCellRenderer extends DefaultTreeCellRenderer {
|
|||
|
||||
protected int getLabelStart() {
|
||||
Icon icon = getIcon();
|
||||
if (icon != null && getText() != null) {
|
||||
if ((icon != null) && (getText() != null)) {
|
||||
return icon.getIconWidth() + Math.max(0, getIconTextGap() - 1);
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ import javax.swing.text.JTextComponent;
|
|||
|
||||
public class TextCompletion {
|
||||
|
||||
private Set<String> completionTerms = Collections.synchronizedSet(new TreeSet<String>(String.CASE_INSENSITIVE_ORDER));;
|
||||
private Set<String> completionTerms = Collections.synchronizedSet(new TreeSet<String>(String.CASE_INSENSITIVE_ORDER));
|
||||
|
||||
private int completionStartLength = 1;
|
||||
|
||||
|
@ -62,6 +62,11 @@ public class TextCompletion {
|
|||
}
|
||||
|
||||
|
||||
public Set<String> getCompletionTerms() {
|
||||
return completionTerms;
|
||||
}
|
||||
|
||||
|
||||
public int getCompletionStartLength() {
|
||||
return completionStartLength;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue