mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-09-10 03:53:21 +02:00
The tool page was not refreshing on configuration change events. The problem was that the list control was returning the tool instead of the reference, and since all the references point to the same tool, the property page thought nothing had changed and did not repaint the selection. Switched around the logic of the list content and label provider to work better under this case.
This commit is contained in:
parent
f2dba87e93
commit
8e163f4d5e
3 changed files with 54 additions and 37 deletions
|
@ -113,6 +113,7 @@ public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropert
|
||||||
private BuildSettingsPage currentSettingsPage;
|
private BuildSettingsPage currentSettingsPage;
|
||||||
private Map configToPageListMap;
|
private Map configToPageListMap;
|
||||||
private BuildToolsSettingsStore settingsStore;
|
private BuildToolsSettingsStore settingsStore;
|
||||||
|
private Map settingsStoreMap;
|
||||||
private IOptionCategory selectedCategory;
|
private IOptionCategory selectedCategory;
|
||||||
private Point lastShellSize;
|
private Point lastShellSize;
|
||||||
private ITool selectedTool;
|
private ITool selectedTool;
|
||||||
|
@ -123,6 +124,7 @@ public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropert
|
||||||
* @see #setMinimumPageSize
|
* @see #setMinimumPageSize
|
||||||
*/
|
*/
|
||||||
private Point minimumPageSize = new Point(200, 200);
|
private Point minimumPageSize = new Point(200, 200);
|
||||||
|
private ToolListContentProvider provider;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Layout for the page container.
|
* Layout for the page container.
|
||||||
|
@ -395,6 +397,8 @@ public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropert
|
||||||
if (children[i] != currentControl)
|
if (children[i] != currentControl)
|
||||||
children[i].setVisible(false);
|
children[i].setVisible(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Make the current page visible
|
||||||
currentSettingsPage.setVisible(true);
|
currentSettingsPage.setVisible(true);
|
||||||
|
|
||||||
// save the last page build options.
|
// save the last page build options.
|
||||||
|
@ -484,6 +488,17 @@ public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropert
|
||||||
return selectedConfiguration;
|
return selectedConfiguration;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* Safe accessor method
|
||||||
|
*
|
||||||
|
* @return Returns the Map of configurations to preference stores.
|
||||||
|
*/
|
||||||
|
protected Map getSettingsStoreMap() {
|
||||||
|
if (settingsStoreMap == null) {
|
||||||
|
settingsStoreMap = new HashMap();
|
||||||
|
}
|
||||||
|
return settingsStoreMap;
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
* Event Handlers
|
* Event Handlers
|
||||||
*/
|
*/
|
||||||
|
@ -493,7 +508,9 @@ public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropert
|
||||||
|
|
||||||
// Check if the user has selected the "all" configuration
|
// Check if the user has selected the "all" configuration
|
||||||
int selectionIndex = configSelector.getSelectionIndex();
|
int selectionIndex = configSelector.getSelectionIndex();
|
||||||
if (selectionIndex >= configurations.length) {
|
if (selectionIndex == -1) return;
|
||||||
|
String configName = configSelector.getItem(selectionIndex);
|
||||||
|
if (configName.equals(ManagedBuilderUIPlugin.getResourceString(ALL_CONFS))) {
|
||||||
// This is the all config
|
// This is the all config
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
|
@ -501,23 +518,29 @@ public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropert
|
||||||
selectedConfiguration = configurations[selectionIndex];
|
selectedConfiguration = configurations[selectionIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the content provider for the list viewer
|
if (provider == null) {
|
||||||
ToolListContentProvider provider = new ToolListContentProvider();
|
provider = new ToolListContentProvider();
|
||||||
optionList.setContentProvider(provider);
|
optionList.setContentProvider(provider);
|
||||||
|
}
|
||||||
optionList.setInput(selectedConfiguration);
|
optionList.setInput(selectedConfiguration);
|
||||||
optionList.expandAll();
|
optionList.expandAll();
|
||||||
|
|
||||||
// Recreate the settings store for the configuration
|
// Create (or retrieve) the settings store for the configuration
|
||||||
settingsStore = new BuildToolsSettingsStore(selectedConfiguration);
|
BuildToolsSettingsStore store = (BuildToolsSettingsStore) getSettingsStoreMap().get(selectedConfiguration.getId());
|
||||||
|
if (store == null) {
|
||||||
|
store = new BuildToolsSettingsStore(selectedConfiguration);
|
||||||
|
getSettingsStoreMap().put(selectedConfiguration.getId(), store);
|
||||||
|
}
|
||||||
|
settingsStore = store;
|
||||||
|
|
||||||
// Select the first tool or option category in the list that has options
|
// Select the first tool in the list
|
||||||
Object[] elements = provider.getElements(selectedConfiguration);
|
Object[] elements = provider.getElements(selectedConfiguration);
|
||||||
Object primary = elements.length > 0 ? elements[0] : null;
|
Object primary = elements.length > 0 ? elements[0] : null;
|
||||||
|
|
||||||
if (primary != null && primary instanceof ITool) {
|
/* if (primary != null && primary instanceof ITool) {
|
||||||
// set the tool as primary selection in the tree hence it displays all the build options.
|
// set the tool as primary selection in the tree hence it displays all the build options.
|
||||||
ITool tool = (ITool)primary;
|
ITool tool = (ITool)primary;
|
||||||
/* IOptionCategory top = tool.getTopOptionCategory();
|
IOptionCategory top = tool.getTopOptionCategory();
|
||||||
IOption[] topOpts = top.getOptions(selectedConfiguration);
|
IOption[] topOpts = top.getOptions(selectedConfiguration);
|
||||||
if (topOpts != null && topOpts.length == 0) {
|
if (topOpts != null && topOpts.length == 0) {
|
||||||
// Get the children categories and start looking
|
// Get the children categories and start looking
|
||||||
|
@ -530,9 +553,9 @@ public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropert
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}*/
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
if (primary != null) {
|
if (primary != null) {
|
||||||
optionList.setSelection(new StructuredSelection(primary));
|
optionList.setSelection(new StructuredSelection(primary));
|
||||||
}
|
}
|
||||||
|
@ -576,6 +599,9 @@ public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropert
|
||||||
// Remove the configurations from the target
|
// Remove the configurations from the target
|
||||||
selectedTarget.removeConfiguration(id);
|
selectedTarget.removeConfiguration(id);
|
||||||
|
|
||||||
|
// Remove any settings stores
|
||||||
|
getSettingsStoreMap().remove(id);
|
||||||
|
|
||||||
// Clean up the UI
|
// Clean up the UI
|
||||||
configurations = selectedTarget.getConfigurations();
|
configurations = selectedTarget.getConfigurations();
|
||||||
configSelector.removeAll();
|
configSelector.removeAll();
|
||||||
|
|
|
@ -35,27 +35,16 @@ public class ToolListContentProvider implements ITreeContentProvider{
|
||||||
// If parent is configuration, return a list of its option categories
|
// If parent is configuration, return a list of its option categories
|
||||||
if (parentElement instanceof IConfiguration) {
|
if (parentElement instanceof IConfiguration) {
|
||||||
IConfiguration config = (IConfiguration)parentElement;
|
IConfiguration config = (IConfiguration)parentElement;
|
||||||
ITool [] tools = config.getTools();
|
// the categories are all accessed through the tools
|
||||||
IOptionCategory [] categories = new IOptionCategory[tools.length];
|
return config.getTools();
|
||||||
// The categories are accessed through the tool
|
|
||||||
for (int index = 0; index < tools.length; ++index) {
|
|
||||||
categories[index] = tools[index].getTopOptionCategory();
|
|
||||||
}
|
|
||||||
return categories;
|
|
||||||
} else if (parentElement instanceof ITool) {
|
} else if (parentElement instanceof ITool) {
|
||||||
// If this is a tool, return the categories it contains
|
// If this is a tool, return the categories it contains
|
||||||
ITool tool = (ITool)parentElement;
|
ITool tool = (ITool)parentElement;
|
||||||
IOptionCategory[] children = tool.getTopOptionCategory().getChildCategories();
|
return tool.getTopOptionCategory().getChildCategories();
|
||||||
return (children == null) ? EMPTY_ARRAY : children;
|
|
||||||
} else if (parentElement instanceof IOptionCategory) {
|
} else if (parentElement instanceof IOptionCategory) {
|
||||||
// Categories can have child categories
|
// Categories can have child categories
|
||||||
IOptionCategory cat = (IOptionCategory)parentElement;
|
IOptionCategory cat = (IOptionCategory)parentElement;
|
||||||
IOptionCategory [] children = cat.getChildCategories();
|
return cat.getChildCategories();
|
||||||
if (children == null) {
|
|
||||||
return EMPTY_ARRAY;
|
|
||||||
} else {
|
|
||||||
return children;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
return EMPTY_ARRAY;
|
return EMPTY_ARRAY;
|
||||||
}
|
}
|
||||||
|
@ -78,7 +67,6 @@ public class ToolListContentProvider implements ITreeContentProvider{
|
||||||
IOptionCategory parent = cat.getOwner();
|
IOptionCategory parent = cat.getOwner();
|
||||||
// Then we need to get the configuration we belong to
|
// Then we need to get the configuration we belong to
|
||||||
if (parent == null) {
|
if (parent == null) {
|
||||||
ITool tool = cat.getTool();
|
|
||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
return parent;
|
return parent;
|
||||||
|
|
|
@ -12,6 +12,7 @@ package org.eclipse.cdt.managedbuilder.ui.properties;
|
||||||
* **********************************************************************/
|
* **********************************************************************/
|
||||||
|
|
||||||
import org.eclipse.cdt.managedbuilder.core.IOptionCategory;
|
import org.eclipse.cdt.managedbuilder.core.IOptionCategory;
|
||||||
|
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.ManagedBuilderUIPlugin;
|
import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIPlugin;
|
||||||
import org.eclipse.jface.viewers.LabelProvider;
|
import org.eclipse.jface.viewers.LabelProvider;
|
||||||
|
@ -24,15 +25,12 @@ class ToolListLabelProvider extends LabelProvider {
|
||||||
private static final String ERROR_UNKNOWN_ELEMENT = "BuildPropertyPage.error.Unknown_tree_element"; //$NON-NLS-1$
|
private static final String ERROR_UNKNOWN_ELEMENT = "BuildPropertyPage.error.Unknown_tree_element"; //$NON-NLS-1$
|
||||||
|
|
||||||
public Image getImage(Object element) {
|
public Image getImage(Object element) {
|
||||||
// If the element is a configuration, return the folder image
|
// Return a tool image for a tool or tool reference
|
||||||
if (element instanceof IOptionCategory) {
|
if (element instanceof ITool) {
|
||||||
IOptionCategory cat = (IOptionCategory)element;
|
return IMG_TOOL;
|
||||||
IOptionCategory [] children = cat.getChildCategories();
|
}
|
||||||
if (children.length > 0){
|
else if (element instanceof IOptionCategory) {
|
||||||
return IMG_TOOL;
|
return IMG_CAT;
|
||||||
} else {
|
|
||||||
return IMG_CAT;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
throw unknownElement(element);
|
throw unknownElement(element);
|
||||||
}
|
}
|
||||||
|
@ -43,7 +41,12 @@ class ToolListLabelProvider extends LabelProvider {
|
||||||
* @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 IOptionCategory) {
|
if (element instanceof ITool) {
|
||||||
|
// Handles tool references as well
|
||||||
|
ITool tool = (ITool)element;
|
||||||
|
return tool.getName();
|
||||||
|
}
|
||||||
|
else if (element instanceof IOptionCategory) {
|
||||||
IOptionCategory cat = (IOptionCategory)element;
|
IOptionCategory cat = (IOptionCategory)element;
|
||||||
return cat.getName();
|
return cat.getName();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue