Initial import of ClientModules from the sourceforge CVS repository
[remote/remote-gui.git] / DIKUClientMainModule / old / gui / MoteListIFrame.java
blob705c0a7b9926eaf525f22f2eba17980897b522c9
1 /*
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
6 */
7 package gui;
9 import java.awt.BorderLayout;
10 import java.awt.event.ActionEvent;
11 import java.awt.event.ActionListener;
13 import javax.swing.*;
14 import javax.swing.event.*;
16 import util.KeyedTable;
18 import diku.distlab.motecontrolclientlib.client.SimpleMoteManager;
19 import diku.distlab.servicewrappers.InfrastructureWrapper;
21 /**
22 * @author zept
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
29 /**
32 private static final long serialVersionUID = 32371604391836635L;
33 static final int xOffset = 0, yOffset = 0;
34 static int openFrameCount = 0;
36 private JPanel panel;
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
44 super( title,
45 true, //resizable
46 true, //closable
47 true, //maximizable
48 true );//iconifiable
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());
57 });
58 // create GUI
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();
69 createButtons();
71 // ...Then set the window size or call pack...
72 setSize(300,600);
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();
95 try
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());
110 catch (Exception ex)
112 ex.printStackTrace();