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

Collapse All | Expand All

(-)compare/org/eclipse/compare/internal/CompareMessages.java (+7 lines)
Lines 120-125 Link Here
120
	public static String CompareWithOther_clear;
120
	public static String CompareWithOther_clear;
121
	public static String CompareWithOther_warning_two_way;
121
	public static String CompareWithOther_warning_two_way;
122
	public static String CompareWithOther_info;
122
	public static String CompareWithOther_info;
123
	public static String CompareWithOther_clipboardSection;
124
	public static String CompareWithOther_fileName;
125
	public static String CompareWithOther_createTmpFile_title;
126
	public static String CompareWithOther_createTmpFile_message;
127
	public static String CompareWithOther_refreshButton;
128
	public static String CompareWithOther_clipboardInfo_1;
129
	public static String CompareWithOther_clipboardInfo_2;
123
130
124
	static {
131
	static {
125
		NLS.initializeMessages(BUNDLE_NAME, CompareMessages.class);
132
		NLS.initializeMessages(BUNDLE_NAME, CompareMessages.class);
(-)compare/org/eclipse/compare/internal/CompareWithOtherResourceDialog.java (-25 / +340 lines)
Lines 10-25 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.compare.internal;
11
package org.eclipse.compare.internal;
12
12
13
import java.io.ByteArrayInputStream;
14
import java.io.FileOutputStream;
15
import java.io.IOException;
16
import java.io.InputStream;
17
13
import org.eclipse.compare.CompareConfiguration;
18
import org.eclipse.compare.CompareConfiguration;
19
import org.eclipse.compare.CompareUI;
20
import org.eclipse.core.resources.IFile;
21
import org.eclipse.core.resources.IFolder;
22
import org.eclipse.core.resources.IProject;
23
import org.eclipse.core.resources.IProjectDescription;
14
import org.eclipse.core.resources.IResource;
24
import org.eclipse.core.resources.IResource;
15
import org.eclipse.core.resources.IWorkspaceRoot;
25
import org.eclipse.core.resources.IWorkspaceRoot;
16
import org.eclipse.core.resources.ResourcesPlugin;
26
import org.eclipse.core.resources.ResourcesPlugin;
27
import org.eclipse.core.runtime.CoreException;
28
import org.eclipse.core.runtime.IPath;
17
import org.eclipse.jface.dialogs.IDialogConstants;
29
import org.eclipse.jface.dialogs.IDialogConstants;
18
import org.eclipse.jface.dialogs.IMessageProvider;
30
import org.eclipse.jface.dialogs.IMessageProvider;
31
import org.eclipse.jface.dialogs.MessageDialog;
19
import org.eclipse.jface.dialogs.TitleAreaDialog;
32
import org.eclipse.jface.dialogs.TitleAreaDialog;
33
import org.eclipse.jface.text.Document;
34
import org.eclipse.jface.text.source.SourceViewer;
20
import org.eclipse.jface.viewers.ISelection;
35
import org.eclipse.jface.viewers.ISelection;
21
import org.eclipse.jface.viewers.StructuredSelection;
36
import org.eclipse.jface.viewers.StructuredSelection;
22
import org.eclipse.swt.SWT;
37
import org.eclipse.swt.SWT;
38
import org.eclipse.swt.dnd.Clipboard;
23
import org.eclipse.swt.dnd.DND;
39
import org.eclipse.swt.dnd.DND;
24
import org.eclipse.swt.dnd.DragSource;
40
import org.eclipse.swt.dnd.DragSource;
25
import org.eclipse.swt.dnd.DragSourceEvent;
41
import org.eclipse.swt.dnd.DragSourceEvent;
Lines 38-43 Link Here
38
import org.eclipse.swt.widgets.Button;
54
import org.eclipse.swt.widgets.Button;
39
import org.eclipse.swt.widgets.Composite;
55
import org.eclipse.swt.widgets.Composite;
40
import org.eclipse.swt.widgets.Control;
56
import org.eclipse.swt.widgets.Control;
57
import org.eclipse.swt.widgets.Display;
41
import org.eclipse.swt.widgets.Group;
58
import org.eclipse.swt.widgets.Group;
42
import org.eclipse.swt.widgets.Label;
59
import org.eclipse.swt.widgets.Label;
43
import org.eclipse.swt.widgets.Shell;
60
import org.eclipse.swt.widgets.Shell;
Lines 49-62 Link Here
49
66
50
/**
67
/**
51
 * This is a dialog that can invoke the compare editor on chosen files.
68
 * This is a dialog that can invoke the compare editor on chosen files.
52
 * 
69
 *
53
 * @since 3.4
70
 * @since 3.4
54
 */
71
 */
55
public class CompareWithOtherResourceDialog extends TitleAreaDialog {
72
public class CompareWithOtherResourceDialog extends TitleAreaDialog {
56
73
57
	private int CLEAR_RETURN_CODE = 150; // any number != 0
74
	private int CLEAR_RETURN_CODE = 150; // any number != 0
75
	private int REFRESH_RETURN_CODE = 154;
58
	private int MIN_WIDTH = 300;
76
	private int MIN_WIDTH = 300;
59
	private int MIN_HEIGHT = 175;
77
	private int MIN_HEIGHT = 175;
78
	private int clipboardCounter = 0;
79
	public final static String TMP_PROJECT_NAME = ".org.eclipse.compare.tmp"; //$NON-NLS-1$
80
	private final static String TMP_PROJECT_FILE = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" //$NON-NLS-1$
81
			+ "<projectDescription>\n" //$NON-NLS-1$
82
			+ "\t<name>" + TMP_PROJECT_NAME + "\t</name>\n" //$NON-NLS-1$ //$NON-NLS-2$
83
			+ "\t<comment></comment>\n" //$NON-NLS-1$
84
			+ "\t<projects>\n" //$NON-NLS-1$
85
			+ "\t</projects>\n" //$NON-NLS-1$
86
			+ "\t<buildSpec>\n" //$NON-NLS-1$
87
			+ "\t</buildSpec>\n" //$NON-NLS-1$
88
			+ "\t<natures>\n" + "\t</natures>\n"   //$NON-NLS-1$//$NON-NLS-2$
89
			+ "</projectDescription>"; //$NON-NLS-1$
60
90
61
	private class FileTextDragListener implements DragSourceListener {
91
	private class FileTextDragListener implements DragSourceListener {
62
92
Lines 71-80 Link Here
71
		}
101
		}
72
102
73
		public void dragSetData(DragSourceEvent event) {
103
		public void dragSetData(DragSourceEvent event) {
74
			if (TextTransfer.getInstance().isSupportedType(event.dataType)) {
104
			event.data = section.fileText.getText();
75
				event.data = section.fileText.getText();
76
			} else
77
				event.data = section.fileText.getText();
78
		}
105
		}
79
106
80
		public void dragStart(DragSourceEvent event) {
107
		public void dragStart(DragSourceEvent event) {
Lines 156-161 Link Here
156
183
157
	}
184
	}
158
185
186
	private class ClipboardDropListener implements DropTargetListener {
187
188
		ClipboardAbstractSection clipboardSection;
189
190
		public ClipboardDropListener(ClipboardAbstractSection clipboardSection) {
191
			this.clipboardSection = clipboardSection;
192
		}
193
194
		public void dragEnter(DropTargetEvent event) {
195
			if (event.detail == DND.DROP_DEFAULT) {
196
				if ((event.operations & DND.DROP_COPY) != 0)
197
					event.detail = DND.DROP_COPY;
198
				else
199
					event.detail = DND.DROP_NONE;
200
			}
201
202
			for (int i = 0; i < event.dataTypes.length; i++) {
203
				if (TextTransfer.getInstance().isSupportedType(event.dataTypes[i])) {
204
					event.currentDataType = event.dataTypes[i];
205
					if (event.detail != DND.DROP_COPY)
206
						event.detail = DND.DROP_NONE;
207
					break;
208
				}
209
			}
210
		}
211
212
		public void dragLeave(DropTargetEvent event) {
213
			clipboardSection.clipboardExpandable.setExpanded(true);
214
			getShell().pack();
215
		}
216
217
		public void dragOperationChanged(DropTargetEvent event) {
218
			// intentionally empty
219
		}
220
221
		public void dragOver(DropTargetEvent event) {
222
			clipboardSection.clipboardExpandable.setExpanded(true);
223
			getShell().pack();
224
		}
225
226
		public void drop(DropTargetEvent event) {
227
			if (TextTransfer.getInstance().isSupportedType(event.currentDataType)) {
228
				String fileContent = (String) event.data;
229
				clipboardSection.setViewerContent(fileContent);
230
				IFile file = clipboardSection.createTmpFile(fileContent);
231
				// don't update a fileText's content
232
				clipboardSection.getPanel().setResourceFromClipboard(file);
233
				updateErrorInfo();
234
			}
235
		}
236
237
		public void dropAccept(DropTargetEvent event) {
238
			// intentionally empty
239
		}
240
241
	}
242
243
	private abstract class ClipboardAbstractSection {
244
245
		protected ExpandableComposite clipboardExpandable;
246
		protected SourceViewer viewer;
247
		protected Button refreshButton;
248
		private InternalSection section;
249
250
		public ClipboardAbstractSection(InternalSection section) {
251
			this.section = section;
252
		}
253
254
		protected void createClipboardSection(Composite parent) {
255
			final Composite p = parent;
256
			clipboardExpandable = new ExpandableComposite(parent, SWT.NONE,
257
					ExpandableComposite.TWISTIE);
258
			clipboardExpandable
259
					.setText(CompareMessages.CompareWithOther_clipboardSection);
260
			Composite content = createContentsForClipboardSection(clipboardExpandable);
261
			clipboardExpandable.setClient(content);
262
			clipboardExpandable.addExpansionListener(new ExpansionAdapter() {
263
				public void expansionStateChanged(ExpansionEvent e) {
264
					p.layout();
265
					getShell().pack();
266
					if (e.getState()) {
267
						section.fileText.setEnabled(false);
268
						// do not clear contents of the fileText
269
						section.clearResourceWithoutPath();
270
						setViewerAndCreateFile();
271
					} else {
272
						section.fileText.setEnabled(true);
273
						section.clearResourceWithoutPath();
274
						if (section.fileText.getText() != "") //$NON-NLS-1$
275
							section.setResource(section.fileText.getText());
276
					}
277
					updateErrorInfo();
278
				}
279
			});
280
281
			GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
282
			gd.horizontalSpan = 2;
283
			clipboardExpandable.setLayoutData(gd);
284
285
			initDropForClipboard();
286
		}
287
288
		private void setViewerAndCreateFile() {
289
			String newContent = (String) clipboard.getContents(TextTransfer.getInstance());
290
			setViewerContent(newContent);
291
		}
292
293
		public void setViewerContent(String newContent) {
294
			viewer.setDocument(new Document(newContent));
295
			// don't update a fileText's content
296
			section.setResourceFromClipboard(createTmpFile(newContent));
297
		}
298
299
		private void initDropForClipboard() {
300
			DropTarget clipboardTarget = new DropTarget(clipboardExpandable, DND.DROP_COPY | DND.DROP_DEFAULT);
301
			Transfer[] types = new Transfer[] {TextTransfer.getInstance()};
302
			clipboardTarget.setTransfer(types);
303
			clipboardTarget.addDropListener(new ClipboardDropListener(this));
304
		}
305
306
		private Composite createContentsForClipboardSection(Composite parent) {
307
308
			Composite contents = new Composite(parent, SWT.NONE);
309
			contents.setLayout(new GridLayout(1, false));
310
311
			Label infoLabel = new Label(contents, SWT.NONE);
312
			infoLabel.setText(clipboardInfo());
313
			GridData labelGd = new GridData(SWT.FILL, SWT.FILL, true, true);
314
			labelGd.horizontalSpan = 3;
315
			infoLabel.setLayoutData(labelGd);
316
317
			viewer = new SourceViewer(contents, null, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
318
			viewer.setEditable(false);
319
320
			GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
321
			gd.horizontalSpan = 3;
322
			gd.widthHint = 200;
323
			gd.heightHint = 150;
324
			viewer.getTextWidget().setLayoutData(gd);
325
			// although viewer is not editable, we need ModifyListener to
326
			// set viewer's content and error message after dropping a portion of text
327
			viewer.getTextWidget().addModifyListener(new ModifyListener() {
328
				public void modifyText(ModifyEvent e) {
329
					setViewerAndCreateFile();
330
					updateErrorInfo();
331
				}
332
			});
333
334
			createRefreshButton(contents);
335
			parent.layout();
336
337
			return contents;
338
		}
339
340
		abstract protected String clipboardInfo();
341
342
		private void createRefreshButton(Composite parent) {
343
			refreshButton = createButton(parent, REFRESH_RETURN_CODE, CompareMessages.CompareWithOther_refreshButton, false);
344
			refreshButton.addSelectionListener(new SelectionListener() {
345
				public void widgetDefaultSelected(SelectionEvent e) {
346
					widgetSelected(e);
347
				}
348
				public void widgetSelected(SelectionEvent e) {
349
					setViewerAndCreateFile();
350
					updateErrorInfo();
351
				}
352
			});
353
		}
354
355
		private IFile createTmpFile(String fileContent) {
356
			IFile file = null;
357
			try {
358
				IProject project = createTmpProject();
359
				if (!project.isOpen())
360
					project.open(null);
361
				IFolder folder = project.getFolder("ClipboardFolder"); //$NON-NLS-1$
362
				if (!folder.exists())
363
					folder.create(IResource.NONE, true, null);
364
				file = folder.getFile(CompareMessages.CompareWithOther_fileName
365
						+ clipboardCounter++);
366
				if (!file.exists()) {
367
					InputStream source = new ByteArrayInputStream(fileContent
368
							.getBytes());
369
					file.create(source, IResource.NONE, null);
370
				}
371
			} catch (CoreException e) {
372
				CompareUIPlugin.log(e);
373
				MessageDialog.openError(getShell(),
374
						CompareMessages.CompareWithOther_createTmpFile_title,
375
						CompareMessages.CompareWithOther_createTmpFile_message);
376
				return file;
377
			}
378
			return file;
379
		}
380
381
		private IProject createTmpProject() throws CoreException {
382
			IProject tmpProject = getTmpProject();
383
			if (!tmpProject.isAccessible()) {
384
				try {
385
					if (!tmpProject.exists()) {
386
						IProjectDescription desc = tmpProject.getWorkspace().newProjectDescription(tmpProject.getName());
387
						IPath location = CompareUI.getPlugin().getStateLocation();
388
						desc.setLocation(location.append(TMP_PROJECT_NAME));
389
						tmpProject.create(desc, null);
390
					}
391
					try {
392
						tmpProject.open(null);
393
					} catch (CoreException e1) { // in case .project file or folder has been deleted
394
						IPath location1 = CompareUI.getPlugin().getStateLocation();
395
						IPath projectPath1 = location1.append(TMP_PROJECT_NAME);
396
						projectPath1.toFile().mkdirs();
397
						FileOutputStream output = new FileOutputStream(
398
								projectPath1.append(".project").toOSString()); //$NON-NLS-1$
399
						try {
400
							output.write(TMP_PROJECT_FILE.getBytes());
401
						} finally {
402
							output.close();
403
						}
404
						tmpProject.open(null);
405
					}
406
				} catch (IOException ioe) {
407
					return tmpProject;
408
				} catch (CoreException ce) {
409
					throw new CoreException(ce.getStatus());
410
				}
411
			}
412
			return tmpProject;
413
		}
414
415
		private IProject getTmpProject() {
416
			return ResourcesPlugin.getWorkspace().getRoot().getProject(
417
					TMP_PROJECT_NAME);
418
		}
419
420
		protected boolean clipboardSectionExpanded() {
421
			return clipboardExpandable.isExpanded();
422
		}
423
424
		protected boolean noResource() {
425
			return section.getResource() == null;
426
		}
427
428
		public InternalSection getPanel() {
429
			return section;
430
		}
431
432
	}
433
434
	private class ClipboardSection extends ClipboardAbstractSection {
435
436
		public ClipboardSection(InternalSection section) {
437
			super(section);
438
		}
439
440
		protected String clipboardInfo() {
441
			return CompareMessages.CompareWithOther_clipboardInfo_1 + "\n" + //$NON-NLS-1$
442
				CompareMessages.CompareWithOther_clipboardInfo_2;
443
		}
444
	}
445
446
	private class ClipboardAncestorSection extends ClipboardAbstractSection {
447
448
		public ClipboardAncestorSection(InternalSection section) {
449
			super(section);
450
		}
451
452
		protected String clipboardInfo() {
453
			return CompareMessages.CompareWithOther_clipboardInfo_1 +
454
				CompareMessages.CompareWithOther_clipboardInfo_2;
455
		}
456
	}
457
159
	private abstract class InternalSection {
458
	private abstract class InternalSection {
160
459
161
		protected Group group;
460
		protected Group group;
Lines 172-179 Link Here
172
471
173
		public void createContents(Composite parent) {
472
		public void createContents(Composite parent) {
174
			createGroup(parent);
473
			createGroup(parent);
175
			createFileLabel();
176
			createFileCombo();
177
			initDrag();
474
			initDrag();
178
			initDrop();
475
			initDrop();
179
		}
476
		}
Lines 195-201 Link Here
195
				resource = null;
492
				resource = null;
196
			else
493
			else
197
				resource = tmp;
494
				resource = tmp;
495
		}
198
496
497
		public void setResourceFromClipboard(IResource resource) {
498
			this.resource = resource;
199
		}
499
		}
200
500
201
		protected void clearResource() {
501
		protected void clearResource() {
Lines 204-209 Link Here
204
			updateErrorInfo();
504
			updateErrorInfo();
205
		}
505
		}
206
506
507
		protected void clearResourceWithoutPath() {
508
			resource = null;
509
			updateErrorInfo();
510
		}
511
207
		protected void initDrag() {
512
		protected void initDrag() {
208
			DragSource source = new DragSource(fileText, DND.DROP_MOVE
513
			DragSource source = new DragSource(fileText, DND.DROP_MOVE
209
					| DND.DROP_COPY | DND.DROP_DEFAULT);
514
					| DND.DROP_COPY | DND.DROP_DEFAULT);
Lines 224-237 Link Here
224
529
225
		protected void createGroup(Composite parent) {
530
		protected void createGroup(Composite parent) {
226
			group = new Group(parent, SWT.NONE);
531
			group = new Group(parent, SWT.NONE);
227
			group.setLayout(new GridLayout(3, false));
532
			group.setLayout(new GridLayout(2, false));
228
			group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
533
			group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
534
			createFileLabel(group);
535
			createFileCombo(group);
229
		}
536
		}
230
537
231
		protected void createFileCombo() {
538
		protected void createFileCombo(Composite parent) {
232
			fileText = new Text(group, SWT.BORDER);
539
			fileText = new Text(parent, SWT.BORDER);
233
			fileText
540
			fileText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
234
					.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
235
541
236
			fileText.addModifyListener(new ModifyListener() {
542
			fileText.addModifyListener(new ModifyListener() {
237
				public void modifyText(ModifyEvent e) {
543
				public void modifyText(ModifyEvent e) {
Lines 241-271 Link Here
241
			});
547
			});
242
548
243
			fileText.addSelectionListener(new SelectionListener() {
549
			fileText.addSelectionListener(new SelectionListener() {
244
245
				public void widgetDefaultSelected(SelectionEvent e) {
550
				public void widgetDefaultSelected(SelectionEvent e) {
246
					widgetSelected(e);
551
					widgetSelected(e);
247
				}
552
				}
248
249
				public void widgetSelected(SelectionEvent e) {
553
				public void widgetSelected(SelectionEvent e) {
250
					setResource(fileText.getText());
554
					setResource(fileText.getText());
251
					updateErrorInfo();
555
					updateErrorInfo();
252
				}
556
				}
253
254
			});
557
			});
255
		}
558
		}
256
559
257
		protected void createFileLabel() {
560
		protected void createFileLabel(Composite parent) {
258
			final Label fileLabel = new Label(group, SWT.NONE);
561
			final Label fileLabel = new Label(parent, SWT.NONE);
259
			fileLabel.setText(CompareMessages.CompareWithOther_fileLabel);
562
			fileLabel.setText(CompareMessages.CompareWithOther_fileLabel);
260
		}
563
		}
261
	}
564
	}
262
565
263
	private class InternalGroup extends InternalSection {
566
	private class InternalGroup extends InternalSection {
264
567
568
		private ClipboardSection clipboardSection;
569
265
		public InternalGroup(Composite parent) {
570
		public InternalGroup(Composite parent) {
571
			this.clipboardSection = new ClipboardSection(this);
266
			createContents(parent);
572
			createContents(parent);
267
		}
573
		}
268
574
575
		protected void createGroup(Composite parent) {
576
			super.createGroup(parent);
577
			clipboardSection.createClipboardSection(group);
578
		}
579
269
		public void setText(String text) {
580
		public void setText(String text) {
270
			group.setText(text);
581
			group.setText(text);
271
		}
582
		}
Lines 278-294 Link Here
278
	private class InternalExpandable extends InternalSection {
589
	private class InternalExpandable extends InternalSection {
279
590
280
		private ExpandableComposite expandable;
591
		private ExpandableComposite expandable;
281
		private Button clearButton;
592
		public Button clearButton;
593
		private ClipboardAncestorSection clipboardAncestorSection;
282
594
283
		public InternalExpandable(Composite parent) {
595
		public InternalExpandable(Composite parent) {
596
			this.clipboardAncestorSection = new ClipboardAncestorSection(this);
284
			createContents(parent);
597
			createContents(parent);
285
		}
598
		}
286
599
287
		public void createContents(Composite parent) {
600
		public void createContents(Composite parent) {
288
			createGroup(parent);
601
			createGroup(parent);
289
			createFileLabel();
290
			createFileCombo();
291
			createClearButton(group);
292
			initDrag();
602
			initDrag();
293
			initDrop();
603
			initDrop();
294
		}
604
		}
Lines 298-309 Link Here
298
			expandable = new ExpandableComposite(parent, SWT.NONE,
608
			expandable = new ExpandableComposite(parent, SWT.NONE,
299
					ExpandableComposite.TREE_NODE | ExpandableComposite.TWISTIE);
609
					ExpandableComposite.TREE_NODE | ExpandableComposite.TWISTIE);
300
			super.createGroup(expandable);
610
			super.createGroup(expandable);
611
			createClearButton(group);
301
			expandable.setClient(group);
612
			expandable.setClient(group);
302
			expandable.addExpansionListener(new ExpansionAdapter() {
613
			expandable.addExpansionListener(new ExpansionAdapter() {
303
				public void expansionStateChanged(ExpansionEvent e) {
614
				public void expansionStateChanged(ExpansionEvent e) {
304
					p.layout();
615
					p.layout();
616
					getShell().pack();
305
				}
617
				}
306
			});
618
			});
619
			clipboardAncestorSection.createClipboardSection(group);
307
		}
620
		}
308
621
309
		protected void createClearButton(Composite parent) {
622
		protected void createClearButton(Composite parent) {
Lines 334-343 Link Here
334
	private InternalGroup rightPanel, leftPanel;
647
	private InternalGroup rightPanel, leftPanel;
335
	private InternalExpandable ancestorPanel;
648
	private InternalExpandable ancestorPanel;
336
	private ISelection fselection;
649
	private ISelection fselection;
650
	Clipboard clipboard;
337
651
338
	/**
652
	/**
339
	 * Creates the dialog.
653
	 * Creates the dialog.
340
	 * 
654
	 *
341
	 * @param shell
655
	 * @param shell
342
	 *            a shell
656
	 *            a shell
343
	 * @param selection
657
	 * @param selection
Lines 349-359 Link Here
349
		super(shell);
663
		super(shell);
350
		setShellStyle(SWT.MODELESS | SWT.RESIZE | SWT.MAX);
664
		setShellStyle(SWT.MODELESS | SWT.RESIZE | SWT.MAX);
351
		fselection = selection;
665
		fselection = selection;
666
		clipboard = new Clipboard(Display.getDefault());
352
	}
667
	}
353
668
354
	/*
669
	/*
355
	 * (non-Javadoc)
670
	 * (non-Javadoc)
356
	 * 
671
	 *
357
	 * @see
672
	 * @see
358
	 * org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets
673
	 * org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets
359
	 * .Composite)
674
	 * .Composite)
Lines 389-395 Link Here
389
704
390
	/*
705
	/*
391
	 * (non-Javadoc)
706
	 * (non-Javadoc)
392
	 * 
707
	 *
393
	 * @see
708
	 * @see
394
	 * org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse
709
	 * org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse
395
	 * .swt.widgets.Composite)
710
	 * .swt.widgets.Composite)
Lines 463-469 Link Here
463
	 * the ancestor panel, table has only two elements -- resources chosen in
778
	 * the ancestor panel, table has only two elements -- resources chosen in
464
	 * left and right panel. In the other case table contains all three
779
	 * left and right panel. In the other case table contains all three
465
	 * resources.
780
	 * resources.
466
	 * 
781
	 *
467
	 * @return table with selected resources
782
	 * @return table with selected resources
468
	 */
783
	 */
469
	public IResource[] getResult() {
784
	public IResource[] getResult() {
(-)compare/org/eclipse/compare/internal/CompareWithOtherResourceAction.java (-1 / +15 lines)
Lines 10-20 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.compare.internal;
11
package org.eclipse.compare.internal;
12
12
13
import org.eclipse.core.resources.IProject;
14
import org.eclipse.core.resources.ResourcesPlugin;
15
import org.eclipse.core.runtime.CoreException;
13
import org.eclipse.jface.viewers.ISelection;
16
import org.eclipse.jface.viewers.ISelection;
14
17
15
/**
18
/**
16
 * The "Compare with other resource" action
19
 * The "Compare with other resource" action
17
 * 
20
 *
18
 * @since 3.4
21
 * @since 3.4
19
 */
22
 */
20
public class CompareWithOtherResourceAction extends CompareAction {
23
public class CompareWithOtherResourceAction extends CompareAction {
Lines 23-28 Link Here
23
		// Show CompareWithOtherResourceDialog which return resources to compare
26
		// Show CompareWithOtherResourceDialog which return resources to compare
24
		// and ancestor if specified. Don't need to display the other dialog
27
		// and ancestor if specified. Don't need to display the other dialog
25
		showSelectAncestorDialog = false;
28
		showSelectAncestorDialog = false;
29
		cleanup();
26
		super.run(selection);
30
		super.run(selection);
27
	}
31
	}
28
32
Lines 32-35 Link Here
32
		return true;
36
		return true;
33
	}
37
	}
34
38
39
	private void cleanup() {
40
		try {
41
			String projectName = CompareWithOtherResourceDialog.TMP_PROJECT_NAME;
42
			IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
43
			project.delete(true, true, null);
44
		} catch (CoreException e) {
45
			CompareUIPlugin.log(e);
46
		}
47
	}
48
35
}
49
}
(-)compare/org/eclipse/compare/internal/CompareMessages.properties (-1 / +8 lines)
Lines 131-134 Link Here
131
CompareWithOther_error_empty=Both left and right panel must contain a valid path.
131
CompareWithOther_error_empty=Both left and right panel must contain a valid path.
132
CompareWithOther_warning_two_way=Ancestor is not a valid resource. Two-way compare will be performed.
132
CompareWithOther_warning_two_way=Ancestor is not a valid resource. Two-way compare will be performed.
133
CompareWithOther_clear=Clear
133
CompareWithOther_clear=Clear
134
CompareWithOther_info=Drag files from a view or between dialog's fields.
134
CompareWithOther_info=Drag files from Package Explorer or from another field within the dialog or expand "Clipboard" if you want to use clipboard's content instead of a resource.
135
CompareWithOther_clipboardSection=Clipboard
136
CompareWithOther_fileName=Clipboard
137
CompareWithOther_createTmpFile_title= Unable to create file
138
CompareWithOther_createTmpFile_message= A file cannot be created from clipboard content.
139
CompareWithOther_refreshButton=Refresh
140
CompareWithOther_clipboardInfo_1=Add content to the viewer below by dropping a portion of text into it or use Refresh
141
CompareWithOther_clipboardInfo_2=button if you want fill the viewer with current clipboard's content.

Return to bug 241088