Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomasz Zarna2008-07-10 10:37:26 -0400
committerTomasz Zarna2008-07-10 10:37:26 -0400
commitfe4d6f3dcd05217831adf91ae5746e8fc6d1fdc5 (patch)
tree5c03cc3635e2e87e362c6132a8e2455136b38fab
parent51548d753336388e757d07b5e7ca2f246f684f0c (diff)
downloadeclipse.platform.team-fe4d6f3dcd05217831adf91ae5746e8fc6d1fdc5.tar.gz
eclipse.platform.team-fe4d6f3dcd05217831adf91ae5746e8fc6d1fdc5.tar.xz
eclipse.platform.team-fe4d6f3dcd05217831adf91ae5746e8fc6d1fdc5.zip
bug 239008: Add 'Apply Patch' to synchronized view
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/actions.properties5
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/ApplyPatchAction.java84
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/WorkspaceModelParticipant.java6
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/ApplyPatchAction.java63
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceSynchronizeParticipant.java9
5 files changed, 163 insertions, 4 deletions
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/actions.properties b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/actions.properties
index 3699e2492..093d67d99 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/actions.properties
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/actions.properties
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2000, 2007 IBM Corporation and others.
+# Copyright (c) 2000, 2008 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
@@ -74,6 +74,9 @@ ShowAnnotationAction.tooltip=Show Annotation
GenerateDiffFileAction.label=Create &Patch...
GenerateDiffFileAction.tooltip=Compare your workspace contents with the server and generate a diff file that can be used as a patch file.
+ApplyPatchAction.label=Appl&y Patch...
+ApplyPatchAction.tooltip=Apply a patch to one or more workspace projects.
+
MergeUpdateAction.label=&Update
MergeUpdateAction.tooltip=Perform an update merge on the selected resources
MergeUpdateAction.helpContextId=org.eclipse.team.cvs.ui.merge_update_action
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/ApplyPatchAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/ApplyPatchAction.java
new file mode 100644
index 000000000..88fb09b14
--- /dev/null
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/ApplyPatchAction.java
@@ -0,0 +1,84 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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 org.eclipse.compare.CompareConfiguration;
+import org.eclipse.compare.patch.ApplyPatchOperation;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.*;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.custom.BusyIndicator;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.team.core.diff.*;
+import org.eclipse.team.internal.ui.TeamUIPlugin;
+import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration;
+
+public class ApplyPatchAction extends CVSModelProviderAction implements
+ IDiffChangeListener {
+
+ public ApplyPatchAction(ISynchronizePageConfiguration configuration) {
+ super(configuration);
+ getSynchronizationContext().getDiffTree().addDiffChangeListener(this);
+ }
+
+ protected void execute() {
+ IResource resource = (IResource) Platform.getAdapterManager()
+ .getAdapter(getStructuredSelection().getFirstElement(),
+ IResource.class);
+
+ boolean isPatch = false;
+ if (resource instanceof IFile) {
+ try {
+ isPatch = ApplyPatchOperation.isPatch((IFile) resource);
+ } catch (CoreException e) {
+ TeamUIPlugin.log(e);
+ }
+ }
+
+ final ApplyPatchOperation op;
+ if (isPatch) {
+ op = new ApplyPatchOperation(
+ getConfiguration().getSite().getPart(), (IFile) resource,
+ null, new CompareConfiguration());
+ } else {
+ op = new ApplyPatchOperation(
+ getConfiguration().getSite().getPart(), resource);
+ }
+ BusyIndicator.showWhile(Display.getDefault(), op);
+ }
+
+ protected boolean isEnabledForSelection(IStructuredSelection selection) {
+ return internalIsEnabled(selection);
+ }
+
+ private boolean internalIsEnabled(IStructuredSelection selection) {
+ Object firstElement = selection.getFirstElement();
+ if (firstElement == null)
+ return false;
+ Object adapter = Platform.getAdapterManager().getAdapter(firstElement,
+ IResource.class);
+ return adapter != null;
+ }
+
+ public void diffsChanged(IDiffChangeEvent event, IProgressMonitor monitor) {
+ updateEnablement();
+ }
+
+ public void propertyChanged(IDiffTree tree, int property, IPath[] paths) {
+ // do nothing
+ }
+
+ protected String getBundleKeyPrefix() {
+ return "ApplyPatchAction."; //$NON-NLS-1$
+ }
+
+}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/WorkspaceModelParticipant.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/WorkspaceModelParticipant.java
index 57cb9edb8..b4dce8dd1 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/WorkspaceModelParticipant.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/WorkspaceModelParticipant.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2007 IBM Corporation and others.
+ * Copyright (c) 2006, 2008 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
@@ -128,6 +128,10 @@ public class WorkspaceModelParticipant extends
appendToGroup(
ISynchronizePageConfiguration.P_CONTEXT_MENU,
CONTEXT_MENU_CONTRIBUTION_GROUP_3,
+ new ApplyPatchAction(configuration));
+ appendToGroup(
+ ISynchronizePageConfiguration.P_CONTEXT_MENU,
+ CONTEXT_MENU_CONTRIBUTION_GROUP_3,
new CVSActionDelegateWrapper(new BranchAction(), configuration));
appendToGroup(
ISynchronizePageConfiguration.P_CONTEXT_MENU,
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/ApplyPatchAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/ApplyPatchAction.java
new file mode 100644
index 000000000..e1582bc40
--- /dev/null
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/ApplyPatchAction.java
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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.subscriber;
+
+import org.eclipse.compare.CompareConfiguration;
+import org.eclipse.compare.patch.ApplyPatchOperation;
+import org.eclipse.compare.structuremergeviewer.IDiffElement;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.swt.custom.BusyIndicator;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.team.internal.ui.TeamUIPlugin;
+import org.eclipse.team.internal.ui.synchronize.SynchronizeModelElement;
+import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration;
+import org.eclipse.team.ui.synchronize.SynchronizeModelOperation;
+
+public class ApplyPatchAction extends CVSParticipantAction {
+
+ public ApplyPatchAction(ISynchronizePageConfiguration configuration) {
+ super(configuration);
+ }
+
+ protected SynchronizeModelOperation getSubscriberOperation(
+ ISynchronizePageConfiguration configuration, IDiffElement[] elements) {
+ return null;
+ }
+
+ public void runOperation() {
+
+ IResource resource = ((SynchronizeModelElement) getStructuredSelection()
+ .getFirstElement()).getResource();
+
+ boolean isPatch = false;
+ if (resource instanceof IFile) {
+ try {
+ isPatch = ApplyPatchOperation.isPatch((IFile) resource);
+ } catch (CoreException e) {
+ TeamUIPlugin.log(e);
+ }
+ }
+
+ final ApplyPatchOperation op;
+ if (isPatch) {
+ op = new ApplyPatchOperation(
+ getConfiguration().getSite().getPart(), (IFile) resource,
+ null, new CompareConfiguration());
+ } else {
+ op = new ApplyPatchOperation(
+ getConfiguration().getSite().getPart(), resource);
+ }
+ BusyIndicator.showWhile(Display.getDefault(), op);
+ }
+
+}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceSynchronizeParticipant.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceSynchronizeParticipant.java
index 24866d2b6..5f8757612 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceSynchronizeParticipant.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceSynchronizeParticipant.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * Copyright (c) 2000, 2008 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
@@ -26,7 +26,8 @@ import org.eclipse.team.core.mapping.provider.ResourceDiffTree;
import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
import org.eclipse.team.internal.ccvs.ui.*;
import org.eclipse.team.internal.ccvs.ui.actions.*;
-import org.eclipse.team.internal.core.subscribers.*;
+import org.eclipse.team.internal.core.subscribers.ActiveChangeSet;
+import org.eclipse.team.internal.core.subscribers.ActiveChangeSetManager;
import org.eclipse.team.internal.ui.synchronize.*;
import org.eclipse.team.ui.TeamUI;
import org.eclipse.team.ui.synchronize.*;
@@ -110,6 +111,10 @@ public class WorkspaceSynchronizeParticipant extends ScopableSubscriberParticipa
appendToGroup(
ISynchronizePageConfiguration.P_CONTEXT_MENU,
CONTEXT_MENU_CONTRIBUTION_GROUP_3,
+ new ApplyPatchAction(configuration));
+ appendToGroup(
+ ISynchronizePageConfiguration.P_CONTEXT_MENU,
+ CONTEXT_MENU_CONTRIBUTION_GROUP_3,
new CVSActionDelegateWrapper(new BranchAction(), configuration));
appendToGroup(
ISynchronizePageConfiguration.P_CONTEXT_MENU,

Back to the top