~ubuntu-branches/debian/sid/eclipse-cdt/sid

« back to all changes in this revision

Viewing changes to build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ToolListElement.java

  • Committer: Package Import Robot
  • Author(s): Jakub Adam
  • Date: 2011-10-06 21:15:04 UTC
  • mfrom: (1.1.4)
  • Revision ID: package-import@ubuntu.com-20111006211504-8dutmljjih0zikfv
Tags: 8.0.1-1
* New upstream release.
* Split the JNI packages into a separate architecture dependent
  package and made eclipse-cdt architecture independent.
* Install JNI libraries into multiarch aware location
* Bumped Standards-Version to 3.9.2.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*******************************************************************************
 
2
 * Copyright (c) 2006, 2010 Intel Corporation and others.
 
3
 * All rights reserved. This program and the accompanying materials
 
4
 * are made available under the terms of the Eclipse Public License v1.0
 
5
 * which accompanies this distribution, and is available at
 
6
 * http://www.eclipse.org/legal/epl-v10.html
 
7
 *
 
8
 * Contributors:
 
9
 * Intel Corporation - Initial API and implementation
 
10
 *******************************************************************************/
 
11
 
 
12
package org.eclipse.cdt.managedbuilder.ui.properties;
 
13
 
 
14
import java.util.ArrayList;
 
15
import java.util.List;
 
16
 
 
17
import org.eclipse.cdt.managedbuilder.core.IHoldsOptions;
 
18
import org.eclipse.cdt.managedbuilder.core.IOptionCategory;
 
19
import org.eclipse.cdt.managedbuilder.core.ITool;
 
20
import org.eclipse.cdt.managedbuilder.internal.core.OptionCategory;
 
21
 
 
22
/**
 
23
 * This class represent the elements in the TreeViewer that displays the tools
 
24
 * and categories in the tool options property pages.  The reason for these
 
25
 * elements is illustrated by bugzilla #123461.  We used to use the ToolChain, 
 
26
 * Tool and OptionCategory objects themselves as the elements in the TreeViewer,
 
27
 * but the same OptionCategory can appear more than once in the list of Tree
 
28
 * Viewer items, and this caused problems.
 
29
 * 
 
30
 * @noextend This class is not intended to be subclassed by clients.
 
31
 * @noinstantiate This class is not intended to be instantiated by clients.
 
32
 */
 
33
public class ToolListElement {
 
34
        
 
35
        /*
 
36
         * Bookeeping variables
 
37
         */
 
38
        private ToolListElement parent = null;
 
39
        private List<ToolListElement> childElements = null;
 
40
 
 
41
        private IHoldsOptions optionHolder = null;
 
42
        private IOptionCategory optionCategory = null;
 
43
        private ITool tool = null;
 
44
 
 
45
        /*
 
46
         * Constructor for an element tha represents an option category
 
47
         */
 
48
        public ToolListElement(ToolListElement parent, IHoldsOptions optionHolder, IOptionCategory optionCategory) {
 
49
                this.parent = parent;
 
50
                this.optionHolder = optionHolder;
 
51
                this.optionCategory = optionCategory;
 
52
        }
 
53
 
 
54
        /*
 
55
         * Constructor for an element tha represents a tool
 
56
         */
 
57
        public ToolListElement(ITool tool) {
 
58
                this.tool = tool;
 
59
        }
 
60
        
 
61
        public boolean isEquivalentTo(ToolListElement e) {
 
62
        
 
63
                if (tool != null) {
 
64
                        //  Look for a matching tool
 
65
                        ITool matchTool = e.getTool();
 
66
                        if (matchTool == tool) return true;
 
67
                        if (matchTool == null) return false;
 
68
                        if (matchTool.getName().equals(tool.getUniqueRealName())) return true;
 
69
                        return false;
 
70
                }
 
71
        
 
72
                if (optionCategory != null) {
 
73
                        IOptionCategory matchCategory = e.getOptionCategory();
 
74
                        IHoldsOptions matchHolder = e.getHoldOptions();
 
75
                        if (matchCategory == optionCategory &&
 
76
                                matchHolder == optionHolder) return true;
 
77
                        if (matchCategory == null) return false;
 
78
                        
 
79
                        //String matchCategoryName = matchCategory.getName();
 
80
                        //String optionCategoryName = optionCategory.getName();
 
81
                        String matchCategoryName = OptionCategory.makeMatchName(matchCategory);
 
82
                        String optionCategoryName = OptionCategory.makeMatchName(optionCategory);
 
83
                        if (matchHolder.getName().equals(optionHolder.getName()) &&
 
84
                                matchCategoryName.equals(optionCategoryName)) return true;
 
85
 
 
86
                        return false;
 
87
                }
 
88
                return false;
 
89
        }
 
90
 
 
91
        /*
 
92
         * Field accessors
 
93
         */
 
94
        public ToolListElement getParent() {
 
95
                return parent;
 
96
        }
 
97
        
 
98
        public IHoldsOptions getHoldOptions() {
 
99
                return optionHolder;
 
100
        }
 
101
        
 
102
        public IOptionCategory getOptionCategory() {
 
103
                return optionCategory;
 
104
        }
 
105
        
 
106
        public ITool getTool() {
 
107
                return tool;
 
108
        }
 
109
        
 
110
        /*
 
111
         * Children handling
 
112
         */
 
113
        public ToolListElement[] getChildElements() {
 
114
                if (childElements != null)
 
115
                        return childElements.toArray(new ToolListElement[childElements.size()]);
 
116
                else
 
117
                        return new ToolListElement[0];
 
118
        }
 
119
        
 
120
        public void addChildElement(ToolListElement element) {
 
121
                if (childElements == null)
 
122
                        childElements = new ArrayList<ToolListElement>();
 
123
                childElements.add(element);
 
124
        }
 
125
}