/** * Aptana Studio * Copyright (c) 2005-2011 by Appcelerator, Inc. All Rights Reserved. * Licensed under the terms of the GNU Public License (GPL) v3 (with exceptions). * Please see the license.html included with this distribution for details. * Any modifications to this file must keep this entire header intact. */ package com.aptana.editor.ruby.internal; import org.eclipse.compare.CompareConfiguration; import org.eclipse.compare.contentmergeviewer.TextMergeViewer; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.text.IDocumentExtension3; import org.eclipse.jface.text.IDocumentPartitioner; import org.eclipse.jface.text.TextViewer; import org.eclipse.jface.text.source.SourceViewer; import org.eclipse.swt.widgets.Composite; import com.aptana.editor.common.ExtendedFastPartitioner; import com.aptana.editor.common.viewer.CommonMergeViewer; import com.aptana.editor.ruby.MergingPartitionScanner; import com.aptana.editor.ruby.RubySourceConfiguration; import com.aptana.editor.ruby.RubySourceEditor; import com.aptana.editor.ruby.RubySourcePartitionScanner; import com.aptana.editor.ruby.RubySourceViewerConfiguration; /** * @author cwilliams */ public class RubyMergeViewer extends CommonMergeViewer { public RubyMergeViewer(Composite parent, CompareConfiguration configuration) { super(parent, configuration); } @Override protected IDocumentPartitioner getDocumentPartitioner() { IDocumentPartitioner partitioner = new ExtendedFastPartitioner(new MergingPartitionScanner( new RubySourcePartitionScanner()), RubySourceConfiguration.getDefault().getContentTypes()); return partitioner; } @Override protected void configureTextViewer(TextViewer textViewer) { super.configureTextViewer(textViewer); if (textViewer instanceof SourceViewer) { SourceViewer sourceViewer = (SourceViewer) textViewer; sourceViewer.unconfigure(); IPreferenceStore preferences = RubySourceEditor.getChainedPreferenceStore(); RubySourceViewerConfiguration config = new RubySourceViewerConfiguration(preferences, null); sourceViewer.configure(config); } } }