Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean Michel-Lemieux2003-08-05 14:43:15 +0000
committerJean Michel-Lemieux2003-08-05 14:43:15 +0000
commit5ec1455fb62e518938e6b2cea77a7462a0fd3684 (patch)
tree66a4161310d9b7a821cbe3100f36d57c73add60a
parentd68ef2c76fca5169e879deaabd937fcd97b6918f (diff)
downloadeclipse.platform.team-5ec1455fb62e518938e6b2cea77a7462a0fd3684.tar.gz
eclipse.platform.team-5ec1455fb62e518938e6b2cea77a7462a0fd3684.tar.xz
eclipse.platform.team-5ec1455fb62e518938e6b2cea77a7462a0fd3684.zip
Removed SubscriberActionContributions in favor of using IActionFilter mechanism
from the workbench plugin.
-rw-r--r--bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/TeamSubscriber.java19
-rw-r--r--bundles/org.eclipse.team.cvs.ui/plugin.xml105
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSSubscriberAction.java2
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/MergeUpdateAction.java84
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/actions/ContributedSubscriberAction.java305
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/actions/SyncViewerActions.java7
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/actions/SyncViewerSubscriberActions.java114
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/compare/SyncInfoCompareInput.java4
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/views/CompressedFolder.java12
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/views/CompressedFolderContentProvider.java14
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/views/SyncResource.java90
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/views/SyncSetContentProvider.java44
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/views/SyncSetTreeContentProvider.java2
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/views/SynchronizeView.java12
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/views/SynchronizeViewNode.java132
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/ISynchronizeViewNode.java82
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/SubscriberAction.java37
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/SyncInfoSet.java2
18 files changed, 424 insertions, 643 deletions
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/TeamSubscriber.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/TeamSubscriber.java
index 8ae4d2ade..6b77778e4 100644
--- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/TeamSubscriber.java
+++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/TeamSubscriber.java
@@ -285,4 +285,23 @@ abstract public class TeamSubscriber {
public boolean isReleaseSupported() {
return true;
}
+
+ /**
+ * Return true if the receiver is equal to object.
+ * @return true if object is the same class as the receiver and has the same ID
+ */
+ public boolean equals(Object object) {
+ if (object instanceof TeamSubscriber) {
+ TeamSubscriber subscriber = (TeamSubscriber) object;
+ return getId().equals(subscriber.getId());
+ }
+ return super.equals(object);
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#hashCode()
+ */
+ public int hashCode() {
+ return getId().hashCode();
+ }
} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.ui/plugin.xml b/bundles/org.eclipse.team.cvs.ui/plugin.xml
index 21856ef67..0df87f679 100644
--- a/bundles/org.eclipse.team.cvs.ui/plugin.xml
+++ b/bundles/org.eclipse.team.cvs.ui/plugin.xml
@@ -557,53 +557,76 @@
</objectContribution>
</extension>
+
+
<!-- ************* Subscriber Menus ************ -->
- <extension
- point="org.eclipse.team.ui.subscriberMenus">
- <subscriberContribution
- subscriberClass="org.eclipse.team.internal.ccvs.core.CVSWorkspaceSubscriber"
- id="org.eclipse.team.ccvs.ui.CVSWorkspaceSubscriberContributions">
- <action
- label="%CVSWorkspaceSubscriber.update.label"
- tooltip="%CVSWorkspaceSubscriber.update.tooltip"
- class="org.eclipse.team.internal.ccvs.ui.subscriber.WorkspaceUpdateAction"
- helpContextId="org.eclipse.team.cvs.ui.workspace_subscriber_update_action"
- id="org.eclipse.team.ccvs.ui.CVSWorkspaceSubscriber.update">
- </action>
- <action
- label="%CVSWorkspaceSubscriber.commit.label"
- tooltip="%CVSWorkspaceSubscriber.commit.tooltip"
- class="org.eclipse.team.internal.ccvs.ui.subscriber.SubscriberCommitAction"
- helpContextId="org.eclipse.team.cvs.ui.workspace_subscriber_commit_action"
- id="org.eclipse.team.ccvs.ui.CVSWorkspaceSubscriber.commit">
- </action>
- <action
+
+ <extension
+ point="org.eclipse.ui.popupMenus">
+ <objectContribution
+ objectClass="org.eclipse.team.ui.sync.ISynchronizeViewNode"
+ id="org.eclipse.team.ccvs.ui.CVSWorkspaceSubscriberContributions"
+ adaptable="true">
+
+ <filter name="equals" value="org.eclipse.team.cvs.subscribers:workspace-subscriber" />
+
+ <action
label="%CVSWorkspaceSubscriber.confirmMerged.label"
+ menubarPath="SubscriberActions"
tooltip="%CVSWorkspaceSubscriber.confirmMerged.tooltip"
class="org.eclipse.team.internal.ccvs.ui.subscriber.SubscriberConfirmMergedAction"
helpContextId="org.eclipse.team.cvs.ui.workspace_subscriber_confirm_merged_action"
id="org.eclipse.team.ccvs.ui.CVSWorkspaceSubscriber.confirmMerged">
- </action>
- </subscriberContribution>
- <subscriberContribution
- subscriberClass="org.eclipse.team.internal.ccvs.core.CVSMergeSubscriber"
- id="org.eclipse.team.ccvs.ui.CVSMergeSubscriberContributions">
- <action
- label="%CVSWorkspaceSubscriber.merge.label"
- tooltip="%CVSWorkspaceSubscriber.merge.tooltip"
- class="org.eclipse.team.internal.ccvs.ui.subscriber.MergeUpdateAction"
- helpContextId="org.eclipse.team.cvs.ui.workspace_subscriber_merge_action"
- id="org.eclipse.team.ccvs.ui.CVSMergeSubscriber.merge">
- </action>
- <action
- label="%CVSWorkspaceSubscriber.confirmMerged.label"
- tooltip="%CVSWorkspaceSubscriber.confirmMerged.tooltip"
- class="org.eclipse.team.internal.ccvs.ui.subscriber.SubscriberConfirmMergedAction"
- helpContextId="org.eclipse.team.cvs.ui.workspace_subscriber_confirm_merged_action"
- id="org.eclipse.team.ccvs.ui.CVSMergeSubscriber.confirmMerged">
- </action>
- </subscriberContribution>
- </extension>
+ </action>
+
+ <action
+ label="%CVSWorkspaceSubscriber.commit.label"
+ menubarPath="SubscriberActions"
+ tooltip="%CVSWorkspaceSubscriber.commit.tooltip"
+ class="org.eclipse.team.internal.ccvs.ui.subscriber.SubscriberCommitAction"
+ overrideActionId="org.eclipse.team.ccvs.ui.commit"
+ helpContextId="org.eclipse.team.cvs.ui.workspace_subscriber_commit_action"
+ id="org.eclipse.team.ccvs.ui.CVSWorkspaceSubscriber.commit">
+ </action>
+
+ <action
+ label="%CVSWorkspaceSubscriber.update.label"
+ menubarPath="SubscriberActions"
+ tooltip="%CVSWorkspaceSubscriber.update.tooltip"
+ class="org.eclipse.team.internal.ccvs.ui.subscriber.WorkspaceUpdateAction"
+ overrideActionId="org.eclipse.team.ccvs.ui.update"
+ helpContextId="org.eclipse.team.cvs.ui.workspace_subscriber_update_action"
+ id="org.eclipse.team.ccvs.ui.CVSWorkspaceSubscriber.update">
+ </action>
+ </objectContribution>
+
+ <objectContribution
+ objectClass="org.eclipse.team.ui.sync.ISynchronizeViewNode"
+ id="org.eclipse.team.ccvs.ui.CVSMergeSubscriberContributions"
+ adaptable="true">
+
+ <filter name="startsWith" value="org.eclipse.team.cvs.subscribers:merge-" />
+
+ <action
+ label="%CVSWorkspaceSubscriber.confirmMerged.label"
+ menubarPath="SubscriberActions"
+ tooltip="%CVSWorkspaceSubscriber.confirmMerged.tooltip"
+ class="org.eclipse.team.internal.ccvs.ui.subscriber.SubscriberConfirmMergedAction"
+ helpContextId="org.eclipse.team.cvs.ui.workspace_subscriber_confirm_merged_action"
+ id="org.eclipse.team.ccvs.ui.CVSMergeSubscriber.confirmMerged">
+ </action>
+
+ <action
+ label="%CVSWorkspaceSubscriber.merge.label"
+ menubarPath="SubscriberActions"
+ tooltip="%CVSWorkspaceSubscriber.merge.tooltip"
+ class="org.eclipse.team.internal.ccvs.ui.subscriber.MergeUpdateAction"
+ overrideActionId="org.eclipse.team.ccvs.ui.update"
+ helpContextId="org.eclipse.team.cvs.ui.workspace_subscriber_merge_action"
+ id="org.eclipse.team.ccvs.ui.CVSMergeSubscriber.merge">
+ </action>
+ </objectContribution>
+ </extension>
<!-- ************** Views ********************** -->
<extension
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSSubscriberAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSSubscriberAction.java
index 3bb84704d..8b39aff2e 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSSubscriberAction.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSSubscriberAction.java
@@ -189,7 +189,7 @@ public abstract class CVSSubscriberAction extends SubscriberAction {
}
protected SyncInfo getParent(SyncInfo info) throws TeamException {
- return getSubscriber().getSyncInfo(info.getLocal().getParent(), new NullProgressMonitor());
+ return info.getSubscriber().getSyncInfo(info.getLocal().getParent(), new NullProgressMonitor());
}
protected IResource[] getIResourcesFrom(SyncInfo[] nodes) {
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/MergeUpdateAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/MergeUpdateAction.java
index a6947c38c..c5b367f4e 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/MergeUpdateAction.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/MergeUpdateAction.java
@@ -85,48 +85,52 @@ public class MergeUpdateAction extends SafeUpdateAction {
* @see org.eclipse.team.internal.ccvs.ui.subscriber.SubscriberUpdateAction#runUpdateShallow(org.eclipse.team.internal.ui.sync.views.SyncInfo[], org.eclipse.team.internal.ccvs.ui.repo.RepositoryManager, org.eclipse.core.runtime.IProgressMonitor)
*/
protected void runSafeUpdate(SyncInfo[] nodes, IProgressMonitor monitor) throws TeamException {
-
- TeamSubscriber subscriber = getSubscriber();
- if (!(subscriber instanceof CVSMergeSubscriber)) {
- throw new CVSException("Invalid subscriber: " + subscriber.getId());
- }
- CVSTag startTag = ((CVSMergeSubscriber)subscriber).getStartTag();
- CVSTag endTag = ((CVSMergeSubscriber)subscriber).getEndTag();
-
- // Incoming additions require different handling then incoming changes and deletions
- List additions = new ArrayList();
- List changes = new ArrayList();
- for (int i = 0; i < nodes.length; i++) {
- SyncInfo resource = nodes[i];
- int kind = resource.getKind();
- if ((kind & SyncInfo.ADDITION) != 0) {
- additions.add(resource);
- } else {
- changes.add(resource);
+ if(nodes.length > 0) {
+ TeamSubscriber subscriber = nodes[0].getSubscriber();
+ if (!(subscriber instanceof CVSMergeSubscriber)) {
+ throw new CVSException("Invalid subscriber: " + subscriber.getId());
+ }
+ CVSTag startTag = ((CVSMergeSubscriber)subscriber).getStartTag();
+ CVSTag endTag = ((CVSMergeSubscriber)subscriber).getEndTag();
+
+ // Incoming additions require different handling then incoming changes and deletions
+ List additions = new ArrayList();
+ List changes = new ArrayList();
+ for (int i = 0; i < nodes.length; i++) {
+ SyncInfo resource = nodes[i];
+ int kind = resource.getKind();
+ if ((kind & SyncInfo.ADDITION) != 0) {
+ additions.add(resource);
+ } else {
+ changes.add(resource);
+ }
+ }
+
+ try {
+ monitor.beginTask(null, (additions.size() + changes.size()) * 100);
+ if (!additions.isEmpty()) {
+ safeUpdate(
+ getIResourcesFrom((SyncInfo[]) additions.toArray(new SyncInfo[additions.size()])),
+ new Command.LocalOption[] {
+ Command.DO_NOT_RECURSE,
+ Update.makeArgumentOption(Update.JOIN, endTag.getName())
+ },
+ Policy.subMonitorFor(monitor, additions.size() * 100));
+ }
+ if (!changes.isEmpty()) {
+ safeUpdate(
+ getIResourcesFrom((SyncInfo[]) changes.toArray(new SyncInfo[changes.size()])),
+ new Command.LocalOption[] {
+ Command.DO_NOT_RECURSE,
+ Update.makeArgumentOption(Update.JOIN, startTag.getName()),
+ Update.makeArgumentOption(Update.JOIN, endTag.getName())
+ },
+ Policy.subMonitorFor(monitor, changes.size() * 100));
+ }
+ } finally {
+ monitor.done();
}
}
-
- monitor.beginTask(null, (additions.size() + changes.size()) * 100);
- if (!additions.isEmpty()) {
- safeUpdate(
- getIResourcesFrom((SyncInfo[]) additions.toArray(new SyncInfo[additions.size()])),
- new Command.LocalOption[] {
- Command.DO_NOT_RECURSE,
- Update.makeArgumentOption(Update.JOIN, endTag.getName())
- },
- Policy.subMonitorFor(monitor, additions.size() * 100));
- }
- if (!changes.isEmpty()) {
- safeUpdate(
- getIResourcesFrom((SyncInfo[]) changes.toArray(new SyncInfo[changes.size()])),
- new Command.LocalOption[] {
- Command.DO_NOT_RECURSE,
- Update.makeArgumentOption(Update.JOIN, startTag.getName()),
- Update.makeArgumentOption(Update.JOIN, endTag.getName())
- },
- Policy.subMonitorFor(monitor, changes.size() * 100));
- }
- monitor.done();
}
/*
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/actions/ContributedSubscriberAction.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/actions/ContributedSubscriberAction.java
deleted file mode 100644
index 5fce175d8..000000000
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/actions/ContributedSubscriberAction.java
+++ /dev/null
@@ -1,305 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ui.sync.actions;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IPluginDescriptor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.internal.ui.TeamUIPlugin;
-import org.eclipse.team.internal.ui.sync.sets.SubscriberInput;
-import org.eclipse.team.ui.sync.SubscriberAction;
-import org.eclipse.ui.IActionDelegate;
-import org.eclipse.ui.IActionDelegate2;
-import org.eclipse.ui.IObjectActionDelegate;
-import org.eclipse.ui.IViewPart;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.help.WorkbenchHelp;
-
-/**
- * This action delegates to an action delegate contributed through the plugin.xml
- *
- * <action
- * label="%CVSWorkspaceSubscriber.commit.label"
- * tooltip="%CVSWorkspaceSubscriber.commit.tooltip"
- * class="org.eclipse.team.internal.ccvs.ui.subscriber.CommitAction"
- * helpContextId="org.eclipse.team.cvs.ui.workspace_subscriber_commit_action"
- * id="org.eclipse.team.ccvs.ui.CVSWorkspaceSubscriber.commit">
- * </action>
- */
-public class ContributedSubscriberAction extends SyncViewerAction {
-
- private IActionDelegate delegate;
- private IConfigurationElement element;
- private IWorkbenchPart activePart;
- private ISelection selection;
- private SubscriberInput context;
-
- /*
- * NOTE: Code copied from WorkbenchPlugin.
- *
- * Creates an extension. If the extension plugin has not
- * been loaded a busy cursor will be activated during the duration of
- * the load.
- *
- * @param element the config element defining the extension
- * @param classAttribute the name of the attribute carrying the class
- * @returns the extension object
- */
- private static Object createExtension(final IConfigurationElement element, final String classAttribute) throws TeamException {
- // If plugin has been loaded create extension.
- // Otherwise, show busy cursor then create extension.
- IPluginDescriptor plugin = element.getDeclaringExtension().getDeclaringPluginDescriptor();
- if (plugin.isPluginActivated()) {
- try {
- return element.createExecutableExtension(classAttribute);
- } catch (CoreException e) {
- throw TeamException.asTeamException(e);
- }
- } else {
- final Object[] ret = new Object[1];
- final TeamException[] exc = new TeamException[1];
- BusyIndicator.showWhile(null, new Runnable() {
- public void run() {
- try {
- ret[0] = element.createExecutableExtension(classAttribute);
- } catch (CoreException e) {
- exc[0] = TeamException.asTeamException(e);
- }
- }
- });
- if (exc[0] != null)
- throw exc[0];
- else
- return ret[0];
- }
- }
-
- private static void log(String message, TeamException e) {
- if (message == null) {
- message = e.getMessage();
- System.err.println(message);
- } else {
- System.err.println(message + "\nReason:");
- System.err.println(e.getStatus().getMessage());
- }
- TeamUIPlugin.log(IStatus.ERROR, message, e);
- }
-
- /**
- * @param viewer
- * @param element
- */
- public ContributedSubscriberAction(IViewPart viewPart, IConfigurationElement element) {
- super(viewPart, element.getAttribute("label"));
- this.element = element;
- String tooltip = element.getAttribute("tooltip");
- String helpContextId = element.getAttribute("helpContextId");
- String id = element.getAttribute("id");
- setToolTipText(tooltip);
- setId(id);
- if (helpContextId != null) {
- WorkbenchHelp.setHelp(this, helpContextId);
- }
- }
-
- /**
- * Return the delegate action or null if not created yet
- */
- private IActionDelegate getDelegate() {
- if (delegate == null) {
- createDelegate();
- }
- return delegate;
- }
-
- private void createDelegate() {
- if (delegate == null) {
- try {
- Object obj = createExtension(element, "class");
- delegate = validateDelegate(obj);
- initDelegate();
- refreshEnablement();
- } catch (TeamException e) {
- String id = element.getAttribute("id");
- log("Could not create action delegate for id: " + id, e); //$NON-NLS-1$
- return;
- }
- }
- }
-
- /**
- *
- */
- private void refreshEnablement() {
- if (delegate != null) {
- delegate.selectionChanged(this, selection);
- }
- }
-
- private void initDelegate() {
- if (delegate instanceof IActionDelegate2)
- ((IActionDelegate2)delegate).init(this);
- if (delegate instanceof IObjectActionDelegate && activePart != null)
- ((IObjectActionDelegate)delegate).setActivePart(this, activePart);
- }
-
-
- /*
- * Validates the object is a delegate of the expected type. Subclasses can
- * override to check for specific delegate types.
- * <p>
- * <b>Note:</b> Calls to the object are not allowed during this method.
- * </p>
- *
- * @param obj a possible action delegate implementation
- * @return the <code>IActionDelegate</code> implementation for the object
- * @throws a <code>WorkbenchException</code> if not expect delegate type
- */
- private IActionDelegate validateDelegate(Object obj) throws TeamException {
- if (obj instanceof IActionDelegate)
- return (IActionDelegate)obj;
- else
- // TODO: Code in PluginAction was not NLSed. Should it be?
- throw new TeamException("Action must implement IActionDelegate"); //$NON-NLS-1$
- }
-
- /**
- * Sets the active part for the delegate.
- * <p>
- * This method will be called every time the action appears in a popup menu. The
- * targetPart may change with each invocation.
- * </p>
- *
- * @param action the action proxy that handles presentation portion of the action
- * @param targetPart the new part target
- */
- public void setActivePart(IWorkbenchPart targetPart) {
- activePart = targetPart;
- if (delegate != null && delegate instanceof IObjectActionDelegate)
- ((IObjectActionDelegate) delegate).setActivePart(this, activePart);
- }
-
- /**
- * Handles selection change. If rule-based enabled is
- * defined, it will be first to call it. If the delegate
- * is loaded, it will also be given a chance.
- */
- public void selectionChanged(ISelection newSelection) {
- // Update selection.
- selection = newSelection;
- if (selection == null)
- selection = StructuredSelection.EMPTY;
-
- // If the delegate can be loaded, do so.
- // Otherwise, just update the enablement.
- if (delegate == null && isOkToCreateDelegate())
- createDelegate();
- else
- refreshEnablement();
- }
-
- /**
- * The <code>SelectionChangedEventAction</code> implementation of this
- * <code>ISelectionChangedListener</code> method calls
- * <code>selectionChanged(IStructuredSelection)</code> when the selection is
- * a structured one.
- */
- public void selectionChanged(SelectionChangedEvent event) {
- ISelection sel = event.getSelection();
- selectionChanged(sel);
- }
-
- /**
- * The <code>SelectionChangedEventAction</code> implementation of this
- * <code>ISelectionListener</code> method calls
- * <code>selectionChanged(IStructuredSelection)</code> when the selection is
- * a structured one. Subclasses may extend this method to react to the change.
- */
- public void selectionChanged(IWorkbenchPart part, ISelection sel) {
- selectionChanged(sel);
- }
-
- /**
- * Returns true if the declaring plugin has been loaded
- * and there is no need to delay creating the delegate
- * any more.
- */
- private boolean isOkToCreateDelegate() {
- // test if the plugin has loaded
- IPluginDescriptor plugin =
- element.getDeclaringExtension().getDeclaringPluginDescriptor();
- return plugin.isPluginActivated();
- }
-
- /* (non-Javadoc)
- * Method declared on IAction.
- */
- public void run() {
- runWithEvent(null);
- }
-
- /* (non-Javadoc)
- * Method declared on IAction.
- */
- public void runWithEvent(Event event) {
- // this message dialog is problematic.
- if (delegate == null) {
- // TODO: We should create the delegate earlier since the subscriber
- // is already loaded by the sync view.
- createDelegate();
- if (delegate == null) {
- MessageDialog.openInformation(
- Display.getDefault().getActiveShell(),
- "Information",
- "Operation Not Available");
- return;
- }
- if (!isEnabled()) {
- MessageDialog.openInformation(
- Display.getDefault().getActiveShell(),
- "Information",
- "Operation is disabled");
- return;
- }
- }
-
- if (event != null) {
- if (delegate instanceof IActionDelegate2) {
- ((IActionDelegate2)delegate).runWithEvent(this, event);
- return;
- }
- }
-
- delegate.run(this);
- }
-
- /*
- * Set the context
- * @param input
- */
- protected void setContext(SubscriberInput input) {
- this.context = input;
- IActionDelegate delegate = getDelegate();
- if (delegate instanceof SubscriberAction) {
- ((SubscriberAction)delegate).setSubscriber(context.getSubscriber());
- }
- }
-
-}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/actions/SyncViewerActions.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/actions/SyncViewerActions.java
index da15d5841..76b205c0a 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/actions/SyncViewerActions.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/actions/SyncViewerActions.java
@@ -42,7 +42,6 @@ public class SyncViewerActions extends SyncViewerActionGroup {
private SyncViewerChangeFilters changeFilters;
private SyncViewerComparisonCriteria comparisonCriteria;
private SyncViewerSubscriberListActions subscriberInputs;
- private SyncViewerSubscriberActions subscriberActions;
private WorkingSetFilterActionGroup workingSetGroup;
private OpenWithActionGroup openWithActionGroup;
@@ -68,7 +67,6 @@ public class SyncViewerActions extends SyncViewerActionGroup {
directionsFilters.updateActionBars();
comparisonCriteria.updateActionBars();
subscriberInputs.updateActionBars();
- subscriberActions.updateActionBars();
expandAll.update();
}
@@ -82,7 +80,6 @@ public class SyncViewerActions extends SyncViewerActionGroup {
SynchronizeView syncView = getSyncView();
directionsFilters = new SyncViewerDirectionFilters(syncView, this);
changeFilters = new SyncViewerChangeFilters(syncView, this);
- subscriberActions = new SyncViewerSubscriberActions(syncView);
// initialize the dropdown for choosing a subscriber
subscriberInputs = new SyncViewerSubscriberListActions(syncView);
@@ -200,8 +197,7 @@ public class SyncViewerActions extends SyncViewerActionGroup {
manager.add(expandAll);
manager.add(new Separator());
manager.add(refreshSelectionAction);
- // Subscriber menus go here
- subscriberActions.fillContextMenu(manager);
+ manager.add(new Separator("SubscriberActions")); //$NON-NLS-1$
// Other plug-ins can contribute there actions here
manager.add(new Separator("Additions")); //$NON-NLS-1$
}
@@ -260,7 +256,6 @@ public class SyncViewerActions extends SyncViewerActionGroup {
directionsFilters.setContext(context);
comparisonCriteria.setContext(context);
subscriberInputs.setContext(context);
- subscriberActions.setContext(context);
openWithActionGroup.setContext(context);
// causes initializeActions to be called. Must be called after
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/actions/SyncViewerSubscriberActions.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/actions/SyncViewerSubscriberActions.java
deleted file mode 100644
index 823412aaa..000000000
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/actions/SyncViewerSubscriberActions.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ui.sync.actions;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtension;
-import org.eclipse.core.runtime.IExtensionPoint;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.Separator;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.team.internal.ui.TeamUIPlugin;
-import org.eclipse.team.internal.ui.sync.views.SynchronizeView;
-
-/**
- * This class manages the actions contributed by the subscriber.
- */
-public class SyncViewerSubscriberActions extends SyncViewerActionGroup {
-
- // cache of the subscriber actins
- private HashMap definitions; // Subscriber class name -> SubscriberAction[]
- private ContributedSubscriberAction[] actions;
-
- /**
- * @param syncView
- */
- protected SyncViewerSubscriberActions(SynchronizeView syncView) {
- super(syncView);
- loadDefinitions();
- }
-
- private void loadDefinitions() {
- IExtensionPoint point = Platform.getPluginRegistry().getExtensionPoint(TeamUIPlugin.ID, TeamUIPlugin.PT_SUBSCRIBER_MENUS);
- IExtension[] types = point.getExtensions();
- definitions = new HashMap(types.length);
- for (int i = 0; i < types.length; i++)
- loadDefinitions(types[i]);
- }
-
- private void loadDefinitions(IExtension type) {
- IConfigurationElement[] elements = type.getConfigurationElements();
- for (int i = 0; i < elements.length; i++) {
- IConfigurationElement element = elements[i];
- String subscriberName = getSubscriberClassName(element);
- if (subscriberName != null) {
- definitions.put(getSubscriberClassName(element), createActions(element));
- }
- }
- }
-
- /**
- * @param element
- * @return
- */
- private ContributedSubscriberAction[] createActions(IConfigurationElement element) {
- IConfigurationElement[] children = element.getChildren();
- List result = new ArrayList();
- for (int i = 0; i < children.length; i++) {
- IConfigurationElement actionDefinition = children[i];
- ContributedSubscriberAction action = new ContributedSubscriberAction(getSyncView(), actionDefinition);
- result.add(action);
- }
- return (ContributedSubscriberAction[]) result.toArray(new ContributedSubscriberAction[result.size()]);
- }
-
- /**
- * @param extension
- * @return
- */
- private String getSubscriberClassName(IConfigurationElement element) {
- return (String)element.getAttribute("subscriberClass"); //$NON-NLS-1$
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.actions.ActionGroup#fillContextMenu(org.eclipse.jface.action.IMenuManager)
- */
- public void fillContextMenu(IMenuManager menu) {
- super.fillContextMenu(menu);
- if (actions == null || actions.length == 0) return;
- menu.add(new Separator());
- ISelection selection = getSyncView().getSelection();
- for (int i = 0; i < actions.length; i++) {
- ContributedSubscriberAction action = actions[i];
- action.setActivePart(getSyncView().getSite().getPage().getActivePart());
- action.setContext(getSubscriberContext());
- action.selectionChanged(selection);
- menu.add(action);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ui.sync.actions.SyncViewerActionGroup#initializeActions()
- */
- protected void initializeActions() {
- super.initializeActions();
- if(getSubscriberContext() != null) {
- String className = getSubscriberContext().getSubscriber().getClass().getName();
- actions = (ContributedSubscriberAction[])definitions.get(className);
- }
- }
-
-}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/compare/SyncInfoCompareInput.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/compare/SyncInfoCompareInput.java
index 4f31f8098..fa5f1d597 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/compare/SyncInfoCompareInput.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/compare/SyncInfoCompareInput.java
@@ -171,6 +171,10 @@ public class SyncInfoCompareInput extends CompareEditorInput {
private boolean equalDiffNodes(SyncInfoDiffNode node1, SyncInfoDiffNode node2) {
+ if(node1 == null || node2 == null) {
+ return false;
+ }
+
// First, ensure the local resources are equals
IResource local1 = null;
if (node1.getLeft() != null)
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/views/CompressedFolder.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/views/CompressedFolder.java
index d72b361c4..ab4e3e802 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/views/CompressedFolder.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/views/CompressedFolder.java
@@ -16,21 +16,21 @@ import java.util.List;
import org.eclipse.core.resources.IResource;
import org.eclipse.team.core.subscribers.SyncInfo;
-import org.eclipse.team.internal.ui.sync.sets.*;
+import org.eclipse.team.internal.ui.sync.sets.SubscriberInput;
/**
* A compressed folder appears under a project and contains out-of-sync resources
*/
-public class CompressedFolder extends SyncResource {
+public class CompressedFolder extends SynchronizeViewNode {
- public CompressedFolder(SyncSet syncSet, IResource resource) {
- super(syncSet, resource);
+ public CompressedFolder( SubscriberInput input, IResource resource) {
+ super(input, resource);
}
/* (non-Javadoc)
- * @see org.eclipse.team.internal.ui.sync.views.SyncResource#getOutOfSyncDescendants()
+ * @see org.eclipse.team.internal.ui.sync.views.SynchronizeViewNode#getOutOfSyncDescendants()
*/
- public SyncInfo[] getOutOfSyncDescendants() {
+ public SyncInfo[] getChildSyncInfos() {
IResource[] children = getSyncSet().members(getResource());
List result = new ArrayList();
for (int i = 0; i < children.length; i++) {
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/views/CompressedFolderContentProvider.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/views/CompressedFolderContentProvider.java
index 927cff917..f9a40e8c0 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/views/CompressedFolderContentProvider.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/views/CompressedFolderContentProvider.java
@@ -21,7 +21,8 @@ import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.jface.viewers.AbstractTreeViewer;
import org.eclipse.team.core.subscribers.SyncInfo;
-import org.eclipse.team.internal.ui.sync.sets.*;
+import org.eclipse.team.internal.ui.sync.sets.SubscriberInput;
+import org.eclipse.team.internal.ui.sync.sets.SyncSetChangedEvent;
/**
* The contents provider compressed in-sync folder paths
@@ -79,13 +80,14 @@ public class CompressedFolderContentProvider extends SyncSetTreeContentProvider
return getModelObject(getResource(element).getProject());
}
Object parent = super.getParent(element);
- if (parent instanceof SyncResource) {
- SyncInfo info = ((SyncResource)parent).getSyncInfo();
+ if (parent instanceof SynchronizeViewNode) {
+ SyncInfo info = ((SynchronizeViewNode)parent).getSyncInfo();
if (info == null) {
// The resource is in-sync so return a compressed folder
- IResource resource = ((SyncResource)parent).getResource();
+ IResource resource = ((SynchronizeViewNode)parent).getResource();
if (resource.getType() == IResource.FOLDER) {
- return new CompressedFolder(((SyncResource)parent).getSyncSet(), resource);
+ return new CompressedFolder((SubscriberInput)viewer.getInput(), resource);
+
}
}
}
@@ -145,7 +147,7 @@ public class CompressedFolderContentProvider extends SyncSetTreeContentProvider
*/
public Object getModelObject(IResource resource) {
if (resource.getType() == IResource.FOLDER && getSyncSet().getSyncInfo(resource) == null) {
- return new CompressedFolder(getSyncSet(), resource);
+ return new CompressedFolder(getSubscriberInput(), resource);
}
return super.getModelObject(resource);
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/views/SyncResource.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/views/SyncResource.java
deleted file mode 100644
index 28de4eed2..000000000
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/views/SyncResource.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ui.sync.views;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.team.core.subscribers.SyncInfo;
-import org.eclipse.team.internal.ui.sync.sets.*;
-
-/**
- * This is the UI model object representing a SyncInfo for a resource.
- * The main purpose of this class is to allow menu object contributions
- * to be applied to these resources.
- */
-public class SyncResource implements IAdaptable {
-
- private SyncSet syncSet;
- private IResource resource;
-
- public SyncResource(SyncSet syncSet, IResource resource) {
- this.syncSet = syncSet;
- this.resource = resource;
- }
-
- public SyncSet getSyncSet() {
- return syncSet;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
- */
- public Object getAdapter(Class adapter) {
- if (adapter == IResource.class) {
- return getResource();
- } else if (adapter == SyncInfo.class) {
- return getSyncInfo();
- }
- return null;
- }
-
- /**
- * @return
- */
- public SyncInfo getSyncInfo() {
- return syncSet.getSyncInfo(resource);
- }
-
- /**
- * Return an array of all descendants (including the receiver) that have
- * a non-null sync-info.
- * @return
- */
- public SyncInfo[] getOutOfSyncDescendants() {
- return syncSet.getOutOfSyncDescendants(resource);
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#equals(java.lang.Object)
- */
- public boolean equals(Object object) {
- if (object instanceof SyncResource) {
- SyncResource syncResource = (SyncResource) object;
- return getResource().equals(syncResource.getResource());
- }
- return super.equals(object);
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#hashCode()
- */
- public int hashCode() {
- return getResource().hashCode();
- }
-
- public IResource getResource() {
- return resource;
- }
-
- public String toString() {
- return "Sync for " + getResource().getFullPath().toString();
- }
-}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/views/SyncSetContentProvider.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/views/SyncSetContentProvider.java
index e1711b55a..d1566449d 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/views/SyncSetContentProvider.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/views/SyncSetContentProvider.java
@@ -19,7 +19,10 @@ import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.widgets.Control;
import org.eclipse.team.core.subscribers.SyncInfo;
import org.eclipse.team.internal.ui.actions.TeamAction;
-import org.eclipse.team.internal.ui.sync.sets.*;
+import org.eclipse.team.internal.ui.sync.sets.ISyncSetChangedListener;
+import org.eclipse.team.internal.ui.sync.sets.SubscriberInput;
+import org.eclipse.team.internal.ui.sync.sets.SyncSet;
+import org.eclipse.team.internal.ui.sync.sets.SyncSetChangedEvent;
/**
* This class provides the contents for a StructuredViewer using a SyncSet as the model
@@ -36,28 +39,37 @@ public abstract class SyncSetContentProvider implements IStructuredContentProvid
if (input == null) {
return null;
}
- return (SyncSet)input;
+ return ((SubscriberInput)input).getFilteredSyncSet();
+ }
+
+ protected SubscriberInput getSubscriberInput() {
+ if(viewer == null || viewer.getControl().isDisposed()) {
+ return null;
+ }
+ return (SubscriberInput)viewer.getInput();
}
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
*/
public void inputChanged(Viewer v, Object oldInput, Object newInput) {
+
this.viewer = v;
- SyncSet oldSyncSet = null;
- SyncSet newSyncSet = null;
- if (oldInput instanceof SyncSet) {
- oldSyncSet = (SyncSet) oldInput;
+ SubscriberInput oldSubscriberInput = null;
+ SubscriberInput newSubscriberInput = null;
+
+ if (oldInput instanceof SubscriberInput) {
+ oldSubscriberInput = (SubscriberInput) oldInput;
}
- if (newInput instanceof SyncSet) {
- newSyncSet = (SyncSet) newInput;
+ if (newInput instanceof SubscriberInput) {
+ newSubscriberInput = (SubscriberInput) newInput;
}
- if (oldSyncSet != newSyncSet) {
- if (oldSyncSet != null) {
- oldSyncSet.removeSyncSetChangedListener(this);
+ if (oldSubscriberInput != newSubscriberInput) {
+ if (oldSubscriberInput != null) {
+ ((SubscriberInput)oldSubscriberInput).getFilteredSyncSet().removeSyncSetChangedListener(this);
}
- if (newSyncSet != null) {
- newSyncSet.addSyncSetChangedListener(this);
+ if (newSubscriberInput != null) {
+ ((SubscriberInput)newSubscriberInput).getFilteredSyncSet().addSyncSetChangedListener(this);
}
}
}
@@ -218,8 +230,8 @@ public abstract class SyncSetContentProvider implements IStructuredContentProvid
public SyncInfo getSyncInfo(Object element) {
if (element instanceof SyncInfo) {
return ((SyncInfo) element);
- } else if (element instanceof SyncResource) {
- SyncResource syncResource = (SyncResource)element;
+ } else if (element instanceof SynchronizeViewNode) {
+ SynchronizeViewNode syncResource = (SynchronizeViewNode)element;
return syncResource.getSyncInfo();
}
return null;
@@ -248,7 +260,7 @@ public abstract class SyncSetContentProvider implements IStructuredContentProvid
if (resource.getType() == IResource.ROOT) {
return getSyncSet();
} else {
- return new SyncResource(getSyncSet(), resource);
+ return new SynchronizeViewNode(getSubscriberInput(), resource);
}
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/views/SyncSetTreeContentProvider.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/views/SyncSetTreeContentProvider.java
index fd54f666c..64b0c01c1 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/views/SyncSetTreeContentProvider.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/views/SyncSetTreeContentProvider.java
@@ -36,7 +36,7 @@ public class SyncSetTreeContentProvider extends SyncSetContentProvider implement
IResource resource = getResource(element);
if (resource != null) {
return members(resource);
- } else if (element instanceof SyncSet) {
+ } else if (element instanceof SubscriberInput) {
return members(ResourcesPlugin.getWorkspace().getRoot());
}
return new Object[0];
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/views/SynchronizeView.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/views/SynchronizeView.java
index d732df502..1c43813d5 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/views/SynchronizeView.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/views/SynchronizeView.java
@@ -230,7 +230,7 @@ public class SynchronizeView extends ViewPart implements ITeamResourceChangeList
ActionContext context = new ActionContext(null);
context.setInput(input);
actions.setContext(context);
- viewer.setInput(input.getFilteredSyncSet());
+ viewer.setInput(input);
RefreshSubscriberInputJob refreshJob = TeamUIPlugin.getPlugin().getRefreshJob();
refreshJob.setSubscriberInput(input);
@@ -240,7 +240,7 @@ public class SynchronizeView extends ViewPart implements ITeamResourceChangeList
updateTitle();
}
/**
- * Toggles between labe/tree/table viewers.
+ * Toggles between label/tree/table viewers.
*/
public void switchViewerType(int viewerType) {
if(viewer == null || viewerType != currentViewType) {
@@ -349,7 +349,7 @@ public class SynchronizeView extends ViewPart implements ITeamResourceChangeList
createTableViewerPartControl(parent);
break;
}
- viewer.setInput(input.getFilteredSyncSet());
+ viewer.setInput(input);
viewer.getControl().setFocus();
hookContextMenu();
initializeListeners();
@@ -632,9 +632,9 @@ public class SynchronizeView extends ViewPart implements ITeamResourceChangeList
Set result = new HashSet();
for (int i = 0; i < selected.length; i++) {
Object object = selected[i];
- if (object instanceof SyncResource) {
- SyncResource syncResource = (SyncResource) object;
- SyncInfo[] infos = syncResource.getOutOfSyncDescendants();
+ if (object instanceof SynchronizeViewNode) {
+ SynchronizeViewNode syncResource = (SynchronizeViewNode) object;
+ SyncInfo[] infos = syncResource.getChildSyncInfos();
result.addAll(Arrays.asList(infos));
}
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/views/SynchronizeViewNode.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/views/SynchronizeViewNode.java
new file mode 100644
index 000000000..782c91134
--- /dev/null
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/views/SynchronizeViewNode.java
@@ -0,0 +1,132 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.team.internal.ui.sync.views;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.team.core.subscribers.SyncInfo;
+import org.eclipse.team.core.subscribers.TeamSubscriber;
+import org.eclipse.team.internal.ui.sync.sets.SubscriberInput;
+import org.eclipse.team.internal.ui.sync.sets.SyncSet;
+import org.eclipse.team.ui.sync.*;
+import org.eclipse.ui.IActionFilter;
+
+/**
+ * A SynchronizeViewNode instance appears in the Synchronize View. Actions contributed to
+ * the view can use these instances to determine the set of resources
+ * shown based on the current filter applied to the view.
+ * <p>
+ * @see org.eclipse.team.ui.sync.ISynchronizeViewNode
+ */
+public class SynchronizeViewNode implements IAdaptable, IActionFilter, ISynchronizeViewNode {
+
+ private IResource resource;
+ private SubscriberInput input;
+
+ /**
+ * Construct a SynchromizeViewNode
+ * @param input The SubscriberInput for the node.
+ * @param resource The resource for the node
+ */
+ public SynchronizeViewNode(SubscriberInput input, IResource resource) {
+ this.input = input;
+ this.resource = resource;
+ }
+
+ protected SyncSet getSyncSet() {
+ return input.getFilteredSyncSet();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.team.ui.sync.ISynchronizeViewNode#getTeamSubscriber()
+ */
+ public TeamSubscriber getTeamSubscriber() {
+ return input.getSubscriber();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
+ */
+ public Object getAdapter(Class adapter) {
+ if (adapter == IResource.class) {
+ return getResource();
+ } else if (adapter == SyncInfo.class) {
+ return getSyncInfo();
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.team.ui.sync.ISynchronizeViewNode#getSyncInfo()
+ */
+ public SyncInfo getSyncInfo() {
+ return getSyncSet().getSyncInfo(resource);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.team.ui.sync.ISynchronizeViewNode#getChildSyncInfos()
+ */
+ public SyncInfo[] getChildSyncInfos() {
+ return getSyncSet().getOutOfSyncDescendants(resource);
+ }
+
+ /**
+ * Return true if the receiver's TeamSubscriber and Resource are equal to that of object.
+ * @param object The object to test
+ * @return true has the same subsriber and resource
+ */
+ public boolean equals(Object object) {
+ if (object instanceof SynchronizeViewNode) {
+ SynchronizeViewNode syncViewNode = (SynchronizeViewNode) object;
+ return getTeamSubscriber().equals(syncViewNode.getTeamSubscriber()) &&
+ getResource().equals(syncViewNode.getResource());
+ }
+ return super.equals(object);
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#hashCode()
+ */
+ public int hashCode() {
+ return getResource().hashCode() | getTeamSubscriber().hashCode();
+ }
+
+ /**
+ * @return IResource The receiver's resource
+ */
+ public IResource getResource() {
+ return resource;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
+ public String toString() {
+ return "SynchronizeViewNode for " + getResource().getFullPath().toString();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IActionFilter#testAttribute(java.lang.Object, java.lang.String, java.lang.String)
+ */
+ public boolean testAttribute(Object target, String name, String value) {
+ if (!(target instanceof SynchronizeViewNode)) {
+ return false;
+ }
+ TeamSubscriber subscriber = ((SynchronizeViewNode) target).getTeamSubscriber();
+ String id = subscriber.getId().toString();
+ if (name.equals("startsWith")) { //$NON-NLS-1$
+ return id.startsWith(value);
+ } else if(name.equals("equals")) { //$NON-NLS-1$
+ return id.equals(value);
+ }
+ return false;
+ }
+}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/ISynchronizeViewNode.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/ISynchronizeViewNode.java
new file mode 100644
index 000000000..4fce1ec9c
--- /dev/null
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/ISynchronizeViewNode.java
@@ -0,0 +1,82 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.team.ui.sync;
+
+import org.eclipse.team.core.subscribers.SyncInfo;
+import org.eclipse.team.core.subscribers.TeamSubscriber;
+
+/**
+ * An <code>ISynchronizeViewNode</code> is used in the <code>ISynchronizeView</code>
+ * to display the kind of change detected as the result of a two-way or three-way
+ * synchronize.
+ * <p>
+ * Clients can contribute objectContribution actions to the Synchronize View that are
+ * scoped by <code>TeamSubscriber</code> ids.
+ * <br>
+ * Example objectContribution:
+ *
+ * <extension
+ * point="org.eclipse.ui.popupMenus">
+ * <objectContribution
+ * objectClass="org.eclipse.team.ui.sync.ISynchronizeViewNode"
+ * id="yourObjectContributionID"
+ * adaptable="true">
+ *
+ * <filter name="equals" value="org.eclipse.team.cvs.subscribers:workspace-subscriber" />
+ * <action
+ * label="Your Action Label"
+ * menubarPath="SubscriberActions"
+ * class="org.eclipse.team.internal.ccvs.ui.subscriber.SubscriberCommitAction"
+ * overrideActionId="org.eclipse.team.ccvs.ui.commit"
+ * id="yourActionID">
+ * </action>
+ * </objectContribution>
+ * </extension>
+ *
+ * The above example makes use of the standard UI mechanisms for contributing ObjectContribution
+ * Actions in Eclipse. See the UI documentation for additional elements that can be declared.
+ * The interesting elements for scoping the contribution to a TeamSubscriber type are:
+ *
+ * <filter> element in the object contribution. This will remove all the actions and their
+ * overridesActionIds unless the filter is matched. The name can be "equals"
+ * or "startsWith" and the value is the ID of the subscriber.
+ *
+ * menuparPath is either SubscriberActions to place actions in their own group above other
+ * objectContributions or Additions to place the actions at the bottom of the menu with other
+ * objectContributions
+ *
+ * overrideActionId is optional but if present, is the ID of an existing objectContribution that
+ * this action should replace.
+ *
+ * </p>
+ * @see org.eclipse.team.ui.sync.ISynchronizeView
+ * @see org.eclipse.team.core.subscribers.TeamSubscriber
+ * @since 3.0
+ */
+public interface ISynchronizeViewNode {
+ /**
+ * Answer the receiver's Subscriber
+ * @return the node's TeamSubscriber
+ */
+ public abstract TeamSubscriber getTeamSubscriber();
+ /**
+ * Returns the SyncInfo for this node. Note that the SynchronizeView only creates nodes
+ * for resources that are out-of-sync.
+ * @return SyncInfo the sync info for this node
+ */
+ public abstract SyncInfo getSyncInfo();
+ /**
+ * Return an array that contains all children (including the receiver) that have SyncInfos
+ * that are out-of-sync. Returns an empty array if this node does not have children.
+ * @return SyncInfo[] all out-of-sync child resources.
+ */
+ public abstract SyncInfo[] getChildSyncInfos();
+}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/SubscriberAction.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/SubscriberAction.java
index 6da700256..99a09a57a 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/SubscriberAction.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/SubscriberAction.java
@@ -11,8 +11,12 @@
package org.eclipse.team.ui.sync;
import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
import java.util.List;
+import java.util.Set;
+import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.core.subscribers.SyncInfo;
import org.eclipse.team.core.subscribers.TeamSubscriber;
@@ -24,19 +28,28 @@ import org.eclipse.team.internal.ui.actions.TeamAction;
*/
public abstract class SubscriberAction extends TeamAction {
- TeamSubscriber subscriber;
+ private TeamSubscriber subscriber;
/**
- * This method returns all instances of SyncResource that are in the current
+ * This method returns all instances of SynchronizeViewNode that are in the current
* selection. For a table view, this is any resource that is directly selected.
- * For a tree view, this is any descendants of the slected resource that are
+ * For a tree view, this is any descendants of the selected resource that are
* contained in the view.
*
* @return the selected resources
*/
protected SyncInfo[] getSyncInfos() {
- SyncInfo[] syncInfos= (SyncInfo[])getSelectedResources(SyncInfo.class);
- return syncInfos;
+ Object[] selected = ((IStructuredSelection)selection).toArray();
+ Set result = new HashSet();
+ for (int i = 0; i < selected.length; i++) {
+ Object object = selected[i];
+ if (object instanceof ISynchronizeViewNode) {
+ ISynchronizeViewNode syncResource = (ISynchronizeViewNode) object;
+ SyncInfo[] infos = syncResource.getChildSyncInfos();
+ result.addAll(Arrays.asList(infos));
+ }
+ }
+ return (SyncInfo[]) result.toArray(new SyncInfo[result.size()]);
}
/**
@@ -78,22 +91,26 @@ public abstract class SubscriberAction extends TeamAction {
List filtered = new ArrayList();
for (int i = 0; i < infos.length; i++) {
SyncInfo info = infos[i];
+ if(subscriber == null) {
+ subscriber = info.getSubscriber();
+ }
if (select(info))
filtered.add(info);
}
return (SyncInfo[]) filtered.toArray(new SyncInfo[filtered.size()]);
}
-
+
/**
- * @return
+ * Returns the TeamSubscriber for this action.
+ * @return TeamSubscriber
*/
public TeamSubscriber getSubscriber() {
return subscriber;
}
-
+
/**
- * Sets
- * @param context
+ * Sets the the TeamSubscriber for this action.
+ * @return TeamSubscriber
*/
public void setSubscriber(TeamSubscriber subscriber) {
this.subscriber = subscriber;
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/SyncInfoSet.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/SyncInfoSet.java
index 539a12461..b6daf1ce5 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/SyncInfoSet.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/SyncInfoSet.java
@@ -202,5 +202,5 @@ public class SyncInfoSet {
}
}
-
}
+

Back to the top