4 |
|
//---IMPORTS--- |
5 |
|
import uk.org.iscream.util.*; |
6 |
|
import java.util.HashMap; |
7 |
+ |
import java.util.List; |
8 |
+ |
import java.util.Collections; |
9 |
|
import javax.swing.ImageIcon; |
8 |
– |
import javax.swing.JTabbedPane; |
10 |
|
import javax.swing.JPanel; |
11 |
+ |
import javax.swing.BorderFactory; |
12 |
+ |
import java.awt.CardLayout; |
13 |
+ |
import javax.swing.JSplitPane; |
14 |
|
import java.util.StringTokenizer; |
15 |
|
import javax.swing.SwingUtilities; |
16 |
+ |
import javax.swing.DefaultListModel; |
17 |
+ |
import javax.swing.JList; |
18 |
+ |
import javax.swing.JScrollPane; |
19 |
+ |
import java.awt.Dimension; |
20 |
+ |
import javax.swing.event.ListSelectionListener; |
21 |
+ |
import javax.swing.event.ListSelectionEvent; |
22 |
+ |
import javax.swing.ListSelectionModel; |
23 |
|
|
24 |
|
/** |
25 |
|
* This thread reads data from the DataReader |
29 |
|
* @author $Author$ |
30 |
|
* @version $Id$ |
31 |
|
*/ |
32 |
< |
public class DataPanel extends JPanel implements Runnable { |
32 |
> |
public class DataPanel extends JSplitPane implements Runnable { |
33 |
|
|
34 |
|
//---FINAL ATTRIBUTES--- |
35 |
|
|
46 |
|
* Constructs the data panel |
47 |
|
*/ |
48 |
|
public DataPanel() { |
49 |
< |
add(_tabbedPane); |
49 |
> |
super(JSplitPane.HORIZONTAL_SPLIT); |
50 |
> |
|
51 |
> |
JScrollPane left = new JScrollPane(_hostChooserList); |
52 |
> |
JScrollPane right = new JScrollPane(_displayPane); |
53 |
> |
|
54 |
> |
setOneTouchExpandable(true); |
55 |
> |
setLeftComponent(left); |
56 |
> |
setRightComponent(right); |
57 |
> |
setDividerLocation(150); |
58 |
|
_xmlPacketMaker = new XMLPacketMaker(); |
59 |
|
} |
60 |
|
|
186 |
|
* @param host the host to add |
187 |
|
*/ |
188 |
|
private void addHostPanel(String host) { |
189 |
< |
HostDisplayPanel hostPanel = new HostDisplayPanel(host); |
190 |
< |
SwingSafeAddTab task = new SwingSafeAddTab(_tabbedPane, hostPanel, host, "Monitor " + host, _serverIcon); |
191 |
< |
SwingUtilities.invokeLater(task); |
189 |
> |
HostDisplayPanel hostPanel = new HostDisplayPanel(host); |
190 |
> |
//SwingSafeAdd task = new SwingSafeAdd(_displayPane, hostPanel); |
191 |
> |
//SwingUtilities.invokeLater(task); |
192 |
> |
_displayPane.add(hostPanel, host); |
193 |
|
_hostList.put(host, hostPanel); |
194 |
+ |
|
195 |
+ |
// we need to reconstruct the displayed host list, so its |
196 |
+ |
// sorted. |
197 |
+ |
|
198 |
+ |
_hostChooserList.setListData((new java.util.TreeSet(_hostList.keySet())).toArray()); |
199 |
+ |
|
200 |
|
Conient.addMessage("New Host added: " + host); |
201 |
|
} |
202 |
|
|
241 |
|
* channel is opened. |
242 |
|
*/ |
243 |
|
public void cleanUpTabs() { |
244 |
< |
_tabbedPane.removeAll(); |
244 |
> |
_displayPane = new JPanel(_displayPaneLayout); |
245 |
|
} |
246 |
|
|
247 |
+ |
/** |
248 |
+ |
* This card layout is used for the _displayPane |
249 |
+ |
* it allows the chooser list to select which |
250 |
+ |
* host to display |
251 |
+ |
*/ |
252 |
+ |
private CardLayout _displayPaneLayout = new CardLayout(); |
253 |
+ |
|
254 |
|
/** |
255 |
< |
* The tabbed pane is where HostDisplayPanel's |
256 |
< |
* are placed |
255 |
> |
* The panel where HostDisplayPanel's |
256 |
> |
* are placed, it uses a CardLayout |
257 |
|
*/ |
258 |
< |
private JTabbedPane _tabbedPane = new JTabbedPane(JTabbedPane.LEFT); |
258 |
> |
private JPanel _displayPane = new JPanel(_displayPaneLayout); |
259 |
|
|
260 |
+ |
/** |
261 |
+ |
* The host list allows the user to select which |
262 |
+ |
* host pane is topmost |
263 |
+ |
*/ |
264 |
+ |
private JList _hostChooserList = new JList(); |
265 |
+ |
{ |
266 |
+ |
_hostChooserList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); |
267 |
+ |
_hostChooserList.addListSelectionListener(new ListSelectionListener() { |
268 |
+ |
public void valueChanged(ListSelectionEvent e) { |
269 |
+ |
int selection = _hostChooserList.getSelectedIndex(); |
270 |
+ |
if (selection > -1) { |
271 |
+ |
_displayPaneLayout.show(_displayPane, (String) _hostChooserList.getSelectedValue()); |
272 |
+ |
} |
273 |
+ |
} |
274 |
+ |
}); |
275 |
+ |
} |
276 |
|
/** |
277 |
|
* The queue new data will be read from |
278 |
|
*/ |