diff options
author | Paul Fullbright | 2011-08-10 00:37:16 +0000 |
---|---|---|
committer | Paul Webster | 2011-08-25 14:22:00 +0000 |
commit | 7b8ce64491b8f39de3085c25551c45b3fec4e509 (patch) | |
tree | 87c8af69bb9a246fd3b3f300f536c1d40d39d755 | |
parent | 095013a8e7b1e8cc8d9564bc257fd97962c6acb8 (diff) | |
download | eclipse.platform.ui-7b8ce64491b8f39de3085c25551c45b3fec4e509.tar.gz eclipse.platform.ui-7b8ce64491b8f39de3085c25551c45b3fec4e509.tar.xz eclipse.platform.ui-7b8ce64491b8f39de3085c25551c45b3fec4e509.zip |
bug 349224 [CommonNavigator] Navigator content provider "appearsBefore"
creates hard reference to named id
4 files changed, 31 insertions, 4 deletions
diff --git a/bundles/org.eclipse.ui.navigator/src/org/eclipse/ui/internal/navigator/extensions/NavigatorContentDescriptorManager.java b/bundles/org.eclipse.ui.navigator/src/org/eclipse/ui/internal/navigator/extensions/NavigatorContentDescriptorManager.java index c2260215e5f..abec983309c 100644 --- a/bundles/org.eclipse.ui.navigator/src/org/eclipse/ui/internal/navigator/extensions/NavigatorContentDescriptorManager.java +++ b/bundles/org.eclipse.ui.navigator/src/org/eclipse/ui/internal/navigator/extensions/NavigatorContentDescriptorManager.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2003, 2010 IBM Corporation and others. + * Copyright (c) 2003, 2011 IBM 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 @@ -7,6 +7,7 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Bug 349224 Navigator content provider "appearsBefore" creates hard reference to named id - paul.fullbright@oracle.com *******************************************************************************/ package org.eclipse.ui.internal.navigator.extensions; @@ -23,6 +24,7 @@ import java.util.TreeSet; import java.util.WeakHashMap; import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.SafeRunner; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.resource.ImageRegistry; @@ -456,9 +458,12 @@ public class NavigatorContentDescriptorManager { if (desc.getId().equals(id)) return i; } - throw new RuntimeException("Can't find id: " + id); //$NON-NLS-1$ + // Do not require content descriptor to exist in workspace + NavigatorPlugin.log(IStatus.WARNING, 0, + "Can't find Navigator Content Descriptor with id: " + id, null); //$NON-NLS-1$ + return -1; } - + private void computeSequenceNumbers() { NavigatorContentDescriptor[] descs = getAllContentDescriptors(); @@ -474,7 +479,7 @@ public class NavigatorContentDescriptorManager { NavigatorContentDescriptor desc = (NavigatorContentDescriptor) list.get(i); if (desc.getAppearsBeforeId() != null) { int beforeInd = findId(list, desc.getAppearsBeforeId()); - if (beforeInd < i) { + if (beforeInd >= 0 && beforeInd < i) { list.add(beforeInd, desc); list.remove(i + 1); changed = true; diff --git a/tests/org.eclipse.ui.tests.navigator/plugin.xml b/tests/org.eclipse.ui.tests.navigator/plugin.xml index ae94131d426..a81970e618a 100644 --- a/tests/org.eclipse.ui.tests.navigator/plugin.xml +++ b/tests/org.eclipse.ui.tests.navigator/plugin.xml @@ -357,6 +357,17 @@ </navigatorContent> <navigatorContent + appearsBefore="org.eclipse.ui.tests.navigator.testTHISISNOTFOUND" + contentProvider="org.eclipse.ui.tests.navigator.extension.TestSimpleChildrenContentProvider2" + id="org.eclipse.ui.tests.navigator.testSimpleChildrenAppearsBeforeNotFound" + labelProvider="org.eclipse.ui.tests.navigator.extension.TestLabelProviderCyan" + name="Test Simple Children Appears Before Not Found"> + <enablement> + <instanceof value="org.eclipse.core.resources.IProject"/> + </enablement> + </navigatorContent> + + <navigatorContent id="org.eclipse.ui.tests.navigator.testContent2" contentProvider="org.eclipse.ui.tests.navigator.extension.TestContentProvider" labelProvider="org.eclipse.ui.tests.navigator.extension.TestLabelProviderBlue" diff --git a/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/NavigatorTestBase.java b/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/NavigatorTestBase.java index 8df313b32d9..a40c5550e53 100644 --- a/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/NavigatorTestBase.java +++ b/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/NavigatorTestBase.java @@ -87,6 +87,7 @@ public class NavigatorTestBase extends TestCase { public static final String TEST_SIMPLE_CHILDREN1 = "org.eclipse.ui.tests.navigator.testSimpleChildrenContent1"; public static final String TEST_SIMPLE_CHILDREN2 = "org.eclipse.ui.tests.navigator.testSimpleChildrenContent2"; public static final String TEST_SIMPLE_CHILDREN3 = "org.eclipse.ui.tests.navigator.testSimpleChildrenContent3"; + public static final String TEST_SIMPLE_CHILDREN_NOT_FOUND = "org.eclipse.ui.tests.navigator.testSimpleChildrenAppearsBeforeNotFound"; public static final String TEST_CONTENT_M12_VIEW = "org.eclipse.ui.tests.navigator.M12View"; public static final String TEST_CONTENT_M12_M1_CONTENT = "org.eclipse.ui.tests.navigator.m12.M1"; diff --git a/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/ProgrammaticOpenTest.java b/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/ProgrammaticOpenTest.java index 014297fb556..6663acbc5a1 100644 --- a/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/ProgrammaticOpenTest.java +++ b/tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/ProgrammaticOpenTest.java @@ -189,4 +189,14 @@ public class ProgrammaticOpenTest extends NavigatorTestBase { } + // bug 349224 Navigator content provider "appearsBefore" creates hard reference to named id + public void testNceNotFound() throws Exception { + _contentService.bindExtensions(new String[] { + COMMON_NAVIGATOR_RESOURCE_EXT, TEST_SIMPLE_CHILDREN_NOT_FOUND }, false); + _contentService.getActivationService().activateExtensions( + new String[] { COMMON_NAVIGATOR_RESOURCE_EXT, TEST_SIMPLE_CHILDREN_NOT_FOUND }, true); + } + + + } |