Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomasz Zarna2012-02-28 12:12:12 +0000
committerTomasz Zarna2012-02-28 12:12:12 +0000
commit9425ca8894f7e0d908378579ee75066cbce54d0b (patch)
tree9bf40f92d507509759bdf45740f88144dadf53e1
parent62be766bed8025810531fe026ab3b1e233904b06 (diff)
downloadeclipse.platform.team-9425ca8894f7e0d908378579ee75066cbce54d0b.tar.gz
eclipse.platform.team-9425ca8894f7e0d908378579ee75066cbce54d0b.tar.xz
eclipse.platform.team-9425ca8894f7e0d908378579ee75066cbce54d0b.zip
bug 361814:[Apply Patch]IAE: Path must include project and resource namev20120228-1212
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchTargetPage.java44
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Patcher.java50
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PreviewPatchPage2.java20
3 files changed, 62 insertions, 52 deletions
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchTargetPage.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchTargetPage.java
index 0f7317461..a7a81da55 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchTargetPage.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchTargetPage.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2010 IBM Corporation and others.
+ * Copyright (c) 2005, 2012 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
@@ -10,26 +10,14 @@
*******************************************************************************/
package org.eclipse.compare.internal.patch;
-import com.ibm.icu.text.MessageFormat;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.swt.widgets.Tree;
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-
+import org.eclipse.compare.internal.ICompareContextIds;
+import org.eclipse.compare.internal.Utilities;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
-
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.DoubleClickEvent;
@@ -40,14 +28,21 @@ import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.jface.wizard.WizardPage;
-
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.swt.widgets.Tree;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.model.WorkbenchContentProvider;
import org.eclipse.ui.model.WorkbenchLabelProvider;
import org.eclipse.ui.views.navigator.ResourceComparator;
-import org.eclipse.compare.internal.ICompareContextIds;
-import org.eclipse.compare.internal.Utilities;
+import com.ibm.icu.text.MessageFormat;
/***
* This page only shows up if the user is trying to apply
@@ -107,11 +102,20 @@ public class PatchTargetPage extends WizardPage {
fPatchTargets.getTree().setEnabled(true);
fPatcher.setTarget(Utilities.getFirstResource(fPatchTargets.getSelection()));
}
+ markPreviewPageToRecalucateIfNonWorkspacePatch();
updateWidgetEnablements();
}
});
}
+ private void markPreviewPageToRecalucateIfNonWorkspacePatch() {
+ if (!fPatcher.isWorkspacePatch()) {
+ PreviewPatchPage2 previewPage = (PreviewPatchPage2) getWizard()
+ .getPage(PreviewPatchPage2.PREVIEWPATCHPAGE_NAME);
+ previewPage.pageRecalculate = true;
+ }
+ }
+
private Button createRadioButton(Composite parent, String label, int span) {
Button button = new Button(parent, SWT.RADIO);
button.setText(label);
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Patcher.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Patcher.java
index dbed2d138..f0e1c57ec 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Patcher.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Patcher.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 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,16 +26,16 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.SubProgressMonitor;
-import org.eclipse.core.runtime.preferences.IScopeContext;
-import org.eclipse.core.runtime.preferences.InstanceScope;
-
+import org.eclipse.compare.internal.core.Messages;
+import org.eclipse.compare.internal.core.patch.DiffProject;
+import org.eclipse.compare.internal.core.patch.FileDiffResult;
+import org.eclipse.compare.internal.core.patch.FilePatch2;
+import org.eclipse.compare.internal.core.patch.Hunk;
+import org.eclipse.compare.internal.core.patch.PatchReader;
+import org.eclipse.compare.patch.IHunk;
+import org.eclipse.compare.patch.IHunkFilter;
+import org.eclipse.compare.patch.PatchConfiguration;
+import org.eclipse.core.filebuffers.FileBuffers;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
@@ -45,21 +45,18 @@ import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IStorage;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ProjectScope;
-
-import org.eclipse.core.filebuffers.FileBuffers;
-
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.core.runtime.preferences.IScopeContext;
+import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.jface.text.TextUtilities;
-import org.eclipse.compare.internal.core.Messages;
-import org.eclipse.compare.internal.core.patch.DiffProject;
-import org.eclipse.compare.internal.core.patch.FileDiffResult;
-import org.eclipse.compare.internal.core.patch.FilePatch2;
-import org.eclipse.compare.internal.core.patch.Hunk;
-import org.eclipse.compare.internal.core.patch.PatchReader;
-import org.eclipse.compare.patch.IHunk;
-import org.eclipse.compare.patch.IHunkFilter;
-import org.eclipse.compare.patch.PatchConfiguration;
-
/**
* A Patcher
* - knows how to parse various patch file formats into some in-memory structure,
@@ -515,11 +512,14 @@ public class Patcher implements IHunkFilter {
//Update prefix count - go through all of the diffs and find the smallest
//path segment contained in all diffs.
int length= 99;
- if (fDiffs!=null)
+ if (fDiffs!=null) {
for (int i= 0; i<fDiffs.length; i++) {
FilePatch2 diff= fDiffs[i];
length= Math.min(length, diff.segmentCount());
}
+ if (ResourcesPlugin.getWorkspace().getRoot().equals(fTarget))
+ length--;
+ }
return length;
}
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PreviewPatchPage2.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PreviewPatchPage2.java
index 7414cbef3..72763cc89 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PreviewPatchPage2.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PreviewPatchPage2.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2009 IBM Corporation and others.
+ * Copyright (c) 2005, 2012 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
@@ -406,17 +406,23 @@ public class PreviewPatchPage2 extends WizardPage {
fStripPrefixSegments.setEnabled(false);
} else {
fStripPrefixSegments.setEnabled(true);
- int length= 99;
- if (fStripPrefixSegments!=null && pageRecalculate) {
- length= getPatcher().calculatePrefixSegmentCount();
- if (length!=99) {
- for (int k= 1; k<length; k++)
+ int length = 99;
+ if (fStripPrefixSegments != null && pageRecalculate) {
+ if (fStripPrefixSegments.getItemCount() > 1)
+ fStripPrefixSegments.remove(1,
+ fStripPrefixSegments.getItemCount() - 1);
+ length = getPatcher().calculatePrefixSegmentCount();
+ if (length != 99) {
+ for (int k = 1; k < length; k++)
fStripPrefixSegments.add(Integer.toString(k));
- pageRecalculate= false;
+ fStripPrefixSegments.select(0);
+ getPatcher().setStripPrefixSegments(0);
+ pageRecalculate = false;
}
}
}
}
+
/*
* Create the group for setting various patch options
*/

Back to the top