mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
2004-07-20 Alain Magloire
Framework to do virtual grouping in the outliner for example group the includes. * icons/full/obj16/incc_obj.gif * src/org/eclipse/cdt/internal/ui/CPluginImages.java * src/org/eclipse/cdt/internal/ui/actions/ActionMessages.properties * src/org/eclipse/cdt/internal/ui/editor/CContentOutlinePage.java * src/org/eclipse/cdt/internal/ui/editor/CContentOutlineProvider.java * src/org/eclipse/cdt/internal/ui/editor/CEditor.java * src/org/eclipse/cdt/internal/ui/PreferenceConstants.java
This commit is contained in:
parent
0146196946
commit
755accf2b1
8 changed files with 317 additions and 14 deletions
|
@ -1,3 +1,16 @@
|
||||||
|
2004-07-20 Alain Magloire
|
||||||
|
|
||||||
|
Framework to do virtual grouping in the outliner
|
||||||
|
for example group the includes.
|
||||||
|
|
||||||
|
* icons/full/obj16/incc_obj.gif
|
||||||
|
* src/org/eclipse/cdt/internal/ui/CPluginImages.java
|
||||||
|
* src/org/eclipse/cdt/internal/ui/actions/ActionMessages.properties
|
||||||
|
* src/org/eclipse/cdt/internal/ui/editor/CContentOutlinePage.java
|
||||||
|
* src/org/eclipse/cdt/internal/ui/editor/CContentOutlineProvider.java
|
||||||
|
* src/org/eclipse/cdt/internal/ui/editor/CEditor.java
|
||||||
|
* src/org/eclipse/cdt/internal/ui/PreferenceConstants.java
|
||||||
|
|
||||||
2004-07-19 Chris Wiebe
|
2004-07-19 Chris Wiebe
|
||||||
This patch cleans up code using the ToggleLinkingAction
|
This patch cleans up code using the ToggleLinkingAction
|
||||||
(subclass off AbstractToggleLinkingAction).
|
(subclass off AbstractToggleLinkingAction).
|
||||||
|
|
BIN
core/org.eclipse.cdt.ui/icons/full/obj16/incc_obj.gif
Normal file
BIN
core/org.eclipse.cdt.ui/icons/full/obj16/incc_obj.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 185 B |
|
@ -92,6 +92,8 @@ public class CPluginImages {
|
||||||
|
|
||||||
public static final String IMG_OBJS_PROJECT=NAME_PREFIX + "prj_obj.gif"; //$NON-NLS-1$
|
public static final String IMG_OBJS_PROJECT=NAME_PREFIX + "prj_obj.gif"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
public static final String IMG_OBJS_INCCONT= NAME_PREFIX + "incc_obj.gif"; //$NON-NLS-1$
|
||||||
|
|
||||||
// Breakpoint images
|
// Breakpoint images
|
||||||
public static final String IMG_OBJS_BREAKPOINT = NAME_PREFIX + "breakpoint.gif"; //$NON-NLS-1$
|
public static final String IMG_OBJS_BREAKPOINT = NAME_PREFIX + "breakpoint.gif"; //$NON-NLS-1$
|
||||||
public static final String IMG_OBJS_BREAKPOINT_DISABLED = NAME_PREFIX + "breakpoint_disabled.gif"; //$NON-NLS-1$
|
public static final String IMG_OBJS_BREAKPOINT_DISABLED = NAME_PREFIX + "breakpoint_disabled.gif"; //$NON-NLS-1$
|
||||||
|
@ -158,6 +160,8 @@ public class CPluginImages {
|
||||||
public static final ImageDescriptor DESC_OBJS_FIXABLE_PROBLEM= createManaged(T_OBJ, IMG_OBJS_FIXABLE_PROBLEM);
|
public static final ImageDescriptor DESC_OBJS_FIXABLE_PROBLEM= createManaged(T_OBJ, IMG_OBJS_FIXABLE_PROBLEM);
|
||||||
public static final ImageDescriptor DESC_OBJS_FIXABLE_ERROR= createManaged(T_OBJ, IMG_OBJS_FIXABLE_ERROR);
|
public static final ImageDescriptor DESC_OBJS_FIXABLE_ERROR= createManaged(T_OBJ, IMG_OBJS_FIXABLE_ERROR);
|
||||||
|
|
||||||
|
public static final ImageDescriptor DESC_OBJS_INCCONT= createManaged(T_OBJ, IMG_OBJS_INCCONT);
|
||||||
|
|
||||||
public static final ImageDescriptor DESC_OBJS_UNKNOWN = createManaged(T_OBJ, IMG_OBJS_UNKNOWN);
|
public static final ImageDescriptor DESC_OBJS_UNKNOWN = createManaged(T_OBJ, IMG_OBJS_UNKNOWN);
|
||||||
// Breakpoint image descriptors
|
// Breakpoint image descriptors
|
||||||
public static final ImageDescriptor DESC_OBJS_BREAKPOINT = createManaged( T_OBJ, IMG_OBJS_BREAKPOINT );
|
public static final ImageDescriptor DESC_OBJS_BREAKPOINT = createManaged( T_OBJ, IMG_OBJS_BREAKPOINT );
|
||||||
|
|
|
@ -276,3 +276,7 @@ AddDelegateMethodsAction.selectioninfo.more={0} methods selected.
|
||||||
ToggleLinkingAction.label=Lin&k With Editor
|
ToggleLinkingAction.label=Lin&k With Editor
|
||||||
ToggleLinkingAction.tooltip=Link with Editor
|
ToggleLinkingAction.tooltip=Link with Editor
|
||||||
ToggleLinkingAction.description=Link with active editor
|
ToggleLinkingAction.description=Link with active editor
|
||||||
|
|
||||||
|
IncludesGroupingAction.label=Group includes
|
||||||
|
IncludesGroupingAction.tooltip=Group includes statements
|
||||||
|
IncludesGroupingAction.description=Group includes statements
|
||||||
|
|
|
@ -10,17 +10,19 @@ import java.util.Iterator;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
|
import org.eclipse.cdt.internal.ui.CPluginImages;
|
||||||
import org.eclipse.cdt.internal.ui.ICHelpContextIds;
|
import org.eclipse.cdt.internal.ui.ICHelpContextIds;
|
||||||
import org.eclipse.cdt.internal.ui.StandardCElementLabelProvider;
|
import org.eclipse.cdt.internal.ui.StandardCElementLabelProvider;
|
||||||
import org.eclipse.cdt.internal.ui.actions.AbstractToggleLinkingAction;
|
import org.eclipse.cdt.internal.ui.actions.AbstractToggleLinkingAction;
|
||||||
|
import org.eclipse.cdt.internal.ui.actions.ActionMessages;
|
||||||
import org.eclipse.cdt.internal.ui.search.actions.SelectionSearchGroup;
|
import org.eclipse.cdt.internal.ui.search.actions.SelectionSearchGroup;
|
||||||
import org.eclipse.cdt.internal.ui.util.ProblemTreeViewer;
|
import org.eclipse.cdt.internal.ui.util.ProblemTreeViewer;
|
||||||
import org.eclipse.cdt.ui.CElementContentProvider;
|
|
||||||
import org.eclipse.cdt.ui.CUIPlugin;
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
import org.eclipse.cdt.ui.PreferenceConstants;
|
import org.eclipse.cdt.ui.PreferenceConstants;
|
||||||
import org.eclipse.cdt.ui.actions.MemberFilterActionGroup;
|
import org.eclipse.cdt.ui.actions.MemberFilterActionGroup;
|
||||||
import org.eclipse.cdt.ui.actions.OpenViewActionGroup;
|
import org.eclipse.cdt.ui.actions.OpenViewActionGroup;
|
||||||
import org.eclipse.cdt.ui.actions.RefactoringActionGroup;
|
import org.eclipse.cdt.ui.actions.RefactoringActionGroup;
|
||||||
|
import org.eclipse.jface.action.Action;
|
||||||
import org.eclipse.jface.action.IMenuListener;
|
import org.eclipse.jface.action.IMenuListener;
|
||||||
import org.eclipse.jface.action.IMenuManager;
|
import org.eclipse.jface.action.IMenuManager;
|
||||||
import org.eclipse.jface.action.IToolBarManager;
|
import org.eclipse.jface.action.IToolBarManager;
|
||||||
|
@ -59,6 +61,7 @@ public class CContentOutlinePage extends Page implements IContentOutlinePage, IS
|
||||||
|
|
||||||
private OpenIncludeAction fOpenIncludeAction;
|
private OpenIncludeAction fOpenIncludeAction;
|
||||||
private ToggleLinkingAction fToggleLinkingAction;
|
private ToggleLinkingAction fToggleLinkingAction;
|
||||||
|
private IncludeGroupingAction fIncludeGroupingAction;
|
||||||
|
|
||||||
private MemberFilterActionGroup fMemberFilterActionGroup;
|
private MemberFilterActionGroup fMemberFilterActionGroup;
|
||||||
|
|
||||||
|
@ -66,6 +69,34 @@ public class CContentOutlinePage extends Page implements IContentOutlinePage, IS
|
||||||
private ActionGroup fRefactoringActionGroup;
|
private ActionGroup fRefactoringActionGroup;
|
||||||
private ActionGroup fOpenViewActionGroup;
|
private ActionGroup fOpenViewActionGroup;
|
||||||
|
|
||||||
|
public class IncludeGroupingAction extends Action {
|
||||||
|
CContentOutlinePage outLine;
|
||||||
|
|
||||||
|
public IncludeGroupingAction(CContentOutlinePage outlinePage) {
|
||||||
|
super(ActionMessages.getString("IncludesGroupingAction.label")); //$NON-NLS-1$
|
||||||
|
setDescription(ActionMessages.getString("IncludesGroupingAction.description")); //$NON-NLS-1$
|
||||||
|
setToolTipText(ActionMessages.getString("IncludeGroupingAction.tooltip")); //$NON-NLS-1$
|
||||||
|
CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, "synced.gif"); //$NON-NLS-1$
|
||||||
|
WorkbenchHelp.setHelp(this, ICHelpContextIds.LINK_EDITOR_ACTION);
|
||||||
|
|
||||||
|
boolean enabled= isIncludesGroupingEnabled();
|
||||||
|
setChecked(enabled);
|
||||||
|
outLine = outlinePage;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Runs the action.
|
||||||
|
*/
|
||||||
|
public void run() {
|
||||||
|
boolean oldValue = isIncludesGroupingEnabled();
|
||||||
|
PreferenceConstants.getPreferenceStore().setValue(PreferenceConstants.OUTLINE_GROUP_INCLUDES, isChecked());
|
||||||
|
if (oldValue != isChecked()) {
|
||||||
|
outLine.contentUpdated();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This action toggles whether this C Outline page links
|
* This action toggles whether this C Outline page links
|
||||||
* its selection to the active editor.
|
* its selection to the active editor.
|
||||||
|
@ -189,7 +220,8 @@ public class CContentOutlinePage extends Page implements IContentOutlinePage, IS
|
||||||
public void createControl(Composite parent) {
|
public void createControl(Composite parent) {
|
||||||
treeViewer = new ProblemTreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
|
treeViewer = new ProblemTreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
|
||||||
|
|
||||||
treeViewer.setContentProvider(new CElementContentProvider(true, true));
|
//treeViewer.setContentProvider(new CElementContentProvider(true, true));
|
||||||
|
treeViewer.setContentProvider(new CContentOutlinerProvider(this));
|
||||||
treeViewer.setLabelProvider(new StandardCElementLabelProvider());
|
treeViewer.setLabelProvider(new StandardCElementLabelProvider());
|
||||||
treeViewer.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS);
|
treeViewer.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS);
|
||||||
treeViewer.addSelectionChangedListener(this);
|
treeViewer.addSelectionChangedListener(this);
|
||||||
|
@ -286,12 +318,14 @@ public class CContentOutlinePage extends Page implements IContentOutlinePage, IS
|
||||||
fMemberFilterActionGroup= new MemberFilterActionGroup(treeViewer, "COutlineViewer"); //$NON-NLS-1$
|
fMemberFilterActionGroup= new MemberFilterActionGroup(treeViewer, "COutlineViewer"); //$NON-NLS-1$
|
||||||
fMemberFilterActionGroup.fillActionBars(actionBars);
|
fMemberFilterActionGroup.fillActionBars(actionBars);
|
||||||
|
|
||||||
/* IMenuManager menu= actionBars.getMenuManager();
|
IMenuManager menu= actionBars.getMenuManager();
|
||||||
menu.add(new Separator("EndFilterGroup")); //$NON-NLS-1$
|
menu.add(new Separator("EndFilterGroup")); //$NON-NLS-1$
|
||||||
|
|
||||||
fToggleLinkingAction= new ToggleLinkingAction(this);
|
//fToggleLinkingAction= new ToggleLinkingAction(this);
|
||||||
menu.add(fToggleLinkingAction);
|
//menu.add(fToggleLinkingAction);
|
||||||
*/ }
|
fIncludeGroupingAction= new IncludeGroupingAction(this);
|
||||||
|
menu.add(fIncludeGroupingAction);
|
||||||
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* Method declared on ISelectionProvider.
|
* Method declared on ISelectionProvider.
|
||||||
|
@ -315,6 +349,7 @@ public class CContentOutlinePage extends Page implements IContentOutlinePage, IS
|
||||||
((ISelectionChangedListener) listeners[i]).selectionChanged(event);
|
((ISelectionChangedListener) listeners[i]).selectionChanged(event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* Method declared on IPage (and Page).
|
* Method declared on IPage (and Page).
|
||||||
*/
|
*/
|
||||||
|
@ -323,6 +358,7 @@ public class CContentOutlinePage extends Page implements IContentOutlinePage, IS
|
||||||
return null;
|
return null;
|
||||||
return treeViewer.getControl();
|
return treeViewer.getControl();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* Method declared on ISelectionProvider.
|
* Method declared on ISelectionProvider.
|
||||||
*/
|
*/
|
||||||
|
@ -331,6 +367,7 @@ public class CContentOutlinePage extends Page implements IContentOutlinePage, IS
|
||||||
return StructuredSelection.EMPTY;
|
return StructuredSelection.EMPTY;
|
||||||
return treeViewer.getSelection();
|
return treeViewer.getSelection();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns this page's tree viewer.
|
* Returns this page's tree viewer.
|
||||||
*
|
*
|
||||||
|
@ -340,12 +377,14 @@ public class CContentOutlinePage extends Page implements IContentOutlinePage, IS
|
||||||
protected TreeViewer getTreeViewer() {
|
protected TreeViewer getTreeViewer() {
|
||||||
return treeViewer;
|
return treeViewer;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* Method declared on ISelectionProvider.
|
* Method declared on ISelectionProvider.
|
||||||
*/
|
*/
|
||||||
public void removeSelectionChangedListener(ISelectionChangedListener listener) {
|
public void removeSelectionChangedListener(ISelectionChangedListener listener) {
|
||||||
selectionChangedListeners.remove(listener);
|
selectionChangedListeners.remove(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* Method declared on ISelectionChangeListener.
|
* Method declared on ISelectionChangeListener.
|
||||||
* Gives notification that the tree selection has changed.
|
* Gives notification that the tree selection has changed.
|
||||||
|
@ -353,12 +392,14 @@ public class CContentOutlinePage extends Page implements IContentOutlinePage, IS
|
||||||
public void selectionChanged(SelectionChangedEvent event) {
|
public void selectionChanged(SelectionChangedEvent event) {
|
||||||
fireSelectionChanged(event.getSelection());
|
fireSelectionChanged(event.getSelection());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets focus to a part in the page.
|
* Sets focus to a part in the page.
|
||||||
*/
|
*/
|
||||||
public void setFocus() {
|
public void setFocus() {
|
||||||
treeViewer.getControl().setFocus();
|
treeViewer.getControl().setFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* Method declared on ISelectionProvider.
|
* Method declared on ISelectionProvider.
|
||||||
*/
|
*/
|
||||||
|
@ -366,6 +407,7 @@ public class CContentOutlinePage extends Page implements IContentOutlinePage, IS
|
||||||
if (treeViewer != null)
|
if (treeViewer != null)
|
||||||
treeViewer.setSelection(selection);
|
treeViewer.setSelection(selection);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the current input to the content provider.
|
* Set the current input to the content provider.
|
||||||
* @param unit
|
* @param unit
|
||||||
|
@ -378,5 +420,8 @@ public class CContentOutlinePage extends Page implements IContentOutlinePage, IS
|
||||||
contentUpdated();
|
contentUpdated();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isIncludesGroupingEnabled () {
|
||||||
|
return PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.OUTLINE_GROUP_INCLUDES);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,224 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Copyright (c) 2002,2003,2004 QNX Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
***********************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.ui.editor;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.model.CModelException;
|
||||||
|
import org.eclipse.cdt.core.model.CoreModel;
|
||||||
|
import org.eclipse.cdt.core.model.ElementChangedEvent;
|
||||||
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
|
import org.eclipse.cdt.core.model.ICElementDelta;
|
||||||
|
import org.eclipse.cdt.core.model.IElementChangedListener;
|
||||||
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
|
import org.eclipse.cdt.internal.ui.BaseCElementContentProvider;
|
||||||
|
import org.eclipse.cdt.internal.ui.CPluginImages;
|
||||||
|
import org.eclipse.core.runtime.IAdaptable;
|
||||||
|
import org.eclipse.jface.resource.ImageDescriptor;
|
||||||
|
import org.eclipse.jface.viewers.Viewer;
|
||||||
|
import org.eclipse.ui.model.IWorkbenchAdapter;
|
||||||
|
import org.eclipse.ui.model.WorkbenchAdapter;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* CContentOutlinerProvider
|
||||||
|
*/
|
||||||
|
public class CContentOutlinerProvider extends BaseCElementContentProvider {
|
||||||
|
|
||||||
|
CContentOutlinePage fOutliner;
|
||||||
|
ITranslationUnit root;
|
||||||
|
private ElementChangedListener fListener;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The element change listener of the java outline viewer.
|
||||||
|
* @see IElementChangedListener
|
||||||
|
*/
|
||||||
|
class ElementChangedListener implements IElementChangedListener {
|
||||||
|
|
||||||
|
public void elementChanged(final ElementChangedEvent e) {
|
||||||
|
|
||||||
|
ICElementDelta delta= findElement(root, e.getDelta());
|
||||||
|
if (delta != null && fOutliner != null) {
|
||||||
|
fOutliner.contentUpdated();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// TODO: We should be able to be smarter then a dum refresh
|
||||||
|
// ICElementDelta delta= findElement(base, e.getDelta());
|
||||||
|
// if (delta != null && fOutlineViewer != null) {
|
||||||
|
// fOutlineViewer.reconcile(delta);
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isPossibleStructuralChange(ICElementDelta cuDelta) {
|
||||||
|
if (cuDelta.getKind() != ICElementDelta.CHANGED) {
|
||||||
|
return true; // add or remove
|
||||||
|
}
|
||||||
|
int flags= cuDelta.getFlags();
|
||||||
|
if ((flags & ICElementDelta.F_CHILDREN) != 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return (flags & (ICElementDelta.F_CONTENT | ICElementDelta.F_FINE_GRAINED)) == ICElementDelta.F_CONTENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ICElementDelta findElement(ICElement unit, ICElementDelta delta) {
|
||||||
|
|
||||||
|
if (delta == null || unit == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
ICElement element= delta.getElement();
|
||||||
|
|
||||||
|
if (unit.equals(element)) {
|
||||||
|
if (isPossibleStructuralChange(delta)) {
|
||||||
|
return delta;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (element.getElementType() > ICElement.C_UNIT)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
ICElementDelta[] children= delta.getAffectedChildren();
|
||||||
|
if (children == null || children.length == 0)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
for (int i= 0; i < children.length; i++) {
|
||||||
|
ICElementDelta d= findElement(unit, children[i]);
|
||||||
|
if (d != null)
|
||||||
|
return d;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* VirtualGrouping
|
||||||
|
*/
|
||||||
|
public class IncludesContainer extends WorkbenchAdapter implements IAdaptable {
|
||||||
|
ITranslationUnit tu;
|
||||||
|
|
||||||
|
public IncludesContainer(ITranslationUnit unit) {
|
||||||
|
tu = unit;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.ui.model.IWorkbenchAdapter#getChildren(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public Object[] getChildren(Object object) {
|
||||||
|
try {
|
||||||
|
return tu.getChildrenOfType(ICElement.C_INCLUDE).toArray();
|
||||||
|
} catch (CModelException e) {
|
||||||
|
}
|
||||||
|
return NO_CHILDREN;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.ui.model.IWorkbenchAdapter#getLabel(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public String getLabel(Object object) {
|
||||||
|
return "include statements";
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.ui.model.IWorkbenchAdapter#getImageDescriptor(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public ImageDescriptor getImageDescriptor(Object object) {
|
||||||
|
return CPluginImages.DESC_OBJS_INCCONT;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.ui.model.IWorkbenchAdapter#getParent(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public Object getParent(Object object) {
|
||||||
|
return tu;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @see org.eclipse.core.runtime.IAdaptable#getAdapter(Class)
|
||||||
|
*/
|
||||||
|
public Object getAdapter(Class clas) {
|
||||||
|
if (clas == IWorkbenchAdapter.class)
|
||||||
|
return this;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public CContentOutlinerProvider(CContentOutlinePage outliner) {
|
||||||
|
super(true, true);
|
||||||
|
fOutliner = outliner;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public Object[] getChildren(Object element) {
|
||||||
|
if (element instanceof ITranslationUnit) {
|
||||||
|
ITranslationUnit unit = (ITranslationUnit)element;
|
||||||
|
try {
|
||||||
|
if (fOutliner != null && fOutliner.isIncludesGroupingEnabled()) {
|
||||||
|
boolean hasInclude = false;
|
||||||
|
ICElement[] children = unit.getChildren();
|
||||||
|
ArrayList list = new ArrayList(children.length);
|
||||||
|
for (int i = 0; i < children.length; i++) {
|
||||||
|
if (children[i].getElementType() != ICElement.C_INCLUDE) {
|
||||||
|
list.add(children[i]);
|
||||||
|
} else {
|
||||||
|
hasInclude = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (hasInclude) {
|
||||||
|
list.add (0, new IncludesContainer(unit));
|
||||||
|
}
|
||||||
|
return list.toArray();
|
||||||
|
}
|
||||||
|
} catch (CModelException e) {
|
||||||
|
return NO_CHILDREN;
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (element instanceof IncludesContainer) {
|
||||||
|
IncludesContainer includes = (IncludesContainer)element;
|
||||||
|
return includes.getChildren(element);
|
||||||
|
}
|
||||||
|
return super.getChildren(element);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.jface.viewers.IContentProvider#dispose()
|
||||||
|
*/
|
||||||
|
public void dispose() {
|
||||||
|
super.dispose();
|
||||||
|
if (fListener != null) {
|
||||||
|
CoreModel.getDefault().removeElementChangedListener(fListener);
|
||||||
|
fListener= null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
|
||||||
|
*/
|
||||||
|
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
|
||||||
|
boolean isTU= (newInput instanceof ITranslationUnit);
|
||||||
|
|
||||||
|
if (isTU && fListener == null) {
|
||||||
|
fListener= new ElementChangedListener();
|
||||||
|
CoreModel.getDefault().addElementChangedListener(fListener);
|
||||||
|
root = (ITranslationUnit)newInput;
|
||||||
|
} else if (!isTU && fListener != null) {
|
||||||
|
CoreModel.getDefault().removeElementChangedListener(fListener);
|
||||||
|
fListener= null;
|
||||||
|
root = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1036,8 +1036,11 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS
|
||||||
* @see org.eclipse.cdt.internal.ui.editor.IReconcilingParticipant#reconciled()
|
* @see org.eclipse.cdt.internal.ui.editor.IReconcilingParticipant#reconciled()
|
||||||
*/
|
*/
|
||||||
public void reconciled(boolean somethingHasChanged) {
|
public void reconciled(boolean somethingHasChanged) {
|
||||||
if(somethingHasChanged && fOutlinePage != null) {
|
// Do nothing the outliner is listeniner to the
|
||||||
fOutlinePage.contentUpdated();
|
// CoreModel WorkingCopy changes instead.
|
||||||
}
|
// It will allow more fined grained.
|
||||||
|
//if(somethingHasChanged && fOutlinePage != null) {
|
||||||
|
// fOutlinePage.contentUpdated();
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -269,9 +269,19 @@ public class PreferenceConstants {
|
||||||
public static final String OPEN_TYPE_HIERARCHY_IN_VIEW_PART= "viewPart"; //$NON-NLS-1$
|
public static final String OPEN_TYPE_HIERARCHY_IN_VIEW_PART= "viewPart"; //$NON-NLS-1$
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the JDT-UI preference store.
|
* A named preference that controls if the C Browsing views are linked to the active editor.
|
||||||
|
* <p>
|
||||||
|
* Value is of type <code>Boolean</code>.
|
||||||
|
* </p>
|
||||||
*
|
*
|
||||||
* @return the JDT-UI preference store
|
* @see #LINK_PACKAGES_TO_EDITOR
|
||||||
|
*/
|
||||||
|
public static final String OUTLINE_GROUP_INCLUDES= "org.eclipse.cdt.ui.outline.groupincludes"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the CDT-UI preference store.
|
||||||
|
*
|
||||||
|
* @return the CDT-UI preference store
|
||||||
*/
|
*/
|
||||||
public static IPreferenceStore getPreferenceStore() {
|
public static IPreferenceStore getPreferenceStore() {
|
||||||
return CUIPlugin.getDefault().getPreferenceStore();
|
return CUIPlugin.getDefault().getPreferenceStore();
|
||||||
|
|
Loading…
Add table
Reference in a new issue