mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Merge remote-tracking branch 'cdt/master' into sd90
This commit is contained in:
commit
06b3b35da1
8 changed files with 178 additions and 70 deletions
|
@ -46,6 +46,8 @@ import org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChang
|
||||||
import org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent;
|
import org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent;
|
||||||
import org.eclipse.core.runtime.preferences.InstanceScope;
|
import org.eclipse.core.runtime.preferences.InstanceScope;
|
||||||
import org.eclipse.jface.viewers.ITreeContentProvider;
|
import org.eclipse.jface.viewers.ITreeContentProvider;
|
||||||
|
import org.eclipse.jface.viewers.StructuredViewer;
|
||||||
|
import org.eclipse.jface.viewers.TableViewer;
|
||||||
import org.eclipse.jface.viewers.TreeViewer;
|
import org.eclipse.jface.viewers.TreeViewer;
|
||||||
import org.eclipse.jface.viewers.Viewer;
|
import org.eclipse.jface.viewers.Viewer;
|
||||||
import org.eclipse.swt.widgets.Display;
|
import org.eclipse.swt.widgets.Display;
|
||||||
|
@ -63,7 +65,7 @@ public class MakeContentProvider implements ITreeContentProvider, IMakeTargetLis
|
||||||
/** presentation of the content, i.e. for MakeView tree of for BuildTargetDialog table */
|
/** presentation of the content, i.e. for MakeView tree of for BuildTargetDialog table */
|
||||||
protected boolean bFlatten;
|
protected boolean bFlatten;
|
||||||
|
|
||||||
protected TreeViewer viewer;
|
protected StructuredViewer viewer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default constructor.
|
* Default constructor.
|
||||||
|
@ -196,7 +198,7 @@ public class MakeContentProvider implements ITreeContentProvider, IMakeTargetLis
|
||||||
if (this.viewer == null) {
|
if (this.viewer == null) {
|
||||||
MakeCorePlugin.getDefault().getTargetManager().addListener(this);
|
MakeCorePlugin.getDefault().getTargetManager().addListener(this);
|
||||||
}
|
}
|
||||||
this.viewer = (TreeViewer) viewer;
|
this.viewer = (StructuredViewer) viewer;
|
||||||
IWorkspace oldWorkspace = null;
|
IWorkspace oldWorkspace = null;
|
||||||
IWorkspace newWorkspace = null;
|
IWorkspace newWorkspace = null;
|
||||||
if (oldInput instanceof IWorkspace) {
|
if (oldInput instanceof IWorkspace) {
|
||||||
|
@ -250,11 +252,23 @@ public class MakeContentProvider implements ITreeContentProvider, IMakeTargetLis
|
||||||
if (viewer == null || viewer.getControl() == null || viewer.getControl().isDisposed())
|
if (viewer == null || viewer.getControl() == null || viewer.getControl().isDisposed())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (viewer.getTree().getItemCount() <= 0) {
|
int itemCount = 0;
|
||||||
|
if (viewer instanceof TreeViewer) {
|
||||||
|
((TreeViewer) viewer).getTree().getItemCount();
|
||||||
|
} else if (viewer instanceof TableViewer) {
|
||||||
|
((TableViewer) viewer).getTable().getItemCount();
|
||||||
|
}
|
||||||
|
if (itemCount <= 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Object firstItem = viewer.getTree().getItem(0).getData();
|
Object firstItem = null;
|
||||||
|
if (viewer instanceof TreeViewer) {
|
||||||
|
firstItem = ((TreeViewer) viewer).getTree().getItem(0).getData();
|
||||||
|
} else if (viewer instanceof TableViewer) {
|
||||||
|
firstItem = ((TableViewer) viewer).getTable().getItem(0).getData();
|
||||||
|
}
|
||||||
|
|
||||||
IContainer parentContainer = null;
|
IContainer parentContainer = null;
|
||||||
|
|
||||||
boolean isDrilledDown = !(firstItem instanceof IProject);
|
boolean isDrilledDown = !(firstItem instanceof IProject);
|
||||||
|
|
|
@ -544,8 +544,6 @@ WriteOccurrenceAnnotation.label= C/C++ Write Occurrences
|
||||||
DocCommentOwner.name = DocCommentOwner
|
DocCommentOwner.name = DocCommentOwner
|
||||||
Doxygen.name = Doxygen
|
Doxygen.name = Doxygen
|
||||||
|
|
||||||
indexedFilesDecorator.label = C/C++ Indexed Files
|
|
||||||
|
|
||||||
# Hyperlinking
|
# Hyperlinking
|
||||||
cEditorHyperlinkTarget= C/C++ Editor
|
cEditorHyperlinkTarget= C/C++ Editor
|
||||||
cElementHyperlinkDetector= C/C++ Elements
|
cElementHyperlinkDetector= C/C++ Elements
|
||||||
|
@ -598,7 +596,12 @@ ShiftRightAction.label= &Shift Right
|
||||||
ShiftLeftAction.label= S&hift Left
|
ShiftLeftAction.label= S&hift Left
|
||||||
|
|
||||||
# Decorators
|
# Decorators
|
||||||
excluded-file.name = C/C++ Files Excluded from Build
|
indexedFilesDecorator.label = C/C++ Indexed Files
|
||||||
|
indexedFilesDecorator.description = Decorates files indexed by C/C++ Indexer.
|
||||||
|
excludedFile.name = C/C++ Files Excluded from Build
|
||||||
|
excludedFile.description = Decorates source files excluded from C/C++ build.
|
||||||
|
includeFolderDecorator.name = C/C++ Missing Include Folders
|
||||||
|
includeFolderDecorator.description = Decorates missing include folders with error/warning indicator.
|
||||||
|
|
||||||
templatesViewName= Templates
|
templatesViewName= Templates
|
||||||
|
|
||||||
|
|
|
@ -4055,6 +4055,7 @@
|
||||||
label="%indexedFilesDecorator.label"
|
label="%indexedFilesDecorator.label"
|
||||||
lightweight="true"
|
lightweight="true"
|
||||||
state="false">
|
state="false">
|
||||||
|
<description>%indexedFilesDecorator.description</description>
|
||||||
<enablement>
|
<enablement>
|
||||||
<or>
|
<or>
|
||||||
<objectClass name="org.eclipse.cdt.core.model.ITranslationUnit"/>
|
<objectClass name="org.eclipse.cdt.core.model.ITranslationUnit"/>
|
||||||
|
@ -4062,6 +4063,34 @@
|
||||||
</or>
|
</or>
|
||||||
</enablement>
|
</enablement>
|
||||||
</decorator>
|
</decorator>
|
||||||
|
<decorator
|
||||||
|
adaptable="true"
|
||||||
|
class="org.eclipse.cdt.internal.ui.viewsupport.ExcludedFileDecorator"
|
||||||
|
id="org.eclipse.cdt.managedbuilder.ui.excludedFile"
|
||||||
|
label="%excludedFile.name"
|
||||||
|
lightweight="true"
|
||||||
|
state="true">
|
||||||
|
<description>%excludedFile.description</description>
|
||||||
|
<enablement>
|
||||||
|
<objectClass name="org.eclipse.core.resources.IFile" />
|
||||||
|
</enablement>
|
||||||
|
</decorator>
|
||||||
|
<decorator
|
||||||
|
adaptable="true"
|
||||||
|
class="org.eclipse.cdt.internal.ui.viewsupport.IncludeFolderDecorator"
|
||||||
|
id="org.eclipse.cdt.managedbuilder.ui.includeFolder"
|
||||||
|
label="%includeFolderDecorator.name"
|
||||||
|
lightweight="true"
|
||||||
|
location="BOTTOM_LEFT"
|
||||||
|
state="true">
|
||||||
|
<description>%includeFolderDecorator.description</description>
|
||||||
|
<enablement>
|
||||||
|
<or>
|
||||||
|
<objectClass name="org.eclipse.cdt.internal.ui.cview.IncludeReferenceProxy" />
|
||||||
|
<objectClass name="org.eclipse.cdt.core.model.IIncludeReference" />
|
||||||
|
</or>
|
||||||
|
</enablement>
|
||||||
|
</decorator>
|
||||||
</extension>
|
</extension>
|
||||||
|
|
||||||
<!-- Hyperlinking support -->
|
<!-- Hyperlinking support -->
|
||||||
|
@ -4259,16 +4288,6 @@
|
||||||
</complexArray>
|
</complexArray>
|
||||||
</processType>
|
</processType>
|
||||||
</extension>
|
</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>
|
|
||||||
<extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
|
<extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
|
||||||
<provider
|
<provider
|
||||||
class="org.eclipse.cdt.core.language.settings.providers.LanguageSettingsGenericProvider"
|
class="org.eclipse.cdt.core.language.settings.providers.LanguageSettingsGenericProvider"
|
||||||
|
|
|
@ -14,6 +14,7 @@ package org.eclipse.cdt.internal.ui.cview;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import org.eclipse.core.resources.IContainer;
|
import org.eclipse.core.resources.IContainer;
|
||||||
|
import org.eclipse.core.resources.ResourcesPlugin;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.jface.viewers.TreeViewer;
|
import org.eclipse.jface.viewers.TreeViewer;
|
||||||
import org.eclipse.jface.viewers.Viewer;
|
import org.eclipse.jface.viewers.Viewer;
|
||||||
|
@ -232,15 +233,14 @@ public class CViewContentProvider extends CElementContentProvider {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else if (element instanceof IncludeReferenceProxy) {
|
} else if (element instanceof IncludeReferenceProxy) {
|
||||||
IIncludeReference ref = ((IncludeReferenceProxy)element).getReference();
|
IIncludeReference reference = ((IncludeReferenceProxy)element).getReference();
|
||||||
IPath location = ref.getPath();
|
IContainer container = ResourcesPlugin.getWorkspace().getRoot().getContainerForLocation(reference.getPath());
|
||||||
IContainer[] containers = ref.getCModel().getWorkspace().getRoot().findContainersForLocation(location);
|
if (container != null) {
|
||||||
for (int i = 0; i < containers.length; ++i) {
|
// do not allow to navigate to workspace containers inside "Includes" node
|
||||||
if (containers[i].isAccessible()) {
|
return false;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return reference.hasChildren();
|
||||||
}
|
}
|
||||||
return super.hasChildren(element);
|
return super.hasChildren(element);
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,16 +21,17 @@ import org.eclipse.jface.resource.ImageDescriptor;
|
||||||
import org.eclipse.jface.viewers.StyledString;
|
import org.eclipse.jface.viewers.StyledString;
|
||||||
import org.eclipse.swt.graphics.Image;
|
import org.eclipse.swt.graphics.Image;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
import org.eclipse.cdt.core.model.IIncludeReference;
|
import org.eclipse.cdt.core.model.IIncludeReference;
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
|
import org.eclipse.cdt.core.settings.model.ICSettingEntry;
|
||||||
import org.eclipse.cdt.ui.CDTSharedImages;
|
import org.eclipse.cdt.ui.CDTSharedImages;
|
||||||
import org.eclipse.cdt.ui.CElementImageDescriptor;
|
import org.eclipse.cdt.ui.CElementImageDescriptor;
|
||||||
import org.eclipse.cdt.ui.CUIPlugin;
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.corext.util.Strings;
|
import org.eclipse.cdt.internal.corext.util.Strings;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.internal.ui.newui.LanguageSettingsImages;
|
||||||
import org.eclipse.cdt.internal.ui.viewsupport.AppearanceAwareLabelProvider;
|
import org.eclipse.cdt.internal.ui.viewsupport.AppearanceAwareLabelProvider;
|
||||||
import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider;
|
import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider;
|
||||||
|
|
||||||
|
@ -107,20 +108,28 @@ public class CViewLabelProvider extends AppearanceAwareLabelProvider {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Image getImage(Object element) {
|
public Image getImage(Object element) {
|
||||||
|
String imageKey = null;
|
||||||
if (element instanceof IncludeReferenceProxy) {
|
if (element instanceof IncludeReferenceProxy) {
|
||||||
IIncludeReference reference = ((IncludeReferenceProxy)element).getReference();
|
IIncludeReference reference = ((IncludeReferenceProxy)element).getReference();
|
||||||
IPath path = reference.getPath();
|
IContainer container = ResourcesPlugin.getWorkspace().getRoot().getContainerForLocation(reference.getPath());
|
||||||
IContainer container = reference.getCModel().getWorkspace().getRoot().getContainerForLocation(path);
|
if (container != null) {
|
||||||
if (container != null && container.isAccessible()) {
|
ICProject cproject = reference.getCProject();
|
||||||
ImageDescriptor desc = CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_INCLUDES_FOLDER_WORKSPACE);
|
IProject project = (cproject != null) ? cproject.getProject() : null;
|
||||||
desc = new CElementImageDescriptor(desc, 0, CElementImageProvider.SMALL_SIZE);
|
boolean isProjectRelative = container.getProject().equals(project);
|
||||||
return CUIPlugin.getImageDescriptorRegistry().get(desc);
|
imageKey = LanguageSettingsImages.getImageKey(ICSettingEntry.INCLUDE_PATH, ICSettingEntry.VALUE_WORKSPACE_PATH, isProjectRelative);
|
||||||
|
} else {
|
||||||
|
imageKey = CDTSharedImages.IMG_OBJS_INCLUDES_FOLDER;
|
||||||
}
|
}
|
||||||
} else if (element instanceof IIncludeReference) {
|
} else if (element instanceof IIncludeReference) {
|
||||||
ImageDescriptor desc = CElementImageProvider.getImageDescriptor(ICElement.C_CCONTAINER);
|
imageKey = CDTSharedImages.IMG_OBJS_CFOLDER;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (imageKey != null) {
|
||||||
|
ImageDescriptor desc = CDTSharedImages.getImageDescriptor(imageKey);
|
||||||
desc = new CElementImageDescriptor(desc, 0, CElementImageProvider.SMALL_SIZE);
|
desc = new CElementImageDescriptor(desc, 0, CElementImageProvider.SMALL_SIZE);
|
||||||
return CUIPlugin.getImageDescriptorRegistry().get(desc);
|
return CUIPlugin.getImageDescriptorRegistry().get(desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
return super.getImage(element);
|
return super.getImage(element);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,7 +64,7 @@ public class LanguageSettingsImages {
|
||||||
/**
|
/**
|
||||||
* @return the base key for the image.
|
* @return the base key for the image.
|
||||||
*/
|
*/
|
||||||
private static String getImageKey(int kind, int flag, boolean isProjectRelative) {
|
public static String getImageKey(int kind, int flag, boolean isProjectRelative) {
|
||||||
String imageKey = null;
|
String imageKey = null;
|
||||||
|
|
||||||
boolean isWorkspacePath = (flag & ICSettingEntry.VALUE_WORKSPACE_PATH) != 0;
|
boolean isWorkspacePath = (flag & ICSettingEntry.VALUE_WORKSPACE_PATH) != 0;
|
||||||
|
|
|
@ -48,10 +48,6 @@ import org.eclipse.cdt.internal.ui.refactoring.utils.VisibilityEnum;
|
||||||
* @author Mirko Stocker
|
* @author Mirko Stocker
|
||||||
*/
|
*/
|
||||||
public class ClassMemberInserter {
|
public class ClassMemberInserter {
|
||||||
private final ICPPASTCompositeTypeSpecifier classNode;
|
|
||||||
private final VisibilityEnum visibility;
|
|
||||||
private final List<IASTNode> nodesToAdd;
|
|
||||||
private final ModificationCollector collector;
|
|
||||||
|
|
||||||
public static void createChange(ICPPASTCompositeTypeSpecifier classNode,
|
public static void createChange(ICPPASTCompositeTypeSpecifier classNode,
|
||||||
VisibilityEnum visibility, IASTNode nodeToAdd, boolean isField,
|
VisibilityEnum visibility, IASTNode nodeToAdd, boolean isField,
|
||||||
|
@ -62,25 +58,12 @@ public class ClassMemberInserter {
|
||||||
public static void createChange(ICPPASTCompositeTypeSpecifier classNode,
|
public static void createChange(ICPPASTCompositeTypeSpecifier classNode,
|
||||||
VisibilityEnum visibility, List<IASTNode> nodesToAdd, boolean isField,
|
VisibilityEnum visibility, List<IASTNode> nodesToAdd, boolean isField,
|
||||||
ModificationCollector collector) {
|
ModificationCollector collector) {
|
||||||
new ClassMemberInserter(classNode, visibility, nodesToAdd, collector, isField);
|
nodesToAdd = new ArrayList<IASTNode>(nodesToAdd);
|
||||||
}
|
|
||||||
|
|
||||||
private ClassMemberInserter(ICPPASTCompositeTypeSpecifier classNode,
|
|
||||||
VisibilityEnum visibility, List<IASTNode> nodesToAdd, ModificationCollector collector,
|
|
||||||
boolean isField) {
|
|
||||||
this.nodesToAdd = new ArrayList<IASTNode>(nodesToAdd);
|
|
||||||
this.classNode = classNode;
|
|
||||||
this.visibility = visibility;
|
|
||||||
this.collector = collector;
|
|
||||||
createRewrites(isField);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void createRewrites(boolean isField) {
|
|
||||||
VisibilityEnum defaultVisibility = classNode.getKey() == IASTCompositeTypeSpecifier.k_struct ?
|
VisibilityEnum defaultVisibility = classNode.getKey() == IASTCompositeTypeSpecifier.k_struct ?
|
||||||
VisibilityEnum.v_public : VisibilityEnum.v_private;
|
VisibilityEnum.v_public : VisibilityEnum.v_private;
|
||||||
VisibilityEnum currentVisibility = defaultVisibility;
|
VisibilityEnum currentVisibility = defaultVisibility;
|
||||||
|
|
||||||
boolean ascendingVisibilityOrder = isAscendingVisibilityOrder();
|
boolean ascendingVisibilityOrder = isAscendingVisibilityOrder(classNode);
|
||||||
int lastFunctionIndex = -1;
|
int lastFunctionIndex = -1;
|
||||||
int lastFieldIndex = -1;
|
int lastFieldIndex = -1;
|
||||||
int lastMatchingVisibilityIndex = -1;
|
int lastMatchingVisibilityIndex = -1;
|
||||||
|
@ -134,16 +117,20 @@ public class ClassMemberInserter {
|
||||||
|
|
||||||
ASTRewrite rewrite = collector.rewriterForTranslationUnit(classNode.getTranslationUnit());
|
ASTRewrite rewrite = collector.rewriterForTranslationUnit(classNode.getTranslationUnit());
|
||||||
for (IASTNode node : nodesToAdd) {
|
for (IASTNode node : nodesToAdd) {
|
||||||
rewrite.insertBefore(classNode, nextNode, node, createEditDescription());
|
rewrite.insertBefore(classNode, nextNode, node, createEditDescription(classNode));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private TextEditGroup createEditDescription() {
|
// Not instantiatable. All methods are static.
|
||||||
|
private ClassMemberInserter() {
|
||||||
|
}
|
||||||
|
|
||||||
|
private static TextEditGroup createEditDescription(ICPPASTCompositeTypeSpecifier classNode) {
|
||||||
return new TextEditGroup(NLS.bind(Messages.AddDeclarationNodeToClassChange_AddDeclaration,
|
return new TextEditGroup(NLS.bind(Messages.AddDeclarationNodeToClassChange_AddDeclaration,
|
||||||
classNode.getName()));
|
classNode.getName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isAscendingVisibilityOrder() {
|
private static boolean isAscendingVisibilityOrder(ICPPASTCompositeTypeSpecifier classNode) {
|
||||||
IPreferencesService preferences = Platform.getPreferencesService();
|
IPreferencesService preferences = Platform.getPreferencesService();
|
||||||
IASTTranslationUnit ast = classNode.getTranslationUnit();
|
IASTTranslationUnit ast = classNode.getTranslationUnit();
|
||||||
ITranslationUnit tu = ast.getOriginatingTranslationUnit();
|
ITranslationUnit tu = ast.getOriginatingTranslationUnit();
|
||||||
|
|
|
@ -0,0 +1,76 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2010, 2012 Andrew Gvozdev 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:
|
||||||
|
* Andrew Gvozdev - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.ui.viewsupport;
|
||||||
|
|
||||||
|
import org.eclipse.core.resources.IContainer;
|
||||||
|
import org.eclipse.core.resources.ResourcesPlugin;
|
||||||
|
import org.eclipse.core.runtime.IPath;
|
||||||
|
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.IIncludeReference;
|
||||||
|
import org.eclipse.cdt.ui.CDTSharedImages;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.internal.ui.cview.IncludeReferenceProxy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines whether an include folder under "Includes" node does exist
|
||||||
|
* and if not decorates the file's icon with warning overlay and
|
||||||
|
* renders the label using the qualifier (gray) color.
|
||||||
|
*/
|
||||||
|
public class IncludeFolderDecorator implements ILightweightLabelDecorator {
|
||||||
|
@Override
|
||||||
|
public void decorate(Object element, IDecoration decoration) {
|
||||||
|
boolean isAccesible = true;
|
||||||
|
|
||||||
|
if (element instanceof IncludeReferenceProxy) {
|
||||||
|
IIncludeReference reference = ((IncludeReferenceProxy)element).getReference();
|
||||||
|
IPath path = reference.getPath();
|
||||||
|
IContainer container = ResourcesPlugin.getWorkspace().getRoot().getContainerForLocation(path);
|
||||||
|
if (container != null) {
|
||||||
|
isAccesible = container.isAccessible();
|
||||||
|
} else {
|
||||||
|
isAccesible = path.toFile().exists();
|
||||||
|
}
|
||||||
|
} else if (element instanceof IIncludeReference) {
|
||||||
|
IPath path = ((IIncludeReference) element).getPath();
|
||||||
|
isAccesible = path.toFile().exists();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isAccesible) {
|
||||||
|
decoration.addOverlay(CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OVR_WARNING));
|
||||||
|
// JFacePreferences.QUALIFIER_COLOR colors label in gray
|
||||||
|
decoration.setForegroundColor(JFaceResources.getColorRegistry().get(JFacePreferences.QUALIFIER_COLOR));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addListener(ILabelProviderListener listener) {
|
||||||
|
// We don't track state changes
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void dispose() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isLabelProperty(Object element, String property) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeListener(ILabelProviderListener listener) {
|
||||||
|
// We don't track state changes
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue