291
|
1 package test.sematest;
|
|
2
|
|
3 import java.util.LinkedList;
|
|
4
|
|
5 import rep.Editor;
|
|
6 import rep.SelectButtonEvent;
|
|
7 import rep.Session;
|
|
8 import rep.SessionManagerEvent;
|
|
9 import rep.SessionManagerEventListener;
|
|
10 import rep.SessionManagerGUI;
|
293
|
11 import rep.channel.REPLogger;
|
291
|
12
|
|
13 /**
|
|
14 * @author kono
|
|
15 * Dummy GUI for test
|
|
16 *
|
|
17 * perform auto select operation
|
|
18 */
|
|
19
|
|
20 public class TestGUI implements SessionManagerGUI {
|
|
21 public LinkedList<Session> slist;
|
|
22 public LinkedList<Editor> elist;
|
|
23 SessionManagerEventListener manager;
|
|
24 int count = 0;
|
293
|
25 private REPLogger ns;
|
291
|
26
|
|
27 public TestGUI(SessionManagerEventListener manager) {
|
|
28 this.manager = manager;
|
293
|
29 ns = REPLogger.singleton();
|
291
|
30 }
|
|
31
|
|
32 public void invokeLater(Runnable doRun) {
|
|
33 doRun.run();
|
|
34 }
|
|
35
|
|
36 public void update(LinkedList<Session> slist, LinkedList<Editor> elist) {
|
320
|
37 int i = 0;
|
291
|
38 this.slist = slist;
|
|
39 this.elist = elist;
|
|
40 // fair and deterministic select session for an empty editor
|
|
41 if (slist.size()==0) return;
|
|
42 Session s = slist.get(count++ % slist.size());
|
|
43 for(Editor e :elist) {
|
|
44 if (!e.hasSession()) {
|
|
45 SessionManagerEvent event = new SelectButtonEvent(e, s, manager);
|
320
|
46 ns.writeLog("Select session "+s.getSID()+" and editor "+i);
|
291
|
47 manager.buttonPressed(event);
|
|
48 s = slist.get(count++ % slist.size());
|
|
49 }
|
320
|
50 i++;
|
291
|
51 }
|
|
52 }
|
|
53
|
|
54 }
|