1
0
mirror of https://github.com/mitb-archive/filebot synced 2024-11-11 03:45:06 -05:00
filebot/source/net/sourceforge/tuned/ui/notification/NotificationWindow.java
Reinhard Pointner ac9473ff07 * automatic episode list download and matching in RenamePanel
* added SeriesNameMatcher
* added SeasonEpisodeMatcher
* access Preferences via new Settings class
* adapt TVDotComClient to site changes (episodes  no longer ordered in reverse)
* added ActionPopup (inspired by the eclipse quickfix popup)

refactoring:
* renamed *Util classes to *Utilities
* renamed HyperlinkLabel to LinkButton as it extends JButton now
* refactored FileBotUtilities and FileUtilities
2009-01-25 00:08:57 +00:00

104 lines
2.0 KiB
Java

/*
* Created on 19.03.2005
*
*/
package net.sourceforge.tuned.ui.notification;
import java.awt.Window;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.WindowEvent;
import javax.swing.JWindow;
import javax.swing.Timer;
import net.sourceforge.tuned.ui.TunedUtilities;
public class NotificationWindow extends JWindow {
private final int timeout;
public NotificationWindow(Window owner, int timeout) {
this(owner, timeout, true);
}
public NotificationWindow(Window owner, int timeout, boolean closeOnClick) {
super(owner);
this.timeout = timeout;
setAlwaysOnTop(true);
if (closeOnClick) {
getGlassPane().addMouseListener(clickListener);
getGlassPane().setVisible(true);
}
addComponentListener(closeOnTimeout);
}
public NotificationWindow(Window owner) {
this(owner, -1);
}
public final void close() {
TunedUtilities.checkEventDispatchThread();
// window events are not fired automatically, required for layout updates
processWindowEvent(new WindowEvent(this, WindowEvent.WINDOW_CLOSING));
setVisible(false);
// component events are not fired automatically, used to cancel timeout timer
processComponentEvent(new ComponentEvent(this, ComponentEvent.COMPONENT_HIDDEN));
dispose();
}
private final ComponentListener closeOnTimeout = new ComponentAdapter() {
private Timer timer = null;
@Override
public void componentShown(ComponentEvent e) {
if (timeout >= 0) {
timer = TunedUtilities.invokeLater(timeout, new Runnable() {
@Override
public void run() {
close();
}
});
}
}
@Override
public void componentHidden(ComponentEvent e) {
if (timer != null) {
timer.stop();
}
}
};
private final MouseAdapter clickListener = new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
close();
}
};
}