From bc0e354a7a61c361478c957ce7ffdde7d4f22e33 Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Sun, 19 Oct 2008 18:51:45 +0000 Subject: [PATCH] * use MigLayout in SFV Panel * use MigLayout in List Panel --- source/Main.java | 1 + .../sourceforge/filebot/ui/FileBotPanel.java | 4 +- .../ui/panel/analyze/tools/ToolPanel.java | 4 +- .../filebot/ui/panel/list/ListPanel.java | 61 ++++++------------- .../panel/sfv/ChecksumComputationService.java | 5 +- .../filebot/ui/panel/sfv/SfvPanel.java | 27 +++----- .../ui/panel/sfv/TotalProgressPanel.java | 6 +- .../ui/AbstractFancyListCellRenderer.java | 4 +- .../tuned/ui/LoadingOverlayPane.java | 3 +- .../tuned/ui/ProgressIndicator.java | 4 +- 10 files changed, 37 insertions(+), 82 deletions(-) diff --git a/source/Main.java b/source/Main.java index 688adcb3..f8b2aa3d 100644 --- a/source/Main.java +++ b/source/Main.java @@ -32,6 +32,7 @@ public class Main { } try { + // UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel"); UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.SEVERE, e.toString(), e); diff --git a/source/net/sourceforge/filebot/ui/FileBotPanel.java b/source/net/sourceforge/filebot/ui/FileBotPanel.java index 9d33895a..850ea478 100644 --- a/source/net/sourceforge/filebot/ui/FileBotPanel.java +++ b/source/net/sourceforge/filebot/ui/FileBotPanel.java @@ -2,8 +2,6 @@ package net.sourceforge.filebot.ui; -import java.awt.BorderLayout; - import javax.swing.Icon; import javax.swing.JPanel; @@ -15,7 +13,6 @@ public class FileBotPanel extends JPanel { public FileBotPanel(String title, Icon icon) { - super(new BorderLayout(10, 10)); this.name = title; this.icon = icon; } @@ -29,4 +26,5 @@ public class FileBotPanel extends JPanel { public String getPanelName() { return name; } + } 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 232bbbaa..347f00e5 100644 --- a/source/net/sourceforge/filebot/ui/panel/analyze/tools/ToolPanel.java +++ b/source/net/sourceforge/filebot/ui/panel/analyze/tools/ToolPanel.java @@ -5,13 +5,13 @@ package net.sourceforge.filebot.ui.panel.analyze.tools; import java.io.File; import java.util.Collection; -import javax.swing.JComponent; +import javax.swing.JPanel; import javax.swing.tree.DefaultMutableTreeNode; import net.sourceforge.tuned.FileUtil; -public abstract class ToolPanel extends JComponent { +public abstract class ToolPanel extends JPanel { private final String name; diff --git a/source/net/sourceforge/filebot/ui/panel/list/ListPanel.java b/source/net/sourceforge/filebot/ui/panel/list/ListPanel.java index d4d45411..7821ebcf 100644 --- a/source/net/sourceforge/filebot/ui/panel/list/ListPanel.java +++ b/source/net/sourceforge/filebot/ui/panel/list/ListPanel.java @@ -3,7 +3,6 @@ package net.sourceforge.filebot.ui.panel.list; import java.awt.BorderLayout; -import java.awt.Dimension; import java.awt.event.ActionEvent; import java.text.NumberFormat; import java.util.ArrayList; @@ -11,16 +10,15 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import javax.swing.AbstractAction; -import javax.swing.Box; import javax.swing.JButton; -import javax.swing.JComponent; import javax.swing.JLabel; +import javax.swing.JPanel; import javax.swing.JSpinner; import javax.swing.JTextField; import javax.swing.KeyStroke; import javax.swing.SpinnerNumberModel; -import javax.swing.border.EmptyBorder; +import net.miginfocom.swing.MigLayout; import net.sourceforge.filebot.ResourceManager; import net.sourceforge.filebot.ui.FileBotList; import net.sourceforge.filebot.ui.FileBotListExportHandler; @@ -54,61 +52,36 @@ public class ListPanel extends FileBotPanel { list.getRemoveAction().setEnabled(true); - Box buttons = Box.createHorizontalBox(); - buttons.setBorder(new EmptyBorder(5, 5, 5, 5)); - buttons.add(Box.createHorizontalGlue()); - - buttons.add(new JButton(new LoadAction(list.getTransferablePolicy()))); - buttons.add(Box.createHorizontalStrut(5)); - buttons.add(new JButton(new SaveAction(list.getExportHandler()))); - buttons.add(Box.createHorizontalGlue()); - - list.add(buttons, BorderLayout.SOUTH); - JSpinner fromSpinner = new JSpinner(fromSpinnerModel); JSpinner toSpinner = new JSpinner(toSpinnerModel); fromSpinner.setEditor(new JSpinner.NumberEditor(fromSpinner, "#")); toSpinner.setEditor(new JSpinner.NumberEditor(toSpinner, "#")); - Dimension spinnerDimension = new Dimension(50, textField.getPreferredSize().height); - fromSpinner.setPreferredSize(spinnerDimension); - toSpinner.setPreferredSize(spinnerDimension); + setLayout(new MigLayout("nogrid, flowx, insets dialog, fill", "align center")); - Box spinners = Box.createHorizontalBox(); - spinners.setBorder(new EmptyBorder(5, 5, 5, 5)); - spinners.add(Box.createHorizontalGlue()); + add(new JLabel("Pattern:"), "gapbefore indent"); + add(textField, "gap related, wmin 2cm"); + add(new JLabel("From:"), "gap 5mm"); + add(fromSpinner, "gap related, wmax 12mm, sizegroup spinner"); + add(new JLabel("To:"), "gap 5mm"); + add(toSpinner, "gap related, wmax 12mm, sizegroup spinner"); + add(new JButton(createAction), "gap 7mm, gapafter indent, wrap paragraph"); - spinners.add(createLabeledComponent("Pattern:", textField)); - spinners.add(Box.createHorizontalStrut(15)); - spinners.add(createLabeledComponent("From:", fromSpinner)); - spinners.add(Box.createHorizontalStrut(10)); - spinners.add(createLabeledComponent("To:", toSpinner)); - spinners.add(Box.createHorizontalStrut(15)); - spinners.add(new JButton(createAction)); - spinners.add(Box.createHorizontalGlue()); + add(list, "grow"); - add(spinners, BorderLayout.NORTH); - add(list, BorderLayout.CENTER); + // panel with buttons that will be added inside the list component + JPanel buttonPanel = new JPanel(new MigLayout("insets 5px, nogrid, flowx, fill", "align center")); + buttonPanel.add(new JButton(new LoadAction(list.getTransferablePolicy()))); + buttonPanel.add(new JButton(new SaveAction(list.getExportHandler())), "gap unrelated"); + + list.add(buttonPanel, BorderLayout.SOUTH); TunedUtil.putActionForKeystroke(this, KeyStroke.getKeyStroke("ENTER"), createAction); MessageBus.getDefault().addMessageHandler(getPanelName(), new FileTransferableMessageHandler(this, list.getTransferablePolicy())); } - - private JComponent createLabeledComponent(String label, JComponent component) { - Box box = Box.createHorizontalBox(); - box.setBorder(new EmptyBorder(5, 5, 5, 5)); - box.add(new JLabel(label)); - box.add(Box.createHorizontalStrut(6)); - box.add(component); - - box.setMaximumSize(box.getPreferredSize()); - - return box; - } - private AbstractAction createAction = new AbstractAction("Create") { public void actionPerformed(ActionEvent e) { diff --git a/source/net/sourceforge/filebot/ui/panel/sfv/ChecksumComputationService.java b/source/net/sourceforge/filebot/ui/panel/sfv/ChecksumComputationService.java index dd7b35e2..6f30f9ba 100644 --- a/source/net/sourceforge/filebot/ui/panel/sfv/ChecksumComputationService.java +++ b/source/net/sourceforge/filebot/ui/panel/sfv/ChecksumComputationService.java @@ -127,11 +127,10 @@ public class ChecksumComputationService { private void adjustPoolSize() { - // for only a few files, use one thread + // for a few files, use one thread // for lots of files, use multiple threads // e.g 50 files ~ 1 thread, 1000 files ~ 3 threads, 40000 files ~ 5 threads - - int preferredPoolSize = (int) Math.log10(Math.max(getQueue().size() / 10, MINIMUM_POOL_SIZE)); + int preferredPoolSize = (int) Math.max(Math.log10(getQueue().size() / 10), MINIMUM_POOL_SIZE); if (getCorePoolSize() != preferredPoolSize) { setCorePoolSize(preferredPoolSize); diff --git a/source/net/sourceforge/filebot/ui/panel/sfv/SfvPanel.java b/source/net/sourceforge/filebot/ui/panel/sfv/SfvPanel.java index 91e6b4b8..7c86bfab 100644 --- a/source/net/sourceforge/filebot/ui/panel/sfv/SfvPanel.java +++ b/source/net/sourceforge/filebot/ui/panel/sfv/SfvPanel.java @@ -2,7 +2,6 @@ package net.sourceforge.filebot.ui.panel.sfv; -import java.awt.BorderLayout; import java.awt.event.ActionEvent; import java.io.File; import java.io.IOException; @@ -10,14 +9,12 @@ import java.util.List; 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.SwingUtilities; -import javax.swing.border.EmptyBorder; +import net.miginfocom.swing.MigLayout; import net.sourceforge.filebot.ResourceManager; import net.sourceforge.filebot.ui.FileBotPanel; import net.sourceforge.filebot.ui.FileTransferableMessageHandler; @@ -41,25 +38,15 @@ public class SfvPanel extends FileBotPanel { setBorder(BorderFactory.createTitledBorder("SFV")); - JPanel southPanel = new JPanel(new BorderLayout()); + setLayout(new MigLayout("nogrid, flowx, insets 0, fill", "", "align bottom")); - JPanel southEastPanel = new JPanel(new BorderLayout()); + add(new JScrollPane(sfvTable), "grow, gap bottom 5, wrap"); - Box buttonBox = Box.createHorizontalBox(); - buttonBox.setBorder(new EmptyBorder(5, 15, 5, 15)); + add(new JButton(loadAction), "gap right 5, gap bottom 4, gap left 15"); + add(new JButton(saveAction), "gap right 5, gap bottom 4"); + add(new JButton(clearAction), "gap right 5, gap bottom 4"); - buttonBox.add(new JButton(loadAction)); - buttonBox.add(Box.createHorizontalStrut(5)); - buttonBox.add(new JButton(saveAction)); - buttonBox.add(Box.createHorizontalStrut(5)); - buttonBox.add(new JButton(clearAction)); - southEastPanel.add(buttonBox, BorderLayout.SOUTH); - - southPanel.add(southEastPanel, BorderLayout.WEST); - southPanel.add(totalProgressPanel, BorderLayout.EAST); - - add(new JScrollPane(sfvTable), BorderLayout.CENTER); - add(southPanel, BorderLayout.SOUTH); + add(totalProgressPanel, "gap left push, gap bottom 2, gap right 7, hidemode 3"); // Shortcut DELETE TunedUtil.putActionForKeystroke(this, KeyStroke.getKeyStroke("pressed DELETE"), removeAction); diff --git a/source/net/sourceforge/filebot/ui/panel/sfv/TotalProgressPanel.java b/source/net/sourceforge/filebot/ui/panel/sfv/TotalProgressPanel.java index 7bf78e4f..d4ffc9d4 100644 --- a/source/net/sourceforge/filebot/ui/panel/sfv/TotalProgressPanel.java +++ b/source/net/sourceforge/filebot/ui/panel/sfv/TotalProgressPanel.java @@ -9,7 +9,6 @@ import javax.swing.BorderFactory; import javax.swing.Box; import javax.swing.BoxLayout; import javax.swing.JProgressBar; -import javax.swing.border.Border; import net.sourceforge.tuned.ui.TunedUtil; @@ -35,10 +34,7 @@ class TotalProgressPanel extends Box { progressBar.setBorderPainted(false); progressBar.setString(""); - Border margin = BorderFactory.createEmptyBorder(5, 5, 4, 8); - Border title = BorderFactory.createTitledBorder("Total Progress"); - - setBorder(BorderFactory.createCompoundBorder(margin, title)); + setBorder(BorderFactory.createTitledBorder("Total Progress")); add(progressBar); diff --git a/source/net/sourceforge/tuned/ui/AbstractFancyListCellRenderer.java b/source/net/sourceforge/tuned/ui/AbstractFancyListCellRenderer.java index dda9cb7c..8ca2298c 100644 --- a/source/net/sourceforge/tuned/ui/AbstractFancyListCellRenderer.java +++ b/source/net/sourceforge/tuned/ui/AbstractFancyListCellRenderer.java @@ -11,8 +11,8 @@ import java.awt.Insets; import java.awt.Rectangle; import java.awt.geom.Rectangle2D; -import javax.swing.JComponent; import javax.swing.JList; +import javax.swing.JPanel; import javax.swing.ListCellRenderer; import javax.swing.border.Border; import javax.swing.border.CompoundBorder; @@ -20,7 +20,7 @@ import javax.swing.border.EmptyBorder; import javax.swing.border.LineBorder; -public abstract class AbstractFancyListCellRenderer extends JComponent implements ListCellRenderer { +public abstract class AbstractFancyListCellRenderer extends JPanel implements ListCellRenderer { private Color gradientBeginColor; private Color gradientEndColor; diff --git a/source/net/sourceforge/tuned/ui/LoadingOverlayPane.java b/source/net/sourceforge/tuned/ui/LoadingOverlayPane.java index dd19d8ed..e1e1d05c 100644 --- a/source/net/sourceforge/tuned/ui/LoadingOverlayPane.java +++ b/source/net/sourceforge/tuned/ui/LoadingOverlayPane.java @@ -10,11 +10,12 @@ import javax.swing.BorderFactory; import javax.swing.Icon; import javax.swing.JComponent; import javax.swing.JLabel; +import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.OverlayLayout; -public class LoadingOverlayPane extends JComponent { +public class LoadingOverlayPane extends JPanel { public static final String LOADING_PROPERTY = "loading"; diff --git a/source/net/sourceforge/tuned/ui/ProgressIndicator.java b/source/net/sourceforge/tuned/ui/ProgressIndicator.java index 48ef61de..b5ef9ae2 100644 --- a/source/net/sourceforge/tuned/ui/ProgressIndicator.java +++ b/source/net/sourceforge/tuned/ui/ProgressIndicator.java @@ -17,10 +17,10 @@ import java.awt.geom.Rectangle2D; import java.util.Calendar; import javax.swing.BoundedRangeModel; -import javax.swing.JComponent; +import javax.swing.JPanel; -public class ProgressIndicator extends JComponent { +public class ProgressIndicator extends JPanel { private BoundedRangeModel model = null;