diff options
author | Sean Evoy | 2004-03-25 19:00:18 +0000 |
---|---|---|
committer | Sean Evoy | 2004-03-25 19:00:18 +0000 |
commit | 8e163f4d5ef3f3c09efd79a7cf1580be994a3408 (patch) | |
tree | ecd36c8564e9b07ccd2eab08cee694a4c837a3ca /build | |
parent | f2dba87e93f7c72fe0413f0bb1f6f490a4b4e8da (diff) | |
download | org.eclipse.cdt-8e163f4d5ef3f3c09efd79a7cf1580be994a3408.tar.gz org.eclipse.cdt-8e163f4d5ef3f3c09efd79a7cf1580be994a3408.tar.xz org.eclipse.cdt-8e163f4d5ef3f3c09efd79a7cf1580be994a3408.zip |
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.
Diffstat (limited to 'build')
3 files changed, 54 insertions, 37 deletions
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildPropertyPage.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildPropertyPage.java index 6113a9a79b6..a33d916b157 100644 --- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildPropertyPage.java +++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildPropertyPage.java @@ -113,6 +113,7 @@ public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropert private BuildSettingsPage currentSettingsPage; private Map configToPageListMap; private BuildToolsSettingsStore settingsStore; + private Map settingsStoreMap; private IOptionCategory selectedCategory; private Point lastShellSize; private ITool selectedTool; @@ -123,6 +124,7 @@ public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropert * @see #setMinimumPageSize */ private Point minimumPageSize = new Point(200, 200); + private ToolListContentProvider provider; /** * Layout for the page container. @@ -395,6 +397,8 @@ public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropert if (children[i] != currentControl) children[i].setVisible(false); } + + // Make the current page visible currentSettingsPage.setVisible(true); // save the last page build options. @@ -484,6 +488,17 @@ public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropert 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 */ @@ -493,7 +508,9 @@ public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropert // Check if the user has selected the "all" configuration 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 return; } else { @@ -501,23 +518,29 @@ public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropert selectedConfiguration = configurations[selectionIndex]; } - // Set the content provider for the list viewer - ToolListContentProvider provider = new ToolListContentProvider(); - optionList.setContentProvider(provider); + if (provider == null) { + provider = new ToolListContentProvider(); + optionList.setContentProvider(provider); + } optionList.setInput(selectedConfiguration); optionList.expandAll(); - // Recreate the settings store for the configuration - settingsStore = new BuildToolsSettingsStore(selectedConfiguration); + // Create (or retrieve) the settings store for the configuration + 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 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. ITool tool = (ITool)primary; - /* IOptionCategory top = tool.getTopOptionCategory(); + IOptionCategory top = tool.getTopOptionCategory(); IOption[] topOpts = top.getOptions(selectedConfiguration); if (topOpts != null && topOpts.length == 0) { // Get the children categories and start looking @@ -530,9 +553,9 @@ public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropert break; } } - }*/ + } } - +*/ if (primary != null) { optionList.setSelection(new StructuredSelection(primary)); } @@ -576,6 +599,9 @@ public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropert // Remove the configurations from the target selectedTarget.removeConfiguration(id); + // Remove any settings stores + getSettingsStoreMap().remove(id); + // Clean up the UI configurations = selectedTarget.getConfigurations(); configSelector.removeAll(); diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ToolListContentProvider.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ToolListContentProvider.java index afa509078d3..88acea5bb02 100644 --- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ToolListContentProvider.java +++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ToolListContentProvider.java @@ -35,27 +35,16 @@ public class ToolListContentProvider implements ITreeContentProvider{ // If parent is configuration, return a list of its option categories if (parentElement instanceof IConfiguration) { IConfiguration config = (IConfiguration)parentElement; - ITool [] tools = config.getTools(); - IOptionCategory [] categories = new IOptionCategory[tools.length]; - // The categories are accessed through the tool - for (int index = 0; index < tools.length; ++index) { - categories[index] = tools[index].getTopOptionCategory(); - } - return categories; + // the categories are all accessed through the tools + return config.getTools(); } else if (parentElement instanceof ITool) { // If this is a tool, return the categories it contains ITool tool = (ITool)parentElement; - IOptionCategory[] children = tool.getTopOptionCategory().getChildCategories(); - return (children == null) ? EMPTY_ARRAY : children; + return tool.getTopOptionCategory().getChildCategories(); } else if (parentElement instanceof IOptionCategory) { // Categories can have child categories IOptionCategory cat = (IOptionCategory)parentElement; - IOptionCategory [] children = cat.getChildCategories(); - if (children == null) { - return EMPTY_ARRAY; - } else { - return children; - } + return cat.getChildCategories(); } else { return EMPTY_ARRAY; } @@ -78,7 +67,6 @@ public class ToolListContentProvider implements ITreeContentProvider{ IOptionCategory parent = cat.getOwner(); // Then we need to get the configuration we belong to if (parent == null) { - ITool tool = cat.getTool(); return root; } return parent; diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ToolListLabelProvider.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ToolListLabelProvider.java index 7933b481fca..8ea8a2723f1 100644 --- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ToolListLabelProvider.java +++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ToolListLabelProvider.java @@ -12,6 +12,7 @@ package org.eclipse.cdt.managedbuilder.ui.properties; * **********************************************************************/ 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.ManagedBuilderUIPlugin; 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$ public Image getImage(Object element) { - // If the element is a configuration, return the folder image - if (element instanceof IOptionCategory) { - IOptionCategory cat = (IOptionCategory)element; - IOptionCategory [] children = cat.getChildCategories(); - if (children.length > 0){ - return IMG_TOOL; - } else { - return IMG_CAT; - } + // Return a tool image for a tool or tool reference + if (element instanceof ITool) { + return IMG_TOOL; + } + else if (element instanceof IOptionCategory) { + return IMG_CAT; } else { throw unknownElement(element); } @@ -43,7 +41,12 @@ class ToolListLabelProvider extends LabelProvider { * @see org.eclipse.jface.viewers.ILabelProvider#getText(Object) */ 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; return cat.getName(); } |