diff --git a/source/net/sourceforge/filebot/ui/SelectDialog.java b/source/net/sourceforge/filebot/ui/SelectDialog.java index 0e64e404..e4ddcdfd 100644 --- a/source/net/sourceforge/filebot/ui/SelectDialog.java +++ b/source/net/sourceforge/filebot/ui/SelectDialog.java @@ -2,7 +2,6 @@ package net.sourceforge.filebot.ui; -import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.Window; import java.awt.event.ActionEvent; @@ -11,19 +10,16 @@ import java.awt.event.MouseEvent; import java.util.Collection; import javax.swing.AbstractAction; -import javax.swing.BorderFactory; -import javax.swing.Box; import javax.swing.JButton; import javax.swing.JComponent; import javax.swing.JDialog; import javax.swing.JLabel; import javax.swing.JList; -import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.KeyStroke; import javax.swing.SwingUtilities; -import javax.swing.border.EmptyBorder; +import net.miginfocom.swing.MigLayout; import net.sourceforge.filebot.ResourceManager; import net.sourceforge.tuned.ui.ArrayListModel; import net.sourceforge.tuned.ui.DefaultFancyListCellRenderer; @@ -32,11 +28,11 @@ import net.sourceforge.tuned.ui.TunedUtil; public class SelectDialog extends JDialog { - private JLabel label = new JLabel(); + private final JLabel headerLabel = new JLabel(); - private JList list = new JList(); + private final JList list; - private T selectedValue = null; + private boolean valueSelected = false; public SelectDialog(Window owner, Collection options) { @@ -44,43 +40,30 @@ public class SelectDialog extends JDialog { setDefaultCloseOperation(DISPOSE_ON_CLOSE); - list.setCellRenderer(new SelectListCellRenderer()); - list.addMouseListener(mouseListener); + // initialize list and select first element + list = new JList(new ArrayListModel(options)); + list.setSelectedIndex(0); - setText("Select:"); + DefaultFancyListCellRenderer cellRenderer = new DefaultFancyListCellRenderer(4); + cellRenderer.setHighlightingEnabled(false); + + list.setCellRenderer(cellRenderer); + list.addMouseListener(mouseListener); JComponent c = (JComponent) getContentPane(); - int border = 5; - c.setBorder(BorderFactory.createEmptyBorder(border, border, border, border)); - c.setLayout(new BorderLayout(border, border)); + c.setLayout(new MigLayout("insets 1.5mm, nogrid, fill")); - JPanel listPanel = new JPanel(new BorderLayout()); + c.add(headerLabel, "wrap"); + c.add(new JScrollPane(list), "grow, wrap 2mm"); - listPanel.add(new JScrollPane(list), BorderLayout.CENTER); + c.add(new JButton(selectAction), "align center"); + c.add(new JButton(cancelAction), "gap unrel, wrap 1.2mm"); - Box buttonBox = Box.createHorizontalBox(); - buttonBox.setBorder(new EmptyBorder(5, 5, 5, 5)); - - buttonBox.add(Box.createHorizontalGlue()); - buttonBox.add(new JButton(selectAction)); - buttonBox.add(Box.createHorizontalStrut(10)); - buttonBox.add(new JButton(cancelAction)); - buttonBox.add(Box.createHorizontalGlue()); - - c.add(label, BorderLayout.NORTH); - c.add(listPanel, BorderLayout.CENTER); - c.add(buttonBox, BorderLayout.SOUTH); - - // bounds and location - setMinimumSize(new Dimension(175, 175)); - setSize(new Dimension(200, 190)); + // set default size and location + setSize(new Dimension(210, 210)); setLocation(TunedUtil.getPreferredLocation(this)); - // default selection - list.setModel(new ArrayListModel(options)); - list.setSelectedIndex(0); - // Shortcut Enter TunedUtil.putActionForKeystroke(list, KeyStroke.getKeyStroke("released ENTER"), selectAction); @@ -89,57 +72,43 @@ public class SelectDialog extends JDialog { } - public void setText(String s) { - label.setText(s); + protected String convertValueToString(Object value) { + return value.toString(); } + public JLabel getHeaderLabel() { + return headerLabel; + } + + + @SuppressWarnings("unchecked") public T getSelectedValue() { - return selectedValue; + if (!valueSelected) + return null; + + return (T) list.getSelectedValue(); } - public void setSelectedValue(T value) { - this.selectedValue = value; - list.setSelectedValue(value, true); + public void close() { + setVisible(false); + dispose(); } private AbstractAction selectAction = new AbstractAction("Select", ResourceManager.getIcon("dialog.continue")) { - @SuppressWarnings("unchecked") public void actionPerformed(ActionEvent e) { - selectedValue = (T) list.getSelectedValue(); - setVisible(false); - dispose(); + valueSelected = true; + close(); } }; private AbstractAction cancelAction = new AbstractAction("Cancel", ResourceManager.getIcon("dialog.cancel")) { public void actionPerformed(ActionEvent e) { - selectedValue = null; - setVisible(false); - dispose(); - } - }; - - - protected String convertValueToString(Object value) { - return value.toString(); - } - - - private class SelectListCellRenderer extends DefaultFancyListCellRenderer { - - public SelectListCellRenderer() { - super(4); - setHighlightingEnabled(false); - } - - - @Override - public void configureListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { - super.configureListCellRendererComponent(list, convertValueToString(value), index, isSelected, cellHasFocus); + valueSelected = false; + close(); } }; @@ -147,8 +116,9 @@ public class SelectDialog extends JDialog { @Override public void mouseClicked(MouseEvent e) { - if (SwingUtilities.isLeftMouseButton(e) && (e.getClickCount() == 2)) + if (SwingUtilities.isLeftMouseButton(e) && (e.getClickCount() == 2)) { selectAction.actionPerformed(null); + } } }; } diff --git a/source/net/sourceforge/filebot/ui/panel/analyze/FileTreePanel.java b/source/net/sourceforge/filebot/ui/panel/analyze/FileTreePanel.java index 831d9e59..55f4ed2f 100644 --- a/source/net/sourceforge/filebot/ui/panel/analyze/FileTreePanel.java +++ b/source/net/sourceforge/filebot/ui/panel/analyze/FileTreePanel.java @@ -2,18 +2,16 @@ package net.sourceforge.filebot.ui.panel.analyze; -import java.awt.BorderLayout; import java.awt.event.ActionEvent; import javax.swing.AbstractAction; import javax.swing.BorderFactory; -import javax.swing.Box; import javax.swing.JButton; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.KeyStroke; -import javax.swing.border.EmptyBorder; +import net.miginfocom.swing.MigLayout; import net.sourceforge.filebot.ResourceManager; import net.sourceforge.filebot.ui.transfer.LoadAction; import net.sourceforge.tuned.ui.LoadingOverlayPane; @@ -26,23 +24,16 @@ class FileTreePanel extends JPanel { public FileTreePanel() { - super(new BorderLayout()); + super(new MigLayout("insets 0, nogrid, fill", "align center")); setBorder(BorderFactory.createTitledBorder("File Tree")); - Box buttons = Box.createHorizontalBox(); - buttons.setBorder(new EmptyBorder(5, 5, 5, 5)); - buttons.add(Box.createGlue()); - buttons.add(new JButton(loadAction)); - buttons.add(Box.createHorizontalStrut(5)); - buttons.add(new JButton(clearAction)); - buttons.add(Box.createGlue()); + add(new LoadingOverlayPane(new JScrollPane(fileTree), ResourceManager.getIcon("loading")), "grow, wrap 1.2mm"); + add(new JButton(loadAction)); + add(new JButton(clearAction), "gap 1.2mm, wrap 1.2mm"); // Shortcut DELETE TunedUtil.putActionForKeystroke(fileTree, KeyStroke.getKeyStroke("pressed DELETE"), removeAction); - - add(new LoadingOverlayPane(new JScrollPane(fileTree), ResourceManager.getIcon("loading")), BorderLayout.CENTER); - add(buttons, BorderLayout.SOUTH); } diff --git a/source/net/sourceforge/filebot/ui/panel/analyze/tools/SplitPanel.java b/source/net/sourceforge/filebot/ui/panel/analyze/tools/SplitPanel.java index 38e549d0..1802649c 100644 --- a/source/net/sourceforge/filebot/ui/panel/analyze/tools/SplitPanel.java +++ b/source/net/sourceforge/filebot/ui/panel/analyze/tools/SplitPanel.java @@ -41,8 +41,6 @@ public class SplitPanel extends ToolPanel implements ChangeListener { public SplitPanel() { super("Split"); - setLayout(new MigLayout("insets 0, nogrid, fill", "align center")); - JScrollPane treeScrollPane = new JScrollPane(tree); treeScrollPane.setBorder(BorderFactory.createEmptyBorder()); @@ -52,6 +50,8 @@ public class SplitPanel extends ToolPanel implements ChangeListener { LoadingOverlayPane loadingOverlayPane = new LoadingOverlayPane(treeScrollPane, ResourceManager.getIcon("loading")); loadingOverlayPane.setBorder(new SeparatorBorder(2, new Color(0, 0, 0, 90), GradientStyle.TOP_TO_BOTTOM, SeparatorBorder.Position.BOTTOM)); + setLayout(new MigLayout("insets 0, nogrid, fill", "align center")); + add(loadingOverlayPane, "grow, wrap"); add(new JLabel("Split every")); diff --git a/source/net/sourceforge/filebot/ui/panel/analyze/tools/ToolPanel.java b/source/net/sourceforge/filebot/ui/panel/analyze/tools/ToolPanel.java index 347f00e5..f43283b4 100644 --- a/source/net/sourceforge/filebot/ui/panel/analyze/tools/ToolPanel.java +++ b/source/net/sourceforge/filebot/ui/panel/analyze/tools/ToolPanel.java @@ -17,6 +17,7 @@ public abstract class ToolPanel extends JPanel { public ToolPanel(String name) { + super(null); this.name = name; } diff --git a/source/net/sourceforge/filebot/ui/panel/analyze/tools/TypePanel.java b/source/net/sourceforge/filebot/ui/panel/analyze/tools/TypePanel.java index 49e49ea9..9e03711e 100644 --- a/source/net/sourceforge/filebot/ui/panel/analyze/tools/TypePanel.java +++ b/source/net/sourceforge/filebot/ui/panel/analyze/tools/TypePanel.java @@ -33,6 +33,7 @@ public class TypePanel extends ToolPanel { public TypePanel() { super("Types"); + setLayout(new BorderLayout()); JScrollPane sp = new JScrollPane(tree); diff --git a/source/net/sourceforge/filebot/ui/panel/episodelist/EpisodeListPanel.java b/source/net/sourceforge/filebot/ui/panel/episodelist/EpisodeListPanel.java index 1475fa06..df37236e 100644 --- a/source/net/sourceforge/filebot/ui/panel/episodelist/EpisodeListPanel.java +++ b/source/net/sourceforge/filebot/ui/panel/episodelist/EpisodeListPanel.java @@ -309,7 +309,7 @@ public class EpisodeListPanel extends FileBotPanel { SelectDialog select = new SelectDialog(window, searchResults); - select.setText("Select a Show:"); + select.getHeaderLabel().setText("Select a Show:"); select.setIconImage(TunedUtil.getImage(episodeList.getIcon())); select.setVisible(true); diff --git a/source/net/sourceforge/filebot/ui/panel/rename/HighlightListCellRenderer.java b/source/net/sourceforge/filebot/ui/panel/rename/HighlightListCellRenderer.java index d8467c19..904508a7 100644 --- a/source/net/sourceforge/filebot/ui/panel/rename/HighlightListCellRenderer.java +++ b/source/net/sourceforge/filebot/ui/panel/rename/HighlightListCellRenderer.java @@ -12,6 +12,7 @@ import java.util.regex.Pattern; import javax.swing.JList; import javax.swing.JTextField; +import javax.swing.border.EmptyBorder; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; import javax.swing.text.BadLocationException; @@ -19,6 +20,7 @@ import javax.swing.text.Highlighter; import javax.swing.text.JTextComponent; import net.sourceforge.tuned.ui.AbstractFancyListCellRenderer; +import net.sourceforge.tuned.ui.TunedUtil; public class HighlightListCellRenderer extends AbstractFancyListCellRenderer { @@ -30,13 +32,17 @@ public class HighlightListCellRenderer extends AbstractFancyListCellRenderer { public HighlightListCellRenderer(Pattern pattern, Highlighter.HighlightPainter highlightPainter, int padding) { - super(new Insets(padding, padding, padding, padding)); + super(new Insets(0, 0, 0, 0)); this.pattern = pattern; this.highlightPainter = highlightPainter; - textComponent.setBorder(null); - textComponent.setOpaque(false); + // pad the cell from inside the text component, + // so the HighlightPainter may paint in this space as well + textComponent.setBorder(new EmptyBorder(padding, padding, padding, padding)); + + // make text component transparent, should work for all LAFs (setOpaque(false) may not, e.g. Nimbus) + textComponent.setBackground(TunedUtil.TRANSLUCENT); this.add(textComponent, BorderLayout.WEST); @@ -83,7 +89,7 @@ public class HighlightListCellRenderer extends AbstractFancyListCellRenderer { @Override public void changedUpdate(DocumentEvent e) { - + updateHighlighter(); } diff --git a/source/net/sourceforge/filebot/ui/panel/rename/ValidateNamesDialog.java b/source/net/sourceforge/filebot/ui/panel/rename/ValidateNamesDialog.java index 692074fa..a9e5f7c9 100644 --- a/source/net/sourceforge/filebot/ui/panel/rename/ValidateNamesDialog.java +++ b/source/net/sourceforge/filebot/ui/panel/rename/ValidateNamesDialog.java @@ -3,29 +3,24 @@ package net.sourceforge.filebot.ui.panel.rename; import java.awt.AlphaComposite; -import java.awt.BorderLayout; import java.awt.Color; -import java.awt.Dimension; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Window; import java.awt.event.ActionEvent; -import java.util.List; +import java.util.Collection; import javax.swing.AbstractAction; import javax.swing.Action; -import javax.swing.BorderFactory; -import javax.swing.Box; import javax.swing.JButton; import javax.swing.JComponent; import javax.swing.JDialog; import javax.swing.JLabel; import javax.swing.JList; -import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.KeyStroke; -import javax.swing.border.EmptyBorder; +import net.miginfocom.swing.MigLayout; import net.sourceforge.filebot.FileBotUtil; import net.sourceforge.filebot.ResourceManager; import net.sourceforge.filebot.ui.panel.rename.entry.ListEntry; @@ -35,7 +30,7 @@ import net.sourceforge.tuned.ui.TunedUtil; public class ValidateNamesDialog extends JDialog { - private final List entries; + private final Collection entries; private boolean cancelled = true; @@ -44,7 +39,7 @@ public class ValidateNamesDialog extends JDialog { private final CancelAction cancelAction = new CancelAction(); - public ValidateNamesDialog(Window owner, List entries) { + public ValidateNamesDialog(Window owner, Collection entries) { super(owner, "Invalid Names", ModalityType.DOCUMENT_MODAL); this.entries = entries; @@ -60,34 +55,16 @@ public class ValidateNamesDialog extends JDialog { JComponent c = (JComponent) getContentPane(); - int border = 5; - c.setBorder(BorderFactory.createEmptyBorder(border, border, border, border)); - c.setLayout(new BorderLayout(border, border)); + c.setLayout(new MigLayout("insets dialog, nogrid, fill")); - JPanel listPanel = new JPanel(new BorderLayout()); + c.add(label, "wrap"); + c.add(new JScrollPane(list), "grow, wrap 2mm"); - listPanel.add(new JScrollPane(list), BorderLayout.CENTER); + c.add(new JButton(validateAction), "align center"); + c.add(new AlphaButton(continueAction), "gap related"); + c.add(new JButton(cancelAction), "gap 12mm"); - Box buttonBox = Box.createHorizontalBox(); - buttonBox.setBorder(new EmptyBorder(5, 5, 5, 5)); - - buttonBox.add(Box.createHorizontalGlue()); - buttonBox.add(new JButton(validateAction)); - buttonBox.add(Box.createHorizontalStrut(10)); - buttonBox.add(new AlphaButton(continueAction)); - - buttonBox.add(Box.createHorizontalStrut(40)); - buttonBox.add(new JButton(cancelAction)); - buttonBox.add(Box.createHorizontalGlue()); - - c.add(label, BorderLayout.NORTH); - c.add(listPanel, BorderLayout.CENTER); - c.add(buttonBox, BorderLayout.SOUTH); - - setLocation(TunedUtil.getPreferredLocation(this)); - - setPreferredSize(new Dimension(365, 280)); - pack(); + setSize(365, 280); TunedUtil.putActionForKeystroke(c, KeyStroke.getKeyStroke("released ESCAPE"), cancelAction); } @@ -126,6 +103,7 @@ public class ValidateNamesDialog extends JDialog { continueAction.putValue(SMALL_ICON, getValue(SMALL_ICON)); continueAction.putValue(ContinueAction.ALPHA, 1.0f); + // render list entries again to display changes repaint(); } }; diff --git a/source/net/sourceforge/filebot/ui/panel/sfv/SfvPanel.java b/source/net/sourceforge/filebot/ui/panel/sfv/SfvPanel.java index 68169783..e1968d2d 100644 --- a/source/net/sourceforge/filebot/ui/panel/sfv/SfvPanel.java +++ b/source/net/sourceforge/filebot/ui/panel/sfv/SfvPanel.java @@ -40,7 +40,7 @@ public class SfvPanel extends FileBotPanel { setLayout(new MigLayout("insets 0, nogrid, fill", "", "align bottom")); - add(new JScrollPane(sfvTable), "grow, gap bottom 5px, wrap"); + add(new JScrollPane(sfvTable), "grow, wrap 10px"); add(new JButton(loadAction), "gap 15px, gap bottom 4px"); add(new JButton(saveAction), "gap rel, gap bottom 4px"); @@ -145,7 +145,7 @@ public class SfvPanel extends FileBotPanel { } }; - selectDialog.setText("Select checksum column:"); + selectDialog.getHeaderLabel().setText("Select checksum column:"); selectDialog.setVisible(true); this.selectedColumn = selectDialog.getSelectedValue(); diff --git a/source/net/sourceforge/filebot/ui/panel/subtitle/SubtitlePanel.java b/source/net/sourceforge/filebot/ui/panel/subtitle/SubtitlePanel.java index 6ab319c7..1fdca5b6 100644 --- a/source/net/sourceforge/filebot/ui/panel/subtitle/SubtitlePanel.java +++ b/source/net/sourceforge/filebot/ui/panel/subtitle/SubtitlePanel.java @@ -98,7 +98,7 @@ public class SubtitlePanel extends AbstractSearchPanel selectDialog) throws Exception { super.configureSelectDialog(selectDialog); - selectDialog.setText("Select a Show / Movie:"); + selectDialog.getHeaderLabel().setText("Select a Show / Movie:"); } } diff --git a/source/net/sourceforge/tuned/ui/TunedUtil.java b/source/net/sourceforge/tuned/ui/TunedUtil.java index 01582cd0..ea7ce264 100644 --- a/source/net/sourceforge/tuned/ui/TunedUtil.java +++ b/source/net/sourceforge/tuned/ui/TunedUtil.java @@ -2,6 +2,7 @@ package net.sourceforge.tuned.ui; +import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics2D; import java.awt.Image; @@ -23,6 +24,9 @@ import javax.swing.Timer; public final class TunedUtil { + public static final Color TRANSLUCENT = new Color(255, 255, 255, 0); + + public static void checkEventDispatchThread() { if (!SwingUtilities.isEventDispatchThread()) { throw new IllegalStateException("Method must be accessed from the Swing Event Dispatch Thread, but was called on Thread \"" + Thread.currentThread().getName() + "\"");