Mercurial > hg > RemoteEditor > REPSessionManager
view test/editortest/UserSimulator.java @ 420:5c95a9020e31
Modify ServerMainLoop
author | one |
---|---|
date | Fri, 13 Feb 2009 19:13:50 +0900 |
parents | 7ff127c8ad64 |
children |
line wrap: on
line source
package test.editortest; import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.LinkedList; import javax.swing.JButton; import javax.swing.JFrame; import rep.REP; import rep.REPCommand; public class UserSimulator extends JFrame implements ActionListener{ /** * */ private static final long serialVersionUID = 1L; private JButton startButton; private LinkedList<SimpleEditorForREPEditor> editorList; private JButton initButton; public UserSimulator(String title){ super(title); editorList = new LinkedList<SimpleEditorForREPEditor>(); setButton(); pack(); } private void init(){ editorList.get(0).repPut(); for(int i = 1; i < editorList.size(); i++){ editorList.get(i).repJoin(); } initButton.setEnabled(false); } private void setButton() { setLayout(new FlowLayout()); initButton = new JButton("init"); startButton = new JButton("start"); add(initButton); add(startButton); initButton.addActionListener(this); startButton.addActionListener(this); } public void add(SimpleEditorForREPEditor editor) { editorList.add(editor); } public void actionPerformed(ActionEvent e) { if(e.getSource() == startButton){ userStart(); }else if(e.getSource() == initButton){ init(); } } private void userStart() { UserThread user = new UserThread(); user.start(); } class UserThread extends Thread{ public void run(){ // for(REPCommand command : userInputList){ for(int i = 0; i < 5; i++){ for(SimpleEditorForREPEditor editor : editorList){ REPCommand command = new REPCommand(REP.REPCMD_INSERT_USER, 0, 0, 0, 0, editor.getTitle() + ":" + i); ((REPTextWithJTextArea) editor.getREPEditor().getREPText()).userInsert(command); } } } } }