mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-09 09:15:38 +02:00
Fix bug 123461 - Deriving from the same tool twice within the same configuration does
This commit is contained in:
parent
72552ca1bc
commit
60194c446d
7 changed files with 383 additions and 301 deletions
|
@ -18,7 +18,6 @@ import java.util.ListIterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.eclipse.cdt.managedbuilder.core.BuildException;
|
import org.eclipse.cdt.managedbuilder.core.BuildException;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IBuildObject;
|
|
||||||
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IHoldsOptions;
|
import org.eclipse.cdt.managedbuilder.core.IHoldsOptions;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IOption;
|
import org.eclipse.cdt.managedbuilder.core.IOption;
|
||||||
|
@ -38,6 +37,7 @@ import org.eclipse.cdt.managedbuilder.ui.properties.BuildToolSettingsPreferenceS
|
||||||
import org.eclipse.cdt.managedbuilder.ui.properties.ResourceBuildPropertyPage;
|
import org.eclipse.cdt.managedbuilder.ui.properties.ResourceBuildPropertyPage;
|
||||||
import org.eclipse.cdt.managedbuilder.ui.properties.ToolListContentProvider;
|
import org.eclipse.cdt.managedbuilder.ui.properties.ToolListContentProvider;
|
||||||
import org.eclipse.cdt.managedbuilder.ui.properties.ToolListLabelProvider;
|
import org.eclipse.cdt.managedbuilder.ui.properties.ToolListLabelProvider;
|
||||||
|
import org.eclipse.cdt.managedbuilder.ui.properties.ToolListElement;
|
||||||
import org.eclipse.cdt.ui.dialogs.AbstractCOptionPage;
|
import org.eclipse.cdt.ui.dialogs.AbstractCOptionPage;
|
||||||
import org.eclipse.cdt.ui.dialogs.ICOptionContainer;
|
import org.eclipse.cdt.ui.dialogs.ICOptionContainer;
|
||||||
import org.eclipse.cdt.utils.ui.controls.ControlFactory;
|
import org.eclipse.cdt.utils.ui.controls.ControlFactory;
|
||||||
|
@ -76,8 +76,6 @@ public class ToolsSettingsBlock extends AbstractCOptionPage {
|
||||||
//private static final String OPTIONS_LABEL = LABEL + ".ToolOptions"; //$NON-NLS-1$
|
//private static final String OPTIONS_LABEL = LABEL + ".ToolOptions"; //$NON-NLS-1$
|
||||||
private static final int[] DEFAULT_SASH_WEIGHTS = new int[] { 20, 30 };
|
private static final int[] DEFAULT_SASH_WEIGHTS = new int[] { 20, 30 };
|
||||||
|
|
||||||
private static final String EMPTY_STRING = new String();
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Dialog widgets
|
* Dialog widgets
|
||||||
*/
|
*/
|
||||||
|
@ -94,10 +92,9 @@ public class ToolsSettingsBlock extends AbstractCOptionPage {
|
||||||
private BuildPropertyPage parent;
|
private BuildPropertyPage parent;
|
||||||
private ResourceBuildPropertyPage resParent;
|
private ResourceBuildPropertyPage resParent;
|
||||||
private BuildSettingsPage currentSettingsPage;
|
private BuildSettingsPage currentSettingsPage;
|
||||||
private IOptionCategory selectedCategory;
|
private ToolListElement selectedElement;
|
||||||
private ToolListContentProvider provider;
|
private ToolListContentProvider provider;
|
||||||
private ITool selectedTool;
|
private Object propertyObject;
|
||||||
private Object element;
|
|
||||||
|
|
||||||
private boolean defaultNeeded;
|
private boolean defaultNeeded;
|
||||||
|
|
||||||
|
@ -152,7 +149,7 @@ public class ToolsSettingsBlock extends AbstractCOptionPage {
|
||||||
super.setContainer(parent);
|
super.setContainer(parent);
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
configToPageListMap = new HashMap();
|
configToPageListMap = new HashMap();
|
||||||
this.element = element;
|
this.propertyObject = element;
|
||||||
settingsStore = new BuildToolSettingsPreferenceStore(this);
|
settingsStore = new BuildToolSettingsPreferenceStore(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -162,7 +159,7 @@ public class ToolsSettingsBlock extends AbstractCOptionPage {
|
||||||
super.setContainer((ICOptionContainer) resParent);
|
super.setContainer((ICOptionContainer) resParent);
|
||||||
this.resParent = resParent;
|
this.resParent = resParent;
|
||||||
configToPageListMap = new HashMap();
|
configToPageListMap = new HashMap();
|
||||||
this.element = element;
|
this.propertyObject = element;
|
||||||
settingsStore = new BuildToolSettingsPreferenceStore(this);
|
settingsStore = new BuildToolSettingsPreferenceStore(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -214,9 +211,10 @@ public class ToolsSettingsBlock extends AbstractCOptionPage {
|
||||||
* Method displayOptionsForCategory
|
* Method displayOptionsForCategory
|
||||||
* @param category
|
* @param category
|
||||||
*/
|
*/
|
||||||
private void displayOptionsForCategory(IOptionCategory category) {
|
private void displayOptionsForCategory(ToolListElement toolListElement) {
|
||||||
selectedTool = null;
|
selectedElement = toolListElement;
|
||||||
selectedCategory = category;
|
IOptionCategory category = toolListElement.getOptionCategory();
|
||||||
|
IHoldsOptions optionHolder = toolListElement.getHoldOptions();
|
||||||
|
|
||||||
// Cache the current build setting page
|
// Cache the current build setting page
|
||||||
BuildSettingsPage oldPage = currentSettingsPage;
|
BuildSettingsPage oldPage = currentSettingsPage;
|
||||||
|
@ -228,18 +226,18 @@ public class ToolsSettingsBlock extends AbstractCOptionPage {
|
||||||
while (iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
BuildSettingsPage page = (BuildSettingsPage) iter.next();
|
BuildSettingsPage page = (BuildSettingsPage) iter.next();
|
||||||
if (page instanceof BuildOptionSettingsPage &&
|
if (page instanceof BuildOptionSettingsPage &&
|
||||||
((BuildOptionSettingsPage)page).isForCategory(category)) {
|
((BuildOptionSettingsPage)page).isForCategory(optionHolder, category)) {
|
||||||
currentSettingsPage = page;
|
currentSettingsPage = page;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (currentSettingsPage == null) {
|
if (currentSettingsPage == null) {
|
||||||
if ( this.element instanceof IProject) {
|
if ( this.propertyObject instanceof IProject) {
|
||||||
currentSettingsPage = new BuildOptionSettingsPage(parent,parent.getSelectedConfigurationClone(), category);
|
currentSettingsPage = new BuildOptionSettingsPage(parent,parent.getSelectedConfigurationClone(), optionHolder, category);
|
||||||
pages.add(currentSettingsPage);
|
pages.add(currentSettingsPage);
|
||||||
currentSettingsPage.setContainer(parent);
|
currentSettingsPage.setContainer(parent);
|
||||||
} else if ( this.element instanceof IFile) {
|
} else if ( this.propertyObject instanceof IFile) {
|
||||||
currentSettingsPage = new BuildOptionSettingsPage(resParent,resParent.getCurrentResourceConfigClone(), category);
|
currentSettingsPage = new BuildOptionSettingsPage(resParent,resParent.getCurrentResourceConfigClone(), optionHolder, category);
|
||||||
pages.add(currentSettingsPage);
|
pages.add(currentSettingsPage);
|
||||||
currentSettingsPage.setContainer(resParent);
|
currentSettingsPage.setContainer(resParent);
|
||||||
}
|
}
|
||||||
|
@ -273,11 +271,9 @@ public class ToolsSettingsBlock extends AbstractCOptionPage {
|
||||||
* Method displayOptionsForTool
|
* Method displayOptionsForTool
|
||||||
* @param tool
|
* @param tool
|
||||||
*/
|
*/
|
||||||
private void displayOptionsForTool(ITool tool) {
|
private void displayOptionsForTool(ToolListElement toolListElement) {
|
||||||
// Unselect the category
|
selectedElement = toolListElement;
|
||||||
selectedCategory = null;
|
ITool tool = toolListElement.getTool();
|
||||||
// record that the tool selection has changed
|
|
||||||
selectedTool = tool;
|
|
||||||
|
|
||||||
// Cache the current build setting page
|
// Cache the current build setting page
|
||||||
BuildSettingsPage oldPage = currentSettingsPage;
|
BuildSettingsPage oldPage = currentSettingsPage;
|
||||||
|
@ -295,12 +291,12 @@ public class ToolsSettingsBlock extends AbstractCOptionPage {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (currentSettingsPage == null) {
|
if (currentSettingsPage == null) {
|
||||||
if ( this.element instanceof IProject) {
|
if ( this.propertyObject instanceof IProject) {
|
||||||
currentSettingsPage = new BuildToolSettingsPage(parent,
|
currentSettingsPage = new BuildToolSettingsPage(parent,
|
||||||
parent.getSelectedConfigurationClone(), tool);
|
parent.getSelectedConfigurationClone(), tool);
|
||||||
pages.add(currentSettingsPage);
|
pages.add(currentSettingsPage);
|
||||||
currentSettingsPage.setContainer(parent);
|
currentSettingsPage.setContainer(parent);
|
||||||
} else if(this.element instanceof IFile) {
|
} else if(this.propertyObject instanceof IFile) {
|
||||||
currentSettingsPage = new BuildToolSettingsPage(resParent,
|
currentSettingsPage = new BuildToolSettingsPage(resParent,
|
||||||
resParent.getCurrentResourceConfigClone(), tool);
|
resParent.getCurrentResourceConfigClone(), tool);
|
||||||
pages.add(currentSettingsPage);
|
pages.add(currentSettingsPage);
|
||||||
|
@ -378,100 +374,111 @@ public class ToolsSettingsBlock extends AbstractCOptionPage {
|
||||||
|
|
||||||
public void setVisible(boolean visible){
|
public void setVisible(boolean visible){
|
||||||
if(visible){
|
if(visible){
|
||||||
selectedCategory = null;
|
selectedElement = null;
|
||||||
selectedTool = null;
|
|
||||||
handleOptionSelection();
|
handleOptionSelection();
|
||||||
}
|
}
|
||||||
super.setVisible(visible);
|
super.setVisible(visible);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setValues() {
|
protected void setValues() {
|
||||||
|
/*
|
||||||
|
* This method updates the context of the build property pages
|
||||||
|
* - Which configuration/resource configuration is selected
|
||||||
|
* - Which tool/option category is selected
|
||||||
|
*
|
||||||
|
* It is called:
|
||||||
|
* - When a property page becomes visible
|
||||||
|
* - When the user changes the configuration selection
|
||||||
|
* - When the user changes the "exclude" setting for a resource
|
||||||
|
*/
|
||||||
|
|
||||||
IConfiguration config = null;
|
// Create the Tree Viewer content provider if first time
|
||||||
IResourceConfiguration resConfig = null;
|
|
||||||
|
|
||||||
if (provider == null) {
|
if (provider == null) {
|
||||||
// IResource element = parent.getProject();
|
IResource resource = (IResource) propertyObject;
|
||||||
IResource resource = (IResource) element;
|
|
||||||
provider = new ToolListContentProvider(resource.getType());
|
provider = new ToolListContentProvider(resource.getType());
|
||||||
optionList.setContentProvider(provider);
|
optionList.setContentProvider(provider);
|
||||||
}
|
}
|
||||||
if ( element instanceof IProject ) {
|
|
||||||
|
// Update the selected configuration and the Tree Viewer
|
||||||
|
IConfiguration config = null;
|
||||||
|
IResourceConfiguration resConfig = null;
|
||||||
|
ToolListElement[] newElements;
|
||||||
|
|
||||||
|
if ( propertyObject instanceof IProject ) {
|
||||||
config = parent.getSelectedConfigurationClone();
|
config = parent.getSelectedConfigurationClone();
|
||||||
optionList.setInput(config);
|
optionList.setInput(config);
|
||||||
} else if ( element instanceof IFile){
|
newElements = (ToolListElement[])provider.getElements(config);
|
||||||
|
} else if ( propertyObject instanceof IFile){
|
||||||
resConfig = resParent.getCurrentResourceConfigClone();
|
resConfig = resParent.getCurrentResourceConfigClone();
|
||||||
optionList.setInput(resConfig);
|
optionList.setInput(resConfig);
|
||||||
}
|
newElements = (ToolListElement[])provider.getElements(resConfig);
|
||||||
|
} else
|
||||||
|
return; // This should not happen
|
||||||
|
|
||||||
optionList.expandAll();
|
optionList.expandAll();
|
||||||
|
|
||||||
// Determine what the selection in the tree should be
|
// Determine what the selection in the tree should be
|
||||||
Object primary = null;
|
// If the saved selection is not null, try to match the saved selection
|
||||||
if (selectedTool != null) {
|
// with an object in the new element list.
|
||||||
// There is a selected tool defined. See if it matches any current tool (by name)
|
// Otherwise, select the first tool in the tree
|
||||||
ITool[] tools = null;
|
Object primaryObject = null;
|
||||||
if ( element instanceof IProject ) {
|
if (selectedElement != null) {
|
||||||
tools = config.getFilteredTools();
|
selectedElement = matchSelectionElement(selectedElement, newElements);
|
||||||
} else if ( element instanceof IFile){
|
|
||||||
tools = resConfig.getTools();
|
|
||||||
}
|
|
||||||
String matchName = selectedTool.getName();
|
|
||||||
for (int i=0; i<tools.length; i++) {
|
|
||||||
ITool tool = tools[i];
|
|
||||||
if (tool.getName().equals(matchName)) {
|
|
||||||
primary = tool;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (selectedCategory != null) {
|
|
||||||
// There is a selected option or category.
|
|
||||||
// See if it matches any category in the current config (by name)
|
|
||||||
ITool[] tools = null;
|
|
||||||
IToolChain toolChain = null;
|
|
||||||
|
|
||||||
if ( element instanceof IProject ) {
|
|
||||||
tools = config.getFilteredTools();
|
|
||||||
toolChain = config.getToolChain();
|
|
||||||
} else if ( element instanceof IFile){
|
|
||||||
tools = resConfig.getTools();
|
|
||||||
}
|
|
||||||
IBuildObject catOrTool = selectedCategory;
|
|
||||||
// Make the match name
|
|
||||||
String matchName = makeMatchName(catOrTool);
|
|
||||||
// Search for selected category/tool in toolChain
|
|
||||||
if ( toolChain != null ) {
|
|
||||||
primary = findOptionCategoryByMatchName(matchName, toolChain.getChildCategories());
|
|
||||||
}
|
|
||||||
// Search for selected category/tool in tools
|
|
||||||
if ( primary == null ) {
|
|
||||||
for (int i=0; i<tools.length && primary == null; i++) {
|
|
||||||
primary = findOptionCategoryByMatchName(matchName, tools[i].getChildCategories());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (primary == null) {
|
if (selectedElement == null) {
|
||||||
// Select the first tool in the list
|
selectedElement = (ToolListElement)(newElements.length > 0 ? newElements[0] : null);
|
||||||
Object[] elements = null;
|
|
||||||
if( element instanceof IProject){
|
|
||||||
elements = provider.getElements(parent.getSelectedConfigurationClone());
|
|
||||||
} else if ( element instanceof IFile) {
|
|
||||||
elements = provider.getElements(resParent.getCurrentResourceConfigClone());
|
|
||||||
}
|
|
||||||
primary = elements.length > 0 ? elements[0] : null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (primary != null) {
|
if (selectedElement != null) {
|
||||||
if(primary instanceof IOptionCategory){
|
primaryObject = selectedElement.getTool();
|
||||||
|
if (primaryObject == null) {
|
||||||
|
primaryObject = selectedElement.getOptionCategory();
|
||||||
|
}
|
||||||
|
if (primaryObject != null) {
|
||||||
|
if (primaryObject instanceof IOptionCategory) {
|
||||||
if(resConfig != null)
|
if(resConfig != null)
|
||||||
settingsStore.setSelection(resConfig,(IOptionCategory)primary);
|
settingsStore.setSelection(resConfig, selectedElement, (IOptionCategory)primaryObject);
|
||||||
else
|
else
|
||||||
settingsStore.setSelection(config,(IOptionCategory)primary);
|
settingsStore.setSelection(config, selectedElement, (IOptionCategory)primaryObject);
|
||||||
}
|
}
|
||||||
optionList.setSelection(new StructuredSelection(primary), true);
|
optionList.setSelection(new StructuredSelection(selectedElement), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private ToolListElement matchSelectionElement(ToolListElement currentElement, ToolListElement[] elements) {
|
||||||
|
// First, look for an exact match
|
||||||
|
ToolListElement match = exactMatchSelectionElement(currentElement, elements);
|
||||||
|
if (match == null)
|
||||||
|
// Else, look for the same tool/category in the new set of elements
|
||||||
|
match = equivalentMatchSelectionElement(currentElement, elements);
|
||||||
|
return match;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ToolListElement exactMatchSelectionElement(ToolListElement currentElement, ToolListElement[] elements) {
|
||||||
|
for (int i=0; i<elements.length; i++) {
|
||||||
|
ToolListElement e = elements[i];
|
||||||
|
if (e == currentElement) {
|
||||||
|
return currentElement;
|
||||||
|
}
|
||||||
|
e = exactMatchSelectionElement(currentElement, e.getChildElements());
|
||||||
|
if (e != null) return e;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ToolListElement equivalentMatchSelectionElement(ToolListElement currentElement, ToolListElement[] elements) {
|
||||||
|
for (int i=0; i<elements.length; i++) {
|
||||||
|
ToolListElement e = elements[i];
|
||||||
|
if (e.isEquivalentTo(currentElement)) {
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
e = equivalentMatchSelectionElement(currentElement, e.getChildElements());
|
||||||
|
if (e != null) return e;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public void removeValues(String id) {
|
public void removeValues(String id) {
|
||||||
}
|
}
|
||||||
|
@ -481,17 +488,24 @@ public class ToolsSettingsBlock extends AbstractCOptionPage {
|
||||||
IStructuredSelection selection = (IStructuredSelection) optionList.getSelection();
|
IStructuredSelection selection = (IStructuredSelection) optionList.getSelection();
|
||||||
|
|
||||||
// Set the option page based on the selection
|
// Set the option page based on the selection
|
||||||
Object element = selection.getFirstElement();
|
ToolListElement toolListElement = (ToolListElement)selection.getFirstElement();
|
||||||
if(element instanceof IOptionCategory){
|
if (toolListElement != null) {
|
||||||
|
IOptionCategory cat = toolListElement.getOptionCategory();
|
||||||
|
if (cat == null)
|
||||||
|
cat = (IOptionCategory)toolListElement.getTool();
|
||||||
|
if (cat != null) {
|
||||||
if(resParent != null)
|
if(resParent != null)
|
||||||
settingsStore.setSelection(resParent.getCurrentResourceConfigClone(),(IOptionCategory)element);
|
settingsStore.setSelection(resParent.getCurrentResourceConfigClone(), toolListElement, cat);
|
||||||
else
|
else
|
||||||
settingsStore.setSelection(parent.getSelectedConfigurationClone(),(IOptionCategory)element);
|
settingsStore.setSelection(parent.getSelectedConfigurationClone(), toolListElement, cat);
|
||||||
|
}
|
||||||
|
|
||||||
|
cat = toolListElement.getOptionCategory();
|
||||||
|
if (cat != null) {
|
||||||
|
displayOptionsForCategory(toolListElement);
|
||||||
|
} else {
|
||||||
|
displayOptionsForTool(toolListElement);
|
||||||
}
|
}
|
||||||
if (element instanceof ITool) {
|
|
||||||
displayOptionsForTool((ITool)element);
|
|
||||||
} else if (element instanceof IOptionCategory) {
|
|
||||||
displayOptionsForCategory((IOptionCategory)element);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -519,10 +533,10 @@ public class ToolsSettingsBlock extends AbstractCOptionPage {
|
||||||
* @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performDefaults()
|
* @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performDefaults()
|
||||||
*/
|
*/
|
||||||
public void performDefaults() {
|
public void performDefaults() {
|
||||||
if ( element instanceof IProject) {
|
if ( propertyObject instanceof IProject) {
|
||||||
performDefaults( (IProject)element);
|
performDefaults( (IProject)propertyObject);
|
||||||
} else if ( element instanceof IFile) {
|
} else if ( propertyObject instanceof IFile) {
|
||||||
performDefaults( (IFile)element);
|
performDefaults( (IFile)propertyObject);
|
||||||
}
|
}
|
||||||
defaultNeeded = true;
|
defaultNeeded = true;
|
||||||
return;
|
return;
|
||||||
|
@ -544,8 +558,7 @@ public class ToolsSettingsBlock extends AbstractCOptionPage {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset the category or tool selection and run selection event handler
|
// Reset the category or tool selection and run selection event handler
|
||||||
selectedCategory = null;
|
selectedElement = null;
|
||||||
selectedTool = null;
|
|
||||||
handleOptionSelection();
|
handleOptionSelection();
|
||||||
|
|
||||||
setDirty(true);
|
setDirty(true);
|
||||||
|
@ -566,8 +579,7 @@ public class ToolsSettingsBlock extends AbstractCOptionPage {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset the category or tool selection and run selection event handler
|
// Reset the category or tool selection and run selection event handler
|
||||||
selectedCategory = null;
|
selectedElement = null;
|
||||||
selectedTool = null;
|
|
||||||
handleOptionSelection();
|
handleOptionSelection();
|
||||||
|
|
||||||
setDirty(true);
|
setDirty(true);
|
||||||
|
@ -579,11 +591,11 @@ public class ToolsSettingsBlock extends AbstractCOptionPage {
|
||||||
*/
|
*/
|
||||||
public void performApply(IProgressMonitor monitor) throws CoreException {
|
public void performApply(IProgressMonitor monitor) throws CoreException {
|
||||||
|
|
||||||
if(element instanceof IFile)
|
if(propertyObject instanceof IFile)
|
||||||
resParent.getCurrentResourceConfig(true);
|
resParent.getCurrentResourceConfig(true);
|
||||||
|
|
||||||
if(defaultNeeded){
|
if(defaultNeeded){
|
||||||
if(element instanceof IFile)
|
if(propertyObject instanceof IFile)
|
||||||
ManagedBuildManager.resetResourceConfiguration(resParent.getProject(), resParent.getCurrentResourceConfig(true));
|
ManagedBuildManager.resetResourceConfiguration(resParent.getProject(), resParent.getCurrentResourceConfig(true));
|
||||||
else
|
else
|
||||||
ManagedBuildManager.resetConfiguration(parent.getProject(), parent.getSelectedConfiguration());
|
ManagedBuildManager.resetConfiguration(parent.getProject(), parent.getSelectedConfiguration());
|
||||||
|
@ -846,13 +858,13 @@ public class ToolsSettingsBlock extends AbstractCOptionPage {
|
||||||
*/
|
*/
|
||||||
private List getPagesForConfig() {
|
private List getPagesForConfig() {
|
||||||
List pages = null;
|
List pages = null;
|
||||||
if ( element instanceof IProject) {
|
if ( propertyObject instanceof IProject) {
|
||||||
// Make sure that something was selected
|
// Make sure that something was selected
|
||||||
if (parent.getSelectedConfigurationClone() == null) {
|
if (parent.getSelectedConfigurationClone() == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
pages = (List) configToPageListMap.get(parent.getSelectedConfigurationClone().getId());
|
pages = (List) configToPageListMap.get(parent.getSelectedConfigurationClone().getId());
|
||||||
} else if (element instanceof IFile) {
|
} else if (propertyObject instanceof IFile) {
|
||||||
if ( resParent.getCurrentResourceConfigClone() == null ) {
|
if ( resParent.getCurrentResourceConfigClone() == null ) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -861,9 +873,9 @@ public class ToolsSettingsBlock extends AbstractCOptionPage {
|
||||||
|
|
||||||
if (pages == null) {
|
if (pages == null) {
|
||||||
pages = new ArrayList();
|
pages = new ArrayList();
|
||||||
if ( element instanceof IProject) {
|
if ( propertyObject instanceof IProject) {
|
||||||
configToPageListMap.put(parent.getSelectedConfigurationClone().getId(), pages);
|
configToPageListMap.put(parent.getSelectedConfigurationClone().getId(), pages);
|
||||||
} else if ( element instanceof IFile) {
|
} else if ( propertyObject instanceof IFile) {
|
||||||
configToPageListMap.put(resParent.getCurrentResourceConfigClone().getId(), pages);
|
configToPageListMap.put(resParent.getCurrentResourceConfigClone().getId(), pages);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -938,59 +950,5 @@ public class ToolsSettingsBlock extends AbstractCOptionPage {
|
||||||
}
|
}
|
||||||
return (BuildMacroProvider)ManagedBuildManager.getBuildMacroProvider();
|
return (BuildMacroProvider)ManagedBuildManager.getBuildMacroProvider();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a name that uniquely identifies a category. The match name is
|
|
||||||
* a concatenation of the tool and categories, e.g. Tool->Cat1->Cat2
|
|
||||||
* maps onto the string "Tool|Cat1|Cat2|"
|
|
||||||
*
|
|
||||||
* @param category or tool for which to build the match name
|
|
||||||
* @return match name
|
|
||||||
*/
|
|
||||||
private String makeMatchName(IBuildObject catOrTool) {
|
|
||||||
String catName = EMPTY_STRING;
|
|
||||||
|
|
||||||
// Build the match name.
|
|
||||||
do {
|
|
||||||
catName = catOrTool.getName() + "|" + catName; //$NON-NLS-1$
|
|
||||||
if (catOrTool instanceof ITool) break;
|
|
||||||
else if (catOrTool instanceof IOptionCategory) {
|
|
||||||
catOrTool = ((IOptionCategory)catOrTool).getOwner();
|
|
||||||
} else
|
|
||||||
break;
|
|
||||||
} while (catOrTool != null);
|
|
||||||
|
|
||||||
return catName;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Finds an option category from an array of categories by comparing against
|
|
||||||
* a match name. The match name is a concatenation of the tool and categories,
|
|
||||||
* e.g. Tool->Cat1->Cat2 maps onto the string "Tool|Cat1|Cat2|"
|
|
||||||
*
|
|
||||||
* @param matchName an identifier to search
|
|
||||||
* @param categories as returned by getChildCategories(), i.e. non-flattened
|
|
||||||
* @return category or tool, if found and null otherwise
|
|
||||||
*/
|
|
||||||
private Object findOptionCategoryByMatchName(String matchName, IOptionCategory[] cats) {
|
|
||||||
Object primary = null;
|
|
||||||
|
|
||||||
for (int j=0; j<cats.length; j++) {
|
|
||||||
IBuildObject catOrTool = cats[j];
|
|
||||||
// Build the match name
|
|
||||||
String catName = makeMatchName(catOrTool);
|
|
||||||
// Check whether the name matches
|
|
||||||
if (catName.equals(matchName)) {
|
|
||||||
primary = cats[j];
|
|
||||||
break;
|
|
||||||
} else if (matchName.startsWith(catName)) {
|
|
||||||
// If there is a common root then check for any further children
|
|
||||||
primary = findOptionCategoryByMatchName(matchName, cats[j].getChildCategories());
|
|
||||||
if (primary != null)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return primary;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,24 +40,27 @@ import org.eclipse.swt.widgets.Composite;
|
||||||
public class BuildOptionSettingsPage extends BuildSettingsPage {
|
public class BuildOptionSettingsPage extends BuildSettingsPage {
|
||||||
private Map fieldsMap = new HashMap();
|
private Map fieldsMap = new HashMap();
|
||||||
private IOptionCategory clonedCategory;
|
private IOptionCategory clonedCategory;
|
||||||
|
private IHoldsOptions optionHolder;
|
||||||
private boolean isItResourceConfigPage;
|
private boolean isItResourceConfigPage;
|
||||||
private Map fieldEditorsToParentMap = new HashMap();
|
private Map fieldEditorsToParentMap = new HashMap();
|
||||||
private AbstractBuildPropertyPage buildPropPage;
|
private AbstractBuildPropertyPage buildPropPage;
|
||||||
|
|
||||||
public BuildOptionSettingsPage(AbstractBuildPropertyPage page,
|
public BuildOptionSettingsPage(AbstractBuildPropertyPage page,
|
||||||
IConfiguration clonedConfig, IOptionCategory clonedCategory) {
|
IConfiguration clonedConfig, IHoldsOptions optionHolder, IOptionCategory clonedCategory) {
|
||||||
// Cache the configuration and option category this page is created for
|
// Cache the configuration and option category this page is created for
|
||||||
super(clonedConfig);
|
super(clonedConfig);
|
||||||
this.clonedCategory = clonedCategory;
|
this.clonedCategory = clonedCategory;
|
||||||
|
this.optionHolder = optionHolder;
|
||||||
isItResourceConfigPage = false;
|
isItResourceConfigPage = false;
|
||||||
buildPropPage = page;
|
buildPropPage = page;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BuildOptionSettingsPage(AbstractBuildPropertyPage page,
|
public BuildOptionSettingsPage(AbstractBuildPropertyPage page,
|
||||||
IResourceConfiguration clonedResConfig, IOptionCategory clonedCategory) {
|
IResourceConfiguration clonedResConfig, IHoldsOptions optionHolder, IOptionCategory clonedCategory) {
|
||||||
// Cache the configuration and option category this page is created for
|
// Cache the configuration and option category this page is created for
|
||||||
super(clonedResConfig);
|
super(clonedResConfig);
|
||||||
this.clonedCategory = clonedCategory;
|
this.clonedCategory = clonedCategory;
|
||||||
|
this.optionHolder = optionHolder;
|
||||||
isItResourceConfigPage = true;
|
isItResourceConfigPage = true;
|
||||||
buildPropPage = page;
|
buildPropPage = page;
|
||||||
}
|
}
|
||||||
|
@ -78,9 +81,9 @@ public class BuildOptionSettingsPage extends BuildSettingsPage {
|
||||||
// for each
|
// for each
|
||||||
Object[][] options;
|
Object[][] options;
|
||||||
if ( isItResourceConfigPage ) {
|
if ( isItResourceConfigPage ) {
|
||||||
options = clonedCategory.getOptions(clonedResConfig);
|
options = clonedCategory.getOptions(clonedResConfig, optionHolder);
|
||||||
} else {
|
} else {
|
||||||
options = clonedCategory.getOptions(clonedConfig);
|
options = clonedCategory.getOptions(clonedConfig, optionHolder);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int index = 0; index < options.length; ++index) {
|
for (int index = 0; index < options.length; ++index) {
|
||||||
|
@ -204,9 +207,10 @@ public class BuildOptionSettingsPage extends BuildSettingsPage {
|
||||||
* @param category
|
* @param category
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean isForCategory(IOptionCategory category) {
|
public boolean isForCategory(IHoldsOptions optionHolder, IOptionCategory category) {
|
||||||
if (category != null) {
|
if (category != null) {
|
||||||
return category.equals(this.clonedCategory);
|
if (this.optionHolder == optionHolder && category.equals(this.clonedCategory))
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -229,13 +233,13 @@ public class BuildOptionSettingsPage extends BuildSettingsPage {
|
||||||
if(realRcCfg == null)
|
if(realRcCfg == null)
|
||||||
return false;
|
return false;
|
||||||
handler = realRcCfg;
|
handler = realRcCfg;
|
||||||
clonedOptions = clonedCategory.getOptions(clonedResConfig);
|
clonedOptions = clonedCategory.getOptions(clonedResConfig, optionHolder);
|
||||||
} else {
|
} else {
|
||||||
realCfg = buildPropPage.getRealConfig(clonedConfig);
|
realCfg = buildPropPage.getRealConfig(clonedConfig);
|
||||||
if(realCfg == null)
|
if(realCfg == null)
|
||||||
return false;
|
return false;
|
||||||
handler = realCfg;
|
handler = realCfg;
|
||||||
clonedOptions = clonedCategory.getOptions(clonedConfig);
|
clonedOptions = clonedCategory.getOptions(clonedConfig, optionHolder);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < clonedOptions.length; i++) {
|
for (int i = 0; i < clonedOptions.length; i++) {
|
||||||
|
@ -353,9 +357,9 @@ public class BuildOptionSettingsPage extends BuildSettingsPage {
|
||||||
public void updateFields() {
|
public void updateFields() {
|
||||||
Object[][] options;
|
Object[][] options;
|
||||||
if (isItResourceConfigPage) {
|
if (isItResourceConfigPage) {
|
||||||
options = clonedCategory.getOptions(clonedResConfig);
|
options = clonedCategory.getOptions(clonedResConfig, optionHolder);
|
||||||
} else {
|
} else {
|
||||||
options = clonedCategory.getOptions(clonedConfig);
|
options = clonedCategory.getOptions(clonedConfig, optionHolder);
|
||||||
}
|
}
|
||||||
|
|
||||||
// some option has changed on this page... update enabled/disabled state for all options
|
// some option has changed on this page... update enabled/disabled state for all options
|
||||||
|
@ -518,9 +522,9 @@ public class BuildOptionSettingsPage extends BuildSettingsPage {
|
||||||
|
|
||||||
Object[][] options;
|
Object[][] options;
|
||||||
if (isItResourceConfigPage) {
|
if (isItResourceConfigPage) {
|
||||||
options = clonedCategory.getOptions(clonedResConfig);
|
options = clonedCategory.getOptions(clonedResConfig, optionHolder);
|
||||||
} else {
|
} else {
|
||||||
options = clonedCategory.getOptions(clonedConfig);
|
options = clonedCategory.getOptions(clonedConfig, optionHolder);
|
||||||
}
|
}
|
||||||
|
|
||||||
// some option has changed on this page... update enabled/disabled state for all options
|
// some option has changed on this page... update enabled/disabled state for all options
|
||||||
|
|
|
@ -543,13 +543,13 @@ public class BuildToolSettingsPage extends BuildSettingsPage {
|
||||||
if(realRcCfg == null)
|
if(realRcCfg == null)
|
||||||
return false;
|
return false;
|
||||||
// handler = realRcCfg;
|
// handler = realRcCfg;
|
||||||
clonedOptions = clonedCategory.getOptions(clonedResConfig);
|
clonedOptions = clonedCategory.getOptions(clonedResConfig, clonedTool);
|
||||||
} else {
|
} else {
|
||||||
realCfg = buildPropPage.getRealConfig(clonedConfig);
|
realCfg = buildPropPage.getRealConfig(clonedConfig);
|
||||||
if(realCfg == null)
|
if(realCfg == null)
|
||||||
return false;
|
return false;
|
||||||
// handler = realCfg;
|
// handler = realCfg;
|
||||||
clonedOptions = clonedCategory.getOptions(clonedConfig);
|
clonedOptions = clonedCategory.getOptions(clonedConfig, clonedTool);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( clonedOptions == null)
|
if ( clonedOptions == null)
|
||||||
|
|
|
@ -43,6 +43,7 @@ public class BuildToolSettingsPreferenceStore implements IPreferenceStore {
|
||||||
private IConfiguration config;
|
private IConfiguration config;
|
||||||
private IResourceConfiguration rcConfig;
|
private IResourceConfiguration rcConfig;
|
||||||
private IOptionCategory optCategory;
|
private IOptionCategory optCategory;
|
||||||
|
private ToolListElement selectedElement;
|
||||||
private ListenerList listenerList;
|
private ListenerList listenerList;
|
||||||
private boolean dirtyFlag;
|
private boolean dirtyFlag;
|
||||||
|
|
||||||
|
@ -90,26 +91,20 @@ public class BuildToolSettingsPreferenceStore implements IPreferenceStore {
|
||||||
this.block = block;
|
this.block = block;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSelection(IConfiguration cfg, IOptionCategory category){
|
public void setSelection(IConfiguration cfg, ToolListElement element, IOptionCategory category){
|
||||||
|
selectedElement = element;
|
||||||
optCategory = category;
|
optCategory = category;
|
||||||
rcConfig = null;
|
rcConfig = null;
|
||||||
config = cfg;
|
config = cfg;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSelection(IResourceConfiguration cfg, IOptionCategory category){
|
public void setSelection(IResourceConfiguration cfg, ToolListElement element, IOptionCategory category){
|
||||||
|
selectedElement = element;
|
||||||
optCategory = category;
|
optCategory = category;
|
||||||
rcConfig = cfg;
|
rcConfig = cfg;
|
||||||
config = cfg.getParent();
|
config = cfg.getParent();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IOptionCategory getSelecedCategory(){
|
|
||||||
return optCategory;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IResourceConfiguration getSelectedRcConfig(){
|
|
||||||
return rcConfig;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IConfiguration getSelectedConfig(){
|
public IConfiguration getSelectedConfig(){
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
@ -264,10 +259,12 @@ public class BuildToolSettingsPreferenceStore implements IPreferenceStore {
|
||||||
public Object[] getOption(String name){
|
public Object[] getOption(String name){
|
||||||
Object options[][];
|
Object options[][];
|
||||||
|
|
||||||
|
IHoldsOptions selectedHolder = selectedElement.getHoldOptions();
|
||||||
|
if (selectedHolder == null) selectedHolder = selectedElement.getTool();
|
||||||
if(rcConfig != null)
|
if(rcConfig != null)
|
||||||
options = optCategory.getOptions(rcConfig);
|
options = optCategory.getOptions(rcConfig, selectedHolder);
|
||||||
else
|
else
|
||||||
options = optCategory.getOptions(config);
|
options = optCategory.getOptions(config, selectedHolder);
|
||||||
|
|
||||||
for(int i = 0; i < options.length; i++){
|
for(int i = 0; i < options.length; i++){
|
||||||
IHoldsOptions ho = (IHoldsOptions)options[i][0];
|
IHoldsOptions ho = (IHoldsOptions)options[i][0];
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2002, 2005 IBM Corporation and others.
|
* Copyright (c) 2002, 2006 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -11,21 +11,19 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.managedbuilder.ui.properties;
|
package org.eclipse.cdt.managedbuilder.ui.properties;
|
||||||
|
|
||||||
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
import org.eclipse.cdt.managedbuilder.core.*;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
|
|
||||||
import org.eclipse.cdt.managedbuilder.core.IOptionCategory;
|
|
||||||
import org.eclipse.cdt.managedbuilder.core.ITool;
|
|
||||||
import org.eclipse.cdt.managedbuilder.core.IToolChain;
|
|
||||||
import org.eclipse.jface.viewers.ITreeContentProvider;
|
import org.eclipse.jface.viewers.ITreeContentProvider;
|
||||||
import org.eclipse.jface.viewers.Viewer;
|
import org.eclipse.jface.viewers.Viewer;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class ToolListContentProvider implements ITreeContentProvider{
|
public class ToolListContentProvider implements ITreeContentProvider{
|
||||||
public static final int FILE = 0x1;
|
public static final int FILE = 0x1;
|
||||||
public static final int PROJECT = 0x4;
|
public static final int PROJECT = 0x4;
|
||||||
private static Object[] EMPTY_ARRAY = new Object[0];
|
|
||||||
private IConfiguration configRoot;
|
private IConfiguration configRoot;
|
||||||
private IResourceConfiguration resConfigRoot;
|
private IResourceConfiguration resConfigRoot;
|
||||||
private int elementType;
|
private int elementType;
|
||||||
|
private ToolListElement[] elements;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.jface.viewers.IContentProvider#dispose()
|
* @see org.eclipse.jface.viewers.IContentProvider#dispose()
|
||||||
|
@ -37,87 +35,86 @@ public class ToolListContentProvider implements ITreeContentProvider{
|
||||||
this.elementType = elementType;
|
this.elementType = elementType;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private ToolListElement[] createElements(IConfiguration config) {
|
||||||
* Gets the top level contents to be displayed in the tool list.
|
IOptionCategory toolChainCategories[];
|
||||||
* If defined, first display the toolChain's option categories (unfiltered).
|
ITool filteredTools[];
|
||||||
* Then display the the tools which are relevant for the project's nature.
|
List elementList = new ArrayList();
|
||||||
*/
|
if (config != null) {
|
||||||
private Object[] getToplevelContent(IConfiguration config) {
|
|
||||||
Object toolChainsCategories[];
|
|
||||||
Object filteredTools[];
|
|
||||||
Object all[];
|
|
||||||
// Get the the option categories of the toolChain
|
// Get the the option categories of the toolChain
|
||||||
IToolChain toolChain = config.getToolChain();
|
IToolChain toolChain = config.getToolChain();
|
||||||
toolChainsCategories = toolChain.getChildCategories();
|
toolChainCategories = toolChain.getChildCategories();
|
||||||
|
// Create an element for each one
|
||||||
|
for (int i=0; i<toolChainCategories.length; i++) {
|
||||||
|
ToolListElement e = new ToolListElement(null, toolChain, toolChainCategories[i]);
|
||||||
|
elementList.add(e);
|
||||||
|
createChildElements(e);
|
||||||
|
}
|
||||||
// Get the tools to be displayed
|
// Get the tools to be displayed
|
||||||
filteredTools = config.getFilteredTools();
|
filteredTools = config.getFilteredTools();
|
||||||
// Add up both arrays and return
|
// Create an element for each one
|
||||||
int i;
|
for (int i=0; i<filteredTools.length; i++) {
|
||||||
int len = toolChainsCategories.length+filteredTools.length;
|
ToolListElement e = new ToolListElement(filteredTools[i]);
|
||||||
all = new Object[len];
|
elementList.add(e);
|
||||||
for (i=0; i < toolChainsCategories.length; i++)
|
createChildElements(e);
|
||||||
all[i] = toolChainsCategories[i];
|
}
|
||||||
for (; i < len; i++)
|
}
|
||||||
all[i] = filteredTools[i-toolChainsCategories.length];
|
return (ToolListElement[])elementList.toArray(new ToolListElement[elementList.size()]);
|
||||||
|
}
|
||||||
|
|
||||||
return all;
|
private ToolListElement[] createElements(IResourceConfiguration resConfig) {
|
||||||
|
List elementList = new ArrayList();
|
||||||
|
if (resConfig != null) {
|
||||||
|
ITool[] tools = resConfig.getTools();
|
||||||
|
// Create an element for each one
|
||||||
|
for (int i=0; i<tools.length; i++) {
|
||||||
|
ToolListElement e = new ToolListElement(tools[i]);
|
||||||
|
elementList.add(e);
|
||||||
|
createChildElements(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (ToolListElement[])elementList.toArray(new ToolListElement[elementList.size()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createChildElements(ToolListElement parentElement) {
|
||||||
|
|
||||||
|
IOptionCategory parent = parentElement.getOptionCategory();
|
||||||
|
IHoldsOptions optHolder = parentElement.getHoldOptions();
|
||||||
|
if (parent == null) {
|
||||||
|
parent = parentElement.getTool().getTopOptionCategory(); // Must be an ITool
|
||||||
|
optHolder = parentElement.getTool();
|
||||||
|
}
|
||||||
|
IOptionCategory[] cats = parent.getChildCategories();
|
||||||
|
// Create an element for each one
|
||||||
|
for (int i=0; i<cats.length; i++) {
|
||||||
|
ToolListElement e = new ToolListElement(parentElement, optHolder, cats[i]);
|
||||||
|
parentElement.addChildElement(e);
|
||||||
|
createChildElements(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object)
|
* @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public Object[] getChildren(Object parentElement) {
|
public Object[] getChildren(Object parentElement) {
|
||||||
// If parent is configuration, return a list of its option categories
|
if (parentElement instanceof IConfiguration ||
|
||||||
if (parentElement instanceof IConfiguration) {
|
parentElement instanceof IResourceConfiguration ) {
|
||||||
IConfiguration config = (IConfiguration)parentElement;
|
return elements;
|
||||||
// Get the contents to be displayed for the configuration
|
|
||||||
return getToplevelContent(config);
|
|
||||||
} else if( parentElement instanceof IResourceConfiguration) {
|
|
||||||
// If parent is a resource configuration, return a list of its tools.
|
|
||||||
// Resource configurations do not support categories that are children
|
|
||||||
// of toolchains. The reason for this is that options in such categories
|
|
||||||
// are intended to be global.
|
|
||||||
// TODO: Remove this restriction in future? Requires getToplevelContent() variant
|
|
||||||
IResourceConfiguration resConfig = (IResourceConfiguration)parentElement;
|
|
||||||
return resConfig.getTools();
|
|
||||||
} else if (parentElement instanceof ITool) {
|
|
||||||
// If this is a tool, return the categories it contains
|
|
||||||
ITool tool = (ITool)parentElement;
|
|
||||||
return tool.getTopOptionCategory().getChildCategories();
|
|
||||||
} else if (parentElement instanceof IOptionCategory) {
|
|
||||||
// Categories can have child categories
|
|
||||||
IOptionCategory cat = (IOptionCategory)parentElement;
|
|
||||||
return cat.getChildCategories();
|
|
||||||
} else {
|
|
||||||
return EMPTY_ARRAY;
|
|
||||||
}
|
}
|
||||||
|
return ((ToolListElement)parentElement).getChildElements();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
|
* @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public Object[] getElements(Object inputElement) {
|
public Object[] getElements(Object inputElement) {
|
||||||
return getChildren(inputElement);
|
return elements;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object)
|
* @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public Object getParent(Object element) {
|
public Object getParent(Object element) {
|
||||||
if (element instanceof IOptionCategory) {
|
return ((ToolListElement)element).getParent();
|
||||||
// Find the parent category
|
|
||||||
IOptionCategory cat = (IOptionCategory)element;
|
|
||||||
IOptionCategory parent = cat.getOwner();
|
|
||||||
// Then we need to get the configuration we belong to
|
|
||||||
if (parent == null) {
|
|
||||||
if(elementType == FILE)
|
|
||||||
return resConfigRoot;
|
|
||||||
else
|
|
||||||
return configRoot;
|
|
||||||
}
|
|
||||||
return parent;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -131,13 +128,22 @@ public class ToolListContentProvider implements ITreeContentProvider{
|
||||||
* @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
|
* @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
|
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
|
||||||
|
// If the input hasn't changed, there is no reason to re-create the content
|
||||||
|
if (oldInput == newInput) return;
|
||||||
|
|
||||||
if(elementType == FILE) {
|
if(elementType == FILE) {
|
||||||
resConfigRoot = (IResourceConfiguration)newInput;
|
resConfigRoot = (IResourceConfiguration)newInput;
|
||||||
configRoot = null;
|
configRoot = null;
|
||||||
|
// Create a ToolListElement to represent each item that will appear
|
||||||
|
// in the TreeViewer.
|
||||||
|
elements = createElements(resConfigRoot);
|
||||||
}
|
}
|
||||||
else if(elementType == PROJECT) {
|
else if(elementType == PROJECT) {
|
||||||
configRoot = (IConfiguration) newInput;
|
configRoot = (IConfiguration) newInput;
|
||||||
resConfigRoot = null;
|
resConfigRoot = null;
|
||||||
|
// Create a ToolListElement to represent each item that will appear
|
||||||
|
// in the TreeViewer.
|
||||||
|
elements = createElements(configRoot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,120 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2006 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.ui.properties;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.managedbuilder.core.*;
|
||||||
|
import org.eclipse.cdt.managedbuilder.internal.core.OptionCategory;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* This class represent the elements in the TreeViewer that displays the tools
|
||||||
|
* and categories in the tool options property pages. The reason for these
|
||||||
|
* elements is illustrated by bugzilla #123461. We used to use the ToolChain,
|
||||||
|
* Tool and OptionCategory objects themselves as the elements in the TreeViewer,
|
||||||
|
* but the same OptionCategory can appear more than once in the list of Tree
|
||||||
|
* Viewer items, and this caused problems.
|
||||||
|
*******************************************************************************/
|
||||||
|
public class ToolListElement {
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Bookeeping variables
|
||||||
|
*/
|
||||||
|
private ToolListElement parent = null;
|
||||||
|
private List childElements = null;
|
||||||
|
|
||||||
|
private IHoldsOptions optionHolder = null;
|
||||||
|
private IOptionCategory optionCategory = null;
|
||||||
|
private ITool tool = null;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Constructor for an element tha represents an option category
|
||||||
|
*/
|
||||||
|
public ToolListElement(ToolListElement parent, IHoldsOptions optionHolder, IOptionCategory optionCategory) {
|
||||||
|
this.parent = parent;
|
||||||
|
this.optionHolder = optionHolder;
|
||||||
|
this.optionCategory = optionCategory;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Constructor for an element tha represents a tool
|
||||||
|
*/
|
||||||
|
public ToolListElement(ITool tool) {
|
||||||
|
this.tool = tool;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isEquivalentTo(ToolListElement e) {
|
||||||
|
|
||||||
|
if (tool != null) {
|
||||||
|
// Look for a matching tool
|
||||||
|
ITool matchTool = e.getTool();
|
||||||
|
if (matchTool == tool) return true;
|
||||||
|
if (matchTool == null) return false;
|
||||||
|
if (matchTool.getName().equals(tool.getName())) return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (optionCategory != null) {
|
||||||
|
IOptionCategory matchCategory = e.getOptionCategory();
|
||||||
|
IHoldsOptions matchHolder = e.getHoldOptions();
|
||||||
|
if (matchCategory == optionCategory &&
|
||||||
|
matchHolder == optionHolder) return true;
|
||||||
|
if (matchCategory == null) return false;
|
||||||
|
|
||||||
|
//String matchCategoryName = matchCategory.getName();
|
||||||
|
//String optionCategoryName = optionCategory.getName();
|
||||||
|
String matchCategoryName = OptionCategory.makeMatchName(matchCategory);
|
||||||
|
String optionCategoryName = OptionCategory.makeMatchName(optionCategory);
|
||||||
|
if (matchHolder.getName().equals(optionHolder.getName()) &&
|
||||||
|
matchCategoryName.equals(optionCategoryName)) return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Field accessors
|
||||||
|
*/
|
||||||
|
public ToolListElement getParent() {
|
||||||
|
return parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IHoldsOptions getHoldOptions() {
|
||||||
|
return optionHolder;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IOptionCategory getOptionCategory() {
|
||||||
|
return optionCategory;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ITool getTool() {
|
||||||
|
return tool;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Children handling
|
||||||
|
*/
|
||||||
|
public ToolListElement[] getChildElements() {
|
||||||
|
if (childElements != null)
|
||||||
|
return (ToolListElement[])childElements.toArray(new ToolListElement[childElements.size()]);
|
||||||
|
else
|
||||||
|
return new ToolListElement[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addChildElement(ToolListElement element) {
|
||||||
|
if (childElements == null)
|
||||||
|
childElements = new ArrayList();
|
||||||
|
childElements.add(element);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2002, 2005 IBM Corporation and others.
|
* Copyright (c) 2002, 2006 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -13,6 +13,7 @@ package org.eclipse.cdt.managedbuilder.ui.properties;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
|
||||||
import org.eclipse.cdt.managedbuilder.core.IOptionCategory;
|
import org.eclipse.cdt.managedbuilder.core.IOptionCategory;
|
||||||
|
import org.eclipse.cdt.managedbuilder.core.IHoldsOptions;
|
||||||
import org.eclipse.cdt.managedbuilder.core.ITool;
|
import org.eclipse.cdt.managedbuilder.core.ITool;
|
||||||
import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIImages;
|
import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIImages;
|
||||||
import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIMessages;
|
import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIMessages;
|
||||||
|
@ -56,50 +57,46 @@ public class ToolListLabelProvider extends LabelProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Image getImage(Object element) {
|
public Image getImage(Object element) {
|
||||||
// Return a tool image for a tool or tool reference
|
if (!(element instanceof ToolListElement)) {
|
||||||
if (element instanceof ITool) {
|
|
||||||
if (element instanceof IOptionCategory) {
|
|
||||||
// Retrieve the Image from Icon information included
|
|
||||||
IOptionCategory cat = (IOptionCategory)element;
|
|
||||||
Image img = getIconFromOptionCategory(cat);
|
|
||||||
|
|
||||||
if (img != null) {
|
|
||||||
return img;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Use default icon for display
|
|
||||||
return IMG_TOOL;
|
|
||||||
|
|
||||||
} else if (element instanceof IOptionCategory) {
|
|
||||||
// Return a OptionCategory image for an OptionCategory reference
|
|
||||||
IOptionCategory cat = (IOptionCategory)element;
|
|
||||||
Image img = getIconFromOptionCategory(cat);
|
|
||||||
|
|
||||||
if (img != null) {
|
|
||||||
return img;
|
|
||||||
}
|
|
||||||
// Use default icon for display
|
|
||||||
return IMG_CAT;
|
|
||||||
} else {
|
|
||||||
throw unknownElement(element);
|
throw unknownElement(element);
|
||||||
}
|
}
|
||||||
|
Image defaultImage = IMG_CAT;
|
||||||
|
ToolListElement toolListElement = (ToolListElement)element;
|
||||||
|
IOptionCategory cat = toolListElement.getOptionCategory();
|
||||||
|
|
||||||
|
if (cat == null) {
|
||||||
|
defaultImage = IMG_TOOL;
|
||||||
|
cat = (IOptionCategory)toolListElement.getTool();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cat != null) {
|
||||||
|
// Return a OptionCategory image for an OptionCategory reference
|
||||||
|
Image img = getIconFromOptionCategory(cat);
|
||||||
|
|
||||||
|
if (img != null) {
|
||||||
|
return img;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Use default icon for display
|
||||||
|
return defaultImage;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.jface.viewers.ILabelProvider#getText(Object)
|
* @see org.eclipse.jface.viewers.ILabelProvider#getText(Object)
|
||||||
*/
|
*/
|
||||||
public String getText(Object element) {
|
public String getText(Object element) {
|
||||||
if (element instanceof ITool) {
|
if (!(element instanceof ToolListElement)) {
|
||||||
// Handles tool references as well
|
throw unknownElement(element);
|
||||||
ITool tool = (ITool)element;
|
}
|
||||||
|
ToolListElement toolListElement = (ToolListElement)element;
|
||||||
|
IOptionCategory cat = toolListElement.getOptionCategory();
|
||||||
|
|
||||||
|
if (cat == null) {
|
||||||
|
ITool tool = toolListElement.getTool();
|
||||||
return tool.getName();
|
return tool.getName();
|
||||||
}
|
}
|
||||||
else if (element instanceof IOptionCategory) {
|
|
||||||
IOptionCategory cat = (IOptionCategory)element;
|
|
||||||
return cat.getName();
|
|
||||||
}
|
|
||||||
else {
|
else {
|
||||||
throw unknownElement(element);
|
return cat.getName();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue