Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis2007-11-02 05:15:51 +0000
committerslewis2007-11-02 05:15:51 +0000
commit019904d3de795fd809bd11972c7aacd498f8916d (patch)
treec25901861e6777623e2f49ec08981404781e77e2 /framework/bundles/org.eclipse.ecf.presence.collab.ui
parent83718c9fc69fffda8833a0d41a682865857e4d2d (diff)
downloadorg.eclipse.ecf-019904d3de795fd809bd11972c7aacd498f8916d.tar.gz
org.eclipse.ecf-019904d3de795fd809bd11972c7aacd498f8916d.tar.xz
org.eclipse.ecf-019904d3de795fd809bd11972c7aacd498f8916d.zip
Modified URL sharing and View sharing to work with drag and drop. Also started listeners automatically.
Diffstat (limited to 'framework/bundles/org.eclipse.ecf.presence.collab.ui')
-rw-r--r--framework/bundles/org.eclipse.ecf.presence.collab.ui/.settings/org.eclipse.jdt.core.prefs69
-rw-r--r--framework/bundles/org.eclipse.ecf.presence.collab.ui/plugin.xml21
-rw-r--r--framework/bundles/org.eclipse.ecf.presence.collab.ui/src/org/eclipse/ecf/internal/presence/collab/ui/Activator.java18
-rw-r--r--framework/bundles/org.eclipse.ecf.presence.collab.ui/src/org/eclipse/ecf/internal/presence/collab/ui/Messages.java2
-rw-r--r--framework/bundles/org.eclipse.ecf.presence.collab.ui/src/org/eclipse/ecf/internal/presence/collab/ui/StartURLShareAndViewShare.java97
-rw-r--r--framework/bundles/org.eclipse.ecf.presence.collab.ui/src/org/eclipse/ecf/internal/presence/collab/ui/messages.properties4
-rw-r--r--framework/bundles/org.eclipse.ecf.presence.collab.ui/src/org/eclipse/ecf/presence/collab/ui/url/URLRosterViewerDropTarget.java65
-rw-r--r--framework/bundles/org.eclipse.ecf.presence.collab.ui/src/org/eclipse/ecf/presence/collab/ui/url/URLShare.java95
-rw-r--r--framework/bundles/org.eclipse.ecf.presence.collab.ui/src/org/eclipse/ecf/presence/collab/ui/url/URLShareRosterContributionItem.java59
-rw-r--r--framework/bundles/org.eclipse.ecf.presence.collab.ui/src/org/eclipse/ecf/presence/collab/ui/url/URLShareRosterEntryContributionItem.java23
-rw-r--r--framework/bundles/org.eclipse.ecf.presence.collab.ui/src/org/eclipse/ecf/presence/collab/ui/view/ViewShare.java104
-rw-r--r--framework/bundles/org.eclipse.ecf.presence.collab.ui/src/org/eclipse/ecf/presence/collab/ui/view/ViewShareRosterContributionItem.java57
-rw-r--r--framework/bundles/org.eclipse.ecf.presence.collab.ui/src/org/eclipse/ecf/presence/collab/ui/view/ViewShareRosterEntryContributionItem.java24
13 files changed, 421 insertions, 217 deletions
diff --git a/framework/bundles/org.eclipse.ecf.presence.collab.ui/.settings/org.eclipse.jdt.core.prefs b/framework/bundles/org.eclipse.ecf.presence.collab.ui/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 000000000..652b088ac
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.presence.collab.ui/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,69 @@
+#Thu Nov 01 22:09:18 PDT 2007
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.doc.comment.support=enabled
+org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
+org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
+org.eclipse.jdt.core.compiler.problem.deprecation=warning
+org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
+org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
+org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
+org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
+org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
+org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled
+org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
+org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
+org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
+org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
+org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
+org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore
+org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
+org.eclipse.jdt.core.compiler.problem.invalidJavadoc=error
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=enabled
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=enabled
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=enabled
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=public
+org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
+org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
+org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore
+org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=enabled
+org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public
+org.eclipse.jdt.core.compiler.problem.missingJavadocTags=error
+org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=enabled
+org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=public
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
+org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
+org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
+org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
+org.eclipse.jdt.core.compiler.problem.nullReference=ignore
+org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
+org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
+org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore
+org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore
+org.eclipse.jdt.core.compiler.problem.rawTypeReference=ignore
+org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
+org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
+org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
+org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
+org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
+org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
+org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=ignore
+org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
+org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
+org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
+org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore
+org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
+org.eclipse.jdt.core.compiler.problem.unusedImport=warning
+org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
+org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
+org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
+org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
+org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
+org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
diff --git a/framework/bundles/org.eclipse.ecf.presence.collab.ui/plugin.xml b/framework/bundles/org.eclipse.ecf.presence.collab.ui/plugin.xml
index 0a5ba4905..36734a450 100644
--- a/framework/bundles/org.eclipse.ecf.presence.collab.ui/plugin.xml
+++ b/framework/bundles/org.eclipse.ecf.presence.collab.ui/plugin.xml
@@ -35,5 +35,26 @@
id="org.eclipse.ecf.presence.collab.ui.dynamic5">
</dynamic>
</menuContribution>
+ <menuContribution
+ locationURI="popup:org.eclipse.ecf.presence.ui.MultiRosterView?before=additions">
+ <dynamic
+ class="org.eclipse.ecf.presence.ui.menu.NoopRosterMenuContributionItem"
+ id="org.eclipse.ecf.presence.collab.ui.dynamic5">
+ </dynamic>
+ </menuContribution>
+ </extension>
+ <extension
+ point="org.eclipse.ecf.presence.ui.rosterViewerDropTarget">
+ <dropTarget
+ class="org.eclipse.ecf.presence.collab.ui.url.URLRosterViewerDropTarget">
+ </dropTarget>
+ </extension>
+ <extension
+ point="org.eclipse.ecf.start">
+ <run
+ class="org.eclipse.ecf.internal.presence.collab.ui.StartURLShareAndViewShare">
+ </run>
</extension>
+
+
</plugin>
diff --git a/framework/bundles/org.eclipse.ecf.presence.collab.ui/src/org/eclipse/ecf/internal/presence/collab/ui/Activator.java b/framework/bundles/org.eclipse.ecf.presence.collab.ui/src/org/eclipse/ecf/internal/presence/collab/ui/Activator.java
index 1cb0ce846..5c9946df7 100644
--- a/framework/bundles/org.eclipse.ecf.presence.collab.ui/src/org/eclipse/ecf/internal/presence/collab/ui/Activator.java
+++ b/framework/bundles/org.eclipse.ecf.presence.collab.ui/src/org/eclipse/ecf/internal/presence/collab/ui/Activator.java
@@ -10,8 +10,10 @@
*****************************************************************************/
package org.eclipse.ecf.internal.presence.collab.ui;
+import org.eclipse.ecf.core.IContainerManager;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
+import org.osgi.util.tracker.ServiceTracker;
/**
* The activator class controls the plug-in life cycle
@@ -24,6 +26,10 @@ public class Activator extends AbstractUIPlugin {
// The shared instance
private static Activator plugin;
+ private BundleContext context;
+
+ private ServiceTracker containerManagerTracker;
+
/**
* The constructor
*/
@@ -38,6 +44,7 @@ public class Activator extends AbstractUIPlugin {
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
+ this.context = context;
}
/*
@@ -46,6 +53,10 @@ public class Activator extends AbstractUIPlugin {
* @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
*/
public void stop(BundleContext context) throws Exception {
+ if (containerManagerTracker != null) {
+ containerManagerTracker.close();
+ containerManagerTracker = null;
+ }
plugin = null;
super.stop(context);
}
@@ -59,4 +70,11 @@ public class Activator extends AbstractUIPlugin {
return plugin;
}
+ public IContainerManager getContainerManager() {
+ if (containerManagerTracker == null) {
+ containerManagerTracker = new ServiceTracker(context, IContainerManager.class.getName(), null);
+ containerManagerTracker.open();
+ }
+ return (IContainerManager) containerManagerTracker.getService();
+ }
}
diff --git a/framework/bundles/org.eclipse.ecf.presence.collab.ui/src/org/eclipse/ecf/internal/presence/collab/ui/Messages.java b/framework/bundles/org.eclipse.ecf.presence.collab.ui/src/org/eclipse/ecf/internal/presence/collab/ui/Messages.java
index be39a7bec..8478bf72a 100644
--- a/framework/bundles/org.eclipse.ecf.presence.collab.ui/src/org/eclipse/ecf/internal/presence/collab/ui/Messages.java
+++ b/framework/bundles/org.eclipse.ecf.presence.collab.ui/src/org/eclipse/ecf/internal/presence/collab/ui/Messages.java
@@ -32,6 +32,8 @@ public class Messages extends NLS {
public static String URLShare_INPUT_URL_DIALOG_TITLE;
public static String URLShare_RECEIVED_URL_MESSAGE;
public static String URLShare_RECEIVED_URL_TITLE;
+ public static String StartURLShareAndViewShare_ERROR_CONTAINERMANAGER_NOT_ACCESSIBLE;
+ public static String StartURLShareAndViewShare_STATUS_URLSHARE_NOT_CREATED;
public static String URLShareRosterContributionItem_ADD_URL_SHARE_MENU_TEXT;
public static String URLShareRosterContributionItem_BROWSER_ICON;
public static String URLShareRosterContributionItem_REMOVE_URL_SHARE_MENU_TEXT;
diff --git a/framework/bundles/org.eclipse.ecf.presence.collab.ui/src/org/eclipse/ecf/internal/presence/collab/ui/StartURLShareAndViewShare.java b/framework/bundles/org.eclipse.ecf.presence.collab.ui/src/org/eclipse/ecf/internal/presence/collab/ui/StartURLShareAndViewShare.java
new file mode 100644
index 000000000..294e68dd7
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.presence.collab.ui/src/org/eclipse/ecf/internal/presence/collab/ui/StartURLShareAndViewShare.java
@@ -0,0 +1,97 @@
+/****************************************************************************
+ * Copyright (c) 20047 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.internal.presence.collab.ui;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.ecf.core.IContainer;
+import org.eclipse.ecf.core.IContainerListener;
+import org.eclipse.ecf.core.IContainerManager;
+import org.eclipse.ecf.core.IContainerManagerListener;
+import org.eclipse.ecf.core.events.IContainerConnectedEvent;
+import org.eclipse.ecf.core.events.IContainerDisconnectedEvent;
+import org.eclipse.ecf.core.events.IContainerEvent;
+import org.eclipse.ecf.core.start.IECFStart;
+import org.eclipse.ecf.core.util.ECFException;
+import org.eclipse.ecf.datashare.IChannelContainerAdapter;
+import org.eclipse.ecf.presence.collab.ui.url.URLShare;
+import org.eclipse.ecf.presence.collab.ui.view.ViewShare;
+import org.eclipse.osgi.util.NLS;
+
+public class StartURLShareAndViewShare implements IECFStart {
+
+ IContainerListener containerListener = new IContainerListener() {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ecf.core.IContainerListener#handleEvent(org.eclipse.ecf.core.events.IContainerEvent)
+ */
+ public void handleEvent(IContainerEvent event) {
+ if (event instanceof IContainerConnectedEvent || event instanceof IContainerDisconnectedEvent) {
+ // connected
+ final IContainerManager containerManager = Activator.getDefault().getContainerManager();
+ if (containerManager == null)
+ return;
+ IContainer container = containerManager.getContainer(event.getLocalContainerID());
+ if (container == null)
+ return;
+ IChannelContainerAdapter cca = (IChannelContainerAdapter) container.getAdapter(IChannelContainerAdapter.class);
+ if (cca == null)
+ return;
+ if (event instanceof IContainerConnectedEvent) {
+ try {
+ URLShare.addURLShare(container.getID(), cca);
+ ViewShare.addViewShare(container.getID(), cca);
+ } catch (ECFException e) {
+ Activator.getDefault().getLog().log(new Status(IStatus.WARNING, Activator.PLUGIN_ID, IStatus.WARNING, NLS.bind(Messages.StartURLShareAndViewShare_STATUS_URLSHARE_NOT_CREATED, container.getID()), null));
+ }
+ } else if (event instanceof IContainerDisconnectedEvent) {
+ // disconnected
+ URLShare.removeURLShare(container.getID());
+ ViewShare.removeViewShare(container.getID());
+ }
+ }
+ }
+
+ };
+
+ IContainerManagerListener containerManagerListener = new IContainerManagerListener() {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ecf.core.IContainerManagerListener#containerAdded(org.eclipse.ecf.core.IContainer)
+ */
+ public void containerAdded(IContainer container) {
+ container.addListener(containerListener);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ecf.core.IContainerManagerListener#containerRemoved(org.eclipse.ecf.core.IContainer)
+ */
+ public void containerRemoved(IContainer container) {
+ container.removeListener(containerListener);
+ }
+ };
+
+ public StartURLShareAndViewShare() {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ecf.core.start.IECFStart#run(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ public IStatus run(IProgressMonitor monitor) {
+ final IContainerManager containerManager = Activator.getDefault().getContainerManager();
+ if (containerManager == null)
+ return new Status(IStatus.WARNING, Activator.PLUGIN_ID, IStatus.WARNING, Messages.StartURLShareAndViewShare_ERROR_CONTAINERMANAGER_NOT_ACCESSIBLE, null);
+ containerManager.addListener(containerManagerListener);
+ return Status.OK_STATUS;
+ }
+}
diff --git a/framework/bundles/org.eclipse.ecf.presence.collab.ui/src/org/eclipse/ecf/internal/presence/collab/ui/messages.properties b/framework/bundles/org.eclipse.ecf.presence.collab.ui/src/org/eclipse/ecf/internal/presence/collab/ui/messages.properties
index bb864f650..662916723 100644
--- a/framework/bundles/org.eclipse.ecf.presence.collab.ui/src/org/eclipse/ecf/internal/presence/collab/ui/messages.properties
+++ b/framework/bundles/org.eclipse.ecf.presence.collab.ui/src/org/eclipse/ecf/internal/presence/collab/ui/messages.properties
@@ -20,7 +20,7 @@ URLShare_ERROR_BROWSER_MESSAGE=Error opening browser
URLShare_EXCEPTION_LOG_BROWSER=Exception in createBrowser
URLShare_RECEIVED_URL_TITLE=Received URL
Share_ERROR_SEND_TITLE=Error sending message
-URLShare_RECEIVED_URL_MESSAGE=Received URL from {0}\n\nDo you want to display?
+URLShare_RECEIVED_URL_MESSAGE=Received URL from {0}:\n\n{1}\n\nDo you want to display in browser?
URLShare_ERROR_BROWSER_TITLE=Error opening browser
Share_ERROR_RECEIVE_TITLE=Error receiving message
Share_ERROR_RECEIVE_MESSAGE=Error receiving message
@@ -29,6 +29,8 @@ Share_EXCEPTION_LOG_MESSAGE=Exception in URLShare.handleMessage
Share_ERROR_SEND_MESSAGE=Error sending message: {0}
Share_ERROR_SEND_TITLE=Error sending message
ViewShareRosterEntryContributionItem_VIEWSHARE_MENU_TEXT=Send Show View Request...
+StartURLShareAndViewShare_ERROR_CONTAINERMANAGER_NOT_ACCESSIBLE=ContainerManager service could not be accessed
+StartURLShareAndViewShare_STATUS_URLSHARE_NOT_CREATED=URLShare for container {0} could not be created.
ViewShareRosterContributionItem_VIEWSHARE_LISTENER_MENU_ADD_TEXT=Add Show View Listener
ViewShareRosterContributionItem_VIEWSHARE_LISTENER_MENU_REMOVE_TEXT=Remove View Open Listener
ViewShare_VIEWSHARE_RECEIVED_REQUEST_TITLE=Received Show View Request
diff --git a/framework/bundles/org.eclipse.ecf.presence.collab.ui/src/org/eclipse/ecf/presence/collab/ui/url/URLRosterViewerDropTarget.java b/framework/bundles/org.eclipse.ecf.presence.collab.ui/src/org/eclipse/ecf/presence/collab/ui/url/URLRosterViewerDropTarget.java
new file mode 100644
index 000000000..e35534195
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.presence.collab.ui/src/org/eclipse/ecf/presence/collab/ui/url/URLRosterViewerDropTarget.java
@@ -0,0 +1,65 @@
+package org.eclipse.ecf.presence.collab.ui.url;
+
+import java.net.URL;
+
+import org.eclipse.ecf.core.IContainer;
+import org.eclipse.ecf.presence.IPresenceContainerAdapter;
+import org.eclipse.ecf.presence.roster.IRosterEntry;
+import org.eclipse.ecf.presence.roster.IRosterItem;
+import org.eclipse.ecf.presence.ui.dnd.IRosterViewerDropTarget;
+import org.eclipse.swt.dnd.TextTransfer;
+import org.eclipse.swt.dnd.TransferData;
+
+public class URLRosterViewerDropTarget implements IRosterViewerDropTarget {
+
+ IRosterEntry rosterEntry;
+
+ public boolean performDrop(Object data) {
+ if (rosterEntry == null)
+ return false;
+ final URLShare urlshare = getURLShare(rosterEntry);
+ if (urlshare == null)
+ return false;
+ try {
+ String s = (String) data;
+ s = s.substring(0, s.indexOf("\n")); //$NON-NLS-1$
+ final URL anURL = new URL(s);
+ urlshare.sendURL(rosterEntry.getUser().getName(), rosterEntry.getUser().getID(), anURL.toExternalForm());
+ } catch (final Exception e) {
+ return false;
+ }
+ return true;
+ }
+
+ private URLShare getURLShare(IRosterEntry rosterEntry) {
+ final IPresenceContainerAdapter pca = rosterEntry.getRoster().getPresenceContainerAdapter();
+ if (pca == null)
+ return null;
+ final IContainer container = (IContainer) pca.getAdapter(IContainer.class);
+ if (container == null)
+ return null;
+ return URLShare.getURLShare(container.getID());
+ }
+
+ public boolean validateDrop(IRosterItem rosterItem, int operation, TransferData transferType) {
+ if (!TextTransfer.getInstance().isSupportedType(transferType))
+ return false;
+ if (rosterItem instanceof IRosterEntry) {
+ final Object data = TextTransfer.getInstance().nativeToJava(transferType);
+ // Check to see if URL...if not, return false;
+ try {
+ new URL((String) data);
+ } catch (final Exception e) {
+ rosterEntry = null;
+ return false;
+ }
+ // Check to see that URLShare exists for roster entry
+ if (getURLShare((IRosterEntry) rosterItem) == null)
+ return false;
+ rosterEntry = (IRosterEntry) rosterItem;
+ return true;
+ }
+ return false;
+ }
+
+}
diff --git a/framework/bundles/org.eclipse.ecf.presence.collab.ui/src/org/eclipse/ecf/presence/collab/ui/url/URLShare.java b/framework/bundles/org.eclipse.ecf.presence.collab.ui/src/org/eclipse/ecf/presence/collab/ui/url/URLShare.java
index 788ea9ff9..276982110 100644
--- a/framework/bundles/org.eclipse.ecf.presence.collab.ui/src/org/eclipse/ecf/presence/collab/ui/url/URLShare.java
+++ b/framework/bundles/org.eclipse.ecf.presence.collab.ui/src/org/eclipse/ecf/presence/collab/ui/url/URLShare.java
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 2004 Composent, Inc. and others.
+ * Copyright (c) 20047 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
@@ -16,6 +16,7 @@ import java.io.ByteArrayOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.URL;
+import java.util.Hashtable;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IStatus;
@@ -41,8 +42,21 @@ public class URLShare extends AbstractShare {
private ID containerID = null;
- public URLShare(ID containerID, IChannelContainerAdapter adapter)
- throws ECFException {
+ private static Hashtable urlsharechannels = new Hashtable();
+
+ public static URLShare getURLShare(ID containerID) {
+ return (URLShare) urlsharechannels.get(containerID);
+ }
+
+ public static URLShare addURLShare(ID containerID, IChannelContainerAdapter channelAdapter) throws ECFException {
+ return (URLShare) urlsharechannels.put(containerID, new URLShare(containerID, channelAdapter));
+ }
+
+ public static URLShare removeURLShare(ID containerID) {
+ return (URLShare) urlsharechannels.remove(containerID);
+ }
+
+ public URLShare(ID containerID, IChannelContainerAdapter adapter) throws ECFException {
super(adapter);
Assert.isNotNull(containerID);
this.containerID = containerID;
@@ -53,9 +67,7 @@ public class URLShare extends AbstractShare {
}
private void logError(String exceptionString, Throwable e) {
- Activator.getDefault().getLog().log(
- new Status(IStatus.ERROR, Activator.PLUGIN_ID, IStatus.ERROR,
- exceptionString, e));
+ Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, IStatus.ERROR, exceptionString, e));
}
@@ -70,22 +82,14 @@ public class URLShare extends AbstractShare {
private void showURL(final String user, final String url) {
Display.getDefault().asyncExec(new Runnable() {
public void run() {
- if (MessageDialog.openQuestion(null,
- Messages.URLShare_RECEIVED_URL_TITLE, NLS.bind(
- Messages.URLShare_RECEIVED_URL_MESSAGE, user))) {
- IWorkbenchBrowserSupport support = PlatformUI
- .getWorkbench().getBrowserSupport();
+ if (MessageDialog.openQuestion(null, Messages.URLShare_RECEIVED_URL_TITLE, NLS.bind(Messages.URLShare_RECEIVED_URL_MESSAGE, user, url))) {
+ final IWorkbenchBrowserSupport support = PlatformUI.getWorkbench().getBrowserSupport();
IWebBrowser browser;
try {
browser = support.createBrowser(null);
browser.openURL(new URL(url));
- } catch (Exception e) {
- showErrorToUser(
- Messages.URLShare_ERROR_BROWSER_TITLE,
- NLS
- .bind(
- Messages.URLShare_ERROR_BROWSER_MESSAGE,
- e.getLocalizedMessage()));
+ } catch (final Exception e) {
+ showErrorToUser(Messages.URLShare_ERROR_BROWSER_TITLE, NLS.bind(Messages.URLShare_ERROR_BROWSER_MESSAGE, e.getLocalizedMessage()));
logError(Messages.URLShare_EXCEPTION_LOG_BROWSER, e);
}
}
@@ -93,31 +97,34 @@ public class URLShare extends AbstractShare {
});
}
- public void sendURL(final String senderuser, final ID toID) {
+ public void sendURL(final String senderuser, final ID toID, final String theURL) {
+ try {
+ sendMessage(toID, serialize(new Object[] {senderuser, theURL}));
+ } catch (final ECFException e) {
+ showErrorToUser(Messages.Share_ERROR_SEND_TITLE, NLS.bind(Messages.Share_ERROR_SEND_MESSAGE, e.getStatus().getException().getLocalizedMessage()));
+ logError(e.getStatus());
+ } catch (final Exception e) {
+ showErrorToUser(Messages.Share_ERROR_SEND_TITLE, NLS.bind(Messages.Share_ERROR_SEND_MESSAGE, e.getLocalizedMessage()));
+ logError(Messages.Share_EXCEPTION_LOG_SEND, e);
+ }
+ }
+
+ public void showDialogAndSendURL(final String senderuser, final ID toID) {
Display.getDefault().asyncExec(new Runnable() {
public void run() {
- InputDialog input = new InputDialog(null,
- Messages.URLShare_INPUT_URL_DIALOG_TITLE,
- Messages.URLShare_ENTER_URL_DIALOG_TEXT,
- Messages.URLShare_ENTER_URL_DEFAULT_URL, null);
+ final InputDialog input = new InputDialog(null, Messages.URLShare_INPUT_URL_DIALOG_TITLE, Messages.URLShare_ENTER_URL_DIALOG_TEXT, Messages.URLShare_ENTER_URL_DEFAULT_URL, null);
input.setBlockOnOpen(true);
- int result = input.open();
+ final int result = input.open();
if (result == InputDialog.OK) {
- String send = input.getValue();
+ final String send = input.getValue();
if (send != null && !send.equals("")) { //$NON-NLS-1$
try {
- sendMessage(toID, serialize(new Object[] {
- senderuser, send }));
- } catch (ECFException e) {
- showErrorToUser(Messages.Share_ERROR_SEND_TITLE,
- NLS.bind(Messages.Share_ERROR_SEND_MESSAGE,
- e.getStatus().getException()
- .getLocalizedMessage()));
+ sendMessage(toID, serialize(new Object[] {senderuser, send}));
+ } catch (final ECFException e) {
+ showErrorToUser(Messages.Share_ERROR_SEND_TITLE, NLS.bind(Messages.Share_ERROR_SEND_MESSAGE, e.getStatus().getException().getLocalizedMessage()));
logError(e.getStatus());
- } catch (Exception e) {
- showErrorToUser(Messages.Share_ERROR_SEND_TITLE,
- NLS.bind(Messages.Share_ERROR_SEND_MESSAGE,
- e.getLocalizedMessage()));
+ } catch (final Exception e) {
+ showErrorToUser(Messages.Share_ERROR_SEND_TITLE, NLS.bind(Messages.Share_ERROR_SEND_MESSAGE, e.getLocalizedMessage()));
logError(Messages.Share_EXCEPTION_LOG_SEND, e);
}
}
@@ -133,26 +140,24 @@ public class URLShare extends AbstractShare {
*/
protected void handleMessage(ID fromContainerID, byte[] data) {
try {
- Object[] msg = (Object[]) deserialize(data);
+ final Object[] msg = (Object[]) deserialize(data);
showURL((String) msg[0], (String) msg[1]);
- } catch (Exception e) {
- showErrorToUser(Messages.Share_ERROR_RECEIVE_TITLE, NLS.bind(
- Messages.Share_ERROR_RECEIVE_MESSAGE, e
- .getLocalizedMessage()));
+ } catch (final Exception e) {
+ showErrorToUser(Messages.Share_ERROR_RECEIVE_TITLE, NLS.bind(Messages.Share_ERROR_RECEIVE_MESSAGE, e.getLocalizedMessage()));
logError(Messages.Share_EXCEPTION_LOG_MESSAGE, e);
}
}
protected byte[] serialize(Object o) throws Exception {
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
- ObjectOutputStream oos = new ObjectOutputStream(bos);
+ final ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ final ObjectOutputStream oos = new ObjectOutputStream(bos);
oos.writeObject(o);
return bos.toByteArray();
}
protected Object deserialize(byte[] bytes) throws Exception {
- ByteArrayInputStream bins = new ByteArrayInputStream(bytes);
- ObjectInputStream oins = new ObjectInputStream(bins);
+ final ByteArrayInputStream bins = new ByteArrayInputStream(bytes);
+ final ObjectInputStream oins = new ObjectInputStream(bins);
return oins.readObject();
}
}
diff --git a/framework/bundles/org.eclipse.ecf.presence.collab.ui/src/org/eclipse/ecf/presence/collab/ui/url/URLShareRosterContributionItem.java b/framework/bundles/org.eclipse.ecf.presence.collab.ui/src/org/eclipse/ecf/presence/collab/ui/url/URLShareRosterContributionItem.java
index 0cef175ff..c5527550f 100644
--- a/framework/bundles/org.eclipse.ecf.presence.collab.ui/src/org/eclipse/ecf/presence/collab/ui/url/URLShareRosterContributionItem.java
+++ b/framework/bundles/org.eclipse.ecf.presence.collab.ui/src/org/eclipse/ecf/presence/collab/ui/url/URLShareRosterContributionItem.java
@@ -10,8 +10,6 @@
*****************************************************************************/
package org.eclipse.ecf.presence.collab.ui.url;
-import java.util.Hashtable;
-
import org.eclipse.ecf.core.IContainer;
import org.eclipse.ecf.core.identity.ID;
import org.eclipse.ecf.core.util.ECFException;
@@ -23,10 +21,7 @@ import org.eclipse.ecf.presence.ui.roster.AbstractRosterContributionItem;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IAction;
-public class URLShareRosterContributionItem extends
- AbstractRosterContributionItem {
-
- private static Hashtable urlsharechannels = new Hashtable();
+public class URLShareRosterContributionItem extends AbstractRosterContributionItem {
public URLShareRosterContributionItem() {
}
@@ -35,68 +30,48 @@ public class URLShareRosterContributionItem extends
super(id);
}
- protected static URLShare getURLShare(ID containerID) {
- return (URLShare) urlsharechannels.get(containerID);
- }
-
- protected static URLShare addURLShare(ID containerID, URLShare urlshare) {
- return (URLShare) urlsharechannels.put(containerID, urlshare);
- }
-
- protected static URLShare removeURLShare(ID containerID) {
- return (URLShare) urlsharechannels.remove(containerID);
- }
-
- private IAction[] createActionAdd(final ID containerID,
- final IChannelContainerAdapter channelAdapter) {
- IAction action = new Action() {
+ private IAction[] createActionAdd(final ID containerID, final IChannelContainerAdapter channelAdapter) {
+ final IAction action = new Action() {
public void run() {
try {
- addURLShare(containerID, new URLShare(containerID, channelAdapter));
+ URLShare.addURLShare(containerID, channelAdapter);
} catch (ECFException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
};
- action
- .setText(Messages.URLShareRosterContributionItem_ADD_URL_SHARE_MENU_TEXT);
- action.setImageDescriptor(Activator.imageDescriptorFromPlugin(
- Activator.PLUGIN_ID, Messages.URLShareRosterContributionItem_BROWSER_ICON));
- return new IAction[] { action };
+ action.setText(Messages.URLShareRosterContributionItem_ADD_URL_SHARE_MENU_TEXT);
+ action.setImageDescriptor(Activator.imageDescriptorFromPlugin(Activator.PLUGIN_ID, Messages.URLShareRosterContributionItem_BROWSER_ICON));
+ return new IAction[] {action};
}
- private IAction[] createActionRemove(final ID containerID,
- final URLShare urlshare) {
- IAction action = new Action() {
+ private IAction[] createActionRemove(final ID containerID, final URLShare urlshare) {
+ final IAction action = new Action() {
public void run() {
- removeURLShare(containerID);
+ URLShare.removeURLShare(containerID);
urlshare.dispose();
}
};
- action
- .setText(Messages.URLShareRosterContributionItem_REMOVE_URL_SHARE_MENU_TEXT);
- action.setImageDescriptor(Activator.imageDescriptorFromPlugin(
- Activator.PLUGIN_ID, Messages.URLShareRosterContributionItem_BROWSER_ICON));
- return new IAction[] { action };
+ action.setText(Messages.URLShareRosterContributionItem_REMOVE_URL_SHARE_MENU_TEXT);
+ action.setImageDescriptor(Activator.imageDescriptorFromPlugin(Activator.PLUGIN_ID, Messages.URLShareRosterContributionItem_BROWSER_ICON));
+ return new IAction[] {action};
}
protected IAction[] makeActions() {
final IRoster roster = getSelectedRoster();
if (roster != null) {
// Roster is selected
- IContainer c = getContainerForRoster(roster);
+ final IContainer c = getContainerForRoster(roster);
if (c != null) {
// Get existing urlshare for this container (if it exists)
- URLShare urlshare = getURLShare(c.getID());
+ final URLShare urlshare = URLShare.getURLShare(c.getID());
// If it does exist already, then create action to remove
if (urlshare != null)
return createActionRemove(c.getID(), urlshare);
else {
- IChannelContainerAdapter channelAdapter = (IChannelContainerAdapter) c
- .getAdapter(IChannelContainerAdapter.class);
- return (channelAdapter == null) ? null : createActionAdd(c
- .getID(), channelAdapter);
+ final IChannelContainerAdapter channelAdapter = (IChannelContainerAdapter) c.getAdapter(IChannelContainerAdapter.class);
+ return (channelAdapter == null) ? null : createActionAdd(c.getID(), channelAdapter);
}
}
}
diff --git a/framework/bundles/org.eclipse.ecf.presence.collab.ui/src/org/eclipse/ecf/presence/collab/ui/url/URLShareRosterEntryContributionItem.java b/framework/bundles/org.eclipse.ecf.presence.collab.ui/src/org/eclipse/ecf/presence/collab/ui/url/URLShareRosterEntryContributionItem.java
index 1f0f0c507..4ea4d10e3 100644
--- a/framework/bundles/org.eclipse.ecf.presence.collab.ui/src/org/eclipse/ecf/presence/collab/ui/url/URLShareRosterEntryContributionItem.java
+++ b/framework/bundles/org.eclipse.ecf.presence.collab.ui/src/org/eclipse/ecf/presence/collab/ui/url/URLShareRosterEntryContributionItem.java
@@ -19,8 +19,7 @@ import org.eclipse.ecf.presence.ui.roster.AbstractRosterEntryContributionItem;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IAction;
-public class URLShareRosterEntryContributionItem extends
- AbstractRosterEntryContributionItem {
+public class URLShareRosterEntryContributionItem extends AbstractRosterEntryContributionItem {
public URLShareRosterEntryContributionItem() {
}
@@ -32,28 +31,24 @@ public class URLShareRosterEntryContributionItem extends
protected IAction[] makeActions() {
// Else check for Roster entry
final IRosterEntry entry = getSelectedRosterEntry();
- IContainer c = getContainerForRosterEntry(entry);
+ final IContainer c = getContainerForRosterEntry(entry);
// If roster entry is selected and it has a container
if (entry != null && c != null) {
- final IChannelContainerAdapter channelAdapter = (IChannelContainerAdapter) c
- .getAdapter(IChannelContainerAdapter.class);
+ final IChannelContainerAdapter channelAdapter = (IChannelContainerAdapter) c.getAdapter(IChannelContainerAdapter.class);
// If the container has channel container adapter and is online/available
if (channelAdapter != null && isAvailable(entry)) {
- URLShare tmp = URLShareRosterContributionItem.getURLShare(c
- .getID());
+ final URLShare tmp = URLShare.getURLShare(c.getID());
// If there is an URL share associated with this container
if (tmp != null) {
final URLShare urlshare = tmp;
- IAction action = new Action() {
+ final IAction action = new Action() {
public void run() {
- urlshare.sendURL(entry.getRoster().getUser().getName(),entry.getUser().getID());
+ urlshare.showDialogAndSendURL(entry.getRoster().getUser().getName(), entry.getUser().getID());
}
};
- action
- .setText(Messages.URLShareRosterEntryContributionItem_SEND_URL_MENU_TEXT);
- action.setImageDescriptor(Activator.imageDescriptorFromPlugin(
- Activator.PLUGIN_ID, Messages.URLShareRosterContributionItem_BROWSER_ICON));
- return new IAction[] { action };
+ action.setText(Messages.URLShareRosterEntryContributionItem_SEND_URL_MENU_TEXT);
+ action.setImageDescriptor(Activator.imageDescriptorFromPlugin(Activator.PLUGIN_ID, Messages.URLShareRosterContributionItem_BROWSER_ICON));
+ return new IAction[] {action};
}
}
}
diff --git a/framework/bundles/org.eclipse.ecf.presence.collab.ui/src/org/eclipse/ecf/presence/collab/ui/view/ViewShare.java b/framework/bundles/org.eclipse.ecf.presence.collab.ui/src/org/eclipse/ecf/presence/collab/ui/view/ViewShare.java
index aeed630bd..e5f7c5212 100644
--- a/framework/bundles/org.eclipse.ecf.presence.collab.ui/src/org/eclipse/ecf/presence/collab/ui/view/ViewShare.java
+++ b/framework/bundles/org.eclipse.ecf.presence.collab.ui/src/org/eclipse/ecf/presence/collab/ui/view/ViewShare.java
@@ -15,6 +15,7 @@ import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
+import java.util.Hashtable;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IStatus;
@@ -47,10 +48,23 @@ import org.eclipse.ui.views.IViewRegistry;
*/
public class ViewShare extends AbstractShare {
+ private static Hashtable viewSharechannels = new Hashtable();
+
private ID containerID = null;
- public ViewShare(ID containerID, IChannelContainerAdapter adapter)
- throws ECFException {
+ public static ViewShare getViewShare(ID containerID) {
+ return (ViewShare) viewSharechannels.get(containerID);
+ }
+
+ public static ViewShare addViewShare(ID containerID, IChannelContainerAdapter channelAdapter) throws ECFException {
+ return (ViewShare) viewSharechannels.put(containerID, new ViewShare(containerID, channelAdapter));
+ }
+
+ public static ViewShare removeViewShare(ID containerID) {
+ return (ViewShare) viewSharechannels.remove(containerID);
+ }
+
+ public ViewShare(ID containerID, IChannelContainerAdapter adapter) throws ECFException {
super(adapter);
Assert.isNotNull(containerID);
this.containerID = containerID;
@@ -61,9 +75,7 @@ public class ViewShare extends AbstractShare {
}
private void logError(String exceptionString, Throwable e) {
- Activator.getDefault().getLog().log(
- new Status(IStatus.ERROR, Activator.PLUGIN_ID, IStatus.ERROR,
- exceptionString, e));
+ Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, IStatus.ERROR, exceptionString, e));
}
@@ -75,33 +87,21 @@ public class ViewShare extends AbstractShare {
MessageDialog.openError(null, title, message);
}
- private void handleOpenViewRequest(final String user, final String viewID,
- final String secondaryID, final int mode) {
+ private void handleOpenViewRequest(final String user, final String viewID, final String secondaryID, final int mode) {
Display.getDefault().asyncExec(new Runnable() {
public void run() {
// Ask user if they want to display view.
- if (MessageDialog
- .openQuestion(
- null,
- Messages.ViewShare_VIEWSHARE_RECEIVED_REQUEST_TITLE,
- NLS
- .bind(
- Messages.ViewShare_VIEWSHARE_RECEIVED_REQUEST_MESSAGE,
- user))) {
+ if (MessageDialog.openQuestion(null, Messages.ViewShare_VIEWSHARE_RECEIVED_REQUEST_TITLE, NLS.bind(Messages.ViewShare_VIEWSHARE_RECEIVED_REQUEST_MESSAGE, user))) {
try {
- IWorkbenchWindow ww = PlatformUI.getWorkbench()
- .getActiveWorkbenchWindow();
- IWorkbenchPage wp = ww.getActivePage();
+ final IWorkbenchWindow ww = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ final IWorkbenchPage wp = ww.getActivePage();
if (wp == null)
- throw new PartInitException(
- Messages.ViewShare_EXCEPTION_WORKBENCHPAGE_NULL);
+ throw new PartInitException(Messages.ViewShare_EXCEPTION_WORKBENCHPAGE_NULL);
// Actually show view requested
wp.showView(viewID, secondaryID, mode);
- } catch (Exception e) {
- showErrorToUser(Messages.ViewShare_VIEWSHARE_ERROR_DIALOG_TITLE, NLS.bind(
- Messages.ViewShare_VIEWSHARE_ERROR_DIALOG_MESSAGE, e
- .getLocalizedMessage()));
+ } catch (final Exception e) {
+ showErrorToUser(Messages.ViewShare_VIEWSHARE_ERROR_DIALOG_TITLE, NLS.bind(Messages.ViewShare_VIEWSHARE_ERROR_DIALOG_MESSAGE, e.getLocalizedMessage()));
logError(Messages.ViewShare_VIEWSHARE_ERROR_LOG_MESSAGE, e);
}
}
@@ -112,14 +112,11 @@ public class ViewShare extends AbstractShare {
public void sendOpenViewRequest(final String senderuser, final ID toID) {
Display.getDefault().asyncExec(new Runnable() {
public void run() {
- IWorkbenchWindow ww = PlatformUI.getWorkbench()
- .getActiveWorkbenchWindow();
- IWorkbenchPage page = ww.getActivePage();
+ final IWorkbenchWindow ww = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ final IWorkbenchPage page = ww.getActivePage();
if (page == null)
return;
- ElementTreeSelectionDialog dlg = new ElementTreeSelectionDialog(
- null, new ShowViewDialogLabelProvider(),
- new ShowViewDialogTreeContentProvider());
+ final ElementTreeSelectionDialog dlg = new ElementTreeSelectionDialog(null, new ShowViewDialogLabelProvider(), new ShowViewDialogTreeContentProvider());
dlg.setTitle(Messages.ViewShare_VIEWSHARE_VIEW_REQUEST_DIALOG_TITLE);
dlg.setMessage(Messages.ViewShare_VIEWSHARE_VIEW_REQUEST_DIALOG_MESSAGE);
dlg.addFilter(new ShowViewDialogViewerFilter());
@@ -128,41 +125,33 @@ public class ViewShare extends AbstractShare {
public IStatus validate(Object[] selection) {
for (int i = 0; i < selection.length; ++i)
if (!(selection[i] instanceof IViewDescriptor))
- return new Status(Status.ERROR,
- Activator.PLUGIN_ID, 0, "", null); //$NON-NLS-1$
+ return new Status(Status.ERROR, Activator.PLUGIN_ID, 0, "", null); //$NON-NLS-1$
- return new Status(Status.OK, Activator.getDefault()
- .getBundle().getSymbolicName(), 0, "", null); //$NON-NLS-1$
+ return new Status(Status.OK, Activator.getDefault().getBundle().getSymbolicName(), 0, "", null); //$NON-NLS-1$
}
});
- IViewRegistry reg = PlatformUI.getWorkbench().getViewRegistry();
+ final IViewRegistry reg = PlatformUI.getWorkbench().getViewRegistry();
dlg.setInput(reg);
dlg.open();
if (dlg.getReturnCode() == Window.CANCEL)
return;
- Object[] descs = dlg.getResult();
+ final Object[] descs = dlg.getResult();
if (descs == null)
return;
- String[] selectedIDs = new String[descs.length];
+ final String[] selectedIDs = new String[descs.length];
for (int i = 0; i < descs.length; ++i) {
selectedIDs[i] = ((IViewDescriptor) descs[i]).getId();
try {
// Actually send messages to target remote user (toID),
// with selectedIDs (view IDs) to show
- sendMessage(toID, serialize(new Object[] { senderuser,
- selectedIDs[i] }));
- } catch (ECFException e) {
- showErrorToUser(Messages.Share_ERROR_SEND_TITLE, NLS
- .bind(Messages.Share_ERROR_SEND_MESSAGE, e
- .getStatus().getException()
- .getLocalizedMessage()));
+ sendMessage(toID, serialize(new Object[] {senderuser, selectedIDs[i]}));
+ } catch (final ECFException e) {
+ showErrorToUser(Messages.Share_ERROR_SEND_TITLE, NLS.bind(Messages.Share_ERROR_SEND_MESSAGE, e.getStatus().getException().getLocalizedMessage()));
logError(e.getStatus());
- } catch (Exception e) {
- showErrorToUser(Messages.Share_ERROR_SEND_TITLE, NLS
- .bind(Messages.Share_ERROR_SEND_MESSAGE, e
- .getLocalizedMessage()));
+ } catch (final Exception e) {
+ showErrorToUser(Messages.Share_ERROR_SEND_TITLE, NLS.bind(Messages.Share_ERROR_SEND_MESSAGE, e.getLocalizedMessage()));
logError(Messages.Share_EXCEPTION_LOG_SEND, e);
}
}
@@ -177,27 +166,24 @@ public class ViewShare extends AbstractShare {
*/
protected void handleMessage(ID fromContainerID, byte[] data) {
try {
- Object[] msg = (Object[]) deserialize(data);
- handleOpenViewRequest((String) msg[0], (String) msg[1], null,
- IWorkbenchPage.VIEW_ACTIVATE);
- } catch (Exception e) {
- showErrorToUser(Messages.Share_ERROR_RECEIVE_TITLE, NLS.bind(
- Messages.Share_ERROR_RECEIVE_MESSAGE, e
- .getLocalizedMessage()));
+ final Object[] msg = (Object[]) deserialize(data);
+ handleOpenViewRequest((String) msg[0], (String) msg[1], null, IWorkbenchPage.VIEW_ACTIVATE);
+ } catch (final Exception e) {
+ showErrorToUser(Messages.Share_ERROR_RECEIVE_TITLE, NLS.bind(Messages.Share_ERROR_RECEIVE_MESSAGE, e.getLocalizedMessage()));
logError(Messages.Share_EXCEPTION_LOG_MESSAGE, e);
}
}
protected byte[] serialize(Object o) throws Exception {
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
- ObjectOutputStream oos = new ObjectOutputStream(bos);
+ final ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ final ObjectOutputStream oos = new ObjectOutputStream(bos);
oos.writeObject(o);
return bos.toByteArray();
}
protected Object deserialize(byte[] bytes) throws Exception {
- ByteArrayInputStream bins = new ByteArrayInputStream(bytes);
- ObjectInputStream oins = new ObjectInputStream(bins);
+ final ByteArrayInputStream bins = new ByteArrayInputStream(bytes);
+ final ObjectInputStream oins = new ObjectInputStream(bins);
return oins.readObject();
}
}
diff --git a/framework/bundles/org.eclipse.ecf.presence.collab.ui/src/org/eclipse/ecf/presence/collab/ui/view/ViewShareRosterContributionItem.java b/framework/bundles/org.eclipse.ecf.presence.collab.ui/src/org/eclipse/ecf/presence/collab/ui/view/ViewShareRosterContributionItem.java
index e01d17168..c5d3e9c60 100644
--- a/framework/bundles/org.eclipse.ecf.presence.collab.ui/src/org/eclipse/ecf/presence/collab/ui/view/ViewShareRosterContributionItem.java
+++ b/framework/bundles/org.eclipse.ecf.presence.collab.ui/src/org/eclipse/ecf/presence/collab/ui/view/ViewShareRosterContributionItem.java
@@ -10,8 +10,6 @@
*****************************************************************************/
package org.eclipse.ecf.presence.collab.ui.view;
-import java.util.Hashtable;
-
import org.eclipse.ecf.core.IContainer;
import org.eclipse.ecf.core.identity.ID;
import org.eclipse.ecf.core.util.ECFException;
@@ -24,10 +22,7 @@ import org.eclipse.jface.action.IAction;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PlatformUI;
-public class ViewShareRosterContributionItem extends
- AbstractRosterContributionItem {
-
- private static Hashtable viewSharechannels = new Hashtable();
+public class ViewShareRosterContributionItem extends AbstractRosterContributionItem {
public ViewShareRosterContributionItem() {
}
@@ -36,67 +31,47 @@ public class ViewShareRosterContributionItem extends
super(id);
}
- protected static ViewShare getViewShare(ID containerID) {
- return (ViewShare) viewSharechannels.get(containerID);
- }
-
- protected static ViewShare addViewShare(ID containerID, ViewShare ViewShare) {
- return (ViewShare) viewSharechannels.put(containerID, ViewShare);
- }
-
- protected static ViewShare removeViewShare(ID containerID) {
- return (ViewShare) viewSharechannels.remove(containerID);
- }
-
- private IAction[] createActionAdd(final ID containerID,
- final IChannelContainerAdapter channelAdapter) {
- IAction action = new Action() {
+ private IAction[] createActionAdd(final ID containerID, final IChannelContainerAdapter channelAdapter) {
+ final IAction action = new Action() {
public void run() {
try {
- addViewShare(containerID, new ViewShare(containerID, channelAdapter));
+ ViewShare.addViewShare(containerID, channelAdapter);
} catch (ECFException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
};
- action
- .setText(Messages.ViewShareRosterContributionItem_VIEWSHARE_LISTENER_MENU_ADD_TEXT);
- action.setImageDescriptor(PlatformUI.getWorkbench()
- .getSharedImages().getImageDescriptor(
- ISharedImages.IMG_DEF_VIEW));
- return new IAction[] { action };
+ action.setText(Messages.ViewShareRosterContributionItem_VIEWSHARE_LISTENER_MENU_ADD_TEXT);
+ action.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_DEF_VIEW));
+ return new IAction[] {action};
}
- private IAction[] createActionRemove(final ID containerID,
- final ViewShare viewShare) {
- IAction action = new Action() {
+ private IAction[] createActionRemove(final ID containerID, final ViewShare viewShare) {
+ final IAction action = new Action() {
public void run() {
- removeViewShare(containerID);
+ ViewShare.removeViewShare(containerID);
viewShare.dispose();
}
};
- action
- .setText(Messages.ViewShareRosterContributionItem_VIEWSHARE_LISTENER_MENU_REMOVE_TEXT);
- return new IAction[] { action };
+ action.setText(Messages.ViewShareRosterContributionItem_VIEWSHARE_LISTENER_MENU_REMOVE_TEXT);
+ return new IAction[] {action};
}
protected IAction[] makeActions() {
final IRoster roster = getSelectedRoster();
if (roster != null) {
// Roster is selected
- IContainer c = getContainerForRoster(roster);
+ final IContainer c = getContainerForRoster(roster);
if (c != null) {
// Get existing ViewShare for this container (if it exists)
- ViewShare viewShare = getViewShare(c.getID());
+ final ViewShare viewShare = ViewShare.getViewShare(c.getID());
// If it does exist already, then create action to remove
if (viewShare != null)
return createActionRemove(c.getID(), viewShare);
else {
- IChannelContainerAdapter channelAdapter = (IChannelContainerAdapter) c
- .getAdapter(IChannelContainerAdapter.class);
- return (channelAdapter == null) ? null : createActionAdd(c
- .getID(), channelAdapter);
+ final IChannelContainerAdapter channelAdapter = (IChannelContainerAdapter) c.getAdapter(IChannelContainerAdapter.class);
+ return (channelAdapter == null) ? null : createActionAdd(c.getID(), channelAdapter);
}
}
}
diff --git a/framework/bundles/org.eclipse.ecf.presence.collab.ui/src/org/eclipse/ecf/presence/collab/ui/view/ViewShareRosterEntryContributionItem.java b/framework/bundles/org.eclipse.ecf.presence.collab.ui/src/org/eclipse/ecf/presence/collab/ui/view/ViewShareRosterEntryContributionItem.java
index 6ae7a06b7..2ff14e704 100644
--- a/framework/bundles/org.eclipse.ecf.presence.collab.ui/src/org/eclipse/ecf/presence/collab/ui/view/ViewShareRosterEntryContributionItem.java
+++ b/framework/bundles/org.eclipse.ecf.presence.collab.ui/src/org/eclipse/ecf/presence/collab/ui/view/ViewShareRosterEntryContributionItem.java
@@ -20,8 +20,7 @@ import org.eclipse.jface.action.IAction;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PlatformUI;
-public class ViewShareRosterEntryContributionItem extends
- AbstractRosterEntryContributionItem {
+public class ViewShareRosterEntryContributionItem extends AbstractRosterEntryContributionItem {
public ViewShareRosterEntryContributionItem() {
}
@@ -33,29 +32,24 @@ public class ViewShareRosterEntryContributionItem extends
protected IAction[] makeActions() {
// Else check for Roster entry
final IRosterEntry entry = getSelectedRosterEntry();
- IContainer c = getContainerForRosterEntry(entry);
+ final IContainer c = getContainerForRosterEntry(entry);
// If roster entry is selected and it has a container
if (entry != null && c != null) {
- final IChannelContainerAdapter channelAdapter = (IChannelContainerAdapter) c
- .getAdapter(IChannelContainerAdapter.class);
+ final IChannelContainerAdapter channelAdapter = (IChannelContainerAdapter) c.getAdapter(IChannelContainerAdapter.class);
// If the container has channel container adapter and is online/available
if (channelAdapter != null && isAvailable(entry)) {
- ViewShare tmp = ViewShareRosterContributionItem.getViewShare(c
- .getID());
+ final ViewShare tmp = ViewShare.getViewShare(c.getID());
// If there is an URL share associated with this container
if (tmp != null) {
final ViewShare viewshare = tmp;
- IAction action = new Action() {
+ final IAction action = new Action() {
public void run() {
- viewshare.sendOpenViewRequest(entry.getRoster().getUser().getName(),entry.getUser().getID());
+ viewshare.sendOpenViewRequest(entry.getRoster().getUser().getName(), entry.getUser().getID());
}
};
- action
- .setText(Messages.ViewShareRosterEntryContributionItem_VIEWSHARE_MENU_TEXT);
- action.setImageDescriptor(PlatformUI.getWorkbench()
- .getSharedImages().getImageDescriptor(
- ISharedImages.IMG_DEF_VIEW));
- return new IAction[] { action };
+ action.setText(Messages.ViewShareRosterEntryContributionItem_VIEWSHARE_MENU_TEXT);
+ action.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_DEF_VIEW));
+ return new IAction[] {action};
}
}
}

Back to the top