KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > ui > compare > ManifestContentMergeViewer


1 /*******************************************************************************
2  * Copyright (c) 2005, 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.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.PDEUIMessages;
21 import org.eclipse.pde.internal.ui.editor.text.ColorManager;
22 import org.eclipse.pde.internal.ui.editor.text.IColorManager;
23 import org.eclipse.pde.internal.ui.editor.text.ManifestConfiguration;
24 import org.eclipse.pde.internal.ui.editor.text.ManifestPartitionScanner;
25 import org.eclipse.swt.events.DisposeEvent;
26 import org.eclipse.swt.graphics.Font;
27 import org.eclipse.swt.widgets.Composite;
28
29 public class ManifestContentMergeViewer extends TextMergeViewer {
30
31     private IColorManager fColorManager;
32
33     public ManifestContentMergeViewer(Composite parent, CompareConfiguration configuration) {
34         super(parent, configuration);
35     }
36
37     protected void configureTextViewer(TextViewer textViewer) {
38         if (textViewer instanceof SourceViewer) {
39             if (fColorManager == null)
40                 fColorManager = ColorManager.getDefault();
41             ((SourceViewer)textViewer).configure(new ManifestConfiguration(fColorManager, null, getDocumentPartitioning()));
42             Font font = JFaceResources.getFont(ManifestContentMergeViewer.class.getName());
43             if (font != null)
44                 ((SourceViewer)textViewer).getTextWidget().setFont(font);
45         }
46     }
47
48     protected IDocumentPartitioner getDocumentPartitioner() {
49         return new FastPartitioner(new ManifestPartitionScanner(), ManifestPartitionScanner.PARTITIONS);
50     }
51     
52     protected String JavaDoc getDocumentPartitioning() {
53         return ManifestPartitionScanner.MANIFEST_FILE_PARTITIONING;
54     }
55     
56     public String JavaDoc getTitle() {
57         return PDEUIMessages.ManifestContentMergeViewer_title;
58     }
59     
60     protected void handleDispose(DisposeEvent event) {
61         super.handleDispose(event);
62         if (fColorManager != null)
63             fColorManager.dispose();
64     }
65     
66 }
67
Popular Tags