Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Valenta2006-01-25 14:18:53 +0000
committerMichael Valenta2006-01-25 14:18:53 +0000
commit53a8c311587d2baea0eb750607d3f19849ade4c0 (patch)
treef80255143931d9f833e691a68321d35416aa2dc7
parent03aa49c1e96e17f74f8c6db05fac9a687389d80c (diff)
downloadeclipse.platform.team-53a8c311587d2baea0eb750607d3f19849ade4c0.tar.gz
eclipse.platform.team-53a8c311587d2baea0eb750607d3f19849ade4c0.tar.xz
eclipse.platform.team-53a8c311587d2baea0eb750607d3f19849ade4c0.zip
Added Create Patch to CVS model sync
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/CVSResourceMappingParticipant.java9
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/CreatePatchAction.java86
2 files changed, 90 insertions, 5 deletions
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/CVSResourceMappingParticipant.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/CVSResourceMappingParticipant.java
index a4f1679dc..e8cb4dd0a 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/CVSResourceMappingParticipant.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/CVSResourceMappingParticipant.java
@@ -67,11 +67,10 @@ public class CVSResourceMappingParticipant extends
}
if (!configuration.getSite().isModal()) {
- // TODO: needs to be converted
-// appendToGroup(
-// ISynchronizePageConfiguration.P_CONTEXT_MENU,
-// CONTEXT_MENU_CONTRIBUTION_GROUP_3,
-// new CreatePatchAction(configuration));
+ appendToGroup(
+ ISynchronizePageConfiguration.P_CONTEXT_MENU,
+ CONTEXT_MENU_CONTRIBUTION_GROUP_3,
+ new CreatePatchAction(configuration));
appendToGroup(
ISynchronizePageConfiguration.P_CONTEXT_MENU,
CONTEXT_MENU_CONTRIBUTION_GROUP_3,
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/CreatePatchAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/CreatePatchAction.java
new file mode 100644
index 000000000..82ec68a2d
--- /dev/null
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/CreatePatchAction.java
@@ -0,0 +1,86 @@
+/*******************************************************************************
+ * Copyright (c) 2006 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.team.internal.ccvs.ui.mappings;
+
+import java.util.*;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.mapping.*;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.team.core.diff.*;
+import org.eclipse.team.core.mapping.IResourceDiffTree;
+import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
+import org.eclipse.team.internal.ccvs.ui.wizards.GenerateDiffFileWizard;
+import org.eclipse.team.internal.ui.Utils;
+import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration;
+
+public class CreatePatchAction extends CVSModelProviderAction {
+
+ public CreatePatchAction(ISynchronizePageConfiguration configuration) {
+ super(configuration);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.team.internal.ui.mapping.ModelProviderAction#isEnabledForSelection(org.eclipse.jface.viewers.IStructuredSelection)
+ */
+ protected boolean isEnabledForSelection(IStructuredSelection selection) {
+ try {
+ IResource[] resources = getVisibleResources(selection);
+ return resources.length > 0;
+ } catch (CoreException e) {
+ CVSUIPlugin.log(e);
+ return false;
+ }
+ }
+
+ private IResource[] getVisibleResources(IStructuredSelection selection) throws CoreException {
+ final Set resources = new HashSet();
+ for (Iterator iter = selection.iterator(); iter.hasNext();) {
+ Object element = iter.next();
+ ResourceMapping mapping = Utils.getResourceMapping(element);
+ ResourceTraversal[] traversals = mapping.getTraversals(ResourceMappingContext.LOCAL_CONTEXT, null);
+ final IResourceDiffTree diffTree = getContext().getDiffTree();
+ diffTree.accept(new IDiffVisitor() {
+ public boolean visit(IDiffNode delta) throws CoreException {
+ IResource resource = diffTree.getResource(delta);
+ if (resource.getType() == IResource.FILE && delta instanceof IThreeWayDiff) {
+ IThreeWayDiff twd = (IThreeWayDiff) delta;
+ IDiffNode local = twd.getLocalChange();
+ if (local != null && local.getKind() != IDiffNode.NO_CHANGE) {
+ resources.add(resource);
+ }
+ }
+ return true;
+ }
+
+ }, traversals);
+ }
+ return (IResource[]) resources.toArray(new IResource[resources.size()]);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.team.internal.ccvs.ui.mappings.CVSModelProviderAction#getBundleKeyPrefix()
+ */
+ protected String getBundleKeyPrefix() {
+ return "GenerateDiffFileAction."; //$NON-NLS-1$
+ }
+
+ public void run() {
+ try {
+ IResource[] resources = getVisibleResources(getStructuredSelection());
+ GenerateDiffFileWizard.run(getConfiguration().getSite().getPart(), resources, false);
+ } catch (CoreException e) {
+ CVSUIPlugin.openError(getConfiguration().getSite().getShell(), null, null, e);
+ }
+ }
+
+}

Back to the top