upload tizen1.0 source
[sdk/ide/product.git] / org.eclipse.cdt.ui / src / org / eclipse / cdt / internal / ui / compare / AsmMergeViewer.java
1 /*******************************************************************************
2  * Copyright (c) 2007, 2009 Wind River Systems, Inc. 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  *     Anton Leherbauer (Wind River Systems) - initial API and implementation
10  *******************************************************************************/
11 package org.eclipse.cdt.internal.ui.compare;
12
13 import org.eclipse.compare.CompareConfiguration;
14 import org.eclipse.jface.preference.IPreferenceStore;
15 import org.eclipse.jface.text.IDocumentPartitioner;
16 import org.eclipse.jface.text.source.SourceViewerConfiguration;
17 import org.eclipse.jface.util.PropertyChangeEvent;
18 import org.eclipse.swt.widgets.Composite;
19
20 import org.eclipse.cdt.ui.CDTUITools;
21 import org.eclipse.cdt.ui.CUIPlugin;
22 import org.eclipse.cdt.ui.text.AsmSourceViewerConfiguration;
23 import org.eclipse.cdt.ui.text.ICPartitions;
24 import org.eclipse.cdt.ui.text.IColorManager;
25
26 /**
27  * A merge viewer for assembly code.
28  */
29 public class AsmMergeViewer extends AbstractMergeViewer {
30
31         private static final String TITLE= "AsmMergeViewer.title"; //$NON-NLS-1$
32
33         AsmSourceViewerConfiguration fSourceViewerConfiguration;
34
35         /**
36          * Create a new assembly merge viewer.
37          * 
38          * @param parent
39          * @param style
40          * @param configuration
41          */
42         public AsmMergeViewer(Composite parent, int style, CompareConfiguration configuration) {
43                 super(parent, style, configuration);
44         }
45
46         @Override
47         protected SourceViewerConfiguration getSourceViewerConfiguration() {
48                 if (fSourceViewerConfiguration == null) {
49                         IPreferenceStore store= getPreferenceStore();
50                         final IColorManager colorManager = CDTUITools.getColorManager();
51                         fSourceViewerConfiguration= new AsmSourceViewerConfiguration(colorManager, store, null, ICPartitions.C_PARTITIONING);
52                 }
53                 return fSourceViewerConfiguration;
54         }
55
56         @Override
57         public String getTitle() {
58                 return CUIPlugin.getResourceString(TITLE);
59         }
60
61         @Override
62         protected IDocumentPartitioner getDocumentPartitioner() {
63                 return CDTUITools.createAsmDocumentPartitioner();
64         }
65
66         @Override
67         protected void handlePropertyChange(PropertyChangeEvent event) {
68                 super.handlePropertyChange(event);
69
70                 if (fSourceViewerConfiguration != null && fSourceViewerConfiguration.affectsTextPresentation(event)) {
71                         fSourceViewerConfiguration.handlePropertyChangeEvent(event);
72                         invalidateTextPresentation();
73                 }
74         }
75 }