[Tinyos-contrib-commits]
CVS: tinyos-1.x/contrib/wustl/tools/java/edu/wustl/mobilab/agilla/plugins
GroupCommChatPlugin.java, 1.4, 1.5
Chien-Liang Fok
chien-liang at users.sourceforge.net
Wed Sep 27 07:34:29 PDT 2006
Update of /cvsroot/tinyos/tinyos-1.x/contrib/wustl/tools/java/edu/wustl/mobilab/agilla/plugins
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv30315/plugins
Modified Files:
GroupCommChatPlugin.java
Log Message:
user can tell agent to move
Index: GroupCommChatPlugin.java
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/contrib/wustl/tools/java/edu/wustl/mobilab/agilla/plugins/GroupCommChatPlugin.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** GroupCommChatPlugin.java 27 Sep 2006 08:52:18 -0000 1.4
--- GroupCommChatPlugin.java 27 Sep 2006 14:34:27 -0000 1.5
***************
*** 256,260 ****
private JScrollPane inTextScroller, outTextScroller;
! private JButton send;
private String font;
private String fontSize;
--- 256,260 ----
private JScrollPane inTextScroller, outTextScroller;
! //private JButton send;
private String font;
private String fontSize;
***************
*** 293,305 ****
outgoingMessages.add("North",new JLabel("Outgoing Messages:"));
! send = new JButton("Send");
send.setActionCommand("Send Message");
- JPanel buttonPanel = new JPanel();
- buttonPanel.setLayout(new BorderLayout());
- buttonPanel.add("East",send);
-
- // add action listener to the "send" button
send.addActionListener(this);
// add Text listener to the input text field,
// to send text when the enter key is hit
--- 293,309 ----
outgoingMessages.add("North",new JLabel("Outgoing Messages:"));
! JButton send = new JButton("Send");
send.setActionCommand("Send Message");
send.addActionListener(this);
+ JButton move = new JButton("Move");
+ move.setActionCommand("Move");
+ move.addActionListener(this);
+
+ JPanel buttonPanel = new JPanel();
+ buttonPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));
+ buttonPanel.add(move);
+ buttonPanel.add(send);
+
// add Text listener to the input text field,
// to send text when the enter key is hit
***************
*** 424,434 ****
optionMenu.addSeparator();
! JMenuItem sendAgentIDMI = new JMenuItem("Send AgentID", KeyEvent.VK_A);
! sendAgentIDMI.setAccelerator(KeyStroke.getKeyStroke(
! KeyEvent.VK_S,
! ActionEvent.ALT_MASK));
! sendAgentIDMI.addActionListener(this);
! sendAgentIDMI.setActionCommand("Send AgentID");
! optionMenu.add(sendAgentIDMI);
JMenuItem clearMessagesMI = new JMenuItem("Clear Incomming Messages",
--- 428,438 ----
optionMenu.addSeparator();
! // JMenuItem sendAgentIDMI = new JMenuItem("Send AgentID", KeyEvent.VK_A);
! // sendAgentIDMI.setAccelerator(KeyStroke.getKeyStroke(
! // KeyEvent.VK_S,
! // ActionEvent.ALT_MASK));
! // sendAgentIDMI.addActionListener(this);
! // sendAgentIDMI.setActionCommand("Send AgentID");
! // optionMenu.add(sendAgentIDMI);
JMenuItem clearMessagesMI = new JMenuItem("Clear Incomming Messages",
***************
*** 511,514 ****
--- 515,523 ----
if (outText.getText() != null && !outText.getText().equals("\n") && !outText.getText().equals("")) {
String outMessage = outText.getText();
+
+ // remove trailing newlines
+ if (outMessage.endsWith("\n")) {
+ outMessage = outMessage.substring(0,outMessage.length()-2);
+ }
if (outMessage.length() > 3) {
JOptionPane.showMessageDialog(frame, "Message must be 3 characters", "Error", JOptionPane.ERROR_MESSAGE);
***************
*** 521,525 ****
chatMsg.addField(new AgillaString(outMessage));
! log("Sending a chat message to : " + local_moteaddr + chatMsg);
injector.getTS().rout(chatMsg, local_moteaddr);
--- 530,534 ----
chatMsg.addField(new AgillaString(outMessage));
! log("Sending a chat message to : " + local_moteaddr + " message = " + chatMsg);
injector.getTS().rout(chatMsg, local_moteaddr);
***************
*** 560,563 ****
--- 569,593 ----
return;
}
+
+ if (ae.getActionCommand().equals("Move")) {
+ String locStr = JOptionPane.showInputDialog("Please enter a destination");
+ int x = 0, y = 0;
+ try {
+ System.out.println("locStr = " + locStr + " index of , = " + locStr.indexOf(","));
+ x = Integer.valueOf(locStr.substring(0, locStr.indexOf(",")));
+ y = Integer.valueOf(locStr.substring(locStr.indexOf(",")+1, locStr.length()));
+ } catch(Exception e) {
+ e.printStackTrace();
+ return;
+ }
+ Tuple moveMsg = new Tuple();
+ moveMsg.addField(new AgillaString("abc"));
+ moveMsg.addField(aid);
+ moveMsg.addField(new AgillaLocation(x, y));
+
+ System.out.println("movemsg = " + moveMsg);
+ log("Sending a move (" + x + ", " + y + ") to " + local_moteaddr);
+ injector.getTS().rout(moveMsg, local_moteaddr);
+ }
}
More information about the Tinyos-contrib-commits
mailing list