Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 809bdc25f000fb303132d599a8bd67727762dcc6 (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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
/*******************************************************************************
 * Copyright (c) 2005 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.managedbuilder.internal.core;

import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ProjectScope;
import org.eclipse.core.runtime.content.*;
import org.eclipse.core.runtime.preferences.IScopeContext;
import org.eclipse.cdt.managedbuilder.core.IBuildObject;
import org.eclipse.cdt.managedbuilder.core.IProjectType;
import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.cdt.managedbuilder.core.IInputType;
import org.eclipse.cdt.managedbuilder.core.IOutputType;
import org.eclipse.cdt.managedbuilder.core.IManagedOutputNameProvider;
import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
import org.eclipse.cdt.managedbuilder.core.IToolChain;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.PluginVersionIdentifier;
import org.w3c.dom.Document;
import org.w3c.dom.Element;

public class OutputType extends BuildObject implements IOutputType {

	private static final String DEFAULT_SEPARATOR = ","; //$NON-NLS-1$
	private static final String EMPTY_STRING = new String();

	//  Superclass
	private IOutputType superClass;
	private String superClassId;
	//  Parent and children
	private ITool parent;
	//  Managed Build model attributes
	private String outputContentTypeId;
	private IContentType outputContentType;
	private String outputs;
	private String optionId;
	private String buildVariable;
	private Boolean multipleOfType;
	private String primaryInputTypeId;
	private IInputType primaryInputType;
	private Boolean primaryOutput;
	private String outputPrefix;
	private String outputNames;
	private String namePattern;
	private IConfigurationElement nameProviderElement = null;
	private IManagedOutputNameProvider nameProvider = null;
	//  Miscellaneous
	private boolean isExtensionOutputType = false;
	private boolean isDirty = false;
	private boolean resolved = true;

	/*
	 *  C O N S T R U C T O R S
	 */
	
	/**
	 * This constructor is called to create an OutputType defined by an extension point in 
	 * a plugin manifest file, or returned by a dynamic element provider
	 * 
	 * @param parent  The ITool parent of this OutputType
	 * @param element The OutputType definition from the manifest file or a dynamic element
	 *                provider
	 */
	public OutputType(ITool parent, IManagedConfigElement element) {
		this.parent = parent;
		isExtensionOutputType = true;
		
		// setup for resolving
		resolved = false;

		loadFromManifest(element);
		
		// Hook me up to the Managed Build Manager
		ManagedBuildManager.addExtensionOutputType(this);
	}

	/**
	 * This constructor is called to create an OutputType whose attributes will be 
	 * set by separate calls.
	 * 
	 * @param Tool The parent of the an OutputType
	 * @param OutputType The superClass, if any
	 * @param String The id for the new OutputType
	 * @param String The name for the new OutputType
	 * @param boolean Indicates whether this is an extension element or a managed project element
	 */
	public OutputType(Tool parent, IOutputType superClass, String Id, String name, boolean isExtensionElement) {
		this.parent = parent;
		this.superClass = superClass;
		if (this.superClass != null) {
			superClassId = this.superClass.getId();
		}
		setId(Id);
		setName(name);
		isExtensionOutputType = isExtensionElement;
		if (isExtensionElement) {
			// Hook me up to the Managed Build Manager
			ManagedBuildManager.addExtensionOutputType(this);
		} else {
			setDirty(true);
		}
	}

	/**
	 * Create an <code>OutputType</code> based on the specification stored in the 
	 * project file (.cdtbuild).
	 * 
	 * @param parent The <code>ITool</code> the OutputType will be added to. 
	 * @param element The XML element that contains the OutputType settings.
	 */
	public OutputType(ITool parent, Element element) {
		this.parent = parent;
		isExtensionOutputType = false;
		
		// Initialize from the XML attributes
		loadFromProject(element);
	}

	/**
	 * Create an <code>OutputType</code> based upon an existing OutputType.
	 * 
	 * @param parent The <code>ITool</code> the OutputType will be added to.
	 * @param Id The identifier of the new OutputType
	 * @param name The name of the new OutputType
	 * @param outputType The existing OutputType to clone.
	 */
	public OutputType(ITool parent, String Id, String name, OutputType outputType) {
		this.parent = parent;
		superClass = outputType.superClass;
		if (superClass != null) {
			if (outputType.superClassId != null) {
				superClassId = new String(outputType.superClassId);
			}
		}
		setId(Id);
		setName(name);
		isExtensionOutputType = false;
		
		//  Copy the remaining attributes
		if (outputType.outputContentTypeId != null) {
			outputContentTypeId = new String(outputType.outputContentTypeId);
		}
		outputContentType = outputType.outputContentType;
		if (outputType.outputs != null) {
			outputs = new String(outputType.outputs);
		}
		if (outputType.optionId != null) {
			optionId = new String(outputType.optionId);
		}
		if (outputType.buildVariable != null) {
			buildVariable = new String(outputType.buildVariable);
		}
		if (outputType.multipleOfType != null) {
			multipleOfType = new Boolean(outputType.multipleOfType.booleanValue());
		}
		if (outputType.primaryInputTypeId != null) {
			primaryInputTypeId = new String(outputType.primaryInputTypeId);
		}
		primaryInputType = outputType.primaryInputType;
		if (outputType.primaryOutput != null) {
			primaryOutput = new Boolean(outputType.primaryOutput.booleanValue());
		}
		if (outputType.outputPrefix != null) {
			outputPrefix = new String(outputType.outputPrefix);
		}
		if (outputType.outputNames != null) {
			outputNames = new String(outputType.outputNames);
		}
		if (outputType.namePattern != null) {
			namePattern = new String(outputType.namePattern);
		}

		nameProviderElement = outputType.nameProviderElement; 
		nameProvider = outputType.nameProvider; 
		
		setDirty(true);
	}

	/*
	 *  E L E M E N T   A T T R I B U T E   R E A D E R S   A N D   W R I T E R S
	 */
	
	/* (non-Javadoc)
	 * Loads the OutputType information from the ManagedConfigElement specified in the 
	 * argument.
	 * 
	 * @param element Contains the OutputType information 
	 */
	protected void loadFromManifest(IManagedConfigElement element) {
		ManagedBuildManager.putConfigElement(this, element);
		
		// id
		setId(element.getAttribute(IBuildObject.ID));
		
		// Get the name
		setName(element.getAttribute(IBuildObject.NAME));
		
		// superClass
		superClassId = element.getAttribute(IProjectType.SUPERCLASS);
		
		// outputContentType
		outputContentTypeId = element.getAttribute(IOutputType.OUTPUT_CONTENT_TYPE); 
		
		// outputs
		outputs = element.getAttribute(IOutputType.OUTPUTS);
		
		// option
		optionId = element.getAttribute(IOutputType.OPTION); 
		
		// multipleOfType
        String isMOT = element.getAttribute(IOutputType.MULTIPLE_OF_TYPE);
        if (isMOT != null){
    		multipleOfType = new Boolean("true".equals(isMOT)); //$NON-NLS-1$
        }
		
		// primaryInputType
		primaryInputTypeId = element.getAttribute(IOutputType.PRIMARY_INPUT_TYPE);
		
		// primaryOutput
        String isPO = element.getAttribute(IOutputType.PRIMARY_OUTPUT);
        if (isPO != null){
    		primaryOutput = new Boolean("true".equals(isPO)); //$NON-NLS-1$
        }
		
		// outputPrefix
		outputPrefix = element.getAttribute(IOutputType.OUTPUT_PREFIX);
		
		// outputNames
		outputNames = element.getAttribute(IOutputType.OUTPUT_NAMES);
		
		// namePattern
		namePattern = element.getAttribute(IOutputType.NAME_PATTERN);
		
		// buildVariable
		buildVariable = element.getAttribute(IOutputType.BUILD_VARIABLE); 

		// Store the configuration element IFF there is a name provider defined 
		String nameProvider = element.getAttribute(IOutputType.NAME_PROVIDER); 
		if (nameProvider != null && element instanceof DefaultManagedConfigElement) {
			nameProviderElement = ((DefaultManagedConfigElement)element).getConfigurationElement();			
		}
	}
	
	/* (non-Javadoc)
	 * Initialize the OutputType information from the XML element 
	 * specified in the argument
	 * 
	 * @param element An XML element containing the OutputType information 
	 */
	protected void loadFromProject(Element element) {
		
		// id
		setId(element.getAttribute(IBuildObject.ID));

		// name
		if (element.hasAttribute(IBuildObject.NAME)) {
			setName(element.getAttribute(IBuildObject.NAME));
		}
		
		// superClass
		superClassId = element.getAttribute(IProjectType.SUPERCLASS);
		if (superClassId != null && superClassId.length() > 0) {
			superClass = ManagedBuildManager.getExtensionOutputType(superClassId);
			if (superClass == null) {
				// TODO:  Report error
			}
		}
		
		// outputContentType
		if (element.hasAttribute(IOutputType.OUTPUT_CONTENT_TYPE)) {
			outputContentTypeId = element.getAttribute(IOutputType.OUTPUT_CONTENT_TYPE); 			
		}
		
		// outputs
		if (element.hasAttribute(IOutputType.OUTPUTS)) {
			outputs = element.getAttribute(IOutputType.OUTPUTS);			
		}
		
		// option
		if (element.hasAttribute(IOutputType.OPTION)) {
			optionId = element.getAttribute(IOutputType.OPTION);
		}
		
		// multipleOfType
		if (element.hasAttribute(IOutputType.MULTIPLE_OF_TYPE)) {
			String isMOT = element.getAttribute(IOutputType.MULTIPLE_OF_TYPE);
			if (isMOT != null){
				multipleOfType = new Boolean("true".equals(isMOT)); //$NON-NLS-1$
			}
		}
		
		// primaryInputType
		if (element.hasAttribute(IOutputType.PRIMARY_INPUT_TYPE)) {
			primaryInputTypeId = element.getAttribute(IOutputType.PRIMARY_INPUT_TYPE);
			primaryInputType = parent.getInputTypeById(primaryInputTypeId);
		}
		
		// primaryOutput
        if (element.hasAttribute(IOutputType.PRIMARY_OUTPUT)) {
			String isPO = element.getAttribute(IOutputType.PRIMARY_OUTPUT);
			if (isPO != null){
				primaryOutput = new Boolean("true".equals(isPO)); //$NON-NLS-1$
			}
        }
		
		// outputPrefix
		if (element.hasAttribute(IOutputType.OUTPUT_PREFIX)) {
			outputPrefix = element.getAttribute(IOutputType.OUTPUT_PREFIX);
		}
		
		// outputNames
		if (element.hasAttribute(IOutputType.OUTPUT_NAMES)) {
			outputNames = element.getAttribute(IOutputType.OUTPUT_NAMES);
		}
		
		// namePattern
		if (element.hasAttribute(IOutputType.NAME_PATTERN)) {
			namePattern = element.getAttribute(IOutputType.NAME_PATTERN);
		}
		
		// buildVariable
		if (element.hasAttribute(IOutputType.BUILD_VARIABLE)) {
			buildVariable = element.getAttribute(IOutputType.BUILD_VARIABLE);
		}
		
		// Note: Name Provider cannot be specified in a project file because
		//       an IConfigurationElement is needed to load it!
		if (element.hasAttribute(IOutputType.NAME_PROVIDER)) {
			// TODO:  Issue warning?
		}
	}

	/**
	 * Persist the OutputType to the project file.
	 * 
	 * @param doc
	 * @param element
	 */
	public void serialize(Document doc, Element element) {
		if (superClass != null)
			element.setAttribute(IProjectType.SUPERCLASS, superClass.getId());
		
		element.setAttribute(IBuildObject.ID, id);
		
		if (name != null) {
			element.setAttribute(IBuildObject.NAME, name);
		}

		if (outputContentTypeId != null) {
			element.setAttribute(IOutputType.OUTPUT_CONTENT_TYPE, outputContentTypeId);
		}

		if (outputs != null) {
			element.setAttribute(IOutputType.OUTPUTS, outputs);
		}
		
		if (optionId != null) {
			element.setAttribute(IOutputType.OPTION, optionId);
		}
		
		if (multipleOfType != null) {
			element.setAttribute(IOutputType.MULTIPLE_OF_TYPE, multipleOfType.toString());
		}
		
		if (primaryInputTypeId != null) {
			element.setAttribute(IOutputType.PRIMARY_INPUT_TYPE, primaryInputTypeId);
		}
		
		if (primaryOutput != null) {
			element.setAttribute(IOutputType.PRIMARY_OUTPUT, primaryOutput.toString());
		}
		
		if (outputPrefix != null) {
			element.setAttribute(IOutputType.OUTPUT_PREFIX, outputPrefix);
		}
		
		if (outputNames != null) {
			element.setAttribute(IOutputType.OUTPUT_NAMES, outputNames);
		}
		
		if (namePattern != null) {
			element.setAttribute(IOutputType.NAME_PATTERN, namePattern);
		}

		if (buildVariable != null) {
			element.setAttribute(IOutputType.BUILD_VARIABLE, buildVariable);
		}

		// Note: dependency generator cannot be specified in a project file because
		//       an IConfigurationElement is needed to load it!
		if (nameProviderElement != null) {
			//  TODO:  issue warning?
		}
		
		// I am clean now
		isDirty = false;
	}

	/*
	 *  P A R E N T   A N D   C H I L D   H A N D L I N G
	 */

	/* (non-Javadoc)
	 * @see org.eclipse.cdt.core.build.managed.IOutputType#getParent()
	 */
	public ITool getParent() {
		return parent;
	}

	/*
	 *  M O D E L   A T T R I B U T E   A C C E S S O R S
	 */

	/* (non-Javadoc)
	 * @see org.eclipse.cdt.managedbuilder.core.IOutputType#getSuperClass()
	 */
	public IOutputType getSuperClass() {
		return superClass;
	}

	/* (non-Javadoc)
	 * @see org.eclipse.cdt.core.build.managed.IOutputType#getName()
	 */
	public String getName() {
		return (name == null && superClass != null) ? superClass.getName() : name;
	}

	/* (non-Javadoc)
	 * @see org.eclipse.cdt.core.build.managed.IOutputType#getBuildVariable()
	 */
	public String getBuildVariable() {
		if (buildVariable == null) {
			// If I have a superClass, ask it
			if (superClass != null) {
				return superClass.getBuildVariable();
			} else {
				//  Use default name
				String name = getName();
				if (name == null || name.length() == 0) {
					name = getId();
				}
				String defaultName = name.toUpperCase();
				defaultName = defaultName.replaceAll("\\W", "_");  //$NON-NLS-1$  //$NON-NLS-2$
				defaultName += "_OUTPUTS";	//$NON-NLS-1$ 
				return defaultName;
			}
		}
		return buildVariable;
	}

	/* (non-Javadoc)
	 * @see org.eclipse.cdt.core.build.managed.IOutputType#setBuildVariable()
	 */
	public void setBuildVariable(String variableName) {
		if (variableName == null && buildVariable == null) return;
		if (buildVariable == null || variableName == null || !(variableName.equals(buildVariable))) {
			buildVariable = variableName;
			setDirty(true);
		}
	}

	/* (non-Javadoc)
	 * @see org.eclipse.cdt.core.build.managed.IOutputType#getMultipleOfType()
	 */
	public boolean getMultipleOfType() {
		if (multipleOfType == null) {
			if (superClass != null) {
				return superClass.getMultipleOfType();
			} else {
				return false;	// default is false
			}
		}
		return multipleOfType.booleanValue();
	}

	/* (non-Javadoc)
	 * @see org.eclipse.cdt.core.build.managed.IOuputType#setMultipleOfType()
	 */
	public void setMultipleOfType(boolean b) {
		if (multipleOfType == null || !(b == multipleOfType.booleanValue())) {
			multipleOfType = new Boolean(b);
			setDirty(true);
		}
	}

	/* (non-Javadoc)
	 * @see org.eclipse.cdt.core.build.managed.IOuputType#getNamePattern()
	 */
	public String getNamePattern() {
		if (namePattern == null) {
			// If I have a superClass, ask it
			if (superClass != null) {
				return superClass.getNamePattern();
			} else {
				return EMPTY_STRING;
			}
		}
		return namePattern;
	}

	/* (non-Javadoc)
	 * @see org.eclipse.cdt.core.build.managed.IOuputType#setNamePattern()
	 */
	public void setNamePattern(String pattern) {
		if (pattern == null && namePattern == null) return;
		if (namePattern == null || pattern == null || !(pattern.equals(namePattern))) {
			namePattern = pattern;
			setDirty(true);
		}
	}

	/* (non-Javadoc)
	 * @see org.eclipse.cdt.core.build.managed.IOuputType#getNameProviderElement()
	 */
	public IConfigurationElement getNameProviderElement() {
		if (nameProviderElement == null) {
			if (superClass != null) {
				return ((OutputType)superClass).getNameProviderElement();
			}
		}
		return nameProviderElement;
	}

	/* (non-Javadoc)
	 * @see org.eclipse.cdt.core.build.managed.IOuputType#setNameProviderElement()
	 */
	public void setNameProviderElement(IConfigurationElement element) {
		nameProviderElement = element;
		setDirty(true);
	}

	/* (non-Javadoc)
	 * @see org.eclipse.cdt.core.build.managed.IOuputType#setNameProviderElement()
	 */
	public IManagedOutputNameProvider getNameProvider() {
		if (nameProvider != null) {
			return nameProvider;
		}
		IConfigurationElement element = getNameProviderElement();
		if (element != null) {
			try {
				if (element.getAttribute(NAME_PROVIDER) != null) {
					nameProvider = (IManagedOutputNameProvider) element.createExecutableExtension(NAME_PROVIDER);
					return nameProvider;
				}
			} catch (CoreException e) {}
		}
		return null;
	}

	/* (non-Javadoc)
	 * @see org.eclipse.cdt.core.build.managed.IOuputType#getOptionId()
	 */
	public String getOptionId() {
		if (optionId == null) {
			if (superClass != null) {
				return superClass.getOptionId();
			} else {
				return null;
			}			
		}
		return optionId; 
	}

	/* (non-Javadoc)
	 * @see org.eclipse.cdt.core.build.managed.IOuputType#setOptionId()
	 */
	public void setOptionId(String id) {
		if (id == null && optionId == null) return;
		if (id == null || optionId == null || !(optionId.equals(id))) {
			optionId = id;
			setDirty(true);
		}
	}

	/* (non-Javadoc)
	 * @see org.eclipse.cdt.core.build.managed.IOuputType#getOutputContentType()
	 */
	public IContentType getOutputContentType() {
		if (outputContentType == null) {
			if (superClass != null) {
				return superClass.getOutputContentType();
			} else {
				return null;
			}			
		}
		return outputContentType;
	}

	/* (non-Javadoc)
	 * @see org.eclipse.cdt.core.build.managed.IOuputType#setOutputContentType()
	 */
	public void setOutputContentType(IContentType type) {
		if (outputContentType != type) {
			outputContentType = type;
			if (outputContentType != null) {
				outputContentTypeId = outputContentType.getId();				
			} else {
				outputContentTypeId = null;
			}
			setDirty(true);
		}
	}

	/* (non-Javadoc)
	 * @see org.eclipse.cdt.core.build.managed.IOuputType#getOutputExtensionsAttribute()
	 */
	public String[] getOutputExtensionsAttribute() {
		if (outputs == null) {
			if (superClass != null) {
				return superClass.getOutputExtensionsAttribute();
			} else {
				return null;
			}
		}
		return outputs.split(DEFAULT_SEPARATOR);
	}

	/* (non-Javadoc)
	 * @see org.eclipse.cdt.core.build.managed.IOuputType#setOutputExtensionsAttribute()
	 */
	public void setOutputExtensionsAttribute(String exts) {
		if (exts == null && outputs == null) return;
		if (outputs == null || exts == null || !(exts.equals(outputs))) {
			outputs = exts;
			setDirty(true);
		}
	}

	/* (non-Javadoc)
	 * @see org.eclipse.cdt.core.build.managed.IOuputType#getOutputExtensions()
	 */
	public String[] getOutputExtensions(ITool tool) {
		//  Use content type if specified and registered with Eclipse
		IContentType type = getOutputContentType();
		if (type != null) {
			return ((Tool)tool).getContentTypeFileSpecs(type);
		}
		return getOutputExtensionsAttribute();
	}

	/* (non-Javadoc)
	 * @see org.eclipse.cdt.core.build.managed.IOutputType#isOutputExtension()
	 */
	public boolean isOutputExtension(ITool tool, String ext) {
		String[] exts = getOutputExtensions(tool);
		if (exts != null) {
			for (int i=0; i<exts.length; i++) {
				if (ext.equals(exts[i])) return true;
			}
		}
		return false;
	}

	/* (non-Javadoc)
	 * @see org.eclipse.cdt.core.build.managed.IOuputType#getOutputPrefix()
	 */
	public String getOutputPrefix() {
		if (outputPrefix == null) {
			// If I have a superClass, ask it
			if (superClass != null) {
				return superClass.getOutputPrefix();
			} else {
				return EMPTY_STRING;
			}
		}
		return outputPrefix;
	}

	/* (non-Javadoc)
	 * @see org.eclipse.cdt.core.build.managed.IOuputType#setOutputPrefix()
	 */
	public void setOutputPrefix(String prefix) {
		if (prefix == null && outputPrefix == null) return;
		if (outputPrefix == null || prefix == null || !(prefix.equals(outputPrefix))) {
			outputPrefix = prefix;
			setDirty(true);
		}
	}

	/* (non-Javadoc)
	 * @see org.eclipse.cdt.core.build.managed.IOuputType#getOutputNames()
	 */
	public String[] getOutputNames() {
		if (outputNames == null) {
			// If I have a superClass, ask it
			if (superClass != null) {
				return superClass.getOutputNames();
			} else {
				return null;
			}
		}
		String[] nameTokens = outputNames.split(";"); //$NON-NLS-1$
		return nameTokens;
	}


	/* (non-Javadoc)
	 * @see org.eclipse.cdt.core.build.managed.IOuputType#setOutputNames()
	 */
	public void setOutputNames(String names) {
		if (names == null && outputNames == null) return;
		if (outputNames == null || names == null || !(names.equals(outputNames))) {
			outputNames = names;
			setDirty(true);
		}
	}

	/* (non-Javadoc)
	 * @see org.eclipse.cdt.core.build.managed.IOuputType#getPrimaryInputType()
	 */
	public IInputType getPrimaryInputType() {
		IInputType ret = primaryInputType;
		if (ret == null) {
			if (superClass != null) {
				ret = superClass.getPrimaryInputType();
			}
			if (ret == null) {
				ret = getParent().getPrimaryInputType();
			}			
		}
		return ret;
	}

	/* (non-Javadoc)
	 * @see org.eclipse.cdt.core.build.managed.IOuputType#setPrimaryInputType()
	 */
	public void setPrimaryInputType(IInputType type) {
		if (primaryInputType != type) {
			primaryInputType = type;
			if (primaryInputType != null) {
				primaryInputTypeId = primaryInputType.getId();				
			} else {
				primaryInputTypeId = null;
			}
			setDirty(true);
		}
	}

	/* (non-Javadoc)
	 * @see org.eclipse.cdt.core.build.managed.IOuputType#getPrimaryOutput()
	 */
	public boolean getPrimaryOutput() {
		if (primaryOutput == null) {
			if (superClass != null) {
				return superClass.getPrimaryOutput();
			} else {
				return false;	// default is false
			}
		}
		return primaryOutput.booleanValue();
	}

	/* (non-Javadoc)
	 * @see org.eclipse.cdt.core.build.managed.IOuputType#setPrimaryOutput()
	 */
	public void setPrimaryOutput(boolean b) {
		if (primaryOutput == null || !(b == primaryOutput.booleanValue())) {
			primaryOutput = new Boolean(b);
			setDirty(true);
		}
	}

	/*
	 *  O B J E C T   S T A T E   M A I N T E N A N C E
	 */
	
	/* (non-Javadoc)
	 * @see org.eclipse.cdt.managedbuilder.core.IOutputType#isExtensionElement()
	 */
	public boolean isExtensionElement() {
		return isExtensionOutputType;
	}

	/* (non-Javadoc)
	 * @see org.eclipse.cdt.managedbuilder.core.IOutputType#isDirty()
	 */
	public boolean isDirty() {
		// This shouldn't be called for an extension OutputType
 		if (isExtensionOutputType) return false;
		return isDirty;
	}

	/* (non-Javadoc)
	 * @see org.eclipse.cdt.managedbuilder.core.IOutputType#setDirty(boolean)
	 */
	public void setDirty(boolean isDirty) {
		this.isDirty = isDirty;
	}
	
	/* (non-Javadoc)
	 *  Resolve the element IDs to interface references
	 */
	public void resolveReferences() {
		if (!resolved) {
			resolved = true;
			// Resolve superClass
			if (superClassId != null && superClassId.length() > 0) {
				superClass = ManagedBuildManager.getExtensionOutputType(superClassId);
				if (superClass == null) {
					// Report error
					ManagedBuildManager.OutputResolveError(
							"superClass",	//$NON-NLS-1$
							superClassId,
							"outputType",	//$NON-NLS-1$
							getId());
				}
			}
			
			// Resolve content types
			IContentTypeManager manager = Platform.getContentTypeManager();
			if (outputContentTypeId != null && outputContentTypeId.length() > 0) {
				outputContentType = manager.getContentType(outputContentTypeId);
			}

			// Resolve primary input type
			if (primaryInputTypeId != null && primaryInputTypeId.length() > 0) {
				primaryInputType = parent.getInputTypeById(primaryInputTypeId);
			}
		}
	}
	
	/**
	 * @return Returns the managedBuildRevision.
	 */
	public String getManagedBuildRevision() {
		if ( managedBuildRevision == null) {
			if ( getParent() != null) {
				return getParent().getManagedBuildRevision();
			}
		}
		return managedBuildRevision;
	}

	/**
	 * @return Returns the version.
	 */
	public PluginVersionIdentifier getVersion() {
		if ( version == null) {
			if ( getParent() != null) {
				return getParent().getVersion();
			}
		}
		return version;
	}
	
	public void setVersion(PluginVersionIdentifier version) {
		// Do nothing
	}
}

Back to the top