1
|
1 package rep;
|
|
2
|
|
3 import java.awt.BorderLayout;
|
|
4 import java.awt.Component;
|
2
|
5 import java.awt.Dimension;
|
1
|
6 import java.awt.FlowLayout;
|
|
7 import java.awt.event.ActionEvent;
|
|
8 import java.awt.event.ActionListener;
|
8
|
9 import java.nio.channels.SocketChannel;
|
1
|
10
|
|
11 import javax.swing.AbstractButton;
|
|
12 import javax.swing.JButton;
|
8
|
13 import javax.swing.JComboBox;
|
1
|
14 import javax.swing.JLabel;
|
|
15 import javax.swing.JPanel;
|
2
|
16 import javax.swing.JScrollBar;
|
|
17 import javax.swing.JScrollPane;
|
1
|
18 import javax.swing.JTextArea;
|
|
19 import javax.swing.JTextField;
|
|
20
|
|
21 public class RPanel extends JPanel implements ActionListener {
|
|
22
|
|
23 private JButton button;
|
2
|
24 private JTextField textField;
|
|
25 private String host;
|
1
|
26 private JLabel label;
|
2
|
27 private JTextArea textArea;
|
|
28 private JScrollBar scrollBar;
|
|
29 private JScrollPane scrollPane;
|
|
30 private SessionViewer sessionViewer;
|
|
31 private JScrollPane viewerPane;
|
|
32 private ConnectionListener listener;
|
8
|
33 private JComboBox comboEditor;
|
|
34 private JComboBox comboSession;
|
|
35 private JButton buttonSelect;
|
|
36 private REPActionListener actionListener;
|
1
|
37
|
|
38 public RPanel() {
|
|
39 button = new JButton("Connect");
|
6
|
40 textField = new JTextField("firefly.cr.ie.u-ryukyu.ac.jp");
|
2
|
41 textArea = new JTextArea();
|
1
|
42 label = new JLabel("test");
|
2
|
43 scrollPane = new JScrollPane(textArea);
|
|
44 sessionViewer = new SessionViewer();
|
|
45 viewerPane = new JScrollPane(sessionViewer.getTree());
|
|
46 //scrollBar = new JScrollBar(JScrollBar.VERTICAL);
|
8
|
47 comboEditor = new JComboBox();
|
|
48 comboSession = new JComboBox();
|
|
49 buttonSelect = new JButton("Select");
|
2
|
50
|
|
51
|
|
52 button.setBounds(160, 5, 100, 20);
|
|
53 textField.setBounds(5, 5, 150, 20);
|
|
54 textArea.setEditable(false);
|
|
55 textArea.setLineWrap(false);
|
|
56 scrollPane.setBounds(5, 30, 200, 200);
|
|
57 scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
|
|
58 viewerPane.setBounds(5, 30, 200, 200);
|
|
59 viewerPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
|
|
60 //scrollPane.setPreferredSize(new Dimension(200, 200));
|
|
61 //textArea.setBounds(5, 30, 200, 200);
|
|
62 //textArea.add(scrollBar, BorderLayout.EAST);
|
8
|
63 comboEditor.setBounds(250, 50, 100, 50);
|
|
64 comboSession.setBounds(250, 100, 100, 50);
|
|
65 buttonSelect.setBounds(250, 180, 100, 20);
|
1
|
66
|
2
|
67 this.setLayout(null);
|
|
68 this.add(textField);
|
|
69 this.add( button);
|
|
70 this.add(label);
|
|
71 //this.add(textArea);
|
|
72 //this.add(scrollPane, BorderLayout.CENTER);
|
|
73 this.add(viewerPane, BorderLayout.CENTER);
|
1
|
74 //this.add(label, BorderLayout.CENTER);
|
8
|
75 this.add(comboEditor);
|
|
76 this.add(comboSession);
|
|
77 this.add(buttonSelect);
|
1
|
78
|
|
79 button.addActionListener(this);
|
8
|
80 buttonSelect.addActionListener(this);
|
1
|
81 }
|
|
82
|
2
|
83 public void addSessionTree(int SID){
|
|
84 sessionViewer.addSessionTree(SID);
|
|
85 }
|
|
86
|
1
|
87 public void actionPerformed(ActionEvent event) {
|
|
88 if (event.getSource() == button) {
|
2
|
89 host = textField.getText();
|
|
90 listener.connectionOccured(new ConnectionEvent(host));
|
8
|
91 }else if(event.getSource() == buttonSelect){
|
|
92 actionListener.ActionOccured(new REPActionEvent((EditorPlus) comboEditor.getSelectedItem(),
|
|
93 (SessionPlus)comboSession.getSelectedItem()));
|
1
|
94 }
|
|
95 }
|
|
96
|
2
|
97 public void addConnectionListener(ConnectionListener listener) {
|
|
98 System.out.println(listener.toString());
|
|
99 this.listener = listener;
|
|
100 }
|
|
101
|
8
|
102 public void setComboEditor(int eid, SocketChannel channel) {
|
|
103 //comboEditor.addItem("Editor:"+eid);
|
|
104 comboEditor.addItem(new EditorPlus(eid, channel));
|
|
105 }
|
|
106
|
|
107 public void REPActionListener(REPActionListener listener2) {
|
|
108 this.actionListener = listener2;
|
|
109 }
|
|
110
|
|
111 public void setComboSession(int sessionID, String string) {
|
|
112 comboSession.addItem(new SessionPlus(sessionID, string));
|
|
113 }
|
|
114
|
1
|
115 }
|