1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

bug 297557: Viewers should clearly indicate whether a file is excluded from build

Patch from Torkild Ulvøy Resheim
This commit is contained in:
Andrew Gvozdev 2010-05-08 18:55:26 +00:00
parent 7848bd21a9
commit d17630643a
3 changed files with 87 additions and 0 deletions

View file

@ -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

View file

@ -3520,4 +3520,14 @@
</complexArray>
</processType>
</extension>
<extension point="org.eclipse.ui.decorators">
<decorator adaptable="true"
class="org.eclipse.cdt.internal.ui.viewsupport.ExcludedFileDecorator"
id="org.eclipse.cdt.managedbuilder.ui.excludedFile" label="%excluded-file.name"
lightweight="true" state="true">
<enablement>
<objectClass name="org.eclipse.core.resources.IFile" />
</enablement>
</decorator>
</extension>
</plugin>

View file

@ -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
}
}