Mercurial > hg > RemoteEditor > Eclipse
view src/remoteeditor/ui/REPSelectWindow.java @ 37:7f346cf2a07b
*** empty log message ***
author | pin |
---|---|
date | Fri, 06 Apr 2007 01:36:23 +0900 |
parents | |
children | 99dc7f13ed80 |
line wrap: on
line source
package remoteeditor.ui; import java.io.IOException; import java.net.InetSocketAddress; import java.nio.channels.SocketChannel; import java.util.StringTokenizer; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Combo; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.MessageBox; import org.eclipse.swt.widgets.Shell; import remoteeditor.command.REPCommand; import remoteeditor.network.REP; import remoteeditor.network.REPPacketReceive; import remoteeditor.network.REPPacketSend; public class REPSelectWindow { private Shell shell; private Combo combo; private Display display; private SocketChannel channel; private REPPacketReceive repreceive; private REPPacketSend repsend; private String filename; private REPCommand command; private int mysid; private int myeid; private int myseq; public REPSelectWindow(Display display){ this.display = display; shell = new Shell(display); shell.setLayout(new FillLayout()); shell.setText("test"); } public REPSelectWindow(Shell shell2) { this.shell = shell2; display = shell.getDisplay(); } public void initWindow(){ combo = new Combo(shell, SWT.READ_ONLY); combo.add("null"); //combo.add("test2"); //combo.add("test3"); combo.select(0); //String text; combo.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e){ } public void widgetSelected(SelectionEvent e){ Combo bCombo = (Combo)e.widget; System.out.println(bCombo.getText()); } }); Button button1 = new Button(shell,SWT.NULL); button1.setText("select"); button1.addSelectionListener(new SelectionAdapter(){ public void widgetSelected(SelectionEvent e){ MessageBox mesBox = new MessageBox(shell); if(combo.getSelectionIndex() == 0){ put(); select(); }else{ mysid = combo.getSelectionIndex() - 1; select(); } mesBox.setMessage("select : " + combo.getText()); mesBox.open(); shell.close(); } }); } public String getSessionList(){ return null; } public int open(){ shell.pack(); shell.open(); join(); //put(); while(!shell.isDisposed()){ if(!display.readAndDispatch()){ display.sleep(); } } //dispose(); //put(); //select(); return 0; } private void select() { repsend.send(new REPCommand(REP.REP_SELECT_CMD, mysid, myeid, myseq, 0, 0, "")); } private void put() { repsend.send(new REPCommand(REP.REP_PUT_CMD, mysid, myeid, myseq, 0, filename.length(), filename)); command = repreceive.unpack(); mysid = command.sid; } public void setName(String name) { this.filename = name; combo.add(name, 0); } public String getSessionName() { return combo.getText(); } public void setChannel(SocketChannel sc) { this.channel = sc; repreceive = new REPPacketReceive(sc); repsend = new REPPacketSend(sc); } public void join(){ repsend.send(new REPCommand(REP.REP_JOIN_CMD, 0, 0, 0, 0, 0, "")); command = repreceive.unpack(); myeid = command.eid; //System.out.println(command.toString()); StringTokenizer tokenizer = new StringTokenizer(command.string, ",{} "); while (tokenizer.hasMoreTokens()) { //System.out.println(tokenizer.nextToken()); combo.add(tokenizer.nextToken()); } } }