1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-23 17:05:26 +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:
Alain Magloire 2003-03-27 16:16:46 +00:00
parent 57e8eb56ff
commit 270cdcae55
21 changed files with 281 additions and 220 deletions

View file

@ -190,7 +190,7 @@ public class ArchiveTests extends TestCase {
IArchive myArchive;
myArchive=CProjectHelper.findArchive(testProject, "libtestlib_g.a");
assertTrue("A archive", myArchive.isArchive());
assertTrue("A archive", myArchive != null);
myArchive=null;

View file

@ -346,7 +346,7 @@ public class BinaryTests extends TestCase {
public void testisBinRead() {
IBinary myBinary;
myBinary =CProjectHelper.findBinary(testProject, "test_g");
assertTrue(myBinary.isBinary());
assertTrue(myBinary != null);
assertTrue(myBinary.isReadOnly());
}
@ -420,7 +420,7 @@ public class BinaryTests extends TestCase {
IBinary myBinary;
myBinary=CProjectHelper.findBinary(testProject, "exebig_g");
assertTrue("A Binary", myBinary.isBinary());
assertTrue("A Binary", myBinary != null);
}

View file

@ -23,13 +23,13 @@ import junit.framework.TestSuite;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.model.CModelException;
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.ICElementDelta;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.model.IElementChangedListener;
import org.eclipse.cdt.core.model.ITranslationUnit;
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.TranslationUnit;
import org.eclipse.cdt.testplugin.CProjectHelper;

View file

@ -164,7 +164,7 @@ public class TranslationUnitTests extends TestCase {
ITranslationUnit myTranslationUnit;
myTranslationUnit=CProjectHelper.findTranslationUnit(testProject,"exetest.c");
assertTrue("A TranslationUnit", myTranslationUnit.isTranslationUnit());
assertTrue("A TranslationUnit", myTranslationUnit != null);
}

View file

@ -17,9 +17,9 @@ import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import org.eclipse.cdt.core.model.IBuffer;
import org.eclipse.cdt.core.model.ICProject;
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.TranslationUnit;
import org.eclipse.cdt.testplugin.CProjectHelper;

View file

@ -8,19 +8,22 @@ package org.eclipse.cdt.internal.ui;
import java.util.ArrayList;
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.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.viewers.ITreeContentProvider;
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
@ -33,11 +36,12 @@ import org.eclipse.cdt.core.model.IParent;
* <pre>
C model (<code>ICModel</code>)
C project (<code>ICProject</code>)
C Folder (<code>ICFolder</code>)
C File (<code>ICFile</code>)
C Container(folders) (<code>ICContainer</code>)
Translation unit (<code>ITranslationUnit</code>)
Binary file (<code>IBinary</code>)
Archive file (<code>IArchive</code>)
Non C Resource file (<code>Object</code>)
* </pre>
*/
public class BaseCElementContentProvider implements ITreeContentProvider {
@ -112,26 +116,18 @@ public class BaseCElementContentProvider implements ITreeContentProvider {
public Object[] getChildren(Object element) {
if (element instanceof ICElement) {
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) {
return ((IParent)element).getChildren();
}
} else if (celement instanceof IParent) {
if (celement instanceof ICProject ) {
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 (Object[])((IParent)celement).getChildren();
}
}
return getResources(element);
@ -143,24 +139,26 @@ public class BaseCElementContentProvider implements ITreeContentProvider {
*/
public boolean hasChildren(Object element) {
if (fProvideMembers) {
if (element instanceof ICFile) {
ICFile cfile = (ICFile)element;
// assume TUs and binary files are never empty
if (cfile.isBinary() || cfile.isTranslationUnit() || cfile.isArchive()) {
return true;
}
// assume TUs and binary files are never empty
if (element instanceof IBinary || element instanceof ITranslationUnit || element instanceof IArchive) {
return true;
}
} else {
// 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;
}
}
if (element instanceof ICProject) {
ICProject cp= (ICProject)element;
if (!cp.getProject().isOpen()) {
return false;
}
} else {
return true;
}
} else if (element instanceof ICContainer) {
return true;
}
if (element instanceof IParent) {
@ -186,6 +184,36 @@ public class BaseCElementContentProvider implements ITreeContentProvider {
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) {
try {
if (resource instanceof IContainer) {
@ -224,4 +252,18 @@ public class BaseCElementContentProvider implements ITreeContentProvider {
}
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;
}
}

View file

@ -5,14 +5,14 @@ package org.eclipse.cdt.internal.ui;
* 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.FilePropertySource;
import org.eclipse.ui.views.properties.IPropertySource;
import org.eclipse.ui.views.properties.PropertyDescriptor;
import org.eclipse.cdt.core.model.IBinary;
import org.eclipse.cdt.ui.*;
public class BinaryPropertySource extends FilePropertySource {
public class BinaryPropertySource implements IPropertySource {
private final static String ELF_CPU= "CElementProperties.elf_cpu";
private final static String ELF_TEXT= "CElementProperties.elf_text";
@ -78,8 +78,7 @@ public class BinaryPropertySource extends FilePropertySource {
}
public BinaryPropertySource(IBinary bin) {
super(bin.getFile());
this.binary= bin;
binary= bin;
}
/**
@ -95,14 +94,15 @@ public class BinaryPropertySource extends FilePropertySource {
* @see IPropertySource#getPropertyValue
*/
public Object getPropertyValue(Object name) {
if (element != null) {
Object returnValue = super.getPropertyValue(name);
if(returnValue != null)
return returnValue;
}
if (name.equals(ICElementPropertyConstants.P_ELF_CPU)) {
// if (element != null) {
// Object returnValue = super.getPropertyValue(name);
//
// if(returnValue != null)
// return returnValue;
// }
if (name.equals(IBasicPropertyConstants.P_TEXT)) {
return binary.getElementName();
} else if (name.equals(ICElementPropertyConstants.P_ELF_CPU)) {
return binary.getCPU();
} else if (name.equals(ICElementPropertyConstants.P_ELF_TEXT)) {
return Long.toString(binary.getText());
@ -143,12 +143,40 @@ public class BinaryPropertySource extends FilePropertySource {
* Return the Property Descriptors for the file type.
*/
private void initializeBinaryDescriptors() {
IPropertyDescriptor[] superDescriptors = super.getPropertyDescriptors();
int superLength = superDescriptors.length;
IPropertyDescriptor[] binDescriptors = getInitialPropertyDescriptor();
int binLength = binDescriptors.length;
fgPropertyDescriptors = new IPropertyDescriptor[superLength + binLength];
System.arraycopy(superDescriptors, 0, fgPropertyDescriptors, 0, superLength);
System.arraycopy(binDescriptors, 0, fgPropertyDescriptors, superLength, binLength);
// IPropertyDescriptor[] superDescriptors = super.getPropertyDescriptors();
// int superLength = superDescriptors.length;
// IPropertyDescriptor[] binDescriptors = getInitialPropertyDescriptor();
// int binLength = binDescriptors.length;
// fgPropertyDescriptors = new IPropertyDescriptor[superLength + binLength];
// System.arraycopy(superDescriptors, 0, fgPropertyDescriptors, 0, superLength);
// 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) {
}
}

View file

@ -8,8 +8,6 @@ package org.eclipse.cdt.internal.ui;
import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.IBinary;
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.IProject;
import org.eclipse.core.resources.IResource;
@ -51,21 +49,17 @@ public class CElementAdapterFactory implements IAdapterFactory {
try {
if (IPropertySource.class.equals(key)) {
if (celem.getElementType() == ICElement.C_FILE) {
if (celem instanceof IBinary) {
return new BinaryPropertySource((IBinary)celem);
}
IFile file = ((ICFile)celem).getFile();
if (file != null) {
return new FilePropertySource(file);
if (celem instanceof IBinary) {
return new BinaryPropertySource((IBinary)celem);
} else if (celem.getElementType() == ICElement.C_UNIT) {
IResource file = celem.getResource();
if (file != null && file instanceof IFile) {
return new FilePropertySource((IFile)file);
}
} else {
try {
if ( celem instanceof ICResource ) {
res = ((ICResource)celem).getResource();
return new ResourcePropertySource(res);
}
} catch (CModelException e) {
res = celem.getResource();
if (res != null) {
return new ResourcePropertySource(res);
}
}
return new CElementPropertySource(celem);

View file

@ -5,22 +5,19 @@ package org.eclipse.cdt.internal.ui;
* 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.ICElement;
import org.eclipse.cdt.core.model.ICFile;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.model.IMember;
import org.eclipse.cdt.core.model.IMethodDeclaration;
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.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.model.IWorkbenchAdapter;
@ -96,9 +93,9 @@ public class CElementImageProvider {
if (element instanceof ICElement) {
descriptor= getCImageDescriptor((ICElement) element, flags);
}
if (descriptor == null && element instanceof ICFile) {
element = ((ICFile)element).getFile();
}
// if (descriptor == null && element instanceof ICFile) {
// element = ((ICFile)element).getFile();
// }
if (descriptor == null && element instanceof IAdaptable) {
descriptor= getWorkbenchImageDescriptor((IAdaptable) element, flags);
}
@ -159,31 +156,30 @@ public class CElementImageProvider {
public ImageDescriptor getBaseImageDescriptor(ICElement celement, int renderFlags) {
int type = celement.getElementType();
switch (type) {
case ICElement.C_CONTAINER:
case ICElement.C_VCONTAINER:
return CPluginImages.DESC_OBJS_CONTAINER;
case ICElement.C_FILE:
ICFile cfile = (ICFile)celement;
if (cfile.isArchive()) {
return CPluginImages.DESC_OBJS_ARCHIVE;
} else if (cfile.isBinary()) {
IBinary bin = (IBinary)cfile;
if (bin.isExecutable()) {
if (bin.hasDebug())
return CPluginImages.DESC_OBJS_CEXEC_DEBUG;
return CPluginImages.DESC_OBJS_CEXEC;
} 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;
case ICElement.C_BINARY: {
IBinary bin = (IBinary)celement;
if (bin.isExecutable()) {
if (bin.hasDebug())
return CPluginImages.DESC_OBJS_CEXEC_DEBUG;
return CPluginImages.DESC_OBJS_CEXEC;
} else if (bin.isSharedLib()) {
return CPluginImages.DESC_OBJS_SHLIB;
} else if (bin.isCore()) {
return CPluginImages.DESC_OBJS_CORE;
}
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;
case ICElement.C_PROJECT:
@ -241,10 +237,10 @@ public class CElementImageProvider {
public ImageDescriptor getCElementImageDescriptor(int type) {
switch (type) {
case ICElement.C_CONTAINER:
case ICElement.C_VCONTAINER:
return CPluginImages.DESC_OBJS_CONTAINER;
case ICElement.C_FILE:
case ICElement.C_UNIT:
return CPluginImages.DESC_OBJS_TUNIT;
case ICElement.C_STRUCT:

View file

@ -7,11 +7,10 @@ package org.eclipse.cdt.internal.ui;
import org.eclipse.cdt.core.model.ICElement;
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.ISourceReference;
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.IResource;
import org.eclipse.core.runtime.CoreException;
@ -41,10 +40,10 @@ public class ErrorTickAdornmentProvider implements IAdornmentProvider {
int type= element.getElementType();
switch (type) {
case ICElement.C_PROJECT:
case ICElement.C_FOLDER:
return getErrorTicksFromMarkers(((ICResource)element).getResource(), IResource.DEPTH_INFINITE, null);
case ICElement.C_FILE:
return getErrorTicksFromMarkers(((ICResource)element).getResource(), IResource.DEPTH_ONE, null);
case ICElement.C_CCONTAINER:
return getErrorTicksFromMarkers(element.getResource(), IResource.DEPTH_INFINITE, null);
case ICElement.C_UNIT:
return getErrorTicksFromMarkers(element.getResource(), IResource.DEPTH_ONE, null);
case ICElement.C_FUNCTION:
case ICElement.C_CLASS:
case ICElement.C_UNION:

View file

@ -64,7 +64,7 @@ public class CStructureCreator implements IStructureCreator {
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);
IStructurizerCallback callback= new CNodeTreeConstructor(root, doc);

View file

@ -17,7 +17,7 @@ import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.cdt.internal.ui.util.StringMatcher;
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;
public class CPatternFilter extends ViewerFilter {
@ -108,7 +108,7 @@ public class CPatternFilter extends ViewerFilter {
// Only apply the rule for Projects and folders.
if (parentElement instanceof ICProject
|| parentElement instanceof ICFolder) {
|| parentElement instanceof ICContainer) {
if (resource != null) {
String name = resource.getName();
StringMatcher[] testMatchers = getMatchers();

View file

@ -14,8 +14,7 @@ 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.ICElement;
import org.eclipse.cdt.core.model.ICFile;
import org.eclipse.cdt.core.model.ICRoot;
import org.eclipse.cdt.core.model.ICModel;
import org.eclipse.cdt.core.model.IParent;
import org.eclipse.cdt.core.resources.MakeUtil;
import org.eclipse.cdt.internal.ui.StandardCElementLabelProvider;
@ -263,7 +262,7 @@ public class CView extends ViewPart implements IMenuListener, ISetSelectionTarge
public void treeExpanded(TreeExpansionEvent event) {
final Object element= event.getElement();
if (element instanceof ICFile) {
if (element instanceof IParent) {
//viewer.refresh (element);
Control ctrl= viewer.getControl();
if (ctrl != null && !ctrl.isDisposed()) {
@ -447,7 +446,7 @@ public class CView extends ViewPart implements IMenuListener, ISetSelectionTarge
else
initFilterFromPreferences();
viewer.setInput (CoreModel.getDefault().getCRoot());
viewer.setInput (CoreModel.getDefault().getCModel());
MenuManager menuMgr= new MenuManager("#PopupMenu"); //$NON-NLS-1$
menuMgr.setRemoveAllWhenShown(true);
@ -967,7 +966,7 @@ public class CView extends ViewPart implements IMenuListener, ISetSelectionTarge
ICElement celement = (ICElement)o;
IResource res = (IResource)celement.getAdapter(IResource.class);
if (res != null) {
if (celement.getElementType() == ICElement.C_CONTAINER) {
if (celement.getElementType() == ICElement.C_VCONTAINER) {
ICElement parent = celement.getParent();
IResource proj = (IResource)parent.getAdapter(IResource.class);
if (celement instanceof IArchiveContainer)
@ -993,7 +992,7 @@ public class CView extends ViewPart implements IMenuListener, ISetSelectionTarge
void updateTitle () {
Object input= getViewer().getInput();
String viewName= getConfigurationElement().getAttribute("name"); //$NON-NLS-1$
if (input == null || (input instanceof ICRoot)) {
if (input == null || (input instanceof ICModel)) {
setTitle(viewName);
setTitleToolTip(""); //$NON-NLS-1$
} else {

View file

@ -9,6 +9,8 @@ import java.util.ArrayList;
import java.util.Iterator;
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.runtime.CoreException;
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.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
* resource navigator.
@ -102,7 +99,15 @@ class CViewDragAdapter extends DragSourceAdapter {
IStructuredSelection selection = (IStructuredSelection)selectionProvider.getSelection();
for (Iterator i = selection.iterator(); i.hasNext();) {
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;
return;
}

View file

@ -9,17 +9,20 @@ import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.CoreModel;
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.ICFile;
import org.eclipse.cdt.core.model.ICFolder;
import org.eclipse.cdt.core.model.ICModel;
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.IFunctionDeclaration;
import org.eclipse.cdt.core.model.IInclude;
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.ITranslationUnit;
import org.eclipse.cdt.core.model.IUsing;
import org.eclipse.cdt.core.model.IVariable;
import org.eclipse.cdt.core.model.IVariableDeclaration;
@ -38,7 +41,7 @@ import org.eclipse.jface.viewers.ViewerSorter;
public class CViewSorter extends ViewerSorter {
public int category (Object element) {
if (element instanceof ICRoot) {
if (element instanceof ICModel) {
return 0;
} else if (element instanceof ICProject) {
return 10;
@ -46,12 +49,12 @@ public class CViewSorter extends ViewerSorter {
return 20;
} else if (element instanceof IArchiveContainer) {
return 30;
} else if (element instanceof ICFolder) {
} else if (element instanceof ICContainer) {
return 40;
} else if (element instanceof ICFile) {
} else if (element instanceof ITranslationUnit) {
IResource res = null;
try {
res = ((ICFile)element).getUnderlyingResource();
res = ((ITranslationUnit)element).getUnderlyingResource();
} catch (CModelException e) {
}
if (res != null) {
@ -66,7 +69,7 @@ public class CViewSorter extends ViewerSorter {
String[] sources = CoreModel.getDefault().getSourceExtensions();
for (int i = 0; i < sources.length; i++) {
if (ext.equals(sources[i])) {
return 44;
return 47;
}
}
return 48;
@ -82,20 +85,13 @@ public class CViewSorter extends ViewerSorter {
return 80;
} else if (element instanceof IUsing) {
return 90;
} else if (element instanceof IFunctionDeclaration) {
} else if (element instanceof IFunctionDeclaration && ! (element instanceof IFunction)) {
return 100;
} else if (element instanceof IVariableDeclaration) {
} else if (element instanceof IMethodDeclaration && !(element instanceof IMethod)) {
return 110;
} else if (element instanceof IVariable) {
String name = ((ICElement)element).getElementName();
if (name.startsWith("__")) {
return 112;
}
if (name.charAt(0) == '_') {
return 114;
}
} else if (element instanceof IVariableDeclaration) {
return 120;
} else if (element instanceof IFunction) {
} else if (element instanceof IVariable) {
String name = ((ICElement)element).getElementName();
if (name.startsWith("__")) {
return 122;
@ -104,7 +100,7 @@ public class CViewSorter extends ViewerSorter {
return 124;
}
return 130;
} else if (element instanceof ICElement) {
} else if (element instanceof IFunction) {
String name = ((ICElement)element).getElementName();
if (name.startsWith("__")) {
return 132;
@ -113,9 +109,20 @@ public class CViewSorter extends ViewerSorter {
return 134;
}
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;
} else if (element instanceof IArchive) {
return 160;
} else if (element instanceof IBinary) {
return 170;
}
return 80;
return 200;
}
}

View file

@ -11,9 +11,9 @@ import java.io.InputStream;
import org.eclipse.cdt.core.model.CModelException;
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.internal.core.model.IBuffer;
import org.eclipse.cdt.internal.core.model.IBufferFactory;
import org.eclipse.cdt.internal.core.model.IWorkingCopy;
import org.eclipse.cdt.internal.ui.CStatusConstants;
@ -111,7 +111,7 @@ public class CDocumentProvider extends FileDocumentProvider implements IWorkingC
return CDocumentProvider.this.createDocument(input);
}
public IBuffer createBuffer(ICOpenable owner) {
public IBuffer createBuffer(IOpenable owner) {
try {
if (owner instanceof IWorkingCopy) {

View file

@ -16,11 +16,11 @@ import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.eclipse.cdt.core.model.BufferChangedEvent;
import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.ICOpenable;
import org.eclipse.cdt.internal.core.model.BufferChangedEvent;
import org.eclipse.cdt.internal.core.model.IBuffer;
import org.eclipse.cdt.internal.core.model.IBufferChangedListener;
import org.eclipse.cdt.core.model.IBuffer;
import org.eclipse.cdt.core.model.IBufferChangedListener;
import org.eclipse.cdt.core.model.IOpenable;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
@ -74,7 +74,7 @@ public class DocumentAdapter implements IBuffer, IDocumentListener {
return 0;
}
public ICOpenable getOwner() {
public IOpenable getOwner() {
return null;
}
@ -163,7 +163,7 @@ public class DocumentAdapter implements IBuffer, IDocumentListener {
}
};
private ICOpenable fOwner;
private IOpenable fOwner;
private IDocument fDocument;
private DocumentSetCommand fSetCmd= new DocumentSetCommand();
private DocumentReplaceCommand fReplaceCmd= new DocumentReplaceCommand();
@ -178,7 +178,7 @@ public class DocumentAdapter implements IBuffer, IDocumentListener {
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(lineTracker);
@ -352,8 +352,8 @@ public class DocumentAdapter implements IBuffer, IDocumentListener {
/**
* @see org.eclipse.cdt.internal.core.model.IBuffer#getOwner()
*/
public ICOpenable getOwner() {
return (ICOpenable) fOwner;
public IOpenable getOwner() {
return (IOpenable) fOwner;
}
/**

View file

@ -124,7 +124,11 @@ public class EditorUtility {
IStorage store = null;
Process objdump = null;
IPath path;
IFile file = bin.getFile();
IResource file = null;
try {
file = bin.getResource();
} catch (CModelException e1) {
}
if (file == null)
return store;
path = file.getLocation();

View file

@ -13,15 +13,13 @@ import org.eclipse.cdt.core.model.IArchive;
import org.eclipse.cdt.core.model.IBinary;
import org.eclipse.cdt.core.model.ICElement;
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.ICRoot;
import org.eclipse.cdt.core.model.IElementChangedListener;
import org.eclipse.cdt.core.model.IParent;
import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.internal.ui.BaseCElementContentProvider;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.StructuredViewer;
import org.eclipse.jface.viewers.Viewer;
@ -50,7 +48,7 @@ public class CElementContentProvider extends BaseCElementContentProvider impleme
fViewer = (StructuredViewer)viewer;
if (oldInput == null && newInput != null) {
if (newInput instanceof ICRoot)
if (newInput instanceof ICModel)
CoreModel.getDefault().addElementChangedListener(this);
} else if (oldInput != null && newInput == null) {
CoreModel.getDefault().removeElementChangedListener(this);
@ -103,22 +101,16 @@ public class CElementContentProvider extends BaseCElementContentProvider impleme
if (kind == ICElementDelta.REMOVED) {
Object parent = getParent(element);
postRemove(element);
if (element instanceof ICFile) {
ICFile cfile = (ICFile)element;
if (updateContainer(cfile)) {
postRefresh(parent);
}
if (updateContainer(element)) {
postRefresh(parent);
}
}
if (kind == ICElementDelta.ADDED) {
Object parent= getParent(element);
postAdd(parent, element);
if (element instanceof ICFile) {
ICFile cfile = (ICFile)element;
if (updateContainer(cfile)) {
postRefresh(parent);
}
if (updateContainer(element)) {
postRefresh(parent);
}
}
@ -141,50 +133,50 @@ public class CElementContentProvider extends BaseCElementContentProvider impleme
}
// Make sure that containers are updated.
//if (element instanceof ICRoot) {
// updateContainer((ICRoot)element);
//if (element instanceof ICModel) {
// updateContainer((ICModel)element);
//}
}
private void updateContainer(ICRoot root) {
postRunnable(new Runnable() {
public void run () {
Control ctrl= fViewer.getControl();
if (ctrl != null && !ctrl.isDisposed()) {
IStructuredSelection s = (IStructuredSelection)fViewer.getSelection();
if (s.isEmpty())
return;
Object element = s.getFirstElement();
if (element instanceof ICProject) {
updateContainer((ICProject)element);
}
}
}
});
}
// private void updateContainer(ICModel root) {
// postRunnable(new Runnable() {
// public void run () {
// Control ctrl= fViewer.getControl();
// if (ctrl != null && !ctrl.isDisposed()) {
// IStructuredSelection s = (IStructuredSelection)fViewer.getSelection();
// if (s.isEmpty())
// return;
// Object element = s.getFirstElement();
// if (element instanceof ICProject) {
// updateContainer((ICProject)element);
// }
// }
// }
// });
// }
protected boolean updateContainer(ICProject cproject) {
IParent binContainer = cproject.getBinaryContainer();
IParent libContainer = cproject.getArchiveContainer();
if (binContainer != null) {
postContainerRefresh(binContainer, cproject);
}
if (libContainer != null) {
postContainerRefresh(libContainer, cproject);
}
return false;
}
// protected boolean updateContainer(ICProject cproject) {
// IParent binContainer = cproject.getBinaryContainer();
// IParent libContainer = cproject.getArchiveContainer();
// if (binContainer != null) {
// postContainerRefresh(binContainer, cproject);
// }
// if (libContainer != null) {
// postContainerRefresh(libContainer, cproject);
// }
// return false;
// }
private boolean updateContainer(ICFile cfile) {
private boolean updateContainer(ICElement cfile) {
IParent container = null;
ICProject cproject = null;
if (cfile.isBinary()) {
if (cfile instanceof IBinary) {
IBinary bin = (IBinary)cfile;
if (bin.isExecutable() || bin.isSharedLib()) {
cproject = bin.getCProject();
container = cproject.getBinaryContainer();
}
} else if (cfile.isArchive()) {
} else if (cfile instanceof IArchive) {
cproject = cfile.getCProject();
container = cproject.getArchiveContainer();
}

View file

@ -7,7 +7,6 @@ package org.eclipse.cdt.ui;
import org.eclipse.cdt.core.model.IBinary;
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.IVariable;
import org.eclipse.cdt.core.model.IVariableDeclaration;
@ -109,11 +108,7 @@ public class CElementLabelProvider extends LabelProvider {
return result;
}
}
if(element instanceof ICFile) {
//element = ((ICFile)element).getFile();
}
return fWorkbenchLabelProvider.getImage(element);
}
/**

View file

@ -145,7 +145,7 @@ public class CUIPlugin extends AbstractUIPlugin {
/**
* Returns the used document provider
*/
public CDocumentProvider getDocumentProvider() {
public synchronized CDocumentProvider getDocumentProvider() {
if (fDocumentProvider == null) {
fDocumentProvider = new CDocumentProvider();
}
@ -156,7 +156,7 @@ public class CUIPlugin extends AbstractUIPlugin {
* Returns the working copy manager
* @return IWorkingCopyManager
*/
public synchronized IWorkingCopyManager getWorkingCopyManager() {
public IWorkingCopyManager getWorkingCopyManager() {
return getDocumentProvider();
}