* visual improvements to FileBotTabComponent
* some refactoring of FileBotUtil and Timer
This commit is contained in:
parent
d7c08bc4ca
commit
396176c2f6
|
@ -3,8 +3,8 @@ package net.sourceforge.filebot;
|
||||||
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileFilter;
|
import java.util.Arrays;
|
||||||
import java.io.FilenameFilter;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
@ -66,13 +66,18 @@ public final class FileBotUtil {
|
||||||
return embeddedChecksum;
|
return embeddedChecksum;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final String[] TORRENT_FILE_EXTENSIONS = { "torrent" };
|
public static final List<String> TORRENT_FILE_EXTENSIONS = unmodifiableList("torrent");
|
||||||
private static final String[] SFV_FILE_EXTENSIONS = { "sfv" };
|
public static final List<String> SFV_FILE_EXTENSIONS = unmodifiableList("sfv");
|
||||||
private static final String[] LIST_FILE_EXTENSIONS = { "txt", "list", "" };
|
public static final List<String> LIST_FILE_EXTENSIONS = unmodifiableList("txt", "list", "");
|
||||||
private static final String[] SUBTITLE_FILE_EXTENSIONS = { "srt", "sub", "ssa", "smi" };
|
public static final List<String> SUBTITLE_FILE_EXTENSIONS = unmodifiableList("srt", "sub", "ssa", "smi");
|
||||||
|
|
||||||
|
|
||||||
public static boolean containsOnlyFolders(List<File> files) {
|
private static List<String> unmodifiableList(String... elements) {
|
||||||
|
return Collections.unmodifiableList(Arrays.asList(elements));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static boolean containsOnlyFolders(Iterable<File> files) {
|
||||||
for (File file : files) {
|
for (File file : files) {
|
||||||
if (!file.isDirectory())
|
if (!file.isDirectory())
|
||||||
return false;
|
return false;
|
||||||
|
@ -82,22 +87,7 @@ public final class FileBotUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static boolean containsOnlyTorrentFiles(List<File> files) {
|
public static boolean containsOnly(Iterable<File> files, Iterable<String> extensions) {
|
||||||
return containsOnly(files, TORRENT_FILE_EXTENSIONS);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static boolean containsOnlySfvFiles(List<File> files) {
|
|
||||||
return containsOnly(files, SFV_FILE_EXTENSIONS);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static boolean containsOnlyListFiles(List<File> files) {
|
|
||||||
return containsOnly(files, LIST_FILE_EXTENSIONS);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static boolean containsOnly(List<File> files, String... extensions) {
|
|
||||||
for (File file : files) {
|
for (File file : files) {
|
||||||
if (!FileUtil.hasExtension(file, extensions))
|
if (!FileUtil.hasExtension(file, extensions))
|
||||||
return false;
|
return false;
|
||||||
|
@ -106,33 +96,6 @@ public final class FileBotUtil {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final FileFilter FOLDERS_ONLY = new FileFilter() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean accept(File file) {
|
|
||||||
return file.isDirectory();
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
public static final FileFilter FILES_ONLY = new FileFilter() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean accept(File file) {
|
|
||||||
return file.isFile();
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
public static final FilenameFilter SUBTITLES_ONLY = new FilenameFilter() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean accept(File dir, String name) {
|
|
||||||
return FileUtil.hasExtension(name, SUBTITLE_FILE_EXTENSIONS);
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dummy constructor to prevent instantiation.
|
* Dummy constructor to prevent instantiation.
|
||||||
|
|
|
@ -2,41 +2,51 @@
|
||||||
package net.sourceforge.filebot.ui;
|
package net.sourceforge.filebot.ui;
|
||||||
|
|
||||||
|
|
||||||
|
import java.awt.Dimension;
|
||||||
|
|
||||||
|
import javax.swing.AbstractButton;
|
||||||
import javax.swing.Icon;
|
import javax.swing.Icon;
|
||||||
import javax.swing.JButton;
|
import javax.swing.JButton;
|
||||||
import javax.swing.JComponent;
|
import javax.swing.JComponent;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.SwingConstants;
|
||||||
|
|
||||||
import net.miginfocom.swing.MigLayout;
|
import net.miginfocom.swing.MigLayout;
|
||||||
import net.sourceforge.filebot.ResourceManager;
|
import net.sourceforge.filebot.ResourceManager;
|
||||||
import net.sourceforge.tuned.ui.ProgressIndicator;
|
import net.sourceforge.tuned.ui.ProgressIndicator;
|
||||||
|
import net.sourceforge.tuned.ui.TunedUtil;
|
||||||
|
|
||||||
|
|
||||||
public class FileBotTabComponent extends JComponent {
|
public class FileBotTabComponent extends JComponent {
|
||||||
|
|
||||||
private ProgressIndicator progressIndicator = new ProgressIndicator();
|
private ProgressIndicator progressIndicator = new ProgressIndicator();
|
||||||
private JLabel label = new JLabel();
|
private JLabel textLabel = new JLabel();
|
||||||
private JButton closeButton = createCloseButton();
|
private JLabel iconLabel = new JLabel();
|
||||||
|
private AbstractButton closeButton = createCloseButton();
|
||||||
|
|
||||||
private Icon icon = null;
|
|
||||||
private boolean loading = false;
|
private boolean loading = false;
|
||||||
|
|
||||||
|
|
||||||
public FileBotTabComponent() {
|
public FileBotTabComponent() {
|
||||||
setLayout(new MigLayout("nogrid, fill, insets 0"));
|
iconLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
||||||
|
textLabel.setHorizontalAlignment(SwingConstants.LEFT);
|
||||||
|
|
||||||
progressIndicator.setVisible(loading);
|
progressIndicator.setVisible(loading);
|
||||||
|
progressIndicator.setMinimumSize(new Dimension(16, 16));
|
||||||
|
|
||||||
add(progressIndicator, "gap right 4px, w 17px!, h 17px!, hidemode 3");
|
setLayout(new MigLayout("nogrid, insets 0 0 1 3"));
|
||||||
add(label, "grow");
|
|
||||||
add(closeButton, "gap 3px:push, w 17!, h 17!");
|
add(progressIndicator, "hidemode 3");
|
||||||
|
add(iconLabel, "hidemode 3");
|
||||||
|
add(textLabel, "gap rel, align left");
|
||||||
|
add(closeButton, "gap unrel:push, hidemode 3, align center 45%");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void setLoading(boolean loading) {
|
public void setLoading(boolean loading) {
|
||||||
this.loading = loading;
|
this.loading = loading;
|
||||||
progressIndicator.setVisible(loading);
|
progressIndicator.setVisible(loading);
|
||||||
label.setIcon(loading ? null : icon);
|
iconLabel.setVisible(!loading);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -46,43 +56,46 @@ public class FileBotTabComponent extends JComponent {
|
||||||
|
|
||||||
|
|
||||||
public void setIcon(Icon icon) {
|
public void setIcon(Icon icon) {
|
||||||
this.icon = icon;
|
iconLabel.setIcon(icon);
|
||||||
label.setIcon(loading ? null : icon);
|
progressIndicator.setPreferredSize(icon != null ? TunedUtil.getDimension(icon) : progressIndicator.getMinimumSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Icon getIcon() {
|
public Icon getIcon() {
|
||||||
return icon;
|
return iconLabel.getIcon();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void setText(String text) {
|
public void setText(String text) {
|
||||||
label.setText(text);
|
textLabel.setText(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String getText() {
|
public String getText() {
|
||||||
return label.getText();
|
return textLabel.getText();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public JButton getCloseButton() {
|
public AbstractButton getCloseButton() {
|
||||||
return closeButton;
|
return closeButton;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private JButton createCloseButton() {
|
protected AbstractButton createCloseButton() {
|
||||||
JButton button = new JButton();
|
Icon icon = ResourceManager.getIcon("tab.close");
|
||||||
|
Icon rolloverIcon = ResourceManager.getIcon("tab.close.hover");
|
||||||
|
|
||||||
|
JButton button = new JButton(icon);
|
||||||
|
button.setRolloverIcon(rolloverIcon);
|
||||||
|
|
||||||
|
button.setPreferredSize(TunedUtil.getDimension(rolloverIcon));
|
||||||
|
button.setMaximumSize(button.getPreferredSize());
|
||||||
|
|
||||||
button.setContentAreaFilled(false);
|
button.setContentAreaFilled(false);
|
||||||
button.setBorderPainted(false);
|
button.setBorderPainted(false);
|
||||||
button.setFocusable(false);
|
button.setFocusable(false);
|
||||||
button.setRolloverEnabled(true);
|
button.setRolloverEnabled(true);
|
||||||
|
|
||||||
button.setIcon(ResourceManager.getIcon("tab.close"));
|
|
||||||
button.setRolloverIcon(ResourceManager.getIcon("tab.close.hover"));
|
|
||||||
|
|
||||||
return button;
|
return button;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,10 @@
|
||||||
package net.sourceforge.filebot.ui.panel.list;
|
package net.sourceforge.filebot.ui.panel.list;
|
||||||
|
|
||||||
|
|
||||||
|
import static net.sourceforge.filebot.FileBotUtil.TORRENT_FILE_EXTENSIONS;
|
||||||
|
import static net.sourceforge.filebot.FileBotUtil.containsOnly;
|
||||||
|
import static net.sourceforge.filebot.FileBotUtil.containsOnlyFolders;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -9,7 +13,6 @@ import java.util.List;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import net.sourceforge.filebot.FileBotUtil;
|
|
||||||
import net.sourceforge.filebot.torrent.Torrent;
|
import net.sourceforge.filebot.torrent.Torrent;
|
||||||
import net.sourceforge.filebot.ui.FileBotList;
|
import net.sourceforge.filebot.ui.FileBotList;
|
||||||
import net.sourceforge.filebot.ui.transfer.FileTransferablePolicy;
|
import net.sourceforge.filebot.ui.transfer.FileTransferablePolicy;
|
||||||
|
@ -43,9 +46,9 @@ class FileListTransferablePolicy extends FileTransferablePolicy {
|
||||||
// set title based on parent folder of first file
|
// set title based on parent folder of first file
|
||||||
list.setTitle(FileUtil.getFolderName(files.get(0).getParentFile()));
|
list.setTitle(FileUtil.getFolderName(files.get(0).getParentFile()));
|
||||||
|
|
||||||
if (FileBotUtil.containsOnlyFolders(files)) {
|
if (containsOnlyFolders(files)) {
|
||||||
loadFolders(files);
|
loadFolders(files);
|
||||||
} else if (FileBotUtil.containsOnlyTorrentFiles(files)) {
|
} else if (containsOnly(files, TORRENT_FILE_EXTENSIONS)) {
|
||||||
loadTorrents(files);
|
loadTorrents(files);
|
||||||
} else {
|
} else {
|
||||||
for (File file : files) {
|
for (File file : files) {
|
||||||
|
|
|
@ -2,11 +2,12 @@
|
||||||
package net.sourceforge.filebot.ui.panel.rename;
|
package net.sourceforge.filebot.ui.panel.rename;
|
||||||
|
|
||||||
|
|
||||||
|
import static net.sourceforge.filebot.FileBotUtil.containsOnlyFolders;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.sourceforge.filebot.FileBotUtil;
|
|
||||||
import net.sourceforge.filebot.ui.panel.rename.entry.FileEntry;
|
import net.sourceforge.filebot.ui.panel.rename.entry.FileEntry;
|
||||||
import net.sourceforge.filebot.ui.transfer.FileTransferablePolicy;
|
import net.sourceforge.filebot.ui.transfer.FileTransferablePolicy;
|
||||||
import ca.odell.glazedlists.EventList;
|
import ca.odell.glazedlists.EventList;
|
||||||
|
@ -36,7 +37,7 @@ class FilesListTransferablePolicy extends FileTransferablePolicy {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void load(List<File> files) {
|
protected void load(List<File> files) {
|
||||||
if (FileBotUtil.containsOnlyFolders(files)) {
|
if (containsOnlyFolders(files)) {
|
||||||
for (File folder : files) {
|
for (File folder : files) {
|
||||||
loadFiles(Arrays.asList(folder.listFiles()));
|
loadFiles(Arrays.asList(folder.listFiles()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,10 @@
|
||||||
package net.sourceforge.filebot.ui.panel.rename;
|
package net.sourceforge.filebot.ui.panel.rename;
|
||||||
|
|
||||||
|
|
||||||
|
import static net.sourceforge.filebot.FileBotUtil.LIST_FILE_EXTENSIONS;
|
||||||
|
import static net.sourceforge.filebot.FileBotUtil.TORRENT_FILE_EXTENSIONS;
|
||||||
|
import static net.sourceforge.filebot.FileBotUtil.containsOnly;
|
||||||
|
|
||||||
import java.awt.datatransfer.Transferable;
|
import java.awt.datatransfer.Transferable;
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
@ -75,9 +79,9 @@ class NamesListTransferablePolicy extends FilesListTransferablePolicy {
|
||||||
@Override
|
@Override
|
||||||
protected void load(List<File> files) {
|
protected void load(List<File> files) {
|
||||||
|
|
||||||
if (FileBotUtil.containsOnlyListFiles(files)) {
|
if (containsOnly(files, LIST_FILE_EXTENSIONS)) {
|
||||||
loadListFiles(files);
|
loadListFiles(files);
|
||||||
} else if (FileBotUtil.containsOnlyTorrentFiles(files)) {
|
} else if (containsOnly(files, TORRENT_FILE_EXTENSIONS)) {
|
||||||
loadTorrentFiles(files);
|
loadTorrentFiles(files);
|
||||||
} else {
|
} else {
|
||||||
super.load(files);
|
super.load(files);
|
||||||
|
|
|
@ -2,6 +2,9 @@
|
||||||
package net.sourceforge.filebot.ui.panel.sfv;
|
package net.sourceforge.filebot.ui.panel.sfv;
|
||||||
|
|
||||||
|
|
||||||
|
import static net.sourceforge.filebot.FileBotUtil.SFV_FILE_EXTENSIONS;
|
||||||
|
import static net.sourceforge.filebot.FileBotUtil.containsOnly;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
|
@ -13,7 +16,6 @@ import java.util.logging.Logger;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import net.sourceforge.filebot.FileBotUtil;
|
|
||||||
import net.sourceforge.filebot.ui.transfer.BackgroundFileTransferablePolicy;
|
import net.sourceforge.filebot.ui.transfer.BackgroundFileTransferablePolicy;
|
||||||
|
|
||||||
|
|
||||||
|
@ -94,7 +96,7 @@ class SfvTransferablePolicy extends BackgroundFileTransferablePolicy<ChecksumTab
|
||||||
@Override
|
@Override
|
||||||
protected void load(List<File> files) {
|
protected void load(List<File> files) {
|
||||||
try {
|
try {
|
||||||
if (FileBotUtil.containsOnlySfvFiles(files)) {
|
if (containsOnly(files, SFV_FILE_EXTENSIONS)) {
|
||||||
// one or more sfv files
|
// one or more sfv files
|
||||||
for (File file : files) {
|
for (File file : files) {
|
||||||
loadSfvFile(file);
|
loadSfvFile(file);
|
||||||
|
|
|
@ -3,14 +3,13 @@ package net.sourceforge.filebot.ui.panel.subtitle;
|
||||||
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.FileFilter;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import net.sourceforge.filebot.FileBotUtil;
|
|
||||||
|
|
||||||
|
|
||||||
public class Unrar {
|
public class Unrar {
|
||||||
|
|
||||||
|
@ -64,11 +63,11 @@ public class Unrar {
|
||||||
if (System.getProperty("os.name").toLowerCase().contains("windows")) {
|
if (System.getProperty("os.name").toLowerCase().contains("windows")) {
|
||||||
File programFiles = new File(System.getenv("PROGRAMFILES"));
|
File programFiles = new File(System.getenv("PROGRAMFILES"));
|
||||||
|
|
||||||
for (File folder : programFiles.listFiles(FileBotUtil.FOLDERS_ONLY)) {
|
for (File folder : programFiles.listFiles(FOLDERS_ONLY)) {
|
||||||
String name = folder.getName().toLowerCase();
|
String name = folder.getName().toLowerCase();
|
||||||
|
|
||||||
if (name.contains("rar") || name.contains("zip")) {
|
if (name.contains("rar") || name.contains("zip")) {
|
||||||
for (File file : folder.listFiles(FileBotUtil.FILES_ONLY)) {
|
for (File file : folder.listFiles(FILES_ONLY)) {
|
||||||
String filename = file.getName();
|
String filename = file.getName();
|
||||||
|
|
||||||
if (filename.equalsIgnoreCase("unrar.exe") || filename.equalsIgnoreCase("7z.exe")) {
|
if (filename.equalsIgnoreCase("unrar.exe") || filename.equalsIgnoreCase("7z.exe")) {
|
||||||
|
@ -89,7 +88,7 @@ public class Unrar {
|
||||||
return new Command(command);
|
return new Command(command);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.WARNING, "Cannot initialize unrar facility: " + e.getMessage());
|
Logger.getLogger("global").log(Level.WARNING, "Cannot initialize unrar facility: " + e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
@ -135,4 +134,23 @@ public class Unrar {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final FileFilter FOLDERS_ONLY = new FileFilter() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean accept(File file) {
|
||||||
|
return file.isDirectory();
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
private static final FileFilter FILES_ONLY = new FileFilter() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean accept(File file) {
|
||||||
|
return file.isFile();
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ public final class FileUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static boolean hasExtension(File file, String... extensions) {
|
public static boolean hasExtension(File file, Iterable<String> extensions) {
|
||||||
if (file.isDirectory())
|
if (file.isDirectory())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ public final class FileUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static boolean hasExtension(String filename, String... extensions) {
|
public static boolean hasExtension(String filename, Iterable<String> extensions) {
|
||||||
String extension = getExtension(filename, false);
|
String extension = getExtension(filename, false);
|
||||||
|
|
||||||
for (String ext : extensions) {
|
for (String ext : extensions) {
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
package net.sourceforge.tuned;
|
package net.sourceforge.tuned;
|
||||||
|
|
||||||
|
|
||||||
import java.util.concurrent.RunnableScheduledFuture;
|
import java.util.concurrent.ScheduledFuture;
|
||||||
import java.util.concurrent.ScheduledThreadPoolExecutor;
|
import java.util.concurrent.ScheduledThreadPoolExecutor;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ public abstract class Timer implements Runnable {
|
||||||
|
|
||||||
private final ScheduledThreadPoolExecutor executor;
|
private final ScheduledThreadPoolExecutor executor;
|
||||||
|
|
||||||
private RunnableScheduledFuture<?> scheduledFuture;
|
private ScheduledFuture<?> scheduledFuture;
|
||||||
private Thread shutdownHook;
|
private Thread shutdownHook;
|
||||||
|
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ public abstract class Timer implements Runnable {
|
||||||
removeShutdownHook();
|
removeShutdownHook();
|
||||||
}
|
}
|
||||||
|
|
||||||
scheduledFuture = (RunnableScheduledFuture<?>) executor.schedule(r, delay, unit);
|
scheduledFuture = executor.schedule(r, delay, unit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -60,8 +60,8 @@ public abstract class Timer implements Runnable {
|
||||||
private synchronized void removeScheduledFuture() {
|
private synchronized void removeScheduledFuture() {
|
||||||
if (scheduledFuture != null) {
|
if (scheduledFuture != null) {
|
||||||
try {
|
try {
|
||||||
scheduledFuture.cancel(false);
|
scheduledFuture.cancel(true);
|
||||||
executor.remove(scheduledFuture);
|
executor.purge();
|
||||||
} finally {
|
} finally {
|
||||||
scheduledFuture = null;
|
scheduledFuture = null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,14 +53,14 @@ public class ProgressIndicator extends JComponent {
|
||||||
addComponentListener(new ComponentAdapter() {
|
addComponentListener(new ComponentAdapter() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void componentHidden(ComponentEvent e) {
|
public void componentShown(ComponentEvent e) {
|
||||||
stopAnimation();
|
startAnimation();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void componentShown(ComponentEvent e) {
|
public void componentHidden(ComponentEvent e) {
|
||||||
startAnimation();
|
stopAnimation();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,6 +69,11 @@ public final class TunedUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static Dimension getDimension(Icon icon) {
|
||||||
|
return new Dimension(icon.getIconWidth(), icon.getIconHeight());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static Timer invokeLater(int delay, final Runnable runnable) {
|
public static Timer invokeLater(int delay, final Runnable runnable) {
|
||||||
Timer timer = new Timer(delay, new ActionListener() {
|
Timer timer = new Timer(delay, new ActionListener() {
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue