mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 22:52:11 +02:00
bug 401734: CDT LanguageSettingsProviders do not support project-relative include paths
This commit is contained in:
parent
72702f1a04
commit
8364d2fbce
4 changed files with 146 additions and 114 deletions
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2002, 2010 QNX Software Systems and others.
|
||||
* Copyright (c) 2002, 2013 QNX Software Systems 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
|
||||
|
@ -35,18 +35,14 @@ import org.eclipse.cdt.internal.ui.language.settings.providers.LanguageSettingsI
|
|||
import org.eclipse.cdt.internal.ui.viewsupport.AppearanceAwareLabelProvider;
|
||||
import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider;
|
||||
|
||||
/*
|
||||
* CViewLabelProvider
|
||||
/**
|
||||
* Label provider for "C/C++ Projects" view.
|
||||
*/
|
||||
public class CViewLabelProvider extends AppearanceAwareLabelProvider {
|
||||
|
||||
public CViewLabelProvider(long textFlags, int imageFlags) {
|
||||
super(textFlags, imageFlags);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public String getText(Object element) {
|
||||
if (element instanceof IncludeReferenceProxy) {
|
||||
|
@ -103,22 +99,23 @@ public class CViewLabelProvider extends AppearanceAwareLabelProvider {
|
|||
return Strings.markLTR(new StyledString(getText(element)));
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public Image getImage(Object element) {
|
||||
String imageKey = null;
|
||||
if (element instanceof IncludeReferenceProxy) {
|
||||
IIncludeReference reference = ((IncludeReferenceProxy)element).getReference();
|
||||
IContainer containerInclude = ResourcesPlugin.getWorkspace().getRoot().getContainerForLocation(reference.getPath());
|
||||
if (containerInclude != null) {
|
||||
ICProject cproject = reference.getCProject();
|
||||
IProject project = (cproject != null) ? cproject.getProject() : null;
|
||||
IPath path = reference.getPath();
|
||||
ICProject cproject = reference.getCProject();
|
||||
IProject project = (cproject != null) ? cproject.getProject() : null;
|
||||
for (IContainer containerInclude : ResourcesPlugin.getWorkspace().getRoot().findContainersForLocationURI(URIUtil.toURI(path.makeAbsolute()))) {
|
||||
IProject projectInclude = containerInclude.getProject();
|
||||
boolean isProjectRelative = projectInclude != null && projectInclude.equals(project);
|
||||
imageKey = LanguageSettingsImages.getImageKey(ICSettingEntry.INCLUDE_PATH, ICSettingEntry.VALUE_WORKSPACE_PATH, isProjectRelative);
|
||||
} else {
|
||||
if (isProjectRelative) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (imageKey == null) {
|
||||
imageKey = CDTSharedImages.IMG_OBJS_INCLUDES_FOLDER;
|
||||
}
|
||||
} else if (element instanceof IIncludeReference) {
|
||||
|
|
|
@ -46,11 +46,11 @@ import org.eclipse.cdt.internal.ui.newui.Messages;
|
|||
public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
|
||||
private static final String SLASH = "/"; //$NON-NLS-1$
|
||||
|
||||
private ICConfigurationDescription cfgDescription;
|
||||
private IProject project;
|
||||
private ICLanguageSettingEntry entry;
|
||||
private boolean clearValue;
|
||||
private int kind;
|
||||
private final ICConfigurationDescription cfgDescription;
|
||||
private final IProject project;
|
||||
private final ICLanguageSettingEntry initialEntry;
|
||||
private final int initialKind;
|
||||
private final boolean clearValue;
|
||||
|
||||
private Composite compositeArea;
|
||||
private Label iconComboKind;
|
||||
|
@ -115,9 +115,9 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
|
|||
super(parent, ""); //$NON-NLS-1$
|
||||
this.cfgDescription = cfgDescription;
|
||||
this.project = cfgDescription.getProjectDescription().getProject();
|
||||
this.entry = null;
|
||||
this.initialEntry = null;
|
||||
this.initialKind = kind;
|
||||
this.clearValue = true;
|
||||
this.kind = kind;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -128,8 +128,8 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
|
|||
super(parent, ""); //$NON-NLS-1$
|
||||
this.cfgDescription = cfgDescription;
|
||||
this.project = cfgDescription.getProjectDescription().getProject();
|
||||
this.entry = entry;
|
||||
this.kind = entry != null ? entry.getKind() : ICSettingEntry.INCLUDE_PATH;
|
||||
this.initialEntry = entry;
|
||||
this.initialKind = entry != null ? entry.getKind() : ICSettingEntry.INCLUDE_PATH;
|
||||
this.clearValue = clearValue;
|
||||
}
|
||||
|
||||
|
@ -210,7 +210,7 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
|
|||
gd.horizontalAlignment = SWT.RIGHT;
|
||||
iconComboKind.setLayoutData(gd);
|
||||
iconComboKind.setText(Messages.LanguageSettingEntryDialog_SelectKind);
|
||||
int kindToComboIndex = kindToComboIndex(kind);
|
||||
int kindToComboIndex = kindToComboIndex(initialKind);
|
||||
iconComboKind.setImage(comboKindImages[kindToComboIndex]);
|
||||
|
||||
// Combo for the setting entry kind
|
||||
|
@ -247,14 +247,14 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
|
|||
comboPathCategory.add(pathCategories[i], pathCategoryImages[i]);
|
||||
}
|
||||
int pcindex = COMBO_PATH_INDEX_PROJECT;
|
||||
if (entry != null) {
|
||||
if ((entry.getFlags() & ICSettingEntry.VALUE_WORKSPACE_PATH) == 0) {
|
||||
if (initialEntry != null) {
|
||||
if ((initialEntry.getFlags() & ICSettingEntry.VALUE_WORKSPACE_PATH) == 0) {
|
||||
pcindex = COMBO_PATH_INDEX_FILESYSTEM;
|
||||
} else {
|
||||
if (entry.getName().startsWith(SLASH)) {
|
||||
pcindex = COMBO_PATH_INDEX_WORKSPACE;
|
||||
} else {
|
||||
if (LanguageSettingsImages.isProjectRelative(initialEntry)) {
|
||||
pcindex = COMBO_PATH_INDEX_PROJECT;
|
||||
} else {
|
||||
pcindex = COMBO_PATH_INDEX_WORKSPACE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -285,8 +285,12 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
|
|||
|
||||
// Dir/File/Name input
|
||||
inputName = new Text(compositeArea, SWT.SINGLE | SWT.BORDER);
|
||||
if (entry!=null && !clearValue) {
|
||||
inputName.setText(entry.getName());
|
||||
if (initialEntry != null && !clearValue) {
|
||||
String name = initialEntry.getName();
|
||||
if (pcindex == COMBO_PATH_INDEX_PROJECT && LanguageSettingsImages.isProjectRelative(initialEntry)) {
|
||||
name = LanguageSettingsImages.toProjectRelative(name);
|
||||
}
|
||||
inputName.setText(name);
|
||||
}
|
||||
gd = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL);
|
||||
gd.horizontalSpan = 2;
|
||||
|
@ -333,14 +337,14 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
|
|||
// Value input. Located after the other controls to get sufficient width
|
||||
int comboPathWidth = comboPathCategory.computeSize(SWT.DEFAULT, SWT.NONE).x;
|
||||
inputValue = new Text(compositeArea, SWT.SINGLE | SWT.BORDER);
|
||||
if (entry != null && !clearValue) {
|
||||
inputValue.setText(entry.getValue());
|
||||
if (initialEntry != null && !clearValue) {
|
||||
inputValue.setText(initialEntry.getValue());
|
||||
}
|
||||
gd = new GridData(SWT.FILL, SWT.NONE, false, false);
|
||||
gd.widthHint = comboPathWidth;
|
||||
inputValue.setLayoutData(gd);
|
||||
|
||||
if (entry != null && kind == ICSettingEntry.MACRO && !clearValue) {
|
||||
if (initialEntry != null && initialKind == ICSettingEntry.MACRO && !clearValue) {
|
||||
inputValue.setFocus();
|
||||
inputValue.setSelection(0, inputValue.getText().length());
|
||||
}
|
||||
|
@ -356,7 +360,7 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
|
|||
// Checkbox "Built-In"
|
||||
checkBoxBuiltIn = new Button(compCheckboxes, SWT.CHECK);
|
||||
checkBoxBuiltIn.setText(Messages.LanguageSettingEntryDialog_BuiltInFlag);
|
||||
checkBoxBuiltIn.setSelection(entry != null && (entry.getFlags() & ICSettingEntry.BUILTIN) != 0);
|
||||
checkBoxBuiltIn.setSelection(initialEntry != null && (initialEntry.getFlags() & ICSettingEntry.BUILTIN) != 0);
|
||||
gd = new GridData(GridData.FILL_HORIZONTAL);
|
||||
checkBoxBuiltIn.setLayoutData(gd);
|
||||
checkBoxBuiltIn.addSelectionListener(new SelectionListener() {
|
||||
|
@ -374,7 +378,7 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
|
|||
// Checkbox "Contains system includes"
|
||||
checkBoxSystem = new Button(compCheckboxes, SWT.CHECK);
|
||||
checkBoxSystem.setText(Messages.LanguageSettingEntryDialog_ContainsSystemHeaders);
|
||||
checkBoxSystem.setSelection(entry != null && (entry.getFlags() & ICSettingEntry.LOCAL) == 0);
|
||||
checkBoxSystem.setSelection(initialEntry != null && (initialEntry.getFlags() & ICSettingEntry.LOCAL) == 0);
|
||||
gd = new GridData(GridData.FILL_HORIZONTAL);
|
||||
checkBoxSystem.setLayoutData(gd);
|
||||
checkBoxSystem.addSelectionListener(new SelectionListener() {
|
||||
|
@ -392,7 +396,7 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
|
|||
// Checkbox "Framework folder"
|
||||
checkBoxFramework = new Button(compCheckboxes, SWT.CHECK);
|
||||
checkBoxFramework.setText(Messages.LanguageSettingEntryDialog_FrameworkFolder);
|
||||
checkBoxFramework.setSelection(entry != null && (entry.getFlags() & ICSettingEntry.FRAMEWORKS_MAC) != 0);
|
||||
checkBoxFramework.setSelection(initialEntry != null && (initialEntry.getFlags() & ICSettingEntry.FRAMEWORKS_MAC) != 0);
|
||||
gd = new GridData(GridData.FILL_HORIZONTAL);
|
||||
checkBoxFramework.setLayoutData(gd);
|
||||
checkBoxFramework.addSelectionListener(new SelectionListener() {
|
||||
|
@ -495,7 +499,7 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
|
|||
boolean isProjectSelected = (indexPathKind == COMBO_PATH_INDEX_PROJECT);
|
||||
boolean isWorkspaceSelected = (indexPathKind == COMBO_PATH_INDEX_WORKSPACE);
|
||||
boolean isFilesystemSelected = (indexPathKind == COMBO_PATH_INDEX_FILESYSTEM);
|
||||
|
||||
|
||||
String path = inputName.getText().trim();
|
||||
if (path.isEmpty()) {
|
||||
buttonOk.setEnabled(false);
|
||||
|
@ -503,7 +507,7 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
|
|||
buttonOk.setEnabled((isProjectSelected && !path.startsWith(SLASH)) ||
|
||||
(isWorkspaceSelected && path.startsWith(SLASH)) || isFilesystemSelected);
|
||||
}
|
||||
|
||||
|
||||
buttonVars.setEnabled(isFilesystemSelected);
|
||||
}
|
||||
|
||||
|
@ -514,28 +518,38 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
|
|||
public void buttonPressed(SelectionEvent e) {
|
||||
String str = null;
|
||||
if (e.widget.equals(buttonOk)) {
|
||||
String name = inputName.getText().trim();
|
||||
text1 = name;
|
||||
String value = inputValue.getText().trim();
|
||||
text1 = inputName.getText().trim();
|
||||
result = true;
|
||||
|
||||
String name = text1;
|
||||
int flagBuiltIn = checkBoxBuiltIn.isVisible() && checkBoxBuiltIn.getSelection() ? ICSettingEntry.BUILTIN : 0;
|
||||
int flagSystem = checkBoxSystem.isVisible() && checkBoxSystem.getSelection() ? 0 : ICSettingEntry.LOCAL;
|
||||
int flagFramework = checkBoxFramework.isVisible() && checkBoxFramework.getSelection() ? ICSettingEntry.FRAMEWORKS_MAC : 0;
|
||||
int indexPathKind = comboPathCategory.getSelectionIndex();
|
||||
int flags = flagBuiltIn;
|
||||
|
||||
int kind = comboKind.getSelectionIndex();
|
||||
boolean isProjectPath = indexPathKind == COMBO_PATH_INDEX_PROJECT;
|
||||
boolean isWorkspacePath = (kind != COMBO_INDEX_MACRO) && (isProjectPath || indexPathKind == COMBO_PATH_INDEX_WORKSPACE);
|
||||
int flagWorkspace = isWorkspacePath ? ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED : 0;
|
||||
int flags = flagBuiltIn | flagWorkspace | flagSystem | flagFramework;
|
||||
if (kind != COMBO_INDEX_MACRO) {
|
||||
int flagSystem = checkBoxSystem.isVisible() && checkBoxSystem.getSelection() ? 0 : ICSettingEntry.LOCAL;
|
||||
int flagFramework = checkBoxFramework.isVisible() && checkBoxFramework.getSelection() ? ICSettingEntry.FRAMEWORKS_MAC : 0;
|
||||
|
||||
int indexPathKind = comboPathCategory.getSelectionIndex();
|
||||
boolean isProjectPath = indexPathKind == COMBO_PATH_INDEX_PROJECT;
|
||||
boolean isWorkspacePath = indexPathKind == COMBO_PATH_INDEX_WORKSPACE;
|
||||
int flagWorkspace = (isWorkspacePath || isProjectPath) ? ICSettingEntry.VALUE_WORKSPACE_PATH : 0;
|
||||
int flagResolved = isWorkspacePath && !name.contains("$") ? ICSettingEntry.RESOLVED : 0; //$NON-NLS-1$
|
||||
flags = flagBuiltIn | flagWorkspace | flagResolved | flagSystem | flagFramework;
|
||||
|
||||
if (isProjectPath) {
|
||||
name = LanguageSettingsImages.fromProjectRelative(name);
|
||||
}
|
||||
}
|
||||
|
||||
ICLanguageSettingEntry entry = null;
|
||||
switch (kind) {
|
||||
switch (comboKind.getSelectionIndex()) {
|
||||
case COMBO_INDEX_INCLUDE_DIR:
|
||||
entry = CDataUtil.createCIncludePathEntry(name, flags);
|
||||
break;
|
||||
case COMBO_INDEX_MACRO:
|
||||
// Note that value=null is not supported by CMacroEntry
|
||||
String value = inputValue.getText().trim();
|
||||
entry = CDataUtil.createCMacroEntry(name, value, flags);
|
||||
break;
|
||||
case COMBO_INDEX_INCLUDE_FILE:
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2010, 2012 Andrew Gvozdev and others.
|
||||
* Copyright (c) 2010, 2013 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
|
||||
|
@ -155,11 +155,15 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
|
|||
public String getText(Object element) {
|
||||
if (element instanceof ICLanguageSettingEntry) {
|
||||
ICLanguageSettingEntry entry = (ICLanguageSettingEntry) element;
|
||||
String s = entry.getName();
|
||||
if ((entry.getKind() == ICSettingEntry.MACRO) && (entry.getFlags()&ICSettingEntry.UNDEFINED) == 0) {
|
||||
s = s + '=' + entry.getValue();
|
||||
String text = entry.getName();
|
||||
if (entry.getKind() == ICSettingEntry.MACRO) {
|
||||
if ((entry.getFlags() & ICSettingEntry.UNDEFINED) == 0) {
|
||||
text = text + '=' + entry.getValue();
|
||||
}
|
||||
} else if (LanguageSettingsImages.isProjectRelative(entry)) {
|
||||
text = LanguageSettingsImages.toProjectRelative(text);
|
||||
}
|
||||
return s;
|
||||
return text;
|
||||
}
|
||||
|
||||
return super.getText(element);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2010, 2012 Andrew Gvozdev and others.
|
||||
* Copyright (c) 2010, 2013 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
|
||||
|
@ -8,10 +8,8 @@
|
|||
* Contributors:
|
||||
* Andrew Gvozdev - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.ui.language.settings.providers;
|
||||
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
|
@ -24,7 +22,6 @@ import org.eclipse.swt.graphics.Image;
|
|||
import org.eclipse.cdt.core.settings.model.ACPathEntry;
|
||||
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
|
||||
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
|
||||
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
|
||||
import org.eclipse.cdt.core.settings.model.ICSettingEntry;
|
||||
import org.eclipse.cdt.core.settings.model.util.CDataUtil;
|
||||
import org.eclipse.cdt.ui.CDTSharedImages;
|
||||
|
@ -37,6 +34,54 @@ import org.eclipse.cdt.internal.ui.newui.Messages;
|
|||
* Helper class to provide unified images for {@link ICLanguageSettingEntry}.
|
||||
*/
|
||||
public class LanguageSettingsImages {
|
||||
private static final String PROJ_NAME_PREFIX = "/${ProjName}/"; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* Check if the language settings entry should be presented as "project-relative" in UI.
|
||||
*
|
||||
* @param entry - language settings entry to check.
|
||||
* @return {@code true} if the entry should be displayed as "project-relative", {@code false} otherwise.
|
||||
*/
|
||||
public static boolean isProjectRelative(ICLanguageSettingEntry entry) {
|
||||
if (entry instanceof ACPathEntry) {
|
||||
String path = entry.getName();
|
||||
return ((ACPathEntry) entry).isValueWorkspacePath() && path.startsWith(PROJ_NAME_PREFIX);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert path used by {@link ICLanguageSettingEntry} to label representing project-relative portion.
|
||||
*
|
||||
* @param path - path to convert to label in project-relative format.
|
||||
* @return label to be used to display the path in UI.
|
||||
*/
|
||||
public static String toProjectRelative(String path) {
|
||||
if (path.startsWith(LanguageSettingsImages.PROJ_NAME_PREFIX)) {
|
||||
return path.substring(LanguageSettingsImages.PROJ_NAME_PREFIX.length());
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert label for project-relative path back to path representation carried by {@link ICLanguageSettingEntry}.
|
||||
*
|
||||
* @param label - label in project-relative format.
|
||||
* @return path to be used by {@link ICLanguageSettingEntry}.
|
||||
*/
|
||||
public static String fromProjectRelative(String label) {
|
||||
return LanguageSettingsImages.PROJ_NAME_PREFIX + label;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns image for the given {@link ICLanguageSettingEntry} from internally managed repository including
|
||||
* necessary overlays for given configuration description.
|
||||
*
|
||||
* @param kind - kind of {@link ICLanguageSettingEntry}, i.e. {@link ICSettingEntry#INCLUDE_PATH} etc.
|
||||
* @param flags - flags of {@link ICSettingEntry}.
|
||||
* @param isProjectRelative specifies if the image should present "project-relative" icon.
|
||||
* @return the image for the entry with appropriate overlays.
|
||||
*/
|
||||
public static Image getImage(int kind, int flags, boolean isProjectRelative) {
|
||||
String imageKey = getImageKey(kind, flags, isProjectRelative);
|
||||
if (imageKey != null) {
|
||||
|
@ -54,19 +99,35 @@ public class LanguageSettingsImages {
|
|||
* @return the image for the entry with appropriate overlays.
|
||||
*/
|
||||
public static Image getImage(ICLanguageSettingEntry entry, ICConfigurationDescription cfgDescription) {
|
||||
String projectName = null;
|
||||
int kind = entry.getKind();
|
||||
int flags = entry.getFlags();
|
||||
boolean isProjectRelative = isProjectRelative(entry);
|
||||
|
||||
if (cfgDescription != null) {
|
||||
ICProjectDescription prjDescription = cfgDescription.getProjectDescription();
|
||||
if (prjDescription != null) {
|
||||
IProject project = prjDescription.getProject();
|
||||
if (project != null) {
|
||||
projectName = project.getName();
|
||||
}
|
||||
String imageKey = getImageKey(kind, flags, isProjectRelative);
|
||||
if (imageKey != null) {
|
||||
if ((flags & ICSettingEntry.UNDEFINED) != 0) {
|
||||
return CDTSharedImages.getImageOverlaid(imageKey, CDTSharedImages.IMG_OVR_INACTIVE, IDecoration.BOTTOM_LEFT);
|
||||
}
|
||||
}
|
||||
|
||||
return getImage(entry, projectName, cfgDescription);
|
||||
String overlayKey=null;
|
||||
IStatus status = getStatus(entry, cfgDescription);
|
||||
switch (status.getSeverity()) {
|
||||
case IStatus.ERROR:
|
||||
overlayKey = CDTSharedImages.IMG_OVR_ERROR;
|
||||
break;
|
||||
case IStatus.WARNING:
|
||||
overlayKey = CDTSharedImages.IMG_OVR_WARNING;
|
||||
break;
|
||||
case IStatus.INFO:
|
||||
overlayKey = CDTSharedImages.IMG_OVR_WARNING;
|
||||
break;
|
||||
}
|
||||
if (overlayKey != null) {
|
||||
return CDTSharedImages.getImageOverlaid(imageKey, overlayKey, IDecoration.BOTTOM_LEFT);
|
||||
}
|
||||
return CDTSharedImages.getImage(imageKey);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -116,50 +177,6 @@ public class LanguageSettingsImages {
|
|||
return imageKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns image for the given entry from internally managed repository including
|
||||
* necessary overlays.
|
||||
*
|
||||
* @param entry - language settings entry to get an image for.
|
||||
* @param projectName - pass project name if available. That lets put "project" metaphor
|
||||
* on the image. Pass {@code null} if no project name is available.
|
||||
* @param cfgDescription - configuration description of the entry.
|
||||
* @return the image for the entry with appropriate overlays.
|
||||
*/
|
||||
private static Image getImage(ICLanguageSettingEntry entry, String projectName, ICConfigurationDescription cfgDescription) {
|
||||
int kind = entry.getKind();
|
||||
int flags = entry.getFlags();
|
||||
boolean isWorkspacePath = (flags & ICSettingEntry.VALUE_WORKSPACE_PATH) != 0;
|
||||
String path = entry.getName();
|
||||
boolean isProjectRelative = (projectName != null) && isWorkspacePath && path.startsWith(IPath.SEPARATOR + projectName + IPath.SEPARATOR);
|
||||
|
||||
String imageKey = getImageKey(kind, flags, isProjectRelative);
|
||||
if (imageKey != null) {
|
||||
if ((flags & ICSettingEntry.UNDEFINED) != 0) {
|
||||
return CDTSharedImages.getImageOverlaid(imageKey, CDTSharedImages.IMG_OVR_INACTIVE, IDecoration.BOTTOM_LEFT);
|
||||
}
|
||||
|
||||
if (entry instanceof ACPathEntry) {
|
||||
String overlayKey=null;
|
||||
IStatus status = getStatus(entry, cfgDescription);
|
||||
switch (status.getSeverity()) {
|
||||
case IStatus.ERROR:
|
||||
overlayKey = CDTSharedImages.IMG_OVR_ERROR;
|
||||
break;
|
||||
case IStatus.WARNING:
|
||||
overlayKey = CDTSharedImages.IMG_OVR_WARNING;
|
||||
break;
|
||||
case IStatus.INFO:
|
||||
overlayKey = CDTSharedImages.IMG_OVR_WARNING;
|
||||
break;
|
||||
}
|
||||
return CDTSharedImages.getImageOverlaid(imageKey, overlayKey, IDecoration.BOTTOM_LEFT);
|
||||
}
|
||||
return CDTSharedImages.getImage(imageKey);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checking if the entry points to existing or accessible location.
|
||||
* @param entry - resolved entry
|
||||
|
|
Loading…
Add table
Reference in a new issue