mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
CView has its own ContentProvider.
This commit is contained in:
parent
9561454a65
commit
19af5bd03e
11 changed files with 301 additions and 28 deletions
|
@ -1,3 +1,20 @@
|
|||
2004-04-03 Alain Magloire
|
||||
|
||||
Draft support for LibraryReference and IncludeReference
|
||||
CView has its own ContentProvider.
|
||||
WORK IN PROGRESS
|
||||
|
||||
* src/org/eclipse/cdt/internal/ui/BaseCElementContentProvider.java
|
||||
* src/org/eclipse/cdt/internal/ui/CPluginImages.java
|
||||
* src/org/eclipse/cdt/internal/ui/cview/CView.java
|
||||
* src/org/eclipse/cdt/internal/ui/cview/CViewActionGroup.java
|
||||
* src/org/eclipse/cdt/internal/ui/cview/CViewContentProvider.java
|
||||
* src/org/eclipse/cdt/internal/ui/cview/IncludeRefContainer.java
|
||||
* src/org/eclipse/cdt/internal/ui/cview/LibraryRefContainer.java
|
||||
* src/org/eclipse/cdt/internal/ui/dialogs/CPListElement.java
|
||||
* src/org/eclipse/cdt/internal/ui/dialogs/CPListElementSorter.java
|
||||
* src/org/eclipse/cdt/ui/CElementContentProvider.java
|
||||
|
||||
2004-04-04 John Camelon
|
||||
Fix https://bugs.eclipse.org/bugs/show_bug.cgi?id=43215
|
||||
|
||||
|
|
|
@ -18,7 +18,6 @@ import org.eclipse.cdt.core.model.ICContainer;
|
|||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.core.model.ICModel;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.core.model.ILibraryReference;
|
||||
import org.eclipse.cdt.core.model.IParent;
|
||||
import org.eclipse.cdt.core.model.ISourceRoot;
|
||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||
|
@ -129,10 +128,6 @@ public class BaseCElementContentProvider implements ITreeContentProvider {
|
|||
return getCProjects((ICModel)element);
|
||||
} else if (element instanceof ICProject ) {
|
||||
return getSourceRoots((ICProject)element);
|
||||
} else if (element instanceof IBinaryContainer) {
|
||||
return ((IBinaryContainer)element).getBinaries();
|
||||
} else if (element instanceof IArchiveContainer) {
|
||||
return ((IArchiveContainer)element).getArchives();
|
||||
} else if (element instanceof ICContainer) {
|
||||
return getCResources((ICContainer)element);
|
||||
} else if (element instanceof ITranslationUnit) {
|
||||
|
@ -292,21 +287,6 @@ public class BaseCElementContentProvider implements ITreeContentProvider {
|
|||
//
|
||||
}
|
||||
|
||||
IArchiveContainer archives = cproject.getArchiveContainer();
|
||||
if (archives.hasChildren()) {
|
||||
objects = concatenate(objects, new Object[] {archives});
|
||||
}
|
||||
IBinaryContainer bins = cproject.getBinaryContainer();
|
||||
if (bins.hasChildren()) {
|
||||
objects = concatenate(objects, new Object[] {bins});
|
||||
}
|
||||
try {
|
||||
ILibraryReference[] refs = cproject.getLibraryReferences();
|
||||
if (refs != null && refs.length > 0) {
|
||||
objects = concatenate(objects, refs);
|
||||
}
|
||||
} catch (CModelException e) {
|
||||
}
|
||||
return objects;
|
||||
}
|
||||
|
||||
|
|
|
@ -79,6 +79,7 @@ public class CPluginImages {
|
|||
public static final String IMG_OBJS_CONTAINER= NAME_PREFIX + "container_obj.gif"; //$NON-NLS-1$
|
||||
public static final String IMG_OBJS_OUTPUT_FOLDER= NAME_PREFIX + "output_folder_obj.gif"; //$NON-NLS-1$
|
||||
public static final String IMG_OBJS_LIBRARY= NAME_PREFIX + "lib_obj.gif"; //$NON-NLS-1$
|
||||
public static final String IMG_OBJS_INCLUDES_CONTAINER = NAME_PREFIX + "includes_container.gif"; //$NON-NLS-1$
|
||||
public static final String IMG_OBJS_ORDER= NAME_PREFIX + "cp_order_obj.gif"; //$NON-NLS-1$
|
||||
public static final String IMG_OBJS_EXCLUDSION_FILTER_ATTRIB= NAME_PREFIX + "exclusion_filter_attrib.gif"; //$NON-NLS-1$
|
||||
|
||||
|
@ -128,6 +129,7 @@ public class CPluginImages {
|
|||
public static final ImageDescriptor DESC_OBJS_CONTAINER= createManaged(T_OBJ, IMG_OBJS_CONTAINER);
|
||||
public static final ImageDescriptor DESC_OBJS_OUTPUT_FOLDER= createManaged(T_OBJ, IMG_OBJS_OUTPUT_FOLDER);
|
||||
public static final ImageDescriptor DESC_OBJS_LIBRARY= createManaged(T_OBJ, IMG_OBJS_LIBRARY);
|
||||
public static final ImageDescriptor DESC_OBJS_INCLUDES_CONTAINER= createManaged(T_OBJ, IMG_OBJS_INCLUDES_CONTAINER);
|
||||
public static final ImageDescriptor DESC_OBJS_ORDER= createManaged(T_OBJ, IMG_OBJS_ORDER);
|
||||
public static final ImageDescriptor DESC_OBJS_EXCLUSION_FILTER_ATTRIB = createManaged(T_OBJ, IMG_OBJS_EXCLUDSION_FILTER_ATTRIB);
|
||||
|
||||
|
|
|
@ -550,7 +550,7 @@ public class CView extends ViewPart implements ISetSelectionTarget, IPropertyCha
|
|||
|
||||
protected CElementContentProvider createContentProvider() {
|
||||
boolean showCUChildren = CPluginPreferencePage.showCompilationUnitChildren();
|
||||
return new CElementContentProvider(showCUChildren, true);
|
||||
return new CViewContentProvider(showCUChildren, true);
|
||||
}
|
||||
|
||||
protected StandardCElementLabelProvider createLabelProvider() {
|
||||
|
|
|
@ -14,7 +14,6 @@ import java.net.MalformedURLException;
|
|||
import java.net.URL;
|
||||
|
||||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
import org.eclipse.cdt.ui.actions.CustomFiltersActionGroup;
|
||||
import org.eclipse.jface.action.IMenuManager;
|
||||
import org.eclipse.jface.resource.ImageDescriptor;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
|
|
|
@ -0,0 +1,107 @@
|
|||
/**********************************************************************
|
||||
* 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.cview;
|
||||
|
||||
import org.eclipse.cdt.core.model.CModelException;
|
||||
import org.eclipse.cdt.core.model.IArchiveContainer;
|
||||
import org.eclipse.cdt.core.model.IBinaryContainer;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.core.model.IIncludeReference;
|
||||
import org.eclipse.cdt.core.model.ILibraryReference;
|
||||
import org.eclipse.cdt.ui.CElementContentProvider;
|
||||
|
||||
/**
|
||||
* CViewContentProvider
|
||||
*/
|
||||
public class CViewContentProvider extends CElementContentProvider {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public CViewContentProvider() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param provideMembers
|
||||
* @param provideWorkingCopy
|
||||
*/
|
||||
public CViewContentProvider(boolean provideMembers, boolean provideWorkingCopy) {
|
||||
super(provideMembers, provideWorkingCopy);
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object)
|
||||
*/
|
||||
public Object[] getChildren(Object element) {
|
||||
Object[] objs = super.getChildren(element);
|
||||
Object[] extras = null;
|
||||
if (element instanceof ICProject) {
|
||||
extras = getProjectChildren((ICProject)element);
|
||||
} else if (element instanceof IBinaryContainer) {
|
||||
extras = ((IBinaryContainer)element).getBinaries();
|
||||
} else if (element instanceof IArchiveContainer) {
|
||||
extras =((IArchiveContainer)element).getArchives();
|
||||
} else if (element instanceof LibraryRefContainer) {
|
||||
extras = ((LibraryRefContainer)element).getChildren(element);
|
||||
} else if (element instanceof IncludeRefContainer) {
|
||||
extras = ((IncludeRefContainer)element).getChildren(element);
|
||||
}
|
||||
|
||||
if (extras != null && extras.length > 0) {
|
||||
objs = concatenate(objs, extras);
|
||||
}
|
||||
return objs;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
private Object[] getProjectChildren(ICProject cproject) {
|
||||
Object[] extras = null;
|
||||
IArchiveContainer archive = cproject.getArchiveContainer();
|
||||
if (archive.hasChildren()) {
|
||||
extras = new Object[] {archive};
|
||||
}
|
||||
IBinaryContainer bin = cproject.getBinaryContainer();
|
||||
if (bin.hasChildren()) {
|
||||
Object[] o = new Object[] {bin};
|
||||
if (extras != null && extras.length > 0) {
|
||||
extras = concatenate(extras, o);
|
||||
} else {
|
||||
extras = o;
|
||||
}
|
||||
}
|
||||
try {
|
||||
ILibraryReference[] libRefs = cproject.getLibraryReferences();
|
||||
if (libRefs != null && libRefs.length > 0) {
|
||||
Object[] o = new Object[] {new LibraryRefContainer(cproject)};
|
||||
if (extras != null && extras.length > 0) {
|
||||
extras = concatenate(extras, o);
|
||||
} else {
|
||||
extras = o;
|
||||
}
|
||||
}
|
||||
IIncludeReference[] incRefs = cproject.getIncludeReferences();
|
||||
if (incRefs != null && incRefs.length > 0) {
|
||||
Object[] o = new Object[] {new IncludeRefContainer(cproject)};
|
||||
if (extras != null && extras.length > 0) {
|
||||
extras = concatenate(extras, o);
|
||||
} else {
|
||||
extras = o;
|
||||
}
|
||||
}
|
||||
} catch (CModelException e) {
|
||||
}
|
||||
return extras;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,85 @@
|
|||
/**********************************************************************
|
||||
* 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.cview;
|
||||
|
||||
import org.eclipse.cdt.core.model.CModelException;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.internal.ui.CPluginImages;
|
||||
import org.eclipse.core.runtime.IAdaptable;
|
||||
import org.eclipse.jface.resource.ImageDescriptor;
|
||||
import org.eclipse.ui.model.IWorkbenchAdapter;
|
||||
|
||||
/**
|
||||
* IncludeRefContainer
|
||||
*/
|
||||
public class IncludeRefContainer implements IAdaptable, IWorkbenchAdapter{
|
||||
|
||||
private Object[] EMPTY = new Object[0];
|
||||
ICProject fCProject;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public IncludeRefContainer(ICProject cproject) {
|
||||
fCProject = cproject;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
|
||||
*/
|
||||
public Object getAdapter(Class adapter) {
|
||||
if (adapter == IWorkbenchAdapter.class) {
|
||||
return this;
|
||||
}
|
||||
if (adapter == ICProject.class) {
|
||||
return fCProject;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.model.IWorkbenchAdapter#getChildren(java.lang.Object)
|
||||
*/
|
||||
public Object[] getChildren(Object o) {
|
||||
try {
|
||||
return fCProject.getIncludeReferences();
|
||||
} catch (CModelException e) {
|
||||
}
|
||||
return EMPTY;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.model.IWorkbenchAdapter#getImageDescriptor(java.lang.Object)
|
||||
*/
|
||||
public ImageDescriptor getImageDescriptor(Object object) {
|
||||
return CPluginImages.DESC_OBJS_INCLUDES_CONTAINER;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.model.IWorkbenchAdapter#getLabel(java.lang.Object)
|
||||
*/
|
||||
public String getLabel(Object o) {
|
||||
return "Includes"; //$NON-NLS-1$
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.model.IWorkbenchAdapter#getParent(java.lang.Object)
|
||||
*/
|
||||
public Object getParent(Object o) {
|
||||
return getCProject();
|
||||
}
|
||||
|
||||
public ICProject getCProject() {
|
||||
return fCProject;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,85 @@
|
|||
/**********************************************************************
|
||||
* 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.cview;
|
||||
|
||||
import org.eclipse.cdt.core.model.CModelException;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.internal.ui.CPluginImages;
|
||||
import org.eclipse.core.runtime.IAdaptable;
|
||||
import org.eclipse.jface.resource.ImageDescriptor;
|
||||
import org.eclipse.ui.model.IWorkbenchAdapter;
|
||||
|
||||
/**
|
||||
* VirtualGrouping
|
||||
*/
|
||||
public class LibraryRefContainer implements IAdaptable, IWorkbenchAdapter {
|
||||
|
||||
private Object[] EMPTY = new Object[0];
|
||||
private ICProject fCProject;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public LibraryRefContainer(ICProject cproject) {
|
||||
fCProject = cproject;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
|
||||
*/
|
||||
public Object getAdapter(Class adapter) {
|
||||
if (adapter == IWorkbenchAdapter.class) {
|
||||
return this;
|
||||
}
|
||||
if (adapter == ICProject.class) {
|
||||
return fCProject;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.model.IWorkbenchAdapter#getChildren(java.lang.Object)
|
||||
*/
|
||||
public Object[] getChildren(Object o) {
|
||||
try {
|
||||
return fCProject.getLibraryReferences();
|
||||
} catch (CModelException e) {
|
||||
}
|
||||
return EMPTY;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.model.IWorkbenchAdapter#getImageDescriptor(java.lang.Object)
|
||||
*/
|
||||
public ImageDescriptor getImageDescriptor(Object object) {
|
||||
return CPluginImages.DESC_OBJS_LIBRARY;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.model.IWorkbenchAdapter#getLabel(java.lang.Object)
|
||||
*/
|
||||
public String getLabel(Object o) {
|
||||
return "Library References"; //$NON-NLS-1
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.model.IWorkbenchAdapter#getParent(java.lang.Object)
|
||||
*/
|
||||
public Object getParent(Object o) {
|
||||
return getCProject();
|
||||
}
|
||||
|
||||
public ICProject getCProject() {
|
||||
return fCProject;
|
||||
}
|
||||
|
||||
}
|
|
@ -112,7 +112,7 @@ public class CPListElement {
|
|||
return CoreModel.newSourceEntry(fPath, exclusionPattern);
|
||||
case IPathEntry.CDT_LIBRARY:
|
||||
IPath attach = (IPath) getAttribute(SOURCEATTACHMENT);
|
||||
return CoreModel.newLibraryEntry(fPath, attach, null, null, isExported());
|
||||
return CoreModel.newLibraryEntry(fPath, null, attach, null, null, isExported());
|
||||
case IPathEntry.CDT_PROJECT:
|
||||
return CoreModel.newProjectEntry(fPath, isExported());
|
||||
case IPathEntry.CDT_CONTAINER:
|
||||
|
|
|
@ -16,8 +16,7 @@ public class CPListElementSorter extends ViewerSorter {
|
|||
private static final int SOURCE = 0;
|
||||
private static final int PROJECT = 1;
|
||||
private static final int LIBRARY = 2;
|
||||
private static final int VARIABLE = 3;
|
||||
private static final int CONTAINER = 4;
|
||||
private static final int CONTAINER = 3;
|
||||
private static final int OTHER = 5;
|
||||
|
||||
/*
|
||||
|
@ -32,8 +31,6 @@ public class CPListElementSorter extends ViewerSorter {
|
|||
return PROJECT;
|
||||
case IPathEntry.CDT_SOURCE:
|
||||
return SOURCE;
|
||||
case IPathEntry.CDT_VARIABLE:
|
||||
return VARIABLE;
|
||||
case IPathEntry.CDT_CONTAINER:
|
||||
return CONTAINER;
|
||||
}
|
||||
|
|
|
@ -110,7 +110,8 @@ public class CElementContentProvider extends BaseCElementContentProvider impleme
|
|||
(flags & ICElementDelta.F_ADDED_PATHENTRY_SOURCE) != 0 ||
|
||||
(flags & ICElementDelta.F_REMOVED_PATHENTRY_LIBRARY) != 0 ||
|
||||
(flags & ICElementDelta.F_PATHENTRY_REORDER) != 0 ||
|
||||
(flags & ICElementDelta.F_REMOVED_PATHENTRY_SOURCE) != 0));
|
||||
(flags & ICElementDelta.F_REMOVED_PATHENTRY_SOURCE) != 0 ||
|
||||
(flags & ICElementDelta.F_CHANGED_PATHENTRY_INCLUDE) != 0));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Reference in a new issue