* use MigLayout in SFV Panel

* use MigLayout in List Panel
This commit is contained in:
Reinhard Pointner 2008-10-19 18:51:45 +00:00
parent 792c729d54
commit bc0e354a7a
10 changed files with 37 additions and 82 deletions

View File

@ -32,6 +32,7 @@ public class Main {
} }
try { try {
// UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception e) { } catch (Exception e) {
Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.SEVERE, e.toString(), e); Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.SEVERE, e.toString(), e);

View File

@ -2,8 +2,6 @@
package net.sourceforge.filebot.ui; package net.sourceforge.filebot.ui;
import java.awt.BorderLayout;
import javax.swing.Icon; import javax.swing.Icon;
import javax.swing.JPanel; import javax.swing.JPanel;
@ -15,7 +13,6 @@ public class FileBotPanel extends JPanel {
public FileBotPanel(String title, Icon icon) { public FileBotPanel(String title, Icon icon) {
super(new BorderLayout(10, 10));
this.name = title; this.name = title;
this.icon = icon; this.icon = icon;
} }
@ -29,4 +26,5 @@ public class FileBotPanel extends JPanel {
public String getPanelName() { public String getPanelName() {
return name; return name;
} }
} }

View File

@ -5,13 +5,13 @@ package net.sourceforge.filebot.ui.panel.analyze.tools;
import java.io.File; import java.io.File;
import java.util.Collection; import java.util.Collection;
import javax.swing.JComponent; import javax.swing.JPanel;
import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.DefaultMutableTreeNode;
import net.sourceforge.tuned.FileUtil; import net.sourceforge.tuned.FileUtil;
public abstract class ToolPanel extends JComponent { public abstract class ToolPanel extends JPanel {
private final String name; private final String name;

View File

@ -3,7 +3,6 @@ package net.sourceforge.filebot.ui.panel.list;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.text.NumberFormat; import java.text.NumberFormat;
import java.util.ArrayList; import java.util.ArrayList;
@ -11,16 +10,15 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import javax.swing.AbstractAction; import javax.swing.AbstractAction;
import javax.swing.Box;
import javax.swing.JButton; import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JLabel; import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JSpinner; import javax.swing.JSpinner;
import javax.swing.JTextField; import javax.swing.JTextField;
import javax.swing.KeyStroke; import javax.swing.KeyStroke;
import javax.swing.SpinnerNumberModel; import javax.swing.SpinnerNumberModel;
import javax.swing.border.EmptyBorder;
import net.miginfocom.swing.MigLayout;
import net.sourceforge.filebot.ResourceManager; import net.sourceforge.filebot.ResourceManager;
import net.sourceforge.filebot.ui.FileBotList; import net.sourceforge.filebot.ui.FileBotList;
import net.sourceforge.filebot.ui.FileBotListExportHandler; import net.sourceforge.filebot.ui.FileBotListExportHandler;
@ -54,61 +52,36 @@ public class ListPanel extends FileBotPanel {
list.getRemoveAction().setEnabled(true); 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 fromSpinner = new JSpinner(fromSpinnerModel);
JSpinner toSpinner = new JSpinner(toSpinnerModel); JSpinner toSpinner = new JSpinner(toSpinnerModel);
fromSpinner.setEditor(new JSpinner.NumberEditor(fromSpinner, "#")); fromSpinner.setEditor(new JSpinner.NumberEditor(fromSpinner, "#"));
toSpinner.setEditor(new JSpinner.NumberEditor(toSpinner, "#")); toSpinner.setEditor(new JSpinner.NumberEditor(toSpinner, "#"));
Dimension spinnerDimension = new Dimension(50, textField.getPreferredSize().height); setLayout(new MigLayout("nogrid, flowx, insets dialog, fill", "align center"));
fromSpinner.setPreferredSize(spinnerDimension);
toSpinner.setPreferredSize(spinnerDimension);
Box spinners = Box.createHorizontalBox(); add(new JLabel("Pattern:"), "gapbefore indent");
spinners.setBorder(new EmptyBorder(5, 5, 5, 5)); add(textField, "gap related, wmin 2cm");
spinners.add(Box.createHorizontalGlue()); 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)); add(list, "grow");
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(spinners, BorderLayout.NORTH); // panel with buttons that will be added inside the list component
add(list, BorderLayout.CENTER); 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); TunedUtil.putActionForKeystroke(this, KeyStroke.getKeyStroke("ENTER"), createAction);
MessageBus.getDefault().addMessageHandler(getPanelName(), new FileTransferableMessageHandler(this, list.getTransferablePolicy())); 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") { private AbstractAction createAction = new AbstractAction("Create") {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {

View File

@ -127,11 +127,10 @@ public class ChecksumComputationService {
private void adjustPoolSize() { 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 // for lots of files, use multiple threads
// e.g 50 files ~ 1 thread, 1000 files ~ 3 threads, 40000 files ~ 5 threads // e.g 50 files ~ 1 thread, 1000 files ~ 3 threads, 40000 files ~ 5 threads
int preferredPoolSize = (int) Math.max(Math.log10(getQueue().size() / 10), MINIMUM_POOL_SIZE);
int preferredPoolSize = (int) Math.log10(Math.max(getQueue().size() / 10, MINIMUM_POOL_SIZE));
if (getCorePoolSize() != preferredPoolSize) { if (getCorePoolSize() != preferredPoolSize) {
setCorePoolSize(preferredPoolSize); setCorePoolSize(preferredPoolSize);

View File

@ -2,7 +2,6 @@
package net.sourceforge.filebot.ui.panel.sfv; package net.sourceforge.filebot.ui.panel.sfv;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
@ -10,14 +9,12 @@ import java.util.List;
import javax.swing.AbstractAction; import javax.swing.AbstractAction;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.JButton; import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JScrollPane; import javax.swing.JScrollPane;
import javax.swing.KeyStroke; import javax.swing.KeyStroke;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
import javax.swing.border.EmptyBorder;
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;
import net.sourceforge.filebot.ui.FileTransferableMessageHandler; import net.sourceforge.filebot.ui.FileTransferableMessageHandler;
@ -41,25 +38,15 @@ public class SfvPanel extends FileBotPanel {
setBorder(BorderFactory.createTitledBorder("SFV")); 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(); add(new JButton(loadAction), "gap right 5, gap bottom 4, gap left 15");
buttonBox.setBorder(new EmptyBorder(5, 15, 5, 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)); add(totalProgressPanel, "gap left push, gap bottom 2, gap right 7, hidemode 3");
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);
// Shortcut DELETE // Shortcut DELETE
TunedUtil.putActionForKeystroke(this, KeyStroke.getKeyStroke("pressed DELETE"), removeAction); TunedUtil.putActionForKeystroke(this, KeyStroke.getKeyStroke("pressed DELETE"), removeAction);

View File

@ -9,7 +9,6 @@ import javax.swing.BorderFactory;
import javax.swing.Box; import javax.swing.Box;
import javax.swing.BoxLayout; import javax.swing.BoxLayout;
import javax.swing.JProgressBar; import javax.swing.JProgressBar;
import javax.swing.border.Border;
import net.sourceforge.tuned.ui.TunedUtil; import net.sourceforge.tuned.ui.TunedUtil;
@ -35,10 +34,7 @@ class TotalProgressPanel extends Box {
progressBar.setBorderPainted(false); progressBar.setBorderPainted(false);
progressBar.setString(""); progressBar.setString("");
Border margin = BorderFactory.createEmptyBorder(5, 5, 4, 8); setBorder(BorderFactory.createTitledBorder("Total Progress"));
Border title = BorderFactory.createTitledBorder("Total Progress");
setBorder(BorderFactory.createCompoundBorder(margin, title));
add(progressBar); add(progressBar);

View File

@ -11,8 +11,8 @@ import java.awt.Insets;
import java.awt.Rectangle; import java.awt.Rectangle;
import java.awt.geom.Rectangle2D; import java.awt.geom.Rectangle2D;
import javax.swing.JComponent;
import javax.swing.JList; import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.ListCellRenderer; import javax.swing.ListCellRenderer;
import javax.swing.border.Border; import javax.swing.border.Border;
import javax.swing.border.CompoundBorder; import javax.swing.border.CompoundBorder;
@ -20,7 +20,7 @@ import javax.swing.border.EmptyBorder;
import javax.swing.border.LineBorder; 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 gradientBeginColor;
private Color gradientEndColor; private Color gradientEndColor;

View File

@ -10,11 +10,12 @@ import javax.swing.BorderFactory;
import javax.swing.Icon; import javax.swing.Icon;
import javax.swing.JComponent; import javax.swing.JComponent;
import javax.swing.JLabel; import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane; import javax.swing.JScrollPane;
import javax.swing.OverlayLayout; import javax.swing.OverlayLayout;
public class LoadingOverlayPane extends JComponent { public class LoadingOverlayPane extends JPanel {
public static final String LOADING_PROPERTY = "loading"; public static final String LOADING_PROPERTY = "loading";

View File

@ -17,10 +17,10 @@ import java.awt.geom.Rectangle2D;
import java.util.Calendar; import java.util.Calendar;
import javax.swing.BoundedRangeModel; 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; private BoundedRangeModel model = null;