blob: 0068174ad87872572096cf3feb5ddbf01c539513 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
/*******************************************************************************
* Copyright (c) 2005, 2009 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
* QNX Software System
* Anton Leherbauer (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.ui.compare;
import org.eclipse.compare.CompareConfiguration;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.text.IDocumentPartitioner;
import org.eclipse.jface.text.source.SourceViewerConfiguration;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.text.CSourceViewerConfiguration;
import org.eclipse.cdt.ui.text.ICPartitions;
import org.eclipse.cdt.ui.text.doctools.IDocCommentOwner;
import org.eclipse.cdt.internal.ui.text.CTextTools;
import org.eclipse.cdt.internal.ui.text.doctools.DocCommentOwnerManager;
/**
* A merge viewer for C/C++ code.
*/
public class CMergeViewer extends AbstractMergeViewer {
private static final String TITLE= "CMergeViewer.title"; //$NON-NLS-1$
CSourceViewerConfiguration fSourceViewerConfiguration;
public CMergeViewer(Composite parent, int styles, CompareConfiguration mp) {
super(parent, styles, mp);
}
@Override
protected SourceViewerConfiguration getSourceViewerConfiguration() {
if (fSourceViewerConfiguration == null) {
CTextTools tools= CUIPlugin.getDefault().getTextTools();
IPreferenceStore store = getPreferenceStore();
fSourceViewerConfiguration = new CSourceViewerConfiguration(tools.getColorManager(), store, null, ICPartitions.C_PARTITIONING);
}
return fSourceViewerConfiguration;
}
@Override
protected IDocumentPartitioner getDocumentPartitioner() {
// use workspace default for highlighting doc comments in compare viewer
IDocCommentOwner owner= DocCommentOwnerManager.getInstance().getWorkspaceCommentOwner();
return CUIPlugin.getDefault().getTextTools().createDocumentPartitioner(owner);
}
@Override
public String getTitle() {
return CUIPlugin.getResourceString(TITLE);
}
@Override
protected void handlePropertyChange(PropertyChangeEvent event) {
super.handlePropertyChange(event);
if (fSourceViewerConfiguration != null && fSourceViewerConfiguration.affectsTextPresentation(event)) {
fSourceViewerConfiguration.handlePropertyChangeEvent(event);
invalidateTextPresentation();
}
}
}
|