### Eclipse Workspace Patch 1.0 #P org.eclipse.compare Index: compare/org/eclipse/compare/internal/CompareMessages.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareMessages.java,v retrieving revision 1.29 diff -u -r1.29 CompareMessages.java --- compare/org/eclipse/compare/internal/CompareMessages.java 27 Mar 2010 09:55:33 -0000 1.29 +++ compare/org/eclipse/compare/internal/CompareMessages.java 13 Sep 2010 15:11:13 -0000 @@ -40,6 +40,7 @@ public static String ComparePreferencePage_2; public static String ComparePreferencePage_3; public static String ComparePreferencePage_4; + public static String ComparePreferencePage_5; public static String CompareUIPlugin_0; public static String CompareUIPlugin_1; public static String ContentMergeViewer_resource_changed_description; Index: compare/org/eclipse/compare/internal/CompareMessages.properties =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareMessages.properties,v retrieving revision 1.44 diff -u -r1.44 CompareMessages.properties --- compare/org/eclipse/compare/internal/CompareMessages.properties 13 May 2010 08:59:50 -0000 1.44 +++ compare/org/eclipse/compare/internal/CompareMessages.properties 13 Sep 2010 15:11:13 -0000 @@ -86,6 +86,7 @@ ComparePreferencePage_2=G&o to the beginning/end of the element ComparePreferencePage_3=Disp&lay the next/previous element ComparePreferencePage_4=Do ¬hing +ComparePreferencePage_5=Internal error saving capping preference CompareDialog_error_message=The changes were not saved: {0} CompareNavigator_atEnd_message= You have reached the last difference. Index: compare/org/eclipse/compare/internal/ComparePreferencePage.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ComparePreferencePage.java,v retrieving revision 1.61 diff -u -r1.61 ComparePreferencePage.java --- compare/org/eclipse/compare/internal/ComparePreferencePage.java 21 Apr 2010 10:52:08 -0000 1.61 +++ compare/org/eclipse/compare/internal/ComparePreferencePage.java 13 Sep 2010 15:11:13 -0000 @@ -20,9 +20,12 @@ import org.eclipse.compare.IEncodedStreamContentAccessor; import org.eclipse.compare.ITypedElement; import org.eclipse.compare.contentmergeviewer.TextMergeViewer; +import org.eclipse.compare.internal.core.ComparePlugin; import org.eclipse.compare.structuremergeviewer.DiffNode; import org.eclipse.compare.structuremergeviewer.Differencer; +import org.eclipse.core.runtime.CoreException; import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.dialogs.ErrorDialog; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.preference.PreferencePage; import org.eclipse.jface.preference.RadioGroupFieldEditor; @@ -92,6 +95,7 @@ public static final String USE_SINGLE_LINE= PREFIX + "UseSingleLine"; //$NON-NLS-1$ public static final String HIGHLIGHT_TOKEN_CHANGES= PREFIX + "HighlightTokenChanges"; //$NON-NLS-1$ //public static final String USE_RESOLVE_UI= PREFIX + "UseResolveUI"; //$NON-NLS-1$ + public static final String CAPPING_DISABLED= PREFIX + "CappingDisable"; //$NON-NLS-1$ public static final String PATH_FILTER= PREFIX + "PathFilter"; //$NON-NLS-1$ public static final String ADDED_LINES_REGEX= PREFIX + "AddedLinesRegex"; //$NON-NLS-1$ public static final String REMOVED_LINES_REGEX= PREFIX + "RemovedLinesRegex"; //$NON-NLS-1$ @@ -122,6 +126,7 @@ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, USE_SINGLE_LINE), new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, HIGHLIGHT_TOKEN_CHANGES), //new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, USE_RESOLVE_UI), + new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, CAPPING_DISABLED), new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PATH_FILTER), new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ICompareUIConstants.PREF_NAVIGATION_END_ACTION), new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ICompareUIConstants.PREF_NAVIGATION_END_ACTION_LOCAL), @@ -143,6 +148,7 @@ store.setDefault(USE_SINGLE_LINE, true); store.setDefault(HIGHLIGHT_TOKEN_CHANGES, true); //store.setDefault(USE_RESOLVE_UI, false); + store.setDefault(CAPPING_DISABLED, ComparePlugin.getDefault().isCappingDisabledByDefault()); store.setDefault(PATH_FILTER, ""); //$NON-NLS-1$ store.setDefault(ICompareUIConstants.PREF_NAVIGATION_END_ACTION, ICompareUIConstants.PREF_VALUE_PROMPT); store.setDefault(ICompareUIConstants.PREF_NAVIGATION_END_ACTION_LOCAL, ICompareUIConstants.PREF_VALUE_LOOP); @@ -185,6 +191,13 @@ editor.store(); fOverlayStore.propagate(); + + try { + ComparePlugin.getDefault().setCappingDisabled(fOverlayStore.getBoolean(CAPPING_DISABLED)); + } catch (CoreException e) { + ErrorDialog.openError(getShell(), CompareMessages.ComparePreferencePage_4, e.getMessage(), e.getStatus()); + return false; + } return true; } @@ -343,6 +356,7 @@ addCheckBox(composite, "ComparePreferencePage.useSingleLine.label", USE_SINGLE_LINE, 0); //$NON-NLS-1$ addCheckBox(composite, "ComparePreferencePage.highlightTokenChanges.label", HIGHLIGHT_TOKEN_CHANGES, 0); //$NON-NLS-1$ //addCheckBox(composite, "ComparePreferencePage.useResolveUI.label", USE_RESOLVE_UI, 0); //$NON-NLS-1$ + addCheckBox(composite, "ComparePreferencePage.disableCapping.label", CAPPING_DISABLED, 0); //$NON-NLS-1$ Composite radioGroup = new Composite(composite, SWT.NULL); radioGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); Index: compare/org/eclipse/compare/internal/merge/DocumentMerger.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/DocumentMerger.java,v retrieving revision 1.11 diff -u -r1.11 DocumentMerger.java --- compare/org/eclipse/compare/internal/merge/DocumentMerger.java 12 Apr 2010 14:36:06 -0000 1.11 +++ compare/org/eclipse/compare/internal/merge/DocumentMerger.java 13 Sep 2010 15:11:14 -0000 @@ -11,17 +11,36 @@ package org.eclipse.compare.internal.merge; import java.lang.reflect.InvocationTargetException; -import java.util.*; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; import org.eclipse.compare.CompareConfiguration; import org.eclipse.compare.contentmergeviewer.ITokenComparator; -import org.eclipse.compare.internal.*; +import org.eclipse.compare.internal.CompareContentViewerSwitchingPane; +import org.eclipse.compare.internal.CompareMessages; +import org.eclipse.compare.internal.CompareUIPlugin; +import org.eclipse.compare.internal.DocLineComparator; +import org.eclipse.compare.internal.MergeViewerContentProvider; +import org.eclipse.compare.internal.Utilities; +import org.eclipse.compare.internal.core.ComparePlugin; import org.eclipse.compare.internal.core.LCS; -import org.eclipse.compare.rangedifferencer.*; +import org.eclipse.compare.rangedifferencer.IRangeComparator; +import org.eclipse.compare.rangedifferencer.RangeDifference; +import org.eclipse.compare.rangedifferencer.RangeDifferencer; import org.eclipse.compare.structuremergeviewer.Differencer; -import org.eclipse.core.runtime.*; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.jface.text.*; +import org.eclipse.jface.text.BadLocationException; +import org.eclipse.jface.text.BadPositionCategoryException; +import org.eclipse.jface.text.IDocument; +import org.eclipse.jface.text.IRegion; +import org.eclipse.jface.text.Position; +import org.eclipse.jface.text.Region; +import org.eclipse.jface.text.TextUtilities; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.Point; import org.eclipse.ui.PlatformUI; @@ -430,7 +449,7 @@ monitor.done(); } }; - + RangeDifference[] e= null; try { getCompareConfiguration().getContainer().run(true, true, runnable); @@ -532,6 +551,8 @@ private boolean isCapped(DocLineComparator ancestor, DocLineComparator left, DocLineComparator right) { + if (ComparePlugin.getDefault().isCappingDisabled()) + return false; int aLength = ancestor == null? 0 : ancestor.getRangeCount(); int lLength = left.getRangeCount(); int rLength = right.getRangeCount(); Index: plugin.properties =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.compare/plugins/org.eclipse.compare/plugin.properties,v retrieving revision 1.97 diff -u -r1.97 plugin.properties --- plugin.properties 21 Apr 2010 10:52:08 -0000 1.97 +++ plugin.properties 13 Sep 2010 15:11:13 -0000 @@ -130,6 +130,7 @@ ComparePreferencePage.synchronizeScrolling.label= Synchronize &scrolling between panes in compare viewers ComparePreferencePage.useSingleLine.label= Connect &ranges with single line ComparePreferencePage.highlightTokenChanges.label=&Highlight individual changes +ComparePreferencePage.disableCapping.label=&Disable capping when comparing large documents ComparePreferencePage.preview.label= Previe&w: ComparePreferencePage.ancestor.label= Common Ancestor #P org.eclipse.compare.core Index: src/org/eclipse/compare/internal/core/ComparePlugin.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.compare/plugins/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/ComparePlugin.java,v retrieving revision 1.2 diff -u -r1.2 ComparePlugin.java --- src/org/eclipse/compare/internal/core/ComparePlugin.java 9 Feb 2010 12:10:44 -0000 1.2 +++ src/org/eclipse/compare/internal/core/ComparePlugin.java 13 Sep 2010 15:11:15 -0000 @@ -10,10 +10,14 @@ *******************************************************************************/ package org.eclipse.compare.internal.core; +import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Plugin; import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.preferences.DefaultScope; +import org.eclipse.core.runtime.preferences.IEclipsePreferences; import org.osgi.framework.BundleContext; +import org.osgi.service.prefs.BackingStoreException; /** * The activator class controls the plug-in life cycle @@ -25,12 +29,17 @@ // The shared instance private static ComparePlugin plugin; - + + private static final String CAPPING_DISABLED = "CappingDisabled"; //$NON-NLS-1$ + + private boolean cappingDisabled; + /** * The constructor */ public ComparePlugin() { - // nothing to do + IEclipsePreferences node = new DefaultScope().getNode(ComparePlugin.PLUGIN_ID); + this.cappingDisabled = node.getBoolean(CAPPING_DISABLED, isCappingDisabledByDefault()); } /* @@ -53,7 +62,7 @@ /** * Returns the shared instance - * + * * @return the shared instance */ public static ComparePlugin getDefault() { @@ -61,11 +70,31 @@ } public static void log(Throwable e) { - log(new Status(IStatus.ERROR, PLUGIN_ID, 0, Messages.Activator_1, e)); + log(new Status(IStatus.ERROR, PLUGIN_ID, 0, Messages.Activator_1, e)); } - + public static void log(IStatus status) { getDefault().getLog().log(status); } + public void setCappingDisabled(boolean disable) throws CoreException { + this.cappingDisabled = disable; + + IEclipsePreferences node = new DefaultScope().getNode(ComparePlugin.PLUGIN_ID); + node.putBoolean(CAPPING_DISABLED, disable); + try { + node.flush(); + } catch (BackingStoreException e) { + throw new CoreException(new Status(IStatus.ERROR, PLUGIN_ID, e.getMessage(), e)); + } + } + + public boolean isCappingDisabled() { + return this.cappingDisabled; + } + + public boolean isCappingDisabledByDefault() { + return false; + } + } Index: src/org/eclipse/compare/internal/core/LCS.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.compare/plugins/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/LCS.java,v retrieving revision 1.3 diff -u -r1.3 LCS.java --- src/org/eclipse/compare/internal/core/LCS.java 27 Mar 2010 09:55:29 -0000 1.3 +++ src/org/eclipse/compare/internal/core/LCS.java 13 Sep 2010 15:11:15 -0000 @@ -52,7 +52,7 @@ } this.max_differences = (length1 + length2 + 1) / 2; // ceil((N+M)/2) - if ((double) length1 * (double) length2 > TOO_LONG) { + if (!isCappingDisabled() && (double) length1 * (double) length2 > TOO_LONG) { // limit complexity to D^POW_LIMIT for long sequences this.max_differences = (int) Math.pow(this.max_differences, POW_LIMIT - 1.0); } @@ -83,7 +83,7 @@ backBoundL2--; worked(subMonitor, 1); } - + this.length = forwardBound + length1 - backBoundL1 @@ -94,6 +94,10 @@ } + private boolean isCappingDisabled() { + return ComparePlugin.getDefault().isCappingDisabled(); + } + /** * The recursive helper function for Myers' LCS. Computes the LCS of * l1[bottoml1 .. topl1] and l2[bottoml2 .. topl2] fills in the appropriate @@ -120,7 +124,7 @@ int bottoml1, int topl1, int bottoml2, int topl2, int[][] V, int[] snake, SubMonitor subMonitor) { - + // check that both sequences are non-empty if (bottoml1 > topl1 || bottoml2 > topl2) { return 0;