From 4afc701ff7b1f67068364a73f0a6c6172bafae99 Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Sun, 5 Apr 2009 21:03:40 +0000 Subject: [PATCH] * use system laf on Windows and Mac, use Nimbus on all the others (Linux, *BSD, ...) * visual imrovements under Nimbus LAF --- source/net/sourceforge/filebot/Main.java | 18 ++--- .../format/EpisodeFormatBindingBean.java | 22 ++++-- .../episodelist/SeasonSpinnerEditor.java | 70 +++++++++++-------- .../filebot/ui/panel/list/ListPanel.java | 4 +- .../tuned/ui/FancyTreeCellRenderer.java | 8 +-- 5 files changed, 75 insertions(+), 47 deletions(-) diff --git a/source/net/sourceforge/filebot/Main.java b/source/net/sourceforge/filebot/Main.java index ae0d917d..aae35214 100644 --- a/source/net/sourceforge/filebot/Main.java +++ b/source/net/sourceforge/filebot/Main.java @@ -21,6 +21,8 @@ import net.sourceforge.filebot.ui.panel.sfv.SfvPanelBuilder; import org.kohsuke.args4j.CmdLineException; import org.kohsuke.args4j.CmdLineParser; +import com.sun.jna.Platform; + public class Main { @@ -47,15 +49,15 @@ public class Main { initializeSettings(); try { - // UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel"); - // UIManager.setLookAndFeel("a03.swing.plaf.A03LookAndFeel"); - // UIManager.setLookAndFeel("org.jvnet.substance.skin.SubstanceBusinessBlueSteelLookAndFeel"); - // UIManager.setLookAndFeel("org.jvnet.substance.skin.SubstanceNebulaBrickWallLookAndFeel"); - // UIManager.setLookAndFeel("org.jvnet.substance.skin.SubstanceSaharaLookAndFeel"); - - UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); + if (Platform.isWindows() || Platform.isMac()) { + // use native laf of windows and mac + UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); + } else { + // use nimubs laf on linux, bsd, ... + UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel"); + } } catch (Exception e) { - Logger.getLogger(Main.class.getName()).log(Level.SEVERE, e.toString(), e); + Logger.getLogger(Main.class.getName()).log(Level.WARNING, e.toString(), e); } SwingUtilities.invokeLater(new Runnable() { diff --git a/source/net/sourceforge/filebot/format/EpisodeFormatBindingBean.java b/source/net/sourceforge/filebot/format/EpisodeFormatBindingBean.java index 8857479f..a4c93580 100644 --- a/source/net/sourceforge/filebot/format/EpisodeFormatBindingBean.java +++ b/source/net/sourceforge/filebot/format/EpisodeFormatBindingBean.java @@ -120,8 +120,14 @@ public class EpisodeFormatBindingBean { return null; } - + + @Define("general") + public SortedMap getGeneralMediaInfo() { + return getMediaInfo().snapshot(StreamKind.General, 0); + } + + @Define("video") public SortedMap getVideoInfo() { return getMediaInfo().snapshot(StreamKind.Video, 0); @@ -133,12 +139,18 @@ public class EpisodeFormatBindingBean { return getMediaInfo().snapshot(StreamKind.Audio, 0); } - - @Define("general") - public SortedMap getGeneralMediaInfo() { - return getMediaInfo().snapshot(StreamKind.General, 0); + + @Define("text") + public SortedMap getTextInfo() { + return getMediaInfo().snapshot(StreamKind.Text, 0); } + + @Define("image") + public SortedMap getImageInfo() { + return getMediaInfo().snapshot(StreamKind.Image, 0); + } + public synchronized MediaInfo getMediaInfo() { if (mediaFile == null) { diff --git a/source/net/sourceforge/filebot/ui/panel/episodelist/SeasonSpinnerEditor.java b/source/net/sourceforge/filebot/ui/panel/episodelist/SeasonSpinnerEditor.java index a48c00f2..5c8bcc4b 100644 --- a/source/net/sourceforge/filebot/ui/panel/episodelist/SeasonSpinnerEditor.java +++ b/source/net/sourceforge/filebot/ui/panel/episodelist/SeasonSpinnerEditor.java @@ -1,43 +1,57 @@ - package net.sourceforge.filebot.ui.panel.episodelist; - import static net.sourceforge.filebot.ui.panel.episodelist.SeasonSpinnerModel.ALL_SEASONS; -import java.awt.Color; +import java.text.ParseException; +import java.util.regex.Matcher; +import java.util.regex.Pattern; -import javax.swing.BorderFactory; -import javax.swing.JLabel; import javax.swing.JSpinner; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; +import javax.swing.SwingConstants; +import javax.swing.JSpinner.DefaultEditor; +import javax.swing.text.DefaultFormatter; +import javax.swing.text.DefaultFormatterFactory; +class SeasonSpinnerEditor extends DefaultEditor { -class SeasonSpinnerEditor extends JLabel implements ChangeListener { - public SeasonSpinnerEditor(JSpinner spinner) { - setHorizontalAlignment(RIGHT); + super(spinner); - spinner.addChangeListener(this); - setValueFromSpinner(spinner); - setBorder(BorderFactory.createEmptyBorder(1, 3, 1, 3)); - - setBackground(Color.WHITE); - setOpaque(true); - } - + getTextField().setFormatterFactory(new DefaultFormatterFactory(new DefaultFormatter() { - public void stateChanged(ChangeEvent e) { - setValueFromSpinner((JSpinner) e.getSource()); - } - + @Override + public Object stringToValue(String string) throws ParseException { + if ("All Seasons".equals(string)) { + return ALL_SEASONS; + } - private void setValueFromSpinner(JSpinner spinner) { - int season = ((SeasonSpinnerModel) spinner.getModel()).getSeason(); + Matcher matcher = Pattern.compile("Season (\\d+)").matcher(string); + + if (matcher.matches()) { + return Integer.valueOf(matcher.group(1)); + } + + // negative season number + throw new ParseException("Illegal season number", 0); + } + + @Override + public String valueToString(Object value) throws ParseException { + int season = ((Number) value).intValue(); + + if (season == ALL_SEASONS) + return "All Seasons"; + else if (season >= 1) + return String.format("Season %d", season); + + // negative season number + throw new ParseException("Illegal season number", 0); + } + + })); - if (season == ALL_SEASONS) - setText("All Seasons"); - else - setText(String.format("Season %d", season)); + getTextField().setHorizontalAlignment(SwingConstants.RIGHT); } + + } diff --git a/source/net/sourceforge/filebot/ui/panel/list/ListPanel.java b/source/net/sourceforge/filebot/ui/panel/list/ListPanel.java index 8ac880b1..fd5e14b4 100644 --- a/source/net/sourceforge/filebot/ui/panel/list/ListPanel.java +++ b/source/net/sourceforge/filebot/ui/panel/list/ListPanel.java @@ -67,9 +67,9 @@ public class ListPanel extends JComponent { 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(fromSpinner, "gap related, wmax 14mm, sizegroup spinner"); add(new JLabel("To:"), "gap 5mm"); - add(toSpinner, "gap related, wmax 12mm, sizegroup spinner"); + add(toSpinner, "gap related, wmax 14mm, sizegroup spinner"); add(new JButton(createAction), "gap 7mm, gapafter indent, wrap paragraph"); add(list, "grow"); diff --git a/source/net/sourceforge/tuned/ui/FancyTreeCellRenderer.java b/source/net/sourceforge/tuned/ui/FancyTreeCellRenderer.java index 4750d131..c3ce173d 100644 --- a/source/net/sourceforge/tuned/ui/FancyTreeCellRenderer.java +++ b/source/net/sourceforge/tuned/ui/FancyTreeCellRenderer.java @@ -40,12 +40,12 @@ public class FancyTreeCellRenderer extends DefaultTreeCellRenderer { @Override - public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) { - super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, false); + public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) { + super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, false); setIconTextGap(5); - - if (sel) { + + if (selected) { setPaintGradient(true); setGradientBeginColor(backgroundSelectionColor.brighter()); setGradientEndColor(backgroundSelectionColor);