1 package org.opentrafficsim.editor.extensions;
2
3 import java.io.IOException;
4 import java.rmi.RemoteException;
5
6 import javax.swing.ImageIcon;
7 import javax.swing.JComponent;
8 import javax.swing.JLabel;
9
10 import org.djutils.event.Event;
11 import org.djutils.event.EventListener;
12 import org.opentrafficsim.editor.OtsEditor;
13 import org.opentrafficsim.editor.XsdTreeNode;
14
15
16
17
18
19
20
21
22
23 public class OdEditor implements EventListener
24 {
25
26
27 private static final long serialVersionUID = 20230313L;
28
29
30 private final OtsEditor editor;
31
32
33
34
35
36
37 public OdEditor(final OtsEditor editor) throws IOException
38 {
39 ImageIcon odIcon = OtsEditor.loadIcon("./Table_blue.png", 16, 16, -1, -1);
40 editor.addTab("OD", odIcon, buildOdPane(), null);
41 editor.addListener(this, OtsEditor.SELECTION_CHANGED);
42 this.editor = editor;
43 }
44
45
46
47
48
49 private static JComponent buildOdPane()
50 {
51 JLabel od = new JLabel("od");
52 od.setOpaque(true);
53 od.setHorizontalAlignment(JLabel.CENTER);
54 return od;
55 }
56
57
58 @Override
59 public void notify(final Event event) throws RemoteException
60 {
61
62 if (event.getType().equals(OtsEditor.SELECTION_CHANGED))
63 {
64 JLabel label = ((JLabel) this.editor.getTab("OD"));
65 XsdTreeNode node = (XsdTreeNode) event.getContent();
66 if (node.getPathString().startsWith("Ots.Demand.Od"))
67 {
68 label.setText(node.getPathString());
69 }
70 else
71 {
72 label.setText("od");
73 }
74 }
75 }
76
77 }