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

Initial version of the Include Browser

This commit is contained in:
Markus Schorn 2006-06-30 09:42:39 +00:00
parent b49574295b
commit 2a8a06ab31
50 changed files with 3432 additions and 61 deletions

View file

@ -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;
}

View file

@ -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();
}
}
}

View file

@ -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);
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 147 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 145 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 883 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 873 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 152 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 152 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 209 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 205 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 888 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 873 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 332 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 323 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 829 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 828 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 823 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 821 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 835 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 866 B

View file

@ -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

View file

@ -15,9 +15,9 @@
<!-- Purpose: Provide a perspective specific text hovering for CEditor files -->
<!-- =========================================================================== -->
<extension-point id="textHovers" name="%textHoversName"/>
<extension-point id="IndexerPage" name="Indexer Page" schema="schema/IndexerPage.exsd"/>
<extension-point id="IndexerPage" name="%indexerPage.name" schema="schema/IndexerPage.exsd"/>
<extension-point id="completionContributors" name="%completionContributors" schema="schema/completionContributors.exsd"/>
<extension-point id="ProposalFilter" name="Code Completion Proposal Filter" schema="schema/ProposalFilter.exsd"/>
<extension-point id="ProposalFilter" name="%proposalFilter.name" schema="schema/ProposalFilter.exsd"/>
<extension
point="org.eclipse.core.runtime.adapters">
@ -211,6 +211,8 @@
<actionSet
id="org.eclipse.debug.ui.launchActionSet">
</actionSet>
<showInPart id="org.eclipse.cdt.ui.includeBrowser"/>
<showInPart id="org.eclipse.cdt.ui.CView"/>
<!--perspectiveShortcut
id="org.eclipse.cdt.ui.CBrowsingPerspective">
</perspectiveShortcut-->
@ -241,6 +243,12 @@
icon="icons/view16/types.gif"
id="org.eclipse.cdt.ui.IndexView"
name="%IndexView.name"/>
<view
category="org.eclipse.cdt.ui.views"
class="org.eclipse.cdt.internal.ui.includebrowser.IBViewPart"
icon="icons/view16/includeBrowser.gif"
id="org.eclipse.cdt.ui.includeBrowser"
name="%includeBrowser.name"/>
<!--category
name="%CBrowsing.viewCategoryName"
id="org.eclipse.cdt.ui.c.browsing">
@ -1054,7 +1062,7 @@
</extension>
<extension
id="pdomSearchPage"
name="CSearchPage"
name="%cSearchPage.name"
point="org.eclipse.search.searchPages">
<page
canSearchEnclosingProjects="true"

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2005 IBM Corporation and others.
* Copyright (c) 2005, 2006 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
@ -8,6 +8,7 @@
* Contributors:
* IBM Corporation - initial API and implementation
* QNX Software System
* Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.ui;
@ -196,13 +197,27 @@ public class CPluginImages {
public static final String IMG_ACTION_SHOW_PUBLIC= NAME_PREFIX + "public_co.gif"; //$NON-NLS-1$
public static final String IMG_ACTION_SHOW_STATIC= NAME_PREFIX + "static_co.gif"; //$NON-NLS-1$
public static final String IMG_ACTION_SHOW_REF_BY = NAME_PREFIX + "ch_callers.gif"; //$NON-NLS-1$
public static final String IMG_ACTION_SHOW_RELATES_TO = NAME_PREFIX + "ch_callees.gif"; //$NON-NLS-1$
public static final String IMG_ACTION_HIDE_INACTIVE = NAME_PREFIX + "filterInactive.gif"; //$NON-NLS-1$
public static final String IMG_ACTION_HIDE_SYSTEM = NAME_PREFIX + "filterSystem.gif"; //$NON-NLS-1$
public static final String IMG_SHOW_NEXT= NAME_PREFIX + "search_next.gif"; //$NON-NLS-1$
public static final String IMG_SHOW_PREV= NAME_PREFIX + "search_prev.gif"; //$NON-NLS-1$
public static final String IMG_REFRESH= NAME_PREFIX + "refresh_nav.gif"; //$NON-NLS-1$
public static final ImageDescriptor DESC_OBJS_TEMPLATE= createManaged(T_OBJ, IMG_OBJS_TEMPLATE);
public static final ImageDescriptor DESC_OVR_STATIC= create(T_OVR, "static_co.gif"); //$NON-NLS-1$
public static final ImageDescriptor DESC_OVR_CONSTANT= create(T_OVR, "c_ovr.gif"); //$NON-NLS-1$
public static final ImageDescriptor DESC_OVR_VOLATILE= create(T_OVR, "volatile_co.gif"); //$NON-NLS-1$
public static final ImageDescriptor DESC_OVR_TEMPLATE= create(T_OVR, "template_co.gif"); //$NON-NLS-1$
public static final ImageDescriptor DESC_OVR_RELATESTO= create(T_OVR, "relatesto_co.gif"); //$NON-NLS-1$
public static final ImageDescriptor DESC_OVR_REFERENCEDBY= create(T_OVR, "referencedby_co.gif"); //$NON-NLS-1$
public static final ImageDescriptor DESC_OVR_REC_RELATESTO= create(T_OVR, "rec_relatesto_co.gif"); //$NON-NLS-1$
public static final ImageDescriptor DESC_OVR_REC_REFERENCEDBY= create(T_OVR, "rec_referencedby_co.gif"); //$NON-NLS-1$
public static final ImageDescriptor DESC_OVR_SYSTEM_INCLUDE= create(T_OVR, "systeminclude_co.gif"); //$NON-NLS-1$
public static final ImageDescriptor DESC_OVR_WARNING= create(T_OVR, "warning_co.gif"); //$NON-NLS-1$
public static final ImageDescriptor DESC_OVR_ERROR= create(T_OVR, "error_co.gif"); //$NON-NLS-1$
@ -242,10 +257,10 @@ public class CPluginImages {
public static final String IMG_OBJS_REFACTORING_WARNING= NAME_PREFIX + "warning_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_REFACTORING_INFO= NAME_PREFIX + "info_obj.gif"; //$NON-NLS-1$
public static final ImageDescriptor DESC_REFACTORING_FATAL= createManaged( T_OBJ, IMG_OBJS_REFACTORING_FATAL); //$NON-NLS-1$
public static final ImageDescriptor DESC_REFACTORING_ERROR= createManaged( T_OBJ, IMG_OBJS_REFACTORING_ERROR); //$NON-NLS-1$
public static final ImageDescriptor DESC_REFACTORING_WARNING= createManaged( T_OBJ, IMG_OBJS_REFACTORING_WARNING); //$NON-NLS-1$
public static final ImageDescriptor DESC_REFACTORING_INFO= createManaged ( T_OBJ, IMG_OBJS_REFACTORING_INFO); //$NON-NLS-1$
public static final ImageDescriptor DESC_REFACTORING_FATAL= createManaged( T_OBJ, IMG_OBJS_REFACTORING_FATAL);
public static final ImageDescriptor DESC_REFACTORING_ERROR= createManaged( T_OBJ, IMG_OBJS_REFACTORING_ERROR);
public static final ImageDescriptor DESC_REFACTORING_WARNING= createManaged( T_OBJ, IMG_OBJS_REFACTORING_WARNING);
public static final ImageDescriptor DESC_REFACTORING_INFO= createManaged ( T_OBJ, IMG_OBJS_REFACTORING_INFO);
public static final ImageDescriptor DESC_WIZBAN_REFACTOR_FIELD= create(T_WIZBAN, "fieldrefact_wiz.gif"); //$NON-NLS-1$
public static final ImageDescriptor DESC_WIZBAN_REFACTOR_METHOD= create(T_WIZBAN, "methrefact_wiz.gif"); //$NON-NLS-1$
@ -256,6 +271,7 @@ public class CPluginImages {
public static final ImageDescriptor DESC_OBJS_CU_CHANGE= create(T_OBJ, "cu_change.gif"); //$NON-NLS-1$
public static final ImageDescriptor DESC_OBJS_FILE_CHANGE= create(T_OBJ, "file_change.gif"); //$NON-NLS-1$
public static final ImageDescriptor DESC_OBJS_TEXT_EDIT= create(T_OBJ, "text_edit.gif"); //$NON-NLS-1$
private static ImageDescriptor createManaged(String prefix, String name) {

View file

@ -1,5 +1,5 @@
###############################################################################
# Copyright (c) 2002, 2005 IBM Corporation and others.
# Copyright (c) 2002, 2006 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:
# Rational Software - Initial API and implementation
# Markus Schorn (Wind River Systems)
###############################################################################
Drag.move.problem.title=Drag and Drop Problem
@ -86,3 +87,5 @@ CElementLabels.declseparator_string=\ :\
CHelpConfigurationPropertyPage.buttonLabels.CheckAll=Check All
CHelpConfigurationPropertyPage.buttonLabels.UncheckAll=Uncheck All
CHelpConfigurationPropertyPage.HelpBooks=Help books
AsyncTreeContentProvider.JobName=Child Node Computation
AsyncTreeContentProvider.TaskName=Compute child nodes

View file

@ -0,0 +1,55 @@
/*******************************************************************************
* Copyright (c) 2000, 2006 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
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.ui.includebrowser;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider;
import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels;
/**
* Action used for the include browser forward / backward buttons
*/
public class HistoryAction extends Action {
private IBViewPart fViewPart;
private ITranslationUnit fElement;
public HistoryAction(IBViewPart viewPart, ITranslationUnit element) {
super("", AS_RADIO_BUTTON); //$NON-NLS-1$
fViewPart= viewPart;
fElement= element;
String elementName= CElementLabels.getElementLabel(element, CElementLabels.ALL_POST_QUALIFIED);
setText(elementName);
setImageDescriptor(getImageDescriptor(element));
}
private ImageDescriptor getImageDescriptor(ITranslationUnit elem) {
CElementImageProvider imageProvider= new CElementImageProvider();
ImageDescriptor desc= imageProvider.getBaseImageDescriptor(elem, 0);
imageProvider.dispose();
return desc;
}
/*
* @see Action#run()
*/
public void run() {
fViewPart.setInput(fElement);
}
}

View file

@ -0,0 +1,105 @@
/*******************************************************************************
* Copyright (c) 2000, 2006 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
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.ui.includebrowser;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.ActionContributionItem;
import org.eclipse.jface.action.IMenuCreator;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.internal.ui.CPluginImages;
public class HistoryDropDownAction extends Action implements IMenuCreator {
public static class ClearHistoryAction extends Action {
private IBViewPart fView;
public ClearHistoryAction(IBViewPart view) {
super(IBMessages.HistoryDropDownAction_ClearHistory_label);
fView= view;
}
public void run() {
fView.setHistoryEntries(new ITranslationUnit[0]);
fView.setInput(null);
}
}
public static final int RESULTS_IN_DROP_DOWN= 10;
private IBViewPart fHierarchyView;
private Menu fMenu;
public HistoryDropDownAction(IBViewPart view) {
fHierarchyView= view;
fMenu= null;
setToolTipText(IBMessages.HistoryDropDownAction_tooltip);
CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, "history_list.gif"); //$NON-NLS-1$
setMenuCreator(this);
}
public void dispose() {
// action is reused, can be called several times.
if (fMenu != null) {
fMenu.dispose();
fMenu= null;
}
}
public Menu getMenu(Menu parent) {
return null;
}
public Menu getMenu(Control parent) {
if (fMenu != null) {
fMenu.dispose();
}
fMenu= new Menu(parent);
ITranslationUnit[] elements= fHierarchyView.getHistoryEntries();
addEntries(fMenu, elements);
new MenuItem(fMenu, SWT.SEPARATOR);
addActionToMenu(fMenu, new HistoryListAction(fHierarchyView));
addActionToMenu(fMenu, new ClearHistoryAction(fHierarchyView));
return fMenu;
}
private boolean addEntries(Menu menu, ITranslationUnit[] elements) {
boolean checked= false;
int min= Math.min(elements.length, RESULTS_IN_DROP_DOWN);
for (int i= 0; i < min; i++) {
HistoryAction action= new HistoryAction(fHierarchyView, elements[i]);
action.setChecked(elements[i].equals(fHierarchyView.getInput()));
checked= checked || action.isChecked();
addActionToMenu(menu, action);
}
return checked;
}
protected void addActionToMenu(Menu parent, Action action) {
ActionContributionItem item= new ActionContributionItem(action);
item.fill(parent, -1);
}
public void run() {
(new HistoryListAction(fHierarchyView)).run();
}
}

View file

@ -0,0 +1,182 @@
/*******************************************************************************
* Copyright (c) 2000, 2006 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
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.ui.includebrowser;
import java.util.Arrays;
import java.util.List;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.dialogs.StatusDialog;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.window.Window;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.internal.ui.dialogs.StatusInfo;
import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider;
import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels;
import org.eclipse.cdt.internal.ui.viewsupport.CUILabelProvider;
import org.eclipse.cdt.internal.ui.wizards.dialogfields.DialogField;
import org.eclipse.cdt.internal.ui.wizards.dialogfields.IListAdapter;
import org.eclipse.cdt.internal.ui.wizards.dialogfields.LayoutUtil;
import org.eclipse.cdt.internal.ui.wizards.dialogfields.ListDialogField;
public class HistoryListAction extends Action {
private class HistoryListDialog extends StatusDialog {
private ListDialogField fHistoryList;
private IStatus fHistoryStatus;
private ITranslationUnit fResult;
private HistoryListDialog(Shell shell, ITranslationUnit[] elements) {
super(shell);
setHelpAvailable(false);
setTitle(IBMessages.HistoryListAction_HistoryDialog_title);
String[] buttonLabels= new String[] {
IBMessages.HistoryListAction_Remove_label,
};
IListAdapter adapter= new IListAdapter() {
public void customButtonPressed(ListDialogField field, int index) {
doCustomButtonPressed();
}
public void selectionChanged(ListDialogField field) {
doSelectionChanged();
}
public void doubleClicked(ListDialogField field) {
doDoubleClicked();
}
};
CUILabelProvider labelProvider= new CUILabelProvider(CElementLabels.APPEND_ROOT_PATH, CElementImageProvider.OVERLAY_ICONS);
fHistoryList= new ListDialogField(adapter, buttonLabels, labelProvider);
fHistoryList.setLabelText(IBMessages.HistoryListAction_HistoryList_label);
fHistoryList.setElements(Arrays.asList(elements));
ISelection sel;
if (elements.length > 0) {
sel= new StructuredSelection(elements[0]);
} else {
sel= new StructuredSelection();
}
fHistoryList.selectElements(sel);
}
/*
* @see Dialog#createDialogArea(Composite)
*/
protected Control createDialogArea(Composite parent) {
initializeDialogUnits(parent);
Composite composite= (Composite) super.createDialogArea(parent);
Composite inner= new Composite(composite, SWT.NONE);
inner.setFont(parent.getFont());
inner.setLayoutData(new GridData(GridData.FILL_BOTH));
LayoutUtil.doDefaultLayout(inner, new DialogField[] { fHistoryList }, true, 0, 0);
LayoutUtil.setHeightHint(fHistoryList.getListControl(null), convertHeightInCharsToPixels(12));
LayoutUtil.setHorizontalGrabbing(fHistoryList.getListControl(null));
applyDialogFont(composite);
return composite;
}
/**
* Method doCustomButtonPressed.
*/
private void doCustomButtonPressed() {
fHistoryList.removeElements(fHistoryList.getSelectedElements());
}
private void doDoubleClicked() {
if (fHistoryStatus.isOK()) {
okPressed();
}
}
private void doSelectionChanged() {
StatusInfo status= new StatusInfo();
List selected= fHistoryList.getSelectedElements();
if (selected.size() != 1) {
status.setError(""); //$NON-NLS-1$
fResult= null;
} else {
fResult= (ITranslationUnit) selected.get(0);
}
fHistoryList.enableButton(0, fHistoryList.getSize() > selected.size() && selected.size() != 0);
fHistoryStatus= status;
updateStatus(status);
}
public ITranslationUnit getResult() {
return fResult;
}
public ITranslationUnit[] getRemaining() {
List elems= fHistoryList.getElements();
return (ITranslationUnit[]) elems.toArray(new ITranslationUnit[elems.size()]);
}
/*
* @see org.eclipse.jface.window.Window#configureShell(Shell)
*/
protected void configureShell(Shell newShell) {
super.configureShell(newShell);
// PlatformUI.getWorkbench().getHelpSystem().setHelp(newShell, ...);
}
/* (non-Javadoc)
* @see org.eclipse.jface.window.Window#create()
*/
public void create() {
setShellStyle(getShellStyle() | SWT.RESIZE);
super.create();
}
}
private IBViewPart fView;
public HistoryListAction(IBViewPart view) {
fView= view;
setText(IBMessages.HistoryListAction_label);
}
/*
* @see IAction#run()
*/
public void run() {
ITranslationUnit[] historyEntries= fView.getHistoryEntries();
HistoryListDialog dialog= new HistoryListDialog(fView.getSite().getShell(), historyEntries);
if (dialog.open() == Window.OK) {
fView.setHistoryEntries(dialog.getRemaining());
fView.setInput(dialog.getResult());
}
}
}

View file

@ -0,0 +1,116 @@
/*******************************************************************************
* 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.internal.ui.includebrowser;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.swt.widgets.Display;
import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.internal.ui.missingapi.CIndexQueries;
import org.eclipse.cdt.internal.ui.missingapi.CIndexQueries.IPDOMInclude;
import org.eclipse.cdt.internal.ui.viewsupport.AsyncTreeContentProvider;
/**
* This is the content provider for the include browser.
*/
public class IBContentProvider extends AsyncTreeContentProvider {
private static final IProgressMonitor NPM = new NullProgressMonitor();
private boolean fComputeIncludedBy = true;
/**
* Constructs the content provider.
*/
public IBContentProvider(Display disp) {
super(disp);
}
public Object getParent(Object element) {
if (element instanceof IBNode) {
IBNode node = (IBNode) element;
return node.getParent();
}
return super.getParent(element);
}
public Object[] syncronouslyComputeChildren(Object parentElement) {
if (parentElement instanceof ITranslationUnit) {
ITranslationUnit tu = (ITranslationUnit) parentElement;
return new Object[] { new IBNode(null, new IBFile(tu), null, null, 0) };
}
if (parentElement instanceof IBNode) {
IBNode node = (IBNode) parentElement;
if (node.isRecursive() || node.getRepresentedTranslationUnit() == null) {
return NO_CHILDREN;
}
}
// allow for async computation
return null;
}
public Object[] asyncronouslyComputeChildren(Object parentElement,
IProgressMonitor monitor) {
if (parentElement instanceof IBNode) {
IBNode node = (IBNode) parentElement;
ITranslationUnit tu= node.getRepresentedTranslationUnit();
if (tu != null) {
try {
IPDOMInclude[] includes;
IBFile directiveFile= null;
IBFile targetFile= null;
if (fComputeIncludedBy) {
includes= CIndexQueries.getInstance().findIncludedBy(tu, NPM);
}
else {
includes= CIndexQueries.getInstance().findIncludesTo(tu, NPM);
directiveFile= node.getRepresentedFile();
}
if (includes.length > 0) {
IBNode[] result = new IBNode[includes.length];
for (int i = 0; i < includes.length; i++) {
IPDOMInclude include = includes[i];
if (fComputeIncludedBy) {
directiveFile= targetFile= new IBFile(tu.getCProject(), include.getIncludedBy());
}
else {
targetFile= new IBFile(tu.getCProject(), include.getIncludes());
}
IBNode newnode= new IBNode(node, targetFile, directiveFile,
include.getName(), include.getOffset());
newnode.setIsActiveCode(include.isActiveCode());
newnode.setIsSystemInclude(include.isSystemInclude());
result[i]= newnode;
}
return result;
}
}
catch (CoreException e) {
CUIPlugin.getDefault().log(e.getStatus());
}
}
}
return NO_CHILDREN;
}
public void setComputeIncludedBy(boolean value) {
fComputeIncludedBy = value;
}
public boolean getComputeIncludedBy() {
return fComputeIncludedBy;
}
}

View file

@ -0,0 +1,90 @@
/*******************************************************************************
* 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.internal.ui.includebrowser;
import java.util.Iterator;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.cdt.core.model.*;
import org.eclipse.cdt.ui.CUIPlugin;
public class IBConversions {
public static ITranslationUnit fileToTU(IFile file) {
if (CoreModel.isTranslationUnit(file)) {
ICProject cp= CoreModel.getDefault().getCModel().getCProject(file.getProject().getName());
if (cp != null) {
ICElement tu;
try {
tu = cp.findElement(file.getProjectRelativePath());
if (tu instanceof ITranslationUnit) {
return (ITranslationUnit) tu;
}
} catch (CModelException e) {
CUIPlugin.getDefault().log(e);
}
}
}
return null;
}
public static IBNode selectionToNode(ISelection sel) {
if (sel instanceof IStructuredSelection) {
IStructuredSelection ssel= (IStructuredSelection) sel;
for (Iterator iter = ssel.iterator(); iter.hasNext();) {
Object o= iter.next();
if (o instanceof IBNode) {
IBNode node = (IBNode) o;
return node;
}
}
}
return null;
}
public static ITranslationUnit selectionToTU(ISelection sel) {
if (sel instanceof IStructuredSelection) {
IStructuredSelection ssel= (IStructuredSelection) sel;
for (Iterator iter = ssel.iterator(); iter.hasNext();) {
ITranslationUnit tu= objectToTU(iter.next());
if (tu != null) {
return tu;
}
}
}
return null;
}
public static ITranslationUnit objectToTU(Object object) {
if (object instanceof ITranslationUnit) {
return (ITranslationUnit) object;
}
if (object instanceof IAdaptable) {
IAdaptable adaptable = (IAdaptable) object;
ITranslationUnit result= (ITranslationUnit) adaptable.getAdapter(ITranslationUnit.class);
if (result != null) {
return result;
}
IFile file= (IFile) adaptable.getAdapter(IFile.class);
if (file != null) {
result= fileToTU(file);
if (result != null) {
return result;
}
}
}
return null;
}
}

View file

@ -0,0 +1,97 @@
/*******************************************************************************
* 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.internal.ui.includebrowser;
import java.util.ArrayList;
import java.util.Iterator;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.IPath;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.swt.dnd.*;
import org.eclipse.ui.part.ResourceTransfer;
public class IBDragSourceListener implements DragSourceListener {
private TreeViewer fTreeViewer;
private ArrayList fSelectedNodes= new ArrayList();
private IBDropTargetListener fDropTargetListener;
public IBDragSourceListener(TreeViewer viewer) {
fTreeViewer= viewer;
}
public void dragStart(DragSourceEvent event) {
if (fDropTargetListener != null) {
fDropTargetListener.setEnabled(false);
}
fSelectedNodes.clear();
if (event.doit) {
IStructuredSelection sel= (IStructuredSelection) fTreeViewer.getSelection();
for (Iterator iter = sel.iterator(); iter.hasNext();) {
Object element = iter.next();
if (element instanceof IBNode) {
fSelectedNodes.add(element);
}
}
event.doit= !fSelectedNodes.isEmpty();
}
}
public void setDependentDropTargetListener(IBDropTargetListener dl) {
fDropTargetListener= dl;
}
public void dragSetData(DragSourceEvent event) {
if (ResourceTransfer.getInstance().isSupportedType(event.dataType)) {
event.data= getResources();
}
else if (FileTransfer.getInstance().isSupportedType(event.dataType)) {
event.data= getFiles();
}
}
private String[] getFiles() {
ArrayList files= new ArrayList(fSelectedNodes.size());
for (Iterator iter = fSelectedNodes.iterator(); iter.hasNext();) {
IBNode node = (IBNode) iter.next();
IFile file= (IFile) node.getAdapter(IFile.class);
if (file != null) {
IPath location= file.getLocation();
if (location != null) {
files.add(location.toOSString());
}
}
}
return (String[]) files.toArray(new String[files.size()]);
}
private IFile[] getResources() {
ArrayList files= new ArrayList(fSelectedNodes.size());
for (Iterator iter = fSelectedNodes.iterator(); iter.hasNext();) {
IBNode node = (IBNode) iter.next();
IFile file= (IFile) node.getAdapter(IFile.class);
if (file != null) {
files.add(file);
}
}
return (IFile[]) files.toArray(new IFile[files.size()]);
}
public void dragFinished(DragSourceEvent event) {
if (fDropTargetListener != null) {
fDropTargetListener.setEnabled(true);
}
fSelectedNodes.clear();
}
}

View file

@ -0,0 +1,161 @@
/*******************************************************************************
* 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.internal.ui.includebrowser;
import java.util.Iterator;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.Path;
import org.eclipse.jface.util.LocalSelectionTransfer;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.dnd.DND;
import org.eclipse.swt.dnd.DropTargetEvent;
import org.eclipse.swt.dnd.DropTargetListener;
import org.eclipse.swt.dnd.FileTransfer;
import org.eclipse.swt.dnd.Transfer;
import org.eclipse.swt.dnd.TransferData;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.part.ResourceTransfer;
import org.eclipse.cdt.core.model.ITranslationUnit;
public class IBDropTargetListener implements DropTargetListener {
private IBViewPart fIncludeBrowser;
private ITranslationUnit fTranslationUnit;
private boolean fEnabled;
public IBDropTargetListener(IBViewPart view) {
fIncludeBrowser= view;
}
public void setEnabled(boolean val) {
fEnabled= val;
}
public void dragEnter(DropTargetEvent event) {
fTranslationUnit= null;
checkOperation(event);
if (event.detail != DND.DROP_NONE) {
if (LocalSelectionTransfer.getTransfer().isSupportedType(event.currentDataType)) {
fTranslationUnit= checkLocalSelection();
if (fTranslationUnit == null) {
TransferData alternateDataType = checkForAlternateDataType(event.dataTypes,
new Transfer[] {ResourceTransfer.getInstance(), FileTransfer.getInstance()});
if (alternateDataType == null) {
event.detail= DND.DROP_NONE;
}
else {
event.currentDataType= alternateDataType;
}
}
}
}
}
private TransferData checkForAlternateDataType(TransferData[] dataTypes, Transfer[] transfers) {
for (int i = 0; i < dataTypes.length; i++) {
TransferData dataType = dataTypes[i];
for (int j = 0; j < transfers.length; j++) {
Transfer transfer = transfers[j];
if (transfer.isSupportedType(dataType)) {
return dataType;
}
}
}
return null;
}
private ITranslationUnit checkLocalSelection() {
ISelection sel= LocalSelectionTransfer.getTransfer().getSelection();
if (sel instanceof IStructuredSelection) {
for (Iterator iter = ((IStructuredSelection)sel).iterator(); iter.hasNext();) {
Object element = iter.next();
if (element instanceof ITranslationUnit) {
return (ITranslationUnit) element;
}
}
}
return null;
}
public void dragLeave(DropTargetEvent event) {
}
public void dragOperationChanged(DropTargetEvent event) {
checkOperation(event);
}
public void dragOver(DropTargetEvent event) {
}
public void drop(DropTargetEvent event) {
if (fTranslationUnit == null) {
fTranslationUnit= findFirstTranslationUnit(event.data);
}
if (fTranslationUnit == null) {
fIncludeBrowser.setMessage(IBMessages.IBViewPart_falseInputMessage);
Display.getCurrent().beep();
}
else {
fIncludeBrowser.setInput(fTranslationUnit);
}
}
private ITranslationUnit findFirstTranslationUnit(Object o) {
if (o instanceof String[]) {
String[] filePaths= (String[]) o;
IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot();
for (int i = 0; i < filePaths.length; i++) {
String filePath = filePaths[i];
ITranslationUnit tu= findTranslationUnit(root.findFilesForLocation(Path.fromOSString(filePath)));
if (tu != null) {
return tu;
}
}
return null;
}
if (o instanceof IResource[]) {
return findTranslationUnit((IResource[]) o);
}
return null;
}
private ITranslationUnit findTranslationUnit(IResource[] files) {
for (int i = 0; i < files.length; i++) {
IResource resource = files[i];
if (resource.getType() == IResource.FILE) {
ITranslationUnit tu= IBConversions.fileToTU((IFile) resource);
if (tu != null) {
return tu;
}
}
}
return null;
}
public void dropAccept(DropTargetEvent event) {
}
private void checkOperation(DropTargetEvent event) {
if (fEnabled && (event.operations & DND.DROP_COPY) != 0) {
event.detail= DND.DROP_COPY;
}
else {
event.detail= DND.DROP_NONE;
}
}
}

View file

@ -0,0 +1,95 @@
/*******************************************************************************
* 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.internal.ui.includebrowser;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath;
import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.internal.ui.util.CoreUtility;
public class IBFile {
public IPath fLocation;
public ITranslationUnit fTU= null;
public IBFile(ITranslationUnit tu) {
fTU= tu;
IResource r= fTU.getResource();
if (r != null) {
fLocation= r.getLocation();
}
else {
fLocation= fTU.getPath();
}
}
public IBFile(ICProject preferredProject, IPath location) throws CModelException {
fLocation= location;
IFile[] files= ResourcesPlugin.getWorkspace().getRoot().findFilesForLocation(location);
if (files.length > 0) {
for (int i = 0; i < files.length && fTU == null; i++) {
IFile file = files[i];
fTU= IBConversions.fileToTU(file);
}
}
else {
CoreModel coreModel = CoreModel.getDefault();
fTU= coreModel.createTranslationUnitFrom(preferredProject, location);
if (fTU == null) {
ICProject[] projects= coreModel.getCModel().getCProjects();
for (int i = 0; i < projects.length && fTU == null; i++) {
ICProject project = projects[i];
if (!preferredProject.equals(project)) {
fTU= coreModel.createTranslationUnitFrom(project, location);
}
}
}
}
}
public IPath getLocation() {
return fLocation;
}
public boolean equals(Object obj) {
if (obj instanceof IBFile) {
IBFile file = (IBFile) obj;
return (CoreUtility.safeEquals(fLocation, file.fLocation) &&
CoreUtility.safeEquals(fTU, file.fTU));
}
return super.equals(obj);
}
public int hashCode() {
return CoreUtility.safeHashcode(fLocation) + CoreUtility.safeHashcode(fTU);
}
public ITranslationUnit getTranslationUnit() {
return fTU;
}
public IFile getResource() {
if (fTU != null) {
IResource r= fTU.getResource();
if (r instanceof IFile) {
return (IFile) r;
}
}
return null;
}
}

View file

@ -0,0 +1,132 @@
/*******************************************************************************
* 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.internal.ui.includebrowser;
import java.util.HashMap;
import java.util.Iterator;
import org.eclipse.core.runtime.IPath;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.IColorProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.widgets.Display;
import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.ui.CElementImageDescriptor;
import org.eclipse.cdt.ui.CElementLabelProvider;
import org.eclipse.cdt.internal.ui.CPluginImages;
import org.eclipse.cdt.internal.ui.viewsupport.ImageImageDescriptor;
public class IBLabelProvider extends LabelProvider implements IColorProvider {
private CElementLabelProvider fCLabelProvider= new CElementLabelProvider();
private Color fColorInactive;
private IBContentProvider fContentProvider;
private HashMap fCachedImages= new HashMap();
private boolean fShowFolders;
public IBLabelProvider(Display display, IBContentProvider cp) {
fColorInactive= display.getSystemColor(SWT.COLOR_DARK_GRAY);
fContentProvider= cp;
}
public Image getImage(Object element) {
if (element instanceof IBNode) {
IBNode node= (IBNode) element;
ITranslationUnit tu= node.getRepresentedTranslationUnit();
Image image= tu != null ? fCLabelProvider.getImage(tu) : CPluginImages.get(CPluginImages.IMG_OBJS_TUNIT_HEADER);
return decorateImage(image, node);
}
return super.getImage(element);
}
public String getText(Object element) {
if (element instanceof IBNode) {
IBNode node= (IBNode) element;
IPath path= node.getRepresentedPath();
if (path != null) {
if (fShowFolders) {
return path.lastSegment() + " (" + path.removeLastSegments(1) + ")"; //$NON-NLS-1$ //$NON-NLS-2$
}
return path.lastSegment();
}
return node.getDirectiveName();
}
return super.getText(element);
}
public void dispose() {
fCLabelProvider.dispose();
for (Iterator iter = fCachedImages.values().iterator(); iter.hasNext();) {
Image image = (Image) iter.next();
image.dispose();
}
fCachedImages.clear();
super.dispose();
}
private Image decorateImage(Image image, IBNode node) {
int flags= 0;
if (node.isSystemInclude()) {
flags |= CElementImageDescriptor.SYSTEM_INCLUDE;
}
if (node.isRecursive()) {
flags |= CElementImageDescriptor.RECURSIVE_RELATION;
}
else if (fContentProvider.hasChildren(node)) {
if (fContentProvider.getComputeIncludedBy()) {
flags |= CElementImageDescriptor.REFERENCED_BY;
}
else {
flags |= CElementImageDescriptor.RELATES_TO;
}
}
if (node.getRepresentedTranslationUnit() == null) {
flags |= CElementImageDescriptor.WARNING;
}
if (flags == 0) {
return image;
}
String key= image.toString()+String.valueOf(flags);
Image result= (Image) fCachedImages.get(key);
if (result == null) {
ImageDescriptor desc= new CElementImageDescriptor(
new ImageImageDescriptor(image), flags, new Point(20,16));
result= desc.createImage();
fCachedImages.put(key, result);
}
return result;
}
public Color getBackground(Object element) {
return null;
}
public Color getForeground(Object element) {
if (element instanceof IBNode) {
IBNode node= (IBNode) element;
if (!node.isActiveCode()) {
return fColorInactive;
}
}
return null;
}
public void setShowFolders(boolean show) {
fShowFolders= show;
}
}

View file

@ -0,0 +1,65 @@
/*******************************************************************************
* 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.internal.ui.includebrowser;
import org.eclipse.osgi.util.NLS;
public class IBMessages extends NLS {
private static final String BUNDLE_NAME = "org.eclipse.cdt.internal.ui.includebrowser.IBMessages"; //$NON-NLS-1$
public static String HistoryDropDownAction_ClearHistory_label;
public static String HistoryDropDownAction_tooltip;
public static String HistoryListAction_HistoryDialog_title;
public static String HistoryListAction_HistoryList_label;
public static String HistoryListAction_label;
public static String HistoryListAction_Remove_label;
public static String IBViewPart_falseInputMessage;
public static String IBViewPart_FocusOn_label;
public static String IBViewPart_hideInactive_label;
public static String IBViewPart_hideInactive_tooltip;
public static String IBViewPart_hideSystem_label;
public static String IBViewPart_hideSystem_tooltip;
public static String IBViewPart_IncludedByContentDescription;
public static String IBViewPart_IncludesToContentDescription;
public static String IBViewPart_instructionMessage;
public static String IBViewPart_nextMatch_label;
public static String IBViewPart_nextMatch_tooltip;
public static String IBViewPart_OpenWithMenu_label;
public static String IBViewPart_previousMatch_label;
public static String IBViewPart_previousMatch_tooltip;
public static String IBViewPart_refresh_label;
public static String IBViewPart_refresh_tooltip;
public static String IBViewPart_showFolders_label;
public static String IBViewPart_showFolders_tooltip;
public static String IBViewPart_showInclude_label;
public static String IBViewPart_showIncludedBy_label;
public static String IBViewPart_showIncludedBy_tooltip;
public static String IBViewPart_showIncludesTo_label;
public static String IBViewPart_showIncludesTo_tooltip;
public static String IBViewPart_ShowInMenu_label;
public static String IBViewPart_workspaceScope;
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, IBMessages.class);
}
private IBMessages() {
}
}

View file

@ -0,0 +1,42 @@
###############################################################################
# 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
###############################################################################
IBViewPart_instructionMessage=To display an include hierarchy, drop a c/c++-file onto this view.
IBViewPart_showIncludedBy_label=Show Includers
IBViewPart_showIncludedBy_tooltip=Show Includers
IBViewPart_showIncludesTo_label=Show Files Included
IBViewPart_showInclude_label=Open Include
IBViewPart_showFolders_label=Show Folders
IBViewPart_showFolders_tooltip=Show Folders
IBViewPart_previousMatch_label=Previous Match
IBViewPart_showIncludesTo_tooltip=Show Files Included
IBViewPart_IncludedByContentDescription=Files including ''{0}'' - in {1}
IBViewPart_IncludesToContentDescription=Files included by ''{0}'' - in {1}
IBViewPart_hideInactive_tooltip=Hide Includes from Inactive Code
IBViewPart_previousMatch_tooltip=Show Previous Match
IBViewPart_OpenWithMenu_label=Open With
IBViewPart_hideInactive_label=Hide Inactive Includes
IBViewPart_hideSystem_tooltip=Hide System Includes
IBViewPart_ShowInMenu_label=Show In
IBViewPart_hideSystem_label=Hide System Includes
IBViewPart_workspaceScope=workspace
IBViewPart_refresh_label=Refresh
IBViewPart_FocusOn_label=Focus On ''{0}''
IBViewPart_nextMatch_label=Next Match
IBViewPart_refresh_tooltip=Refresh View Content
IBViewPart_falseInputMessage=Include Hierarchies can be shown for C or C++ files, only. They have to be part of the workspace.
IBViewPart_nextMatch_tooltip=Show Next Match
HistoryListAction_HistoryDialog_title=Include Browser History
HistoryDropDownAction_ClearHistory_label=Clear History
HistoryListAction_Remove_label=Remove
HistoryDropDownAction_tooltip=Show History List
HistoryListAction_HistoryList_label=Select a file to show in the Include Browser:
HistoryListAction_label=Open History...

View file

@ -0,0 +1,186 @@
/*******************************************************************************
* 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.internal.ui.includebrowser;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IPath;
import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.internal.ui.util.CoreUtility;
/**
* Represents a node in the include browser
*/
public class IBNode implements IAdaptable {
private IBNode fParent;
private IBFile fRepresentedFile;
// navigation info
private IBFile fDirectiveFile;
private String fDirectiveName;
private int fDirectiveCharacterOffset;
private int fHashCode;
private boolean fIsSystemInclude= false;
private boolean fIsActive= true;
private boolean fIsRecursive;
/**
* Creates a new node for the include browser
*/
public IBNode(IBNode parent, IBFile represents, IBFile fileOfDirective, String nameOfDirective,
int charOffset) {
fParent= parent;
fRepresentedFile= represents;
fDirectiveFile= fileOfDirective;
fDirectiveName= nameOfDirective;
fDirectiveCharacterOffset= charOffset;
fIsRecursive= computeIsRecursive(fParent, represents.getLocation());
fHashCode= computeHashCode();
}
private int computeHashCode() {
int hashCode= 0;
if (fParent != null) {
hashCode= fParent.hashCode() * 31;
}
if (fDirectiveName != null) {
hashCode+= fDirectiveName.hashCode();
}
else if (fRepresentedFile != null) {
IPath path= fRepresentedFile.getLocation();
if (path != null) {
hashCode+= path.hashCode();
}
}
return hashCode;
}
public int hashCode() {
return fHashCode;
}
public boolean equals(Object o) {
if (!(o instanceof IBNode)) {
return false;
}
IBNode rhs = (IBNode) o;
if (fHashCode != rhs.fHashCode) {
return false;
}
return (CoreUtility.safeEquals(fRepresentedFile, rhs.fRepresentedFile) &&
CoreUtility.safeEquals(fDirectiveName, rhs.fDirectiveName));
}
private boolean computeIsRecursive(IBNode parent, IPath path) {
if (parent == null || path == null) {
return false;
}
if (path.equals(parent.getRepresentedFile().getLocation())) {
return true;
}
return computeIsRecursive(parent.fParent, path);
}
/**
* Returns the parent node or <code>null</code> for the root node.
*/
public IBNode getParent() {
return fParent;
}
/**
* Returns the translation unit that requests the inclusion
*/
public IBFile getRepresentedFile() {
return fRepresentedFile;
}
/**
* Returns whether this is a system include (angle-brackets).
*/
public boolean isSystemInclude() {
return fIsSystemInclude;
}
/**
* Defines whether this is a system include (angle-brackets).
* @see FileInclusionNode#isSystemInclude().
*/
public void setIsSystemInclude(boolean isSystemInclude) {
fIsSystemInclude= isSystemInclude;
}
/**
* Returns whether this inclusion is actually performed with the current set
* of macro definitions. This is true unless the include directive appears within
* a conditional compilation construct (#ifdef/#endif).
*/
public boolean isActiveCode() {
return fIsActive;
}
/**
* Defines whether the inclusion appears in active code.
* @see FileInclusionNode#isInActiveCode().
*/
public void setIsActiveCode(boolean isActiveCode) {
fIsActive= isActiveCode;
}
public boolean isRecursive() {
return fIsRecursive;
}
public int getDirectiveCharacterOffset() {
return fDirectiveCharacterOffset;
}
public IBFile getDirectiveFile() {
return fDirectiveFile;
}
public String getDirectiveName() {
return fDirectiveName;
}
public Object getAdapter(Class adapter) {
if (fRepresentedFile != null) {
if (adapter.isAssignableFrom(ITranslationUnit.class)) {
return fRepresentedFile.getTranslationUnit();
}
if (adapter.isAssignableFrom(IFile.class)) {
return fRepresentedFile.getResource();
}
}
return null;
}
public ITranslationUnit getRepresentedTranslationUnit() {
return fRepresentedFile == null ? null : fRepresentedFile.getTranslationUnit();
}
public IPath getRepresentedPath() {
if (fRepresentedFile == null) {
return null;
}
IFile file= fRepresentedFile.getResource();
if (file != null) {
return file.getFullPath();
}
return fRepresentedFile.getLocation();
}
}

View file

@ -0,0 +1,763 @@
/*******************************************************************************
* 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.internal.ui.includebrowser;
import java.util.ArrayList;
import java.util.Arrays;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.IMenuListener;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.jface.util.LocalSelectionTransfer;
import org.eclipse.jface.viewers.IOpenListener;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.OpenEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerComparator;
import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.search.ui.IContextMenuConstants;
import org.eclipse.swt.SWT;
import org.eclipse.swt.dnd.DND;
import org.eclipse.swt.dnd.DropTarget;
import org.eclipse.swt.dnd.FileTransfer;
import org.eclipse.swt.dnd.Transfer;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeItem;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.IEditorDescriptor;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IMemento;
import org.eclipse.ui.IPageLayout;
import org.eclipse.ui.IViewSite;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPartSite;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.actions.ActionFactory;
import org.eclipse.ui.actions.ContributionItemFactory;
import org.eclipse.ui.actions.OpenFileAction;
import org.eclipse.ui.ide.IDE;
import org.eclipse.ui.part.IShowInSource;
import org.eclipse.ui.part.IShowInTarget;
import org.eclipse.ui.part.IShowInTargetList;
import org.eclipse.ui.part.PageBook;
import org.eclipse.ui.part.ResourceTransfer;
import org.eclipse.ui.part.ShowInContext;
import org.eclipse.ui.part.ViewPart;
import org.eclipse.ui.texteditor.ITextEditor;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.core.resources.FileStorage;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.internal.ui.CPluginImages;
import org.eclipse.cdt.internal.ui.util.ExternalEditorInput;
import org.eclipse.cdt.internal.ui.util.Messages;
import org.eclipse.cdt.internal.ui.viewsupport.ExtendedTreeViewer;
import org.eclipse.cdt.internal.ui.viewsupport.WorkingSetFilterUI;
/**
* The view part for the include browser.
*/
public class IBViewPart extends ViewPart
implements IShowInSource, IShowInTarget, IShowInTargetList {
private static final int MAX_HISTORY_SIZE = 10;
private static final String TRUE = String.valueOf(true);
private static final String KEY_WORKING_SET_FILTER = "workingSetFilter"; //$NON-NLS-1$
private static final String KEY_FILTER_SYSTEM = "systemFilter"; //$NON-NLS-1$
private static final String KEY_FILTER_INACTIVE = "inactiveFilter"; //$NON-NLS-1$
private static final String KEY_INPUT_PATH= "inputPath"; //$NON-NLS-1$
private IMemento fMemento;
private boolean fShowsMessage;
private IBNode fLastNavigationNode;
private ArrayList fHistoryEntries= new ArrayList(MAX_HISTORY_SIZE);
// widgets
private PageBook fPagebook;
private Composite fViewerPage;
private Composite fInfoPage;
private Text fInfoText;
// treeviewer
private IBContentProvider fContentProvider;
private IBLabelProvider fLabelProvider;
private ExtendedTreeViewer fTreeViewer;
// filters, sorter
private IBWorkingSetFilter fWorkingSetFilter;
private ViewerFilter fInactiveFilter;
private ViewerFilter fSystemFilter;
private ViewerComparator fSorterAlphaNumeric;
private ViewerComparator fSorterReferencePosition;
// actions
private Action fIncludedByAction;
private Action fIncludesToAction;
private Action fFilterInactiveAction;
private Action fFilterSystemAction;
private Action fShowFolderInLabelsAction;
private Action fNext;
private Action fPrevious;
private Action fRefresh;
public void setFocus() {
fPagebook.setFocus();
}
public void setMessage(String msg) {
fInfoText.setText(msg);
fPagebook.showPage(fInfoPage);
fShowsMessage= true;
updateDescription();
}
public void setInput(ITranslationUnit input) {
fShowsMessage= false;
boolean isHeader= false;
String contentType= input.getContentTypeId();
if (contentType.equals(CCorePlugin.CONTENT_TYPE_CXXHEADER) ||
contentType.equals(CCorePlugin.CONTENT_TYPE_CHEADER)) {
isHeader= true;
}
fTreeViewer.setInput(null);
if (!isHeader) {
fContentProvider.setComputeIncludedBy(isHeader);
fIncludedByAction.setChecked(isHeader);
fIncludesToAction.setChecked(!isHeader);
updateSorter();
}
fTreeViewer.setInput(input);
fPagebook.showPage(fViewerPage);
updateDescription();
updateHistory(input);
}
public void createPartControl(Composite parent) {
fPagebook = new PageBook(parent, SWT.NULL);
fPagebook.setLayoutData(new GridData(GridData.FILL_BOTH));
createInfoPage();
createViewerPage();
initDragAndDrop();
createActions();
createContextMenu();
getSite().setSelectionProvider(fTreeViewer);
setMessage(IBMessages.IBViewPart_instructionMessage);
initializeActionStates();
restoreInput();
fMemento= null;
}
private void initializeActionStates() {
boolean includedBy= true;
boolean filterSystem= false;
boolean filterInactive= false;
if (fMemento != null) {
filterSystem= TRUE.equals(fMemento.getString(KEY_FILTER_SYSTEM));
filterInactive= TRUE.equals(fMemento.getString(KEY_FILTER_INACTIVE));
}
fIncludedByAction.setChecked(includedBy);
fIncludesToAction.setChecked(!includedBy);
fContentProvider.setComputeIncludedBy(includedBy);
fFilterInactiveAction.setChecked(filterInactive);
fFilterInactiveAction.run();
fFilterSystemAction.setChecked(filterSystem);
fFilterSystemAction.run();
updateSorter();
}
private void restoreInput() {
if (fMemento != null) {
String pathStr= fMemento.getString(KEY_INPUT_PATH);
if (pathStr != null) {
IPath path= Path.fromPortableString(pathStr);
if (path.segmentCount() > 1) {
String name= path.segment(0);
ICProject project= CoreModel.getDefault().getCModel().getCProject(name);
if (project != null) {
ICElement celement;
try {
celement = project.findElement(path);
if (celement instanceof ITranslationUnit) {
setInput((ITranslationUnit) celement);
}
} catch (CModelException e) {
// ignore
}
}
}
}
}
}
public void init(IViewSite site, IMemento memento) throws PartInitException {
fMemento= memento;
super.init(site, memento);
}
public void saveState(IMemento memento) {
if (fWorkingSetFilter != null) {
fWorkingSetFilter.getUI().saveState(memento, KEY_WORKING_SET_FILTER);
}
memento.putString(KEY_FILTER_INACTIVE, String.valueOf(fFilterInactiveAction.isChecked()));
memento.putString(KEY_FILTER_SYSTEM, String.valueOf(fFilterSystemAction.isChecked()));
ITranslationUnit input= getInput();
if (input != null) {
IPath path= input.getPath();
if (path != null) {
memento.putString(KEY_INPUT_PATH, path.toPortableString());
}
}
super.saveState(memento);
}
private void createContextMenu() {
MenuManager manager = new MenuManager();
manager.setRemoveAllWhenShown(true);
manager.addMenuListener(new IMenuListener() {
public void menuAboutToShow(IMenuManager m) {
onContextMenuAboutToShow(m);
}
});
Menu menu = manager.createContextMenu(fTreeViewer.getControl());
fTreeViewer.getControl().setMenu(menu);
IWorkbenchPartSite site = getSite();
site.registerContextMenu(CUIPlugin.ID_INCLUDE_BROWSER, manager, fTreeViewer);
}
private void createViewerPage() {
Display display= getSite().getShell().getDisplay();
fViewerPage = new Composite(fPagebook, SWT.NULL);
fViewerPage.setLayoutData(new GridData(GridData.FILL_BOTH));
fViewerPage.setSize(100, 100);
fViewerPage.setLayout(new FillLayout());
fContentProvider= new IBContentProvider(display);
fLabelProvider= new IBLabelProvider(display, fContentProvider);
fTreeViewer= new ExtendedTreeViewer(fViewerPage);
fTreeViewer.setContentProvider(fContentProvider);
fTreeViewer.setLabelProvider(fLabelProvider);
fTreeViewer.setAutoExpandLevel(2);
fTreeViewer.addOpenListener(new IOpenListener() {
public void open(OpenEvent event) {
onShowInclude(event.getSelection());
}
});
}
private void createInfoPage() {
fInfoPage = new Composite(fPagebook, SWT.NULL);
fInfoPage.setLayoutData(new GridData(GridData.FILL_BOTH));
fInfoPage.setSize(100, 100);
fInfoPage.setLayout(new FillLayout());
fInfoText= new Text(fInfoPage, SWT.WRAP | SWT.READ_ONLY);
}
private void initDragAndDrop() {
IBDropTargetListener dropListener= new IBDropTargetListener(this);
Transfer[] dropTransfers= new Transfer[] {
LocalSelectionTransfer.getTransfer(),
ResourceTransfer.getInstance(),
FileTransfer.getInstance()};
DropTarget dropTarget = new DropTarget(fPagebook, DND.DROP_COPY);
dropTarget.setTransfer(dropTransfers);
dropTarget.addDropListener(dropListener);
Transfer[] dragTransfers= new Transfer[] {
ResourceTransfer.getInstance(),
FileTransfer.getInstance()};
IBDragSourceListener dragListener= new IBDragSourceListener(fTreeViewer);
dragListener.setDependentDropTargetListener(dropListener);
fTreeViewer.addDragSupport(DND.DROP_COPY, dragTransfers, dragListener);
}
private void createActions() {
WorkingSetFilterUI wsFilterUI= new WorkingSetFilterUI(this, fMemento, KEY_WORKING_SET_FILTER) {
protected void onWorkingSetChange() {
updateWorkingSetFilter(this);
}
protected void onWorkingSetNameChange() {
updateDescription();
}
};
fIncludedByAction=
new Action(IBMessages.IBViewPart_showIncludedBy_label, IAction.AS_RADIO_BUTTON) {
public void run() {
if (isChecked()) {
onSetDirection(true);
}
}
};
fIncludedByAction.setToolTipText(IBMessages.IBViewPart_showIncludedBy_tooltip);
CPluginImages.setImageDescriptors(fIncludedByAction, CPluginImages.T_LCL, CPluginImages.IMG_ACTION_SHOW_REF_BY);
fIncludesToAction=
new Action(IBMessages.IBViewPart_showIncludesTo_label, IAction.AS_RADIO_BUTTON) {
public void run() {
if (isChecked()) {
onSetDirection(false);
}
}
};
fIncludesToAction.setToolTipText(IBMessages.IBViewPart_showIncludesTo_tooltip);
CPluginImages.setImageDescriptors(fIncludesToAction, CPluginImages.T_LCL, CPluginImages.IMG_ACTION_SHOW_RELATES_TO);
fInactiveFilter= new ViewerFilter() {
public boolean select(Viewer viewer, Object parentElement, Object element) {
if (element instanceof IBNode) {
IBNode node= (IBNode) element;
return node.isActiveCode();
}
return true;
}
};
fFilterInactiveAction= new Action(IBMessages.IBViewPart_hideInactive_label, IAction.AS_CHECK_BOX) {
public void run() {
if (isChecked()) {
fTreeViewer.addFilter(fInactiveFilter);
}
else {
fTreeViewer.removeFilter(fInactiveFilter);
}
}
};
fFilterInactiveAction.setToolTipText(IBMessages.IBViewPart_hideInactive_tooltip);
CPluginImages.setImageDescriptors(fFilterInactiveAction, CPluginImages.T_LCL, CPluginImages.IMG_ACTION_HIDE_INACTIVE);
fSystemFilter= new ViewerFilter() {
public boolean select(Viewer viewer, Object parentElement, Object element) {
if (element instanceof IBNode) {
IBNode node= (IBNode) element;
return !node.isSystemInclude();
}
return true;
}
};
fFilterSystemAction= new Action(IBMessages.IBViewPart_hideSystem_label, IAction.AS_CHECK_BOX) {
public void run() {
if (isChecked()) {
fTreeViewer.addFilter(fSystemFilter);
}
else {
fTreeViewer.removeFilter(fSystemFilter);
}
}
};
fFilterSystemAction.setToolTipText(IBMessages.IBViewPart_hideSystem_tooltip);
CPluginImages.setImageDescriptors(fFilterSystemAction, CPluginImages.T_LCL, CPluginImages.IMG_ACTION_HIDE_SYSTEM);
fSorterAlphaNumeric= new ViewerComparator();
fSorterReferencePosition= new ViewerComparator() {
public int category(Object element) {
if (element instanceof IBNode) {
return 0;
}
return 1;
}
public int compare(Viewer viewer, Object e1, Object e2) {
if (!(e1 instanceof IBNode)) {
if (!(e2 instanceof IBNode)) {
return 0;
}
return -1;
}
if (!(e2 instanceof IBNode)) {
return 1;
}
IBNode n1= (IBNode) e1;
IBNode n2= (IBNode) e2;
return n1.getDirectiveCharacterOffset() - n2.getDirectiveCharacterOffset();
}
};
fShowFolderInLabelsAction= new Action(IBMessages.IBViewPart_showFolders_label, IAction.AS_CHECK_BOX) {
public void run() {
onShowFolderInLabels(isChecked());
}
};
fShowFolderInLabelsAction.setDescription(IBMessages.IBViewPart_showFolders_tooltip);
fNext = new Action(IBMessages.IBViewPart_nextMatch_label) {
public void run() {
onNextOrPrevious(true);
}
};
fNext.setToolTipText(IBMessages.IBViewPart_nextMatch_tooltip);
CPluginImages.setImageDescriptors(fNext, CPluginImages.T_LCL, CPluginImages.IMG_SHOW_NEXT);
fPrevious = new Action(IBMessages.IBViewPart_previousMatch_label) {
public void run() {
onNextOrPrevious(false);
}
};
fPrevious.setToolTipText(IBMessages.IBViewPart_previousMatch_tooltip);
CPluginImages.setImageDescriptors(fPrevious, CPluginImages.T_LCL, CPluginImages.IMG_SHOW_PREV);
fRefresh = new Action(IBMessages.IBViewPart_refresh_label) {
public void run() {
onRefresh();
}
};
fRefresh.setToolTipText(IBMessages.IBViewPart_refresh_tooltip);
CPluginImages.setImageDescriptors(fRefresh, CPluginImages.T_LCL, CPluginImages.IMG_REFRESH);
// setup action bar
// global action hooks
IActionBars actionBars = getViewSite().getActionBars();
actionBars.setGlobalActionHandler(ActionFactory.NEXT.getId(), fNext);
actionBars.setGlobalActionHandler(ActionFactory.PREVIOUS.getId(), fPrevious);
actionBars.setGlobalActionHandler(ActionFactory.REFRESH.getId(), fRefresh);
actionBars.updateActionBars();
// local toolbar
IToolBarManager tm = actionBars.getToolBarManager();
tm.add(fNext);
tm.add(fPrevious);
tm.add(new Separator());
tm.add(fFilterSystemAction);
tm.add(fFilterInactiveAction);
tm.add(new Separator());
tm.add(fIncludedByAction);
tm.add(fIncludesToAction);
tm.add(new HistoryDropDownAction(this));
tm.add(fRefresh);
// local menu
IMenuManager mm = actionBars.getMenuManager();
// tm.add(fNext);
// tm.add(fPrevious);
// tm.add(new Separator());
wsFilterUI.fillActionBars(actionBars);
mm.add(fIncludedByAction);
mm.add(fIncludesToAction);
mm.add(new Separator());
mm.add(fShowFolderInLabelsAction);
mm.add(new Separator());
mm.add(fFilterSystemAction);
mm.add(fFilterInactiveAction);
}
private TreeItem getNextTreeItem(boolean forward) {
Tree tree= fTreeViewer.getTree();
TreeItem[] selectedNodes= tree.getSelection();
TreeItem selectedItem= null;
for (int i = 0; i < selectedNodes.length; i++) {
TreeItem item = selectedNodes[i];
if (item.getData() instanceof IBNode) {
selectedItem= item;
break;
}
}
if (selectedItem == null) {
// try to obtain an include on level 1;
if (tree.getItemCount() > 0) {
selectedItem= tree.getItem(0);
int itemCount= selectedItem.getItemCount();
if (itemCount > 0) {
return selectedItem.getItem(forward ? 0 : itemCount-1);
}
}
return null;
}
IBNode selectedNode= (IBNode) selectedItem.getData();
if (!selectedNode.equals(fLastNavigationNode)) {
return selectedItem;
}
TreeItem parentItem= selectedItem.getParentItem();
int itemCount = parentItem.getItemCount();
if (parentItem != null && itemCount > 1) {
int index= parentItem.indexOf(selectedItem);
index = (index + (forward ? 1 : itemCount-1)) % itemCount;
return parentItem.getItem(index);
}
return null;
}
protected void onNextOrPrevious(boolean forward) {
TreeItem nextItem= getNextTreeItem(forward);
if (nextItem != null && nextItem.getData() instanceof IBNode) {
StructuredSelection sel= new StructuredSelection(nextItem.getData());
fTreeViewer.setSelection(sel);
onShowInclude(sel);
}
}
protected void onRefresh() {
fContentProvider.recompute();
}
protected void onShowFolderInLabels(boolean show) {
fLabelProvider.setShowFolders(show);
fTreeViewer.refresh();
}
protected void updateHistory(ITranslationUnit input) {
if (input != null) {
fHistoryEntries.remove(input);
fHistoryEntries.add(0, input);
if (fHistoryEntries.size() > MAX_HISTORY_SIZE) {
fHistoryEntries.remove(MAX_HISTORY_SIZE-1);
}
}
}
protected void updateSorter() {
if (fIncludedByAction.isChecked()) {
fTreeViewer.setComparator(fSorterAlphaNumeric);
}
else {
fTreeViewer.setComparator(fSorterReferencePosition);
}
}
protected void updateDescription() {
String message= ""; //$NON-NLS-1$
if (!fShowsMessage) {
ITranslationUnit tu= getInput();
if (tu != null) {
IPath path= tu.getPath();
if (path != null) {
String format, file, scope;
file= path.lastSegment() + "(" + path.removeLastSegments(1) + ")"; //$NON-NLS-1$//$NON-NLS-2$
if (fWorkingSetFilter == null) {
scope= IBMessages.IBViewPart_workspaceScope;
}
else {
scope= fWorkingSetFilter.getLabel();
}
if (fIncludedByAction.isChecked()) {
format= IBMessages.IBViewPart_IncludedByContentDescription;
}
else {
format= IBMessages.IBViewPart_IncludesToContentDescription;
}
message= Messages.format(format, file, scope);
}
}
}
message= "The Include Browser is work in progress! - " + message; //$NON-NLS-1$
setContentDescription(message);
}
protected void updateWorkingSetFilter(WorkingSetFilterUI filterUI) {
if (filterUI.getWorkingSet() == null) {
if (fWorkingSetFilter != null) {
fTreeViewer.removeFilter(fWorkingSetFilter);
fWorkingSetFilter= null;
}
}
else {
if (fWorkingSetFilter != null) {
fTreeViewer.refresh();
}
else {
fWorkingSetFilter= new IBWorkingSetFilter(filterUI);
fTreeViewer.addFilter(fWorkingSetFilter);
}
}
}
protected void onSetDirection(boolean includedBy) {
if (includedBy != fContentProvider.getComputeIncludedBy()) {
Object input= fTreeViewer.getInput();
fTreeViewer.setInput(null);
fContentProvider.setComputeIncludedBy(includedBy);
updateSorter();
fTreeViewer.setInput(input);
updateDescription();
}
}
protected void onContextMenuAboutToShow(IMenuManager m) {
final IStructuredSelection selection = (IStructuredSelection) fTreeViewer.getSelection();
final IBNode node= IBConversions.selectionToNode(selection);
if (node != null) {
final IWorkbenchPage page = getSite().getPage();
// open include
if (node.getParent() != null && node.getDirectiveFile() != null) {
m.add(new Action(IBMessages.IBViewPart_showInclude_label) {
public void run() {
onShowInclude(selection);
}
});
}
final ITranslationUnit tu= node.getRepresentedTranslationUnit();
if (tu != null) {
// open
OpenFileAction ofa= new OpenFileAction(page);
ofa.selectionChanged(selection);
m.add(ofa);
// open with
// keep the menu shorter, no open with support
// final IResource r= tu.getResource();
// if (r != null) {
// IMenuManager submenu= new MenuManager(IBMessages.IBViewPart_OpenWithMenu_label);
// submenu.add(new OpenWithMenu(page, r));
// m.add(submenu);
// }
// show in
IMenuManager submenu= new MenuManager(IBMessages.IBViewPart_ShowInMenu_label);
submenu.add(ContributionItemFactory.VIEWS_SHOW_IN.create(getSite().getWorkbenchWindow()));
m.add(submenu);
if (node.getParent() != null) {
m.add(new Separator());
m.add(new Action(Messages.format(IBMessages.IBViewPart_FocusOn_label, tu.getPath().lastSegment())) {
public void run() {
setInput(tu);
}
});
}
}
}
m.add(new Separator(IContextMenuConstants.GROUP_ADDITIONS));
}
protected void onShowInclude(ISelection selection) {
IBNode node= IBConversions.selectionToNode(selection);
if (node != null) {
IWorkbenchPage page= getSite().getPage();
IBFile ibf= node.getDirectiveFile();
if (ibf != null) {
IEditorPart editor= null;
int offset= node.getDirectiveCharacterOffset();
int length= node.getDirectiveName().length() + 2;
IFile f= ibf.getResource();
if (f != null) {
fLastNavigationNode= node;
// mstodo position tracker
try {
editor= IDE.openEditor(page, f, false);
} catch (PartInitException e) {
CUIPlugin.getDefault().log(e);
}
}
else {
IPath location= ibf.getLocation();
if (location != null) {
fLastNavigationNode= node;
ExternalEditorInput ei= new ExternalEditorInput(new FileStorage(null, location));
try {
IEditorDescriptor descriptor = IDE.getEditorDescriptor(location.lastSegment());
editor= IDE.openEditor(page, ei, descriptor.getId(), false);
} catch (PartInitException e) {
CUIPlugin.getDefault().log(e);
}
}
}
if (editor instanceof ITextEditor) {
ITextEditor te= (ITextEditor) editor;
te.selectAndReveal(offset, length);
}
}
else {
ITranslationUnit tu= IBConversions.selectionToTU(selection);
if (tu != null) {
IResource r= tu.getResource();
if (r != null) {
OpenFileAction ofa= new OpenFileAction(page);
ofa.selectionChanged((IStructuredSelection) selection);
ofa.run();
}
}
}
}
}
public ShowInContext getShowInContext() {
return new ShowInContext(null, fTreeViewer.getSelection());
}
public boolean show(ShowInContext context) {
ITranslationUnit tu= IBConversions.selectionToTU(context.getSelection());
if (tu == null) {
tu= IBConversions.objectToTU(context.getInput());
if (tu == null) {
setMessage(IBMessages.IBViewPart_falseInputMessage);
return false;
}
}
setInput(tu);
return true;
}
public String[] getShowInTargetIds() {
return new String[] {
CUIPlugin.CVIEW_ID,
IPageLayout.ID_RES_NAV
};
}
public Control getPageBook() {
return fPagebook;
}
public ITranslationUnit[] getHistoryEntries() {
return (ITranslationUnit[]) fHistoryEntries.toArray(new ITranslationUnit[fHistoryEntries.size()]);
}
public void setHistoryEntries(ITranslationUnit[] remaining) {
fHistoryEntries.clear();
fHistoryEntries.addAll(Arrays.asList(remaining));
}
public ITranslationUnit getInput() {
Object input= fTreeViewer.getInput();
if (input instanceof ITranslationUnit) {
return (ITranslationUnit) input;
}
return null;
}
}

View file

@ -0,0 +1,49 @@
/*******************************************************************************
* 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.internal.ui.includebrowser;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.ui.IWorkingSet;
import org.eclipse.cdt.internal.ui.viewsupport.WorkingSetFilterUI;
public class IBWorkingSetFilter extends ViewerFilter {
private WorkingSetFilterUI fWorkingSetFilter;
public IBWorkingSetFilter(WorkingSetFilterUI wsFilter) {
fWorkingSetFilter= wsFilter;
}
public boolean select(Viewer viewer, Object parentElement, Object element) {
if (parentElement instanceof IBNode && element instanceof IBNode) {
IBNode node= (IBNode) element;
if (!fWorkingSetFilter.isPartOfWorkingSet(node.getRepresentedTranslationUnit())) {
return false;
}
}
return true;
}
public WorkingSetFilterUI getUI() {
return fWorkingSetFilter;
}
public String getLabel() {
IWorkingSet ws= fWorkingSetFilter.getWorkingSet();
if (ws != null) {
return ws.getLabel();
}
return IBMessages.IBViewPart_workspaceScope;
}
}

View file

@ -0,0 +1,125 @@
/*******************************************************************************
* 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.internal.ui.missingapi;
import java.util.ArrayList;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMFile;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMInclude;
public class CIndexQueries {
public static class IPDOMInclude {
private PDOMInclude fInclude;
public IPDOMInclude(PDOMInclude include) {
fInclude= include;
}
public boolean isSystemInclude() {
return false;
}
public boolean isActiveCode() {
return true;
}
public IPath getIncludedBy() throws CoreException {
return Path.fromOSString(fInclude.getIncludedBy().getFileName().getString());
}
public IPath getIncludes() throws CoreException {
return Path.fromOSString(fInclude.getIncludes().getFileName().getString());
}
public String getName() throws CoreException {
return Path.fromOSString(fInclude.getIncludes().getFileName().getString()).lastSegment();
}
public int getOffset() {
return 9;
}
}
private static final IPDOMInclude[] EMPTY_INCLUDES = new IPDOMInclude[0];
private static final CIndexQueries sInstance= new CIndexQueries();
public static CIndexQueries getInstance() {
return sInstance;
}
public static ITranslationUnit toTranslationUnit(ICProject cproject, PDOMFile includedBy) throws CoreException {
String name= includedBy.getFileName().getString();
IPath path= Path.fromOSString(name);
ICElement e= cproject.findElement(path);
if (e instanceof ITranslationUnit) {
return (ITranslationUnit) e;
}
return null;
}
private CIndexQueries() {
}
public IPDOMInclude[] findIncludedBy(ITranslationUnit tu, IProgressMonitor pm) throws CoreException {
ICProject cproject= tu.getCProject();
if (cproject != null) {
PDOM pdom= (PDOM) CCorePlugin.getPDOMManager().getPDOM(cproject);
if (pdom != null) {
PDOMFile fileTarget= pdom.getFile(locationForTU(tu));
if (fileTarget != null) {
ArrayList result= new ArrayList();
PDOMInclude include= fileTarget.getFirstIncludedBy();
while (include != null) {
result.add(new IPDOMInclude(include));
include= include.getNextInIncludedBy();
}
return (IPDOMInclude[]) result.toArray(new IPDOMInclude[result.size()]);
}
}
}
return EMPTY_INCLUDES;
}
private IPath locationForTU(ITranslationUnit tu) {
IResource r= tu.getResource();
if (r != null) {
return r.getLocation();
}
return tu.getPath();
}
public IPDOMInclude[] findIncludesTo(ITranslationUnit tu, IProgressMonitor pm) throws CoreException {
ICProject cproject= tu.getCProject();
if (cproject != null) {
PDOM pdom= (PDOM) CCorePlugin.getPDOMManager().getPDOM(cproject);
if (pdom != null) {
PDOMFile fileTarget= pdom.getFile(locationForTU(tu));
if (fileTarget != null) {
ArrayList result= new ArrayList();
PDOMInclude include= fileTarget.getFirstInclude();
while (include != null) {
result.add(new IPDOMInclude(include));
include= include.getNextInIncludes();
}
return (IPDOMInclude[]) result.toArray(new IPDOMInclude[result.size()]);
}
}
}
return EMPTY_INCLUDES;
}
}

View file

@ -7,6 +7,7 @@
*
* Contributors:
* QNX Software Systems - initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.ui.util;
@ -69,6 +70,26 @@ public class CoreUtility {
if (exc[0] != null)
throw exc[0];
return ret[0];
}
/**
* Calls equals after checking for nulls
*/
public static boolean safeEquals(Object lhs, Object rhs) {
if (lhs==rhs) {
return true;
}
if (lhs == null || rhs == null) {
return false;
}
return lhs.equals(rhs);
}
/**
* Calls hashCode after checking for null
*/
public static int safeHashcode(Object o) {
return o == null ? 0 : o.hashCode();
}
}

View file

@ -0,0 +1,36 @@
/*******************************************************************************
* 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.internal.ui.util;
import java.text.MessageFormat;
public class Messages {
public static String format(String pattern, Object[] args) {
return MessageFormat.format(pattern, args);
}
public static String format(String pattern, Object arg0) {
return format(pattern, new Object[] {arg0});
}
public static String format(String pattern, Object arg0, Object arg1) {
return format(pattern, new Object[] {arg0, arg1});
}
public static String format(String pattern, Object arg0, Object arg1, Object arg2) {
return format(pattern, new Object[] {arg0, arg1, arg2});
}
public static String format(String pattern, Object arg0, Object arg1, Object arg2, Object arg3) {
return format(pattern, new Object[] {arg0, arg1, arg2, arg3});
}
}

View file

@ -0,0 +1,340 @@
/*******************************************************************************
* 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.internal.ui.viewsupport;
import java.util.*;
import org.eclipse.cdt.internal.ui.CUIMessages;
import org.eclipse.core.runtime.*;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.viewers.*;
import org.eclipse.swt.SWTException;
import org.eclipse.swt.widgets.Display;
/**
* A TreeContentProvider that supports asyncronous computation of child nodes.
* <p>
* While a computation for children is in progress an object of type {@link AsyncTreeWorkInProgressNode}
* is returned as a child. On completion of the computation the viewer will be refreshed with the actual
* children.
*/
public abstract class AsyncTreeContentProvider implements ITreeContentProvider {
private static final int PRIORITY_LOW = 0;
private static final int PRIORITY_HIGH = 10;
protected static final Object[] NO_CHILDREN = new Object[0];
private Object fInput;
private HashMap fChildNodes= new HashMap();
private HashSet fHighPriorityTasks= new HashSet();
private HashSet fLowPriorityTasks= new HashSet();
private HashMap fViewUpdates= new HashMap();
private int fViewUpdateDelta;
private Job fJob;
private Display fDisplay;
private TreeViewer fTreeViewer= null;
private Runnable fScheduledViewupdate= null;
private HashSet fAutoexpand;
private Object fAutoSelect;
public AsyncTreeContentProvider(Display disp) {
fDisplay= disp;
fJob= new Job(CUIMessages.getString("AsyncTreeContentProvider.JobName")) { //$NON-NLS-1$
protected IStatus run(final IProgressMonitor monitor) {
return runJob(monitor);
}
};
fJob.setSystem(true);
}
/**
* {@inheritDoc}
* <p>
* This implementation returns the parent for nodes indicating asyncronous computation.
* It returns <code>null</code> for all other elements. It should be overridden and
* called by derived classes.
*/
public Object getParent(Object element) {
if (element instanceof AsyncTreeWorkInProgressNode) {
AsyncTreeWorkInProgressNode wipNode = (AsyncTreeWorkInProgressNode) element;
return wipNode.getParent();
}
return null;
}
/**
* Returns the child elements of the given parent element, or <code>null</code>.
* <p>
* The method is called within the UI-thread and shall therefore return null in case
* the computation of the children may take longer.
* </p>
* The result is neither modified by the content provider nor the viewer.
*
* @param parentElement the parent element
* @return an array of child elements, or <code>null</code>
*/
public Object[] syncronouslyComputeChildren(Object parentElement) {
return null;
}
/**
* Returns the child elements of the given parent element.
* <p>
* The method is called outside the UI-thread. There is no need to report progress, the monitor
* is supplied such that implementations can check for cancel requests.
* </p>
* The result is neither modified by the content provider nor the viewer.
*
* @param parentElement the parent element
* @param monitor the monitor that can be checked for a cancel event.
* @return an array of child elements.
*/
public Object[] asyncronouslyComputeChildren(Object parentElement, IProgressMonitor monitor) {
return NO_CHILDREN;
}
/**
* Clears all caches and stops asyncronous computations. As a consequence
* child nodes requested by the viewer have to be computed from scratch.
* <p>
* Derived classes may override this method but must call <code>super.clearCaches()</code>.
*/
protected void clear() {
fChildNodes.clear();
synchronized (fHighPriorityTasks) {
fScheduledViewupdate= null;
fHighPriorityTasks.clear();
fLowPriorityTasks.clear();
fViewUpdates.clear();
}
}
/**
* Recomputes all of the nodes, trying to keep the expanded state even with async
* computations.
*/
public void recompute() {
fAutoexpand= new HashSet();
fAutoexpand.addAll(Arrays.asList(fTreeViewer.getVisibleExpandedElements()));
fAutoSelect= null;
fAutoSelect= ((IStructuredSelection) fTreeViewer.getSelection()).getFirstElement();
clear();
refreshViewer();
}
/**
* Refreshes the viewer
*/
private void refreshViewer() {
if (fTreeViewer != null) {
fTreeViewer.refresh();
}
}
final public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
if (newInput != oldInput) {
clear();
fInput= newInput;
}
if (viewer instanceof TreeViewer) {
fTreeViewer= (TreeViewer) viewer;
}
else {
fTreeViewer= null;
}
}
final public Object getInput() {
return fInput;
}
final public Object[] getElements(Object inputElement) {
return getChildren(inputElement);
}
final public Object[] getChildren(Object parentElement) {
Object[] children = internalGetChildren(parentElement);
if (children == null) {
scheduleQuery(parentElement, PRIORITY_HIGH);
return new Object[] {new AsyncTreeWorkInProgressNode(parentElement)};
}
return children;
}
final public boolean hasChildren(Object element) {
assert Display.getCurrent() != null;
Object[] children= internalGetChildren(element);
if (children == null) {
scheduleQuery(element, PRIORITY_LOW);
return true;
}
return children.length > 0;
}
public void dispose() {
fTreeViewer= null;
clear();
}
private void scheduleQuery(Object element, int priority) {
synchronized(fHighPriorityTasks) {
if (priority == PRIORITY_HIGH) {
if (!fHighPriorityTasks.contains(element)) {
fHighPriorityTasks.add(element);
fLowPriorityTasks.remove(element);
}
}
else {
if (!fHighPriorityTasks.contains(element) &&
!fLowPriorityTasks.contains(element)) {
fLowPriorityTasks.add(element);
}
}
fJob.schedule();
}
}
private IStatus runJob(final IProgressMonitor monitor) {
monitor.beginTask(CUIMessages.getString("AsyncTreeContentProvider.TaskName"), IProgressMonitor.UNKNOWN); //$NON-NLS-1$
try {
Object parent= getParentForNextTask();
while (parent != null) {
Object[] children= asyncronouslyComputeChildren(parent, monitor);
synchronized (fHighPriorityTasks) {
if (fHighPriorityTasks.remove(parent) || fLowPriorityTasks.remove(parent)) {
fViewUpdates.put(parent, children);
scheduleViewerUpdate();
}
}
parent= getParentForNextTask();
}
return Status.OK_STATUS;
}
finally {
monitor.done();
}
}
private void scheduleViewerUpdate() {
Runnable runme= null;
synchronized(fHighPriorityTasks) {
if (fScheduledViewupdate != null) {
return;
}
runme= fScheduledViewupdate= new Runnable(){
public void run() {
HashMap updates= null;
synchronized(fHighPriorityTasks) {
if (fViewUpdates.isEmpty()) {
fScheduledViewupdate= null;
return;
}
if (fScheduledViewupdate != this) {
return;
}
updates= fViewUpdates;
fViewUpdates= new HashMap();
}
fChildNodes.putAll(updates);
if (fTreeViewer instanceof ExtendedTreeViewer) {
((ExtendedTreeViewer) fTreeViewer).refresh(updates.keySet().toArray());
}
else if (fTreeViewer != null) {
for (Iterator iter = updates.keySet().iterator(); iter.hasNext();) {
fTreeViewer.refresh(iter.next());
}
}
for (Iterator iter = updates.values().iterator(); iter.hasNext();) {
checkForAutoExpand((Object[]) iter.next());
}
fViewUpdateDelta= Math.min(1000, fViewUpdateDelta*2);
fDisplay.timerExec(fViewUpdateDelta, this);
}
};
}
try {
fViewUpdateDelta= 32;
fDisplay.asyncExec(runme);
}
catch (SWTException e) {
// display may have been disposed.
}
}
private void checkForAutoExpand(Object[] objects) {
if (fTreeViewer == null) {
return;
}
if (fAutoexpand != null && !fAutoexpand.isEmpty()) {
for (int i = 0; i < objects.length; i++) {
Object object = objects[i];
if (fAutoexpand.remove(object)) {
fTreeViewer.setExpandedState(object, true);
}
if (object.equals(fAutoSelect)) {
if (fTreeViewer.getSelection().isEmpty()) {
fTreeViewer.setSelection(new StructuredSelection(object));
}
fAutoSelect= null;
}
}
}
if (fAutoSelect != null) {
if (fTreeViewer.getSelection().isEmpty()) {
for (int i = 0; i < objects.length; i++) {
Object object = objects[i];
if (object.equals(fAutoSelect)) {
fTreeViewer.setSelection(new StructuredSelection(object));
fAutoSelect= null;
}
}
}
else {
fAutoSelect= null;
}
}
}
private final Object getParentForNextTask() {
synchronized(fHighPriorityTasks) {
Object parent= null;
if (!fHighPriorityTasks.isEmpty()) {
parent= fHighPriorityTasks.iterator().next();
}
else if (!fLowPriorityTasks.isEmpty()) {
parent= fLowPriorityTasks.iterator().next();
}
return parent;
}
}
private Object[] internalGetChildren(Object parentElement) {
assert Display.getCurrent() != null;
if (parentElement instanceof AsyncTreeWorkInProgressNode) {
return NO_CHILDREN;
}
Object[] children= (Object[]) fChildNodes.get(parentElement);
if (children == null) {
children= syncronouslyComputeChildren(parentElement);
if (children != null) {
final Object[] finalChildren= children;
fChildNodes.put(parentElement, children);
fDisplay.asyncExec(new Runnable() {
public void run() {
checkForAutoExpand(finalChildren);
}});
}
}
return children;
}
}

View file

@ -0,0 +1,27 @@
/*******************************************************************************
* 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.internal.ui.viewsupport;
public class AsyncTreeWorkInProgressNode {
private Object fParent;
public AsyncTreeWorkInProgressNode(Object parentElement) {
fParent= parentElement;
}
public Object getParent() {
return fParent;
}
public String toString() {
return "..."; //$NON-NLS-1$
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2003, 2005 IBM Corporation and others.
* Copyright (c) 2003, 2006 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,12 +7,18 @@
*
* Contributors:
* IBM Corp. - Rational Software - initial implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/
/*
* Created on Jun 24, 2003
*/
package org.eclipse.cdt.internal.ui.viewsupport;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IPath;
import org.eclipse.ui.model.IWorkbenchAdapter;
import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.IBinary;
import org.eclipse.cdt.core.model.ICContainer;
@ -20,12 +26,11 @@ import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.IMethod;
import org.eclipse.cdt.core.model.ISourceRoot;
import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.internal.corext.util.CModelUtil;
import org.eclipse.cdt.internal.ui.CUIMessages;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.ui.model.IWorkbenchAdapter;
import org.eclipse.cdt.internal.corext.util.CModelUtil;
import org.eclipse.cdt.internal.ui.CUIMessages;
/**
* @author aniefer
@ -353,7 +358,7 @@ public class CElementLabels {
for (int i= 0; i < nParams; i++) {
if (i > 0) {
buf.append( COMMA_STRING ); //$NON-NLS-1$
buf.append( COMMA_STRING );
}
if (types != null) {
@ -441,19 +446,31 @@ public class CElementLabels {
* Appends the label for a translation unit to a StringBuffer. Considers the CU_* flags.
*/
public static void getTranslationUnitLabel(ITranslationUnit tu, int flags, StringBuffer buf) {
if (getFlag(flags, CU_QUALIFIED)) {
ISourceRoot root= CModelUtil.getSourceRoot(tu);
// if (!pack.isDefaultPackage()) {
buf.append(root.getElementName());
buf.append('.');
// }
IResource r= tu.getResource();
IPath path;
if (r != null) {
path= r.getFullPath().makeRelative();
}
else {
path= tu.getPath();
}
buf.append(tu.getElementName());
if (getFlag(flags, CU_POST_QUALIFIED)) {
buf.append(CONCAT_STRING);
getSourceRootLabel((ISourceRoot) tu.getParent(), 0, buf);
}
if (path == null) {
buf.append(tu.getElementName());
}
else {
if (getFlag(flags, CU_QUALIFIED)) {
buf.append(path.toString());
}
else if (getFlag(flags, CU_POST_QUALIFIED)) {
buf.append(path.lastSegment());
buf.append(CONCAT_STRING);
buf.append(path.removeLastSegments(1));
}
else {
buf.append(path.lastSegment());
}
}
}
/**

View file

@ -0,0 +1,49 @@
/*******************************************************************************
* 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.internal.ui.viewsupport;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.swt.widgets.Composite;
public class ExtendedTreeViewer extends TreeViewer {
private boolean fPreservingSelection= false;
public ExtendedTreeViewer(Composite parent) {
super(parent);
}
public void refresh(final Object[] elements) {
preservingSelection(new Runnable() {
public void run() {
for (int i = 0; i < elements.length; i++) {
refresh(elements[i]);
}
}
});
}
protected void preservingSelection(Runnable updateCode) {
if (fPreservingSelection) {
updateCode.run();
}
else {
fPreservingSelection= true;
try {
super.preservingSelection(updateCode);
}
finally {
fPreservingSelection= false;
}
}
}
}

View file

@ -0,0 +1,74 @@
/*******************************************************************************
* 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.internal.ui.viewsupport;
import java.util.HashMap;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IPath;
import org.eclipse.ui.IWorkingSet;
public class WorkingSetFilter {
private static final Object ACCEPT = new Object();
private static final Object REJECT = new Object();
private HashMap fResourceFilter= null;
public synchronized boolean isPartOfWorkingSet(ICElement elem) {
if (fResourceFilter == null) {
return true;
}
IPath path= elem.getPath();
if (path == null) {
return false;
}
Object check= fResourceFilter.get(path);
if (check == null) {
check= checkWorkingSet(path);
fResourceFilter.put(path, check);
}
return check == ACCEPT;
}
private synchronized Object checkWorkingSet(IPath path) {
if (path.segmentCount() == 0) {
return REJECT;
}
Object result= fResourceFilter.get(path);
if (result == null) {
result= checkWorkingSet(path.removeLastSegments(1));
fResourceFilter.put(path, result);
}
return result;
}
public synchronized void setWorkingSet(IWorkingSet workingSetFilter) {
if (workingSetFilter == null) {
fResourceFilter= null;
}
else {
IAdaptable[] input = workingSetFilter.getElements();
fResourceFilter = new HashMap();
for (int i = 0; i < input.length; i++) {
IAdaptable adaptable = input[i];
IResource res = (IResource) adaptable.getAdapter(IResource.class);
if (res != null) {
fResourceFilter.put(res.getFullPath(), ACCEPT);
}
}
}
}
}

View file

@ -0,0 +1,170 @@
/*******************************************************************************
* 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.internal.ui.viewsupport;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.ui.*;
import org.eclipse.ui.actions.WorkingSetFilterActionGroup;
/**
* Wraps {@link WorkingSetFilterActionGroup} and handles the property changed
* events
*/
public abstract class WorkingSetFilterUI {
private IPropertyChangeListener fWorkingSetListener;
private IWorkingSet fWorkingSet;
WorkingSetFilterActionGroup fWorkingSetFilterGroup;
private IViewPart fViewPart;
private WorkingSetFilter fWorkingSetFilter= null;
private IWorkingSetManager fWSManager;
public WorkingSetFilterUI(IViewPart viewPart, IMemento memento, String key) {
fWSManager= PlatformUI.getWorkbench().getWorkingSetManager();
fViewPart= viewPart;
if (memento != null) {
memento= memento.getChild(key);
if (memento != null) {
IWorkingSet ws= fWSManager.createWorkingSet(memento);
if (ws != null) {
fWorkingSet= fWSManager.getWorkingSet(ws.getName());
if (fWorkingSet == null) {
fWorkingSet= ws;
fWSManager.addWorkingSet(ws);
}
}
}
}
fWorkingSetListener = new IPropertyChangeListener() {
public void propertyChange(org.eclipse.jface.util.PropertyChangeEvent event) {
onWorkingSetPropertyChange(event);
}
};
fWSManager.addPropertyChangeListener(fWorkingSetListener);
IPropertyChangeListener workingSetUpdater = new IPropertyChangeListener() {
public void propertyChange(PropertyChangeEvent event) {
onWorkingSetFilterUpdate(event);
}
};
fWorkingSetFilterGroup= new WorkingSetFilterActionGroup(fViewPart.getSite().getShell(), workingSetUpdater);
fWorkingSetFilterGroup.setWorkingSet(fWorkingSet);
}
public void dispose() {
fWSManager.removePropertyChangeListener(fWorkingSetListener);
fWorkingSetFilterGroup.dispose();
}
private void applyWorkingSetFilter() {
if (fWorkingSet == null) {
fWorkingSetFilter = null;
}
else {
fWorkingSetFilter = new WorkingSetFilter();
fWorkingSetFilter.setWorkingSet(fWorkingSet);
}
}
protected void onWorkingSetPropertyChange(PropertyChangeEvent evt) {
if (fWorkingSet == null) {
return;
}
boolean doRefresh = false;
String propertyName = evt.getProperty();
Object newValue = evt.getNewValue();
Object oldValue = evt.getOldValue();
if (propertyName.equals(IWorkingSetManager.CHANGE_WORKING_SET_CONTENT_CHANGE)) {
if (fWorkingSet == newValue) { // weired, but this is how it works
doRefresh = true;
}
}
else if (propertyName.equals(IWorkingSetManager.CHANGE_WORKING_SET_NAME_CHANGE)) {
if (fWorkingSet == newValue) {
onWorkingSetNameChange();
}
}
else if (propertyName.equals(IWorkingSetManager.CHANGE_WORKING_SET_REMOVE)) {
if (fWorkingSet == oldValue) {
fWorkingSet = null;
doRefresh = true;
}
}
if (doRefresh) {
applyWorkingSetFilter();
onWorkingSetChange();
}
}
protected void onWorkingSetFilterUpdate(PropertyChangeEvent event) {
String property = event.getProperty();
if (WorkingSetFilterActionGroup.CHANGE_WORKING_SET.equals(property)) {
Object newValue = event.getNewValue();
if (newValue instanceof IWorkingSet) {
fWorkingSet = (IWorkingSet) newValue;
fWSManager.addRecentWorkingSet(fWorkingSet);
}
else {
fWorkingSet = null;
}
applyWorkingSetFilter();
onWorkingSetChange();
onWorkingSetNameChange();
}
}
protected abstract void onWorkingSetChange();
protected abstract void onWorkingSetNameChange();
public void fillActionBars(IActionBars actionBars) {
fWorkingSetFilterGroup.fillActionBars(actionBars);
}
public boolean isPartOfWorkingSet(ICElement element) {
if (fWorkingSetFilter == null) {
return true;
}
return fWorkingSetFilter.isPartOfWorkingSet(element);
}
public IWorkingSet getWorkingSet() {
return fWorkingSet;
}
public void setWorkingSet(IWorkingSet workingSet) {
fWorkingSet= workingSet;
fWorkingSetFilterGroup.setWorkingSet(fWorkingSet);
}
public List getRecent() {
IWorkingSet[] workingSets= fWSManager.getRecentWorkingSets();
ArrayList result= new ArrayList(workingSets.length);
for (int i = 0; i < workingSets.length; i++) {
result.add(workingSets[i].getName());
}
return result;
}
public void saveState(IMemento memento, String key) {
if (fWorkingSet != null) {
fWorkingSet.saveState(memento.createChild(key));
}
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000 2005 IBM Corporation and others.
* Copyright (c) 2000, 2006 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
@ -8,6 +8,7 @@
* Contributors:
* IBM Corporation - initial API and implementation
* QNX Software System
* Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.ui;
@ -52,7 +53,7 @@ public class CElementImageDescriptor extends CompositeImageDescriptor {
public final static int RUNNABLE= 0x010;
/** Flag to render the waring adornment */
public final static int WARNING= 0x020;
public final static int WARNING= 0x020;
/** Flag to render the error adornment */
public final static int ERROR= 0x040;
@ -61,7 +62,19 @@ public class CElementImageDescriptor extends CompositeImageDescriptor {
public final static int OVERRIDES= 0x080;
/** Flag to render the 'implements' adornment */
public final static int IMPLEMENTS= 0x100;
public final static int IMPLEMENTS= 0x100;
/** Flag to render the 'relates to' adornment (for trees, an arrow down) */
public final static int RELATES_TO= 0x200;
/** Flag to render the 'referenced by' adornment (for trees, an arrow up) */
public final static int REFERENCED_BY= 0x400;
/** Flag to render the 'recursive relation' adornment (for trees, an arrow pointing back) */
public final static int RECURSIVE_RELATION= 0x800;
/** Flag to render the 'system include' adornment */
public final static int SYSTEM_INCLUDE= 0x1000;
private ImageDescriptor fBaseImage;
private int fFlags;
@ -188,12 +201,32 @@ public class CElementImageDescriptor extends CompositeImageDescriptor {
x-= data.width;
drawImage(data, x, 0);
}
if ((fFlags & SYSTEM_INCLUDE) != 0) {
data= CPluginImages.DESC_OVR_SYSTEM_INCLUDE.getImageData();
x-= data.width;
drawImage(data, x, 0);
}
}
private void drawBottomRight() {
//Point size= getSize();
//int x= size.x;
//ImageData data= null;
Point size= getSize();
int x= size.x;
ImageData data= null;
if ((fFlags & RECURSIVE_RELATION) != 0) {
data= CPluginImages.DESC_OVR_REC_RELATESTO.getImageData();
x-= data.width;
drawImage(data, x, size.y-data.height);
}
else if ((fFlags & RELATES_TO) != 0) {
data= CPluginImages.DESC_OVR_RELATESTO.getImageData();
x-= data.width;
drawImage(data, x, size.y-data.height);
}
else if ((fFlags & REFERENCED_BY) != 0) {
data= CPluginImages.DESC_OVR_REFERENCEDBY.getImageData();
x-= data.width;
drawImage(data, x, size.y-data.height);
}
/*if ((fFlags & SYNCHRONIZED) != 0) {
data= CPluginImages.DESC_OVR_SYNCH.getImageData();
x-= data.width;

View file

@ -8,6 +8,7 @@
* Contributors:
* QNX Software Systems - Initial API and implementation
* IBM Corp. - Rational Software
* Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.ui;
@ -20,31 +21,6 @@ import java.util.MissingResourceException;
import java.util.ResourceBundle;
import java.util.Set;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.IWorkingCopy;
import org.eclipse.cdt.core.model.IWorkingCopyProvider;
import org.eclipse.cdt.internal.core.model.IBufferFactory;
import org.eclipse.cdt.internal.corext.template.c.CContextType;
import org.eclipse.cdt.internal.ui.CElementAdapterFactory;
import org.eclipse.cdt.internal.ui.ICStatusConstants;
import org.eclipse.cdt.internal.ui.IContextMenuConstants;
import org.eclipse.cdt.internal.ui.ResourceAdapterFactory;
import org.eclipse.cdt.internal.ui.buildconsole.BuildConsoleManager;
import org.eclipse.cdt.internal.ui.editor.CDocumentProvider;
import org.eclipse.cdt.internal.ui.editor.CustomBufferFactory;
import org.eclipse.cdt.internal.ui.editor.ExternalSearchDocumentProvider;
import org.eclipse.cdt.internal.ui.editor.SharedTextColors;
import org.eclipse.cdt.internal.ui.editor.WorkingCopyManager;
import org.eclipse.cdt.internal.ui.editor.asm.AsmTextTools;
import org.eclipse.cdt.internal.ui.text.CTextTools;
import org.eclipse.cdt.internal.ui.text.PreferencesAdapter;
import org.eclipse.cdt.internal.ui.text.c.hover.CEditorTextHoverDescriptor;
import org.eclipse.cdt.internal.ui.text.folding.CFoldingStructureProviderRegistry;
import org.eclipse.cdt.internal.ui.util.ImageDescriptorRegistry;
import org.eclipse.cdt.internal.ui.util.ProblemMarkerManager;
import org.eclipse.cdt.internal.ui.util.Util;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.ResourcesPlugin;
@ -78,6 +54,34 @@ import org.eclipse.ui.texteditor.ChainedPreferenceStore;
import org.eclipse.ui.texteditor.ConfigurationElementSorter;
import org.osgi.framework.BundleContext;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.IWorkingCopy;
import org.eclipse.cdt.core.model.IWorkingCopyProvider;
import org.eclipse.cdt.internal.core.model.IBufferFactory;
import org.eclipse.cdt.internal.corext.template.c.CContextType;
import org.eclipse.cdt.internal.ui.CElementAdapterFactory;
import org.eclipse.cdt.internal.ui.ICStatusConstants;
import org.eclipse.cdt.internal.ui.IContextMenuConstants;
import org.eclipse.cdt.internal.ui.ResourceAdapterFactory;
import org.eclipse.cdt.internal.ui.buildconsole.BuildConsoleManager;
import org.eclipse.cdt.internal.ui.editor.CDocumentProvider;
import org.eclipse.cdt.internal.ui.editor.CustomBufferFactory;
import org.eclipse.cdt.internal.ui.editor.ExternalSearchDocumentProvider;
import org.eclipse.cdt.internal.ui.editor.SharedTextColors;
import org.eclipse.cdt.internal.ui.editor.WorkingCopyManager;
import org.eclipse.cdt.internal.ui.editor.asm.AsmTextTools;
import org.eclipse.cdt.internal.ui.text.CTextTools;
import org.eclipse.cdt.internal.ui.text.PreferencesAdapter;
import org.eclipse.cdt.internal.ui.text.c.hover.CEditorTextHoverDescriptor;
import org.eclipse.cdt.internal.ui.text.folding.CFoldingStructureProviderRegistry;
import org.eclipse.cdt.internal.ui.util.ImageDescriptorRegistry;
import org.eclipse.cdt.internal.ui.util.ProblemMarkerManager;
import org.eclipse.cdt.internal.ui.util.Util;
public class CUIPlugin extends AbstractUIPlugin {
private ISharedTextColors fSharedTextColors;
@ -88,6 +92,8 @@ public class CUIPlugin extends AbstractUIPlugin {
public static final String CVIEW_ID = PLUGIN_ID + ".CView"; //$NON-NLS-1$
public static final String C_PROBLEMMARKER = PLUGIN_CORE_ID + ".problem"; //$NON-NLS-1$
public static final String ID_INCLUDE_BROWSER= PLUGIN_ID + ".includeBrowser"; //$NON-NLS-1$
public static final String C_PROJECT_WIZARD_ID = PLUGIN_ID + ".wizards.StdCWizard"; //$NON-NLS-1$
public static final String CPP_PROJECT_WIZARD_ID = PLUGIN_ID + ".wizards.StdCCWizard"; //$NON-NLS-1$