Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrsuen2009-05-22 14:38:35 +0000
committerrsuen2009-05-22 14:38:35 +0000
commit35465d533765d7d3174b5defa6d3401270203563 (patch)
treecd997b5ef0cdcf172f76f5df77c0163bcab5437e /framework
parente3eed1e5328ffffc9cecdc7d068cef9ade35b493 (diff)
downloadorg.eclipse.ecf-35465d533765d7d3174b5defa6d3401270203563.tar.gz
org.eclipse.ecf-35465d533765d7d3174b5defa6d3401270203563.tar.xz
org.eclipse.ecf-35465d533765d7d3174b5defa6d3401270203563.zip
Prompt before allowing remote users to synchronize to prevent leaking information.
Diffstat (limited to 'framework')
-rw-r--r--framework/bundles/org.eclipse.team.ecf.ui/plugin.xml4
-rw-r--r--framework/bundles/org.eclipse.team.ecf.ui/src/org/eclipse/team/internal/ecf/ui/ECFStart.java107
-rw-r--r--framework/bundles/org.eclipse.team.ecf.ui/src/org/eclipse/team/internal/ecf/ui/Messages.java2
-rw-r--r--framework/bundles/org.eclipse.team.ecf.ui/src/org/eclipse/team/internal/ecf/ui/WorkbenchAwareRemoteShare.java43
-rw-r--r--framework/bundles/org.eclipse.team.ecf.ui/src/org/eclipse/team/internal/ecf/ui/messages.properties2
5 files changed, 158 insertions, 0 deletions
diff --git a/framework/bundles/org.eclipse.team.ecf.ui/plugin.xml b/framework/bundles/org.eclipse.team.ecf.ui/plugin.xml
index be6c2a094..7ebec236d 100644
--- a/framework/bundles/org.eclipse.team.ecf.ui/plugin.xml
+++ b/framework/bundles/org.eclipse.team.ecf.ui/plugin.xml
@@ -2,6 +2,10 @@
<?eclipse version="3.2"?>
<plugin>
<extension
+ point="org.eclipse.ecf.start">
+ <run class="org.eclipse.team.internal.ecf.ui.ECFStart"/>
+ </extension>
+ <extension
point="org.eclipse.team.ui.synchronizeParticipants">
<participant
class="org.eclipse.team.internal.ecf.ui.subscriber.RemoteSubscriberParticipant"
diff --git a/framework/bundles/org.eclipse.team.ecf.ui/src/org/eclipse/team/internal/ecf/ui/ECFStart.java b/framework/bundles/org.eclipse.team.ecf.ui/src/org/eclipse/team/internal/ecf/ui/ECFStart.java
new file mode 100644
index 000000000..6b61e7614
--- /dev/null
+++ b/framework/bundles/org.eclipse.team.ecf.ui/src/org/eclipse/team/internal/ecf/ui/ECFStart.java
@@ -0,0 +1,107 @@
+/****************************************************************************
+ * Copyright (c) 2007, 2009 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.team.internal.ecf.ui;
+
+import org.eclipse.core.runtime.*;
+import org.eclipse.ecf.core.*;
+import org.eclipse.ecf.core.events.*;
+import org.eclipse.ecf.core.identity.ID;
+import org.eclipse.ecf.core.start.IECFStart;
+import org.eclipse.ecf.core.util.ECFException;
+import org.eclipse.ecf.datashare.IChannelContainerAdapter;
+import org.eclipse.team.internal.ecf.core.TeamSynchronization;
+
+public class ECFStart 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) {
+ final IContainerManager containerManager = (IContainerManager) ContainerFactory.getDefault();
+ if (containerManager == null)
+ return;
+ IContainer container = containerManager.getContainer(event.getLocalContainerID());
+ if (container == null)
+ return;
+ if (event instanceof IContainerConnectedEvent || event instanceof IContainerDisconnectedEvent) {
+ // connected
+ IChannelContainerAdapter cca = (IChannelContainerAdapter) container.getAdapter(IChannelContainerAdapter.class);
+ if (cca == null)
+ return;
+ ID containerID = container.getID();
+ if (event instanceof IContainerConnectedEvent) {
+ try {
+ if (!TeamSynchronization.contains(containerID)) {
+ TeamSynchronization.put(containerID, new WorkbenchAwareRemoteShare(cca));
+ }
+ } catch (ECFException e) {
+ TeamSynchronization.log("RemoteShare could not be added or created", e); //$NON-NLS-1$
+ }
+ } else if (event instanceof IContainerDisconnectedEvent) {
+ // disconnected
+ TeamSynchronization.removeShare(containerID);
+ }
+ } else if (event instanceof IContainerDisposeEvent) {
+ containerManager.removeListener(containerManagerListener);
+ container.removeListener(containerListener);
+ }
+ }
+
+ };
+
+ IContainerManagerListener containerManagerListener = new IContainerManagerListener() {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.ecf.core.IContainerManagerListener#containerAdded(org
+ * .eclipse.ecf.core.IContainer)
+ */
+ public void containerAdded(IContainer container) {
+ IChannelContainerAdapter cca = (IChannelContainerAdapter) container.getAdapter(IChannelContainerAdapter.class);
+ if (cca == null)
+ return;
+ 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);
+ }
+ };
+
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.eclipse.ecf.core.start.IECFStart#run(org.eclipse.core.runtime.
+ * IProgressMonitor)
+ */
+ public IStatus run(IProgressMonitor monitor) {
+ final IContainerManager containerManager = (IContainerManager) ContainerFactory.getDefault();
+ containerManager.addListener(containerManagerListener);
+ return Status.OK_STATUS;
+ }
+
+}
diff --git a/framework/bundles/org.eclipse.team.ecf.ui/src/org/eclipse/team/internal/ecf/ui/Messages.java b/framework/bundles/org.eclipse.team.ecf.ui/src/org/eclipse/team/internal/ecf/ui/Messages.java
index a5c132e08..73cd6e692 100644
--- a/framework/bundles/org.eclipse.team.ecf.ui/src/org/eclipse/team/internal/ecf/ui/Messages.java
+++ b/framework/bundles/org.eclipse.team.ecf.ui/src/org/eclipse/team/internal/ecf/ui/Messages.java
@@ -16,6 +16,8 @@ public class Messages extends NLS {
private static final String BUNDLE_NAME = "org.eclipse.team.internal.ecf.ui.messages"; //$NON-NLS-1$
+ public static String WorkbenchAwareRemoteShare_PromptMessage;
+
public static String OverrideWithRemoteAction_ActionLabel;
public static String OverrideWithRemoteOperation_SubTaskName;
public static String OverrideWithRemoteOperation_CreatingResource;
diff --git a/framework/bundles/org.eclipse.team.ecf.ui/src/org/eclipse/team/internal/ecf/ui/WorkbenchAwareRemoteShare.java b/framework/bundles/org.eclipse.team.ecf.ui/src/org/eclipse/team/internal/ecf/ui/WorkbenchAwareRemoteShare.java
new file mode 100644
index 000000000..7e4ab65b5
--- /dev/null
+++ b/framework/bundles/org.eclipse.team.ecf.ui/src/org/eclipse/team/internal/ecf/ui/WorkbenchAwareRemoteShare.java
@@ -0,0 +1,43 @@
+package org.eclipse.team.internal.ecf.ui;
+
+import org.eclipse.ecf.core.identity.ID;
+import org.eclipse.ecf.core.util.ECFException;
+import org.eclipse.ecf.datashare.IChannelContainerAdapter;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.team.internal.ecf.core.RemoteShare;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+
+public class WorkbenchAwareRemoteShare extends RemoteShare {
+
+ WorkbenchAwareRemoteShare(IChannelContainerAdapter adapter) throws ECFException {
+ super(adapter);
+ }
+
+ protected boolean prompt(final ID fromId, String[] paths) {
+ IWorkbenchWindow[] windows = PlatformUI.getWorkbench().getWorkbenchWindows();
+ for (int i = 0; i < windows.length; i++) {
+ final Shell shell = windows[i].getShell();
+ if (shell != null && !shell.isDisposed()) {
+ final boolean[] prompt = {false};
+
+ final StringBuffer buffer = new StringBuffer(Text.DELIMITER);
+ for (int j = 0; j < paths.length; j++) {
+ buffer.append(paths[j]).append(Text.DELIMITER);
+ }
+
+ PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
+ public void run() {
+ prompt[0] = MessageDialog.openConfirm(shell, null, NLS.bind(Messages.WorkbenchAwareRemoteShare_PromptMessage, fromId.getName(), buffer.toString()));
+ }
+ });
+
+ return prompt[0];
+ }
+ }
+ return false;
+ }
+}
diff --git a/framework/bundles/org.eclipse.team.ecf.ui/src/org/eclipse/team/internal/ecf/ui/messages.properties b/framework/bundles/org.eclipse.team.ecf.ui/src/org/eclipse/team/internal/ecf/ui/messages.properties
index a78729eb4..adde505d8 100644
--- a/framework/bundles/org.eclipse.team.ecf.ui/src/org/eclipse/team/internal/ecf/ui/messages.properties
+++ b/framework/bundles/org.eclipse.team.ecf.ui/src/org/eclipse/team/internal/ecf/ui/messages.properties
@@ -9,6 +9,8 @@
# Remy Chi Jian Suen - initial API and implementation
################################################################################
+WorkbenchAwareRemoteShare_PromptMessage = {0} would like to synchronize some resources with you.{1}
+
OverrideWithRemoteAction_ActionLabel = Override with Remote
OverrideWithRemoteOperation_SubTaskName = Overriding resources with remote copy...
OverrideWithRemoteOperation_CreatingResource = Creating {0}...

Back to the top