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

Collapse All | Expand All

(-)compare/org/eclipse/compare/internal/GenerateDiffFileWizard.java (-32 / +310 lines)
Lines 15-27 Link Here
15
15
16
import java.io.File;
16
import java.io.File;
17
import java.io.IOException;
17
import java.io.IOException;
18
import java.io.InputStream;
18
import java.net.MalformedURLException;
19
import java.net.MalformedURLException;
19
import java.net.URL;
20
import java.net.URL;
20
import java.util.ArrayList;
21
import java.util.ArrayList;
21
import java.util.Iterator;
22
import java.util.Iterator;
22
import java.util.List;
23
import java.util.List;
23
24
25
import org.eclipse.compare.CompareConfiguration;
26
import org.eclipse.compare.CompareEditorInput;
27
import org.eclipse.compare.ITypedElement;
28
import org.eclipse.compare.ResourceNode;
29
import org.eclipse.compare.contentmergeviewer.ITokenComparator;
30
import org.eclipse.compare.contentmergeviewer.TokenComparator;
31
import org.eclipse.compare.internal.ResourceCompareInput.FilteredBufferedResourceNode;
24
import org.eclipse.compare.internal.merge.DocumentMerger;
32
import org.eclipse.compare.internal.merge.DocumentMerger;
33
import org.eclipse.compare.internal.merge.DocumentMerger.IDocumentMergerInput;
34
import org.eclipse.compare.structuremergeviewer.DiffNode;
35
import org.eclipse.compare.structuremergeviewer.Differencer;
36
import org.eclipse.compare.structuremergeviewer.ICompareInput;
37
import org.eclipse.compare.structuremergeviewer.IDiffElement;
25
import org.eclipse.core.resources.IContainer;
38
import org.eclipse.core.resources.IContainer;
26
import org.eclipse.core.resources.IFile;
39
import org.eclipse.core.resources.IFile;
27
import org.eclipse.core.resources.IProject;
40
import org.eclipse.core.resources.IProject;
Lines 35-44 Link Here
35
import org.eclipse.jface.dialogs.Dialog;
48
import org.eclipse.jface.dialogs.Dialog;
36
import org.eclipse.jface.dialogs.IDialogConstants;
49
import org.eclipse.jface.dialogs.IDialogConstants;
37
import org.eclipse.jface.dialogs.IDialogSettings;
50
import org.eclipse.jface.dialogs.IDialogSettings;
51
import org.eclipse.jface.dialogs.IPageChangingListener;
38
import org.eclipse.jface.dialogs.MessageDialog;
52
import org.eclipse.jface.dialogs.MessageDialog;
53
import org.eclipse.jface.dialogs.PageChangingEvent;
39
import org.eclipse.jface.dialogs.TitleAreaDialog;
54
import org.eclipse.jface.dialogs.TitleAreaDialog;
40
import org.eclipse.jface.resource.ImageDescriptor;
55
import org.eclipse.jface.resource.ImageDescriptor;
56
import org.eclipse.jface.text.Document;
41
import org.eclipse.jface.text.IDocument;
57
import org.eclipse.jface.text.IDocument;
58
import org.eclipse.jface.text.Position;
42
import org.eclipse.jface.viewers.DoubleClickEvent;
59
import org.eclipse.jface.viewers.DoubleClickEvent;
43
import org.eclipse.jface.viewers.IDoubleClickListener;
60
import org.eclipse.jface.viewers.IDoubleClickListener;
44
import org.eclipse.jface.viewers.ISelection;
61
import org.eclipse.jface.viewers.ISelection;
Lines 69-74 Link Here
69
import org.eclipse.swt.widgets.Listener;
86
import org.eclipse.swt.widgets.Listener;
70
import org.eclipse.swt.widgets.Shell;
87
import org.eclipse.swt.widgets.Shell;
71
import org.eclipse.swt.widgets.Text;
88
import org.eclipse.swt.widgets.Text;
89
import org.eclipse.ui.IWorkbenchPart;
72
import org.eclipse.ui.model.BaseWorkbenchContentProvider;
90
import org.eclipse.ui.model.BaseWorkbenchContentProvider;
73
import org.eclipse.ui.model.WorkbenchLabelProvider;
91
import org.eclipse.ui.model.WorkbenchLabelProvider;
74
import org.eclipse.ui.views.navigator.ResourceComparator;
92
import org.eclipse.ui.views.navigator.ResourceComparator;
Lines 88-97 Link Here
88
		final GenerateDiffFileWizard wizard = new GenerateDiffFileWizard(merger, rightToLeft);
106
		final GenerateDiffFileWizard wizard = new GenerateDiffFileWizard(merger, rightToLeft);
89
		wizard.setWindowTitle(title);
107
		wizard.setWindowTitle(title);
90
		WizardDialog dialog = new WizardDialog(shell, wizard);
108
		WizardDialog dialog = new WizardDialog(shell, wizard);
109
		
110
		dialog.addPageChangingListener(new IPageChangingListener() {
111
112
			public void handlePageChanging(PageChangingEvent event) {
113
				if(event.getTargetPage() instanceof LocationPage) {
114
					LocationPage page = (LocationPage) event.getTargetPage();
115
					page.updateAssociatedResources();
116
				}
117
			}
118
			
119
		});
120
		
91
		dialog.setMinimumPageSize(INITIAL_WIDTH, INITIAL_HEIGHT);
121
		dialog.setMinimumPageSize(INITIAL_WIDTH, INITIAL_HEIGHT);
92
		dialog.open();
122
		dialog.open();
93
	}
123
	}
124
	public static void run(IResource[] input, Shell shell) {
125
		final String title = CompareMessages.GenerateLocalDiff_title;
126
		final GenerateDiffFileWizard wizard = new GenerateDiffFileWizard(input);
127
		wizard.setWindowTitle(title);
128
		WizardDialog dialog = new WizardDialog(shell, wizard);
129
		
130
		dialog.addPageChangingListener(new IPageChangingListener() {
94
131
132
			public void handlePageChanging(PageChangingEvent event) {
133
				if(event.getTargetPage() instanceof LocationPage) {
134
					LocationPage page = (LocationPage) event.getTargetPage();
135
					page.updateAssociatedResources();
136
				}
137
			}
138
			
139
		});
140
		
141
		dialog.setMinimumPageSize(INITIAL_WIDTH, INITIAL_HEIGHT);
142
		dialog.open();
143
		
144
	}
145
95
	protected class DirectionSelectionPage extends WizardPage {
146
	protected class DirectionSelectionPage extends WizardPage {
96
147
97
		public final static int LEFT_OPTION = 1;
148
		public final static int LEFT_OPTION = 1;
Lines 214-220 Link Here
214
		 */
265
		 */
215
		private final DefaultValuesStore store;
266
		private final DefaultValuesStore store;
216
267
217
218
		class LocationPageContentProvider extends BaseWorkbenchContentProvider {
268
		class LocationPageContentProvider extends BaseWorkbenchContentProvider {
219
			//Never show closed projects
269
			//Never show closed projects
220
			boolean showClosedProjects=false;
270
			boolean showClosedProjects=false;
Lines 448-453 Link Here
448
			this.store= store;
498
			this.store= store;
449
		}
499
		}
450
500
501
		public void updateAssociatedResources() {
502
			Differencer dif = new Differencer();
503
			if(directionSelectionPage.isRightToLeft())
504
				startNode = (DiffNode) dif.findDifferences(false, null, null, null, 
505
														new FilteredBufferedResourceNode(rightResource), 
506
														new FilteredBufferedResourceNode(leftResource));
507
			else if(!directionSelectionPage.isRightToLeft())
508
				startNode = (DiffNode) dif.findDifferences(false, null, null, null, 
509
														new FilteredBufferedResourceNode(leftResource), 
510
														new FilteredBufferedResourceNode(rightResource));
511
			associatedResources = buildMap(startNode);
512
		}
513
451
		/**
514
		/**
452
		 * Allow the user to finish if a valid file has been entered.
515
		 * Allow the user to finish if a valid file has been entered.
453
		 */
516
		 */
Lines 463-469 Link Here
463
				pageValid= true;
526
				pageValid= true;
464
				break;
527
				break;
465
			}
528
			}
466
529
			
467
			/**
530
			/**
468
			 * Avoid draw flicker by clearing error message
531
			 * Avoid draw flicker by clearing error message
469
			 * if all is valid.
532
			 * if all is valid.
Lines 623-629 Link Here
623
		public void createControl(Composite parent) {
686
		public void createControl(Composite parent) {
624
687
625
			final Composite composite= new Composite(parent, SWT.NULL);
688
			final Composite composite= new Composite(parent, SWT.NULL);
626
			composite.setLayout(new GridLayout());
689
			GridLayout lay = new GridLayout();
690
			lay.verticalSpacing = 15;
691
			composite.setLayout(lay);
627
			setControl(composite);
692
			setControl(composite);
628
			initializeDialogUnits(composite);
693
			initializeDialogUnits(composite);
629
694
Lines 632-640 Link Here
632
697
633
			//Create a location group
698
			//Create a location group
634
			setupLocationControls(composite);
699
			setupLocationControls(composite);
635
700
			
636
			initializeDefaultValues();
701
			initializeDefaultValues();
637
702
			
638
			Dialog.applyDialogFont(parent);
703
			Dialog.applyDialogFont(parent);
639
704
640
			validatePage();
705
			validatePage();
Lines 643-648 Link Here
643
			setupListeners();
708
			setupListeners();
644
		}
709
		}
645
710
711
		
646
		/**
712
		/**
647
		 * Setup the controls for the location.
713
		 * Setup the controls for the location.
648
		 */
714
		 */
Lines 815-821 Link Here
815
			});
881
			});
816
882
817
		}
883
		}
818
884
        
819
		/**
885
		/**
820
		 * Enable and disable controls based on the selected radio button.
886
		 * Enable and disable controls based on the selected radio button.
821
		 */
887
		 */
Lines 1158-1164 Link Here
1158
1224
1159
	private final DefaultValuesStore defaultValuesStore;
1225
	private final DefaultValuesStore defaultValuesStore;
1160
1226
1161
	private DocumentMerger merger;
1162
	private IDocument leftDoc;
1227
	private IDocument leftDoc;
1163
	private IDocument rightDoc;
1228
	private IDocument rightDoc;
1164
	private String leftPath;
1229
	private String leftPath;
Lines 1170-1192 Link Here
1170
	private Text unified_customRelativeText;
1235
	private Text unified_customRelativeText;
1171
	private Button unified_customRelativeOption;
1236
	private Button unified_customRelativeOption;
1172
1237
1238
	private IResource rightResource;
1239
	private IResource leftResource;
1240
	
1241
	private ArrayList associatedResources;
1242
	
1173
	public GenerateDiffFileWizard() {
1243
	public GenerateDiffFileWizard() {
1174
		super();
1244
		super();
1175
		setWindowTitle(CompareMessages.GenerateLocalDiff_title);
1245
		setWindowTitle(CompareMessages.GenerateLocalDiff_title);
1176
		initializeDefaultPageImageDescriptor();
1246
		initializeDefaultPageImageDescriptor();
1177
		defaultValuesStore = new DefaultValuesStore();
1247
		defaultValuesStore = new DefaultValuesStore();
1248
		associatedResources = new ArrayList();
1178
	}
1249
	}
1179
1250
1251
	private DiffNode startNode;
1252
	
1253
	public GenerateDiffFileWizard(IResource[] input) {
1254
		this();
1255
		
1256
		this.leftDoc = new Document();
1257
		this.rightDoc = new Document(); 
1258
		
1259
		leftResource = input[0];
1260
		rightResource = input[1];
1261
		
1262
		leftPath = leftResource.getFullPath().toString();
1263
		rightPath = rightResource.getFullPath().toString();
1264
1265
		Differencer dif = new Differencer();
1266
		startNode = (DiffNode) dif.findDifferences(false, null, null, null, 
1267
													new FilteredBufferedResourceNode(leftResource), 
1268
													new FilteredBufferedResourceNode(rightResource));
1269
		associatedResources = buildMap(startNode);
1270
		
1271
	}
1272
	
1180
	public GenerateDiffFileWizard(DocumentMerger merger, boolean rightToLeft) {
1273
	public GenerateDiffFileWizard(DocumentMerger merger, boolean rightToLeft) {
1181
		this();
1274
		this();
1182
		this.merger = merger;
1183
		this.leftDoc = merger.getDocument(MergeViewerContentProvider.LEFT_CONTRIBUTOR);
1275
		this.leftDoc = merger.getDocument(MergeViewerContentProvider.LEFT_CONTRIBUTOR);
1184
		this.rightDoc = merger.getDocument(MergeViewerContentProvider.RIGHT_CONTRIBUTOR);
1276
		this.rightDoc = merger.getDocument(MergeViewerContentProvider.RIGHT_CONTRIBUTOR);
1185
		this.leftPath = merger.getCompareConfiguration().getLeftLabel(leftDoc);
1277
		this.leftPath = merger.getCompareConfiguration().getLeftLabel(leftDoc);
1186
		this.rightPath = merger.getCompareConfiguration().getRightLabel(rightDoc);
1278
		this.rightPath = merger.getCompareConfiguration().getRightLabel(rightDoc);
1187
		this.rightToLeft = rightToLeft;
1279
		this.rightToLeft = rightToLeft;
1280
		IWorkbenchPart workbenchPart = merger.getCompareConfiguration().getContainer().getWorkbenchPart();
1281
		
1282
		if(workbenchPart instanceof CompareEditor) {
1283
						
1284
			CompareEditor editor = (CompareEditor)workbenchPart;
1285
			
1286
			CompareEditorInput input = (CompareEditorInput)editor.getEditorInput();
1287
			input.getCompareResult();
1288
			if(input.getCompareResult() instanceof ICompareInput) {
1289
				ICompareInput node = (ICompareInput)input.getCompareResult();	
1290
				
1291
				leftResource = ((ResourceNode)node.getLeft()).getResource();
1292
				rightResource = ((ResourceNode)node.getRight()).getResource();
1293
				Differencer dif = new Differencer();
1294
				startNode = (DiffNode) dif.findDifferences(false, null, null, null, 
1295
															new FilteredBufferedResourceNode(leftResource), 
1296
															new FilteredBufferedResourceNode(rightResource));
1297
				
1298
				if(leftResource instanceof IFile && rightResource instanceof IFile)
1299
					associatedResources.add(new Object[] {leftResource, rightResource});
1300
					
1301
			}
1302
			
1303
		}
1188
	}
1304
	}
1305
	
1306
	private ArrayList buildMap(DiffNode diff) {
1307
		ArrayList res = new ArrayList();
1308
		IResource lresource = null;
1309
		IResource rresource = null;
1310
		IDiffElement[] children = diff.getChildren();
1311
		if (children != null) {
1312
			for (int i = 0; i < children.length; i++) {
1313
				if (children[i] instanceof DiffNode) {
1314
					DiffNode o = (DiffNode) children[i];
1315
					if (o != null && o.getKind() != Differencer.NO_CHANGE) {
1316
						DiffNode node = o;
1189
1317
1318
						ITypedElement left = node.getLeft();
1319
						if (left instanceof BufferedResourceNode) {
1320
							BufferedResourceNode bn = (BufferedResourceNode) left;
1321
							IResource resource = bn.getResource();
1322
							if (resource instanceof IFile) {
1323
								lresource = resource;
1324
							}
1325
1326
						}
1327
1328
						ITypedElement right = node.getRight();
1329
						if (right instanceof BufferedResourceNode) {
1330
							BufferedResourceNode bn = (BufferedResourceNode) right;
1331
							IResource resource = bn.getResource();
1332
							if (resource instanceof IFile) {
1333
								rresource = resource;
1334
							}
1335
						}
1336
						
1337
						if(rresource != null || lresource != null)
1338
							res.add(new Object[] {lresource, rresource});
1339
						lresource = null;
1340
						rresource = null;
1341
					}
1342
1343
					res.addAll(buildMap((DiffNode) children[i]));
1344
				}
1345
			}
1346
			return res;
1347
		}
1348
		return res;
1349
	}
1350
1351
1190
	public void addPages() {
1352
	public void addPages() {
1191
		String pageTitle = CompareMessages.GenerateLocalDiff_pageTitle;
1353
		String pageTitle = CompareMessages.GenerateLocalDiff_pageTitle;
1192
		String pageDescription = CompareMessages.GenerateLocalDiff_Specify_the_file_which_contributes_the_changes;
1354
		String pageDescription = CompareMessages.GenerateLocalDiff_Specify_the_file_which_contributes_the_changes;
Lines 1286-1292 Link Here
1286
	public boolean needsProgressMonitor() {
1448
	public boolean needsProgressMonitor() {
1287
		return true;
1449
		return true;
1288
	}
1450
	}
1289
1451
	
1290
	/**
1452
	/**
1291
	 * Completes processing of the wizard. If this method returns <code>
1453
	 * Completes processing of the wizard. If this method returns <code>
1292
	 * true</code>, the wizard will close; otherwise, it will stay active.
1454
	 * true</code>, the wizard will close; otherwise, it will stay active.
Lines 1301-1324 Link Here
1301
		}
1463
		}
1302
1464
1303
		//Validation of patch root
1465
		//Validation of patch root
1304
		if(optionsPage.getRootSelection() == OptionsPage.ROOT_CUSTOM) {
1466
//		if(optionsPage.getRootSelection() == OptionsPage.ROOT_CUSTOM) {
1305
			String path = optionsPage.getPath();
1467
//			String path = optionsPage.getPath();
1306
			IFile file2;
1468
//			IFile file2;
1307
			try {
1469
//			try {
1308
				file2 = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(path));
1470
//				file2 = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(path));
1309
			} catch(IllegalArgumentException e) {
1471
//			} catch(IllegalArgumentException e) {
1310
				final String title = CompareMessages.GenerateLocalDiff_3;
1472
//				final String title = CompareMessages.GenerateLocalDiff_3;
1311
				final String msg = CompareMessages.GenerateLocalDiff_4;
1473
//				final String msg = CompareMessages.GenerateLocalDiff_4;
1312
				final MessageDialog dialog = new MessageDialog(getShell(), title,
1474
//				final MessageDialog dialog = new MessageDialog(getShell(), title,
1313
						null, msg, MessageDialog.ERROR,
1475
//						null, msg, MessageDialog.ERROR,
1314
						new String[] { IDialogConstants.OK_LABEL }, 0);
1476
//						new String[] { IDialogConstants.OK_LABEL }, 0);
1315
				dialog.open();
1477
//				dialog.open();
1316
				return false;
1478
//				return false;
1317
			}
1479
//			}
1318
			if(!validateFile2(file2)) {
1480
//			if(!validateFile2(file2)) {
1319
				return false;
1481
//				return false;
1320
			}
1482
//			}
1321
		}
1483
//		}
1322
1484
1323
		// Create the patch
1485
		// Create the patch
1324
		generateDiffFile(file);
1486
		generateDiffFile(file);
Lines 1385-1397 Link Here
1385
		} else {
1547
		} else {
1386
			oldPath = this.rightPath;
1548
			oldPath = this.rightPath;
1387
		}
1549
		}
1388
1550
		
1389
		UnifiedDiffFormatter formatter = new UnifiedDiffFormatter(merger
1551
		//TODO extend formatter to use list of mergers.
1390
				.getAllDiffs(), leftDoc, rightDoc, oldPath, toPath,
1552
		UnifiedDiffFormatter formatter = new UnifiedDiffFormatter(createFormatterInput());
1391
				directionSelectionPage.isRightToLeft());
1392
		try {
1553
		try {
1393
			if (file == null) {
1554
			if (file == null) {
1394
				formatter.generateDiffToClipboard();
1555
				formatter.generateDiff();
1395
			} else {
1556
			} else {
1396
				formatter.generateDiff(file);
1557
				formatter.generateDiff(file);
1397
			}
1558
			}
Lines 1399-1404 Link Here
1399
			throw new RuntimeException(e);
1560
			throw new RuntimeException(e);
1400
		}
1561
		}
1401
	}
1562
	}
1563
	
1564
	private Object[][] createFormatterInput() {
1565
		Object[] resArr = associatedResources.toArray();
1566
		int size = resArr.length;
1567
		Object[][] result = new Object[size][3];
1568
		DocumentMerger merg = null;
1569
		for (int j = 0; j < size; j++) {
1570
			IFile sourceRes = (IFile) ((Object[])resArr[j])[0];
1571
			IFile targetRes = (IFile) ((Object[])resArr[j])[1];
1572
			merg = createDocumentMerger(sourceRes, targetRes);
1573
			result[j][0] = merg;
1574
			result[j][1] = targetRes ;
1575
			result[j][2] = sourceRes ;
1576
		}
1577
		return result;
1578
	}
1579
	
1580
	private DocumentMerger createDocumentMerger(IFile leftFile, IFile rightFile){
1581
			IDocument leftDoc = convertFileToDocument(leftFile);
1582
			IDocument rightDoc = convertFileToDocument(rightFile);
1583
            if (leftDoc == null) {
1584
                leftDoc = new Document();
1585
            }
1586
            if (rightDoc == null) {
1587
                rightDoc = new Document();
1588
            }
1589
			DocumentMerger docMerger;
1590
			docMerger = new DocumentMerger(new LocalDiffMergerInput(leftDoc, rightDoc));
1591
			try {
1592
				docMerger.doDiff();
1593
			} catch (Exception e) {
1594
				throw new RuntimeException(e);
1595
			}
1596
			return docMerger;
1597
	}
1598
	
1599
	private IDocument convertFileToDocument(IFile file) {
1600
		if(file == null)
1601
			return null;
1602
		StringBuffer str = new StringBuffer();
1603
		int c;
1604
		try{
1605
			InputStream inputStream = file.getContents();
1606
			while ((c = inputStream.read())!=-1){
1607
				str.append((char)c);
1608
			}
1609
			inputStream.close();
1610
			return new Document(str.toString());
1611
		}catch(Exception ex){
1612
			CompareUIPlugin.log(ex);
1613
		}
1614
	
1615
		return null;
1616
	}
1617
	
1618
	private class LocalDiffMergerInput implements IDocumentMergerInput {
1619
		        
1620
			private IDocument leftDoc;
1621
			private IDocument rightDoc;
1622
			
1623
			public LocalDiffMergerInput(IDocument leftDoc, IDocument rightDoc) {
1624
				this.leftDoc = leftDoc ;
1625
				this.rightDoc= rightDoc;
1626
			}
1627
				
1628
			public ITokenComparator createTokenComparator(String line) {
1629
		            return new TokenComparator(line);
1630
		    }
1631
		    public CompareConfiguration getCompareConfiguration() {
1632
		            return new CompareConfiguration();
1633
		    }
1634
		    public IDocument getDocument(char contributor) {
1635
		            switch (contributor) {
1636
		            case MergeViewerContentProvider.LEFT_CONTRIBUTOR:
1637
		                    return leftDoc;
1638
		            case MergeViewerContentProvider.RIGHT_CONTRIBUTOR:
1639
		                    return rightDoc;
1640
		            case MergeViewerContentProvider.ANCESTOR_CONTRIBUTOR: 
1641
		                    return null;
1642
		            }
1643
		            return null;
1644
		    }
1645
		    public int getHunkStart() {
1646
		            return 0;
1647
		    }
1648
		    public Position getRegion(char contributor) {
1649
		            switch (contributor) {
1650
		            case MergeViewerContentProvider.LEFT_CONTRIBUTOR:
1651
		                    return new Position(0, leftDoc.getLength());
1652
		            case MergeViewerContentProvider.RIGHT_CONTRIBUTOR:
1653
		                    return new Position(0, rightDoc.getLength());
1654
		            case MergeViewerContentProvider.ANCESTOR_CONTRIBUTOR:
1655
		                    return new Position(0, 0);
1656
		            }
1657
		            return null;
1658
		    }
1659
		    public boolean isHunkOnLeft() {
1660
		    	return false;
1661
		    }
1662
		    public boolean isIgnoreAncestor() {
1663
		    	return true;
1664
		    }
1665
		    public boolean isPatchHunk() {
1666
		    	return false;
1667
		    }
1668
		
1669
		    public boolean isShowPseudoConflicts() {
1670
		    	return false;
1671
		    }
1672
		    public boolean isThreeWay() {
1673
		    	return false;
1674
		    }
1675
		    public boolean isPatchHunkOk() {
1676
		    	return false;
1677
		    }
1678
		    
1679
		}
1402
1680
1403
	public boolean validateFile(File file) {
1681
	public boolean validateFile(File file) {
1404
1682
(-)compare/org/eclipse/compare/internal/CompareMessages.properties (-2 / +6 lines)
Lines 150-155 Link Here
150
150
151
ReaderCreator_fileIsNotAccessible=Cannot create a reader because the file is inaccessible.
151
ReaderCreator_fileIsNotAccessible=Cannot create a reader because the file is inaccessible.
152
152
153
CreatePatchActionTitle=Create Patch...
153
WorkspacePatchDialogTitle=Set a Patch Location
154
WorkspacePatchDialogTitle=Set a Patch Location
154
WorkspacePatchDialogDescription=Select a folder in the workspace and enter a name for the patch.
155
WorkspacePatchDialogDescription=Select a folder in the workspace and enter a name for the patch.
155
Save_To_Clipboard_2=&Clipboard
156
Save_To_Clipboard_2=&Clipboard
Lines 193-199 Link Here
193
GenerateDiffFileWizard_13=Use only &file path:
194
GenerateDiffFileWizard_13=Use only &file path:
194
GenerateDiffFileWizard_Left=&Left:
195
GenerateDiffFileWizard_Left=&Left:
195
GenerateDiffFileWizard_Right=&Right:
196
GenerateDiffFileWizard_Right=&Right:
196
CreatePatchActionTitle=Create Patch...
197
CreatePatchActionTitle=Create Patch
197
WorkspacePatchDialogTitle=Set a Patch Location
198
WorkspacePatchDialogTitle=Set a Patch Location
198
WorkspacePatchDialogDescription=Select a folder in the workspace and enter a name for the patch.
199
WorkspacePatchDialogDescription=Select a folder in the workspace and enter a name for the patch.
199
Save_To_Clipboard_2=&Clipboard
200
Save_To_Clipboard_2=&Clipboard
Lines 236-239 Link Here
236
GenerateDiffFileWizard_ProjectClosed=The specified path points to a closed project.
237
GenerateDiffFileWizard_ProjectClosed=The specified path points to a closed project.
237
GenerateDiffFileWizard_13=Use only &file path:
238
GenerateDiffFileWizard_13=Use only &file path:
238
GenerateDiffFileWizard_Left=&Left:
239
GenerateDiffFileWizard_Left=&Left:
239
GenerateDiffFileWizard_Right=&Right:
240
GenerateDiffFileWizard_Right=&Right:
241
GenerateDiffFileWizard_SelectAll=Select &All
242
GenerateDiffFileWizard_DeselectAll=&Deselect All
243
GenerateDiffFileWizard_noChangesSelected=No changes selected.
(-)compare/org/eclipse/compare/internal/ICompareUIConstants.java (-1 / +1 lines)
Lines 40-46 Link Here
40
	public static final String PROP_TITLE_IMAGE = PREFIX + "TitleImage"; //$NON-NLS-1$
40
	public static final String PROP_TITLE_IMAGE = PREFIX + "TitleImage"; //$NON-NLS-1$
41
	public static final String PROP_SELECTED_EDITION = PREFIX + "SelectedEdition"; //$NON-NLS-1$
41
	public static final String PROP_SELECTED_EDITION = PREFIX + "SelectedEdition"; //$NON-NLS-1$
42
	
42
	
43
	public static final int COMPARE_IMAGE_WIDTH= 22;
43
	public static final int COMPARE_IMAGE_WIDTH= 17;
44
	
44
	
45
	public static final String PREF_NAVIGATION_END_ACTION= PREFIX + "NavigationEndAction"; //$NON-NLS-1$
45
	public static final String PREF_NAVIGATION_END_ACTION= PREFIX + "NavigationEndAction"; //$NON-NLS-1$
46
	public static final String PREF_NAVIGATION_END_ACTION_LOCAL= PREFIX + "NavigationEndActionLocal"; //$NON-NLS-1$
46
	public static final String PREF_NAVIGATION_END_ACTION_LOCAL= PREFIX + "NavigationEndActionLocal"; //$NON-NLS-1$
(-)compare/org/eclipse/compare/internal/GenerateDiffAction.java (-118 / +1 lines)
Lines 13-31 Link Here
13
package org.eclipse.compare.internal;
13
package org.eclipse.compare.internal;
14
14
15
15
16
import java.io.InputStream;
17
18
import org.eclipse.compare.CompareConfiguration;
16
import org.eclipse.compare.CompareConfiguration;
19
import org.eclipse.compare.contentmergeviewer.ITokenComparator;
20
import org.eclipse.compare.contentmergeviewer.TokenComparator;
21
import org.eclipse.compare.internal.merge.DocumentMerger;
22
import org.eclipse.compare.internal.merge.DocumentMerger.IDocumentMergerInput;
23
import org.eclipse.core.resources.IFile;
24
import org.eclipse.core.resources.IResource;
17
import org.eclipse.core.resources.IResource;
25
import org.eclipse.jface.action.IAction;
18
import org.eclipse.jface.action.IAction;
26
import org.eclipse.jface.text.Document;
27
import org.eclipse.jface.text.IDocument;
28
import org.eclipse.jface.text.Position;
29
import org.eclipse.jface.viewers.ISelection;
19
import org.eclipse.jface.viewers.ISelection;
30
import org.eclipse.swt.widgets.Shell;
20
import org.eclipse.swt.widgets.Shell;
31
import org.eclipse.ui.IObjectActionDelegate;
21
import org.eclipse.ui.IObjectActionDelegate;
Lines 49-61 Link Here
49
		boolean ok = fInput.setSelection(selection,shell, showSelectAncestorDialog);
39
		boolean ok = fInput.setSelection(selection,shell, showSelectAncestorDialog);
50
		if (!ok) return;
40
		if (!ok) return;
51
41
52
		DocumentMerger merger = null;
42
		GenerateDiffFileWizard.run(ir, shell);
53
		if(ir[0] instanceof IFile && ir[1] instanceof IFile) {
54
			merger = createDocumentMerger((IFile)ir[0], (IFile)ir[1]);
55
			merger.getCompareConfiguration().setLeftLabel(ir[0].getFullPath().toString());
56
			merger.getCompareConfiguration().setRightLabel(ir[1].getFullPath().toString());
57
			GenerateDiffFileWizard.run(merger, shell, true);
58
		}
59
		
43
		
60
44
61
	}
45
	}
Lines 73-178 Link Here
73
		fWorkbenchPage= targetPart.getSite().getPage();
57
		fWorkbenchPage= targetPart.getSite().getPage();
74
	}
58
	}
75
	
59
	
76
	private DocumentMerger createDocumentMerger(IFile leftFile, IFile rightFile){
77
		IDocument leftDoc = convertFileToDocument(leftFile);
78
		IDocument rightDoc = convertFileToDocument(rightFile);
79
        if (leftDoc == null) {
80
            leftDoc = new Document();
81
        }
82
        if (rightDoc == null) {
83
            rightDoc = new Document();
84
        }
85
		DocumentMerger docMerger;
86
		docMerger = new DocumentMerger(new LocalDiffMergerInput(leftDoc, rightDoc));
87
		try {
88
			docMerger.doDiff();
89
		} catch (Exception e) {
90
			throw new RuntimeException(e);
91
		}
92
		return docMerger;
93
	}
94
95
	private IDocument convertFileToDocument(IFile file) {
96
		if(file == null)
97
			return null;
98
		StringBuffer str = new StringBuffer();
99
		int c;
100
		try{
101
			InputStream inputStream = file.getContents();
102
			while ((c = inputStream.read())!=-1){
103
				str.append((char)c);
104
			}
105
			inputStream.close();
106
			return new Document(str.toString());
107
		}catch(Exception ex){
108
			CompareUIPlugin.log(ex);
109
		}
110
	
111
		return null;
112
	}
113
114
	private class LocalDiffMergerInput implements IDocumentMergerInput {
115
		        
116
			private IDocument leftDoc;
117
			private IDocument rightDoc;
118
			
119
			public LocalDiffMergerInput(IDocument leftDoc, IDocument rightDoc) {
120
				this.leftDoc = leftDoc ;
121
				this.rightDoc= rightDoc;
122
			}
123
				
124
			public ITokenComparator createTokenComparator(String line) {
125
		            return new TokenComparator(line);
126
		    }
127
		    public CompareConfiguration getCompareConfiguration() {
128
		            return fInput.getCompareConfiguration();
129
		    }
130
		    public IDocument getDocument(char contributor) {
131
		            switch (contributor) {
132
		            case MergeViewerContentProvider.LEFT_CONTRIBUTOR:
133
		                    return leftDoc;
134
		            case MergeViewerContentProvider.RIGHT_CONTRIBUTOR:
135
		                    return rightDoc;
136
		            case MergeViewerContentProvider.ANCESTOR_CONTRIBUTOR: 
137
		                    return null;
138
		            }
139
		            return null;
140
		    }
141
		    public int getHunkStart() {
142
		            return 0;
143
		    }
144
		    public Position getRegion(char contributor) {
145
		            switch (contributor) {
146
		            case MergeViewerContentProvider.LEFT_CONTRIBUTOR:
147
		                    return new Position(0, leftDoc.getLength());
148
		            case MergeViewerContentProvider.RIGHT_CONTRIBUTOR:
149
		                    return new Position(0, rightDoc.getLength());
150
		            case MergeViewerContentProvider.ANCESTOR_CONTRIBUTOR:
151
		                    return new Position(0, 0);
152
		            }
153
		            return null;
154
		    }
155
		    public boolean isHunkOnLeft() {
156
		    	return false;
157
		    }
158
		    public boolean isIgnoreAncestor() {
159
		    	return true;
160
		    }
161
		    public boolean isPatchHunk() {
162
		    	return false;
163
		    }
164
		
165
		    public boolean isShowPseudoConflicts() {
166
		    	return false;
167
		    }
168
		    public boolean isThreeWay() {
169
		    	return false;
170
		    }
171
		    public boolean isPatchHunkOk() {
172
		    	return false;
173
		    }
174
		    
175
	}
176
	
177
}
60
}
178
61
(-)compare/org/eclipse/compare/internal/UnifiedDiffFormatter.java (-100 / +131 lines)
Lines 17-32 Link Here
17
import java.io.File;
17
import java.io.File;
18
import java.io.FileOutputStream;
18
import java.io.FileOutputStream;
19
import java.io.IOException;
19
import java.io.IOException;
20
import java.io.InputStream;
20
import java.io.PrintStream;
21
import java.io.PrintStream;
21
import java.util.ArrayList;
22
import java.util.ArrayList;
22
import java.util.Arrays;
23
import java.util.Arrays;
23
import java.util.Calendar;
24
import java.util.Calendar;
24
import java.util.Date;
25
import java.util.Date;
25
import java.util.List;
26
26
27
import org.eclipse.compare.internal.merge.DocumentMerger;
27
import org.eclipse.compare.internal.merge.DocumentMerger.Diff;
28
import org.eclipse.compare.internal.merge.DocumentMerger.Diff;
28
import org.eclipse.compare.rangedifferencer.RangeDifference;
29
import org.eclipse.compare.rangedifferencer.RangeDifference;
30
import org.eclipse.core.resources.IFile;
29
import org.eclipse.jface.text.BadLocationException;
31
import org.eclipse.jface.text.BadLocationException;
32
import org.eclipse.jface.text.Document;
30
import org.eclipse.jface.text.IDocument;
33
import org.eclipse.jface.text.IDocument;
31
import org.eclipse.swt.dnd.Clipboard;
34
import org.eclipse.swt.dnd.Clipboard;
32
import org.eclipse.swt.dnd.TextTransfer;
35
import org.eclipse.swt.dnd.TextTransfer;
Lines 52-73 Link Here
52
	public static final String RANGE_INFORMATION_PREFIX = "@@ -"; //$NON-NLS-1$
55
	public static final String RANGE_INFORMATION_PREFIX = "@@ -"; //$NON-NLS-1$
53
	public static final String RANGE_INFORMATION_AFFIX = " @@"; //$NON-NLS-1$
56
	public static final String RANGE_INFORMATION_AFFIX = " @@"; //$NON-NLS-1$
54
57
55
	private List fAllDiffs;
58
	private Object[][] input;
56
	private IDocument leftDoc;
57
	private IDocument rightDoc;
58
	private String oldPath;
59
	private String newPath;
60
	private boolean rightToLeft;
61
59
62
	public UnifiedDiffFormatter(List allDiffs, IDocument leftDoc,
60
	public UnifiedDiffFormatter(Object[][] input) {
63
			IDocument rightDoc, String oldPath, String newPath,
61
		this.input = input;
64
			boolean rightToLeft) {
65
		this.fAllDiffs = allDiffs;
66
		this.leftDoc = leftDoc;
67
		this.rightDoc = rightDoc;
68
		this.oldPath = oldPath;
69
		this.newPath = newPath;
70
		this.rightToLeft = rightToLeft;
71
	}
62
	}
72
63
73
	/**
64
	/**
Lines 78-84 Link Here
78
	 * 
69
	 * 
79
	 * @throws IOException
70
	 * @throws IOException
80
	 */
71
	 */
81
	public void generateDiffToClipboard() throws IOException {
72
	public void generateDiff() throws IOException {
82
		ByteArrayOutputStream bos = new ByteArrayOutputStream();
73
		ByteArrayOutputStream bos = new ByteArrayOutputStream();
83
		PrintStream ps = new PrintStream(bos);
74
		PrintStream ps = new PrintStream(bos);
84
75
Lines 148-242 Link Here
148
	 * @param strictUnixFormat determinates if the format should be fully compatible with the Unix one.
139
	 * @param strictUnixFormat determinates if the format should be fully compatible with the Unix one.
149
	 */
140
	 */
150
	private void generateDiff(PrintStream output, boolean strictUnixFormat) {
141
	private void generateDiff(PrintStream output, boolean strictUnixFormat) {
151
		// If the first block isn't the only one, or first block is different
142
		for (int fileNr = 0; fileNr < input.length; fileNr++) {
152
		if (fAllDiffs.size() > 1 || isPartDifferent(0)) {
143
			DocumentMerger merger = (DocumentMerger) input[fileNr][0];
153
			output.println(INDEX_MARKER + oldPath);
144
			IDocument leftDoc = convertFileToDocument((IFile)input[fileNr][1]);
154
			output.println(DELIMITER);
145
			IDocument rightDoc = convertFileToDocument((IFile)input[fileNr][2]);
155
			Date oldDate = Calendar.getInstance().getTime();
146
			String oldPath;
156
			Date newDate = Calendar.getInstance().getTime();
147
			String newPath;
157
			String oldDateFormat = DateFormat.getDateTimeInstance().format(oldDate);
148
			if (leftDoc == null) {
158
			String newDateFormat = DateFormat.getDateTimeInstance().format(newDate);
149
				leftDoc = new Document();
159
			output.println(OLD_FILE_PREFIX + oldPath + '\t'
150
				newPath = ((IFile)input[fileNr][2]).getFullPath().toString();
160
					+ oldDateFormat + " -0000"); //$NON-NLS-1$
151
				oldPath = ((IFile)input[fileNr][2]).getFullPath().toString();
161
			output.println(NEW_FILE_PREFIX + newPath + '\t'
152
			}
162
					+ newDateFormat + " -0000"); //$NON-NLS-1$
153
			else if (rightDoc == null) {
154
				rightDoc = new Document();
155
				newPath = ((IFile)input[fileNr][1]).getFullPath().toString();
156
				oldPath = ((IFile)input[fileNr][1]).getFullPath().toString();
157
			}
158
			else {
159
				oldPath = ((IFile)input[fileNr][1]).getFullPath().toString();
160
				newPath = ((IFile)input[fileNr][2]).getFullPath().toString();
161
			}
162
			
163
			ArrayList allDiffs = merger.getAllDiffs();
164
			// If the first block isn't the only one, or first block is different
165
			if (allDiffs.size() > 1 || isPartDifferent(allDiffs, 0)) {
166
				output.println(INDEX_MARKER + oldPath);
167
				output.println(DELIMITER);
168
				Date oldDate = Calendar.getInstance().getTime();
169
				Date newDate = Calendar.getInstance().getTime();
170
				String oldDateFormat = DateFormat.getDateTimeInstance().format(oldDate);
171
				String newDateFormat = DateFormat.getDateTimeInstance().format(newDate);
172
				output.println(OLD_FILE_PREFIX + oldPath + '\t'
173
						+ oldDateFormat + " -0000"); //$NON-NLS-1$
174
				output.println(NEW_FILE_PREFIX + newPath + '\t'
175
						+ newDateFormat + " -0000"); //$NON-NLS-1$
163
176
164
			boolean firstHunk = true;
177
				boolean firstHunk = true;
165
			Hunk currentHunk = null;
178
				Hunk currentHunk = null;
166
179
167
			int currentLineNumberOld = 0;
180
				int currentLineNumberOld = 0;
168
			int currentLineNumberNew = 0;
181
				int currentLineNumberNew = 0;
169
182
170
			for (int i = 0; i < fAllDiffs.size(); i++) {
183
				for (int partNumber = 0; partNumber < allDiffs.size(); partNumber++) {
171
184
172
				List oldPart = getPart(i, LEFT_CONTRIBUTOR);
185
					ArrayList oldPart = getPart(partNumber, LEFT_CONTRIBUTOR, merger, leftDoc, rightDoc);
173
				List newPart = getPart(i, RIGHT_CONTRIBUTOR);
186
					ArrayList newPart = getPart(partNumber, RIGHT_CONTRIBUTOR, merger, leftDoc, rightDoc);
174
187
175
				if (isPartDifferent(i)) {
188
					if (isPartDifferent(allDiffs, partNumber)) {
176
					// This part has some changes
189
						// This part has some changes
177
					if (firstHunk) {
190
						if (firstHunk) {
178
						// Hunk will start with changed block
191
							// Hunk will start with changed block
179
						currentHunk = new Hunk(0, 0, strictUnixFormat);
192
							currentHunk = new Hunk(0, 0, strictUnixFormat);
180
						firstHunk = false;
193
							firstHunk = false;
181
					}
194
						}
182
					if (i == (fAllDiffs.size() - 1)) {
195
						if (partNumber == (allDiffs.size() - 1)) {
183
						// If it is the last part
184
						currentHunk.addPartRangeToOld(oldPart, 0, oldPart
185
								.size(), true);
186
						currentHunk.addPartRangeToNew(newPart, 0, newPart
187
								.size(), true);
188
					} else {
189
						currentHunk.addPartRangeToOld(oldPart, 0, oldPart
190
								.size(), false);
191
						currentHunk.addPartRangeToNew(newPart, 0, newPart
192
								.size(), false);
193
					}
194
				} else {
195
					if (firstHunk) {
196
						// Hunk will start with context
197
						currentHunk = new Hunk((oldPart.size() - 1) - NUMBER_OF_CONTEXT_LINES,
198
								(oldPart.size() - 1) - NUMBER_OF_CONTEXT_LINES, strictUnixFormat);
199
						firstHunk = false;
200
						currentHunk.addPartRangeToBoth(oldPart,
201
								(oldPart.size() - 1) - NUMBER_OF_CONTEXT_LINES, oldPart.size(), false);
202
					} else {
203
						if (i == (fAllDiffs.size() - 1)) {
204
							// If it is the last part
196
							// If it is the last part
205
							currentHunk.addPartRangeToBoth(oldPart, 0, NUMBER_OF_CONTEXT_LINES, true);
197
							currentHunk.addPartRangeToOld(oldPart, 0, oldPart
198
									.size(), true);
199
							currentHunk.addPartRangeToNew(newPart, 0, newPart
200
									.size(), true);
206
						} else {
201
						} else {
207
							if (oldPart.size() - 1 < 2*NUMBER_OF_CONTEXT_LINES) {
202
							currentHunk.addPartRangeToOld(oldPart, 0, oldPart
208
								// Context too short to start new hunk
203
									.size(), false);
209
								currentHunk.addPartRangeToBoth(oldPart, 0,
204
							currentHunk.addPartRangeToNew(newPart, 0, newPart
210
										oldPart.size(), false);
205
									.size(), false);
206
						}
207
					} else {
208
						if (firstHunk) {
209
							// Hunk will start with context
210
							currentHunk = new Hunk((oldPart.size() - 1) - NUMBER_OF_CONTEXT_LINES,
211
									(oldPart.size() - 1) - NUMBER_OF_CONTEXT_LINES, strictUnixFormat);
212
							firstHunk = false;
213
							currentHunk.addPartRangeToBoth(oldPart,
214
									(oldPart.size() - 1) - NUMBER_OF_CONTEXT_LINES, oldPart.size(), false);
215
						} else {
216
							if (partNumber == (allDiffs.size() - 1)) {
217
								// If it is the last part
218
								currentHunk.addPartRangeToBoth(oldPart, 0, NUMBER_OF_CONTEXT_LINES, true);
211
							} else {
219
							} else {
212
								// Context long enough to start new hunk
220
								if (oldPart.size() - 1 < 2*NUMBER_OF_CONTEXT_LINES) {
213
								currentHunk.addPartRangeToBoth(oldPart, 0, NUMBER_OF_CONTEXT_LINES,
221
									// Context too short to start new hunk
214
										false);
222
									currentHunk.addPartRangeToBoth(oldPart, 0,
215
								currentHunk.printTo(output);
223
											oldPart.size(), false);
216
								currentHunk = new Hunk(currentLineNumberOld
224
								} else {
217
										+ (oldPart.size() - 1) - NUMBER_OF_CONTEXT_LINES,
225
									// Context long enough to start new hunk
218
										currentLineNumberNew + (oldPart.size() - 1)
226
									currentHunk.addPartRangeToBoth(oldPart, 0, NUMBER_OF_CONTEXT_LINES,
219
										- NUMBER_OF_CONTEXT_LINES, strictUnixFormat);
227
											false);
220
								currentHunk.addPartRangeToBoth(oldPart,
228
									currentHunk.printTo(output);
221
										(oldPart.size() - 1) - NUMBER_OF_CONTEXT_LINES,
229
									currentHunk = new Hunk(currentLineNumberOld
222
										oldPart.size(), false);
230
											+ (oldPart.size() - 1) - NUMBER_OF_CONTEXT_LINES,
231
											currentLineNumberNew + (oldPart.size() - 1)
232
											- NUMBER_OF_CONTEXT_LINES, strictUnixFormat);
233
									currentHunk.addPartRangeToBoth(oldPart,
234
											(oldPart.size() - 1) - NUMBER_OF_CONTEXT_LINES,
235
											oldPart.size(), false);
236
								}
223
							}
237
							}
224
						}
238
						}
225
					}
239
					}
240
					currentLineNumberOld += oldPart.size();
241
					currentLineNumberNew += newPart.size();
226
				}
242
				}
227
				currentLineNumberOld += oldPart.size();
243
				// Print the last hunk
228
				currentLineNumberNew += newPart.size();
244
				currentHunk.printTo(output);
245
			}			
246
		}
247
	}
248
249
	private IDocument convertFileToDocument(IFile file) {
250
		if(file == null)
251
			return null;
252
		StringBuffer str = new StringBuffer();
253
		int c;
254
		try{
255
			InputStream inputStream = file.getContents();
256
			while ((c = inputStream.read())!=-1){
257
				str.append((char)c);
229
			}
258
			}
230
			// Print the last hunk
259
			inputStream.close();
231
			currentHunk.printTo(output);
260
			return new Document(str.toString());
261
		}catch(Exception ex){
262
			CompareUIPlugin.log(ex);
232
		}
263
		}
264
	
265
		return null;
233
	}
266
	}
234
267
	
235
	private List getPart(int i, char side) {
268
	private ArrayList getPart(int nr, char side, DocumentMerger merger, IDocument leftDoc, IDocument rightDoc) {
236
		try {
269
		try {
237
			String s = extract(i, side).replaceAll("\r\n", "\n"); //$NON-NLS-1$ //$NON-NLS-2$
270
			String s = extract(nr, side, merger, leftDoc, rightDoc).replaceAll("\r", ""); //$NON-NLS-1$ //$NON-NLS-2$
238
			s.replaceAll("\r", "\n"); //$NON-NLS-1$ //$NON-NLS-2$
271
			ArrayList diffLines = new ArrayList(Arrays
239
			List diffLines = new ArrayList(Arrays
240
					.asList(s.split("\n", -1))); //$NON-NLS-1$
272
					.asList(s.split("\n", -1))); //$NON-NLS-1$
241
			return diffLines;
273
			return diffLines;
242
		} catch (BadLocationException e) {
274
		} catch (BadLocationException e) {
Lines 245-254 Link Here
245
		return null;
277
		return null;
246
	}
278
	}
247
279
248
	private String extract(int i, char side) throws BadLocationException {
280
	private String extract(int nr, char side, DocumentMerger merger, IDocument leftDoc, IDocument rightDoc) throws BadLocationException {
249
		Diff diff = ((Diff) fAllDiffs.get(i));
281
		Diff diff = ((Diff) merger.getAllDiffs().get(nr));
250
		if (side == LEFT_CONTRIBUTOR && !rightToLeft
282
		if (side == LEFT_CONTRIBUTOR) {
251
				|| side == RIGHT_CONTRIBUTOR && rightToLeft) {
252
			return leftDoc.get(diff.getPosition(LEFT_CONTRIBUTOR).offset, diff
283
			return leftDoc.get(diff.getPosition(LEFT_CONTRIBUTOR).offset, diff
253
					.getPosition(LEFT_CONTRIBUTOR).length);
284
					.getPosition(LEFT_CONTRIBUTOR).length);
254
		}
285
		}
Lines 256-263 Link Here
256
				.getPosition(RIGHT_CONTRIBUTOR).length);
287
				.getPosition(RIGHT_CONTRIBUTOR).length);
257
	}
288
	}
258
289
259
	private boolean isPartDifferent(int i) {
290
	private boolean isPartDifferent(ArrayList allDiffs, int nr) {
260
		Diff diff = ((Diff) fAllDiffs.get(i));
291
		Diff diff = ((Diff) allDiffs.get(nr));
261
		if (diff.getKind() == RangeDifference.CHANGE) {
292
		if (diff.getKind() == RangeDifference.CHANGE) {
262
			return true;
293
			return true;
263
		}
294
		}
Lines 271-277 Link Here
271
		private int newLength;
302
		private int newLength;
272
		private boolean strictUnixFormat;
303
		private boolean strictUnixFormat;
273
		private boolean printNoNewlineMarker;
304
		private boolean printNoNewlineMarker;
274
		List lines;
305
		ArrayList lines;
275
306
276
		public Hunk(int oldStart, int newStart, boolean strictUnixFormat) {
307
		public Hunk(int oldStart, int newStart, boolean strictUnixFormat) {
277
			if (oldStart < 0)
308
			if (oldStart < 0)
Lines 287-293 Link Here
287
			lines = new ArrayList();
318
			lines = new ArrayList();
288
		}
319
		}
289
320
290
		public void addPartRangeToOld(List part, int start, int end,
321
		public void addPartRangeToOld(ArrayList part, int start, int end,
291
				boolean lastPart) {
322
				boolean lastPart) {
292
			if (start < 0)
323
			if (start < 0)
293
				start = 0;
324
				start = 0;
Lines 322-328 Link Here
322
			}
353
			}
323
		}
354
		}
324
355
325
		public void addPartRangeToNew(List part, int start, int end,
356
		public void addPartRangeToNew(ArrayList part, int start, int end,
326
				boolean lastPart) {
357
				boolean lastPart) {
327
			if (start < 0)
358
			if (start < 0)
328
				start = 0;
359
				start = 0;
Lines 356-362 Link Here
356
			}
387
			}
357
		}
388
		}
358
389
359
		public void addPartRangeToBoth(List part, int start, int end,
390
		public void addPartRangeToBoth(ArrayList part, int start, int end,
360
				boolean lastPart) {
391
				boolean lastPart) {
361
			if (start < 0)
392
			if (start < 0)
362
				start = 0;
393
				start = 0;
(-)compare/org/eclipse/compare/internal/CompareMessages.java (+3 lines)
Lines 181-186 Link Here
181
	public static String GenerateLocalDiff_4;
181
	public static String GenerateLocalDiff_4;
182
	public static String GenerateLocalDiff_5;
182
	public static String GenerateLocalDiff_5;
183
	public static String GenerateLocalDiff_6;
183
	public static String GenerateLocalDiff_6;
184
	public static String GenerateDiffFileWizard_SelectAll;
185
	public static String GenerateDiffFileWizard_DeselectAll;
186
	public static String GenerateDiffFileWizard_noChangesSelected;
184
187
185
	static {
188
	static {
186
		NLS.initializeMessages(BUNDLE_NAME, CompareMessages.class);
189
		NLS.initializeMessages(BUNDLE_NAME, CompareMessages.class);

Return to bug 265030