mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-10 01:35:39 +02:00
Changes was doen int the Core Model:
ICModel, ICProject, ICContainer, ICTranslationUnit IArchive and IBinary We now adjust the code
This commit is contained in:
parent
57e8eb56ff
commit
270cdcae55
21 changed files with 281 additions and 220 deletions
|
@ -190,7 +190,7 @@ public class ArchiveTests extends TestCase {
|
||||||
IArchive myArchive;
|
IArchive myArchive;
|
||||||
myArchive=CProjectHelper.findArchive(testProject, "libtestlib_g.a");
|
myArchive=CProjectHelper.findArchive(testProject, "libtestlib_g.a");
|
||||||
|
|
||||||
assertTrue("A archive", myArchive.isArchive());
|
assertTrue("A archive", myArchive != null);
|
||||||
myArchive=null;
|
myArchive=null;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -346,7 +346,7 @@ public class BinaryTests extends TestCase {
|
||||||
public void testisBinRead() {
|
public void testisBinRead() {
|
||||||
IBinary myBinary;
|
IBinary myBinary;
|
||||||
myBinary =CProjectHelper.findBinary(testProject, "test_g");
|
myBinary =CProjectHelper.findBinary(testProject, "test_g");
|
||||||
assertTrue(myBinary.isBinary());
|
assertTrue(myBinary != null);
|
||||||
assertTrue(myBinary.isReadOnly());
|
assertTrue(myBinary.isReadOnly());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -420,7 +420,7 @@ public class BinaryTests extends TestCase {
|
||||||
IBinary myBinary;
|
IBinary myBinary;
|
||||||
|
|
||||||
myBinary=CProjectHelper.findBinary(testProject, "exebig_g");
|
myBinary=CProjectHelper.findBinary(testProject, "exebig_g");
|
||||||
assertTrue("A Binary", myBinary.isBinary());
|
assertTrue("A Binary", myBinary != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -23,13 +23,13 @@ import junit.framework.TestSuite;
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.model.CModelException;
|
import org.eclipse.cdt.core.model.CModelException;
|
||||||
import org.eclipse.cdt.core.model.ElementChangedEvent;
|
import org.eclipse.cdt.core.model.ElementChangedEvent;
|
||||||
|
import org.eclipse.cdt.core.model.IBuffer;
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
import org.eclipse.cdt.core.model.ICElementDelta;
|
import org.eclipse.cdt.core.model.ICElementDelta;
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
import org.eclipse.cdt.core.model.IElementChangedListener;
|
import org.eclipse.cdt.core.model.IElementChangedListener;
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
import org.eclipse.cdt.internal.core.model.CModelManager;
|
import org.eclipse.cdt.internal.core.model.CModelManager;
|
||||||
import org.eclipse.cdt.internal.core.model.IBuffer;
|
|
||||||
import org.eclipse.cdt.internal.core.model.IWorkingCopy;
|
import org.eclipse.cdt.internal.core.model.IWorkingCopy;
|
||||||
import org.eclipse.cdt.internal.core.model.TranslationUnit;
|
import org.eclipse.cdt.internal.core.model.TranslationUnit;
|
||||||
import org.eclipse.cdt.testplugin.CProjectHelper;
|
import org.eclipse.cdt.testplugin.CProjectHelper;
|
||||||
|
|
|
@ -164,7 +164,7 @@ public class TranslationUnitTests extends TestCase {
|
||||||
ITranslationUnit myTranslationUnit;
|
ITranslationUnit myTranslationUnit;
|
||||||
|
|
||||||
myTranslationUnit=CProjectHelper.findTranslationUnit(testProject,"exetest.c");
|
myTranslationUnit=CProjectHelper.findTranslationUnit(testProject,"exetest.c");
|
||||||
assertTrue("A TranslationUnit", myTranslationUnit.isTranslationUnit());
|
assertTrue("A TranslationUnit", myTranslationUnit != null);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,9 +17,9 @@ import junit.framework.Test;
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
import junit.framework.TestSuite;
|
import junit.framework.TestSuite;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.model.IBuffer;
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
import org.eclipse.cdt.internal.core.model.IBuffer;
|
|
||||||
import org.eclipse.cdt.internal.core.model.IWorkingCopy;
|
import org.eclipse.cdt.internal.core.model.IWorkingCopy;
|
||||||
import org.eclipse.cdt.internal.core.model.TranslationUnit;
|
import org.eclipse.cdt.internal.core.model.TranslationUnit;
|
||||||
import org.eclipse.cdt.testplugin.CProjectHelper;
|
import org.eclipse.cdt.testplugin.CProjectHelper;
|
||||||
|
|
|
@ -8,19 +8,22 @@ package org.eclipse.cdt.internal.ui;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.model.CModelException;
|
||||||
|
import org.eclipse.cdt.core.model.IArchive;
|
||||||
|
import org.eclipse.cdt.core.model.IArchiveContainer;
|
||||||
|
import org.eclipse.cdt.core.model.IBinary;
|
||||||
|
import org.eclipse.cdt.core.model.IBinaryContainer;
|
||||||
|
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.IParent;
|
||||||
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
import org.eclipse.core.resources.IContainer;
|
import org.eclipse.core.resources.IContainer;
|
||||||
import org.eclipse.core.resources.IFile;
|
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.jface.viewers.ITreeContentProvider;
|
import org.eclipse.jface.viewers.ITreeContentProvider;
|
||||||
import org.eclipse.jface.viewers.Viewer;
|
import org.eclipse.jface.viewers.Viewer;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.model.IArchiveContainer;
|
|
||||||
import org.eclipse.cdt.core.model.IBinaryContainer;
|
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
|
||||||
import org.eclipse.cdt.core.model.ICFile;
|
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
|
||||||
import org.eclipse.cdt.core.model.IParent;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A base content provider for C elements. It provides access to the
|
* A base content provider for C elements. It provides access to the
|
||||||
|
@ -33,11 +36,12 @@ import org.eclipse.cdt.core.model.IParent;
|
||||||
* <pre>
|
* <pre>
|
||||||
C model (<code>ICModel</code>)
|
C model (<code>ICModel</code>)
|
||||||
C project (<code>ICProject</code>)
|
C project (<code>ICProject</code>)
|
||||||
C Folder (<code>ICFolder</code>)
|
C Container(folders) (<code>ICContainer</code>)
|
||||||
C File (<code>ICFile</code>)
|
|
||||||
Translation unit (<code>ITranslationUnit</code>)
|
Translation unit (<code>ITranslationUnit</code>)
|
||||||
Binary file (<code>IBinary</code>)
|
Binary file (<code>IBinary</code>)
|
||||||
Archive file (<code>IArchive</code>)
|
Archive file (<code>IArchive</code>)
|
||||||
|
Non C Resource file (<code>Object</code>)
|
||||||
|
|
||||||
* </pre>
|
* </pre>
|
||||||
*/
|
*/
|
||||||
public class BaseCElementContentProvider implements ITreeContentProvider {
|
public class BaseCElementContentProvider implements ITreeContentProvider {
|
||||||
|
@ -112,26 +116,18 @@ public class BaseCElementContentProvider implements ITreeContentProvider {
|
||||||
public Object[] getChildren(Object element) {
|
public Object[] getChildren(Object element) {
|
||||||
if (element instanceof ICElement) {
|
if (element instanceof ICElement) {
|
||||||
ICElement celement = (ICElement)element;
|
ICElement celement = (ICElement)element;
|
||||||
if (celement.getElementType() == ICElement.C_FILE) {
|
if (celement instanceof ICModel) {
|
||||||
|
return getCProjects((ICModel)celement);
|
||||||
|
} else if (celement instanceof ICProject ) {
|
||||||
|
return getCProjectResources((ICProject)celement);
|
||||||
|
} else if (celement instanceof ICContainer) {
|
||||||
|
return getCResources((ICContainer)celement);
|
||||||
|
} else if (celement.getElementType() == ICElement.C_UNIT) {
|
||||||
if (fProvideMembers) {
|
if (fProvideMembers) {
|
||||||
return ((IParent)element).getChildren();
|
return ((IParent)element).getChildren();
|
||||||
}
|
}
|
||||||
} else if (celement instanceof IParent) {
|
} else if (celement instanceof IParent) {
|
||||||
if (celement instanceof ICProject ) {
|
return (Object[])((IParent)celement).getChildren();
|
||||||
ICElement[] children = ((IParent)celement).getChildren();
|
|
||||||
ArrayList list = new ArrayList(children.length);
|
|
||||||
for( int i = 0; i < children.length; i++ ) {
|
|
||||||
// Note, here we are starting the Archive and binary containers thread upfront.
|
|
||||||
if (children[i] instanceof IArchiveContainer || children[i] instanceof IBinaryContainer) {
|
|
||||||
if ( ((IParent)children[i]).getChildren().length == 0 ) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
list.add(children[i]);
|
|
||||||
}
|
|
||||||
return list.toArray();
|
|
||||||
} else
|
|
||||||
return (Object[])((IParent)celement).getChildren();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return getResources(element);
|
return getResources(element);
|
||||||
|
@ -143,24 +139,26 @@ public class BaseCElementContentProvider implements ITreeContentProvider {
|
||||||
*/
|
*/
|
||||||
public boolean hasChildren(Object element) {
|
public boolean hasChildren(Object element) {
|
||||||
if (fProvideMembers) {
|
if (fProvideMembers) {
|
||||||
if (element instanceof ICFile) {
|
// assume TUs and binary files are never empty
|
||||||
ICFile cfile = (ICFile)element;
|
if (element instanceof IBinary || element instanceof ITranslationUnit || element instanceof IArchive) {
|
||||||
// assume TUs and binary files are never empty
|
return true;
|
||||||
if (cfile.isBinary() || cfile.isTranslationUnit() || cfile.isArchive()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// don't allow to drill down into a compilation unit or class file
|
// don't allow to drill down into a compilation unit or class file
|
||||||
if (element instanceof ICFile || element instanceof IFile)
|
if (element instanceof ITranslationUnit || element instanceof IBinary || element instanceof IArchive) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (element instanceof ICProject) {
|
if (element instanceof ICProject) {
|
||||||
ICProject cp= (ICProject)element;
|
ICProject cp= (ICProject)element;
|
||||||
if (!cp.getProject().isOpen()) {
|
if (!cp.getProject().isOpen()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} else if (element instanceof ICContainer) {
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (element instanceof IParent) {
|
if (element instanceof IParent) {
|
||||||
|
@ -186,6 +184,36 @@ public class BaseCElementContentProvider implements ITreeContentProvider {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected Object[] getCProjects(ICModel cModel) {
|
||||||
|
return cModel.getCProjects();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Object[] getCProjectResources(ICProject cproject) {
|
||||||
|
Object[] objects = getCResources((ICContainer)cproject);
|
||||||
|
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});
|
||||||
|
}
|
||||||
|
return objects;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Object[] getCResources(ICContainer container) {
|
||||||
|
Object[] objects = null;
|
||||||
|
Object[] children = container.getChildren();
|
||||||
|
try {
|
||||||
|
objects = container.getNonCResources();
|
||||||
|
} catch (CModelException e) {
|
||||||
|
}
|
||||||
|
if (objects == null) {
|
||||||
|
return children;
|
||||||
|
}
|
||||||
|
return concatenate(children, objects);
|
||||||
|
}
|
||||||
|
|
||||||
private Object[] getResources(Object resource) {
|
private Object[] getResources(Object resource) {
|
||||||
try {
|
try {
|
||||||
if (resource instanceof IContainer) {
|
if (resource instanceof IContainer) {
|
||||||
|
@ -224,4 +252,18 @@ public class BaseCElementContentProvider implements ITreeContentProvider {
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Note: This method is for internal use only. Clients should not call this method.
|
||||||
|
*/
|
||||||
|
protected static Object[] concatenate(Object[] a1, Object[] a2) {
|
||||||
|
int a1Len = a1.length;
|
||||||
|
int a2Len = a2.length;
|
||||||
|
Object[] res = new Object[a1Len + a2Len];
|
||||||
|
System.arraycopy(a1, 0, res, 0, a1Len);
|
||||||
|
System.arraycopy(a2, 0, res, a1Len, a2Len);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,14 +5,14 @@ package org.eclipse.cdt.internal.ui;
|
||||||
* All Rights Reserved.
|
* All Rights Reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.model.IBinary;
|
||||||
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
|
import org.eclipse.jface.viewers.IBasicPropertyConstants;
|
||||||
import org.eclipse.ui.views.properties.IPropertyDescriptor;
|
import org.eclipse.ui.views.properties.IPropertyDescriptor;
|
||||||
import org.eclipse.ui.views.properties.FilePropertySource;
|
import org.eclipse.ui.views.properties.IPropertySource;
|
||||||
import org.eclipse.ui.views.properties.PropertyDescriptor;
|
import org.eclipse.ui.views.properties.PropertyDescriptor;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.model.IBinary;
|
public class BinaryPropertySource implements IPropertySource {
|
||||||
import org.eclipse.cdt.ui.*;
|
|
||||||
|
|
||||||
public class BinaryPropertySource extends FilePropertySource {
|
|
||||||
|
|
||||||
private final static String ELF_CPU= "CElementProperties.elf_cpu";
|
private final static String ELF_CPU= "CElementProperties.elf_cpu";
|
||||||
private final static String ELF_TEXT= "CElementProperties.elf_text";
|
private final static String ELF_TEXT= "CElementProperties.elf_text";
|
||||||
|
@ -78,8 +78,7 @@ public class BinaryPropertySource extends FilePropertySource {
|
||||||
}
|
}
|
||||||
|
|
||||||
public BinaryPropertySource(IBinary bin) {
|
public BinaryPropertySource(IBinary bin) {
|
||||||
super(bin.getFile());
|
binary= bin;
|
||||||
this.binary= bin;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -95,14 +94,15 @@ public class BinaryPropertySource extends FilePropertySource {
|
||||||
* @see IPropertySource#getPropertyValue
|
* @see IPropertySource#getPropertyValue
|
||||||
*/
|
*/
|
||||||
public Object getPropertyValue(Object name) {
|
public Object getPropertyValue(Object name) {
|
||||||
if (element != null) {
|
// if (element != null) {
|
||||||
Object returnValue = super.getPropertyValue(name);
|
// Object returnValue = super.getPropertyValue(name);
|
||||||
|
//
|
||||||
if(returnValue != null)
|
// if(returnValue != null)
|
||||||
return returnValue;
|
// return returnValue;
|
||||||
}
|
// }
|
||||||
|
if (name.equals(IBasicPropertyConstants.P_TEXT)) {
|
||||||
if (name.equals(ICElementPropertyConstants.P_ELF_CPU)) {
|
return binary.getElementName();
|
||||||
|
} else if (name.equals(ICElementPropertyConstants.P_ELF_CPU)) {
|
||||||
return binary.getCPU();
|
return binary.getCPU();
|
||||||
} else if (name.equals(ICElementPropertyConstants.P_ELF_TEXT)) {
|
} else if (name.equals(ICElementPropertyConstants.P_ELF_TEXT)) {
|
||||||
return Long.toString(binary.getText());
|
return Long.toString(binary.getText());
|
||||||
|
@ -143,12 +143,40 @@ public class BinaryPropertySource extends FilePropertySource {
|
||||||
* Return the Property Descriptors for the file type.
|
* Return the Property Descriptors for the file type.
|
||||||
*/
|
*/
|
||||||
private void initializeBinaryDescriptors() {
|
private void initializeBinaryDescriptors() {
|
||||||
IPropertyDescriptor[] superDescriptors = super.getPropertyDescriptors();
|
// IPropertyDescriptor[] superDescriptors = super.getPropertyDescriptors();
|
||||||
int superLength = superDescriptors.length;
|
// int superLength = superDescriptors.length;
|
||||||
IPropertyDescriptor[] binDescriptors = getInitialPropertyDescriptor();
|
// IPropertyDescriptor[] binDescriptors = getInitialPropertyDescriptor();
|
||||||
int binLength = binDescriptors.length;
|
// int binLength = binDescriptors.length;
|
||||||
fgPropertyDescriptors = new IPropertyDescriptor[superLength + binLength];
|
// fgPropertyDescriptors = new IPropertyDescriptor[superLength + binLength];
|
||||||
System.arraycopy(superDescriptors, 0, fgPropertyDescriptors, 0, superLength);
|
// System.arraycopy(superDescriptors, 0, fgPropertyDescriptors, 0, superLength);
|
||||||
System.arraycopy(binDescriptors, 0, fgPropertyDescriptors, superLength, binLength);
|
// System.arraycopy(binDescriptors, 0, fgPropertyDescriptors, superLength, binLength);
|
||||||
|
fgPropertyDescriptors = getInitialPropertyDescriptor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.ui.views.properties.IPropertySource#getEditableValue()
|
||||||
|
*/
|
||||||
|
public Object getEditableValue() {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.ui.views.properties.IPropertySource#isPropertySet(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public boolean isPropertySet(Object id) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.ui.views.properties.IPropertySource#resetPropertyValue(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public void resetPropertyValue(Object id) {
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.ui.views.properties.IPropertySource#setPropertyValue(java.lang.Object, java.lang.Object)
|
||||||
|
*/
|
||||||
|
public void setPropertyValue(Object id, Object value) {
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,8 +8,6 @@ package org.eclipse.cdt.internal.ui;
|
||||||
import org.eclipse.cdt.core.model.CModelException;
|
import org.eclipse.cdt.core.model.CModelException;
|
||||||
import org.eclipse.cdt.core.model.IBinary;
|
import org.eclipse.cdt.core.model.IBinary;
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
import org.eclipse.cdt.core.model.ICFile;
|
|
||||||
import org.eclipse.cdt.core.model.ICResource;
|
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
|
@ -51,21 +49,17 @@ public class CElementAdapterFactory implements IAdapterFactory {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (IPropertySource.class.equals(key)) {
|
if (IPropertySource.class.equals(key)) {
|
||||||
if (celem.getElementType() == ICElement.C_FILE) {
|
if (celem instanceof IBinary) {
|
||||||
if (celem instanceof IBinary) {
|
return new BinaryPropertySource((IBinary)celem);
|
||||||
return new BinaryPropertySource((IBinary)celem);
|
} else if (celem.getElementType() == ICElement.C_UNIT) {
|
||||||
}
|
IResource file = celem.getResource();
|
||||||
IFile file = ((ICFile)celem).getFile();
|
if (file != null && file instanceof IFile) {
|
||||||
if (file != null) {
|
return new FilePropertySource((IFile)file);
|
||||||
return new FilePropertySource(file);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
try {
|
res = celem.getResource();
|
||||||
if ( celem instanceof ICResource ) {
|
if (res != null) {
|
||||||
res = ((ICResource)celem).getResource();
|
return new ResourcePropertySource(res);
|
||||||
return new ResourcePropertySource(res);
|
|
||||||
}
|
|
||||||
} catch (CModelException e) {
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new CElementPropertySource(celem);
|
return new CElementPropertySource(celem);
|
||||||
|
|
|
@ -5,22 +5,19 @@ package org.eclipse.cdt.internal.ui;
|
||||||
* All Rights Reserved.
|
* All Rights Reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import org.eclipse.swt.graphics.Image;
|
|
||||||
import org.eclipse.swt.graphics.Point;
|
|
||||||
|
|
||||||
import org.eclipse.jface.resource.ImageDescriptor;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.core.model.IBinary;
|
import org.eclipse.cdt.core.model.IBinary;
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
import org.eclipse.cdt.core.model.ICFile;
|
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
import org.eclipse.cdt.core.model.IMember;
|
import org.eclipse.cdt.core.model.IMember;
|
||||||
import org.eclipse.cdt.core.model.IMethodDeclaration;
|
import org.eclipse.cdt.core.model.IMethodDeclaration;
|
||||||
import org.eclipse.cdt.internal.ui.util.ImageDescriptorRegistry;
|
import org.eclipse.cdt.internal.ui.util.ImageDescriptorRegistry;
|
||||||
import org.eclipse.cdt.ui.*;
|
import org.eclipse.cdt.ui.CElementImageDescriptor;
|
||||||
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.runtime.IAdaptable;
|
import org.eclipse.core.runtime.IAdaptable;
|
||||||
|
import org.eclipse.jface.resource.ImageDescriptor;
|
||||||
|
import org.eclipse.swt.graphics.Image;
|
||||||
|
import org.eclipse.swt.graphics.Point;
|
||||||
import org.eclipse.ui.ISharedImages;
|
import org.eclipse.ui.ISharedImages;
|
||||||
import org.eclipse.ui.model.IWorkbenchAdapter;
|
import org.eclipse.ui.model.IWorkbenchAdapter;
|
||||||
|
|
||||||
|
@ -96,9 +93,9 @@ public class CElementImageProvider {
|
||||||
if (element instanceof ICElement) {
|
if (element instanceof ICElement) {
|
||||||
descriptor= getCImageDescriptor((ICElement) element, flags);
|
descriptor= getCImageDescriptor((ICElement) element, flags);
|
||||||
}
|
}
|
||||||
if (descriptor == null && element instanceof ICFile) {
|
// if (descriptor == null && element instanceof ICFile) {
|
||||||
element = ((ICFile)element).getFile();
|
// element = ((ICFile)element).getFile();
|
||||||
}
|
// }
|
||||||
if (descriptor == null && element instanceof IAdaptable) {
|
if (descriptor == null && element instanceof IAdaptable) {
|
||||||
descriptor= getWorkbenchImageDescriptor((IAdaptable) element, flags);
|
descriptor= getWorkbenchImageDescriptor((IAdaptable) element, flags);
|
||||||
}
|
}
|
||||||
|
@ -159,31 +156,30 @@ public class CElementImageProvider {
|
||||||
public ImageDescriptor getBaseImageDescriptor(ICElement celement, int renderFlags) {
|
public ImageDescriptor getBaseImageDescriptor(ICElement celement, int renderFlags) {
|
||||||
int type = celement.getElementType();
|
int type = celement.getElementType();
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case ICElement.C_CONTAINER:
|
case ICElement.C_VCONTAINER:
|
||||||
return CPluginImages.DESC_OBJS_CONTAINER;
|
return CPluginImages.DESC_OBJS_CONTAINER;
|
||||||
|
|
||||||
case ICElement.C_FILE:
|
case ICElement.C_BINARY: {
|
||||||
ICFile cfile = (ICFile)celement;
|
IBinary bin = (IBinary)celement;
|
||||||
if (cfile.isArchive()) {
|
if (bin.isExecutable()) {
|
||||||
return CPluginImages.DESC_OBJS_ARCHIVE;
|
if (bin.hasDebug())
|
||||||
} else if (cfile.isBinary()) {
|
return CPluginImages.DESC_OBJS_CEXEC_DEBUG;
|
||||||
IBinary bin = (IBinary)cfile;
|
return CPluginImages.DESC_OBJS_CEXEC;
|
||||||
if (bin.isExecutable()) {
|
} else if (bin.isSharedLib()) {
|
||||||
if (bin.hasDebug())
|
return CPluginImages.DESC_OBJS_SHLIB;
|
||||||
return CPluginImages.DESC_OBJS_CEXEC_DEBUG;
|
} else if (bin.isCore()) {
|
||||||
return CPluginImages.DESC_OBJS_CEXEC;
|
return CPluginImages.DESC_OBJS_CORE;
|
||||||
} else if (bin.isSharedLib()) {
|
|
||||||
return CPluginImages.DESC_OBJS_SHLIB;
|
|
||||||
} else if (bin.isCore()) {
|
|
||||||
return CPluginImages.DESC_OBJS_CORE;
|
|
||||||
}
|
|
||||||
return CPluginImages.DESC_OBJS_BINARY;
|
|
||||||
} else if (cfile.isTranslationUnit()) {
|
|
||||||
return CPluginImages.DESC_OBJS_TUNIT;
|
|
||||||
}
|
}
|
||||||
break;
|
return CPluginImages.DESC_OBJS_BINARY;
|
||||||
|
}
|
||||||
|
|
||||||
|
case ICElement.C_ARCHIVE:
|
||||||
|
return CPluginImages.DESC_OBJS_ARCHIVE;
|
||||||
|
|
||||||
|
case ICElement.C_UNIT:
|
||||||
|
return CPluginImages.DESC_OBJS_TUNIT;
|
||||||
|
|
||||||
case ICElement.C_FOLDER:
|
case ICElement.C_CCONTAINER:
|
||||||
return DESC_OBJ_FOLDER;
|
return DESC_OBJ_FOLDER;
|
||||||
|
|
||||||
case ICElement.C_PROJECT:
|
case ICElement.C_PROJECT:
|
||||||
|
@ -241,10 +237,10 @@ public class CElementImageProvider {
|
||||||
|
|
||||||
public ImageDescriptor getCElementImageDescriptor(int type) {
|
public ImageDescriptor getCElementImageDescriptor(int type) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case ICElement.C_CONTAINER:
|
case ICElement.C_VCONTAINER:
|
||||||
return CPluginImages.DESC_OBJS_CONTAINER;
|
return CPluginImages.DESC_OBJS_CONTAINER;
|
||||||
|
|
||||||
case ICElement.C_FILE:
|
case ICElement.C_UNIT:
|
||||||
return CPluginImages.DESC_OBJS_TUNIT;
|
return CPluginImages.DESC_OBJS_TUNIT;
|
||||||
|
|
||||||
case ICElement.C_STRUCT:
|
case ICElement.C_STRUCT:
|
||||||
|
|
|
@ -7,11 +7,10 @@ package org.eclipse.cdt.internal.ui;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
import org.eclipse.cdt.core.model.ICModelMarker;
|
import org.eclipse.cdt.core.model.ICModelMarker;
|
||||||
import org.eclipse.cdt.core.model.ICResource;
|
|
||||||
import org.eclipse.cdt.core.model.ISourceRange;
|
import org.eclipse.cdt.core.model.ISourceRange;
|
||||||
import org.eclipse.cdt.core.model.ISourceReference;
|
import org.eclipse.cdt.core.model.ISourceReference;
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
import org.eclipse.cdt.ui.*;
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
import org.eclipse.core.resources.IMarker;
|
import org.eclipse.core.resources.IMarker;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
@ -41,10 +40,10 @@ public class ErrorTickAdornmentProvider implements IAdornmentProvider {
|
||||||
int type= element.getElementType();
|
int type= element.getElementType();
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case ICElement.C_PROJECT:
|
case ICElement.C_PROJECT:
|
||||||
case ICElement.C_FOLDER:
|
case ICElement.C_CCONTAINER:
|
||||||
return getErrorTicksFromMarkers(((ICResource)element).getResource(), IResource.DEPTH_INFINITE, null);
|
return getErrorTicksFromMarkers(element.getResource(), IResource.DEPTH_INFINITE, null);
|
||||||
case ICElement.C_FILE:
|
case ICElement.C_UNIT:
|
||||||
return getErrorTicksFromMarkers(((ICResource)element).getResource(), IResource.DEPTH_ONE, null);
|
return getErrorTicksFromMarkers(element.getResource(), IResource.DEPTH_ONE, null);
|
||||||
case ICElement.C_FUNCTION:
|
case ICElement.C_FUNCTION:
|
||||||
case ICElement.C_CLASS:
|
case ICElement.C_CLASS:
|
||||||
case ICElement.C_UNION:
|
case ICElement.C_UNION:
|
||||||
|
|
|
@ -64,7 +64,7 @@ public class CStructureCreator implements IStructureCreator {
|
||||||
|
|
||||||
Document doc= new Document(s != null ? s : "");
|
Document doc= new Document(s != null ? s : "");
|
||||||
|
|
||||||
CNode root= new CNode(null, ICElement.C_FILE, "root", doc, 0, 0);
|
CNode root= new CNode(null, ICElement.C_UNIT, "root", doc, 0, 0);
|
||||||
|
|
||||||
DocumentInputStream is= new DocumentInputStream(doc);
|
DocumentInputStream is= new DocumentInputStream(doc);
|
||||||
IStructurizerCallback callback= new CNodeTreeConstructor(root, doc);
|
IStructurizerCallback callback= new CNodeTreeConstructor(root, doc);
|
||||||
|
|
|
@ -17,7 +17,7 @@ import org.eclipse.core.runtime.IAdaptable;
|
||||||
import org.eclipse.cdt.internal.ui.util.StringMatcher;
|
import org.eclipse.cdt.internal.ui.util.StringMatcher;
|
||||||
import org.eclipse.cdt.ui.CUIPlugin;
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.model.ICFolder;
|
import org.eclipse.cdt.core.model.ICContainer;
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
|
|
||||||
public class CPatternFilter extends ViewerFilter {
|
public class CPatternFilter extends ViewerFilter {
|
||||||
|
@ -108,7 +108,7 @@ public class CPatternFilter extends ViewerFilter {
|
||||||
|
|
||||||
// Only apply the rule for Projects and folders.
|
// Only apply the rule for Projects and folders.
|
||||||
if (parentElement instanceof ICProject
|
if (parentElement instanceof ICProject
|
||||||
|| parentElement instanceof ICFolder) {
|
|| parentElement instanceof ICContainer) {
|
||||||
if (resource != null) {
|
if (resource != null) {
|
||||||
String name = resource.getName();
|
String name = resource.getName();
|
||||||
StringMatcher[] testMatchers = getMatchers();
|
StringMatcher[] testMatchers = getMatchers();
|
||||||
|
|
|
@ -14,8 +14,7 @@ import org.eclipse.cdt.core.model.IArchiveContainer;
|
||||||
import org.eclipse.cdt.core.model.IBinary;
|
import org.eclipse.cdt.core.model.IBinary;
|
||||||
import org.eclipse.cdt.core.model.IBinaryContainer;
|
import org.eclipse.cdt.core.model.IBinaryContainer;
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
import org.eclipse.cdt.core.model.ICFile;
|
import org.eclipse.cdt.core.model.ICModel;
|
||||||
import org.eclipse.cdt.core.model.ICRoot;
|
|
||||||
import org.eclipse.cdt.core.model.IParent;
|
import org.eclipse.cdt.core.model.IParent;
|
||||||
import org.eclipse.cdt.core.resources.MakeUtil;
|
import org.eclipse.cdt.core.resources.MakeUtil;
|
||||||
import org.eclipse.cdt.internal.ui.StandardCElementLabelProvider;
|
import org.eclipse.cdt.internal.ui.StandardCElementLabelProvider;
|
||||||
|
@ -263,7 +262,7 @@ public class CView extends ViewPart implements IMenuListener, ISetSelectionTarge
|
||||||
|
|
||||||
public void treeExpanded(TreeExpansionEvent event) {
|
public void treeExpanded(TreeExpansionEvent event) {
|
||||||
final Object element= event.getElement();
|
final Object element= event.getElement();
|
||||||
if (element instanceof ICFile) {
|
if (element instanceof IParent) {
|
||||||
//viewer.refresh (element);
|
//viewer.refresh (element);
|
||||||
Control ctrl= viewer.getControl();
|
Control ctrl= viewer.getControl();
|
||||||
if (ctrl != null && !ctrl.isDisposed()) {
|
if (ctrl != null && !ctrl.isDisposed()) {
|
||||||
|
@ -447,7 +446,7 @@ public class CView extends ViewPart implements IMenuListener, ISetSelectionTarge
|
||||||
else
|
else
|
||||||
initFilterFromPreferences();
|
initFilterFromPreferences();
|
||||||
|
|
||||||
viewer.setInput (CoreModel.getDefault().getCRoot());
|
viewer.setInput (CoreModel.getDefault().getCModel());
|
||||||
|
|
||||||
MenuManager menuMgr= new MenuManager("#PopupMenu"); //$NON-NLS-1$
|
MenuManager menuMgr= new MenuManager("#PopupMenu"); //$NON-NLS-1$
|
||||||
menuMgr.setRemoveAllWhenShown(true);
|
menuMgr.setRemoveAllWhenShown(true);
|
||||||
|
@ -967,7 +966,7 @@ public class CView extends ViewPart implements IMenuListener, ISetSelectionTarge
|
||||||
ICElement celement = (ICElement)o;
|
ICElement celement = (ICElement)o;
|
||||||
IResource res = (IResource)celement.getAdapter(IResource.class);
|
IResource res = (IResource)celement.getAdapter(IResource.class);
|
||||||
if (res != null) {
|
if (res != null) {
|
||||||
if (celement.getElementType() == ICElement.C_CONTAINER) {
|
if (celement.getElementType() == ICElement.C_VCONTAINER) {
|
||||||
ICElement parent = celement.getParent();
|
ICElement parent = celement.getParent();
|
||||||
IResource proj = (IResource)parent.getAdapter(IResource.class);
|
IResource proj = (IResource)parent.getAdapter(IResource.class);
|
||||||
if (celement instanceof IArchiveContainer)
|
if (celement instanceof IArchiveContainer)
|
||||||
|
@ -993,7 +992,7 @@ public class CView extends ViewPart implements IMenuListener, ISetSelectionTarge
|
||||||
void updateTitle () {
|
void updateTitle () {
|
||||||
Object input= getViewer().getInput();
|
Object input= getViewer().getInput();
|
||||||
String viewName= getConfigurationElement().getAttribute("name"); //$NON-NLS-1$
|
String viewName= getConfigurationElement().getAttribute("name"); //$NON-NLS-1$
|
||||||
if (input == null || (input instanceof ICRoot)) {
|
if (input == null || (input instanceof ICModel)) {
|
||||||
setTitle(viewName);
|
setTitle(viewName);
|
||||||
setTitleToolTip(""); //$NON-NLS-1$
|
setTitleToolTip(""); //$NON-NLS-1$
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -9,6 +9,8 @@ import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.model.CModelException;
|
||||||
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.jface.viewers.ISelection;
|
import org.eclipse.jface.viewers.ISelection;
|
||||||
|
@ -22,11 +24,6 @@ import org.eclipse.swt.dnd.FileTransfer;
|
||||||
import org.eclipse.swt.widgets.Control;
|
import org.eclipse.swt.widgets.Control;
|
||||||
import org.eclipse.ui.part.ResourceTransfer;
|
import org.eclipse.ui.part.ResourceTransfer;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.model.CModelException;
|
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
|
||||||
import org.eclipse.cdt.core.model.ICFile;
|
|
||||||
import org.eclipse.cdt.core.model.ICFolder;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implements drag behaviour when items are dragged out of the
|
* Implements drag behaviour when items are dragged out of the
|
||||||
* resource navigator.
|
* resource navigator.
|
||||||
|
@ -102,7 +99,15 @@ class CViewDragAdapter extends DragSourceAdapter {
|
||||||
IStructuredSelection selection = (IStructuredSelection)selectionProvider.getSelection();
|
IStructuredSelection selection = (IStructuredSelection)selectionProvider.getSelection();
|
||||||
for (Iterator i = selection.iterator(); i.hasNext();) {
|
for (Iterator i = selection.iterator(); i.hasNext();) {
|
||||||
Object next = i.next();
|
Object next = i.next();
|
||||||
if (!(next instanceof ICFile || next instanceof ICFolder)) {
|
IResource res = null;
|
||||||
|
if (next instanceof ICElement) {
|
||||||
|
ICElement celement = (ICElement)next;
|
||||||
|
try {
|
||||||
|
res = celement.getResource();
|
||||||
|
} catch (CModelException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (res == null) {
|
||||||
event.doit = false;
|
event.doit = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,17 +9,20 @@ import org.eclipse.cdt.core.model.CModelException;
|
||||||
import org.eclipse.cdt.core.model.CoreModel;
|
import org.eclipse.cdt.core.model.CoreModel;
|
||||||
import org.eclipse.cdt.core.model.IArchive;
|
import org.eclipse.cdt.core.model.IArchive;
|
||||||
import org.eclipse.cdt.core.model.IArchiveContainer;
|
import org.eclipse.cdt.core.model.IArchiveContainer;
|
||||||
|
import org.eclipse.cdt.core.model.IBinary;
|
||||||
import org.eclipse.cdt.core.model.IBinaryContainer;
|
import org.eclipse.cdt.core.model.IBinaryContainer;
|
||||||
|
import org.eclipse.cdt.core.model.ICContainer;
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
import org.eclipse.cdt.core.model.ICFile;
|
import org.eclipse.cdt.core.model.ICModel;
|
||||||
import org.eclipse.cdt.core.model.ICFolder;
|
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
import org.eclipse.cdt.core.model.ICRoot;
|
|
||||||
import org.eclipse.cdt.core.model.IFunction;
|
import org.eclipse.cdt.core.model.IFunction;
|
||||||
import org.eclipse.cdt.core.model.IFunctionDeclaration;
|
import org.eclipse.cdt.core.model.IFunctionDeclaration;
|
||||||
import org.eclipse.cdt.core.model.IInclude;
|
import org.eclipse.cdt.core.model.IInclude;
|
||||||
import org.eclipse.cdt.core.model.IMacro;
|
import org.eclipse.cdt.core.model.IMacro;
|
||||||
|
import org.eclipse.cdt.core.model.IMethod;
|
||||||
|
import org.eclipse.cdt.core.model.IMethodDeclaration;
|
||||||
import org.eclipse.cdt.core.model.INamespace;
|
import org.eclipse.cdt.core.model.INamespace;
|
||||||
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
import org.eclipse.cdt.core.model.IUsing;
|
import org.eclipse.cdt.core.model.IUsing;
|
||||||
import org.eclipse.cdt.core.model.IVariable;
|
import org.eclipse.cdt.core.model.IVariable;
|
||||||
import org.eclipse.cdt.core.model.IVariableDeclaration;
|
import org.eclipse.cdt.core.model.IVariableDeclaration;
|
||||||
|
@ -38,7 +41,7 @@ import org.eclipse.jface.viewers.ViewerSorter;
|
||||||
public class CViewSorter extends ViewerSorter {
|
public class CViewSorter extends ViewerSorter {
|
||||||
|
|
||||||
public int category (Object element) {
|
public int category (Object element) {
|
||||||
if (element instanceof ICRoot) {
|
if (element instanceof ICModel) {
|
||||||
return 0;
|
return 0;
|
||||||
} else if (element instanceof ICProject) {
|
} else if (element instanceof ICProject) {
|
||||||
return 10;
|
return 10;
|
||||||
|
@ -46,12 +49,12 @@ public class CViewSorter extends ViewerSorter {
|
||||||
return 20;
|
return 20;
|
||||||
} else if (element instanceof IArchiveContainer) {
|
} else if (element instanceof IArchiveContainer) {
|
||||||
return 30;
|
return 30;
|
||||||
} else if (element instanceof ICFolder) {
|
} else if (element instanceof ICContainer) {
|
||||||
return 40;
|
return 40;
|
||||||
} else if (element instanceof ICFile) {
|
} else if (element instanceof ITranslationUnit) {
|
||||||
IResource res = null;
|
IResource res = null;
|
||||||
try {
|
try {
|
||||||
res = ((ICFile)element).getUnderlyingResource();
|
res = ((ITranslationUnit)element).getUnderlyingResource();
|
||||||
} catch (CModelException e) {
|
} catch (CModelException e) {
|
||||||
}
|
}
|
||||||
if (res != null) {
|
if (res != null) {
|
||||||
|
@ -66,7 +69,7 @@ public class CViewSorter extends ViewerSorter {
|
||||||
String[] sources = CoreModel.getDefault().getSourceExtensions();
|
String[] sources = CoreModel.getDefault().getSourceExtensions();
|
||||||
for (int i = 0; i < sources.length; i++) {
|
for (int i = 0; i < sources.length; i++) {
|
||||||
if (ext.equals(sources[i])) {
|
if (ext.equals(sources[i])) {
|
||||||
return 44;
|
return 47;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 48;
|
return 48;
|
||||||
|
@ -82,20 +85,13 @@ public class CViewSorter extends ViewerSorter {
|
||||||
return 80;
|
return 80;
|
||||||
} else if (element instanceof IUsing) {
|
} else if (element instanceof IUsing) {
|
||||||
return 90;
|
return 90;
|
||||||
} else if (element instanceof IFunctionDeclaration) {
|
} else if (element instanceof IFunctionDeclaration && ! (element instanceof IFunction)) {
|
||||||
return 100;
|
return 100;
|
||||||
} else if (element instanceof IVariableDeclaration) {
|
} else if (element instanceof IMethodDeclaration && !(element instanceof IMethod)) {
|
||||||
return 110;
|
return 110;
|
||||||
} else if (element instanceof IVariable) {
|
} else if (element instanceof IVariableDeclaration) {
|
||||||
String name = ((ICElement)element).getElementName();
|
|
||||||
if (name.startsWith("__")) {
|
|
||||||
return 112;
|
|
||||||
}
|
|
||||||
if (name.charAt(0) == '_') {
|
|
||||||
return 114;
|
|
||||||
}
|
|
||||||
return 120;
|
return 120;
|
||||||
} else if (element instanceof IFunction) {
|
} else if (element instanceof IVariable) {
|
||||||
String name = ((ICElement)element).getElementName();
|
String name = ((ICElement)element).getElementName();
|
||||||
if (name.startsWith("__")) {
|
if (name.startsWith("__")) {
|
||||||
return 122;
|
return 122;
|
||||||
|
@ -104,7 +100,7 @@ public class CViewSorter extends ViewerSorter {
|
||||||
return 124;
|
return 124;
|
||||||
}
|
}
|
||||||
return 130;
|
return 130;
|
||||||
} else if (element instanceof ICElement) {
|
} else if (element instanceof IFunction) {
|
||||||
String name = ((ICElement)element).getElementName();
|
String name = ((ICElement)element).getElementName();
|
||||||
if (name.startsWith("__")) {
|
if (name.startsWith("__")) {
|
||||||
return 132;
|
return 132;
|
||||||
|
@ -113,9 +109,20 @@ public class CViewSorter extends ViewerSorter {
|
||||||
return 134;
|
return 134;
|
||||||
}
|
}
|
||||||
return 140;
|
return 140;
|
||||||
} else if (element instanceof IArchive) {
|
} else if (element instanceof ICElement) {
|
||||||
|
String name = ((ICElement)element).getElementName();
|
||||||
|
if (name.startsWith("__")) {
|
||||||
|
return 142;
|
||||||
|
}
|
||||||
|
if (name.charAt(0) == '_') {
|
||||||
|
return 144;
|
||||||
|
}
|
||||||
return 150;
|
return 150;
|
||||||
|
} else if (element instanceof IArchive) {
|
||||||
|
return 160;
|
||||||
|
} else if (element instanceof IBinary) {
|
||||||
|
return 170;
|
||||||
}
|
}
|
||||||
return 80;
|
return 200;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,9 +11,9 @@ import java.io.InputStream;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.model.CModelException;
|
import org.eclipse.cdt.core.model.CModelException;
|
||||||
import org.eclipse.cdt.core.model.CoreModel;
|
import org.eclipse.cdt.core.model.CoreModel;
|
||||||
import org.eclipse.cdt.core.model.ICOpenable;
|
import org.eclipse.cdt.core.model.IBuffer;
|
||||||
|
import org.eclipse.cdt.core.model.IOpenable;
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
import org.eclipse.cdt.internal.core.model.IBuffer;
|
|
||||||
import org.eclipse.cdt.internal.core.model.IBufferFactory;
|
import org.eclipse.cdt.internal.core.model.IBufferFactory;
|
||||||
import org.eclipse.cdt.internal.core.model.IWorkingCopy;
|
import org.eclipse.cdt.internal.core.model.IWorkingCopy;
|
||||||
import org.eclipse.cdt.internal.ui.CStatusConstants;
|
import org.eclipse.cdt.internal.ui.CStatusConstants;
|
||||||
|
@ -111,7 +111,7 @@ public class CDocumentProvider extends FileDocumentProvider implements IWorkingC
|
||||||
return CDocumentProvider.this.createDocument(input);
|
return CDocumentProvider.this.createDocument(input);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IBuffer createBuffer(ICOpenable owner) {
|
public IBuffer createBuffer(IOpenable owner) {
|
||||||
try {
|
try {
|
||||||
if (owner instanceof IWorkingCopy) {
|
if (owner instanceof IWorkingCopy) {
|
||||||
|
|
||||||
|
|
|
@ -16,11 +16,11 @@ import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.model.BufferChangedEvent;
|
||||||
import org.eclipse.cdt.core.model.CModelException;
|
import org.eclipse.cdt.core.model.CModelException;
|
||||||
import org.eclipse.cdt.core.model.ICOpenable;
|
import org.eclipse.cdt.core.model.IBuffer;
|
||||||
import org.eclipse.cdt.internal.core.model.BufferChangedEvent;
|
import org.eclipse.cdt.core.model.IBufferChangedListener;
|
||||||
import org.eclipse.cdt.internal.core.model.IBuffer;
|
import org.eclipse.cdt.core.model.IOpenable;
|
||||||
import org.eclipse.cdt.internal.core.model.IBufferChangedListener;
|
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
@ -74,7 +74,7 @@ public class DocumentAdapter implements IBuffer, IDocumentListener {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICOpenable getOwner() {
|
public IOpenable getOwner() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -163,7 +163,7 @@ public class DocumentAdapter implements IBuffer, IDocumentListener {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private ICOpenable fOwner;
|
private IOpenable fOwner;
|
||||||
private IDocument fDocument;
|
private IDocument fDocument;
|
||||||
private DocumentSetCommand fSetCmd= new DocumentSetCommand();
|
private DocumentSetCommand fSetCmd= new DocumentSetCommand();
|
||||||
private DocumentReplaceCommand fReplaceCmd= new DocumentReplaceCommand();
|
private DocumentReplaceCommand fReplaceCmd= new DocumentReplaceCommand();
|
||||||
|
@ -178,7 +178,7 @@ public class DocumentAdapter implements IBuffer, IDocumentListener {
|
||||||
private IStatus fStatus;
|
private IStatus fStatus;
|
||||||
|
|
||||||
|
|
||||||
public DocumentAdapter(ICOpenable owner, IDocument document, ILineTracker lineTracker, CDocumentProvider provider, Object providerKey) {
|
public DocumentAdapter(IOpenable owner, IDocument document, ILineTracker lineTracker, CDocumentProvider provider, Object providerKey) {
|
||||||
|
|
||||||
Assert.isNotNull(document);
|
Assert.isNotNull(document);
|
||||||
Assert.isNotNull(lineTracker);
|
Assert.isNotNull(lineTracker);
|
||||||
|
@ -352,8 +352,8 @@ public class DocumentAdapter implements IBuffer, IDocumentListener {
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.cdt.internal.core.model.IBuffer#getOwner()
|
* @see org.eclipse.cdt.internal.core.model.IBuffer#getOwner()
|
||||||
*/
|
*/
|
||||||
public ICOpenable getOwner() {
|
public IOpenable getOwner() {
|
||||||
return (ICOpenable) fOwner;
|
return (IOpenable) fOwner;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -124,7 +124,11 @@ public class EditorUtility {
|
||||||
IStorage store = null;
|
IStorage store = null;
|
||||||
Process objdump = null;
|
Process objdump = null;
|
||||||
IPath path;
|
IPath path;
|
||||||
IFile file = bin.getFile();
|
IResource file = null;
|
||||||
|
try {
|
||||||
|
file = bin.getResource();
|
||||||
|
} catch (CModelException e1) {
|
||||||
|
}
|
||||||
if (file == null)
|
if (file == null)
|
||||||
return store;
|
return store;
|
||||||
path = file.getLocation();
|
path = file.getLocation();
|
||||||
|
|
|
@ -13,15 +13,13 @@ import org.eclipse.cdt.core.model.IArchive;
|
||||||
import org.eclipse.cdt.core.model.IBinary;
|
import org.eclipse.cdt.core.model.IBinary;
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
import org.eclipse.cdt.core.model.ICElementDelta;
|
import org.eclipse.cdt.core.model.ICElementDelta;
|
||||||
import org.eclipse.cdt.core.model.ICFile;
|
import org.eclipse.cdt.core.model.ICModel;
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
import org.eclipse.cdt.core.model.ICRoot;
|
|
||||||
import org.eclipse.cdt.core.model.IElementChangedListener;
|
import org.eclipse.cdt.core.model.IElementChangedListener;
|
||||||
import org.eclipse.cdt.core.model.IParent;
|
import org.eclipse.cdt.core.model.IParent;
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
import org.eclipse.cdt.internal.ui.BaseCElementContentProvider;
|
import org.eclipse.cdt.internal.ui.BaseCElementContentProvider;
|
||||||
import org.eclipse.core.runtime.IAdaptable;
|
import org.eclipse.core.runtime.IAdaptable;
|
||||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
|
||||||
import org.eclipse.jface.viewers.ITreeContentProvider;
|
import org.eclipse.jface.viewers.ITreeContentProvider;
|
||||||
import org.eclipse.jface.viewers.StructuredViewer;
|
import org.eclipse.jface.viewers.StructuredViewer;
|
||||||
import org.eclipse.jface.viewers.Viewer;
|
import org.eclipse.jface.viewers.Viewer;
|
||||||
|
@ -50,7 +48,7 @@ public class CElementContentProvider extends BaseCElementContentProvider impleme
|
||||||
fViewer = (StructuredViewer)viewer;
|
fViewer = (StructuredViewer)viewer;
|
||||||
|
|
||||||
if (oldInput == null && newInput != null) {
|
if (oldInput == null && newInput != null) {
|
||||||
if (newInput instanceof ICRoot)
|
if (newInput instanceof ICModel)
|
||||||
CoreModel.getDefault().addElementChangedListener(this);
|
CoreModel.getDefault().addElementChangedListener(this);
|
||||||
} else if (oldInput != null && newInput == null) {
|
} else if (oldInput != null && newInput == null) {
|
||||||
CoreModel.getDefault().removeElementChangedListener(this);
|
CoreModel.getDefault().removeElementChangedListener(this);
|
||||||
|
@ -103,22 +101,16 @@ public class CElementContentProvider extends BaseCElementContentProvider impleme
|
||||||
if (kind == ICElementDelta.REMOVED) {
|
if (kind == ICElementDelta.REMOVED) {
|
||||||
Object parent = getParent(element);
|
Object parent = getParent(element);
|
||||||
postRemove(element);
|
postRemove(element);
|
||||||
if (element instanceof ICFile) {
|
if (updateContainer(element)) {
|
||||||
ICFile cfile = (ICFile)element;
|
postRefresh(parent);
|
||||||
if (updateContainer(cfile)) {
|
|
||||||
postRefresh(parent);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (kind == ICElementDelta.ADDED) {
|
if (kind == ICElementDelta.ADDED) {
|
||||||
Object parent= getParent(element);
|
Object parent= getParent(element);
|
||||||
postAdd(parent, element);
|
postAdd(parent, element);
|
||||||
if (element instanceof ICFile) {
|
if (updateContainer(element)) {
|
||||||
ICFile cfile = (ICFile)element;
|
postRefresh(parent);
|
||||||
if (updateContainer(cfile)) {
|
|
||||||
postRefresh(parent);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,50 +133,50 @@ public class CElementContentProvider extends BaseCElementContentProvider impleme
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure that containers are updated.
|
// Make sure that containers are updated.
|
||||||
//if (element instanceof ICRoot) {
|
//if (element instanceof ICModel) {
|
||||||
// updateContainer((ICRoot)element);
|
// updateContainer((ICModel)element);
|
||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateContainer(ICRoot root) {
|
// private void updateContainer(ICModel root) {
|
||||||
postRunnable(new Runnable() {
|
// postRunnable(new Runnable() {
|
||||||
public void run () {
|
// public void run () {
|
||||||
Control ctrl= fViewer.getControl();
|
// Control ctrl= fViewer.getControl();
|
||||||
if (ctrl != null && !ctrl.isDisposed()) {
|
// if (ctrl != null && !ctrl.isDisposed()) {
|
||||||
IStructuredSelection s = (IStructuredSelection)fViewer.getSelection();
|
// IStructuredSelection s = (IStructuredSelection)fViewer.getSelection();
|
||||||
if (s.isEmpty())
|
// if (s.isEmpty())
|
||||||
return;
|
// return;
|
||||||
Object element = s.getFirstElement();
|
// Object element = s.getFirstElement();
|
||||||
if (element instanceof ICProject) {
|
// if (element instanceof ICProject) {
|
||||||
updateContainer((ICProject)element);
|
// updateContainer((ICProject)element);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
|
|
||||||
protected boolean updateContainer(ICProject cproject) {
|
// protected boolean updateContainer(ICProject cproject) {
|
||||||
IParent binContainer = cproject.getBinaryContainer();
|
// IParent binContainer = cproject.getBinaryContainer();
|
||||||
IParent libContainer = cproject.getArchiveContainer();
|
// IParent libContainer = cproject.getArchiveContainer();
|
||||||
if (binContainer != null) {
|
// if (binContainer != null) {
|
||||||
postContainerRefresh(binContainer, cproject);
|
// postContainerRefresh(binContainer, cproject);
|
||||||
}
|
// }
|
||||||
if (libContainer != null) {
|
// if (libContainer != null) {
|
||||||
postContainerRefresh(libContainer, cproject);
|
// postContainerRefresh(libContainer, cproject);
|
||||||
}
|
// }
|
||||||
return false;
|
// return false;
|
||||||
}
|
// }
|
||||||
|
|
||||||
private boolean updateContainer(ICFile cfile) {
|
private boolean updateContainer(ICElement cfile) {
|
||||||
IParent container = null;
|
IParent container = null;
|
||||||
ICProject cproject = null;
|
ICProject cproject = null;
|
||||||
if (cfile.isBinary()) {
|
if (cfile instanceof IBinary) {
|
||||||
IBinary bin = (IBinary)cfile;
|
IBinary bin = (IBinary)cfile;
|
||||||
if (bin.isExecutable() || bin.isSharedLib()) {
|
if (bin.isExecutable() || bin.isSharedLib()) {
|
||||||
cproject = bin.getCProject();
|
cproject = bin.getCProject();
|
||||||
container = cproject.getBinaryContainer();
|
container = cproject.getBinaryContainer();
|
||||||
}
|
}
|
||||||
} else if (cfile.isArchive()) {
|
} else if (cfile instanceof IArchive) {
|
||||||
cproject = cfile.getCProject();
|
cproject = cfile.getCProject();
|
||||||
container = cproject.getArchiveContainer();
|
container = cproject.getArchiveContainer();
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,6 @@ package org.eclipse.cdt.ui;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.model.IBinary;
|
import org.eclipse.cdt.core.model.IBinary;
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
import org.eclipse.cdt.core.model.ICFile;
|
|
||||||
import org.eclipse.cdt.core.model.IFunctionDeclaration;
|
import org.eclipse.cdt.core.model.IFunctionDeclaration;
|
||||||
import org.eclipse.cdt.core.model.IVariable;
|
import org.eclipse.cdt.core.model.IVariable;
|
||||||
import org.eclipse.cdt.core.model.IVariableDeclaration;
|
import org.eclipse.cdt.core.model.IVariableDeclaration;
|
||||||
|
@ -109,11 +108,7 @@ public class CElementLabelProvider extends LabelProvider {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(element instanceof ICFile) {
|
|
||||||
//element = ((ICFile)element).getFile();
|
|
||||||
}
|
|
||||||
return fWorkbenchLabelProvider.getImage(element);
|
return fWorkbenchLabelProvider.getImage(element);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -145,7 +145,7 @@ public class CUIPlugin extends AbstractUIPlugin {
|
||||||
/**
|
/**
|
||||||
* Returns the used document provider
|
* Returns the used document provider
|
||||||
*/
|
*/
|
||||||
public CDocumentProvider getDocumentProvider() {
|
public synchronized CDocumentProvider getDocumentProvider() {
|
||||||
if (fDocumentProvider == null) {
|
if (fDocumentProvider == null) {
|
||||||
fDocumentProvider = new CDocumentProvider();
|
fDocumentProvider = new CDocumentProvider();
|
||||||
}
|
}
|
||||||
|
@ -156,7 +156,7 @@ public class CUIPlugin extends AbstractUIPlugin {
|
||||||
* Returns the working copy manager
|
* Returns the working copy manager
|
||||||
* @return IWorkingCopyManager
|
* @return IWorkingCopyManager
|
||||||
*/
|
*/
|
||||||
public synchronized IWorkingCopyManager getWorkingCopyManager() {
|
public IWorkingCopyManager getWorkingCopyManager() {
|
||||||
return getDocumentProvider();
|
return getDocumentProvider();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue