1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-10 09:45:39 +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) { public static CWizardHandler updateData(Tree tree, Composite right, Button show_sup, IWizardItemsListListener ls, IWizard wizard) {
// remember selected item // remember selected item
TreeItem[] sel = tree.getSelection(); TreeItem[] selection = tree.getSelection();
String savedStr = (sel.length > 0) ? sel[0].getText() : null; TreeItem selectedItem = selection.length>0 ? selection[0] : null;
String savedLabel = selectedItem!=null ? selectedItem.getText() : null;
String savedParentLabel = getParentText(selectedItem);
tree.removeAll(); tree.removeAll();
IExtensionPoint extensionPoint = IExtensionPoint extensionPoint =
@ -312,17 +314,10 @@ import org.eclipse.cdt.internal.ui.CPluginImages;
if (tree.getItemCount() > 0) { if (tree.getItemCount() > 0) {
TreeItem target = null; TreeItem target = null;
// try to search item which was selected before // try to search item which was selected before
if (savedStr != null) { if (savedLabel!=null) {
TreeItem[] all = tree.getItems(); target = findItem(tree, savedLabel, savedParentLabel);
for (TreeItem element : all) {
if (savedStr.equals(element.getText())) {
target = element;
break;
}
}
} }
if (target == null) if (target == null) {
{
target = tree.getItem(0); target = tree.getItem(0);
if (target.getItemCount() != 0) if (target.getItemCount() != 0)
target = target.getItem(0); target = target.getItem(0);
@ -333,6 +328,33 @@ import org.eclipse.cdt.internal.ui.CPluginImages;
return null; 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) { private static void addItemsToTree(Tree tree, List<EntryDescriptor> items) {
// Sorting is disabled because of users requests // Sorting is disabled because of users requests
// Collections.sort(items, CDTListComparator.getInstance()); // Collections.sort(items, CDTListComparator.getInstance());