1 | package de.ugoe.cs.eventbench.swing;
|
---|
2 |
|
---|
3 | import java.awt.EventQueue;
|
---|
4 | import javax.swing.JFrame;
|
---|
5 | import javax.swing.JList;
|
---|
6 | import java.awt.BorderLayout;
|
---|
7 | import java.util.List;
|
---|
8 |
|
---|
9 | import javax.swing.JButton;
|
---|
10 | import javax.swing.AbstractListModel;
|
---|
11 | import javax.swing.event.ListSelectionListener;
|
---|
12 | import javax.swing.event.ListSelectionEvent;
|
---|
13 | import de.ugoe.cs.eventbench.data.Event;
|
---|
14 | import de.ugoe.cs.eventbench.data.GlobalDataContainer;
|
---|
15 | import de.ugoe.cs.eventbench.windows.data.WindowsMessage;
|
---|
16 | import de.ugoe.cs.util.console.Console;
|
---|
17 |
|
---|
18 | import java.awt.event.MouseAdapter;
|
---|
19 | import java.awt.event.MouseEvent;
|
---|
20 | import javax.swing.JPanel;
|
---|
21 | import javax.swing.border.EtchedBorder;
|
---|
22 | import javax.swing.JScrollPane;
|
---|
23 | import java.awt.event.ComponentAdapter;
|
---|
24 | import java.awt.event.ComponentEvent;
|
---|
25 | import java.awt.event.WindowAdapter;
|
---|
26 | import java.awt.event.WindowEvent;
|
---|
27 |
|
---|
28 | public class DlgSequences {
|
---|
29 |
|
---|
30 | private JFrame frmSequences;
|
---|
31 | private List<List<Event<?>>> containedSequences;
|
---|
32 |
|
---|
33 | /**
|
---|
34 | * Launch the application.
|
---|
35 | */
|
---|
36 | public static void ShowDialog() {
|
---|
37 | EventQueue.invokeLater(new Runnable() {
|
---|
38 | public void run() {
|
---|
39 | try {
|
---|
40 | DlgSequences window = new DlgSequences();
|
---|
41 | window.frmSequences.setVisible(true);
|
---|
42 | } catch (Exception e) {
|
---|
43 | e.printStackTrace();
|
---|
44 | }
|
---|
45 | }
|
---|
46 | });
|
---|
47 | }
|
---|
48 |
|
---|
49 | /**
|
---|
50 | * Create the application.
|
---|
51 | */
|
---|
52 | public DlgSequences() {
|
---|
53 | initialize();
|
---|
54 | }
|
---|
55 |
|
---|
56 | /**
|
---|
57 | * Initialize the contents of the frame.
|
---|
58 | */
|
---|
59 | private void initialize() {
|
---|
60 | frmSequences = new JFrame();
|
---|
61 | final javax.swing.DefaultListModel modelListSequences = new javax.swing.DefaultListModel();
|
---|
62 | final JButton btnSequence = new JButton("Show details");
|
---|
63 | final JButton btnClose = new JButton("Close");
|
---|
64 | JPanel panel = new JPanel();
|
---|
65 |
|
---|
66 |
|
---|
67 | // JFrame: frmSequence ***
|
---|
68 | frmSequences.setTitle("Sequences");
|
---|
69 | frmSequences.setResizable(false);
|
---|
70 | frmSequences.setBounds(100, 100, 270, 332);
|
---|
71 | frmSequences.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
---|
72 | frmSequences.getContentPane().setLayout(null);
|
---|
73 |
|
---|
74 |
|
---|
75 | try {
|
---|
76 | containedSequences = (List<List<Event<?>>>) GlobalDataContainer.getInstance().getData("sequences");
|
---|
77 | }
|
---|
78 | catch(ClassCastException e) {
|
---|
79 | Console.println("Not able to cast Data in GlobalDataContainer to List of Sequences");
|
---|
80 | }
|
---|
81 |
|
---|
82 | try {
|
---|
83 | for(int i=0; i<containedSequences.size(); i++) {
|
---|
84 | modelListSequences.addElement("Sequence " + (i+1) + ": " + containedSequences.get(i).size() + " Events");
|
---|
85 | }
|
---|
86 | }
|
---|
87 | catch(NullPointerException e) {
|
---|
88 | Console.println("No sequences found.");
|
---|
89 | }
|
---|
90 |
|
---|
91 |
|
---|
92 | panel.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
|
---|
93 | panel.setBounds(10, 11, 244, 218);
|
---|
94 | frmSequences.getContentPane().add(panel);
|
---|
95 | panel.setLayout(null);
|
---|
96 | // ***
|
---|
97 |
|
---|
98 |
|
---|
99 | // JScrollPane: scrollPane
|
---|
100 | JScrollPane scrollPane = new JScrollPane();
|
---|
101 | scrollPane.setBounds(10, 11, 224, 196);
|
---|
102 | panel.add(scrollPane);
|
---|
103 | final JList listSequences = new JList(modelListSequences);
|
---|
104 | scrollPane.setViewportView(listSequences);
|
---|
105 | // ***
|
---|
106 |
|
---|
107 |
|
---|
108 |
|
---|
109 | // JList: listSequnces
|
---|
110 | listSequences.addListSelectionListener(new ListSelectionListener() {
|
---|
111 | public void valueChanged(ListSelectionEvent arg0) {
|
---|
112 | if(listSequences.getSelectedIndex() >= 0) btnSequence.setEnabled(true);
|
---|
113 | else btnSequence.setEnabled(false);
|
---|
114 | }
|
---|
115 | });
|
---|
116 |
|
---|
117 | JPanel panel_1 = new JPanel();
|
---|
118 | panel_1.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
|
---|
119 | panel_1.setBounds(10, 240, 244, 53);
|
---|
120 | frmSequences.getContentPane().add(panel_1);
|
---|
121 | panel_1.setLayout(null);
|
---|
122 | // ***
|
---|
123 |
|
---|
124 |
|
---|
125 | // JButton: btnSequence ***
|
---|
126 | btnSequence.addMouseListener(new MouseAdapter() {
|
---|
127 | public void mouseClicked(MouseEvent arg0) {
|
---|
128 | if(btnSequence.isEnabled()) {
|
---|
129 | DlgSequenceDetails dlgSequences = new DlgSequenceDetails(frmSequences, containedSequences.get(listSequences.getSelectedIndex()));
|
---|
130 | dlgSequences.ShowDialog(frmSequences, containedSequences.get(listSequences.getSelectedIndex()));
|
---|
131 | frmSequences.setVisible(false);
|
---|
132 | }
|
---|
133 | }
|
---|
134 | });
|
---|
135 | btnSequence.setBounds(124, 11, 110, 32);
|
---|
136 | panel_1.add(btnSequence);
|
---|
137 | btnSequence.setEnabled(false);
|
---|
138 | // ***
|
---|
139 |
|
---|
140 |
|
---|
141 | //JButton: btnClose ***
|
---|
142 | btnClose.addMouseListener(new MouseAdapter() {
|
---|
143 | public void mouseClicked(MouseEvent arg0) {
|
---|
144 | frmSequences.dispose();
|
---|
145 | }
|
---|
146 | });
|
---|
147 | btnClose.setBounds(10, 11, 110, 32);
|
---|
148 | panel_1.add(btnClose);
|
---|
149 | // ***
|
---|
150 | }
|
---|
151 | }
|
---|