diff options
| author | slewis | 2005-04-01 03:19:48 +0000 |
|---|---|---|
| committer | slewis | 2005-04-01 03:19:48 +0000 |
| commit | 4d513db02096f985e26baf004b1ffcfb5e41c1b0 (patch) | |
| tree | 595aae9e25aa9fa145972a587be134488af74bf2 | |
| parent | f154c5ee97b032d609d531a45ece5a31f54dc2e9 (diff) | |
| download | org.eclipse.ecf-4d513db02096f985e26baf004b1ffcfb5e41c1b0.tar.gz org.eclipse.ecf-4d513db02096f985e26baf004b1ffcfb5e41c1b0.tar.xz org.eclipse.ecf-4d513db02096f985e26baf004b1ffcfb5e41c1b0.zip | |
Fixed file transfer, file send and launch, send message
5 files changed, 92 insertions, 73 deletions
diff --git a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/EclipseMessage.java b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/EclipseMessage.java index ccf0feafe..e36ba0aa5 100644 --- a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/EclipseMessage.java +++ b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/EclipseMessage.java @@ -1,19 +1,17 @@ /**************************************************************************** -* Copyright (c) 2004 Composent, Inc. and others. -* All rights reserved. This program and the accompanying materials -* are made available under the terms of the Eclipse Public License v1.0 -* which accompanies this distribution, and is available at -* http://www.eclipse.org/legal/epl-v10.html -* -* Contributors: -* Composent, Inc. - initial API and implementation -*****************************************************************************/ - + * Copyright (c) 2004 Composent, Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Composent, Inc. - initial API and implementation + *****************************************************************************/ package org.eclipse.ecf.example.collab.share; import java.util.HashMap; import java.util.Map; - import org.eclipse.ecf.core.ISharedObjectConfig; import org.eclipse.ecf.core.SharedObjectDescription; import org.eclipse.ecf.core.SharedObjectInitException; @@ -22,71 +20,75 @@ import org.eclipse.ecf.example.collab.Trace; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.swt.widgets.Display; - public class EclipseMessage extends GenericSharedObject { - - public static final Trace trace = Trace.create("eclipsemessagesharedobject"); - - String message; - String sender; + public static final Trace trace = Trace + .create("eclipsemessagesharedobject"); + String message; + String sender; + + public EclipseMessage() { + sender = "<unknown>"; + message = " says hello"; + } - public EclipseMessage() { - sender = "<unknown>"; - message = " says hello"; - } - public EclipseMessage(String message, String sender) { - this.message = message; - this.sender = sender; - } - protected void trace(String msg) { - if (Trace.ON && trace != null) { - trace.msg(msg); + public EclipseMessage(String message, String sender) { + this.message = message; + this.sender = sender; + } + + protected void trace(String msg) { + if (Trace.ON && trace != null) { + trace.msg(msg); } } + protected void traceDump(String msg, Throwable e) { if (Trace.ON && trace != null) { - trace.dumpStack(e,msg); + trace.dumpStack(e, msg); } } - public void init(ISharedObjectConfig config) throws SharedObjectInitException { + + public void init(ISharedObjectConfig config) + throws SharedObjectInitException { super.init(config); Map aMap = config.getProperties(); - Object [] args = (Object []) aMap.get("args"); + Object[] args = (Object[]) aMap.get("args"); if (args != null && args.length == 2) { this.message = (String) args[0]; this.sender = (String) args[1]; } } - public void activated(ID[] others) { - // Note: be sure to call super.activated first so - // replication gets done - super.activated(others); - showMessage(message, sender); - } - protected SharedObjectDescription getReplicaDescription(ID remoteID) { - Object[] remoteArgs = { message, sender }; - HashMap map = new HashMap(); - map.put("args",remoteArgs); - return new SharedObjectDescription( - getHomeContainerID(), - getClass().getName(),map, - replicateID++); - } - protected void showMessage(final String message, final String sender) { - final String msg = sender + " says '" + message + "'"; - try { - Display.getDefault().syncExec(new Runnable() { - public void run() { - Display.getDefault().beep(); - MessageDialog.openInformation( - null, - "Message from " + sender, - msg); - } - }); - } catch (Exception e) { - traceDump("Exception showing message dialog ",e); - } - destroySelf(); - } + + public void activated(ID[] others) { + // Note: be sure to call super.activated first so + // replication gets done + super.activated(others); + showMessage(message, sender); + } + + protected SharedObjectDescription getReplicaDescription(ID remoteID) { + Object[] remoteArgs = { message, sender }; + HashMap map = new HashMap(); + map.put("args", remoteArgs); + return new SharedObjectDescription(getHomeContainerID(), getClass() + .getName(), map, replicateID++); + } + + protected void showMessage(final String message, final String sender) { + final String msg = sender + " says '" + message + "'"; + try { + if (!getContext().isGroupManager()) { + Display.getDefault().syncExec(new Runnable() { + public void run() { + Display.getDefault().beep(); + MessageDialog.openInformation(null, "Message from " + + sender, msg); + } + }); + } + } catch (Exception e) { + traceDump("Exception showing message dialog ", e); + } + destroySelf(); + } } diff --git a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/io/EclipseFileTransfer.java b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/io/EclipseFileTransfer.java index fb48e89ee..30a651565 100644 --- a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/io/EclipseFileTransfer.java +++ b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/io/EclipseFileTransfer.java @@ -144,9 +144,12 @@ public class EclipseFileTransfer extends FileTransferSharedObject implements public void receiveStart(FileTransferSharedObject obj, File aFile, long length, float rate) { - FileReceiver r = new FileReceiver(obj, aFile, length, rate); - Display d = ClientPlugin.getDefault().getActiveShell().getDisplay(); - d.asyncExec(r); + final FileReceiver r = new FileReceiver(obj, aFile, length, rate); + Display.getDefault().syncExec(new Runnable() { + public void run() { + if (r != null) r.run(); + } + }); } public void receiveData(FileTransferSharedObject obj, int dataLength) { diff --git a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/io/EclipseFileTransferAndLaunch.java b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/io/EclipseFileTransferAndLaunch.java index 52e7171d8..430cdbbfb 100644 --- a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/io/EclipseFileTransferAndLaunch.java +++ b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/io/EclipseFileTransferAndLaunch.java @@ -11,7 +11,9 @@ package org.eclipse.ecf.example.collab.share.io; +import java.io.File; import org.eclipse.ecf.example.collab.ClientPlugin; +import org.eclipse.ecf.example.collab.share.EclipseCollabSharedObject; import org.eclipse.ecf.example.collab.ui.MessageLoader; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.swt.program.Program; @@ -30,8 +32,20 @@ public class EclipseFileTransferAndLaunch } else { System.out.println("Sending done for: "+transferParams.getRemoteFile()); } - // Now launch file locally - if (e == null) launchFile(transferParams.getRemoteFile().getAbsolutePath()); + EclipseCollabSharedObject sender = null; + try { + sender = (EclipseCollabSharedObject) getContext() + .getSharedObjectManager().getSharedObject(eclipseStageID); + } catch (Exception except) { + // Should never happen + except.printStackTrace(System.err); + } + if (sender != null) { + String senderPath = sender.getLocalFullDownloadPath(); + File senderLaunch = new File(new File(senderPath),transferParams.getRemoteFile().getName()); + // Now launch file locally + if (e == null) launchFile(senderLaunch.getAbsolutePath()); + } } protected void launchFile(String fileName) { try { @@ -52,10 +66,10 @@ public class EclipseFileTransferAndLaunch if (receiverUI != null) { receiverUI.receiveDone(getHomeContainerID(),localFile,e); } else { - System.out.println("Receiving done for: "+localFile); + System.out.println("Receive done for: "+localFile); } // Now...we launch the file - if (e == null) { + if (e == null && localFile != null) { launchFile(localFile.getAbsolutePath()); } } diff --git a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/io/FileTransferSharedObject.java b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/io/FileTransferSharedObject.java index 97c7ed36b..964a78638 100644 --- a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/io/FileTransferSharedObject.java +++ b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/io/FileTransferSharedObject.java @@ -113,7 +113,7 @@ public class FileTransferSharedObject extends TransactionSharedObject } } } catch (Exception e) { - debug(e,"Exception sending failure back to host"); + debug(e,"Exception in receive start"); try { // Respond with create failure message back to host getContext().sendCreateResponse(getHomeContainerID(), e, getIdentifier()); diff --git a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/url/ExecURL.java b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/url/ExecURL.java index 964fd765f..64ee215ea 100644 --- a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/url/ExecURL.java +++ b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/url/ExecURL.java @@ -68,8 +68,8 @@ public class ExecURL extends GenericSharedObject { } protected SharedObjectDescription getReplicaDescription(ID remoteMember) { - String types[] = { String.class.getName()}; - Object args[] = { url }; + String types[] = { ID.class.getName(), String.class.getName()}; + Object args[] = { receiver, url }; HashMap map = new HashMap(); map.put("args",args); map.put("types",types); |
