### Eclipse Workspace Patch 1.0 #P org.eclipse.compare Index: compare/org/eclipse/compare/internal/CompareContentViewerSwitchingPane.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareContentViewerSwitchingPane.java,v retrieving revision 1.7 diff -u -r1.7 CompareContentViewerSwitchingPane.java --- compare/org/eclipse/compare/internal/CompareContentViewerSwitchingPane.java 22 Mar 2010 13:13:07 -0000 1.7 +++ compare/org/eclipse/compare/internal/CompareContentViewerSwitchingPane.java 27 Mar 2010 09:48:23 -0000 @@ -23,6 +23,8 @@ import org.eclipse.osgi.util.NLS; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.CLabel; +import org.eclipse.swt.events.DisposeEvent; +import org.eclipse.swt.events.DisposeListener; import org.eclipse.swt.events.MenuAdapter; import org.eclipse.swt.events.MenuEvent; import org.eclipse.swt.events.MouseAdapter; @@ -46,12 +48,16 @@ public class CompareContentViewerSwitchingPane extends CompareViewerSwitchingPane { + private static final String OPTIMIZED_WARNING_IMAGE_NAME = "obj16/warning_st_obj.gif"; //$NON-NLS-1$ + public static final String OPTIMIZED_ALGORITHM_USED = "OPTIMIZED_ALGORITHM_USED"; //$NON-NLS-1$ + private CompareEditorInput fCompareEditorInput; private ViewerDescriptor fSelectedViewerDescriptor; private ToolBar toolBar; - + private CLabel clOptimized; + private boolean menuShowing; public CompareContentViewerSwitchingPane(Splitter parent, int style, @@ -122,6 +128,23 @@ showMenu(); } }); + + clOptimized = new CLabel(composite, SWT.NONE); + clOptimized + .setText(CompareMessages.CompareContentViewerSwitchingPane_optimized); + clOptimized + .setToolTipText(CompareMessages.CompareContentViewerSwitchingPane_optimizedTooltip); + clOptimized.setImage(CompareUIPlugin.getImageDescriptor( + OPTIMIZED_WARNING_IMAGE_NAME).createImage()); + clOptimized.addDisposeListener(new DisposeListener() { + public void widgetDisposed(DisposeEvent e) { + Image img = clOptimized.getImage(); + if ((img != null) && (!img.isDisposed())) { + img.dispose(); + } + } + }); + return composite; } @@ -138,6 +161,9 @@ .findContentViewerDescriptor(getViewer(), getInput(), getCompareConfiguration()); toolBar.setVisible(vd != null && vd.length > 1); + CompareConfiguration cc = getCompareConfiguration(); + Boolean isOptimized = (Boolean) cc.getProperty(OPTIMIZED_ALGORITHM_USED); + clOptimized.setVisible(isOptimized != null && isOptimized.booleanValue()); } private void showMenu() { @@ -254,4 +280,9 @@ } } } + + public void dispose () { + + } + } 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.28 diff -u -r1.28 CompareMessages.java --- compare/org/eclipse/compare/internal/CompareMessages.java 22 Jun 2009 10:07:23 -0000 1.28 +++ compare/org/eclipse/compare/internal/CompareMessages.java 27 Mar 2010 09:48:23 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. + * Copyright (c) 2000, 2010 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 @@ -121,6 +121,8 @@ public static String CompareContentViewerSwitchingPane_defaultViewer; public static String CompareContentViewerSwitchingPane_switchButtonTooltip; public static String CompareContentViewerSwitchingPane_discoveredLabel; + public static String CompareContentViewerSwitchingPane_optimized; + public static String CompareContentViewerSwitchingPane_optimizedTooltip; public static String CompareStructureViewerSwitchingPane_defaultViewer; public static String CompareStructureViewerSwitchingPane_switchButtonTooltip; public static String CompareStructureViewerSwitchingPane_discoveredLabel; 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.39 diff -u -r1.39 CompareMessages.properties --- compare/org/eclipse/compare/internal/CompareMessages.properties 22 Jun 2009 10:07:23 -0000 1.39 +++ compare/org/eclipse/compare/internal/CompareMessages.properties 27 Mar 2010 09:48:23 -0000 @@ -1,5 +1,5 @@ ############################################################################### -# Copyright (c) 2000, 2009 IBM Corporation and others. +# Copyright (c) 2000, 2010 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 @@ -134,6 +134,8 @@ CompareContentViewerSwitchingPane_defaultViewer=Default Compare CompareContentViewerSwitchingPane_switchButtonTooltip=Switch Compare Viewer CompareContentViewerSwitchingPane_discoveredLabel={0} Compare +CompareContentViewerSwitchingPane_optimized=Optimized algorithm used +CompareContentViewerSwitchingPane_optimizedTooltip=To avoid long computation time an optimized comparison algorithm has been used. As a result a non-optimal matching could be found. CompareStructureViewerSwitchingPane_defaultViewer=Default Structure Compare CompareStructureViewerSwitchingPane_switchButtonTooltip=Switch Structure Compare Viewer CompareStructureViewerSwitchingPane_discoveredLabel={0} Structure Compare 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.8 diff -u -r1.8 DocumentMerger.java --- compare/org/eclipse/compare/internal/merge/DocumentMerger.java 20 Jan 2009 10:33:16 -0000 1.8 +++ compare/org/eclipse/compare/internal/merge/DocumentMerger.java 27 Mar 2010 09:48:24 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 IBM Corporation and others. + * Copyright (c) 2007, 2010 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 @@ -16,6 +16,7 @@ import org.eclipse.compare.CompareConfiguration; import org.eclipse.compare.contentmergeviewer.ITokenComparator; import org.eclipse.compare.internal.*; +import org.eclipse.compare.internal.core.LCS; import org.eclipse.compare.rangedifferencer.*; import org.eclipse.compare.structuremergeviewer.Differencer; import org.eclipse.core.runtime.*; @@ -447,7 +448,12 @@ } catch (InterruptedException ex) { // } - + + if (isCapped(sa, sl, sr)) + fInput.getCompareConfiguration().setProperty( + CompareContentViewerSwitchingPane.OPTIMIZED_ALGORITHM_USED, + new Boolean(true)); + ArrayList newAllDiffs = new ArrayList(); for (int i= 0; i < e.length; i++) { RangeDifference es= e[i]; @@ -520,6 +526,18 @@ fAllDiffs = newAllDiffs; } + private boolean isCapped(DocLineComparator ancestor, + DocLineComparator left, DocLineComparator right) { + int aLength = ancestor == null? 0 : ancestor.getRangeCount(); + int lLength = left.getRangeCount(); + int rLength = right.getRangeCount(); + if (aLength * lLength > LCS.TOO_LONG + || aLength * rLength > LCS.TOO_LONG + || lLength * lLength > LCS.TOO_LONG) + return true; + return false; + } + public Diff findDiff(char type, int pos) throws CoreException { IDocument aDoc= null; #P org.eclipse.compare.core 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.2 diff -u -r1.2 LCS.java --- src/org/eclipse/compare/internal/core/LCS.java 9 Feb 2010 12:10:44 -0000 1.2 +++ src/org/eclipse/compare/internal/core/LCS.java 27 Mar 2010 09:48:26 -0000 @@ -16,7 +16,7 @@ /* Used to determine the change set responsible for each line */ public abstract class LCS { - private static final double TOO_LONG = 10000000.0; // the value of N*M when + public static final double TOO_LONG = 10000000.0; // the value of N*M when // to start binding the // run time