diff --git a/core/org.eclipse.cdt.ui/plugin.properties b/core/org.eclipse.cdt.ui/plugin.properties index e8c297ed06e..1a464acbbe3 100644 --- a/core/org.eclipse.cdt.ui/plugin.properties +++ b/core/org.eclipse.cdt.ui/plugin.properties @@ -567,3 +567,6 @@ AddBlockCommentAction.label= Add &Block Comment RemoveBlockCommentAction.label= Remove Bloc&k Comment ShiftRightAction.label= &Shift Right ShiftLeftAction.label= S&hift Left + +# Decorators +excluded-file.name = Excluded File \ No newline at end of file diff --git a/core/org.eclipse.cdt.ui/plugin.xml b/core/org.eclipse.cdt.ui/plugin.xml index 584ca76135b..bdcafb55510 100644 --- a/core/org.eclipse.cdt.ui/plugin.xml +++ b/core/org.eclipse.cdt.ui/plugin.xml @@ -3520,4 +3520,14 @@ + + + + + + + diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/ExcludedFileDecorator.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/ExcludedFileDecorator.java new file mode 100644 index 00000000000..b72196ed2a6 --- /dev/null +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/ExcludedFileDecorator.java @@ -0,0 +1,74 @@ +/******************************************************************************* + * Copyright (c) 2010 Atmel Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Torkild U. Resheim (Atmel Corporation) - Initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.internal.ui.viewsupport; + + +import org.eclipse.core.resources.IFile; +import org.eclipse.jface.preference.JFacePreferences; +import org.eclipse.jface.resource.JFaceResources; +import org.eclipse.jface.viewers.IDecoration; +import org.eclipse.jface.viewers.ILabelProviderListener; +import org.eclipse.jface.viewers.ILightweightLabelDecorator; + +import org.eclipse.cdt.core.model.CoreModel; +import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; +import org.eclipse.cdt.core.settings.model.ICProjectDescription; +import org.eclipse.cdt.core.settings.model.ICProjectDescriptionManager; +import org.eclipse.cdt.core.settings.model.ICSourceEntry; +import org.eclipse.cdt.core.settings.model.util.CDataUtil; + +import org.eclipse.cdt.internal.ui.CPluginImages; + +/** + * Determines if a file is excluded from a CDT build and if that is the case decorates the file's icon and + * renders the label using the qualifier (gray) color. + */ +public class ExcludedFileDecorator implements ILightweightLabelDecorator { + + public void decorate(Object element, IDecoration decoration) { + if (element instanceof IFile) { + IFile resource = (IFile) element; + ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager(); + ICProjectDescription desc = mngr.getProjectDescription(resource.getProject()); + ICConfigurationDescription conf = desc.getDefaultSettingConfiguration(); + ICSourceEntry[] entries = conf.getSourceEntries(); + boolean isSource = false; + for (ICSourceEntry icSourceEntry : entries) { + if (icSourceEntry.getFullPath().isPrefixOf(resource.getFullPath())) { + isSource = true; + break; + } + + } + // Only bother to mark items that would be included otherwise + if (isSource && CDataUtil.isExcluded(resource.getFullPath(), entries)) { + decoration.addOverlay(CPluginImages.DESC_OVR_INACTIVE); + decoration.setForegroundColor(JFaceResources.getColorRegistry().get( + JFacePreferences.QUALIFIER_COLOR)); + } + } + } + + public void addListener(ILabelProviderListener listener) { + // We don't track state changes + } + + public void dispose() { + } + + public boolean isLabelProperty(Object element, String property) { + return false; + } + + public void removeListener(ILabelProviderListener listener) { + // We don't track state changes + } +} \ No newline at end of file