From 3dc5e212e06fd3fce07b73780e08910725fedbd1 Mon Sep 17 00:00:00 2001 From: Alain Magloire Date: Fri, 16 Apr 2004 04:21:17 +0000 Subject: [PATCH] Added Properties for Binaries --- core/org.eclipse.cdt.ui/ChangeLog | 10 +++ .../cdt/internal/ui/BinaryPropertySource.java | 39 +++++---- .../internal/ui/CElementAdapterFactory.java | 8 +- .../cdt/internal/ui/CElementProperties.java | 80 ------------------- .../internal/ui/CElementPropertySource.java | 5 +- 5 files changed, 38 insertions(+), 104 deletions(-) delete mode 100644 core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CElementProperties.java diff --git a/core/org.eclipse.cdt.ui/ChangeLog b/core/org.eclipse.cdt.ui/ChangeLog index 968db2a1a9f..7d8e24144e6 100644 --- a/core/org.eclipse.cdt.ui/ChangeLog +++ b/core/org.eclipse.cdt.ui/ChangeLog @@ -1,3 +1,13 @@ +2004-04-15 Alain Magloire + + Added Properties for the Binaries. + * src/org/eclipse/cdt/internal/ui/BinaryProjectSource.java + * src/org/eclipse/cdt/internal/ui/CElementAdapterFactory.java + * src/org/eclipse/cdt/internla/ui/CElementPropertySource.java + + removed unused files + * src/org/eclipse/cdt/internal/ui/CElementProperties.java + 2004-04-15 Hoda Amer Fix for bug#58566 : [Refactoring] renaming #define statements Fix for bug#58335 : [Content Assist] Class forward declarations not reported diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/BinaryPropertySource.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/BinaryPropertySource.java index 5c8c708ef88..92f22b8aef7 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/BinaryPropertySource.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/BinaryPropertySource.java @@ -7,12 +7,14 @@ package org.eclipse.cdt.internal.ui; import org.eclipse.cdt.core.model.IBinary; import org.eclipse.cdt.ui.CUIPlugin; +import org.eclipse.core.resources.IFile; import org.eclipse.jface.viewers.IBasicPropertyConstants; +import org.eclipse.ui.views.properties.FilePropertySource; import org.eclipse.ui.views.properties.IPropertyDescriptor; import org.eclipse.ui.views.properties.IPropertySource; import org.eclipse.ui.views.properties.PropertyDescriptor; -public class BinaryPropertySource implements IPropertySource { +public class BinaryPropertySource extends FilePropertySource implements IPropertySource { private final static String ELF_CPU= "CElementProperties.elf_cpu"; //$NON-NLS-1$ private final static String ELF_TEXT= "CElementProperties.elf_text"; //$NON-NLS-1$ @@ -78,6 +80,7 @@ public class BinaryPropertySource implements IPropertySource { } public BinaryPropertySource(IBinary bin) { + super((IFile)bin.getResource()); binary= bin; } @@ -85,8 +88,9 @@ public class BinaryPropertySource implements IPropertySource { * @see IPropertySource#getPropertyDescriptors */ public IPropertyDescriptor[] getPropertyDescriptors() { - if (fgPropertyDescriptors == null) + if (fgPropertyDescriptors == null) { initializeBinaryDescriptors(); + } return fgPropertyDescriptors; } @@ -94,12 +98,12 @@ public class BinaryPropertySource implements IPropertySource { * @see IPropertySource#getPropertyValue */ public Object getPropertyValue(Object name) { -// if (element != null) { -// Object returnValue = super.getPropertyValue(name); -// -// if(returnValue != null) -// return returnValue; -// } + 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)) { @@ -143,14 +147,17 @@ public class BinaryPropertySource implements IPropertySource { * 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); - fgPropertyDescriptors = getInitialPropertyDescriptor(); + if (element != null) { + 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); + } else { + fgPropertyDescriptors = getInitialPropertyDescriptor(); + } } /* (non-Javadoc) diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CElementAdapterFactory.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CElementAdapterFactory.java index 40f72b6257e..15cfe78d981 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CElementAdapterFactory.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CElementAdapterFactory.java @@ -49,14 +49,12 @@ public class CElementAdapterFactory implements IAdapterFactory { if (IPropertySource.class.equals(key)) { 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 { res = celem.getResource(); if (res != null) { + if (res instanceof IFile) { + return new FilePropertySource((IFile)res); + } return new ResourcePropertySource(res); } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CElementProperties.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CElementProperties.java deleted file mode 100644 index d4ce8ca8670..00000000000 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CElementProperties.java +++ /dev/null @@ -1,80 +0,0 @@ -package org.eclipse.cdt.internal.ui; - -/* - * (c) Copyright IBM Corp. 2000, 2001. - * All Rights Reserved. - */ - -import org.eclipse.jface.viewers.IBasicPropertyConstants; -import org.eclipse.ui.views.properties.IPropertyDescriptor; -import org.eclipse.ui.views.properties.IPropertySource; -import org.eclipse.ui.views.properties.PropertyDescriptor; - -import org.eclipse.cdt.core.model.ICElement; -import org.eclipse.cdt.ui.*; - -public class CElementProperties implements IPropertySource { - - private final static String LABEL= "CElementProperties.name"; //$NON-NLS-1$ - - private ICElement fCElement; - - // Property Descriptors - static private IPropertyDescriptor[] fgPropertyDescriptors; - - static { - // resource name - String displayName= CUIPlugin.getResourceString(LABEL); - PropertyDescriptor descriptor= new PropertyDescriptor(IBasicPropertyConstants.P_TEXT, displayName); - descriptor.setAlwaysIncompatible(true); - - fgPropertyDescriptors= new IPropertyDescriptor[] { descriptor }; - } - - public CElementProperties(ICElement elem) { - fCElement= elem; - } - - /** - * @see IPropertySource#getPropertyDescriptors - */ - public IPropertyDescriptor[] getPropertyDescriptors() { - return fgPropertyDescriptors; - } - - /** - * @see IPropertySource#getPropertyValue - */ - public Object getPropertyValue(Object name) { - if (name.equals(IBasicPropertyConstants.P_TEXT)) { - return fCElement.getElementName(); - } - return null; - } - - /** - * @see IPropertySource#setPropertyValue - */ - public void setPropertyValue(Object name, Object value) { - } - - /** - * @see IPropertySource#getEditableValue - */ - public Object getEditableValue() { - return null; - } - - /** - * @see IPropertySource#isPropertySet - */ - public boolean isPropertySet(Object property) { - return false; - } - - /** - * @see IPropertySource#resetPropertyValue - */ - public void resetPropertyValue(Object property) { - } -} diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CElementPropertySource.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CElementPropertySource.java index 123c99018a3..25434f8bedb 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CElementPropertySource.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CElementPropertySource.java @@ -5,14 +5,13 @@ package org.eclipse.cdt.internal.ui; * All Rights Reserved. */ +import org.eclipse.cdt.core.model.ICElement; +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.IPropertySource; import org.eclipse.ui.views.properties.PropertyDescriptor; -import org.eclipse.cdt.core.model.ICElement; -import org.eclipse.cdt.ui.*; - public class CElementPropertySource implements IPropertySource { private final static String LABEL= "CElementProperties.name"; //$NON-NLS-1$