1 11 package org.eclipse.pde.internal.ui.compare; 12 13 import org.eclipse.compare.CompareConfiguration; 14 import org.eclipse.compare.contentmergeviewer.TextMergeViewer; 15 import org.eclipse.jface.resource.JFaceResources; 16 import org.eclipse.jface.text.IDocumentPartitioner; 17 import org.eclipse.jface.text.TextViewer; 18 import org.eclipse.jface.text.rules.FastPartitioner; 19 import org.eclipse.jface.text.source.SourceViewer; 20 import org.eclipse.pde.internal.ui.editor.text.ColorManager; 21 import org.eclipse.pde.internal.ui.editor.text.IColorManager; 22 import org.eclipse.pde.internal.ui.editor.text.XMLConfiguration; 23 import org.eclipse.pde.internal.ui.editor.text.XMLPartitionScanner; 24 import org.eclipse.swt.events.DisposeEvent; 25 import org.eclipse.swt.graphics.Font; 26 import org.eclipse.swt.widgets.Composite; 27 28 public class XMLContentMergeViewer extends TextMergeViewer { 29 30 private IColorManager fColorManager; 31 32 public XMLContentMergeViewer(Composite parent, CompareConfiguration config) { 33 super(parent, config); 34 } 35 36 protected void configureTextViewer(TextViewer textViewer) { 37 if (textViewer instanceof SourceViewer) { 38 if (fColorManager == null) 39 fColorManager = ColorManager.getDefault(); 40 ((SourceViewer)textViewer).configure(new XMLConfiguration(fColorManager)); 41 Font font = JFaceResources.getFont(XMLContentMergeViewer.class.getName()); 42 if (font != null) 43 ((SourceViewer)textViewer).getTextWidget().setFont(font); 44 } 45 } 46 47 protected IDocumentPartitioner getDocumentPartitioner() { 48 return new FastPartitioner(new XMLPartitionScanner(), XMLPartitionScanner.PARTITIONS); 49 } 50 51 public String getTitle() { 52 return XMLStructureCreator.DEFAULT_NAME; 53 } 54 55 protected void handleDispose(DisposeEvent event) { 56 super.handleDispose(event); 57 if (fColorManager != null) 58 fColorManager.dispose(); 59 } 60 } 61 | Popular Tags |