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

Collapse All | Expand All

(-)ui/org/eclipse/jdt/internal/ui/compare/JavaMergeViewer.java (-15 / +25 lines)
Lines 40-45 Link Here
40
import org.eclipse.jface.text.source.CompositeRuler;
40
import org.eclipse.jface.text.source.CompositeRuler;
41
import org.eclipse.jface.text.source.ISourceViewer;
41
import org.eclipse.jface.text.source.ISourceViewer;
42
import org.eclipse.jface.text.source.SourceViewer;
42
import org.eclipse.jface.text.source.SourceViewer;
43
import org.eclipse.jface.text.source.SourceViewerConfiguration;
43
44
44
import org.eclipse.ui.IEditorInput;
45
import org.eclipse.ui.IEditorInput;
45
import org.eclipse.ui.IEditorSite;
46
import org.eclipse.ui.IEditorSite;
Lines 273-280 Link Here
273
			CompilationUnitEditorAdapter editor= (CompilationUnitEditorAdapter)fEditor.get(sourceViewer);
274
			CompilationUnitEditorAdapter editor= (CompilationUnitEditorAdapter)fEditor.get(sourceViewer);
274
			try {
275
			try {
275
				editor.init((IEditorSite)editor.getSite(), editorInput);
276
				editor.init((IEditorSite)editor.getSite(), editorInput);
277
				editor.createPartControl(sourceViewer);
276
				editor.createActions();
278
				editor.createActions();
277
				configuration= new JavaSourceViewerConfiguration(tools.getColorManager(), fPreferenceStore, editor, getDocumentPartitioning());
279
//				configuration= new JavaSourceViewerConfiguration(tools.getColorManager(), fPreferenceStore, editor, getDocumentPartitioning());
280
				SourceViewerConfiguration svc= editor.getJavaSourceViewerConfiguration();
281
				Assert.isTrue(svc instanceof JavaSourceViewerConfiguration);
282
				configuration= (JavaSourceViewerConfiguration)svc;
278
			} catch (PartInitException e) {
283
			} catch (PartInitException e) {
279
				JavaPlugin.log(e);
284
				JavaPlugin.log(e);
280
			}
285
			}
Lines 473-484 Link Here
473
	protected SourceViewer createSourceViewer(Composite parent, int textOrientation) {
478
	protected SourceViewer createSourceViewer(Composite parent, int textOrientation) {
474
		SourceViewer sourceViewer;
479
		SourceViewer sourceViewer;
475
		if (getSite() != null) {
480
		if (getSite() != null) {
476
			CompilationUnitEditorAdapter editor= new CompilationUnitEditorAdapter(textOrientation);
481
			CompilationUnitEditorAdapter editor= new CompilationUnitEditorAdapter();
477
			editor.createPartControl(parent);
482
			sourceViewer = editor.createJavaSourceViewer(parent, textOrientation);
478
483
479
			ISourceViewer iSourceViewer= editor.getViewer();
480
			Assert.isTrue(iSourceViewer instanceof SourceViewer);
481
			sourceViewer= (SourceViewer)iSourceViewer;
482
			if (fEditor == null)
484
			if (fEditor == null)
483
				fEditor= new HashMap(3);
485
				fEditor= new HashMap(3);
484
			fEditor.put(sourceViewer, editor);
486
			fEditor.put(sourceViewer, editor);
Lines 525-539 Link Here
525
	
527
	
526
	private class CompilationUnitEditorAdapter extends CompilationUnitEditor {
528
	private class CompilationUnitEditorAdapter extends CompilationUnitEditor {
527
		private boolean fInputSet = false;
529
		private boolean fInputSet = false;
528
		private int fTextOrientation;
529
		private boolean fEditable;
530
		private boolean fEditable;
530
		
531
		
531
		CompilationUnitEditorAdapter(int textOrientation) {
532
			super();
533
			fTextOrientation = textOrientation;
534
			// TODO: has to be set here
535
			setPreferenceStore(createChainedPreferenceStore(null));
536
		}
537
		private void setEditable(boolean editable) {
532
		private void setEditable(boolean editable) {
538
			fEditable= editable;
533
			fEditable= editable;
539
		}
534
		}
Lines 551-561 Link Here
551
			}
546
			}
552
			// else do nothing, we will create actions later, when input is available
547
			// else do nothing, we will create actions later, when input is available
553
		}
548
		}
554
		public void createPartControl(Composite composite) {
549
		/**
555
			SourceViewer sourceViewer= createJavaSourceViewer(composite, new CompositeRuler(), null, false, fTextOrientation | SWT.H_SCROLL | SWT.V_SCROLL, createChainedPreferenceStore(null));
550
		 * Tries to mimic what takes place in
551
		 * <code>AbstractTextEditor#createPartControl(Composite)</code>. Instead of creating an
552
		 * editor part it sets previously created source viewer and configures it.
553
		 * 
554
		 * @param sourceViewer the source viewer to set
555
		 * @see org.eclipse.ui.texteditor.AbstractTextEditor#createPartControl(Composite)
556
		 * @see #createJavaSourceViewer(Composite, int)
557
		 */
558
		public void createPartControl(SourceViewer sourceViewer) {
556
			setSourceViewer(this, sourceViewer);
559
			setSourceViewer(this, sourceViewer);
560
			getSourceViewer().configure(getSourceViewerConfiguration());
557
			getSelectionProvider().addSelectionChangedListener(getSelectionChangedListener());
561
			getSelectionProvider().addSelectionChangedListener(getSelectionChangedListener());
558
		}
562
		}
563
		protected SourceViewer createJavaSourceViewer(Composite parent, int textOrientation) {
564
			return createJavaSourceViewer(parent, new CompositeRuler(), null, false, textOrientation | SWT.H_SCROLL | SWT.V_SCROLL, createChainedPreferenceStore(null));
565
		}
559
		protected void doSetInput(IEditorInput input) throws CoreException {
566
		protected void doSetInput(IEditorInput input) throws CoreException {
560
			super.doSetInput(input);
567
			super.doSetInput(input);
561
			// the editor input has been explicitly set
568
			// the editor input has been explicitly set
Lines 577-582 Link Here
577
		public void close(boolean save) {
584
		public void close(boolean save) {
578
			getDocumentProvider().disconnect(getEditorInput());
585
			getDocumentProvider().disconnect(getEditorInput());
579
		}
586
		}
587
		protected SourceViewerConfiguration getJavaSourceViewerConfiguration() {
588
			return getSourceViewerConfiguration();
589
		}
580
	}
590
	}
581
591
582
	// no setter to private field AbstractTextEditor.fSourceViewer
592
	// no setter to private field AbstractTextEditor.fSourceViewer

Return to bug 271787