From 52d82489cb54a19e9b6a97157e7ea1826e67a8e7 Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Tue, 26 Jan 2016 16:23:01 +0000 Subject: [PATCH] Allow Season Year values in the Season spinner --- .../ui/episodelist/EpisodeListPanel.java | 5 +- .../ui/episodelist/SeasonSpinnerModel.java | 67 +++++++++---------- 2 files changed, 34 insertions(+), 38 deletions(-) diff --git a/source/net/filebot/ui/episodelist/EpisodeListPanel.java b/source/net/filebot/ui/episodelist/EpisodeListPanel.java index 09c562f2..4b00c188 100644 --- a/source/net/filebot/ui/episodelist/EpisodeListPanel.java +++ b/source/net/filebot/ui/episodelist/EpisodeListPanel.java @@ -3,6 +3,7 @@ package net.filebot.ui.episodelist; import static net.filebot.ui.episodelist.SeasonSpinnerModel.*; import static net.filebot.web.EpisodeUtilities.*; +import java.awt.Dimension; import java.awt.datatransfer.Clipboard; import java.awt.datatransfer.StringSelection; import java.awt.datatransfer.Transferable; @@ -66,7 +67,9 @@ public class EpisodeListPanel extends AbstractSearchPanel getSeasonValues() { + IntStream values = IntStream.of(ALL_SEASONS); + values = IntStream.concat(values, IntStream.range(SEASON_MIN_VALUE, SEASON_MAX_VALUE)); + values = IntStream.concat(values, IntStream.range(YEAR_SEASON_MIN_VALUE, YEAR_SEASON_MAX_VALUE)); + return values.boxed().collect(Collectors.toList()); + } public SeasonSpinnerModel() { - super(ALL_SEASONS, ALL_SEASONS, MAX_VALUE, 1); + super(getSeasonValues()); } - public int getSeason() { - return getNumber().intValue(); + return ((Integer) getValue()).intValue(); } - - @Override - public Integer getMinimum() { - return (Integer) super.getMinimum(); - } - - - @Override - public Integer getMaximum() { - return (Integer) super.getMaximum(); - } - - public void spin(int steps) { - int next = getSeason() + steps; - - if (next < getMinimum()) - next = getMinimum(); - else if (next > getMaximum()) - next = getMaximum(); - - setValue(next); + for (int i = 0; i < abs(steps); i++) { + setValue(i < 0 ? getPreviousValue() : getNextValue()); + } } + private Object valueBeforeLock = null; public void lock(int value) { - valueBeforeLock = getNumber(); - setMinimum(value); - setMaximum(value); - setValue(value); + valueBeforeLock = getValue(); + + setList(singletonList(ALL_SEASONS)); + setValue(ALL_SEASONS); } - public void unlock() { - setMinimum(ALL_SEASONS); - setMaximum(MAX_VALUE); + setList(getSeasonValues()); if (valueBeforeLock != null) { setValue(valueBeforeLock); - valueBeforeLock = null; } + valueBeforeLock = null; } + }