01: /*******************************************************************************
02: * Copyright (c) 2005, 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.pde.internal.ui.compare;
11:
12: import org.eclipse.compare.CompareConfiguration;
13: import org.eclipse.compare.contentmergeviewer.TextMergeViewer;
14: import org.eclipse.jface.resource.JFaceResources;
15: import org.eclipse.jface.text.IDocumentPartitioner;
16: import org.eclipse.jface.text.TextViewer;
17: import org.eclipse.jface.text.rules.FastPartitioner;
18: import org.eclipse.jface.text.source.SourceViewer;
19: import org.eclipse.pde.internal.ui.PDEUIMessages;
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.ManifestConfiguration;
23: import org.eclipse.pde.internal.ui.editor.text.ManifestPartitionScanner;
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 ManifestContentMergeViewer extends TextMergeViewer {
29:
30: private IColorManager fColorManager;
31:
32: public ManifestContentMergeViewer(Composite parent,
33: 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)
42: .configure(new ManifestConfiguration(fColorManager,
43: null, getDocumentPartitioning()));
44: Font font = JFaceResources
45: .getFont(ManifestContentMergeViewer.class.getName());
46: if (font != null)
47: ((SourceViewer) textViewer).getTextWidget().setFont(
48: font);
49: }
50: }
51:
52: protected IDocumentPartitioner getDocumentPartitioner() {
53: return new FastPartitioner(new ManifestPartitionScanner(),
54: ManifestPartitionScanner.PARTITIONS);
55: }
56:
57: protected String getDocumentPartitioning() {
58: return ManifestPartitionScanner.MANIFEST_FILE_PARTITIONING;
59: }
60:
61: public String getTitle() {
62: return PDEUIMessages.ManifestContentMergeViewer_title;
63: }
64:
65: protected void handleDispose(DisposeEvent event) {
66: if (fColorManager != null)
67: fColorManager.dispose();
68: super.handleDispose(event);
69: }
70:
71: }
|