mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-30 21:55:31 +02:00
fixed the following bugs:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=66783 https://bugs.eclipse.org/bugs/show_bug.cgi?id=66021 https://bugs.eclipse.org/bugs/show_bug.cgi?id=66754
This commit is contained in:
parent
3a263d390d
commit
6f341e4ccb
7 changed files with 447 additions and 231 deletions
|
@ -25,7 +25,9 @@ import org.eclipse.cdt.ui.CUIPlugin;
|
|||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.resources.IWorkspaceRoot;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
|
||||
public class CPElement {
|
||||
|
||||
|
@ -49,13 +51,13 @@ public class CPElement {
|
|||
private final ArrayList fChildren = new ArrayList(1);
|
||||
|
||||
private boolean fIsExported;
|
||||
private boolean fIsMissing;
|
||||
|
||||
private IPathEntry fCachedEntry;
|
||||
private CPElement Inherited; // used when the path is duplicated on a child
|
||||
// resource but is inherited from a parent
|
||||
// resource
|
||||
// these are not real path entries
|
||||
// resource but is inherited from a parent
|
||||
// resource these are not real path entries
|
||||
|
||||
private IStatus fStatus;
|
||||
|
||||
// create a inherited element and apply to path/resource
|
||||
public CPElement(CPElement element, IPath path, IResource res) {
|
||||
|
@ -76,7 +78,6 @@ public class CPElement {
|
|||
fResource = res;
|
||||
|
||||
fIsExported = false;
|
||||
fIsMissing = false;
|
||||
fCachedEntry = null;
|
||||
|
||||
switch (entryKind) {
|
||||
|
@ -357,6 +358,7 @@ public class CPElement {
|
|||
|
||||
private void attributeChanged(String key) {
|
||||
fCachedEntry = null;
|
||||
fStatus = null;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -427,15 +429,91 @@ public class CPElement {
|
|||
*
|
||||
* @return Returns a boolean
|
||||
*/
|
||||
public boolean isMissing() {
|
||||
return fIsMissing;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the 'missing' state of the entry.
|
||||
*/
|
||||
public void setIsMissing(boolean isMissing) {
|
||||
fIsMissing = isMissing;
|
||||
public IStatus getStatus() {
|
||||
if (Inherited != null) {
|
||||
return Inherited.getStatus();
|
||||
}
|
||||
if (fStatus == null) {
|
||||
fStatus = Status.OK_STATUS;
|
||||
IResource res = null;
|
||||
IPath path;
|
||||
IWorkspaceRoot root = CUIPlugin.getWorkspace().getRoot();
|
||||
IPathEntry entry = getPathEntry();
|
||||
switch (getEntryKind()) {
|
||||
case IPathEntry.CDT_CONTAINER :
|
||||
try {
|
||||
if ((CoreModel.getPathEntryContainer(fPath, fCProject) == null)) {
|
||||
fStatus = new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, -1,
|
||||
CPathEntryMessages.getString("CPElement.status.pathContainerMissing"), null); //$NON-NLS-1$
|
||||
}
|
||||
} catch (CModelException e) {
|
||||
}
|
||||
break;
|
||||
case IPathEntry.CDT_LIBRARY :
|
||||
if (!((ILibraryEntry)entry).getFullLibraryPath().toFile().exists()) {
|
||||
fStatus = new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, -1, CPathEntryMessages.getString("CPElement.status.libraryPathNotFound"), null); //$NON-NLS-1$
|
||||
}
|
||||
break;
|
||||
case IPathEntry.CDT_SOURCE :
|
||||
path = fPath.removeTrailingSeparator();
|
||||
res = root.findMember(path);
|
||||
if (res == null) {
|
||||
if (root.getWorkspace().validatePath(path.toString(), IResource.FOLDER).isOK()) {
|
||||
res = root.getFolder(path);
|
||||
}
|
||||
fStatus = new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, -1, CPathEntryMessages.getString("CPElement.status.sourcePathMissing"), null); //$NON-NLS-1$
|
||||
}
|
||||
break;
|
||||
case IPathEntry.CDT_OUTPUT :
|
||||
path = fPath.removeTrailingSeparator();
|
||||
res = root.findMember(path);
|
||||
if (res == null) {
|
||||
if (root.getWorkspace().validatePath(path.toString(), IResource.FOLDER).isOK()) {
|
||||
res = root.getFolder(path);
|
||||
}
|
||||
fStatus = new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, -1, CPathEntryMessages.getString("CPElement.status.outputPathMissing"), null); //$NON-NLS-1$
|
||||
}
|
||||
break;
|
||||
case IPathEntry.CDT_INCLUDE :
|
||||
path = fPath.removeTrailingSeparator();
|
||||
res = root.findMember(path);
|
||||
if (res == null) {
|
||||
if (root.getWorkspace().validatePath(path.toString(), IResource.FOLDER).isOK()) {
|
||||
res = root.getFolder(path);
|
||||
}
|
||||
}
|
||||
if (res.getType() != IResource.ROOT && res.getType() != IResource.PROJECT && fCProject != null) {
|
||||
if (!fCProject.isOnSourceRoot(res)) {
|
||||
fStatus = new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, -1, CPathEntryMessages.getString("CPElement.status.notOnSourcePath"), null); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
if (!((IIncludeEntry)entry).getFullIncludePath().toFile().exists()) {
|
||||
fStatus = new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, -1, CPathEntryMessages.getString("CPElement.status.includePathNotFound"), null); //$NON-NLS-1$
|
||||
}
|
||||
break;
|
||||
case IPathEntry.CDT_MACRO :
|
||||
path = fPath.removeTrailingSeparator();
|
||||
res = root.findMember(path);
|
||||
if (res == null) {
|
||||
if (root.getWorkspace().validatePath(path.toString(), IResource.FOLDER).isOK()) {
|
||||
res = root.getFolder(path);
|
||||
}
|
||||
}
|
||||
if (res.getType() != IResource.ROOT && res.getType() != IResource.PROJECT && fCProject != null) {
|
||||
if (!fCProject.isOnSourceRoot(res)) {
|
||||
fStatus = new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, -1, CPathEntryMessages.getString("CPElement.status.notOnSourcePath"), null); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
break;
|
||||
case IPathEntry.CDT_PROJECT :
|
||||
res = root.findMember(fPath);
|
||||
if (res == null) {
|
||||
fStatus = new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, -1, CPathEntryMessages.getString("CPElement.status.missingProjectPath"), null); //$NON-NLS-1$
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return fStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -486,26 +564,12 @@ public class CPElement {
|
|||
|
||||
// get the resource
|
||||
IResource res = null;
|
||||
boolean isMissing = false;
|
||||
|
||||
switch (curr.getEntryKind()) {
|
||||
case IPathEntry.CDT_CONTAINER :
|
||||
res = null;
|
||||
try {
|
||||
isMissing = (CoreModel.getPathEntryContainer(path, project) == null);
|
||||
} catch (CModelException e) {
|
||||
}
|
||||
break;
|
||||
case IPathEntry.CDT_LIBRARY :
|
||||
res = root.findMember(path);
|
||||
if (res == null) {
|
||||
// if (!ArchiveFileFilter.isArchivePath(path)) {
|
||||
if (root.getWorkspace().validatePath(path.toString(), IResource.FOLDER).isOK()
|
||||
&& root.getProject(path.segment(0)).exists()) {
|
||||
res = root.getFolder(path);
|
||||
}
|
||||
isMissing = !path.toFile().isFile(); // look for external
|
||||
}
|
||||
library = ((ILibraryEntry)curr).getLibraryPath();
|
||||
sourceAttachment = ((ILibraryEntry)curr).getSourceAttachmentPath();
|
||||
base = ((ILibraryEntry)curr).getBasePath();
|
||||
|
@ -518,7 +582,6 @@ public class CPElement {
|
|||
if (root.getWorkspace().validatePath(path.toString(), IResource.FOLDER).isOK()) {
|
||||
res = root.getFolder(path);
|
||||
}
|
||||
isMissing = true;
|
||||
}
|
||||
exclusion = ((ISourceEntry)curr).getExclusionPatterns();
|
||||
break;
|
||||
|
@ -529,7 +592,6 @@ public class CPElement {
|
|||
if (root.getWorkspace().validatePath(path.toString(), IResource.FOLDER).isOK()) {
|
||||
res = root.getFolder(path);
|
||||
}
|
||||
isMissing = true;
|
||||
}
|
||||
exclusion = ((IOutputEntry)curr).getExclusionPatterns();
|
||||
break;
|
||||
|
@ -541,9 +603,6 @@ public class CPElement {
|
|||
res = root.getFolder(path);
|
||||
}
|
||||
}
|
||||
if (res.getType() != IResource.ROOT && project != null) {
|
||||
isMissing = !project.isOnSourceRoot(res);
|
||||
}
|
||||
exclusion = ((IIncludeEntry)curr).getExclusionPatterns();
|
||||
sysInclude = ((IIncludeEntry)curr).isSystemInclude();
|
||||
baseRef = ((IIncludeEntry)curr).getBaseReference();
|
||||
|
@ -558,9 +617,6 @@ public class CPElement {
|
|||
res = root.getFolder(path);
|
||||
}
|
||||
}
|
||||
if (res.getType() != IResource.ROOT && project != null) {
|
||||
isMissing = !project.isOnSourceRoot(res);
|
||||
}
|
||||
exclusion = ((IMacroEntry)curr).getExclusionPatterns();
|
||||
macroName = ((IMacroEntry)curr).getMacroName();
|
||||
macroValue = ((IMacroEntry)curr).getMacroValue();
|
||||
|
@ -569,7 +625,6 @@ public class CPElement {
|
|||
break;
|
||||
case IPathEntry.CDT_PROJECT :
|
||||
res = root.findMember(path);
|
||||
isMissing = (res == null);
|
||||
break;
|
||||
}
|
||||
CPElement elem = new CPElement(project, curr.getEntryKind(), path, res);
|
||||
|
@ -583,10 +638,6 @@ public class CPElement {
|
|||
elem.setAttribute(BASE_REF, baseRef);
|
||||
elem.setAttribute(BASE, base);
|
||||
elem.setExported(curr.isExported());
|
||||
|
||||
if (project != null && project.exists()) {
|
||||
elem.setIsMissing(isMissing);
|
||||
}
|
||||
return elem;
|
||||
}
|
||||
}
|
|
@ -10,7 +10,11 @@ package org.eclipse.cdt.internal.ui.dialogs.cpaths;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
|
@ -20,17 +24,19 @@ public class CPElementGroup {
|
|||
private CPElement parent;
|
||||
private final int kind;
|
||||
private IResource resource;
|
||||
private List children = new ArrayList(1);
|
||||
private Map childrenListMap;
|
||||
private List childrenList;
|
||||
|
||||
public CPElementGroup(IResource resource) {
|
||||
this.kind = -1;
|
||||
this.resource = resource;
|
||||
this.children = new ArrayList();
|
||||
this.childrenListMap = new HashMap(2);
|
||||
}
|
||||
|
||||
public CPElementGroup(CPElement parent, int kind) {
|
||||
this.parent = parent;
|
||||
this.kind = kind;
|
||||
this.childrenList = new ArrayList();
|
||||
}
|
||||
|
||||
public IResource getResource() {
|
||||
|
@ -66,14 +72,36 @@ public class CPElementGroup {
|
|||
return hashCode + kind;
|
||||
}
|
||||
|
||||
public int indexof(CPElement element) {
|
||||
List children = getChildrenList(element.getEntryKind(), false);
|
||||
return children != null ? children.indexOf(element) : -1;
|
||||
}
|
||||
|
||||
public void addChild(CPElement element, int insertIndex) {
|
||||
List children = getChildrenList(element.getEntryKind(), true);
|
||||
children.add(insertIndex, element);
|
||||
element.setParent(this);
|
||||
}
|
||||
|
||||
public void addChild(CPElement element) {
|
||||
List children = getChildrenList(element.getEntryKind(), true);
|
||||
int indx = children.indexOf(element);
|
||||
if (indx == -1) {
|
||||
children.add(element);
|
||||
indx = children.size();
|
||||
if (element.getInherited() == null) {
|
||||
for (int i = 0; i < children.size(); i++) {
|
||||
CPElement next = (CPElement)children.get(i);
|
||||
if (next.getInherited() != null) {
|
||||
indx = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
children.add(indx, element);
|
||||
element.setParent(this);
|
||||
} else { // add element with closes matching resource path.
|
||||
} else { // add element with closes matching resource path.
|
||||
CPElement other = (CPElement)children.get(indx);
|
||||
if ( other.getInherited() != null && element.getInherited() != null) {
|
||||
if (other.getInherited() != null && element.getInherited() != null) {
|
||||
IPath otherPath = other.getInherited().getPath();
|
||||
IPath elemPath = element.getInherited().getPath();
|
||||
if (!otherPath.equals(elemPath) && otherPath.isPrefixOf(elemPath)) {
|
||||
|
@ -87,7 +115,13 @@ public class CPElementGroup {
|
|||
}
|
||||
|
||||
public void setChildren(CPElement[] elements) {
|
||||
children = new ArrayList(Arrays.asList(elements));
|
||||
if (elements.length > 0) {
|
||||
if (childrenListMap != null) {
|
||||
childrenListMap.put(new Integer(elements[0].getEntryKind()), new ArrayList(Arrays.asList(elements)));
|
||||
} else {
|
||||
childrenList = new ArrayList(Arrays.asList(elements));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void addChildren(CPElement[] elements) {
|
||||
|
@ -97,6 +131,10 @@ public class CPElementGroup {
|
|||
}
|
||||
|
||||
public boolean removeChild(CPElement element) {
|
||||
List children = getChildrenList(element.getEntryKind(), false);
|
||||
if (children == null) {
|
||||
return false;
|
||||
}
|
||||
boolean removed = children.remove(element);
|
||||
if (removed) {
|
||||
element.setParent(null);
|
||||
|
@ -104,19 +142,42 @@ public class CPElementGroup {
|
|||
return removed;
|
||||
}
|
||||
|
||||
public CPElement[] getChildren() {
|
||||
public CPElement[] getChildren(int kind) {
|
||||
List children = getChildrenList(kind, true);
|
||||
return (CPElement[])children.toArray(new CPElement[children.size()]);
|
||||
}
|
||||
|
||||
public CPElement[] getChildren() {
|
||||
if (childrenList != null) {
|
||||
return (CPElement[])childrenList.toArray(new CPElement[childrenList.size()]);
|
||||
} else {
|
||||
Collection lists = childrenListMap.values();
|
||||
Iterator iter = lists.iterator();
|
||||
List children = new ArrayList();
|
||||
while (iter.hasNext()) {
|
||||
children.addAll((List)iter.next());
|
||||
}
|
||||
return (CPElement[])children.toArray(new CPElement[children.size()]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param newPath
|
||||
* @return
|
||||
*/
|
||||
public boolean contains(CPElement newPath) {
|
||||
return children.contains(newPath);
|
||||
public boolean contains(CPElement element) {
|
||||
List children = getChildrenList(element.getEntryKind(), false);
|
||||
if (children == null) {
|
||||
return false;
|
||||
}
|
||||
return children.contains(element);
|
||||
}
|
||||
|
||||
public void replaceChild(CPElement element, CPElement replaceWith) {
|
||||
List children = getChildrenList(element.getEntryKind(), false);
|
||||
if (children == null) {
|
||||
return;
|
||||
}
|
||||
int idx = children.indexOf(element);
|
||||
if (idx != -1) {
|
||||
children.remove(idx);
|
||||
|
@ -124,4 +185,17 @@ public class CPElementGroup {
|
|||
}
|
||||
}
|
||||
|
||||
private List getChildrenList(int kind, boolean create) {
|
||||
List children = null;
|
||||
if (childrenList != null) {
|
||||
children = childrenList;
|
||||
} else {
|
||||
children = (List)childrenListMap.get(new Integer(kind));
|
||||
if (children == null && create) {
|
||||
children = new ArrayList();
|
||||
childrenListMap.put(new Integer(kind), children);
|
||||
}
|
||||
}
|
||||
return children;
|
||||
}
|
||||
}
|
|
@ -18,6 +18,7 @@ import org.eclipse.cdt.internal.ui.util.ImageDescriptorRegistry;
|
|||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.jface.resource.ImageDescriptor;
|
||||
import org.eclipse.jface.viewers.IColorProvider;
|
||||
import org.eclipse.jface.viewers.LabelProvider;
|
||||
|
@ -87,7 +88,7 @@ class CPElementLabelProvider extends LabelProvider implements IColorProvider {
|
|||
return CPathEntryMessages.getString("CPElementLabelProvider.PreprocessorSymbols"); //$NON-NLS-1$
|
||||
case IPathEntry.CDT_LIBRARY :
|
||||
return CPathEntryMessages.getString("CPElementLabelProvider.Libraries"); //$NON-NLS-1$
|
||||
case -1:
|
||||
case -1 :
|
||||
if (group.getResource().getType() == IResource.PROJECT) {
|
||||
return group.getResource().getName();
|
||||
}
|
||||
|
@ -137,64 +138,59 @@ class CPElementLabelProvider extends LabelProvider implements IColorProvider {
|
|||
public String getCPElementText(CPElement cpentry) {
|
||||
IPath path = cpentry.getPath();
|
||||
switch (cpentry.getEntryKind()) {
|
||||
case IPathEntry.CDT_LIBRARY :
|
||||
{
|
||||
IPath libPath = (IPath)cpentry.getAttribute(CPElement.LIBRARY);
|
||||
StringBuffer str = new StringBuffer();
|
||||
addBaseString(libPath, cpentry, str);
|
||||
addExport(cpentry, str);
|
||||
addParentInfo(cpentry, str);
|
||||
return str.toString();
|
||||
}
|
||||
case IPathEntry.CDT_LIBRARY : {
|
||||
IPath libPath = (IPath)cpentry.getAttribute(CPElement.LIBRARY);
|
||||
StringBuffer str = new StringBuffer();
|
||||
addBaseString(libPath, cpentry, str);
|
||||
addExport(cpentry, str);
|
||||
addParentInfo(cpentry, str);
|
||||
return str.toString();
|
||||
}
|
||||
case IPathEntry.CDT_PROJECT :
|
||||
return path.lastSegment();
|
||||
case IPathEntry.CDT_INCLUDE :
|
||||
{
|
||||
IPath incPath = ((IPath)cpentry.getAttribute(CPElement.INCLUDE));
|
||||
StringBuffer str = new StringBuffer();
|
||||
addBaseString(incPath, cpentry, str);
|
||||
addExport(cpentry, str);
|
||||
addParentInfo(cpentry, str);
|
||||
return str.toString();
|
||||
}
|
||||
case IPathEntry.CDT_MACRO :
|
||||
{
|
||||
StringBuffer str = new StringBuffer((String)cpentry.getAttribute(CPElement.MACRO_NAME) + "=" //$NON-NLS-1$
|
||||
+ (String)cpentry.getAttribute(CPElement.MACRO_VALUE));
|
||||
addBaseString(null, cpentry, str);
|
||||
addExport(cpentry, str);
|
||||
addParentInfo(cpentry, str);
|
||||
return str.toString();
|
||||
}
|
||||
case IPathEntry.CDT_CONTAINER :
|
||||
{
|
||||
StringBuffer str = new StringBuffer(path.toString());
|
||||
try {
|
||||
IPathEntryContainer container = CoreModel.getPathEntryContainer(cpentry.getPath(), cpentry.getCProject());
|
||||
if (container != null) {
|
||||
str.setLength(0);
|
||||
str.append(container.getDescription());
|
||||
}
|
||||
} catch (CModelException e) {
|
||||
case IPathEntry.CDT_INCLUDE : {
|
||||
IPath incPath = ((IPath)cpentry.getAttribute(CPElement.INCLUDE));
|
||||
StringBuffer str = new StringBuffer();
|
||||
addBaseString(incPath, cpentry, str);
|
||||
addExport(cpentry, str);
|
||||
addParentInfo(cpentry, str);
|
||||
return str.toString();
|
||||
}
|
||||
case IPathEntry.CDT_MACRO : {
|
||||
StringBuffer str = new StringBuffer((String)cpentry.getAttribute(CPElement.MACRO_NAME) + "=" //$NON-NLS-1$
|
||||
+ (String)cpentry.getAttribute(CPElement.MACRO_VALUE));
|
||||
addBaseString(null, cpentry, str);
|
||||
addExport(cpentry, str);
|
||||
addParentInfo(cpentry, str);
|
||||
return str.toString();
|
||||
}
|
||||
case IPathEntry.CDT_CONTAINER : {
|
||||
StringBuffer str = new StringBuffer(path.toString());
|
||||
try {
|
||||
IPathEntryContainer container = CoreModel.getPathEntryContainer(cpentry.getPath(), cpentry.getCProject());
|
||||
if (container != null) {
|
||||
str.setLength(0);
|
||||
str.append(container.getDescription());
|
||||
}
|
||||
addExport(cpentry, str);
|
||||
return str.toString();
|
||||
} catch (CModelException e) {
|
||||
}
|
||||
addExport(cpentry, str);
|
||||
return str.toString();
|
||||
}
|
||||
case IPathEntry.CDT_SOURCE :
|
||||
case IPathEntry.CDT_OUTPUT :
|
||||
{
|
||||
StringBuffer buf = new StringBuffer(path.makeRelative().toString());
|
||||
IResource resource = cpentry.getResource();
|
||||
if (resource != null && !resource.exists()) {
|
||||
buf.append(' ');
|
||||
if (cpentry.isMissing()) {
|
||||
buf.append(fCreateLabel);
|
||||
} else {
|
||||
buf.append(fNewLabel);
|
||||
}
|
||||
case IPathEntry.CDT_OUTPUT : {
|
||||
StringBuffer buf = new StringBuffer(path.makeRelative().toString());
|
||||
IResource resource = cpentry.getResource();
|
||||
if (resource != null && !resource.exists()) {
|
||||
buf.append(' ');
|
||||
if (cpentry.getStatus().getSeverity() != IStatus.OK) { // only valid error for src/output would missing path...
|
||||
buf.append(fCreateLabel);
|
||||
} else {
|
||||
buf.append(fNewLabel);
|
||||
}
|
||||
return buf.toString();
|
||||
}
|
||||
return buf.toString();
|
||||
}
|
||||
default :
|
||||
// pass
|
||||
}
|
||||
|
@ -321,8 +317,13 @@ class CPElementLabelProvider extends LabelProvider implements IColorProvider {
|
|||
CPElement cpentry = (CPElement)element;
|
||||
ImageDescriptor imageDescriptor = getCPElementBaseImage(cpentry);
|
||||
if (imageDescriptor != null) {
|
||||
if (cpentry.isMissing()) {
|
||||
imageDescriptor = new CPListImageDescriptor(imageDescriptor, CPListImageDescriptor.WARNING, SMALL_SIZE);
|
||||
switch (cpentry.getStatus().getSeverity()) {
|
||||
case IStatus.WARNING :
|
||||
imageDescriptor = new CPListImageDescriptor(imageDescriptor, CPListImageDescriptor.WARNING, SMALL_SIZE);
|
||||
break;
|
||||
case IStatus.ERROR :
|
||||
imageDescriptor = new CPListImageDescriptor(imageDescriptor, CPListImageDescriptor.ERROR, SMALL_SIZE);
|
||||
break;
|
||||
}
|
||||
if (cpentry.getInherited() != null) {
|
||||
imageDescriptor = new CPListImageDescriptor(imageDescriptor, CPListImageDescriptor.PATH_INHERIT, SMALL_SIZE);
|
||||
|
@ -346,26 +347,30 @@ class CPElementLabelProvider extends LabelProvider implements IColorProvider {
|
|||
return fRegistry.get(fMacroIcon);
|
||||
case IPathEntry.CDT_LIBRARY :
|
||||
return CPluginImages.get(CPluginImages.IMG_OBJS_LIBRARY);
|
||||
case -1:
|
||||
return fCImages.getImageLabel(((CPElementGroup)element).getResource(), CElementImageProvider.SMALL_ICONS);
|
||||
case -1 :
|
||||
return fCImages.getImageLabel( ((CPElementGroup)element).getResource(), CElementImageProvider.SMALL_ICONS);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.jface.viewers.IColorProvider#getForeground(java.lang.Object)
|
||||
*/
|
||||
public Color getForeground(Object element) {
|
||||
if (element instanceof CPElement) {
|
||||
if (((CPElement)element).getInherited() != null) {
|
||||
if ( ((CPElement)element).getInherited() != null) {
|
||||
return inDirect;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.jface.viewers.IColorProvider#getBackground(java.lang.Object)
|
||||
*/
|
||||
public Color getBackground(Object element) {
|
||||
|
|
|
@ -98,10 +98,17 @@ CPathsBlock.path.up.button=&Up
|
|||
CPathsBlock.path.down.button=&Down
|
||||
CPathsBlock.path.checkall.button=Select &All
|
||||
CPathsBlock.path.uncheckall.button=D&eselect All
|
||||
CPathsBlock.warning.EntryMissing=Build path entry is missing: {0}
|
||||
CPathsBlock.warning.EntriesMissing={0} project path entries are missing.
|
||||
CPathsBlock.operationdesc_c=Setting project paths...
|
||||
|
||||
CPElement.status.multiplePathErrors={0} project path entries have errors.
|
||||
CPElement.status.pathContainerMissing=Missing project path container.
|
||||
CPElement.status.libraryPathNotFound=Library not found.
|
||||
CPElement.status.sourcePathMissing=Source path does not exist.
|
||||
CPElement.status.outputPathMissing=Output path does not exist.
|
||||
CPElement.status.notOnSourcePath=Project path must exist on source path.
|
||||
CPElement.status.includePathNotFound=Include path not found.
|
||||
CPElement.status.missingProjectPath=Missing project path.
|
||||
|
||||
# ------- SourcePathEntryPage-------
|
||||
SourcePathEntryPage.title=&Source
|
||||
SourcePathEntryPage.description=Source Path for project
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
package org.eclipse.cdt.internal.ui.dialogs.cpaths;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -54,6 +54,7 @@ import org.eclipse.swt.events.KeyEvent;
|
|||
import org.eclipse.swt.events.SelectionAdapter;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
import org.eclipse.swt.graphics.Image;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.DirectoryDialog;
|
||||
|
@ -96,8 +97,8 @@ public class CPathIncludeSymbolEntryPage extends CPathBasePage {
|
|||
null,
|
||||
/* 12 */CPathEntryMessages.getString("IncludeSymbolEntryPage.export"), //$NON-NLS-1$
|
||||
null,
|
||||
/* 14 */CPathEntryMessages.getString("IncludeSymbolEntryPage.down"), //$NON-NLS-1$
|
||||
/* 15 */CPathEntryMessages.getString("IncludeSymbolEntryPage.up")}; //$NON-NLS-1$
|
||||
/* 14 */CPathEntryMessages.getString("IncludeSymbolEntryPage.up"), //$NON-NLS-1$
|
||||
/* 15 */CPathEntryMessages.getString("IncludeSymbolEntryPage.down")}; //$NON-NLS-1$
|
||||
private CPElementGroup fProjectGroup;
|
||||
|
||||
private class IncludeSymbolAdapter implements IDialogFieldListener, ITreeListAdapter {
|
||||
|
@ -110,7 +111,7 @@ public class CPathIncludeSymbolEntryPage extends CPathBasePage {
|
|||
}
|
||||
|
||||
public void selectionChanged(TreeListDialogField field) {
|
||||
ListPageSelectionChanged(field);
|
||||
listPageSelectionChanged(field);
|
||||
}
|
||||
|
||||
public void doubleClicked(TreeListDialogField field) {
|
||||
|
@ -152,8 +153,7 @@ public class CPathIncludeSymbolEntryPage extends CPathBasePage {
|
|||
// ---------- IDialogFieldListener --------
|
||||
|
||||
public void dialogFieldChanged(DialogField field) {
|
||||
ListPageDialogFieldChanged(field);
|
||||
|
||||
listPageDialogFieldChanged(field);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -192,6 +192,7 @@ public class CPathIncludeSymbolEntryPage extends CPathBasePage {
|
|||
PixelConverter converter = new PixelConverter(parent);
|
||||
|
||||
Composite composite = new Composite(parent, SWT.NONE);
|
||||
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
|
||||
|
||||
LayoutUtil.doDefaultLayout(composite, new DialogField[]{fIncludeSymPathsList, fShowInheritedPaths}, true);
|
||||
LayoutUtil.setHorizontalGrabbing(fIncludeSymPathsList.getTreeControl(null));
|
||||
|
@ -200,7 +201,6 @@ public class CPathIncludeSymbolEntryPage extends CPathBasePage {
|
|||
fIncludeSymPathsList.setButtonsMinWidth(buttonBarWidth);
|
||||
setControl(composite);
|
||||
fIncludeSymPathsList.getTreeViewer().addFilter(fFilter);
|
||||
fIncludeSymPathsList.getTreeViewer().setSorter(new CPElementSorter());
|
||||
}
|
||||
|
||||
public Image getImage() {
|
||||
|
@ -211,37 +211,55 @@ public class CPathIncludeSymbolEntryPage extends CPathBasePage {
|
|||
fCurrCProject = cproject;
|
||||
List elements = createGroups(cPaths);
|
||||
fIncludeSymPathsList.setElements(elements);
|
||||
updateStatus();
|
||||
}
|
||||
|
||||
private void updateStatus() {
|
||||
CPElement entryMissing = null;
|
||||
int nEntriesMissing = 0;
|
||||
CPElement entryError = null;
|
||||
int nErrorEntries = 0;
|
||||
IStatus status = Status.OK_STATUS;
|
||||
List elements = getCPaths();
|
||||
for (int i = elements.size() - 1; i >= 0; i--) {
|
||||
CPElement currElement = (CPElement)elements.get(i);
|
||||
if (currElement.isMissing()) {
|
||||
nEntriesMissing++;
|
||||
if (entryMissing == null) {
|
||||
entryMissing = currElement;
|
||||
if (currElement.getStatus().getSeverity() != IStatus.OK) {
|
||||
nErrorEntries++;
|
||||
if (entryError == null) {
|
||||
entryError = currElement;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (nEntriesMissing > 0) {
|
||||
if (nEntriesMissing == 1) {
|
||||
status = new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, -1, CPathEntryMessages.getFormattedString(
|
||||
"CPathsBlock.warning.EntryMissing", //$NON-NLS-1$
|
||||
entryMissing.getPath().toString()), null);
|
||||
if (nErrorEntries > 0) {
|
||||
if (nErrorEntries == 1) {
|
||||
status = entryError.getStatus();
|
||||
} else {
|
||||
status = new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, -1, CPathEntryMessages.getFormattedString(
|
||||
"CPathsBlock.warning.EntriesMissing", //$NON-NLS-1$
|
||||
String.valueOf(nEntriesMissing)), null);
|
||||
"CPElement.status.multiplePathErrors", //$NON-NLS-1$
|
||||
String.valueOf(nErrorEntries)), null);
|
||||
}
|
||||
}
|
||||
fContext.statusChanged(status);
|
||||
}
|
||||
|
||||
private void updateStatus(List selected) {
|
||||
if (selected.size() != 1) {
|
||||
updateStatus();
|
||||
return;
|
||||
}
|
||||
CPElement element = null;
|
||||
if (selected.get(0) instanceof CPElement) {
|
||||
element = (CPElement)selected.get(0);
|
||||
} else if (selected.get(0) instanceof CPElementAttribute) {
|
||||
element = ((CPElementAttribute)selected.get(0)).getParent();
|
||||
}
|
||||
if (element != null && element.getStatus().getSeverity() != IStatus.OK) {
|
||||
fContext.statusChanged(element.getStatus());
|
||||
} else {
|
||||
updateStatus();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private List createGroups(List cPaths) {
|
||||
// create resource groups
|
||||
List resourceGroups = new ArrayList(5);
|
||||
|
@ -286,7 +304,25 @@ public class CPathIncludeSymbolEntryPage extends CPathBasePage {
|
|||
&& resPath.isPrefixOf(group.getPath())
|
||||
&& (resPath.equals(group.getPath()) || !CoreModelUtil.isExcludedPath(
|
||||
group.getResource().getFullPath().removeFirstSegments(resPath.segmentCount()), exclusions))) {
|
||||
group.addChild(new CPElement(element, group.getPath(), group.getResource()));
|
||||
if (parent != null) { // try to insert at proper place in group...
|
||||
int insertHere = -1;
|
||||
int ndx = parent.indexof(element);
|
||||
if (ndx != -1) {
|
||||
CPElement[] children = parent.getChildren(element.getEntryKind());
|
||||
for (int i = ndx; i < children.length; i++) {
|
||||
insertHere = group.indexof(new CPElement(children[i], group.getPath(), group.getResource()));
|
||||
if (insertHere != -1) {
|
||||
group.addChild(new CPElement(element, group.getPath(), group.getResource()), insertHere);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (insertHere == -1) {
|
||||
group.addChild(new CPElement(element, group.getPath(), group.getResource()));
|
||||
}
|
||||
} else {
|
||||
group.addChild(new CPElement(element, group.getPath(), group.getResource()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -308,11 +344,12 @@ public class CPathIncludeSymbolEntryPage extends CPathBasePage {
|
|||
CPElementGroup group = (CPElementGroup)groups.get(i);
|
||||
if (group != parent) {
|
||||
boolean found = false;
|
||||
CPElement[] elements = group.getChildren();
|
||||
CPElement[] elements = group.getChildren(element.getEntryKind());
|
||||
for (int j = 0; j < elements.length; j++) {
|
||||
if (elements[j].getInherited() == element) {
|
||||
found = true;
|
||||
if (!CoreModelUtil.isExcludedPath(group.getResource().getFullPath().removeFirstSegments(resPath.segmentCount()), exclusions)) {
|
||||
if (!CoreModelUtil.isExcludedPath(group.getResource().getFullPath().removeFirstSegments(
|
||||
resPath.segmentCount()), exclusions)) {
|
||||
group.replaceChild(elements[j], new CPElement(element, group.getPath(), group.getResource()));
|
||||
} else {
|
||||
group.removeChild(elements[j]);
|
||||
|
@ -343,7 +380,7 @@ public class CPathIncludeSymbolEntryPage extends CPathBasePage {
|
|||
// remove all inherited
|
||||
for (int i = 0; i < groups.size(); i++) {
|
||||
CPElementGroup group = (CPElementGroup)groups.get(i);
|
||||
CPElement elements[] = group.getChildren();
|
||||
CPElement elements[] = group.getChildren(element.getEntryKind());
|
||||
for (int j = 0; j < elements.length; j++) {
|
||||
if (elements[j].getInherited() == element) {
|
||||
group.removeChild(elements[j]);
|
||||
|
@ -387,10 +424,13 @@ public class CPathIncludeSymbolEntryPage extends CPathBasePage {
|
|||
List selected = getSelection();
|
||||
Object elem = selected.get(0);
|
||||
if (elem instanceof CPElement) {
|
||||
if (removePathFromResourceGroups((CPElement)elem, fIncludeSymPathsList.getElements()) == null) {
|
||||
updatePathOnResourceGroups(((CPElement)elem).getInherited(), fIncludeSymPathsList.getElements());
|
||||
CPElement element = (CPElement)elem;
|
||||
CPElementGroup parent = element.getParent();
|
||||
if (removePathFromResourceGroups(element, fIncludeSymPathsList.getElements()) == null) {
|
||||
updatePathOnResourceGroups( element.getInherited(), fIncludeSymPathsList.getElements());
|
||||
}
|
||||
fIncludeSymPathsList.refresh();
|
||||
fIncludeSymPathsList.selectElements(new StructuredSelection(parent));
|
||||
} else if (elem instanceof CPElementAttribute) {
|
||||
CPElementAttribute attrib = (CPElementAttribute)elem;
|
||||
String key = attrib.getKey();
|
||||
|
@ -505,38 +545,76 @@ public class CPathIncludeSymbolEntryPage extends CPathBasePage {
|
|||
return false;
|
||||
}
|
||||
|
||||
private boolean canMoveUp(List element) {
|
||||
return false;
|
||||
private boolean canMove(List selected) {
|
||||
for (int i = 0; i < selected.size(); i++) {
|
||||
Object element = selected.get(i);
|
||||
if (! (element instanceof CPElement))
|
||||
return false;
|
||||
CPElement elem = (CPElement)element;
|
||||
if (elem.getEntryKind() != IPathEntry.CDT_INCLUDE && elem.getEntryKind() != IPathEntry.CDT_MACRO) {
|
||||
return false;
|
||||
}
|
||||
if (elem.getParentContainer() != null || elem.getInherited() != null) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean canMoveDown(List element) {
|
||||
return false;
|
||||
private boolean canMoveUp(List selected) {
|
||||
if (!canMove(selected)) {
|
||||
return false;
|
||||
}
|
||||
CPElement first = (CPElement)selected.get(0);
|
||||
CPElementGroup parent = first.getParent();
|
||||
CPElement children[] = parent.getChildren(first.getEntryKind());
|
||||
int indx = Arrays.asList(children).indexOf(first);
|
||||
if (indx <= 0) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean moveUp() {
|
||||
private boolean canMoveDown(List selected) {
|
||||
if (!canMove(selected)) {
|
||||
return false;
|
||||
}
|
||||
CPElement last = (CPElement)selected.get(selected.size() - 1);
|
||||
CPElementGroup parent = last.getParent();
|
||||
CPElement children[] = parent.getChildren(last.getEntryKind());
|
||||
int indx = Arrays.asList(children).indexOf(last);
|
||||
if (indx >= children.length - 1 || children[indx + 1].getInherited() != null) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean moveUp(CPElement element) {
|
||||
boolean rc = false;
|
||||
List selElements = fIncludeSymPathsList.getSelectedElements();
|
||||
for (Iterator i = selElements.iterator(); i.hasNext();) {
|
||||
CPElement elem = (CPElement)i.next();
|
||||
CPElementGroup parent = elem.getParent();
|
||||
CPElement[] children = parent.getChildren();
|
||||
for (int j = 0; j < children.length; ++j) {
|
||||
CPElement child = children[j];
|
||||
if (elem.equals(child)) {
|
||||
int prevIndex = j - 1;
|
||||
int kind = element.getEntryKind();
|
||||
for (Iterator j = fIncludeSymPathsList.getElements().iterator(); j.hasNext();) {
|
||||
CPElementGroup group = (CPElementGroup)j.next();
|
||||
CPElement[] children = group.getChildren(kind);
|
||||
for (int k = 0; k < children.length; ++k) {
|
||||
CPElement child = children[k];
|
||||
if (element.equals(child) || (child.getInherited() != null && child.getInherited().equals(element))) {
|
||||
if (child.getInherited() != null && k > 0 && children[k - 1].getInherited() == null) {
|
||||
break;
|
||||
}
|
||||
int prevIndex = k - 1;
|
||||
if (prevIndex >= 0) {
|
||||
// swap the two
|
||||
children[j] = children[prevIndex];
|
||||
children[prevIndex] = elem;
|
||||
children[k] = children[prevIndex];
|
||||
children[prevIndex] = child;
|
||||
rc = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
parent.setChildren(children);
|
||||
group.setChildren(children);
|
||||
}
|
||||
fIncludeSymPathsList.refresh();
|
||||
fIncludeSymPathsList.postSetSelection(new StructuredSelection(selElements));
|
||||
fIncludeSymPathsList.selectElements(new StructuredSelection(element));
|
||||
fIncludeSymPathsList.setFocus();
|
||||
return rc;
|
||||
}
|
||||
|
@ -544,62 +622,33 @@ public class CPathIncludeSymbolEntryPage extends CPathBasePage {
|
|||
/**
|
||||
*
|
||||
*/
|
||||
private boolean moveDown() {
|
||||
private boolean moveDown(CPElement element) {
|
||||
boolean rc = false;
|
||||
List selElements = fIncludeSymPathsList.getSelectedElements();
|
||||
List revSelElements = new ArrayList(selElements);
|
||||
Collections.reverse(revSelElements);
|
||||
for (Iterator i = revSelElements.iterator(); i.hasNext();) {
|
||||
CPElement elem = (CPElement)i.next();
|
||||
CPElementGroup parent = elem.getParent();
|
||||
CPElement[] children = parent.getChildren();
|
||||
for (int j = children.length - 1; j >= 0; --j) {
|
||||
CPElement child = children[j];
|
||||
if (elem.equals(child)) {
|
||||
int prevIndex = j + 1;
|
||||
int kind = element.getEntryKind();
|
||||
for (Iterator j = fIncludeSymPathsList.getElements().iterator(); j.hasNext();) {
|
||||
CPElementGroup group = (CPElementGroup)j.next();
|
||||
CPElement[] children = group.getChildren(kind);
|
||||
for (int k = children.length - 1; k >= 0; --k) {
|
||||
CPElement child = children[k];
|
||||
if (element.equals(child) || (child.getInherited() != null && child.getInherited().equals(element))) {
|
||||
int prevIndex = k + 1;
|
||||
if (prevIndex < children.length) {
|
||||
// swap the two
|
||||
children[j] = children[prevIndex];
|
||||
children[prevIndex] = elem;
|
||||
children[k] = children[prevIndex];
|
||||
children[prevIndex] = child;
|
||||
rc = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
parent.setChildren(children);
|
||||
group.setChildren(children);
|
||||
}
|
||||
fIncludeSymPathsList.refresh();
|
||||
fIncludeSymPathsList.postSetSelection(new StructuredSelection(selElements));
|
||||
fIncludeSymPathsList.selectElements(new StructuredSelection(element));
|
||||
fIncludeSymPathsList.setFocus();
|
||||
return rc;
|
||||
}
|
||||
|
||||
protected void ListPageDialogFieldChanged(DialogField field) {
|
||||
if (field == fShowInheritedPaths) {
|
||||
boolean showInherited = fShowInheritedPaths.isSelected();
|
||||
if (fFilter != null) {
|
||||
fIncludeSymPathsList.getTreeViewer().removeFilter(fFilter);
|
||||
}
|
||||
fFilter = new CPElementFilter(new int[]{-1, IPathEntry.CDT_INCLUDE, IPathEntry.CDT_MACRO, IPathEntry.CDT_CONTAINER},
|
||||
false, showInherited);
|
||||
fIncludeSymPathsList.getTreeViewer().addFilter(fFilter);
|
||||
fIncludeSymPathsList.refresh();
|
||||
}
|
||||
}
|
||||
|
||||
protected void ListPageSelectionChanged(TreeListDialogField field) {
|
||||
List selected = field.getSelectedElements();
|
||||
field.enableButton(IDX_REMOVE, canRemove(selected));
|
||||
field.enableButton(IDX_EDIT, canEdit(selected));
|
||||
field.enableButton(IDX_ADD_CONTRIBUTED, canAddPath(selected));
|
||||
field.enableButton(IDX_ADD_EXT_INCLUDE, canAddPath(selected));
|
||||
field.enableButton(IDX_ADD_WS_INCLUDE, canAddPath(selected));
|
||||
field.enableButton(IDX_ADD_SYMBOL, canAddPath(selected));
|
||||
field.enableButton(IDX_EXPORT, canExport(selected));
|
||||
field.enableButton(IDX_DOWN, canMoveDown(selected));
|
||||
field.enableButton(IDX_UP, canMoveUp(selected));
|
||||
}
|
||||
|
||||
private CPElementGroup getSelectedGroup() {
|
||||
List selected = fIncludeSymPathsList.getSelectedElements();
|
||||
if (!selected.isEmpty()) {
|
||||
|
@ -614,6 +663,34 @@ public class CPathIncludeSymbolEntryPage extends CPathBasePage {
|
|||
return null;
|
||||
}
|
||||
|
||||
protected void listPageDialogFieldChanged(DialogField field) {
|
||||
if (field == fShowInheritedPaths) {
|
||||
boolean showInherited = fShowInheritedPaths.isSelected();
|
||||
if (fFilter != null) {
|
||||
fIncludeSymPathsList.getTreeViewer().removeFilter(fFilter);
|
||||
}
|
||||
fFilter = new CPElementFilter(new int[]{-1, IPathEntry.CDT_INCLUDE, IPathEntry.CDT_MACRO, IPathEntry.CDT_CONTAINER},
|
||||
false, showInherited);
|
||||
fIncludeSymPathsList.getTreeViewer().addFilter(fFilter);
|
||||
fIncludeSymPathsList.refresh();
|
||||
}
|
||||
updateStatus();
|
||||
}
|
||||
|
||||
protected void listPageSelectionChanged(TreeListDialogField field) {
|
||||
List selected = field.getSelectedElements();
|
||||
field.enableButton(IDX_REMOVE, canRemove(selected));
|
||||
field.enableButton(IDX_EDIT, canEdit(selected));
|
||||
field.enableButton(IDX_ADD_CONTRIBUTED, canAddPath(selected));
|
||||
field.enableButton(IDX_ADD_EXT_INCLUDE, canAddPath(selected));
|
||||
field.enableButton(IDX_ADD_WS_INCLUDE, canAddPath(selected));
|
||||
field.enableButton(IDX_ADD_SYMBOL, canAddPath(selected));
|
||||
field.enableButton(IDX_EXPORT, canExport(selected));
|
||||
field.enableButton(IDX_DOWN, canMoveDown(selected));
|
||||
field.enableButton(IDX_UP, canMoveUp(selected));
|
||||
updateStatus(selected);
|
||||
}
|
||||
|
||||
protected void ListCustomButtonPressed(TreeListDialogField field, int index) {
|
||||
switch (index) {
|
||||
case IDX_ADD_FOLDER_FILE :
|
||||
|
@ -643,12 +720,12 @@ public class CPathIncludeSymbolEntryPage extends CPathBasePage {
|
|||
break;
|
||||
case IDX_DOWN :
|
||||
if (canMoveDown(field.getSelectedElements())) {
|
||||
moveDown();
|
||||
moveDown((CPElement)field.getSelectedElements().get(0));
|
||||
}
|
||||
break;
|
||||
case IDX_UP :
|
||||
if (canMoveUp(field.getSelectedElements())) {
|
||||
moveUp();
|
||||
moveUp((CPElement)field.getSelectedElements().get(0));
|
||||
}
|
||||
break;
|
||||
case IDX_EXPORT :
|
||||
|
@ -686,7 +763,7 @@ public class CPathIncludeSymbolEntryPage extends CPathBasePage {
|
|||
return currEntries;
|
||||
}
|
||||
|
||||
private void addNewPathResource() {
|
||||
protected void addNewPathResource() {
|
||||
Class[] acceptedClasses = new Class[]{ICProject.class, ICContainer.class, ITranslationUnit.class};
|
||||
TypedElementSelectionValidator validator = new TypedElementSelectionValidator(acceptedClasses, false);
|
||||
ViewerFilter filter = new TypedViewerFilter(acceptedClasses);
|
||||
|
@ -776,10 +853,10 @@ public class CPathIncludeSymbolEntryPage extends CPathBasePage {
|
|||
} else {
|
||||
newPath.setAttribute(CPElement.MACRO_NAME, name);
|
||||
newPath.setAttribute(CPElement.MACRO_VALUE, value);
|
||||
|
||||
if (!group.contains(newPath)) {
|
||||
addPathToResourceGroups(newPath, group, fIncludeSymPathsList.getElements());
|
||||
fIncludeSymPathsList.refresh();
|
||||
fIncludeSymPathsList.selectElements(new StructuredSelection(newPath));
|
||||
}
|
||||
updateStatus();
|
||||
}
|
||||
|
@ -810,12 +887,14 @@ public class CPathIncludeSymbolEntryPage extends CPathBasePage {
|
|||
newPath.setAttribute(CPElement.INCLUDE, new Path(newItem));
|
||||
if (!group.contains(newPath)) {
|
||||
addPathToResourceGroups(newPath, group, fIncludeSymPathsList.getElements());
|
||||
fIncludeSymPathsList.refresh();
|
||||
fIncludeSymPathsList.selectElements(new StructuredSelection(newPath));
|
||||
}
|
||||
} else {
|
||||
existing.setAttribute(CPElement.INCLUDE, new Path(newItem));
|
||||
updatePathOnResourceGroups(existing, fIncludeSymPathsList.getElements());
|
||||
fIncludeSymPathsList.refresh();
|
||||
}
|
||||
fIncludeSymPathsList.refresh();
|
||||
updateStatus();
|
||||
}
|
||||
}
|
||||
|
@ -831,7 +910,7 @@ public class CPathIncludeSymbolEntryPage extends CPathBasePage {
|
|||
if (!group.contains(curr)) {
|
||||
addPathToResourceGroups(curr, group, fIncludeSymPathsList.getElements());
|
||||
fIncludeSymPathsList.refresh();
|
||||
fIncludeSymPathsList.expandElement(getSelectedGroup(), 1);
|
||||
fIncludeSymPathsList.selectElements(new StructuredSelection(curr));
|
||||
updateStatus();
|
||||
}
|
||||
}
|
||||
|
@ -850,7 +929,7 @@ public class CPathIncludeSymbolEntryPage extends CPathBasePage {
|
|||
if (!group.contains(curr)) {
|
||||
addPathToResourceGroups(curr, getSelectedGroup(), fIncludeSymPathsList.getElements());
|
||||
fIncludeSymPathsList.refresh();
|
||||
fIncludeSymPathsList.expandElement(getSelectedGroup(), 1);
|
||||
fIncludeSymPathsList.selectElements(new StructuredSelection(curr));
|
||||
updateStatus();
|
||||
}
|
||||
}
|
||||
|
@ -939,7 +1018,7 @@ public class CPathIncludeSymbolEntryPage extends CPathBasePage {
|
|||
}
|
||||
return res;
|
||||
}
|
||||
return new CPElement[] {CPElement.createFromExisting(parent, fCurrCProject)};
|
||||
return new CPElement[]{CPElement.createFromExisting(parent, fCurrCProject)};
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -955,7 +1034,7 @@ public class CPathIncludeSymbolEntryPage extends CPathBasePage {
|
|||
super.createButtonsForButtonBar(parent);
|
||||
Button browse = createButton(parent, 3,
|
||||
CPathEntryMessages.getString("IncludeSymbolEntryPage.addExternal.button.browse"), //$NON-NLS-1$
|
||||
true); //$NON-NLS-1$
|
||||
false);
|
||||
browse.addSelectionListener(new SelectionAdapter() {
|
||||
|
||||
public void widgetSelected(SelectionEvent ev) {
|
||||
|
|
|
@ -16,13 +16,14 @@ import org.eclipse.cdt.internal.ui.dialogs.IStatusChangeListener;
|
|||
import org.eclipse.cdt.internal.ui.wizards.dialogfields.DialogField;
|
||||
import org.eclipse.cdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
|
||||
import org.eclipse.cdt.internal.ui.wizards.dialogfields.ListDialogField;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.jface.dialogs.Dialog;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Control;
|
||||
|
||||
public class CPathTabBlock extends AbstractPathOptionBlock {
|
||||
|
||||
private int[] pathTypes = { IPathEntry.CDT_SOURCE, IPathEntry.CDT_PROJECT, IPathEntry.CDT_OUTPUT, IPathEntry.CDT_LIBRARY,
|
||||
private int[] pathTypes = {IPathEntry.CDT_SOURCE, IPathEntry.CDT_PROJECT, IPathEntry.CDT_OUTPUT, IPathEntry.CDT_LIBRARY,
|
||||
IPathEntry.CDT_CONTAINER};
|
||||
private ListDialogField fCPathList;
|
||||
|
||||
|
@ -50,7 +51,7 @@ public class CPathTabBlock extends AbstractPathOptionBlock {
|
|||
public CPathTabBlock(IStatusChangeListener context, int pageToShow) {
|
||||
super(context, pageToShow);
|
||||
|
||||
String[] buttonLabels = new String[] { /* 0 */CPathEntryMessages.getString("CPathsBlock.path.up.button"), //$NON-NLS-1$
|
||||
String[] buttonLabels = new String[]{ /* 0 */CPathEntryMessages.getString("CPathsBlock.path.up.button"), //$NON-NLS-1$
|
||||
/* 1 */CPathEntryMessages.getString("CPathsBlock.path.down.button"), //$NON-NLS-1$
|
||||
/* 2 */null, /* 3 */CPathEntryMessages.getString("CPathsBlock.path.checkall.button"), //$NON-NLS-1$
|
||||
/* 4 */CPathEntryMessages.getString("CPathsBlock.path.uncheckall.button") //$NON-NLS-1$
|
||||
|
@ -97,7 +98,6 @@ public class CPathTabBlock extends AbstractPathOptionBlock {
|
|||
return control;
|
||||
}
|
||||
|
||||
|
||||
protected void initialize(ICElement element, List cPaths) {
|
||||
|
||||
fCPathList.setElements(cPaths);
|
||||
|
@ -114,7 +114,6 @@ public class CPathTabBlock extends AbstractPathOptionBlock {
|
|||
initializeTimeStamps();
|
||||
}
|
||||
|
||||
|
||||
protected int[] getFilteredTypes() {
|
||||
return pathTypes;
|
||||
}
|
||||
|
@ -127,29 +126,28 @@ public class CPathTabBlock extends AbstractPathOptionBlock {
|
|||
|
||||
List elements = fCPathList.getElements();
|
||||
|
||||
CPElement entryMissing = null;
|
||||
int nEntriesMissing = 0;
|
||||
CPElement entryError = null;
|
||||
int nErrorEntries = 0;
|
||||
IPathEntry[] entries = new IPathEntry[elements.size()];
|
||||
|
||||
for (int i = elements.size() - 1; i >= 0; i--) {
|
||||
CPElement currElement = (CPElement) elements.get(i);
|
||||
CPElement currElement = (CPElement)elements.get(i);
|
||||
|
||||
entries[i] = currElement.getPathEntry();
|
||||
if (currElement.isMissing()) {
|
||||
nEntriesMissing++;
|
||||
if (entryMissing == null) {
|
||||
entryMissing = currElement;
|
||||
if (currElement.getStatus().getSeverity() != IStatus.OK) {
|
||||
nErrorEntries++;
|
||||
if (entryError == null) {
|
||||
entryError = currElement;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (nEntriesMissing > 0) {
|
||||
if (nEntriesMissing == 1) {
|
||||
getPathStatus().setWarning(CPathEntryMessages.getFormattedString("CPathsBlock.warning.EntryMissing", //$NON-NLS-1$
|
||||
entryMissing.getPath().toString()));
|
||||
if (nErrorEntries > 0) {
|
||||
if (nErrorEntries == 1) {
|
||||
getPathStatus().setWarning(entryError.getStatus().getMessage());
|
||||
} else {
|
||||
getPathStatus().setWarning(CPathEntryMessages.getFormattedString("CPathsBlock.warning.EntriesMissing", //$NON-NLS-1$
|
||||
String.valueOf(nEntriesMissing)));
|
||||
getPathStatus().setWarning(CPathEntryMessages.getFormattedString("CPElement.status.multiplePathErrors", //$NON-NLS-1$
|
||||
String.valueOf(nErrorEntries)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -97,6 +97,8 @@ public class NewIncludesSymbolsTabBlock extends AbstractPathOptionBlock implemen
|
|||
case IStatus.WARNING :
|
||||
getPathStatus().setWarning(status.getMessage());
|
||||
break;
|
||||
default:
|
||||
getPathStatus().setOK();
|
||||
}
|
||||
updateBuildPathStatus();
|
||||
doStatusLineUpdate();
|
||||
|
|
Loading…
Add table
Reference in a new issue