Mercurial > hg > RemoteEditor > Eclipse
changeset 37:7f346cf2a07b
*** empty log message ***
author | pin |
---|---|
date | Fri, 06 Apr 2007 01:36:23 +0900 |
parents | 18badb26ba0e |
children | 99dc7f13ed80 |
files | bin/remoteeditor/editors/RemoteEditor$1.class bin/remoteeditor/editors/RemoteEditor.class plugin.xml src/remoteeditor/action/RemoteEditorAction.java src/remoteeditor/editors/RemoteEditor.java src/remoteeditor/ui/REPSelectWindow.java |
diffstat | 6 files changed, 185 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/plugin.xml Tue Mar 20 16:19:47 2007 +0900 +++ b/plugin.xml Fri Apr 06 01:36:23 2007 +0900 @@ -8,7 +8,7 @@ class="remoteeditor.editors.RemoteEditor" contributorClass="org.eclipse.ui.texteditor.BasicTextEditorActionContributor" default="true" - extensions="java" + extensions="" icon="icons/R-01.gif" id="remoteeditor.editors.RemoteEditor" name="Remote Editor">
--- a/src/remoteeditor/action/RemoteEditorAction.java Tue Mar 20 16:19:47 2007 +0900 +++ b/src/remoteeditor/action/RemoteEditorAction.java Fri Apr 06 01:36:23 2007 +0900 @@ -2,6 +2,7 @@ import org.eclipse.jface.action.IAction; import org.eclipse.jface.viewers.ISelection; +import org.eclipse.swt.widgets.Display; import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IEditorPart; import org.eclipse.ui.IWorkbench; @@ -13,6 +14,9 @@ import org.eclipse.ui.internal.Workbench; import org.eclipse.ui.internal.WorkbenchPage; +import remoteeditor.ui.REPSelectWindow; +import remoteeditor.ui.RepInputDialog; + public class RemoteEditorAction implements IWorkbenchWindowActionDelegate { public RemoteEditorAction(){ @@ -29,6 +33,7 @@ public void run(IAction action) { IWorkbench workbench = PlatformUI.getWorkbench(); + //Display display = workbench.getDisplay(); IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow(); IWorkbenchPage workbenchPage = workbenchWindow.getActivePage(); IEditorPart editorPart = workbenchPage.getActiveEditor(); @@ -40,6 +45,11 @@ //System.out.println(editorinput.getName()); + //ComboSample1 combo = new ComboSample1(display); + //combo.addText(); + //combo.open(); + + try { editorPart = workbenchPage.openEditor(editorinput, "remoteeditor.editors.RemoteEditor"); System.out.println("test");
--- a/src/remoteeditor/editors/RemoteEditor.java Tue Mar 20 16:19:47 2007 +0900 +++ b/src/remoteeditor/editors/RemoteEditor.java Fri Apr 06 01:36:23 2007 +0900 @@ -13,6 +13,10 @@ import org.eclipse.jface.text.TextEvent; import org.eclipse.jface.text.source.ISourceViewer; import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.PlatformUI; import org.eclipse.ui.editors.text.TextEditor; import remoteeditor.command.REPCommand; @@ -23,6 +27,7 @@ import remoteeditor.network.REPPacketSend; import remoteeditor.network.RSocketEvent; import remoteeditor.network.RSocketListener; +import remoteeditor.ui.REPSelectWindow; import sample.merge.Translate; @@ -43,7 +48,7 @@ private int myseq = 0; private int mysid = 0; private String filename = "afro"; - + public RemoteEditor() { super(); //filename = this.getEditorInput().getName(); @@ -70,9 +75,24 @@ e.printStackTrace(); } repreceive = new REPPacketReceive(sc); + repsend = new REPPacketSend(sc); + + + IWorkbench workbench = PlatformUI.getWorkbench(); + Display display = workbench.getDisplay(); + REPSelectWindow selectwindow = new REPSelectWindow(display); + selectwindow.initWindow(); + selectwindow.setName(this.getEditorInput().getName()); + selectwindow.setChannel(sc); + selectwindow.open(); + + //String sessionlist = selectwindow.getSessionList(); + //String sessionID = selectwindow.getSessionName(); + + //joinPart(); + REPCommand temp = repreceive.unpack(); + myeid = temp.eid; mysid = temp.sid; repreceive.addCommandListener(this); - repsend = new REPPacketSend(sc); - joinPart(); } @@ -178,6 +198,13 @@ case REP.REP_SELECT_ACK_CMD: break; + case REP.REP_INSERT_CMD: + try { + changeText(command.cmd, command.lineno, command.len, command.string); + } catch (Exception e) { + e.printStackTrace(); + } + break; } } }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/remoteeditor/ui/REPSelectWindow.java Fri Apr 06 01:36:23 2007 +0900 @@ -0,0 +1,144 @@ +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()); + } + } +}