package pt.treps.ui;
import java.awt.Menu;
import java.awt.MenuItem;
import java.awt.PopupMenu;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.List;
import java.util.Vector;
import javax.swing.SwingUtilities;
import org.pushingpixels.substance.api.SubstanceLookAndFeel;
import org.pushingpixels.substance.api.skin.SkinInfo;
public class TrayPopupMenu extends PopupMenu {
private static final long serialVersionUID = 1L;
protected Menu lookAndFeelItem;
protected MenuItem exitItem;
protected MenuItem showItem;
public TrayPopupMenu() {
initComponents();
}
protected void initComponents() {
this.showItem = new MenuItem("Show");
this.showItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
//TODO bring back the window
}
});
}
});
this.lookAndFeelItem = new Menu("Look&Feel");
this.exitItem = new MenuItem("Exit");
this.exitItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
System.exit(0);
}
});
}
});
List<SkinInfo> availableSkins = new Vector<SkinInfo>(SubstanceLookAndFeel.getAllSkins().values());
for (final SkinInfo skinInfo : availableSkins) {
MenuItem skinMenuItem = new MenuItem(skinInfo.getDisplayName());
skinMenuItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
SubstanceLookAndFeel.setSkin(skinInfo.getClassName());
}
});
}
});
this.lookAndFeelItem.add(skinMenuItem);
}
this.add(this.lookAndFeelItem);
this.addSeparator();
this.add(this.exitItem);
}
}