mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
2004-08-31 Alain Magloire
Provide a Proxy wrapper for the includeRefence class This will allow us to provide special Icon, a correct getParent() etc .. in the C/C++ view. * src/org/eclipse/cdt/internal/ui/cview/CViewContentProvider.java * src/org/eclipse/cdt/internal/ui/cview/CViewLabelProvider.java * src/org/eclipse/cdt/internal/ui/cview/IncludeRefContainer.java * src/org/eclipse/cdt/internal/ui/cview/IncludeReferenceProxy.java
This commit is contained in:
parent
5efbcb92a6
commit
5976bb29a1
5 changed files with 106 additions and 7 deletions
|
@ -1,3 +1,13 @@
|
||||||
|
2004-08-31 Alain Magloire
|
||||||
|
|
||||||
|
Provide a Proxy wrapper for the includeRefence class
|
||||||
|
This will allow us to provide special Icon, a correct
|
||||||
|
getParent() etc .. in the C/C++ view.
|
||||||
|
* src/org/eclipse/cdt/internal/ui/cview/CViewContentProvider.java
|
||||||
|
* src/org/eclipse/cdt/internal/ui/cview/CViewLabelProvider.java
|
||||||
|
* src/org/eclipse/cdt/internal/ui/cview/IncludeRefContainer.java
|
||||||
|
* src/org/eclipse/cdt/internal/ui/cview/IncludeReferenceProxy.java
|
||||||
|
|
||||||
2004-08-30 Alain Magloire
|
2004-08-30 Alain Magloire
|
||||||
|
|
||||||
Fix for 72914
|
Fix for 72914
|
||||||
|
|
|
@ -153,10 +153,8 @@ public class CViewContentProvider extends CElementContentProvider {
|
||||||
// up the parent for {IInclude,ILibrary}Reference so that they refer
|
// up the parent for {IInclude,ILibrary}Reference so that they refer
|
||||||
// to the container and containers refere to the project
|
// to the container and containers refere to the project
|
||||||
Object parent = super.internalGetParent(element);
|
Object parent = super.internalGetParent(element);
|
||||||
if (element instanceof IIncludeReference) {
|
if (element instanceof IncludeReferenceProxy) {
|
||||||
if (parent instanceof ICProject) {
|
parent = ((IncludeReferenceProxy)element).getIncludeRefContainer();
|
||||||
parent = new IncludeRefContainer((ICProject)parent);
|
|
||||||
}
|
|
||||||
} else if (element instanceof IncludeRefContainer) {
|
} else if (element instanceof IncludeRefContainer) {
|
||||||
parent = ((IncludeRefContainer)element).getCProject();
|
parent = ((IncludeRefContainer)element).getCProject();
|
||||||
} if (element instanceof ILibraryReference) {
|
} if (element instanceof ILibraryReference) {
|
||||||
|
|
|
@ -10,11 +10,16 @@
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
package org.eclipse.cdt.internal.ui.cview;
|
package org.eclipse.cdt.internal.ui.cview;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
import org.eclipse.cdt.core.model.IIncludeReference;
|
import org.eclipse.cdt.core.model.IIncludeReference;
|
||||||
|
import org.eclipse.cdt.internal.ui.CElementImageProvider;
|
||||||
import org.eclipse.cdt.internal.ui.IAdornmentProvider;
|
import org.eclipse.cdt.internal.ui.IAdornmentProvider;
|
||||||
import org.eclipse.cdt.internal.ui.StandardCElementLabelProvider;
|
import org.eclipse.cdt.internal.ui.StandardCElementLabelProvider;
|
||||||
|
import org.eclipse.cdt.ui.CElementImageDescriptor;
|
||||||
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
import org.eclipse.core.resources.IContainer;
|
import org.eclipse.core.resources.IContainer;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
|
import org.eclipse.jface.resource.ImageDescriptor;
|
||||||
import org.eclipse.swt.graphics.Image;
|
import org.eclipse.swt.graphics.Image;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -73,6 +78,9 @@ public class CViewLabelProvider extends StandardCElementLabelProvider {
|
||||||
if (container != null && container.isAccessible()) {
|
if (container != null && container.isAccessible()) {
|
||||||
return getImage(reference.getCProject());
|
return getImage(reference.getCProject());
|
||||||
}
|
}
|
||||||
|
ImageDescriptor desc = CElementImageProvider.getImageDescriptor(ICElement.C_CCONTAINER);
|
||||||
|
desc = new CElementImageDescriptor(desc, 0, CElementImageProvider.SMALL_SIZE);
|
||||||
|
return CUIPlugin.getImageDescriptorRegistry().get(desc);
|
||||||
}
|
}
|
||||||
return super.getImage(element);
|
return super.getImage(element);
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,6 @@ import org.eclipse.ui.model.IWorkbenchAdapter;
|
||||||
*/
|
*/
|
||||||
public class IncludeRefContainer extends CElementGrouping {
|
public class IncludeRefContainer extends CElementGrouping {
|
||||||
|
|
||||||
private Object[] EMPTY = new Object[0];
|
|
||||||
ICProject fCProject;
|
ICProject fCProject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -55,10 +54,14 @@ public class IncludeRefContainer extends CElementGrouping {
|
||||||
public Object[] getChildren(Object o) {
|
public Object[] getChildren(Object o) {
|
||||||
try {
|
try {
|
||||||
IIncludeReference[] references = fCProject.getIncludeReferences();
|
IIncludeReference[] references = fCProject.getIncludeReferences();
|
||||||
return references;
|
IncludeReferenceProxy[] proxies = new IncludeReferenceProxy[references.length];
|
||||||
|
for (int i = 0; i < proxies.length; ++i) {
|
||||||
|
proxies[i] = new IncludeReferenceProxy(this, references[i]);
|
||||||
|
}
|
||||||
|
return proxies;
|
||||||
} catch (CModelException e) {
|
} catch (CModelException e) {
|
||||||
}
|
}
|
||||||
return EMPTY;
|
return NO_CHILDREN;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
|
|
@ -0,0 +1,80 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2000, 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.IIncludeReference;
|
||||||
|
import org.eclipse.cdt.internal.ui.CPluginImages;
|
||||||
|
import org.eclipse.cdt.ui.CElementGrouping;
|
||||||
|
import org.eclipse.jface.resource.ImageDescriptor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author User
|
||||||
|
*
|
||||||
|
* TODO To change the template for this generated type comment go to
|
||||||
|
* Window - Preferences - Java - Code Style - Code Templates
|
||||||
|
*/
|
||||||
|
public class IncludeReferenceProxy extends CElementGrouping {
|
||||||
|
|
||||||
|
IncludeRefContainer includeRefContainer;
|
||||||
|
IIncludeReference reference;
|
||||||
|
|
||||||
|
public IncludeReferenceProxy(IncludeRefContainer parent, IIncludeReference reference) {
|
||||||
|
super(0);
|
||||||
|
this.reference = reference;
|
||||||
|
this.includeRefContainer = parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.ui.model.IWorkbenchAdapter#getChildren(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public Object[] getChildren(Object object) {
|
||||||
|
try {
|
||||||
|
return reference.getChildren();
|
||||||
|
} catch (CModelException e) {
|
||||||
|
// We should log the error.
|
||||||
|
}
|
||||||
|
return NO_CHILDREN;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.ui.model.IWorkbenchAdapter#getImageDescriptor(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public ImageDescriptor getImageDescriptor(Object object) {
|
||||||
|
return CPluginImages.DESC_OBJS_INCLUDES_FOLDER;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.ui.model.IWorkbenchAdapter#getParent(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public Object getParent(Object object) {
|
||||||
|
return getIncludeRefContainer();
|
||||||
|
}
|
||||||
|
|
||||||
|
public IncludeRefContainer getIncludeRefContainer() {
|
||||||
|
return includeRefContainer;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see java.lang.Object#equals(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
return reference.equals(obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see java.lang.Object#toString()
|
||||||
|
*/
|
||||||
|
public String toString() {
|
||||||
|
return reference.toString();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue