1 11 package org.eclipse.jdt.internal.ui.compare; 12 13 import org.eclipse.swt.SWT; 14 import org.eclipse.swt.widgets.Composite; 15 16 import org.eclipse.compare.CompareConfiguration; 17 import org.eclipse.compare.contentmergeviewer.TextMergeViewer; 18 19 import org.eclipse.jface.preference.IPreferenceStore; 20 21 import org.eclipse.jface.text.IDocumentPartitioner; 22 import org.eclipse.jface.text.TextViewer; 23 import org.eclipse.jface.text.rules.FastPartitioner; 24 import org.eclipse.jface.text.source.SourceViewer; 25 import org.eclipse.jface.text.source.SourceViewerConfiguration; 26 27 import org.eclipse.jdt.ui.text.JavaTextTools; 28 29 import org.eclipse.jdt.internal.ui.JavaPlugin; 30 import org.eclipse.jdt.internal.ui.propertiesfileeditor.IPropertiesFilePartitions; 31 import org.eclipse.jdt.internal.ui.propertiesfileeditor.PropertiesFilePartitionScanner; 32 import org.eclipse.jdt.internal.ui.propertiesfileeditor.PropertiesFileSourceViewerConfiguration; 33 34 39 public class PropertiesFileMergeViewer extends TextMergeViewer { 40 41 47 public PropertiesFileMergeViewer(Composite parent, CompareConfiguration configuration) { 48 super(parent, SWT.LEFT_TO_RIGHT, configuration); 49 } 50 51 54 protected void configureTextViewer(TextViewer textViewer) { 55 if (textViewer instanceof SourceViewer) { 56 JavaTextTools tools= JavaCompareUtilities.getJavaTextTools(); 57 if (tools != null) 58 ((SourceViewer)textViewer).configure(getSourceViewerConfiguration(tools)); 59 } 60 } 61 62 private SourceViewerConfiguration getSourceViewerConfiguration(JavaTextTools textTools) { 63 IPreferenceStore store= JavaPlugin.getDefault().getCombinedPreferenceStore(); 64 return new PropertiesFileSourceViewerConfiguration(textTools.getColorManager(), store, null, getDocumentPartitioning()); 65 } 66 67 70 protected IDocumentPartitioner getDocumentPartitioner() { 71 return new FastPartitioner(new PropertiesFilePartitionScanner(), IPropertiesFilePartitions.PARTITIONS); 72 } 73 74 78 protected String getDocumentPartitioning() { 79 return IPropertiesFilePartitions.PROPERTIES_FILE_PARTITIONING; 80 } 81 82 85 public String getTitle() { 86 return CompareMessages.PropertiesFileMergeViewer_title; 87 } 88 } 89 | Popular Tags |