2 * Created on Sep 28, 2005
4 * TODO To change the template for this generated file go to
5 * Window - Preferences - Java - Code Style - Code Templates
9 import java
.awt
.BorderLayout
;
10 import java
.awt
.event
.ActionEvent
;
11 import java
.awt
.event
.ActionListener
;
14 import javax
.swing
.event
.*;
16 import util
.KeyedTable
;
18 import diku
.distlab
.motecontrolclientlib
.client
.SimpleMoteManager
;
19 import diku
.distlab
.servicewrappers
.InfrastructureWrapper
;
24 * TODO To change the template for this generated type comment go to
25 * Window - Preferences - Java - Code Style - Code Templates
27 public class MoteListIFrame
extends JInternalFrame
implements ActionListener
32 private static final long serialVersionUID
= 32371604391836635L;
33 static final int xOffset
= 0, yOffset
= 0;
34 static int openFrameCount
= 0;
37 private KeyedTable table
;
38 private JScrollPane scrollPane
;
39 private JToolBar toolBar
;
40 private SimpleMoteManager moteManager
;
42 public MoteListIFrame(String title
,SimpleMoteManager moteManager
) throws Exception
49 this.moteManager
= moteManager
;
50 this.setDefaultCloseOperation(HIDE_ON_CLOSE
);
52 this.addInternalFrameListener(new InternalFrameAdapter() {
53 public void internalFrameActivated(InternalFrameEvent e
) {
54 InfrastructureWrapper
.updateMoteList();
55 table
.setDataTable(InfrastructureWrapper
.getMoteTable());
59 InfrastructureWrapper
.updateMoteList();
61 table
= new KeyedTable(InfrastructureWrapper
.getMoteTable());
62 // table.setDragEnabled(true);
64 panel
= new JPanel(new BorderLayout());
65 scrollPane
= new JScrollPane(table
);
67 toolBar
= new JToolBar();
71 // ...Then set the window size or call pack...
74 // Set the window's location.
75 setLocation(xOffset
, yOffset
);
77 getContentPane().add(panel
);
78 panel
.add(toolBar
,BorderLayout
.PAGE_START
);
79 panel
.add(scrollPane
,BorderLayout
.CENTER
);
83 private void createButtons()
85 toolBar
.setFloatable(false);
86 toolBar
.add(MainWindow
.createButton("refresh","/toolbarButtonGraphics/general/Refresh16.gif","Refresh the mote list.",this));
87 toolBar
.addSeparator();
88 toolBar
.add(MainWindow
.createButton("control","/toolbarButtonGraphics/general/Add16.gif","Get control of the selected mote(s).",this));
91 public void actionPerformed(ActionEvent e
)
93 String cmd
= e
.getActionCommand();
97 if (cmd
.equals("control"))
99 moteManager
.requestMotes(table
.getSelectedKeys());
100 MainWindow
.getMainWindow().createMoteControlListFrame();
104 if (cmd
.equals("refresh"))
106 InfrastructureWrapper
.updateMoteList();
107 table
.setDataTable(InfrastructureWrapper
.getMoteTable());
112 ex
.printStackTrace();