2007-12-23 19:28:04 +00:00
|
|
|
/*
|
|
|
|
* Created on 19.03.2005
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
package net.sourceforge.tuned.ui.notification;
|
|
|
|
|
|
|
|
|
2008-04-27 17:36:27 +00:00
|
|
|
import java.awt.event.ComponentAdapter;
|
|
|
|
import java.awt.event.ComponentEvent;
|
2007-12-23 19:28:04 +00:00
|
|
|
|
|
|
|
|
|
|
|
public class NotificationManager {
|
|
|
|
|
|
|
|
private NotificationLayout layout;
|
|
|
|
|
|
|
|
|
|
|
|
public NotificationManager() {
|
|
|
|
this(new QueueNotificationLayout());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public NotificationManager(NotificationLayout layout) {
|
|
|
|
setLayoutManager(layout);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void setLayoutManager(NotificationLayout layout) {
|
|
|
|
this.layout = layout;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public NotificationLayout getLayoutManager() {
|
|
|
|
return layout;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void show(NotificationWindow notification) {
|
|
|
|
if (layout == null)
|
|
|
|
return;
|
|
|
|
|
2008-04-27 17:36:27 +00:00
|
|
|
notification.addComponentListener(new RemoveListener(layout));
|
2007-12-23 19:28:04 +00:00
|
|
|
layout.add(notification);
|
|
|
|
notification.setVisible(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-04-27 17:36:27 +00:00
|
|
|
private static class RemoveListener extends ComponentAdapter {
|
2007-12-23 19:28:04 +00:00
|
|
|
|
|
|
|
private NotificationLayout layout;
|
|
|
|
|
|
|
|
|
|
|
|
public RemoveListener(NotificationLayout layout) {
|
|
|
|
this.layout = layout;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-04-27 17:36:27 +00:00
|
|
|
@Override
|
|
|
|
public void componentHidden(ComponentEvent e) {
|
|
|
|
NotificationWindow window = (NotificationWindow) e.getSource();
|
|
|
|
layout.remove(window);
|
|
|
|
window.dispose();
|
2007-12-23 19:28:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|