1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-24 09:25:31 +02:00

bug 289813: [New project Wizard] Project type changes on toggling of supported platform settings

This commit is contained in:
Andrew Gvozdev 2009-09-18 14:47:45 +00:00
parent 521ce406d8
commit 4ffa61aca1

View file

@ -262,8 +262,10 @@ import org.eclipse.cdt.internal.ui.CPluginImages;
*/
public static CWizardHandler updateData(Tree tree, Composite right, Button show_sup, IWizardItemsListListener ls, IWizard wizard) {
// remember selected item
TreeItem[] sel = tree.getSelection();
String savedStr = (sel.length > 0) ? sel[0].getText() : null;
TreeItem[] selection = tree.getSelection();
TreeItem selectedItem = selection.length>0 ? selection[0] : null;
String savedLabel = selectedItem!=null ? selectedItem.getText() : null;
String savedParentLabel = getParentText(selectedItem);
tree.removeAll();
IExtensionPoint extensionPoint =
@ -312,17 +314,10 @@ import org.eclipse.cdt.internal.ui.CPluginImages;
if (tree.getItemCount() > 0) {
TreeItem target = null;
// try to search item which was selected before
if (savedStr != null) {
TreeItem[] all = tree.getItems();
for (TreeItem element : all) {
if (savedStr.equals(element.getText())) {
target = element;
break;
}
}
if (savedLabel!=null) {
target = findItem(tree, savedLabel, savedParentLabel);
}
if (target == null)
{
if (target == null) {
target = tree.getItem(0);
if (target.getItemCount() != 0)
target = target.getItem(0);
@ -333,6 +328,33 @@ import org.eclipse.cdt.internal.ui.CPluginImages;
return null;
}
private static String getParentText(TreeItem item) {
if (item==null || item.getParentItem()==null)
return ""; //$NON-NLS-1$
return item.getParentItem().getText();
}
private static TreeItem findItem(Tree tree, String label, String parentLabel) {
for (TreeItem item : tree.getItems()) {
TreeItem foundItem = findTreeItem(item, label, parentLabel);
if (foundItem!=null)
return foundItem;
}
return null;
}
private static TreeItem findTreeItem(TreeItem item, String label, String parentLabel) {
if (item.getText().equals(label) && getParentText(item).equals(parentLabel))
return item;
for (TreeItem child : item.getItems()) {
TreeItem foundItem = findTreeItem(child, label, parentLabel);
if (foundItem!=null)
return foundItem;
}
return null;
}
private static void addItemsToTree(Tree tree, List<EntryDescriptor> items) {
// Sorting is disabled because of users requests
// Collections.sort(items, CDTListComparator.getInstance());