diff --git a/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/testplugin/CTestPlugin.java b/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/testplugin/CTestPlugin.java index 524d1fb8ff6..9035430b561 100644 --- a/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/testplugin/CTestPlugin.java +++ b/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/testplugin/CTestPlugin.java @@ -17,12 +17,13 @@ import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.resources.IWorkspaceDescription; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.FileLocator; import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Plugin; import org.eclipse.swt.widgets.Display; + public class CTestPlugin extends Plugin { public static String PLUGIN_ID = "org.eclipse.cdt.ui.tests"; //$NON-NLS-1$ @@ -51,7 +52,7 @@ public class CTestPlugin extends Plugin { public File getFileInPlugin(IPath path) { try { - return new File(Platform.asLocalURL(find(path)).getFile()); + return new File(FileLocator.toFileURL(FileLocator.find(getBundle(), path, null)).getFile()); } catch (IOException e) { return null; } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/viewsupport/AsyncViewerTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/viewsupport/AsyncViewerTest.java new file mode 100644 index 00000000000..ea50a2fb1b0 --- /dev/null +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/viewsupport/AsyncViewerTest.java @@ -0,0 +1,275 @@ +/******************************************************************************* + * Copyright (c) 2006 Wind River Systems, Inc. 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 + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Markus Schorn - initial API and implementation + *******************************************************************************/ + +package org.eclipse.cdt.ui.tests.viewsupport; + +import junit.framework.TestCase; + +import org.eclipse.cdt.internal.ui.viewsupport.*; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.viewers.*; +import org.eclipse.swt.widgets.*; +import org.eclipse.ui.PlatformUI; + +public class AsyncViewerTest extends TestCase { + private class Node { + private String fLabel; + private Node[] fChildren; + private int fAsync; + + Node(String label, Node[] children, int async) { + fLabel= label; + fChildren= children; + fAsync= async; + } + + public Node(String label) { + this(label, new Node[0], 0); + } + + public String toString() { + return fLabel; + } + + public int hashCode() { + return fLabel.hashCode(); + } + + public boolean equals(Object rhs) { + if (rhs instanceof Node) { + return fLabel.equals(((Node) rhs).fLabel); + } + return false; + } + } + + private class ContentProvider extends AsyncTreeContentProvider { + public ContentProvider(Display disp) { + super(disp); + } + + public Object[] asyncronouslyComputeChildren(Object parentElement, IProgressMonitor monitor) { + Node n= (Node) parentElement; + try { + Thread.sleep(n.fAsync); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + return n.fChildren; + } + + public Object[] syncronouslyComputeChildren(Object parentElement) { + Node n= (Node) parentElement; + if (n.fAsync != 0) { + return null; + } + return n.fChildren; + } + }; + + private class MyLabelProvider extends LabelProvider { + public String getText(Object element) { + if (element instanceof AsyncTreeWorkInProgressNode) { + return "..."; + } + return ((Node) element).fLabel; + } + } + + private class TestDialog extends Dialog { + private TreeViewer fViewer; + private ContentProvider fContentProvider; + private boolean fUseExtendedViewer; + + protected TestDialog(Shell parentShell, boolean useExtendedViewer) { + super(parentShell); + fUseExtendedViewer= useExtendedViewer; + } + + protected Control createDialogArea(Composite parent) { + fContentProvider= new ContentProvider(getShell().getDisplay()); + + Composite comp= (Composite) super.createDialogArea(parent); + fViewer= fUseExtendedViewer ? new ExtendedTreeViewer(comp) : new TreeViewer(comp); + fViewer.setContentProvider(fContentProvider); + fViewer.setLabelProvider(new MyLabelProvider()); + return comp; + } + } + + public void testSyncPopulation() { + TestDialog dlg = createTestDialog(false); + doTestSyncPopulation(dlg); + } + + public void testSyncPopulationEx() { + TestDialog dlg = createTestDialog(true); + doTestSyncPopulation(dlg); + } + + private void doTestSyncPopulation(TestDialog dlg) { + Node a,b,c; + Node root= new Node("", new Node[] { + a= new Node("a"), + b= new Node("b", new Node[] { + c= new Node("c") + }, 0) + }, 0); + dlg.fViewer.setInput(root); + assertEquals(2, countVisibleItems(dlg.fViewer)); + + dlg.fViewer.setExpandedState(a, true); + assertEquals(2, countVisibleItems(dlg.fViewer)); + + dlg.fViewer.setExpandedState(b, true); + assertEquals(3, countVisibleItems(dlg.fViewer)); + } + + private TestDialog createTestDialog(boolean useExtendedViewer) { + TestDialog dlg= new TestDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), useExtendedViewer); + dlg.setBlockOnOpen(false); + dlg.open(); + return dlg; + } + + private int countVisibleItems(TreeViewer viewer) { + return countVisibleItems(viewer.getTree().getItems()); + } + + private int countVisibleItems(TreeItem[] items) { + int count= items.length; + for (int i = 0; i < items.length; i++) { + TreeItem item = items[i]; + if (item.getExpanded()) { + count+= countVisibleItems(item.getItems()); + } + } + return count; + } + + public void testAsyncPopulation() throws InterruptedException { + TestDialog dlg = createTestDialog(false); + doTestAsyncPopulation(dlg); + } + + public void testAsyncPopulationEx() throws InterruptedException { + TestDialog dlg = createTestDialog(true); + doTestAsyncPopulation(dlg); + } + + private void doTestAsyncPopulation(TestDialog dlg) throws InterruptedException { + Node a,b,c; + Node root= new Node("", new Node[] { + a= new Node("a", new Node[0], 200), + b= new Node("b", new Node[] { + new Node("c"), new Node("d") + }, 200) + }, 0); + + dlg.fViewer.setInput(root); dispatch(); + assertEquals(2, countVisibleItems(dlg.fViewer)); + + // expand async with no children + dlg.fViewer.setExpandedState(a, true); dispatch(); + assertEquals("...", dlg.fViewer.getTree().getItem(0).getItem(0).getText()); + assertEquals(3, countVisibleItems(dlg.fViewer)); + + Thread.sleep(400); dispatch(); + assertEquals(2, countVisibleItems(dlg.fViewer)); + + // reset the viewer + dlg.fViewer.setInput(null); + dlg.fViewer.setInput(root); + + // expand async with two children + dlg.fViewer.setExpandedState(b, true); dispatch(); + assertEquals(3, countVisibleItems(dlg.fViewer)); + assertEquals("...", dlg.fViewer.getTree().getItem(1).getItem(0).getText()); + + Thread.sleep(400); dispatch(); + assertEquals(4, countVisibleItems(dlg.fViewer)); + + // reset the viewer + dlg.fViewer.setInput(null); + dlg.fViewer.setInput(root); + + // wait until children are computed (for the sake of the +-sign) + Thread.sleep(600); dispatch(); + dlg.fViewer.setExpandedState(a, true); + assertEquals(2, countVisibleItems(dlg.fViewer)); + dlg.fViewer.setExpandedState(b, true); + assertEquals(4, countVisibleItems(dlg.fViewer)); + } + + private void dispatch() throws InterruptedException { + Display d= Display.getCurrent(); + while (d.readAndDispatch()); + } + + public void testRecompute() throws InterruptedException { + TestDialog dlg = createTestDialog(true); + Node a,b,c; + Node root= + new Node("", new Node[] { + a= new Node("a"), + b= new Node("b", new Node[] { + c= new Node("c", new Node[] { + new Node("c1"), new Node("c2")}, 150), + new Node("d") + }, 150) + }, 0); + + dlg.fViewer.setInput(root); dispatch(); + assertEquals(2, countVisibleItems(dlg.fViewer)); + + dlg.fContentProvider.recompute(); + assertEquals(2, countVisibleItems(dlg.fViewer)); + + dlg.fViewer.setExpandedState(b, true); + sleepAndDispatch(10, 16); + assertEquals(4, countVisibleItems(dlg.fViewer)); + sleepAndDispatch(10, 16); + + root.fChildren= new Node[] { + a= new Node("a1"), + b= new Node("b", new Node[] { + c= new Node("c", new Node[] { + new Node("c3"), new Node("c4")}, 150), + new Node("d") + }, 150) + }; + dlg.fContentProvider.recompute(); + assertEquals(3, countVisibleItems(dlg.fViewer)); + sleepAndDispatch(10, 16); + assertEquals(4, countVisibleItems(dlg.fViewer)); + + dlg.fViewer.setExpandedState(c, true); + assertEquals(5, countVisibleItems(dlg.fViewer)); + sleepAndDispatch(10, 16); + assertEquals(6, countVisibleItems(dlg.fViewer)); + + dlg.fViewer.setSelection(new StructuredSelection(c)); + dlg.fContentProvider.recompute(); + sleepAndDispatch(10, 16); + assertEquals(5, countVisibleItems(dlg.fViewer)); + sleepAndDispatch(10, 16); + assertEquals(6, countVisibleItems(dlg.fViewer)); + assertEquals(1, dlg.fViewer.getTree().getSelectionCount()); + assertEquals("c", dlg.fViewer.getTree().getSelection()[0].getText()); + } + + private void sleepAndDispatch(int sleep, int count) throws InterruptedException { + for (int i = 0; i < count; i++) { + Thread.sleep(sleep); dispatch(); + } + } +} diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/viewsupport/ViewSupportTestSuite.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/viewsupport/ViewSupportTestSuite.java new file mode 100644 index 00000000000..e290c64a4c0 --- /dev/null +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/viewsupport/ViewSupportTestSuite.java @@ -0,0 +1,26 @@ +/******************************************************************************* + * Copyright (c) 2006 Wind River Systems, Inc. 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 + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Markus Schorn - initial API and implementation + *******************************************************************************/ + +package org.eclipse.cdt.ui.tests.viewsupport; + +import junit.framework.TestSuite; + +public class ViewSupportTestSuite extends TestSuite { + + public static TestSuite suite() { + return new ViewSupportTestSuite(); + } + + public ViewSupportTestSuite() { + super("View support tests"); + addTestSuite(AsyncViewerTest.class); + } +} diff --git a/core/org.eclipse.cdt.ui/icons/dlcl16/ch_callees.gif b/core/org.eclipse.cdt.ui/icons/dlcl16/ch_callees.gif new file mode 100644 index 00000000000..4e01f248acd Binary files /dev/null and b/core/org.eclipse.cdt.ui/icons/dlcl16/ch_callees.gif differ diff --git a/core/org.eclipse.cdt.ui/icons/dlcl16/ch_callers.gif b/core/org.eclipse.cdt.ui/icons/dlcl16/ch_callers.gif new file mode 100644 index 00000000000..4091cac6356 Binary files /dev/null and b/core/org.eclipse.cdt.ui/icons/dlcl16/ch_callers.gif differ diff --git a/core/org.eclipse.cdt.ui/icons/dlcl16/filterInactive.gif b/core/org.eclipse.cdt.ui/icons/dlcl16/filterInactive.gif new file mode 100644 index 00000000000..d8bda99d429 Binary files /dev/null and b/core/org.eclipse.cdt.ui/icons/dlcl16/filterInactive.gif differ diff --git a/core/org.eclipse.cdt.ui/icons/dlcl16/filterSystem.gif b/core/org.eclipse.cdt.ui/icons/dlcl16/filterSystem.gif new file mode 100644 index 00000000000..3e1d300226d Binary files /dev/null and b/core/org.eclipse.cdt.ui/icons/dlcl16/filterSystem.gif differ diff --git a/core/org.eclipse.cdt.ui/icons/dlcl16/search_next.gif b/core/org.eclipse.cdt.ui/icons/dlcl16/search_next.gif new file mode 100644 index 00000000000..8aacf959dc4 Binary files /dev/null and b/core/org.eclipse.cdt.ui/icons/dlcl16/search_next.gif differ diff --git a/core/org.eclipse.cdt.ui/icons/dlcl16/search_prev.gif b/core/org.eclipse.cdt.ui/icons/dlcl16/search_prev.gif new file mode 100644 index 00000000000..38841abe9bb Binary files /dev/null and b/core/org.eclipse.cdt.ui/icons/dlcl16/search_prev.gif differ diff --git a/core/org.eclipse.cdt.ui/icons/elcl16/ch_callees.gif b/core/org.eclipse.cdt.ui/icons/elcl16/ch_callees.gif new file mode 100644 index 00000000000..695e5a5cfa5 Binary files /dev/null and b/core/org.eclipse.cdt.ui/icons/elcl16/ch_callees.gif differ diff --git a/core/org.eclipse.cdt.ui/icons/elcl16/ch_callers.gif b/core/org.eclipse.cdt.ui/icons/elcl16/ch_callers.gif new file mode 100644 index 00000000000..de0e6f9cf40 Binary files /dev/null and b/core/org.eclipse.cdt.ui/icons/elcl16/ch_callers.gif differ diff --git a/core/org.eclipse.cdt.ui/icons/elcl16/filterInactive.gif b/core/org.eclipse.cdt.ui/icons/elcl16/filterInactive.gif new file mode 100644 index 00000000000..1292803d5df Binary files /dev/null and b/core/org.eclipse.cdt.ui/icons/elcl16/filterInactive.gif differ diff --git a/core/org.eclipse.cdt.ui/icons/elcl16/filterSystem.gif b/core/org.eclipse.cdt.ui/icons/elcl16/filterSystem.gif new file mode 100644 index 00000000000..e4c0868d7d4 Binary files /dev/null and b/core/org.eclipse.cdt.ui/icons/elcl16/filterSystem.gif differ diff --git a/core/org.eclipse.cdt.ui/icons/elcl16/search_next.gif b/core/org.eclipse.cdt.ui/icons/elcl16/search_next.gif new file mode 100644 index 00000000000..072b1844572 Binary files /dev/null and b/core/org.eclipse.cdt.ui/icons/elcl16/search_next.gif differ diff --git a/core/org.eclipse.cdt.ui/icons/elcl16/search_prev.gif b/core/org.eclipse.cdt.ui/icons/elcl16/search_prev.gif new file mode 100644 index 00000000000..07164754e5c Binary files /dev/null and b/core/org.eclipse.cdt.ui/icons/elcl16/search_prev.gif differ diff --git a/core/org.eclipse.cdt.ui/icons/ovr16/rec_referencedby_co.gif b/core/org.eclipse.cdt.ui/icons/ovr16/rec_referencedby_co.gif new file mode 100644 index 00000000000..6c93c32b3c0 Binary files /dev/null and b/core/org.eclipse.cdt.ui/icons/ovr16/rec_referencedby_co.gif differ diff --git a/core/org.eclipse.cdt.ui/icons/ovr16/rec_relatesto_co.gif b/core/org.eclipse.cdt.ui/icons/ovr16/rec_relatesto_co.gif new file mode 100644 index 00000000000..eef6eaa724e Binary files /dev/null and b/core/org.eclipse.cdt.ui/icons/ovr16/rec_relatesto_co.gif differ diff --git a/core/org.eclipse.cdt.ui/icons/ovr16/referencedby_co.gif b/core/org.eclipse.cdt.ui/icons/ovr16/referencedby_co.gif new file mode 100644 index 00000000000..e2456a4a7cb Binary files /dev/null and b/core/org.eclipse.cdt.ui/icons/ovr16/referencedby_co.gif differ diff --git a/core/org.eclipse.cdt.ui/icons/ovr16/relatesto_co.gif b/core/org.eclipse.cdt.ui/icons/ovr16/relatesto_co.gif new file mode 100644 index 00000000000..460f9b4aa38 Binary files /dev/null and b/core/org.eclipse.cdt.ui/icons/ovr16/relatesto_co.gif differ diff --git a/core/org.eclipse.cdt.ui/icons/ovr16/systeminclude_co.gif b/core/org.eclipse.cdt.ui/icons/ovr16/systeminclude_co.gif new file mode 100644 index 00000000000..5c474e5bb5c Binary files /dev/null and b/core/org.eclipse.cdt.ui/icons/ovr16/systeminclude_co.gif differ diff --git a/core/org.eclipse.cdt.ui/icons/view16/includeBrowser.gif b/core/org.eclipse.cdt.ui/icons/view16/includeBrowser.gif new file mode 100644 index 00000000000..8b784b6a008 Binary files /dev/null and b/core/org.eclipse.cdt.ui/icons/view16/includeBrowser.gif differ diff --git a/core/org.eclipse.cdt.ui/plugin.properties b/core/org.eclipse.cdt.ui/plugin.properties index 925cd3da934..1ed07eb4c75 100644 --- a/core/org.eclipse.cdt.ui/plugin.properties +++ b/core/org.eclipse.cdt.ui/plugin.properties @@ -7,6 +7,7 @@ # # Contributors: # IBM Corporation - initial API and implementation +# Markus Schorn (Wind River Systems) ############################################################################### pluginName=C/C++ Development Tools UI providerName=Eclipse.org @@ -328,3 +329,8 @@ CDTIndexer.fastindexer=Fast C/C++ Indexer (faster but less accurate) IndexView.name=C/C++ Index RebuildIndex.name=Rebuild Index + +indexerPage.name = Indexer Page +proposalFilter.name = Code Completion Proposal Filter +includeBrowser.name = Include Browser +cSearchPage.name = CSearchPage \ No newline at end of file diff --git a/core/org.eclipse.cdt.ui/plugin.xml b/core/org.eclipse.cdt.ui/plugin.xml index 2d5358056e1..88ec71ab2f0 100644 --- a/core/org.eclipse.cdt.ui/plugin.xml +++ b/core/org.eclipse.cdt.ui/plugin.xml @@ -15,9 +15,9 @@ - + - + @@ -211,6 +211,8 @@ + + @@ -241,6 +243,12 @@ icon="icons/view16/types.gif" id="org.eclipse.cdt.ui.IndexView" name="%IndexView.name"/> +