mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-01 06:05:24 +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.IResource;
|
||||||
import org.eclipse.core.resources.IWorkspaceRoot;
|
import org.eclipse.core.resources.IWorkspaceRoot;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
|
import org.eclipse.core.runtime.IStatus;
|
||||||
import org.eclipse.core.runtime.Path;
|
import org.eclipse.core.runtime.Path;
|
||||||
|
import org.eclipse.core.runtime.Status;
|
||||||
|
|
||||||
public class CPElement {
|
public class CPElement {
|
||||||
|
|
||||||
|
@ -49,13 +51,13 @@ public class CPElement {
|
||||||
private final ArrayList fChildren = new ArrayList(1);
|
private final ArrayList fChildren = new ArrayList(1);
|
||||||
|
|
||||||
private boolean fIsExported;
|
private boolean fIsExported;
|
||||||
private boolean fIsMissing;
|
|
||||||
|
|
||||||
private IPathEntry fCachedEntry;
|
private IPathEntry fCachedEntry;
|
||||||
private CPElement Inherited; // used when the path is duplicated on a child
|
private CPElement Inherited; // used when the path is duplicated on a child
|
||||||
// resource but is inherited from a parent
|
// resource but is inherited from a parent
|
||||||
// resource
|
// resource these are not real path entries
|
||||||
// these are not real path entries
|
|
||||||
|
private IStatus fStatus;
|
||||||
|
|
||||||
// create a inherited element and apply to path/resource
|
// create a inherited element and apply to path/resource
|
||||||
public CPElement(CPElement element, IPath path, IResource res) {
|
public CPElement(CPElement element, IPath path, IResource res) {
|
||||||
|
@ -76,7 +78,6 @@ public class CPElement {
|
||||||
fResource = res;
|
fResource = res;
|
||||||
|
|
||||||
fIsExported = false;
|
fIsExported = false;
|
||||||
fIsMissing = false;
|
|
||||||
fCachedEntry = null;
|
fCachedEntry = null;
|
||||||
|
|
||||||
switch (entryKind) {
|
switch (entryKind) {
|
||||||
|
@ -357,6 +358,7 @@ public class CPElement {
|
||||||
|
|
||||||
private void attributeChanged(String key) {
|
private void attributeChanged(String key) {
|
||||||
fCachedEntry = null;
|
fCachedEntry = null;
|
||||||
|
fStatus = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -427,15 +429,91 @@ public class CPElement {
|
||||||
*
|
*
|
||||||
* @return Returns a boolean
|
* @return Returns a boolean
|
||||||
*/
|
*/
|
||||||
public boolean isMissing() {
|
public IStatus getStatus() {
|
||||||
return fIsMissing;
|
if (Inherited != null) {
|
||||||
|
return Inherited.getStatus();
|
||||||
}
|
}
|
||||||
|
if (fStatus == null) {
|
||||||
/**
|
fStatus = Status.OK_STATUS;
|
||||||
* Sets the 'missing' state of the entry.
|
IResource res = null;
|
||||||
*/
|
IPath path;
|
||||||
public void setIsMissing(boolean isMissing) {
|
IWorkspaceRoot root = CUIPlugin.getWorkspace().getRoot();
|
||||||
fIsMissing = isMissing;
|
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
|
// get the resource
|
||||||
IResource res = null;
|
IResource res = null;
|
||||||
boolean isMissing = false;
|
|
||||||
|
|
||||||
switch (curr.getEntryKind()) {
|
switch (curr.getEntryKind()) {
|
||||||
case IPathEntry.CDT_CONTAINER :
|
case IPathEntry.CDT_CONTAINER :
|
||||||
res = null;
|
res = null;
|
||||||
try {
|
|
||||||
isMissing = (CoreModel.getPathEntryContainer(path, project) == null);
|
|
||||||
} catch (CModelException e) {
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case IPathEntry.CDT_LIBRARY :
|
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();
|
library = ((ILibraryEntry)curr).getLibraryPath();
|
||||||
sourceAttachment = ((ILibraryEntry)curr).getSourceAttachmentPath();
|
sourceAttachment = ((ILibraryEntry)curr).getSourceAttachmentPath();
|
||||||
base = ((ILibraryEntry)curr).getBasePath();
|
base = ((ILibraryEntry)curr).getBasePath();
|
||||||
|
@ -518,7 +582,6 @@ public class CPElement {
|
||||||
if (root.getWorkspace().validatePath(path.toString(), IResource.FOLDER).isOK()) {
|
if (root.getWorkspace().validatePath(path.toString(), IResource.FOLDER).isOK()) {
|
||||||
res = root.getFolder(path);
|
res = root.getFolder(path);
|
||||||
}
|
}
|
||||||
isMissing = true;
|
|
||||||
}
|
}
|
||||||
exclusion = ((ISourceEntry)curr).getExclusionPatterns();
|
exclusion = ((ISourceEntry)curr).getExclusionPatterns();
|
||||||
break;
|
break;
|
||||||
|
@ -529,7 +592,6 @@ public class CPElement {
|
||||||
if (root.getWorkspace().validatePath(path.toString(), IResource.FOLDER).isOK()) {
|
if (root.getWorkspace().validatePath(path.toString(), IResource.FOLDER).isOK()) {
|
||||||
res = root.getFolder(path);
|
res = root.getFolder(path);
|
||||||
}
|
}
|
||||||
isMissing = true;
|
|
||||||
}
|
}
|
||||||
exclusion = ((IOutputEntry)curr).getExclusionPatterns();
|
exclusion = ((IOutputEntry)curr).getExclusionPatterns();
|
||||||
break;
|
break;
|
||||||
|
@ -541,9 +603,6 @@ public class CPElement {
|
||||||
res = root.getFolder(path);
|
res = root.getFolder(path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (res.getType() != IResource.ROOT && project != null) {
|
|
||||||
isMissing = !project.isOnSourceRoot(res);
|
|
||||||
}
|
|
||||||
exclusion = ((IIncludeEntry)curr).getExclusionPatterns();
|
exclusion = ((IIncludeEntry)curr).getExclusionPatterns();
|
||||||
sysInclude = ((IIncludeEntry)curr).isSystemInclude();
|
sysInclude = ((IIncludeEntry)curr).isSystemInclude();
|
||||||
baseRef = ((IIncludeEntry)curr).getBaseReference();
|
baseRef = ((IIncludeEntry)curr).getBaseReference();
|
||||||
|
@ -558,9 +617,6 @@ public class CPElement {
|
||||||
res = root.getFolder(path);
|
res = root.getFolder(path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (res.getType() != IResource.ROOT && project != null) {
|
|
||||||
isMissing = !project.isOnSourceRoot(res);
|
|
||||||
}
|
|
||||||
exclusion = ((IMacroEntry)curr).getExclusionPatterns();
|
exclusion = ((IMacroEntry)curr).getExclusionPatterns();
|
||||||
macroName = ((IMacroEntry)curr).getMacroName();
|
macroName = ((IMacroEntry)curr).getMacroName();
|
||||||
macroValue = ((IMacroEntry)curr).getMacroValue();
|
macroValue = ((IMacroEntry)curr).getMacroValue();
|
||||||
|
@ -569,7 +625,6 @@ public class CPElement {
|
||||||
break;
|
break;
|
||||||
case IPathEntry.CDT_PROJECT :
|
case IPathEntry.CDT_PROJECT :
|
||||||
res = root.findMember(path);
|
res = root.findMember(path);
|
||||||
isMissing = (res == null);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
CPElement elem = new CPElement(project, curr.getEntryKind(), path, res);
|
CPElement elem = new CPElement(project, curr.getEntryKind(), path, res);
|
||||||
|
@ -583,10 +638,6 @@ public class CPElement {
|
||||||
elem.setAttribute(BASE_REF, baseRef);
|
elem.setAttribute(BASE_REF, baseRef);
|
||||||
elem.setAttribute(BASE, base);
|
elem.setAttribute(BASE, base);
|
||||||
elem.setExported(curr.isExported());
|
elem.setExported(curr.isExported());
|
||||||
|
|
||||||
if (project != null && project.exists()) {
|
|
||||||
elem.setIsMissing(isMissing);
|
|
||||||
}
|
|
||||||
return elem;
|
return elem;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -10,7 +10,11 @@ package org.eclipse.cdt.internal.ui.dialogs.cpaths;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
|
@ -20,17 +24,19 @@ public class CPElementGroup {
|
||||||
private CPElement parent;
|
private CPElement parent;
|
||||||
private final int kind;
|
private final int kind;
|
||||||
private IResource resource;
|
private IResource resource;
|
||||||
private List children = new ArrayList(1);
|
private Map childrenListMap;
|
||||||
|
private List childrenList;
|
||||||
|
|
||||||
public CPElementGroup(IResource resource) {
|
public CPElementGroup(IResource resource) {
|
||||||
this.kind = -1;
|
this.kind = -1;
|
||||||
this.resource = resource;
|
this.resource = resource;
|
||||||
this.children = new ArrayList();
|
this.childrenListMap = new HashMap(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CPElementGroup(CPElement parent, int kind) {
|
public CPElementGroup(CPElement parent, int kind) {
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
this.kind = kind;
|
this.kind = kind;
|
||||||
|
this.childrenList = new ArrayList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IResource getResource() {
|
public IResource getResource() {
|
||||||
|
@ -66,10 +72,32 @@ public class CPElementGroup {
|
||||||
return hashCode + kind;
|
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) {
|
public void addChild(CPElement element) {
|
||||||
|
List children = getChildrenList(element.getEntryKind(), true);
|
||||||
int indx = children.indexOf(element);
|
int indx = children.indexOf(element);
|
||||||
if (indx == -1) {
|
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);
|
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);
|
CPElement other = (CPElement)children.get(indx);
|
||||||
|
@ -87,7 +115,13 @@ public class CPElementGroup {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setChildren(CPElement[] elements) {
|
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) {
|
public void addChildren(CPElement[] elements) {
|
||||||
|
@ -97,6 +131,10 @@ public class CPElementGroup {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean removeChild(CPElement element) {
|
public boolean removeChild(CPElement element) {
|
||||||
|
List children = getChildrenList(element.getEntryKind(), false);
|
||||||
|
if (children == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
boolean removed = children.remove(element);
|
boolean removed = children.remove(element);
|
||||||
if (removed) {
|
if (removed) {
|
||||||
element.setParent(null);
|
element.setParent(null);
|
||||||
|
@ -104,19 +142,42 @@ public class CPElementGroup {
|
||||||
return removed;
|
return removed;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CPElement[] getChildren() {
|
public CPElement[] getChildren(int kind) {
|
||||||
|
List children = getChildrenList(kind, true);
|
||||||
return (CPElement[])children.toArray(new CPElement[children.size()]);
|
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
|
* @param newPath
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean contains(CPElement newPath) {
|
public boolean contains(CPElement element) {
|
||||||
return children.contains(newPath);
|
List children = getChildrenList(element.getEntryKind(), false);
|
||||||
|
if (children == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return children.contains(element);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void replaceChild(CPElement element, CPElement replaceWith) {
|
public void replaceChild(CPElement element, CPElement replaceWith) {
|
||||||
|
List children = getChildrenList(element.getEntryKind(), false);
|
||||||
|
if (children == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
int idx = children.indexOf(element);
|
int idx = children.indexOf(element);
|
||||||
if (idx != -1) {
|
if (idx != -1) {
|
||||||
children.remove(idx);
|
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.cdt.ui.CUIPlugin;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
|
import org.eclipse.core.runtime.IStatus;
|
||||||
import org.eclipse.jface.resource.ImageDescriptor;
|
import org.eclipse.jface.resource.ImageDescriptor;
|
||||||
import org.eclipse.jface.viewers.IColorProvider;
|
import org.eclipse.jface.viewers.IColorProvider;
|
||||||
import org.eclipse.jface.viewers.LabelProvider;
|
import org.eclipse.jface.viewers.LabelProvider;
|
||||||
|
@ -137,8 +138,7 @@ class CPElementLabelProvider extends LabelProvider implements IColorProvider {
|
||||||
public String getCPElementText(CPElement cpentry) {
|
public String getCPElementText(CPElement cpentry) {
|
||||||
IPath path = cpentry.getPath();
|
IPath path = cpentry.getPath();
|
||||||
switch (cpentry.getEntryKind()) {
|
switch (cpentry.getEntryKind()) {
|
||||||
case IPathEntry.CDT_LIBRARY :
|
case IPathEntry.CDT_LIBRARY : {
|
||||||
{
|
|
||||||
IPath libPath = (IPath)cpentry.getAttribute(CPElement.LIBRARY);
|
IPath libPath = (IPath)cpentry.getAttribute(CPElement.LIBRARY);
|
||||||
StringBuffer str = new StringBuffer();
|
StringBuffer str = new StringBuffer();
|
||||||
addBaseString(libPath, cpentry, str);
|
addBaseString(libPath, cpentry, str);
|
||||||
|
@ -148,8 +148,7 @@ class CPElementLabelProvider extends LabelProvider implements IColorProvider {
|
||||||
}
|
}
|
||||||
case IPathEntry.CDT_PROJECT :
|
case IPathEntry.CDT_PROJECT :
|
||||||
return path.lastSegment();
|
return path.lastSegment();
|
||||||
case IPathEntry.CDT_INCLUDE :
|
case IPathEntry.CDT_INCLUDE : {
|
||||||
{
|
|
||||||
IPath incPath = ((IPath)cpentry.getAttribute(CPElement.INCLUDE));
|
IPath incPath = ((IPath)cpentry.getAttribute(CPElement.INCLUDE));
|
||||||
StringBuffer str = new StringBuffer();
|
StringBuffer str = new StringBuffer();
|
||||||
addBaseString(incPath, cpentry, str);
|
addBaseString(incPath, cpentry, str);
|
||||||
|
@ -157,8 +156,7 @@ class CPElementLabelProvider extends LabelProvider implements IColorProvider {
|
||||||
addParentInfo(cpentry, str);
|
addParentInfo(cpentry, str);
|
||||||
return str.toString();
|
return str.toString();
|
||||||
}
|
}
|
||||||
case IPathEntry.CDT_MACRO :
|
case IPathEntry.CDT_MACRO : {
|
||||||
{
|
|
||||||
StringBuffer str = new StringBuffer((String)cpentry.getAttribute(CPElement.MACRO_NAME) + "=" //$NON-NLS-1$
|
StringBuffer str = new StringBuffer((String)cpentry.getAttribute(CPElement.MACRO_NAME) + "=" //$NON-NLS-1$
|
||||||
+ (String)cpentry.getAttribute(CPElement.MACRO_VALUE));
|
+ (String)cpentry.getAttribute(CPElement.MACRO_VALUE));
|
||||||
addBaseString(null, cpentry, str);
|
addBaseString(null, cpentry, str);
|
||||||
|
@ -166,8 +164,7 @@ class CPElementLabelProvider extends LabelProvider implements IColorProvider {
|
||||||
addParentInfo(cpentry, str);
|
addParentInfo(cpentry, str);
|
||||||
return str.toString();
|
return str.toString();
|
||||||
}
|
}
|
||||||
case IPathEntry.CDT_CONTAINER :
|
case IPathEntry.CDT_CONTAINER : {
|
||||||
{
|
|
||||||
StringBuffer str = new StringBuffer(path.toString());
|
StringBuffer str = new StringBuffer(path.toString());
|
||||||
try {
|
try {
|
||||||
IPathEntryContainer container = CoreModel.getPathEntryContainer(cpentry.getPath(), cpentry.getCProject());
|
IPathEntryContainer container = CoreModel.getPathEntryContainer(cpentry.getPath(), cpentry.getCProject());
|
||||||
|
@ -181,13 +178,12 @@ class CPElementLabelProvider extends LabelProvider implements IColorProvider {
|
||||||
return str.toString();
|
return str.toString();
|
||||||
}
|
}
|
||||||
case IPathEntry.CDT_SOURCE :
|
case IPathEntry.CDT_SOURCE :
|
||||||
case IPathEntry.CDT_OUTPUT :
|
case IPathEntry.CDT_OUTPUT : {
|
||||||
{
|
|
||||||
StringBuffer buf = new StringBuffer(path.makeRelative().toString());
|
StringBuffer buf = new StringBuffer(path.makeRelative().toString());
|
||||||
IResource resource = cpentry.getResource();
|
IResource resource = cpentry.getResource();
|
||||||
if (resource != null && !resource.exists()) {
|
if (resource != null && !resource.exists()) {
|
||||||
buf.append(' ');
|
buf.append(' ');
|
||||||
if (cpentry.isMissing()) {
|
if (cpentry.getStatus().getSeverity() != IStatus.OK) { // only valid error for src/output would missing path...
|
||||||
buf.append(fCreateLabel);
|
buf.append(fCreateLabel);
|
||||||
} else {
|
} else {
|
||||||
buf.append(fNewLabel);
|
buf.append(fNewLabel);
|
||||||
|
@ -321,8 +317,13 @@ class CPElementLabelProvider extends LabelProvider implements IColorProvider {
|
||||||
CPElement cpentry = (CPElement)element;
|
CPElement cpentry = (CPElement)element;
|
||||||
ImageDescriptor imageDescriptor = getCPElementBaseImage(cpentry);
|
ImageDescriptor imageDescriptor = getCPElementBaseImage(cpentry);
|
||||||
if (imageDescriptor != null) {
|
if (imageDescriptor != null) {
|
||||||
if (cpentry.isMissing()) {
|
switch (cpentry.getStatus().getSeverity()) {
|
||||||
|
case IStatus.WARNING :
|
||||||
imageDescriptor = new CPListImageDescriptor(imageDescriptor, CPListImageDescriptor.WARNING, SMALL_SIZE);
|
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) {
|
if (cpentry.getInherited() != null) {
|
||||||
imageDescriptor = new CPListImageDescriptor(imageDescriptor, CPListImageDescriptor.PATH_INHERIT, SMALL_SIZE);
|
imageDescriptor = new CPListImageDescriptor(imageDescriptor, CPListImageDescriptor.PATH_INHERIT, SMALL_SIZE);
|
||||||
|
@ -353,7 +354,9 @@ class CPElementLabelProvider extends LabelProvider implements IColorProvider {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
* @see org.eclipse.jface.viewers.IColorProvider#getForeground(java.lang.Object)
|
* @see org.eclipse.jface.viewers.IColorProvider#getForeground(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public Color getForeground(Object element) {
|
public Color getForeground(Object element) {
|
||||||
|
@ -365,7 +368,9 @@ class CPElementLabelProvider extends LabelProvider implements IColorProvider {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
* @see org.eclipse.jface.viewers.IColorProvider#getBackground(java.lang.Object)
|
* @see org.eclipse.jface.viewers.IColorProvider#getBackground(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public Color getBackground(Object element) {
|
public Color getBackground(Object element) {
|
||||||
|
|
|
@ -98,10 +98,17 @@ CPathsBlock.path.up.button=&Up
|
||||||
CPathsBlock.path.down.button=&Down
|
CPathsBlock.path.down.button=&Down
|
||||||
CPathsBlock.path.checkall.button=Select &All
|
CPathsBlock.path.checkall.button=Select &All
|
||||||
CPathsBlock.path.uncheckall.button=D&eselect 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...
|
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-------
|
||||||
SourcePathEntryPage.title=&Source
|
SourcePathEntryPage.title=&Source
|
||||||
SourcePathEntryPage.description=Source Path for project
|
SourcePathEntryPage.description=Source Path for project
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
package org.eclipse.cdt.internal.ui.dialogs.cpaths;
|
package org.eclipse.cdt.internal.ui.dialogs.cpaths;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Arrays;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
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.SelectionAdapter;
|
||||||
import org.eclipse.swt.events.SelectionEvent;
|
import org.eclipse.swt.events.SelectionEvent;
|
||||||
import org.eclipse.swt.graphics.Image;
|
import org.eclipse.swt.graphics.Image;
|
||||||
|
import org.eclipse.swt.layout.GridData;
|
||||||
import org.eclipse.swt.widgets.Button;
|
import org.eclipse.swt.widgets.Button;
|
||||||
import org.eclipse.swt.widgets.Composite;
|
import org.eclipse.swt.widgets.Composite;
|
||||||
import org.eclipse.swt.widgets.DirectoryDialog;
|
import org.eclipse.swt.widgets.DirectoryDialog;
|
||||||
|
@ -96,8 +97,8 @@ public class CPathIncludeSymbolEntryPage extends CPathBasePage {
|
||||||
null,
|
null,
|
||||||
/* 12 */CPathEntryMessages.getString("IncludeSymbolEntryPage.export"), //$NON-NLS-1$
|
/* 12 */CPathEntryMessages.getString("IncludeSymbolEntryPage.export"), //$NON-NLS-1$
|
||||||
null,
|
null,
|
||||||
/* 14 */CPathEntryMessages.getString("IncludeSymbolEntryPage.down"), //$NON-NLS-1$
|
/* 14 */CPathEntryMessages.getString("IncludeSymbolEntryPage.up"), //$NON-NLS-1$
|
||||||
/* 15 */CPathEntryMessages.getString("IncludeSymbolEntryPage.up")}; //$NON-NLS-1$
|
/* 15 */CPathEntryMessages.getString("IncludeSymbolEntryPage.down")}; //$NON-NLS-1$
|
||||||
private CPElementGroup fProjectGroup;
|
private CPElementGroup fProjectGroup;
|
||||||
|
|
||||||
private class IncludeSymbolAdapter implements IDialogFieldListener, ITreeListAdapter {
|
private class IncludeSymbolAdapter implements IDialogFieldListener, ITreeListAdapter {
|
||||||
|
@ -110,7 +111,7 @@ public class CPathIncludeSymbolEntryPage extends CPathBasePage {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void selectionChanged(TreeListDialogField field) {
|
public void selectionChanged(TreeListDialogField field) {
|
||||||
ListPageSelectionChanged(field);
|
listPageSelectionChanged(field);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void doubleClicked(TreeListDialogField field) {
|
public void doubleClicked(TreeListDialogField field) {
|
||||||
|
@ -152,8 +153,7 @@ public class CPathIncludeSymbolEntryPage extends CPathBasePage {
|
||||||
// ---------- IDialogFieldListener --------
|
// ---------- IDialogFieldListener --------
|
||||||
|
|
||||||
public void dialogFieldChanged(DialogField field) {
|
public void dialogFieldChanged(DialogField field) {
|
||||||
ListPageDialogFieldChanged(field);
|
listPageDialogFieldChanged(field);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -192,6 +192,7 @@ public class CPathIncludeSymbolEntryPage extends CPathBasePage {
|
||||||
PixelConverter converter = new PixelConverter(parent);
|
PixelConverter converter = new PixelConverter(parent);
|
||||||
|
|
||||||
Composite composite = new Composite(parent, SWT.NONE);
|
Composite composite = new Composite(parent, SWT.NONE);
|
||||||
|
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
|
||||||
|
|
||||||
LayoutUtil.doDefaultLayout(composite, new DialogField[]{fIncludeSymPathsList, fShowInheritedPaths}, true);
|
LayoutUtil.doDefaultLayout(composite, new DialogField[]{fIncludeSymPathsList, fShowInheritedPaths}, true);
|
||||||
LayoutUtil.setHorizontalGrabbing(fIncludeSymPathsList.getTreeControl(null));
|
LayoutUtil.setHorizontalGrabbing(fIncludeSymPathsList.getTreeControl(null));
|
||||||
|
@ -200,7 +201,6 @@ public class CPathIncludeSymbolEntryPage extends CPathBasePage {
|
||||||
fIncludeSymPathsList.setButtonsMinWidth(buttonBarWidth);
|
fIncludeSymPathsList.setButtonsMinWidth(buttonBarWidth);
|
||||||
setControl(composite);
|
setControl(composite);
|
||||||
fIncludeSymPathsList.getTreeViewer().addFilter(fFilter);
|
fIncludeSymPathsList.getTreeViewer().addFilter(fFilter);
|
||||||
fIncludeSymPathsList.getTreeViewer().setSorter(new CPElementSorter());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Image getImage() {
|
public Image getImage() {
|
||||||
|
@ -211,37 +211,55 @@ public class CPathIncludeSymbolEntryPage extends CPathBasePage {
|
||||||
fCurrCProject = cproject;
|
fCurrCProject = cproject;
|
||||||
List elements = createGroups(cPaths);
|
List elements = createGroups(cPaths);
|
||||||
fIncludeSymPathsList.setElements(elements);
|
fIncludeSymPathsList.setElements(elements);
|
||||||
|
updateStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateStatus() {
|
private void updateStatus() {
|
||||||
CPElement entryMissing = null;
|
CPElement entryError = null;
|
||||||
int nEntriesMissing = 0;
|
int nErrorEntries = 0;
|
||||||
IStatus status = Status.OK_STATUS;
|
IStatus status = Status.OK_STATUS;
|
||||||
List elements = getCPaths();
|
List elements = getCPaths();
|
||||||
for (int i = elements.size() - 1; i >= 0; i--) {
|
for (int i = elements.size() - 1; i >= 0; i--) {
|
||||||
CPElement currElement = (CPElement)elements.get(i);
|
CPElement currElement = (CPElement)elements.get(i);
|
||||||
if (currElement.isMissing()) {
|
if (currElement.getStatus().getSeverity() != IStatus.OK) {
|
||||||
nEntriesMissing++;
|
nErrorEntries++;
|
||||||
if (entryMissing == null) {
|
if (entryError == null) {
|
||||||
entryMissing = currElement;
|
entryError = currElement;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nEntriesMissing > 0) {
|
if (nErrorEntries > 0) {
|
||||||
if (nEntriesMissing == 1) {
|
if (nErrorEntries == 1) {
|
||||||
status = new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, -1, CPathEntryMessages.getFormattedString(
|
status = entryError.getStatus();
|
||||||
"CPathsBlock.warning.EntryMissing", //$NON-NLS-1$
|
|
||||||
entryMissing.getPath().toString()), null);
|
|
||||||
} else {
|
} else {
|
||||||
status = new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, -1, CPathEntryMessages.getFormattedString(
|
status = new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, -1, CPathEntryMessages.getFormattedString(
|
||||||
"CPathsBlock.warning.EntriesMissing", //$NON-NLS-1$
|
"CPElement.status.multiplePathErrors", //$NON-NLS-1$
|
||||||
String.valueOf(nEntriesMissing)), null);
|
String.valueOf(nErrorEntries)), null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fContext.statusChanged(status);
|
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) {
|
private List createGroups(List cPaths) {
|
||||||
// create resource groups
|
// create resource groups
|
||||||
List resourceGroups = new ArrayList(5);
|
List resourceGroups = new ArrayList(5);
|
||||||
|
@ -286,8 +304,26 @@ public class CPathIncludeSymbolEntryPage extends CPathBasePage {
|
||||||
&& resPath.isPrefixOf(group.getPath())
|
&& resPath.isPrefixOf(group.getPath())
|
||||||
&& (resPath.equals(group.getPath()) || !CoreModelUtil.isExcludedPath(
|
&& (resPath.equals(group.getPath()) || !CoreModelUtil.isExcludedPath(
|
||||||
group.getResource().getFullPath().removeFirstSegments(resPath.segmentCount()), exclusions))) {
|
group.getResource().getFullPath().removeFirstSegments(resPath.segmentCount()), exclusions))) {
|
||||||
|
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()));
|
group.addChild(new CPElement(element, group.getPath(), group.getResource()));
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
group.addChild(new CPElement(element, group.getPath(), group.getResource()));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addPathToResourceGroups(CPElement element, CPElementGroup parent, List groups) {
|
private void addPathToResourceGroups(CPElement element, CPElementGroup parent, List groups) {
|
||||||
|
@ -308,11 +344,12 @@ public class CPathIncludeSymbolEntryPage extends CPathBasePage {
|
||||||
CPElementGroup group = (CPElementGroup)groups.get(i);
|
CPElementGroup group = (CPElementGroup)groups.get(i);
|
||||||
if (group != parent) {
|
if (group != parent) {
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
CPElement[] elements = group.getChildren();
|
CPElement[] elements = group.getChildren(element.getEntryKind());
|
||||||
for (int j = 0; j < elements.length; j++) {
|
for (int j = 0; j < elements.length; j++) {
|
||||||
if (elements[j].getInherited() == element) {
|
if (elements[j].getInherited() == element) {
|
||||||
found = true;
|
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()));
|
group.replaceChild(elements[j], new CPElement(element, group.getPath(), group.getResource()));
|
||||||
} else {
|
} else {
|
||||||
group.removeChild(elements[j]);
|
group.removeChild(elements[j]);
|
||||||
|
@ -343,7 +380,7 @@ public class CPathIncludeSymbolEntryPage extends CPathBasePage {
|
||||||
// remove all inherited
|
// remove all inherited
|
||||||
for (int i = 0; i < groups.size(); i++) {
|
for (int i = 0; i < groups.size(); i++) {
|
||||||
CPElementGroup group = (CPElementGroup)groups.get(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++) {
|
for (int j = 0; j < elements.length; j++) {
|
||||||
if (elements[j].getInherited() == element) {
|
if (elements[j].getInherited() == element) {
|
||||||
group.removeChild(elements[j]);
|
group.removeChild(elements[j]);
|
||||||
|
@ -387,10 +424,13 @@ public class CPathIncludeSymbolEntryPage extends CPathBasePage {
|
||||||
List selected = getSelection();
|
List selected = getSelection();
|
||||||
Object elem = selected.get(0);
|
Object elem = selected.get(0);
|
||||||
if (elem instanceof CPElement) {
|
if (elem instanceof CPElement) {
|
||||||
if (removePathFromResourceGroups((CPElement)elem, fIncludeSymPathsList.getElements()) == null) {
|
CPElement element = (CPElement)elem;
|
||||||
updatePathOnResourceGroups(((CPElement)elem).getInherited(), fIncludeSymPathsList.getElements());
|
CPElementGroup parent = element.getParent();
|
||||||
|
if (removePathFromResourceGroups(element, fIncludeSymPathsList.getElements()) == null) {
|
||||||
|
updatePathOnResourceGroups( element.getInherited(), fIncludeSymPathsList.getElements());
|
||||||
}
|
}
|
||||||
fIncludeSymPathsList.refresh();
|
fIncludeSymPathsList.refresh();
|
||||||
|
fIncludeSymPathsList.selectElements(new StructuredSelection(parent));
|
||||||
} else if (elem instanceof CPElementAttribute) {
|
} else if (elem instanceof CPElementAttribute) {
|
||||||
CPElementAttribute attrib = (CPElementAttribute)elem;
|
CPElementAttribute attrib = (CPElementAttribute)elem;
|
||||||
String key = attrib.getKey();
|
String key = attrib.getKey();
|
||||||
|
@ -505,38 +545,76 @@ public class CPathIncludeSymbolEntryPage extends CPathBasePage {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean canMoveUp(List element) {
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (elem.getParentContainer() != null || elem.getInherited() != null) {
|
||||||
private boolean canMoveDown(List element) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
private boolean moveUp() {
|
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 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;
|
boolean rc = false;
|
||||||
List selElements = fIncludeSymPathsList.getSelectedElements();
|
int kind = element.getEntryKind();
|
||||||
for (Iterator i = selElements.iterator(); i.hasNext();) {
|
for (Iterator j = fIncludeSymPathsList.getElements().iterator(); j.hasNext();) {
|
||||||
CPElement elem = (CPElement)i.next();
|
CPElementGroup group = (CPElementGroup)j.next();
|
||||||
CPElementGroup parent = elem.getParent();
|
CPElement[] children = group.getChildren(kind);
|
||||||
CPElement[] children = parent.getChildren();
|
for (int k = 0; k < children.length; ++k) {
|
||||||
for (int j = 0; j < children.length; ++j) {
|
CPElement child = children[k];
|
||||||
CPElement child = children[j];
|
if (element.equals(child) || (child.getInherited() != null && child.getInherited().equals(element))) {
|
||||||
if (elem.equals(child)) {
|
if (child.getInherited() != null && k > 0 && children[k - 1].getInherited() == null) {
|
||||||
int prevIndex = j - 1;
|
break;
|
||||||
|
}
|
||||||
|
int prevIndex = k - 1;
|
||||||
if (prevIndex >= 0) {
|
if (prevIndex >= 0) {
|
||||||
// swap the two
|
// swap the two
|
||||||
children[j] = children[prevIndex];
|
children[k] = children[prevIndex];
|
||||||
children[prevIndex] = elem;
|
children[prevIndex] = child;
|
||||||
rc = true;
|
rc = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
parent.setChildren(children);
|
group.setChildren(children);
|
||||||
}
|
}
|
||||||
fIncludeSymPathsList.refresh();
|
fIncludeSymPathsList.refresh();
|
||||||
fIncludeSymPathsList.postSetSelection(new StructuredSelection(selElements));
|
fIncludeSymPathsList.selectElements(new StructuredSelection(element));
|
||||||
fIncludeSymPathsList.setFocus();
|
fIncludeSymPathsList.setFocus();
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
@ -544,62 +622,33 @@ public class CPathIncludeSymbolEntryPage extends CPathBasePage {
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private boolean moveDown() {
|
private boolean moveDown(CPElement element) {
|
||||||
boolean rc = false;
|
boolean rc = false;
|
||||||
List selElements = fIncludeSymPathsList.getSelectedElements();
|
int kind = element.getEntryKind();
|
||||||
List revSelElements = new ArrayList(selElements);
|
for (Iterator j = fIncludeSymPathsList.getElements().iterator(); j.hasNext();) {
|
||||||
Collections.reverse(revSelElements);
|
CPElementGroup group = (CPElementGroup)j.next();
|
||||||
for (Iterator i = revSelElements.iterator(); i.hasNext();) {
|
CPElement[] children = group.getChildren(kind);
|
||||||
CPElement elem = (CPElement)i.next();
|
for (int k = children.length - 1; k >= 0; --k) {
|
||||||
CPElementGroup parent = elem.getParent();
|
CPElement child = children[k];
|
||||||
CPElement[] children = parent.getChildren();
|
if (element.equals(child) || (child.getInherited() != null && child.getInherited().equals(element))) {
|
||||||
for (int j = children.length - 1; j >= 0; --j) {
|
int prevIndex = k + 1;
|
||||||
CPElement child = children[j];
|
|
||||||
if (elem.equals(child)) {
|
|
||||||
int prevIndex = j + 1;
|
|
||||||
if (prevIndex < children.length) {
|
if (prevIndex < children.length) {
|
||||||
// swap the two
|
// swap the two
|
||||||
children[j] = children[prevIndex];
|
children[k] = children[prevIndex];
|
||||||
children[prevIndex] = elem;
|
children[prevIndex] = child;
|
||||||
rc = true;
|
rc = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
parent.setChildren(children);
|
group.setChildren(children);
|
||||||
}
|
}
|
||||||
fIncludeSymPathsList.refresh();
|
fIncludeSymPathsList.refresh();
|
||||||
fIncludeSymPathsList.postSetSelection(new StructuredSelection(selElements));
|
fIncludeSymPathsList.selectElements(new StructuredSelection(element));
|
||||||
fIncludeSymPathsList.setFocus();
|
fIncludeSymPathsList.setFocus();
|
||||||
return rc;
|
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() {
|
private CPElementGroup getSelectedGroup() {
|
||||||
List selected = fIncludeSymPathsList.getSelectedElements();
|
List selected = fIncludeSymPathsList.getSelectedElements();
|
||||||
if (!selected.isEmpty()) {
|
if (!selected.isEmpty()) {
|
||||||
|
@ -614,6 +663,34 @@ public class CPathIncludeSymbolEntryPage extends CPathBasePage {
|
||||||
return null;
|
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) {
|
protected void ListCustomButtonPressed(TreeListDialogField field, int index) {
|
||||||
switch (index) {
|
switch (index) {
|
||||||
case IDX_ADD_FOLDER_FILE :
|
case IDX_ADD_FOLDER_FILE :
|
||||||
|
@ -643,12 +720,12 @@ public class CPathIncludeSymbolEntryPage extends CPathBasePage {
|
||||||
break;
|
break;
|
||||||
case IDX_DOWN :
|
case IDX_DOWN :
|
||||||
if (canMoveDown(field.getSelectedElements())) {
|
if (canMoveDown(field.getSelectedElements())) {
|
||||||
moveDown();
|
moveDown((CPElement)field.getSelectedElements().get(0));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case IDX_UP :
|
case IDX_UP :
|
||||||
if (canMoveUp(field.getSelectedElements())) {
|
if (canMoveUp(field.getSelectedElements())) {
|
||||||
moveUp();
|
moveUp((CPElement)field.getSelectedElements().get(0));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case IDX_EXPORT :
|
case IDX_EXPORT :
|
||||||
|
@ -686,7 +763,7 @@ public class CPathIncludeSymbolEntryPage extends CPathBasePage {
|
||||||
return currEntries;
|
return currEntries;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addNewPathResource() {
|
protected void addNewPathResource() {
|
||||||
Class[] acceptedClasses = new Class[]{ICProject.class, ICContainer.class, ITranslationUnit.class};
|
Class[] acceptedClasses = new Class[]{ICProject.class, ICContainer.class, ITranslationUnit.class};
|
||||||
TypedElementSelectionValidator validator = new TypedElementSelectionValidator(acceptedClasses, false);
|
TypedElementSelectionValidator validator = new TypedElementSelectionValidator(acceptedClasses, false);
|
||||||
ViewerFilter filter = new TypedViewerFilter(acceptedClasses);
|
ViewerFilter filter = new TypedViewerFilter(acceptedClasses);
|
||||||
|
@ -776,10 +853,10 @@ public class CPathIncludeSymbolEntryPage extends CPathBasePage {
|
||||||
} else {
|
} else {
|
||||||
newPath.setAttribute(CPElement.MACRO_NAME, name);
|
newPath.setAttribute(CPElement.MACRO_NAME, name);
|
||||||
newPath.setAttribute(CPElement.MACRO_VALUE, value);
|
newPath.setAttribute(CPElement.MACRO_VALUE, value);
|
||||||
|
|
||||||
if (!group.contains(newPath)) {
|
if (!group.contains(newPath)) {
|
||||||
addPathToResourceGroups(newPath, group, fIncludeSymPathsList.getElements());
|
addPathToResourceGroups(newPath, group, fIncludeSymPathsList.getElements());
|
||||||
fIncludeSymPathsList.refresh();
|
fIncludeSymPathsList.refresh();
|
||||||
|
fIncludeSymPathsList.selectElements(new StructuredSelection(newPath));
|
||||||
}
|
}
|
||||||
updateStatus();
|
updateStatus();
|
||||||
}
|
}
|
||||||
|
@ -810,12 +887,14 @@ public class CPathIncludeSymbolEntryPage extends CPathBasePage {
|
||||||
newPath.setAttribute(CPElement.INCLUDE, new Path(newItem));
|
newPath.setAttribute(CPElement.INCLUDE, new Path(newItem));
|
||||||
if (!group.contains(newPath)) {
|
if (!group.contains(newPath)) {
|
||||||
addPathToResourceGroups(newPath, group, fIncludeSymPathsList.getElements());
|
addPathToResourceGroups(newPath, group, fIncludeSymPathsList.getElements());
|
||||||
|
fIncludeSymPathsList.refresh();
|
||||||
|
fIncludeSymPathsList.selectElements(new StructuredSelection(newPath));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
existing.setAttribute(CPElement.INCLUDE, new Path(newItem));
|
existing.setAttribute(CPElement.INCLUDE, new Path(newItem));
|
||||||
updatePathOnResourceGroups(existing, fIncludeSymPathsList.getElements());
|
updatePathOnResourceGroups(existing, fIncludeSymPathsList.getElements());
|
||||||
}
|
|
||||||
fIncludeSymPathsList.refresh();
|
fIncludeSymPathsList.refresh();
|
||||||
|
}
|
||||||
updateStatus();
|
updateStatus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -831,7 +910,7 @@ public class CPathIncludeSymbolEntryPage extends CPathBasePage {
|
||||||
if (!group.contains(curr)) {
|
if (!group.contains(curr)) {
|
||||||
addPathToResourceGroups(curr, group, fIncludeSymPathsList.getElements());
|
addPathToResourceGroups(curr, group, fIncludeSymPathsList.getElements());
|
||||||
fIncludeSymPathsList.refresh();
|
fIncludeSymPathsList.refresh();
|
||||||
fIncludeSymPathsList.expandElement(getSelectedGroup(), 1);
|
fIncludeSymPathsList.selectElements(new StructuredSelection(curr));
|
||||||
updateStatus();
|
updateStatus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -850,7 +929,7 @@ public class CPathIncludeSymbolEntryPage extends CPathBasePage {
|
||||||
if (!group.contains(curr)) {
|
if (!group.contains(curr)) {
|
||||||
addPathToResourceGroups(curr, getSelectedGroup(), fIncludeSymPathsList.getElements());
|
addPathToResourceGroups(curr, getSelectedGroup(), fIncludeSymPathsList.getElements());
|
||||||
fIncludeSymPathsList.refresh();
|
fIncludeSymPathsList.refresh();
|
||||||
fIncludeSymPathsList.expandElement(getSelectedGroup(), 1);
|
fIncludeSymPathsList.selectElements(new StructuredSelection(curr));
|
||||||
updateStatus();
|
updateStatus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -955,7 +1034,7 @@ public class CPathIncludeSymbolEntryPage extends CPathBasePage {
|
||||||
super.createButtonsForButtonBar(parent);
|
super.createButtonsForButtonBar(parent);
|
||||||
Button browse = createButton(parent, 3,
|
Button browse = createButton(parent, 3,
|
||||||
CPathEntryMessages.getString("IncludeSymbolEntryPage.addExternal.button.browse"), //$NON-NLS-1$
|
CPathEntryMessages.getString("IncludeSymbolEntryPage.addExternal.button.browse"), //$NON-NLS-1$
|
||||||
true); //$NON-NLS-1$
|
false);
|
||||||
browse.addSelectionListener(new SelectionAdapter() {
|
browse.addSelectionListener(new SelectionAdapter() {
|
||||||
|
|
||||||
public void widgetSelected(SelectionEvent ev) {
|
public void widgetSelected(SelectionEvent ev) {
|
||||||
|
|
|
@ -16,6 +16,7 @@ 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.DialogField;
|
||||||
import org.eclipse.cdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
|
import org.eclipse.cdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
|
||||||
import org.eclipse.cdt.internal.ui.wizards.dialogfields.ListDialogField;
|
import org.eclipse.cdt.internal.ui.wizards.dialogfields.ListDialogField;
|
||||||
|
import org.eclipse.core.runtime.IStatus;
|
||||||
import org.eclipse.jface.dialogs.Dialog;
|
import org.eclipse.jface.dialogs.Dialog;
|
||||||
import org.eclipse.swt.widgets.Composite;
|
import org.eclipse.swt.widgets.Composite;
|
||||||
import org.eclipse.swt.widgets.Control;
|
import org.eclipse.swt.widgets.Control;
|
||||||
|
@ -97,7 +98,6 @@ public class CPathTabBlock extends AbstractPathOptionBlock {
|
||||||
return control;
|
return control;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected void initialize(ICElement element, List cPaths) {
|
protected void initialize(ICElement element, List cPaths) {
|
||||||
|
|
||||||
fCPathList.setElements(cPaths);
|
fCPathList.setElements(cPaths);
|
||||||
|
@ -114,7 +114,6 @@ public class CPathTabBlock extends AbstractPathOptionBlock {
|
||||||
initializeTimeStamps();
|
initializeTimeStamps();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected int[] getFilteredTypes() {
|
protected int[] getFilteredTypes() {
|
||||||
return pathTypes;
|
return pathTypes;
|
||||||
}
|
}
|
||||||
|
@ -127,29 +126,28 @@ public class CPathTabBlock extends AbstractPathOptionBlock {
|
||||||
|
|
||||||
List elements = fCPathList.getElements();
|
List elements = fCPathList.getElements();
|
||||||
|
|
||||||
CPElement entryMissing = null;
|
CPElement entryError = null;
|
||||||
int nEntriesMissing = 0;
|
int nErrorEntries = 0;
|
||||||
IPathEntry[] entries = new IPathEntry[elements.size()];
|
IPathEntry[] entries = new IPathEntry[elements.size()];
|
||||||
|
|
||||||
for (int i = elements.size() - 1; i >= 0; i--) {
|
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();
|
entries[i] = currElement.getPathEntry();
|
||||||
if (currElement.isMissing()) {
|
if (currElement.getStatus().getSeverity() != IStatus.OK) {
|
||||||
nEntriesMissing++;
|
nErrorEntries++;
|
||||||
if (entryMissing == null) {
|
if (entryError == null) {
|
||||||
entryMissing = currElement;
|
entryError = currElement;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nEntriesMissing > 0) {
|
if (nErrorEntries > 0) {
|
||||||
if (nEntriesMissing == 1) {
|
if (nErrorEntries == 1) {
|
||||||
getPathStatus().setWarning(CPathEntryMessages.getFormattedString("CPathsBlock.warning.EntryMissing", //$NON-NLS-1$
|
getPathStatus().setWarning(entryError.getStatus().getMessage());
|
||||||
entryMissing.getPath().toString()));
|
|
||||||
} else {
|
} else {
|
||||||
getPathStatus().setWarning(CPathEntryMessages.getFormattedString("CPathsBlock.warning.EntriesMissing", //$NON-NLS-1$
|
getPathStatus().setWarning(CPathEntryMessages.getFormattedString("CPElement.status.multiplePathErrors", //$NON-NLS-1$
|
||||||
String.valueOf(nEntriesMissing)));
|
String.valueOf(nErrorEntries)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -97,6 +97,8 @@ public class NewIncludesSymbolsTabBlock extends AbstractPathOptionBlock implemen
|
||||||
case IStatus.WARNING :
|
case IStatus.WARNING :
|
||||||
getPathStatus().setWarning(status.getMessage());
|
getPathStatus().setWarning(status.getMessage());
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
getPathStatus().setOK();
|
||||||
}
|
}
|
||||||
updateBuildPathStatus();
|
updateBuildPathStatus();
|
||||||
doStatusLineUpdate();
|
doStatusLineUpdate();
|
||||||
|
|
Loading…
Add table
Reference in a new issue