/** * If the object is a {@link ProjectElementAdapter} it returns the image returned by the * extension's labelProvider or the icon defined in the extension (if it is defined). If the * element is not a ProjectElementAdapter the a default image is returned * * @generated NOT */ public Object getImage(Object object) { ProjectElementAdapter projectElementAdapter = ((ProjectElementAdapter) object); IGenericProjectElement backingObject = projectElementAdapter.getBackingObject(); if (backingObject == null) { return null; } String extensionId = backingObject.getExtensionId(); IConfigurationElement extension = findExtension(extensionId); String labelProviderAtt = extension.getAttribute(LABEL_PROVIDER_ATT); Object image = null; if (labelProviderAtt != null) { try { IBaseLabelProvider baseProvider = (IBaseLabelProvider) extension.createExecutableExtension(LABEL_PROVIDER_ATT); if (baseProvider instanceof ILabelProvider) { ILabelProvider labelProvider = (ILabelProvider) baseProvider; image = labelProvider.getImage(backingObject); } } catch (CoreException e) { // not good log this ProjectEditPlugin.log("Unable to load the LabelProvider for Element: " + extensionId, e); } } String iconPath = extension.getAttribute(ICON_ATT); if (image == null && iconPath != null) { image = AbstractUIPlugin.imageDescriptorFromPlugin(extension.getNamespaceIdentifier(), iconPath); } return image; }
/** * If the object is a {@link ProjectElementAdapter} it returns the text returned by the * extension's labelProvider or the label defined in the extension (if it is defined). If the * element is not a ProjectElementAdapter the a default text is returned * * @generated NOT */ public String getText(Object object) { ProjectElementAdapter projectElementAdapter = ((ProjectElementAdapter) object); IGenericProjectElement backingObject = projectElementAdapter.getBackingObject(); if (backingObject == null) { return projectElementAdapter.getName() + "- No backing object"; } String extensionId = backingObject.getExtensionId(); IConfigurationElement extension = findExtension(extensionId); String labelProviderAtt = extension.getAttribute(LABEL_PROVIDER_ATT); String text = null; if (labelProviderAtt != null) { try { IBaseLabelProvider baseProvider = (IBaseLabelProvider) extension.createExecutableExtension(LABEL_PROVIDER_ATT); if (baseProvider instanceof ILabelProvider) { ILabelProvider labelProvider = (ILabelProvider) baseProvider; text = labelProvider.getText(backingObject); } } catch (CoreException e) { // not good log this ProjectEditPlugin.log("Unable to load the LabelProvider for Element: " + extensionId, e); } } if (text == null) { text = extension.getAttribute(LABEL_ATT); } return text; }
/** * If the extension's LabelProvider is non-null and implements the IColorProvider interface the * background color from the provider is returned otherwise null is returned */ public Color getBackground(Object object) { ProjectElementAdapter projectElementAdapter = ((ProjectElementAdapter) object); IGenericProjectElement backingObject = projectElementAdapter.getBackingObject(); if (backingObject == null) { return null; } String extensionId = backingObject.getExtensionId(); IConfigurationElement extension = findExtension(extensionId); String labelProviderAtt = extension.getAttribute(LABEL_PROVIDER_ATT); Color color = null; if (labelProviderAtt != null) { try { IBaseLabelProvider baseProvider = (IBaseLabelProvider) extension.createExecutableExtension(LABEL_PROVIDER_ATT); if (baseProvider instanceof IColorProvider) { IColorProvider labelProvider = (IColorProvider) baseProvider; color = labelProvider.getBackground(backingObject); } } catch (CoreException e) { // not good log this ProjectEditPlugin.log("Unable to load the LabelProvider for Element: " + extensionId, e); } } return color; }