View | Details | Raw Unified | Return to bug 292831 | Differences between
and this patch

Collapse All | Expand All

(-)compare/org/eclipse/compare/internal/CompareContentViewerSwitchingPane.java (-1 / +32 lines)
Lines 23-28 Link Here
23
import org.eclipse.osgi.util.NLS;
23
import org.eclipse.osgi.util.NLS;
24
import org.eclipse.swt.SWT;
24
import org.eclipse.swt.SWT;
25
import org.eclipse.swt.custom.CLabel;
25
import org.eclipse.swt.custom.CLabel;
26
import org.eclipse.swt.events.DisposeEvent;
27
import org.eclipse.swt.events.DisposeListener;
26
import org.eclipse.swt.events.MenuAdapter;
28
import org.eclipse.swt.events.MenuAdapter;
27
import org.eclipse.swt.events.MenuEvent;
29
import org.eclipse.swt.events.MenuEvent;
28
import org.eclipse.swt.events.MouseAdapter;
30
import org.eclipse.swt.events.MouseAdapter;
Lines 46-57 Link Here
46
public class CompareContentViewerSwitchingPane extends
48
public class CompareContentViewerSwitchingPane extends
47
		CompareViewerSwitchingPane {
49
		CompareViewerSwitchingPane {
48
50
51
	private static final String OPTIMIZED_WARNING_IMAGE_NAME = "obj16/warning_st_obj.gif"; //$NON-NLS-1$
52
	public static final String OPTIMIZED_ALGORITHM_USED = "OPTIMIZED_ALGORITHM_USED"; //$NON-NLS-1$
53
49
	private CompareEditorInput fCompareEditorInput;
54
	private CompareEditorInput fCompareEditorInput;
50
55
51
	private ViewerDescriptor fSelectedViewerDescriptor;
56
	private ViewerDescriptor fSelectedViewerDescriptor;
52
57
53
	private ToolBar toolBar;
58
	private ToolBar toolBar;
54
	
59
	private CLabel clOptimized;
60
55
	private boolean menuShowing;
61
	private boolean menuShowing;
56
62
57
	public CompareContentViewerSwitchingPane(Splitter parent, int style,
63
	public CompareContentViewerSwitchingPane(Splitter parent, int style,
Lines 122-127 Link Here
122
				showMenu();
128
				showMenu();
123
			}
129
			}
124
		});
130
		});
131
132
		clOptimized = new CLabel(composite, SWT.NONE);
133
		clOptimized
134
				.setText(CompareMessages.CompareContentViewerSwitchingPane_optimized);
135
		clOptimized
136
				.setToolTipText(CompareMessages.CompareContentViewerSwitchingPane_optimizedTooltip);
137
		clOptimized.setImage(CompareUIPlugin.getImageDescriptor(
138
				OPTIMIZED_WARNING_IMAGE_NAME).createImage());
139
		clOptimized.addDisposeListener(new DisposeListener() {
140
			public void widgetDisposed(DisposeEvent e) {
141
				Image img = clOptimized.getImage();
142
				if ((img != null) && (!img.isDisposed())) {
143
					img.dispose();
144
				}
145
			}
146
		});
147
125
		return composite;
148
		return composite;
126
	}
149
	}
127
	
150
	
Lines 138-143 Link Here
138
				.findContentViewerDescriptor(getViewer(), getInput(),
161
				.findContentViewerDescriptor(getViewer(), getInput(),
139
						getCompareConfiguration());
162
						getCompareConfiguration());
140
		toolBar.setVisible(vd != null && vd.length > 1);
163
		toolBar.setVisible(vd != null && vd.length > 1);
164
		CompareConfiguration cc = getCompareConfiguration();
165
		Boolean isOptimized = (Boolean) cc.getProperty(OPTIMIZED_ALGORITHM_USED);
166
		clOptimized.setVisible(isOptimized != null && isOptimized.booleanValue());
141
	}
167
	}
142
168
143
	private void showMenu() {
169
	private void showMenu() {
Lines 254-257 Link Here
254
			}
280
			}
255
		}
281
		}
256
	}
282
	}
283
284
	public void dispose () {
285
		
286
	}
287
257
}
288
}
(-)compare/org/eclipse/compare/internal/CompareMessages.java (-1 / +3 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 121-126 Link Here
121
	public static String CompareContentViewerSwitchingPane_defaultViewer;
121
	public static String CompareContentViewerSwitchingPane_defaultViewer;
122
	public static String CompareContentViewerSwitchingPane_switchButtonTooltip;
122
	public static String CompareContentViewerSwitchingPane_switchButtonTooltip;
123
	public static String CompareContentViewerSwitchingPane_discoveredLabel;
123
	public static String CompareContentViewerSwitchingPane_discoveredLabel;
124
	public static String CompareContentViewerSwitchingPane_optimized;
125
	public static String CompareContentViewerSwitchingPane_optimizedTooltip;
124
	public static String CompareStructureViewerSwitchingPane_defaultViewer;
126
	public static String CompareStructureViewerSwitchingPane_defaultViewer;
125
	public static String CompareStructureViewerSwitchingPane_switchButtonTooltip;
127
	public static String CompareStructureViewerSwitchingPane_switchButtonTooltip;
126
	public static String CompareStructureViewerSwitchingPane_discoveredLabel;
128
	public static String CompareStructureViewerSwitchingPane_discoveredLabel;
(-)compare/org/eclipse/compare/internal/CompareMessages.properties (-1 / +3 lines)
Lines 1-5 Link Here
1
###############################################################################
1
###############################################################################
2
# Copyright (c) 2000, 2009 IBM Corporation and others.
2
# Copyright (c) 2000, 2010 IBM Corporation and others.
3
# All rights reserved. This program and the accompanying materials
3
# All rights reserved. This program and the accompanying materials
4
# are made available under the terms of the Eclipse Public License v1.0
4
# are made available under the terms of the Eclipse Public License v1.0
5
# which accompanies this distribution, and is available at
5
# which accompanies this distribution, and is available at
Lines 134-139 Link Here
134
CompareContentViewerSwitchingPane_defaultViewer=Default Compare
134
CompareContentViewerSwitchingPane_defaultViewer=Default Compare
135
CompareContentViewerSwitchingPane_switchButtonTooltip=Switch Compare Viewer
135
CompareContentViewerSwitchingPane_switchButtonTooltip=Switch Compare Viewer
136
CompareContentViewerSwitchingPane_discoveredLabel={0} Compare
136
CompareContentViewerSwitchingPane_discoveredLabel={0} Compare
137
CompareContentViewerSwitchingPane_optimized=Optimized algorithm used
138
CompareContentViewerSwitchingPane_optimizedTooltip=To avoid long computation time an optimized comparison algorithm has been used. As a result a non-optimal matching could be found.
137
CompareStructureViewerSwitchingPane_defaultViewer=Default Structure Compare
139
CompareStructureViewerSwitchingPane_defaultViewer=Default Structure Compare
138
CompareStructureViewerSwitchingPane_switchButtonTooltip=Switch Structure Compare Viewer
140
CompareStructureViewerSwitchingPane_switchButtonTooltip=Switch Structure Compare Viewer
139
CompareStructureViewerSwitchingPane_discoveredLabel={0} Structure Compare
141
CompareStructureViewerSwitchingPane_discoveredLabel={0} Structure Compare
(-)compare/org/eclipse/compare/internal/merge/DocumentMerger.java (-2 / +20 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2007, 2009 IBM Corporation and others.
2
 * Copyright (c) 2007, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 16-21 Link Here
16
import org.eclipse.compare.CompareConfiguration;
16
import org.eclipse.compare.CompareConfiguration;
17
import org.eclipse.compare.contentmergeviewer.ITokenComparator;
17
import org.eclipse.compare.contentmergeviewer.ITokenComparator;
18
import org.eclipse.compare.internal.*;
18
import org.eclipse.compare.internal.*;
19
import org.eclipse.compare.internal.core.LCS;
19
import org.eclipse.compare.rangedifferencer.*;
20
import org.eclipse.compare.rangedifferencer.*;
20
import org.eclipse.compare.structuremergeviewer.Differencer;
21
import org.eclipse.compare.structuremergeviewer.Differencer;
21
import org.eclipse.core.runtime.*;
22
import org.eclipse.core.runtime.*;
Lines 447-453 Link Here
447
		} catch (InterruptedException ex) {
448
		} catch (InterruptedException ex) {
448
			// 
449
			// 
449
		}
450
		}
450
		
451
452
		if (isCapped(sa, sl, sr))
453
			fInput.getCompareConfiguration().setProperty(
454
					CompareContentViewerSwitchingPane.OPTIMIZED_ALGORITHM_USED,
455
					new Boolean(true));
456
451
		ArrayList newAllDiffs = new ArrayList();
457
		ArrayList newAllDiffs = new ArrayList();
452
		for (int i= 0; i < e.length; i++) {
458
		for (int i= 0; i < e.length; i++) {
453
			RangeDifference es= e[i];
459
			RangeDifference es= e[i];
Lines 520-525 Link Here
520
		fAllDiffs = newAllDiffs;
526
		fAllDiffs = newAllDiffs;
521
	}
527
	}
522
528
529
	private boolean isCapped(DocLineComparator ancestor,
530
			DocLineComparator left, DocLineComparator right) {
531
		int aLength = ancestor == null? 0 : ancestor.getRangeCount();
532
		int lLength = left.getRangeCount();
533
		int rLength = right.getRangeCount();
534
		if (aLength * lLength > LCS.TOO_LONG
535
				|| aLength * rLength > LCS.TOO_LONG
536
				|| lLength * lLength > LCS.TOO_LONG)
537
			return true;
538
		return false;
539
	}
540
523
	public Diff findDiff(char type, int pos) throws CoreException {
541
	public Diff findDiff(char type, int pos) throws CoreException {
524
		
542
		
525
		IDocument aDoc= null;
543
		IDocument aDoc= null;
(-)src/org/eclipse/compare/internal/core/LCS.java (-1 / +1 lines)
Lines 16-22 Link Here
16
16
17
/* Used to determine the change set responsible for each line */
17
/* Used to determine the change set responsible for each line */
18
public abstract class LCS {
18
public abstract class LCS {
19
	private static final double TOO_LONG = 10000000.0; // the value of N*M when
19
	public static final double TOO_LONG = 10000000.0; // the value of N*M when
20
														// to start binding the
20
														// to start binding the
21
														// run time
21
														// run time
22
22

Return to bug 292831