Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: cac6a69e75ea55a1e23f1d865494b0be779e7d1c (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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
/*******************************************************************************
 * 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 java.util.Arrays;

import org.eclipse.cdt.core.envvar.IEnvironmentContributor;
import org.eclipse.cdt.core.settings.model.ICOutputEntry;
import org.eclipse.cdt.core.settings.model.extension.CBuildData;
import org.eclipse.cdt.core.settings.model.util.CDataUtil;
import org.eclipse.core.runtime.IPath;

public class CDefaultBuildData extends CBuildData {
	protected IPath fCWD;
	protected String[] fErrorParserIDs;
	protected ICOutputEntry fOutputEntries[];
	protected static final String[] EMPTY_STRING_ARRAY = new String[0];
	protected static final ICOutputEntry[] EMPTY_OUTPUT_ENTRIES_ARRAY = new ICOutputEntry[0];
	protected String fName;
	protected String fId;
	protected boolean fIsModified;
//	protected CConfigurationData fCfg;
//	private CDataFacroty fFactory;


//	public CDefaultBuildData(CConfigurationData cfg, CDataFacroty factory) {
//		fCfg = cfg;
//		if(factory == null)
//			factory = new CDataFacroty();
//		fFactory = factory;
//	}
	
	public CDefaultBuildData(){
		
	}
	
	public CDefaultBuildData(String id, CBuildData base) {
		fId = id;
		
		copySettingsFrom(base);
	}
	
	protected void copySettingsFrom(CBuildData data){
		if(data != null){
			fName = data.getName();
			fCWD = data.getBuilderCWD();
			fErrorParserIDs = data.getErrorParserIDs();
			fOutputEntries = data.getOutputDirectories();
		}
	}

	@Override
	public IPath getBuilderCWD() {
		return fCWD;
	}

	@Override
	public String[] getErrorParserIDs() {
		if(fErrorParserIDs != null && fErrorParserIDs.length != 0)
			return fErrorParserIDs.clone();
		return EMPTY_STRING_ARRAY;
	}

	@Override
	public ICOutputEntry[] getOutputDirectories() {
		if(fOutputEntries != null && fOutputEntries.length != 0)
			return fOutputEntries.clone();
		return EMPTY_OUTPUT_ENTRIES_ARRAY;
	}

	@Override
	public void setBuilderCWD(IPath path) {
		if(CDataUtil.objectsEqual(path, fCWD))
			return;
		
		fCWD = path;
		
		setModified(true);
	}

	@Override
	public void setErrorParserIDs(String[] ids) {
		if(Arrays.equals(ids, fErrorParserIDs))
			return;
		if(ids != null && ids.length != 0)
			fErrorParserIDs = ids.clone();
		else
			fErrorParserIDs = ids;
		
		setModified(true);
	}

	@Override
	public void setOutputDirectories(ICOutputEntry[] entries) {
		if(Arrays.equals(entries, fOutputEntries))
			return;
		
		if(entries != null && entries.length != 0)
			fOutputEntries = entries.clone();
		else
			fOutputEntries = entries; 

		setModified(true);
	}

	@Override
	public String getId() {
		return fId;
	}

	@Override
	public String getName() {
		return fName;
	}

	@Override
	public boolean isValid() {
		return getId() != null;
	}

	@Override
	public IEnvironmentContributor getBuildEnvironmentContributor() {
		// TODO Auto-generated method stub
		return null;
	}

	public boolean isModified(){
		return fIsModified;
	}
	
	public void setModified(boolean modified){
		fIsModified = modified;
	}
}

Back to the top