1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-17 13:15:44 +02:00

Merge remote-tracking branch 'cdt/master' into sd90

This commit is contained in:
Andrew Gvozdev 2012-01-06 00:29:12 -05:00
commit 2bcefc5379
7 changed files with 91 additions and 79 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 521 B

View file

@ -551,7 +551,8 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
private void updateStatusLine() { private void updateStatusLine() {
IStatus status=null; IStatus status=null;
if (enableProvidersCheckBox.getSelection()==true) { if (enableProvidersCheckBox.getSelection()==true) {
status = LanguageSettingsImages.getStatus(getSelectedEntry()); ICConfigurationDescription cfgDescription = getConfigurationDescription();
status = LanguageSettingsImages.getStatus(getSelectedEntry(), cfgDescription);
} }
if (status==null || status==Status.OK_STATUS) { if (status==null || status==Status.OK_STATUS) {
ILanguageSettingsProvider provider = getSelectedProvider(); ILanguageSettingsProvider provider = getSelectedProvider();

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2010 Andrew Gvozdev and others. * Copyright (c) 2010, 2012 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
@ -21,6 +21,7 @@ import org.eclipse.jface.viewers.IDecoration;
import org.eclipse.swt.graphics.Image; 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.ICLanguageSettingEntry; import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
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;
@ -31,6 +32,8 @@ import org.eclipse.cdt.ui.CUIPlugin;
* Helper class to provide unified images for {@link ICLanguageSettingEntry}. * Helper class to provide unified images for {@link ICLanguageSettingEntry}.
*/ */
public class LanguageSettingsImages { public class LanguageSettingsImages {
// AG FIXME - replace usage with version taking cfgDescription
@Deprecated
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) {
@ -45,114 +48,17 @@ public class LanguageSettingsImages {
/** /**
* Returns image for the given entry from internally managed repository including * Returns image for the given entry from internally managed repository including
* necessary overlays. This method is shortcut for {@link #getImage(ICLanguageSettingEntry, String)} * necessary overlays. This method is shortcut for {@link #getImage(ICLanguageSettingEntry, String, ICConfigurationDescription)}
* when no project is available. * when no project is available.
* *
* @param entry - language settings entry to get an image for. * @param entry - language settings entry to get an image for.
* @return the image for the entry with appropriate overlays. * @return the image for the entry with appropriate overlays.
*
* AG FIXME - replace usage with version taking cfgDescription
*/ */
@Deprecated
public static Image getImage(ICLanguageSettingEntry entry) { public static Image getImage(ICLanguageSettingEntry entry) {
return getImage(entry, null); return getImage(entry, null, null);
}
/**
* 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 to put "project" metaphor
* on the image. Pass {@code null} if no project name is available.
* @return the image for the entry with appropriate overlays.
*/
public static Image getImage(ICLanguageSettingEntry entry, String projectName) {
int kind = entry.getKind();
boolean isWorkspacePath = (entry.getFlags() & ICSettingEntry.VALUE_WORKSPACE_PATH) != 0;
String path = entry.getName();
boolean isProjectRelative = projectName!=null && isWorkspacePath && path.startsWith(IPath.SEPARATOR+projectName+IPath.SEPARATOR);
// FIXME
isProjectRelative = isProjectRelative || (isWorkspacePath && path.charAt(0)!=IPath.SEPARATOR);
int flags = entry.getFlags();
String imageKey = getImageKey(kind, flags, isProjectRelative);
if (imageKey!=null) {
if ((entry.getFlags()&ICSettingEntry.UNDEFINED) == ICSettingEntry.UNDEFINED)
return CDTSharedImages.getImageOverlaid(imageKey, CDTSharedImages.IMG_OVR_INACTIVE, IDecoration.BOTTOM_LEFT);
if (entry instanceof ACPathEntry) {
String overlayKey=null;
IStatus status = getStatus(entry);
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.
*/
private static boolean isLocationOk(ACPathEntry entry) {
// have to trust paths which contain variables
if (entry.getName().contains("${")) //$NON-NLS-1$
return true;
boolean exists = true;
boolean isWorkspacePath = (entry.getFlags() & ICSettingEntry.VALUE_WORKSPACE_PATH) != 0;
if (isWorkspacePath) {
IPath path = new Path(entry.getValue());
IResource rc = ResourcesPlugin.getWorkspace().getRoot().findMember(path);
exists = rc!=null && rc.isAccessible();
} else {
String pathname = entry.getName();
java.io.File file = new java.io.File(pathname);
exists = file.exists();
}
return exists;
}
/**
* Defines status object for the status message line.
*
* @param entry - the entry to check status on.
* @return a status object defining severity and message.
*/
public static IStatus getStatus(ICLanguageSettingEntry entry) {
if (entry instanceof ACPathEntry) {
if (!entry.isResolved()) {
ICLanguageSettingEntry[] entries = CDataUtil.resolveEntries(new ICLanguageSettingEntry[] {entry}, null);
if (entries != null && entries.length > 0) {
entry = entries[0];
}
}
ACPathEntry acEntry = (ACPathEntry)entry;
String acEntryName = acEntry.getName();
IPath path = new Path(acEntryName);
if (!path.isAbsolute()) {
String msg = "Using relative paths is ambiguous and not recommended. It can cause unexpected side-effects.";
return new Status(IStatus.INFO, CUIPlugin.PLUGIN_ID, msg);
}
if (!isLocationOk(acEntry)) {
String msg;
if (acEntry.isFile())
msg = "The selected file does not exist or not accessible.";
else
msg = "The selected folder does not exist or not accessible.";
return new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, msg);
}
}
return Status.OK_STATUS;
} }
/** /**
@ -167,17 +73,19 @@ public class LanguageSettingsImages {
switch (kind) { switch (kind) {
case ICSettingEntry.INCLUDE_PATH: case ICSettingEntry.INCLUDE_PATH:
if (isWorkspacePath) if (isWorkspacePath) {
if (isProjectRelative) if (isProjectRelative) {
imageKey = CDTSharedImages.IMG_OBJS_INCLUDES_FOLDER_PROJECT; imageKey = CDTSharedImages.IMG_OBJS_INCLUDES_FOLDER_PROJECT;
else } else {
imageKey = CDTSharedImages.IMG_OBJS_INCLUDES_FOLDER_WORKSPACE; imageKey = CDTSharedImages.IMG_OBJS_INCLUDES_FOLDER_WORKSPACE;
else if (isFramework) }
} else if (isFramework) {
imageKey = CDTSharedImages.IMG_OBJS_FRAMEWORKS_FOLDER; imageKey = CDTSharedImages.IMG_OBJS_FRAMEWORKS_FOLDER;
else if (isBuiltin) } else if (isBuiltin) {
imageKey = CDTSharedImages.IMG_OBJS_INCLUDES_FOLDER_SYSTEM; imageKey = CDTSharedImages.IMG_OBJS_INCLUDES_FOLDER_SYSTEM;
else } else {
imageKey = CDTSharedImages.IMG_OBJS_INCLUDES_FOLDER; imageKey = CDTSharedImages.IMG_OBJS_INCLUDES_FOLDER;
}
break; break;
case ICSettingEntry.INCLUDE_FILE: case ICSettingEntry.INCLUDE_FILE:
imageKey = CDTSharedImages.IMG_OBJS_TUNIT_HEADER; imageKey = CDTSharedImages.IMG_OBJS_TUNIT_HEADER;
@ -200,4 +108,101 @@ 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.
*/
public 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
*/
private static boolean isLocationOk(ACPathEntry entry) {
boolean exists = true;
boolean isWorkspacePath = (entry.getFlags() & ICSettingEntry.VALUE_WORKSPACE_PATH) != 0;
if (isWorkspacePath) {
IPath path = new Path(entry.getValue());
IResource rc = ResourcesPlugin.getWorkspace().getRoot().findMember(path);
exists = (rc !=null) && rc.isAccessible();
} else {
String pathname = entry.getName();
java.io.File file = new java.io.File(pathname);
exists = file.exists();
}
return exists;
}
/**
* Defines status object for the status message line.
*
* @param entry - the entry to check status on.
* @param cfgDescription - configuration description of the entry.
* @return a status object defining severity and message.
*/
public static IStatus getStatus(ICLanguageSettingEntry entry, ICConfigurationDescription cfgDescription) {
if (entry instanceof ACPathEntry) {
if (!entry.isResolved()) {
ICLanguageSettingEntry[] entries = CDataUtil.resolveEntries(new ICLanguageSettingEntry[] {entry}, cfgDescription);
if (entries != null && entries.length > 0) {
entry = entries[0];
}
}
ACPathEntry acEntry = (ACPathEntry)entry;
String acEntryName = acEntry.getName();
IPath path = new Path(acEntryName);
if (!path.isAbsolute()) {
return new Status(IStatus.INFO, CUIPlugin.PLUGIN_ID, Messages.LanguageSettingsImages_UsingRelativePathsNotRecommended);
}
if (!isLocationOk(acEntry)) {
if (acEntry.isFile()) {
return new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, Messages.LanguageSettingsImages_FileDoesNotExist);
} else {
return new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, Messages.LanguageSettingsImages_FolderDoesNotExist);
}
}
}
return Status.OK_STATUS;
}
} }

View file

@ -187,6 +187,9 @@ public class Messages extends NLS {
public static String IncludeTab_2; public static String IncludeTab_2;
public static String IncludeTab_export; public static String IncludeTab_export;
public static String IncludeTab_import; public static String IncludeTab_import;
public static String LanguageSettingsImages_FileDoesNotExist;
public static String LanguageSettingsImages_FolderDoesNotExist;
public static String LanguageSettingsImages_UsingRelativePathsNotRecommended;
public static String LanguageSettingsProviderTab_AreYouSureToResetProviders; public static String LanguageSettingsProviderTab_AreYouSureToResetProviders;
public static String LanguageSettingsProviderTab_Clear; public static String LanguageSettingsProviderTab_Clear;
public static String LanguageSettingsProviderTab_Configure; public static String LanguageSettingsProviderTab_Configure;

View file

@ -166,6 +166,9 @@ IncludeDialog_0=Directory:
IncludeDialog_1=File: IncludeDialog_1=File:
IncludeDialog_2=Add to all configurations IncludeDialog_2=Add to all configurations
IncludeDialog_3=Add to all languages IncludeDialog_3=Add to all languages
LanguageSettingsImages_FileDoesNotExist=The selected file does not exist or not accessible.
LanguageSettingsImages_FolderDoesNotExist=The selected folder does not exist or not accessible.
LanguageSettingsImages_UsingRelativePathsNotRecommended=Using relative paths is ambiguous and not recommended. It can cause unexpected effects.
LanguageSettingsProviderTab_AreYouSureToResetProviders=Are you sure you want to reset all customized language settings providers? LanguageSettingsProviderTab_AreYouSureToResetProviders=Are you sure you want to reset all customized language settings providers?
LanguageSettingsProviderTab_Clear=Clear Entries LanguageSettingsProviderTab_Clear=Clear Entries
LanguageSettingsProviderTab_Configure=Configure LanguageSettingsProviderTab_Configure=Configure

View file

@ -117,7 +117,7 @@ public class CDTSharedImages {
public static final String IMG_OBJS_QUOTE_INCLUDES_FOLDER = "icons/obj16/hfolder_quote_obj.gif"; //$NON-NLS-1$ public static final String IMG_OBJS_QUOTE_INCLUDES_FOLDER = "icons/obj16/hfolder_quote_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_INCLUDES_FOLDER_SYSTEM = "icons/obj16/fldr_sys_obj.gif"; //$NON-NLS-1$ public static final String IMG_OBJS_INCLUDES_FOLDER_SYSTEM = "icons/obj16/fldr_sys_obj.gif"; //$NON-NLS-1$
/** @since 5.4 */ /** @since 5.4 */
public static final String IMG_OBJS_FRAMEWORKS_FOLDER = "icons/obj16/frameworks.gif"; //$NON-NLS-1$ public static final String IMG_OBJS_FRAMEWORKS_FOLDER = "icons/obj16/frameworks.png"; //$NON-NLS-1$
public static final String IMG_OBJS_MACROS_FILE= "icons/obj16/macros_file.gif"; //$NON-NLS-1$ public static final String IMG_OBJS_MACROS_FILE= "icons/obj16/macros_file.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_LIBRARY_FOLDER= "icons/obj16/fldr_lib_obj.gif"; // $NON-NLS-1$ //$NON-NLS-1$ public static final String IMG_OBJS_LIBRARY_FOLDER= "icons/obj16/fldr_lib_obj.gif"; // $NON-NLS-1$ //$NON-NLS-1$
public static final String IMG_OBJS_ORDER = "icons/obj16/cp_order_obj.gif"; //$NON-NLS-1$ public static final String IMG_OBJS_ORDER = "icons/obj16/cp_order_obj.gif"; //$NON-NLS-1$

View file

@ -9,7 +9,7 @@
* Intel Corporation - initial API and implementation * Intel Corporation - initial API and implementation
* IBM Corporation * IBM Corporation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
* Andrew Gvozdev (Quoin Inc.) * Andrew Gvozdev
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.ui.newui; package org.eclipse.cdt.ui.newui;
@ -261,7 +261,7 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
* Multiline selection is not supported. * Multiline selection is not supported.
*/ */
private void updateStatusLine() { private void updateStatusLine() {
fStatusLine.setErrorStatus(LanguageSettingsImages.getStatus(getSelectedEntry())); fStatusLine.setErrorStatus(LanguageSettingsImages.getStatus(getSelectedEntry(), getResDesc().getConfiguration()));
} }
/** /**
@ -731,7 +731,7 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
if (columnIndex==0 && (element instanceof ICLanguageSettingEntry)) { if (columnIndex==0 && (element instanceof ICLanguageSettingEntry)) {
ICConfigurationDescription cfg = getResDesc().getConfiguration(); ICConfigurationDescription cfg = getResDesc().getConfiguration();
IProject project = cfg.getProjectDescription().getProject(); IProject project = cfg.getProjectDescription().getProject();
return LanguageSettingsImages.getImage((ICLanguageSettingEntry) element, project.getName()); return LanguageSettingsImages.getImage((ICLanguageSettingEntry) element, project.getName(), cfg);
} }
return null; return null;
} }