Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 4944ec21cacd6857c61f18485676556cabe5ca86 (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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/*******************************************************************************
 * Copyright (c) 2007 Intel 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:
 * Intel Corporation - Initial API and implementation
 *******************************************************************************/
package org.eclipse.cdt.core.settings.model.extension.impl;

import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
import org.eclipse.cdt.core.settings.model.extension.CConfigurationData;
import org.eclipse.cdt.core.settings.model.extension.CLanguageData;
import org.eclipse.cdt.core.settings.model.extension.CResourceData;
import org.eclipse.cdt.core.settings.model.util.CDataSerializer;
import org.eclipse.cdt.core.settings.model.util.CDataUtil;
import org.eclipse.cdt.core.settings.model.util.UserAndDiscoveredEntryDataSerializer;
import org.eclipse.cdt.core.settings.model.util.UserAndDiscoveredEntryLanguageData;

public abstract class UserAndDiscoveredEntryConfigurationDataProvider extends
		CDefaultConfigurationDataProvider {
	private static DataFactory fDataFactory;
	
	protected class LanguageData extends UserAndDiscoveredEntryLanguageData {

		public LanguageData() {
			super();
		}

		public LanguageData(String id, CLanguageData base) {
			super(id, base);
		}

		public LanguageData(String id, String languageId, String[] ids,
				boolean isContentTypes) {
			super(id, languageId, ids, isContentTypes);
		}
		
		public LanguageData(String id, String name, String languageId, int kinds, String[] ids,
				boolean isContentTypes) {
			super(id, languageId, ids, isContentTypes);
			fName = name;
			fSupportedKinds = kinds;
		}

		@Override
		protected ICLanguageSettingEntry[] getAllDiscoveredEntries(int kind) {
			return UserAndDiscoveredEntryConfigurationDataProvider.this.getAllDiscoveredEntries(this, kind);
		}
	}
	
	protected class DataFactory extends CDataFactory {
		@Override
		public CLanguageData createLanguageData(CConfigurationData cfg,
				CResourceData rcBase, CLanguageData base, String id, boolean clone) {
			if(id == null)
				id = clone ? base.getId() : CDataUtil.genId(rcBase.getId());
			return new LanguageData(id, base);
		}

		@Override
		public CLanguageData createLanguageData(CConfigurationData cfg,
				CResourceData rcBase, String id, String name, String languageId,
				int supportedKinds, String[] rcTypes, boolean isContentTypes) {
			if(id == null)
				id = CDataUtil.genId(rcBase.getId());
			LanguageData lData = new LanguageData(id, name, languageId, supportedKinds, rcTypes, isContentTypes);
			return lData;
		}		
	}
	
	@Override
	protected CDataSerializer getDataSerializer() {
		return UserAndDiscoveredEntryDataSerializer.getDefault();
	}

	@Override
	protected CDataFactory getDataFactory() {
		if(fDataFactory == null){
			fDataFactory = new DataFactory();
		}
		return fDataFactory;
	}
	
	protected abstract ICLanguageSettingEntry[] getAllDiscoveredEntries(LanguageData data, int kind);

}

Back to the top