KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > ui > compare > PropertiesFileMergeViewer


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

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 /**
35  * Properties file merge viewer.
36  *
37  * @since 3.1
38  */

39 public class PropertiesFileMergeViewer extends TextMergeViewer {
40
41     /**
42      * Creates a properties file merge viewer under the given parent control.
43      *
44      * @param parent the parent control
45      * @param configuration the configuration object
46      */

47     public PropertiesFileMergeViewer(Composite parent, CompareConfiguration configuration) {
48         super(parent, SWT.LEFT_TO_RIGHT, configuration);
49     }
50     
51     /*
52      * @see org.eclipse.compare.contentmergeviewer.TextMergeViewer#configureTextViewer(org.eclipse.jface.text.TextViewer)
53      */

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     /*
68      * @see org.eclipse.compare.contentmergeviewer.TextMergeViewer#getDocumentPartitioner()
69      */

70     protected IDocumentPartitioner getDocumentPartitioner() {
71         return new FastPartitioner(new PropertiesFilePartitionScanner(), IPropertiesFilePartitions.PARTITIONS);
72     }
73     
74     /*
75      * @see org.eclipse.compare.contentmergeviewer.TextMergeViewer#getDocumentPartitioning()
76      * @since 3.3
77      */

78     protected String JavaDoc getDocumentPartitioning() {
79         return IPropertiesFilePartitions.PROPERTIES_FILE_PARTITIONING;
80     }
81
82     /*
83      * @see org.eclipse.compare.contentmergeviewer.ContentMergeViewer#getTitle()
84      */

85     public String JavaDoc getTitle() {
86         return CompareMessages.PropertiesFileMergeViewer_title;
87     }
88 }
89
Popular Tags