Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: a3e6fbeb4aa6aa0f14c406d44a448f952b661037 (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
/*******************************************************************************
 * Copyright (c) 2007, 2015 Red Hat Inc..
 * 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:
 *     Red Hat Incorporated - initial API and implementation
 *******************************************************************************/
package org.eclipse.cdt.internal.autotools.ui.editors.automake;

import org.eclipse.cdt.autotools.core.AutotoolsPlugin;
import org.eclipse.cdt.internal.autotools.ui.preferences.ColorManager;
import org.eclipse.cdt.make.ui.IWorkingCopyManager;
import org.eclipse.jface.preference.PreferenceConverter;
import org.eclipse.swt.graphics.Color;


public class AutomakeEditorFactory {
	private IWorkingCopyManager workingCopyManager;
	private AutomakeDocumentProvider automakeFileDocumentProvider;
	private static volatile AutomakeEditorFactory factory;

	/**
	 * The constructor.
	 */
	private AutomakeEditorFactory() {
		factory = this;
	}
	
	public synchronized AutomakeDocumentProvider getAutomakefileDocumentProvider() {
		if (automakeFileDocumentProvider == null) {
			automakeFileDocumentProvider=  new AutomakeDocumentProvider();
		}
		return automakeFileDocumentProvider;
	}

	public synchronized IWorkingCopyManager getWorkingCopyManager() {
		if (workingCopyManager == null) {
			IMakefileDocumentProvider provider= getAutomakefileDocumentProvider();
			workingCopyManager= new WorkingCopyManager(provider);
		}
		return workingCopyManager;
	}

	/**
	 * Returns the preference color, identified by the given preference.
	 */
	public static Color getPreferenceColor(String key) {
		//FIXME: what do we do with Makefile editor preferences?
		return ColorManager.getDefault().getColor(PreferenceConverter.getColor(AutotoolsPlugin.getDefault().getPreferenceStore(), key));
	}

	public static AutomakeEditorFactory getDefault() {
		if (factory == null)
			factory = new AutomakeEditorFactory();
		return factory;
	}
}

Back to the top