mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-06 09:16:02 +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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* 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.AppearanceAwareLabelProvider;
|
||||||
import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider;
|
import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider;
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* CViewLabelProvider
|
* Label provider for "C/C++ Projects" view.
|
||||||
*/
|
*/
|
||||||
public class CViewLabelProvider extends AppearanceAwareLabelProvider {
|
public class CViewLabelProvider extends AppearanceAwareLabelProvider {
|
||||||
|
|
||||||
public CViewLabelProvider(long textFlags, int imageFlags) {
|
public CViewLabelProvider(long textFlags, int imageFlags) {
|
||||||
super(textFlags, imageFlags);
|
super(textFlags, imageFlags);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String getText(Object element) {
|
public String getText(Object element) {
|
||||||
if (element instanceof IncludeReferenceProxy) {
|
if (element instanceof IncludeReferenceProxy) {
|
||||||
|
@ -103,22 +99,23 @@ public class CViewLabelProvider extends AppearanceAwareLabelProvider {
|
||||||
return Strings.markLTR(new StyledString(getText(element)));
|
return Strings.markLTR(new StyledString(getText(element)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public Image getImage(Object element) {
|
public Image getImage(Object element) {
|
||||||
String imageKey = null;
|
String imageKey = null;
|
||||||
if (element instanceof IncludeReferenceProxy) {
|
if (element instanceof IncludeReferenceProxy) {
|
||||||
IIncludeReference reference = ((IncludeReferenceProxy)element).getReference();
|
IIncludeReference reference = ((IncludeReferenceProxy)element).getReference();
|
||||||
IContainer containerInclude = ResourcesPlugin.getWorkspace().getRoot().getContainerForLocation(reference.getPath());
|
IPath path = reference.getPath();
|
||||||
if (containerInclude != null) {
|
ICProject cproject = reference.getCProject();
|
||||||
ICProject cproject = reference.getCProject();
|
IProject project = (cproject != null) ? cproject.getProject() : null;
|
||||||
IProject project = (cproject != null) ? cproject.getProject() : null;
|
for (IContainer containerInclude : ResourcesPlugin.getWorkspace().getRoot().findContainersForLocationURI(URIUtil.toURI(path.makeAbsolute()))) {
|
||||||
IProject projectInclude = containerInclude.getProject();
|
IProject projectInclude = containerInclude.getProject();
|
||||||
boolean isProjectRelative = projectInclude != null && projectInclude.equals(project);
|
boolean isProjectRelative = projectInclude != null && projectInclude.equals(project);
|
||||||
imageKey = LanguageSettingsImages.getImageKey(ICSettingEntry.INCLUDE_PATH, ICSettingEntry.VALUE_WORKSPACE_PATH, isProjectRelative);
|
imageKey = LanguageSettingsImages.getImageKey(ICSettingEntry.INCLUDE_PATH, ICSettingEntry.VALUE_WORKSPACE_PATH, isProjectRelative);
|
||||||
} else {
|
if (isProjectRelative) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (imageKey == null) {
|
||||||
imageKey = CDTSharedImages.IMG_OBJS_INCLUDES_FOLDER;
|
imageKey = CDTSharedImages.IMG_OBJS_INCLUDES_FOLDER;
|
||||||
}
|
}
|
||||||
} else if (element instanceof IIncludeReference) {
|
} else if (element instanceof IIncludeReference) {
|
||||||
|
|
|
@ -46,11 +46,11 @@ import org.eclipse.cdt.internal.ui.newui.Messages;
|
||||||
public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
|
public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
|
||||||
private static final String SLASH = "/"; //$NON-NLS-1$
|
private static final String SLASH = "/"; //$NON-NLS-1$
|
||||||
|
|
||||||
private ICConfigurationDescription cfgDescription;
|
private final ICConfigurationDescription cfgDescription;
|
||||||
private IProject project;
|
private final IProject project;
|
||||||
private ICLanguageSettingEntry entry;
|
private final ICLanguageSettingEntry initialEntry;
|
||||||
private boolean clearValue;
|
private final int initialKind;
|
||||||
private int kind;
|
private final boolean clearValue;
|
||||||
|
|
||||||
private Composite compositeArea;
|
private Composite compositeArea;
|
||||||
private Label iconComboKind;
|
private Label iconComboKind;
|
||||||
|
@ -115,9 +115,9 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
|
||||||
super(parent, ""); //$NON-NLS-1$
|
super(parent, ""); //$NON-NLS-1$
|
||||||
this.cfgDescription = cfgDescription;
|
this.cfgDescription = cfgDescription;
|
||||||
this.project = cfgDescription.getProjectDescription().getProject();
|
this.project = cfgDescription.getProjectDescription().getProject();
|
||||||
this.entry = null;
|
this.initialEntry = null;
|
||||||
|
this.initialKind = kind;
|
||||||
this.clearValue = true;
|
this.clearValue = true;
|
||||||
this.kind = kind;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -128,8 +128,8 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
|
||||||
super(parent, ""); //$NON-NLS-1$
|
super(parent, ""); //$NON-NLS-1$
|
||||||
this.cfgDescription = cfgDescription;
|
this.cfgDescription = cfgDescription;
|
||||||
this.project = cfgDescription.getProjectDescription().getProject();
|
this.project = cfgDescription.getProjectDescription().getProject();
|
||||||
this.entry = entry;
|
this.initialEntry = entry;
|
||||||
this.kind = entry != null ? entry.getKind() : ICSettingEntry.INCLUDE_PATH;
|
this.initialKind = entry != null ? entry.getKind() : ICSettingEntry.INCLUDE_PATH;
|
||||||
this.clearValue = clearValue;
|
this.clearValue = clearValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -210,7 +210,7 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
|
||||||
gd.horizontalAlignment = SWT.RIGHT;
|
gd.horizontalAlignment = SWT.RIGHT;
|
||||||
iconComboKind.setLayoutData(gd);
|
iconComboKind.setLayoutData(gd);
|
||||||
iconComboKind.setText(Messages.LanguageSettingEntryDialog_SelectKind);
|
iconComboKind.setText(Messages.LanguageSettingEntryDialog_SelectKind);
|
||||||
int kindToComboIndex = kindToComboIndex(kind);
|
int kindToComboIndex = kindToComboIndex(initialKind);
|
||||||
iconComboKind.setImage(comboKindImages[kindToComboIndex]);
|
iconComboKind.setImage(comboKindImages[kindToComboIndex]);
|
||||||
|
|
||||||
// Combo for the setting entry kind
|
// Combo for the setting entry kind
|
||||||
|
@ -247,14 +247,14 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
|
||||||
comboPathCategory.add(pathCategories[i], pathCategoryImages[i]);
|
comboPathCategory.add(pathCategories[i], pathCategoryImages[i]);
|
||||||
}
|
}
|
||||||
int pcindex = COMBO_PATH_INDEX_PROJECT;
|
int pcindex = COMBO_PATH_INDEX_PROJECT;
|
||||||
if (entry != null) {
|
if (initialEntry != null) {
|
||||||
if ((entry.getFlags() & ICSettingEntry.VALUE_WORKSPACE_PATH) == 0) {
|
if ((initialEntry.getFlags() & ICSettingEntry.VALUE_WORKSPACE_PATH) == 0) {
|
||||||
pcindex = COMBO_PATH_INDEX_FILESYSTEM;
|
pcindex = COMBO_PATH_INDEX_FILESYSTEM;
|
||||||
} else {
|
} else {
|
||||||
if (entry.getName().startsWith(SLASH)) {
|
if (LanguageSettingsImages.isProjectRelative(initialEntry)) {
|
||||||
pcindex = COMBO_PATH_INDEX_WORKSPACE;
|
|
||||||
} else {
|
|
||||||
pcindex = COMBO_PATH_INDEX_PROJECT;
|
pcindex = COMBO_PATH_INDEX_PROJECT;
|
||||||
|
} else {
|
||||||
|
pcindex = COMBO_PATH_INDEX_WORKSPACE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -285,8 +285,12 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
|
||||||
|
|
||||||
// Dir/File/Name input
|
// Dir/File/Name input
|
||||||
inputName = new Text(compositeArea, SWT.SINGLE | SWT.BORDER);
|
inputName = new Text(compositeArea, SWT.SINGLE | SWT.BORDER);
|
||||||
if (entry!=null && !clearValue) {
|
if (initialEntry != null && !clearValue) {
|
||||||
inputName.setText(entry.getName());
|
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 = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL);
|
||||||
gd.horizontalSpan = 2;
|
gd.horizontalSpan = 2;
|
||||||
|
@ -333,14 +337,14 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
|
||||||
// Value input. Located after the other controls to get sufficient width
|
// Value input. Located after the other controls to get sufficient width
|
||||||
int comboPathWidth = comboPathCategory.computeSize(SWT.DEFAULT, SWT.NONE).x;
|
int comboPathWidth = comboPathCategory.computeSize(SWT.DEFAULT, SWT.NONE).x;
|
||||||
inputValue = new Text(compositeArea, SWT.SINGLE | SWT.BORDER);
|
inputValue = new Text(compositeArea, SWT.SINGLE | SWT.BORDER);
|
||||||
if (entry != null && !clearValue) {
|
if (initialEntry != null && !clearValue) {
|
||||||
inputValue.setText(entry.getValue());
|
inputValue.setText(initialEntry.getValue());
|
||||||
}
|
}
|
||||||
gd = new GridData(SWT.FILL, SWT.NONE, false, false);
|
gd = new GridData(SWT.FILL, SWT.NONE, false, false);
|
||||||
gd.widthHint = comboPathWidth;
|
gd.widthHint = comboPathWidth;
|
||||||
inputValue.setLayoutData(gd);
|
inputValue.setLayoutData(gd);
|
||||||
|
|
||||||
if (entry != null && kind == ICSettingEntry.MACRO && !clearValue) {
|
if (initialEntry != null && initialKind == ICSettingEntry.MACRO && !clearValue) {
|
||||||
inputValue.setFocus();
|
inputValue.setFocus();
|
||||||
inputValue.setSelection(0, inputValue.getText().length());
|
inputValue.setSelection(0, inputValue.getText().length());
|
||||||
}
|
}
|
||||||
|
@ -356,7 +360,7 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
|
||||||
// Checkbox "Built-In"
|
// Checkbox "Built-In"
|
||||||
checkBoxBuiltIn = new Button(compCheckboxes, SWT.CHECK);
|
checkBoxBuiltIn = new Button(compCheckboxes, SWT.CHECK);
|
||||||
checkBoxBuiltIn.setText(Messages.LanguageSettingEntryDialog_BuiltInFlag);
|
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);
|
gd = new GridData(GridData.FILL_HORIZONTAL);
|
||||||
checkBoxBuiltIn.setLayoutData(gd);
|
checkBoxBuiltIn.setLayoutData(gd);
|
||||||
checkBoxBuiltIn.addSelectionListener(new SelectionListener() {
|
checkBoxBuiltIn.addSelectionListener(new SelectionListener() {
|
||||||
|
@ -374,7 +378,7 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
|
||||||
// Checkbox "Contains system includes"
|
// Checkbox "Contains system includes"
|
||||||
checkBoxSystem = new Button(compCheckboxes, SWT.CHECK);
|
checkBoxSystem = new Button(compCheckboxes, SWT.CHECK);
|
||||||
checkBoxSystem.setText(Messages.LanguageSettingEntryDialog_ContainsSystemHeaders);
|
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);
|
gd = new GridData(GridData.FILL_HORIZONTAL);
|
||||||
checkBoxSystem.setLayoutData(gd);
|
checkBoxSystem.setLayoutData(gd);
|
||||||
checkBoxSystem.addSelectionListener(new SelectionListener() {
|
checkBoxSystem.addSelectionListener(new SelectionListener() {
|
||||||
|
@ -392,7 +396,7 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
|
||||||
// Checkbox "Framework folder"
|
// Checkbox "Framework folder"
|
||||||
checkBoxFramework = new Button(compCheckboxes, SWT.CHECK);
|
checkBoxFramework = new Button(compCheckboxes, SWT.CHECK);
|
||||||
checkBoxFramework.setText(Messages.LanguageSettingEntryDialog_FrameworkFolder);
|
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);
|
gd = new GridData(GridData.FILL_HORIZONTAL);
|
||||||
checkBoxFramework.setLayoutData(gd);
|
checkBoxFramework.setLayoutData(gd);
|
||||||
checkBoxFramework.addSelectionListener(new SelectionListener() {
|
checkBoxFramework.addSelectionListener(new SelectionListener() {
|
||||||
|
@ -495,7 +499,7 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
|
||||||
boolean isProjectSelected = (indexPathKind == COMBO_PATH_INDEX_PROJECT);
|
boolean isProjectSelected = (indexPathKind == COMBO_PATH_INDEX_PROJECT);
|
||||||
boolean isWorkspaceSelected = (indexPathKind == COMBO_PATH_INDEX_WORKSPACE);
|
boolean isWorkspaceSelected = (indexPathKind == COMBO_PATH_INDEX_WORKSPACE);
|
||||||
boolean isFilesystemSelected = (indexPathKind == COMBO_PATH_INDEX_FILESYSTEM);
|
boolean isFilesystemSelected = (indexPathKind == COMBO_PATH_INDEX_FILESYSTEM);
|
||||||
|
|
||||||
String path = inputName.getText().trim();
|
String path = inputName.getText().trim();
|
||||||
if (path.isEmpty()) {
|
if (path.isEmpty()) {
|
||||||
buttonOk.setEnabled(false);
|
buttonOk.setEnabled(false);
|
||||||
|
@ -503,7 +507,7 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
|
||||||
buttonOk.setEnabled((isProjectSelected && !path.startsWith(SLASH)) ||
|
buttonOk.setEnabled((isProjectSelected && !path.startsWith(SLASH)) ||
|
||||||
(isWorkspaceSelected && path.startsWith(SLASH)) || isFilesystemSelected);
|
(isWorkspaceSelected && path.startsWith(SLASH)) || isFilesystemSelected);
|
||||||
}
|
}
|
||||||
|
|
||||||
buttonVars.setEnabled(isFilesystemSelected);
|
buttonVars.setEnabled(isFilesystemSelected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -514,28 +518,38 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
|
||||||
public void buttonPressed(SelectionEvent e) {
|
public void buttonPressed(SelectionEvent e) {
|
||||||
String str = null;
|
String str = null;
|
||||||
if (e.widget.equals(buttonOk)) {
|
if (e.widget.equals(buttonOk)) {
|
||||||
String name = inputName.getText().trim();
|
text1 = inputName.getText().trim();
|
||||||
text1 = name;
|
|
||||||
String value = inputValue.getText().trim();
|
|
||||||
result = true;
|
result = true;
|
||||||
|
|
||||||
|
String name = text1;
|
||||||
int flagBuiltIn = checkBoxBuiltIn.isVisible() && checkBoxBuiltIn.getSelection() ? ICSettingEntry.BUILTIN : 0;
|
int flagBuiltIn = checkBoxBuiltIn.isVisible() && checkBoxBuiltIn.getSelection() ? ICSettingEntry.BUILTIN : 0;
|
||||||
int flagSystem = checkBoxSystem.isVisible() && checkBoxSystem.getSelection() ? 0 : ICSettingEntry.LOCAL;
|
int flags = flagBuiltIn;
|
||||||
int flagFramework = checkBoxFramework.isVisible() && checkBoxFramework.getSelection() ? ICSettingEntry.FRAMEWORKS_MAC : 0;
|
|
||||||
int indexPathKind = comboPathCategory.getSelectionIndex();
|
|
||||||
int kind = comboKind.getSelectionIndex();
|
int kind = comboKind.getSelectionIndex();
|
||||||
boolean isProjectPath = indexPathKind == COMBO_PATH_INDEX_PROJECT;
|
if (kind != COMBO_INDEX_MACRO) {
|
||||||
boolean isWorkspacePath = (kind != COMBO_INDEX_MACRO) && (isProjectPath || indexPathKind == COMBO_PATH_INDEX_WORKSPACE);
|
int flagSystem = checkBoxSystem.isVisible() && checkBoxSystem.getSelection() ? 0 : ICSettingEntry.LOCAL;
|
||||||
int flagWorkspace = isWorkspacePath ? ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED : 0;
|
int flagFramework = checkBoxFramework.isVisible() && checkBoxFramework.getSelection() ? ICSettingEntry.FRAMEWORKS_MAC : 0;
|
||||||
int flags = flagBuiltIn | flagWorkspace | flagSystem | flagFramework;
|
|
||||||
|
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;
|
ICLanguageSettingEntry entry = null;
|
||||||
switch (kind) {
|
switch (comboKind.getSelectionIndex()) {
|
||||||
case COMBO_INDEX_INCLUDE_DIR:
|
case COMBO_INDEX_INCLUDE_DIR:
|
||||||
entry = CDataUtil.createCIncludePathEntry(name, flags);
|
entry = CDataUtil.createCIncludePathEntry(name, flags);
|
||||||
break;
|
break;
|
||||||
case COMBO_INDEX_MACRO:
|
case COMBO_INDEX_MACRO:
|
||||||
// Note that value=null is not supported by CMacroEntry
|
// Note that value=null is not supported by CMacroEntry
|
||||||
|
String value = inputValue.getText().trim();
|
||||||
entry = CDataUtil.createCMacroEntry(name, value, flags);
|
entry = CDataUtil.createCMacroEntry(name, value, flags);
|
||||||
break;
|
break;
|
||||||
case COMBO_INDEX_INCLUDE_FILE:
|
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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -155,11 +155,15 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
|
||||||
public String getText(Object element) {
|
public String getText(Object element) {
|
||||||
if (element instanceof ICLanguageSettingEntry) {
|
if (element instanceof ICLanguageSettingEntry) {
|
||||||
ICLanguageSettingEntry entry = (ICLanguageSettingEntry) element;
|
ICLanguageSettingEntry entry = (ICLanguageSettingEntry) element;
|
||||||
String s = entry.getName();
|
String text = entry.getName();
|
||||||
if ((entry.getKind() == ICSettingEntry.MACRO) && (entry.getFlags()&ICSettingEntry.UNDEFINED) == 0) {
|
if (entry.getKind() == ICSettingEntry.MACRO) {
|
||||||
s = s + '=' + entry.getValue();
|
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);
|
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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -8,10 +8,8 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Andrew Gvozdev - Initial API and implementation
|
* Andrew Gvozdev - Initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.ui.language.settings.providers;
|
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.IResource;
|
||||||
import org.eclipse.core.resources.ResourcesPlugin;
|
import org.eclipse.core.resources.ResourcesPlugin;
|
||||||
import org.eclipse.core.runtime.IPath;
|
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.ACPathEntry;
|
||||||
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
|
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
|
||||||
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
|
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.ICSettingEntry;
|
||||||
import org.eclipse.cdt.core.settings.model.util.CDataUtil;
|
import org.eclipse.cdt.core.settings.model.util.CDataUtil;
|
||||||
import org.eclipse.cdt.ui.CDTSharedImages;
|
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}.
|
* Helper class to provide unified images for {@link ICLanguageSettingEntry}.
|
||||||
*/
|
*/
|
||||||
public class LanguageSettingsImages {
|
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) {
|
public static Image getImage(int kind, int flags, boolean isProjectRelative) {
|
||||||
String imageKey = getImageKey(kind, flags, isProjectRelative);
|
String imageKey = getImageKey(kind, flags, isProjectRelative);
|
||||||
if (imageKey != null) {
|
if (imageKey != null) {
|
||||||
|
@ -54,19 +99,35 @@ public class LanguageSettingsImages {
|
||||||
* @return the image for the entry with appropriate overlays.
|
* @return the image for the entry with appropriate overlays.
|
||||||
*/
|
*/
|
||||||
public static Image getImage(ICLanguageSettingEntry entry, ICConfigurationDescription cfgDescription) {
|
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) {
|
String imageKey = getImageKey(kind, flags, isProjectRelative);
|
||||||
ICProjectDescription prjDescription = cfgDescription.getProjectDescription();
|
if (imageKey != null) {
|
||||||
if (prjDescription != null) {
|
if ((flags & ICSettingEntry.UNDEFINED) != 0) {
|
||||||
IProject project = prjDescription.getProject();
|
return CDTSharedImages.getImageOverlaid(imageKey, CDTSharedImages.IMG_OVR_INACTIVE, IDecoration.BOTTOM_LEFT);
|
||||||
if (project != null) {
|
|
||||||
projectName = project.getName();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
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.
|
* Checking if the entry points to existing or accessible location.
|
||||||
* @param entry - resolved entry
|
* @param entry - resolved entry
|
||||||
|
|
Loading…
Add table
Reference in a new issue