1 | // License: GPL. Copyright 2007 by Immanuel Scholz and others
|
---|
2 | package org.openstreetmap.josm.gui.dialogs;
|
---|
3 |
|
---|
4 | import static org.openstreetmap.josm.tools.I18n.tr;
|
---|
5 |
|
---|
6 | import java.awt.Component;
|
---|
7 | import java.awt.event.ActionEvent;
|
---|
8 |
|
---|
9 | import javax.swing.AbstractAction;
|
---|
10 | import javax.swing.JList;
|
---|
11 | import javax.swing.JOptionPane;
|
---|
12 | import javax.swing.JPopupMenu;
|
---|
13 |
|
---|
14 | import org.openstreetmap.josm.Main;
|
---|
15 | import org.openstreetmap.josm.gui.layer.Layer;
|
---|
16 | import org.openstreetmap.josm.tools.ImageProvider;
|
---|
17 |
|
---|
18 | /**
|
---|
19 | * Popup menu handler for the layer list.
|
---|
20 | */
|
---|
21 | public class LayerListPopup extends JPopupMenu {
|
---|
22 |
|
---|
23 | public final static class InfoAction extends AbstractAction {
|
---|
24 | private final Layer layer;
|
---|
25 | public InfoAction(Layer layer) {
|
---|
26 | super(tr("Info"), ImageProvider.get("info"));
|
---|
27 | this.layer = layer;
|
---|
28 | }
|
---|
29 | public void actionPerformed(ActionEvent e) {
|
---|
30 | JOptionPane.showMessageDialog(
|
---|
31 | Main.parent,
|
---|
32 | layer.getInfoComponent(),
|
---|
33 | tr("Information about layer"),
|
---|
34 | JOptionPane.INFORMATION_MESSAGE
|
---|
35 | );
|
---|
36 | }
|
---|
37 | }
|
---|
38 |
|
---|
39 | public LayerListPopup(final JList layers, final Layer layer) {
|
---|
40 | for (Component c : layer.getMenuEntries()) {
|
---|
41 | add(c);
|
---|
42 | }
|
---|
43 | }
|
---|
44 | }
|
---|